:root {
  --canvas: #fff9f2;
  --surface: #ffffff;
  --ink: #19233d;
  --muted: #56617a;
  --blue: #2457db;
  --accent: #ffd54a;
  --mint: #62d6b3;
  --coral: #ff725e;
  --lavender: #ac98ff;
  font-family: 'Avenir Next', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--accent), transparent 72%), transparent 18rem),
    var(--canvas);
  font-size: 1rem;
  line-height: 1.5;
}

button,
a { font: inherit; }

button { color: inherit; }

:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.8rem;
  left: 0.8rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  color: white;
  background: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

.game-header {
  border-bottom: 2px solid var(--ink);
  background: white;
}

.game-header__inner {
  display: flex;
  width: min(calc(100% - 1.5rem), 1040px);
  min-height: 72px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.home-link,
.sound-button,
.help-button,
.continue-button,
.play-again,
.next-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
}

.home-link,
.sound-button,
.help-button { background: white; }

.continue-button {
  color: white;
  background: var(--blue);
  cursor: pointer;
}

.continue-button[hidden] { display: none; }

.sound-button { cursor: pointer; }

.game-header strong { font-size: 1.08rem; }

.game-main {
  width: min(calc(100% - 1.5rem), 900px);
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) 0 4rem;
}

.game-shell {
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 28px;
  background: white;
  box-shadow: 0 9px 0 var(--ink);
}

.game-intro {
  padding: 1.15rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 3px solid var(--ink);
  background: color-mix(in srgb, var(--accent), white 30%);
}

.game-intro h1 {
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1.08;
}

