:root {
  --ink: #160d20;
  --muted: #6e6174;
  --cream: #fff6e8;
  --paper: #fffaf2;
  --purple: #5c176f;
  --plum: #30113f;
  --gold: #ffd45b;
  --amber: #ef8f4e;
  --teal: #1d8a84;
  --line: rgba(92, 23, 111, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: linear-gradient(180deg, #160d20 0, #2e123c 230px, var(--cream) 231px);
}

button,
a {
  font: inherit;
}

.games-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(14px, 4vw, 38px);
  color: #fff;
  background: rgba(22, 9, 32, 0.82);
  border-bottom: 1px solid rgba(255, 212, 91, 0.28);
  backdrop-filter: blur(14px);
}

.games-brand,
.games-back-link {
  color: inherit;
  text-decoration: none;
}

.games-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 950;
}

.games-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.games-brand b {
  color: var(--gold);
}

.games-back-link {
  display: inline-grid;
  min-height: 40px;
  padding: 0 18px;
  place-items: center;
  color: #2a1732;
  font-weight: 900;
  background: linear-gradient(180deg, #fff2a8, var(--gold) 55%, #f29d53);
  border: 1px solid rgba(255, 238, 172, 0.78);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(239, 143, 78, 0.26);
}

main {
  padding-bottom: 56px;
}

.games-hero {
  position: relative;
  min-height: clamp(360px, 55vw, 560px);
  overflow: hidden;
  display: grid;
  align-items: end;
  border-bottom: 1px solid rgba(255, 212, 91, 0.34);
}

.games-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.games-hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(22, 9, 32, 0.84), rgba(22, 9, 32, 0.22) 54%, rgba(22, 9, 32, 0.52)),
    linear-gradient(0deg, rgba(22, 9, 32, 0.76), transparent 42%);
}

.games-hero-copy {
  position: relative;
  z-index: 1;
  width: min(100% - 28px, 1120px);
  margin: 0 auto;
  padding: 0 0 clamp(30px, 7vw, 74px);
  color: #fff;
}

.games-hero-copy p,
.games-hero-copy h1,
.games-hero-copy span {
  margin: 0;
}

.games-hero-copy p,
.game-card > p,
#game-kicker {
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.games-hero-copy h1 {
  max-width: 760px;
  margin-top: 8px;
  font-size: clamp(42px, 8vw, 86px);
  line-height: 0.96;
}

.games-hero-copy span {
  display: block;
  max-width: 540px;
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(17px, 2.2vw, 22px);
  font-weight: 750;
}