.game-intro p { margin: 0; font-weight: 700; }

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.progress span {
  width: 30px;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.progress span[data-complete='true'] { background: var(--mint); }

.game-stage {
  min-height: 480px;
  padding: clamp(1.2rem, 4vw, 2.5rem);
  text-align: center;
}

.prompt {
  margin: 0 0 1.2rem;
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 900;
  line-height: 1.2;
}

.puzzle {
  display: flex;
  min-height: 170px;
  align-items: center;
  justify-content: center;
  gap: clamp(0.55rem, 2vw, 1rem);
  margin: 0 auto 1.3rem;
  padding: 1rem;
  border: 2px dashed #a9b3c7;
  border-radius: 22px;
  background: #f9fbff;
}

.counting-set {
  display: flex;
  max-width: 620px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-object {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: var(--coral);
  box-shadow: 0 4px 0 rgba(25, 35, 61, 0.2);
  font-size: 2rem;
  line-height: 1;
}

.game-object:nth-child(3n + 2) { background: var(--mint); }
.game-object:nth-child(3n + 3) { background: var(--accent); }

.game-object[data-number]::after {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: white;
  content: attr(data-number);
  font-size: 0.75rem;
  font-weight: 900;
}

.pattern-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.pattern-unit {
  display: contents;
}

.pattern-line[data-help='true'] .pattern-unit:first-child .shape-token {
  box-shadow: 0 0 0 5px white, 0 0 0 9px var(--blue);
}

.question-token {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 3px dashed var(--ink);
  border-radius: 16px;
  background: white;
  font-size: 2rem;
  font-weight: 900;
}

.shape-token,
.choice-shape {
  display: block;
  width: 58px;
  height: 58px;
  border: 3px solid var(--ink);
  background: var(--token-color, var(--blue));
}

.shape-token.circle,
.choice-shape.circle { border-radius: 50%; }

.shape-token.square,
.choice-shape.square { border-radius: 10px; }

.shape-token.triangle,
.choice-shape.triangle {
  width: 0;
  height: 0;
  border-top: 0;
  border-right: 32px solid transparent;
  border-bottom: 58px solid var(--token-color, var(--coral));
  border-left: 32px solid transparent;
  background: transparent;
}

.shape-token.rectangle,
.choice-shape.rectangle { width: 78px; border-radius: 9px; }

.shape-token.oval,
.choice-shape.oval { width: 78px; border-radius: 50%; }

.color-coral { --token-color: #ff725e; }
.color-blue { --token-color: #3a7bff; }
.color-yellow { --token-color: #ffd54a; }
.color-mint { --token-color: #62d6b3; }
.color-lavender { --token-color: #ac98ff; }

.target-letter {
  position: relative;
  display: grid;
  width: 120px;
  height: 135px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50% 50% 20px 20px / 30% 30% 20px 20px;
  color: white;
  background: var(--blue);
  box-shadow: 0 7px 0 var(--ink);
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
}

.target-letter[data-help='true']::after {
  position: absolute;
  margin-top: 175px;
  color: var(--ink);
  content: attr(data-pair);
  font-size: 1rem;
  font-weight: 800;
}

.options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}

.choice-button {
  display: grid;
  min-width: 78px;
  min-height: 68px;
  place-items: center;
  padding: 0.55rem 1rem;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: white;
  box-shadow: 0 5px 0 var(--ink);
  font-size: 1.65rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.choice-button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.choice-button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }

.choice-button[data-state='wrong'] { background: #ffe3de; }
.choice-button[data-state='correct'] { background: #cff5ea; }

.letter-choice { font-size: 3rem; }

.feedback {
  min-height: 2.1rem;
  margin: 1.1rem 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.game-actions {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.help-button { cursor: pointer; }

.completion {
  display: grid;
  min-height: 410px;
  place-items: center;
  padding: 2rem;
  text-align: center;
  background: color-mix(in srgb, var(--accent), white 45%);
}

.completion[hidden],
.game-round[hidden] { display: none; }

.completion__mark {
  display: grid;
  width: 92px;
  height: 92px;
  margin: 0 auto 1rem;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  font-size: 3rem;
}

.completion h2 { margin: 0 0 0.6rem; font-size: clamp(2rem, 6vw, 3.5rem); }
.completion p { max-width: 38ch; margin: 0 auto 1.4rem; font-size: 1.1rem; }

.completion__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}

.play-again,
.next-button {
  border-width: 3px;
  color: white;
  background: var(--blue);
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
}

.next-button { color: var(--ink); background: white; }

.learning-note {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.learning-note section {
  padding: 1rem;
  border: 2px solid #dbe2ef;
  border-radius: 16px;
  background: white;
}

.learning-note h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.learning-note p { margin: 0; color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .game-header__inner { min-height: 64px; }
  .game-header strong { display: none; }
  .game-stage { min-height: 450px; padding: 1.1rem; }
  .learning-note { grid-template-columns: 1fr; }
  .game-object { width: 50px; height: 50px; font-size: 1.7rem; }
  .shape-token, .choice-shape { width: 50px; height: 50px; }
  .shape-token.triangle, .choice-shape.triangle { width: 0; height: 0; border-right-width: 28px; border-bottom-width: 50px; border-left-width: 28px; }
}

@media (orientation: landscape) and (max-height: 420px) {
  .game-header__inner { min-height: 48px; }
  .game-header strong { display: block; font-size: 0.95rem; }
  .home-link,
  .sound-button { min-height: 44px; padding: 0.35rem 0.75rem; }
  .game-main { width: min(calc(100% - 1rem), 1040px); padding: 0.45rem 0 1rem; }
  .game-shell { display: grid; grid-template-columns: minmax(185px, 32%) minmax(0, 1fr); }
  .game-intro { padding: 0.7rem 0.85rem; border-right: 3px solid var(--ink); border-bottom: 0; }
  .game-intro h1 { margin: 0.2rem 0 0.35rem; font-size: 1.5rem; }
  .game-intro p:not(.eyebrow) { font-size: 0.8rem; line-height: 1.35; }
  .eyebrow { font-size: 0.65rem; }
  .game-stage { min-height: calc(100svh - 63px); padding: 0.45rem 0.7rem; }
  .progress { gap: 0.3rem; margin-bottom: 0.25rem; }
  .progress span { width: 22px; height: 8px; }
  .prompt { margin-bottom: 0.3rem; font-size: 1rem; }
  .puzzle { min-height: 58px; height: 58px; margin-bottom: 0.35rem; padding: 0.25rem; border-radius: 14px; }
  .counting-set,
  .pattern-line { gap: 0.35rem; }
  .game-object,
  .shape-token,
  .choice-shape { width: 38px; height: 38px; font-size: 1.25rem; }
  .shape-token.triangle,
  .choice-shape.triangle { width: 0; height: 0; border-right-width: 21px; border-bottom-width: 38px; border-left-width: 21px; }
  .question-token { width: 42px; height: 42px; font-size: 1.25rem; }
  .target-letter { width: 46px; height: 50px; box-shadow: 0 3px 0 var(--ink); font-size: 2.25rem; }
  .target-letter[data-help='true']::after { margin-top: 68px; font-size: 0.7rem; }
  .options { gap: 0.45rem; }
  .choice-button { min-width: 58px; min-height: 48px; padding: 0.25rem 0.55rem; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); font-size: 1.1rem; }
  .letter-choice { font-size: 2rem; }
  .feedback { min-height: 1rem; margin: 0.3rem 0 0; font-size: 0.75rem; }
  .game-actions { margin-top: 0.25rem; }
  .help-button,
  .continue-button { min-height: 44px; padding: 0.3rem 0.75rem; font-size: 0.75rem; }
  .completion { min-height: calc(100svh - 63px); padding: 0.75rem; }
  .completion__mark { width: 52px; height: 52px; margin-bottom: 0.4rem; font-size: 1.7rem; }
  .completion h2 { margin-bottom: 0.25rem; font-size: 1.7rem; }
  .completion p { margin-bottom: 0.65rem; font-size: 0.9rem; }
  .learning-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.playhouse-footer {
  width: min(calc(100% - 1.5rem), 1040px);
  margin: 0 auto;
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.playhouse-footer p { margin: 0; }

.playhouse-footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 10px;
  color: var(--blue);
  font-weight: 900;
}