.games-grid {
  width: min(100% - 28px, 1120px);
  margin: -34px auto 26px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.game-card {
  display: grid;
  align-content: start;
  min-height: 312px;
  padding: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(255, 212, 91, 0.72);
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(56, 18, 71, 0.16);
  cursor: pointer;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 22px 42px rgba(56, 18, 71, 0.22);
  outline: none;
}

.game-card > p,
.game-card h2,
.game-card > span {
  margin: 0;
}

.game-card h2 {
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

.game-card > span {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
}

.game-card button {
  align-self: end;
  min-height: 42px;
  margin-top: 18px;
  color: #fff;
  font-weight: 950;
  background: linear-gradient(135deg, var(--purple), #8f3494);
  border: 1px solid rgba(255, 212, 91, 0.44);
  border-radius: 8px;
  cursor: pointer;
}

.game-card-art {
  display: grid;
  height: 112px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(92, 23, 111, 0.14), rgba(29, 138, 132, 0.13)),
    #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-card-tic .game-card-art,
.game-card-memory .game-card-art {
  grid-template-columns: repeat(2, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 8px;
}

.game-card-tic .game-card-art span,
.game-card-memory .game-card-art span {
  width: 44px;
  height: 44px;
  background: #fff7d9;
  border: 2px solid rgba(92, 23, 111, 0.28);
  border-radius: 7px;
}

.game-card-tic .game-card-art span:nth-child(1)::before,
.game-card-tic .game-card-art span:nth-child(4)::before {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--purple);
  content: "X";
  font-size: 24px;
  font-weight: 950;
}

.game-card-tic .game-card-art span:nth-child(2)::before {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--teal);
  content: "O";
  font-size: 24px;
  font-weight: 950;
}

.game-card-memory .game-card-art span:nth-child(1),
.game-card-memory .game-card-art span:nth-child(4) {
  background: linear-gradient(135deg, #ffe291, #f19a54);
}

.game-card-catcher .game-card-art span {
  width: 72px;
  height: 72px;
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
  background: linear-gradient(180deg, #fff5a5, var(--gold) 52%, #f19a54);
  box-shadow: 0 10px 24px rgba(241, 154, 84, 0.36);
}

.game-card-number .game-card-art {
  grid-template-columns: repeat(3, 46px);
  gap: 8px;
}

.game-card-number .game-card-art span {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #fff;
  font-size: 22px;
  font-weight: 950;
  background: linear-gradient(135deg, var(--teal), #39a9a3);
  border-radius: 7px;
}

.game-panel {
  width: min(100% - 28px, 900px);
  margin: 0 auto;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(56, 18, 71, 0.13);
}

.game-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#game-kicker,
#game-title,
.game-status {
  margin: 0;
}

#game-title {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
}

.game-close,
.game-reset {
  min-height: 38px;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 900;
  background: #fff8e4;
  border: 1px solid rgba(92, 23, 111, 0.2);
  border-radius: 8px;
  cursor: pointer;
}

.game-status {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 800;
}

.game-stage {
  margin-top: 14px;
  display: grid;
  justify-items: center;
  gap: 14px;
  min-height: 280px;
  padding: 18px;
  background: linear-gradient(180deg, #fffaf3, #fff3dc);
  border: 1px solid rgba(92, 23, 111, 0.12);
  border-radius: 8px;
}

.game-board {
  display: grid;
  gap: 8px;
}

.tic-board {
  grid-template-columns: repeat(3, 82px);
}

.memory-board {
  grid-template-columns: repeat(4, 78px);
}

.catcher-board {
  grid-template-columns: repeat(5, 62px);
}

.number-board {
  grid-template-columns: repeat(4, 62px);
}

.game-cell {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  color: var(--ink);
  font-size: 28px;
  font-weight: 950;
  background: #fff;
  border: 1px solid rgba(92, 23, 111, 0.22);
  border-radius: 8px;
  cursor: pointer;
}

.game-cell:hover,
.game-cell:focus-visible {
  border-color: rgba(92, 23, 111, 0.5);
  outline: none;
}

.memory-card.matched,
.memory-card.flipped,
.number-cell.done {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), #8f3494);
}

.catcher-cell.active {
  color: #2b1b05;
  background: linear-gradient(180deg, #fff3a4, var(--gold) 58%, #f09a4e);
  box-shadow: 0 10px 20px rgba(240, 154, 78, 0.25);
}

.game-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.game-meta-row span {
  padding: 7px 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  background: #fff;
  border: 1px solid rgba(92, 23, 111, 0.14);
  border-radius: 999px;
}

@media (max-width: 980px) {
  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .games-topbar {
    align-items: start;
    flex-direction: column;
  }

  .games-back-link {
    width: 100%;
  }

  .games-grid {
    grid-template-columns: 1fr;
    margin-top: -20px;
  }

  .game-card {
    min-height: auto;
  }

  .game-panel-heading {
    align-items: start;
    flex-direction: column;
  }

  .game-close {
    width: 100%;
  }

  .tic-board {
    grid-template-columns: repeat(3, minmax(66px, 1fr));
    width: min(100%, 248px);
  }

  .memory-board {
    grid-template-columns: repeat(4, minmax(52px, 1fr));
    width: min(100%, 280px);
  }

  .catcher-board {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
    width: min(100%, 310px);
  }

  .number-board {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
    width: min(100%, 280px);
  }
}
