:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #3e4c5f;
  --paper: #efe6d2;
  --card: #fffdf8;
  --line: #1c2430;
  --good: #0f7a45;
  --bad: #a33b24;
  --good-bg: #b7ebc6;
  --bad-bg: #ffc7b8;
  --gold: #ffd36e;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background-color: var(--paper);
  background-image: radial-gradient(#e4d3ab 1.15px, transparent 1.2px);
  background-size: 18px 18px;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  z-index: 5;
}

.skip:focus { top: 8px; }

.page { max-width: 1040px; margin: 0 auto; }

.hero, .end, .card, .flag-frame, .tray, .readout, .blank, .choice, .key, .letter, .primary, .ghost, .back, .sound, .scoreline, .levels button {
  border: 2px solid var(--line);
}

.hero {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 5px 5px 0 var(--line);
  padding: 22px 20px 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: #8a4b12;
}

h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -0.03em; line-height: 0.95; }

.lede { margin: 10px 0 0; max-width: 40rem; color: var(--muted); font-size: 1.05rem; line-height: 1.45; }

.arcade, .footer a {
  color: var(--ink);
  font-weight: 800;
}

.hero-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.arcade {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--gold);
  border: 2px solid var(--line);
  box-shadow: 3px 3px 0 var(--line);
  text-decoration: none;
}

.arcade:focus-visible, .card:focus-visible, .back:focus-visible, .sound:focus-visible, .primary:focus-visible, .ghost:focus-visible, .choice:focus-visible, .key:focus-visible, .letter:focus-visible, .levels button:focus-visible, .textbtn:focus-visible {
  outline: 3px solid #2f6fed;
  outline-offset: 3px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 4px 4px 0 var(--line);
  overflow: hidden;
}

.art {
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 2px solid var(--line);
  font-weight: 800;
  font-size: 1.8rem;
}

.art.math { background: #ffd36e; }
.art.times { background: #ffb085; }
.art.fractions { background: #f7b4c2; }
.art.flags { background: #9fd7c8; }
.art.clock { background: #b7d3ff; }
.art.science { background: #c9f0a4; }
.art.spelling { background: #e3c8ff; }
.art.money { background: #ffe08a; }

.mini-flag { width: 46px; height: 30px; border: 2px solid var(--line); border-radius: 3px; overflow: hidden; display: grid; }
.mini-flag.fr { grid-template-columns: 1fr 1fr 1fr; }
.mini-flag.fr i:nth-child(1) { background: #0055a4; }
.mini-flag.fr i:nth-child(2) { background: #fff; }
.mini-flag.fr i:nth-child(3) { background: #ef4135; }
.mini-flag.jp { place-items: center; background: #fff; display: grid; }
.mini-flag.jp b { width: 14px; height: 14px; border-radius: 50%; background: #bc002d; }
.mini-flag.de { display: grid; grid-template-rows: 1fr 1fr 1fr; }
.mini-flag.de i:nth-child(1) { background: #000; }
.mini-flag.de i:nth-child(2) { background: #dd0000; }
.mini-flag.de i:nth-child(3) { background: #ffce00; }

.pie {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: conic-gradient(#ef6f4c 0 50%, #f6d7a2 50% 100%);
  box-shadow: inset 0 0 0 6px #e7b07a;
}

.css-clock {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background:
    linear-gradient(#1c2430, #1c2430) center/3px 26px no-repeat,
    linear-gradient(#1c2430, #1c2430) center/20px 3px no-repeat,
    #fff;
}

.tile {
  width: 36px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--line);
}

.coin-art {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #d4845a;
}
.coin-art.n { width: 36px; height: 36px; background: #e6e9ee; }
.coin-art.q { width: 44px; height: 44px; background: #f4f6f8; }

.tf { display: flex; gap: 6px; }
.tf span {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
}

.info { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.info h2 { margin: 0; font-size: 1.35rem; }
.info p { margin: 0; color: var(--muted); line-height: 1.4; }
.tag {
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #fff3c4;
  border-radius: 999px;
  padding: 3px 8px;
}
.best { margin-top: auto; font-weight: 800; color: var(--ink); }

.footer { margin: 18px 0 0; color: var(--muted); }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.bar h1 { font-size: clamp(1.4rem, 4vw, 2rem); flex: 1 1 160px; }

.back, .sound, .scoreline, .levels button, .primary, .ghost, .textbtn, .choice, .key, .letter {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
}

.back, .sound {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--line);
  cursor: pointer;
}

.bar-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.scoreline {
  margin: 0;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
}

.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.levels button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.levels button.on { background: var(--ink); color: #fff; }

.help { margin: 0 0 6px; color: var(--muted); line-height: 1.4; }

.status {
  min-height: 1.5em;
  margin: 0 0 10px;
  text-align: center;
  font-weight: 800;
}

.status.good { color: var(--good); }
.status.bad { color: var(--bad); }

.stage { max-width: 720px; margin: 0 auto; }

.progress, .question, .countline, .legend, .sub {
  text-align: center;
  margin: 0 0 8px;
}

.question { font-size: clamp(1.2rem, 3.4vw, 1.7rem); font-weight: 800; }

.prompt {
  text-align: center;
  font-size: clamp(2.2rem, 9vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 8px 0 12px;
  line-height: 1;
}

.sub { color: var(--muted); font-weight: 800; }

.choices { display: grid; grid-template-columns: 1fr; gap: 10px; }

.choice, .key, .letter, .textbtn, .primary, .ghost {
  cursor: pointer;
}

.choice {
  min-height: 58px;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.choice.good { background: var(--good-bg); }
.choice.bad { background: var(--bad-bg); }
.choice:disabled:not(.good):not(.bad) { opacity: 0.55; }

.pad { max-width: 380px; margin: 8px auto 0; }

.readout {
  min-height: 68px;
  display: grid;
  place-items: center;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 800;
  background: #fff;
  border-radius: 14px;
  margin-bottom: 10px;
}

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.key, .letter, .textbtn {
  min-height: 56px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}

.key { font-size: 1.35rem; }
.key.go, .textbtn.go, .primary { background: var(--gold); }
.key:active, .letter:active, .choice:active, .textbtn:active, .primary:active, .ghost:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line);
}

.track {
  position: relative;
  height: 36px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  margin: 4px 0 12px;
}

.runner {
  position: absolute;
  top: 4px;
  left: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ef6f4c;
  border: 2px solid var(--line);
  font-size: 14px;
}

.flag-frame {
  width: min(440px, 100%);
  margin: 0 auto 12px;
  background: #e7e0d2;
  border-radius: 14px;
  padding: 12px;
}

.flag-frame svg { display: block; width: 100%; height: auto; border-radius: 4px; }

.pizza-wrap { width: min(320px, 92vw); margin: 0 auto; }
.pizza-wrap svg { display: block; width: 100%; height: auto; }
.slice { cursor: pointer; }
.slice:focus { outline: none; }
.slice:focus-visible { stroke: #2f6fed; stroke-width: 4; }

.actions, .end-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }

.textbtn, .primary, .ghost {
  min-height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary, .ghost { box-shadow: 3px 3px 0 var(--line); }
.ghost { background: #fff; }

.clock-wrap { width: min(280px, 78vw); margin: 0 auto 12px; }
.clock-wrap svg { display: block; width: 100%; height: auto; }

.blanks, .bank, .legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.blanks, .bank { margin: 12px auto; max-width: 560px; }

.blank {
  width: 46px;
  height: 56px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  font-size: 1.5rem;
  font-weight: 800;
}

.blank.fixed { background: #fff3c4; }
.blank.btn { padding: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.5rem; }

.letter { min-width: 52px; padding: 0 8px; font-size: 1.3rem; }
.letter:disabled { opacity: 0.35; }

.emoji { font-size: 3.2rem; line-height: 1; text-align: center; margin: 0; }

.clue { text-align: center; font-size: 1.15rem; margin: 6px 0; font-weight: 800; }

.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  min-height: 132px;
  padding: 16px;
  background: #1f7a4d;
  border-radius: 18px;
  box-shadow: inset 0 0 0 4px #17633e;
}

.coin, .bill {
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  font-weight: 800;
  color: var(--ink);
}

.coin { border-radius: 50%; }
.coin span, .bill span { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }
.coin.penny { width: 58px; height: 58px; background: radial-gradient(circle at 35% 30%, #f3c2a4, #c86b3c 58%, #8d4528); font-size: 0.85rem; }
.coin.nickel { width: 72px; height: 72px; background: radial-gradient(circle at 35% 30%, #fff, #d5dae1 55%, #9aa3af); font-size: 0.95rem; }
.coin.dime { width: 50px; height: 50px; background: radial-gradient(circle at 35% 30%, #fff, #e6eaef 55%, #aeb6c2); font-size: 0.78rem; }
.coin.quarter { width: 86px; height: 86px; background: radial-gradient(circle at 35% 30%, #fff, #f3f5f8 50%, #b7c0cc); font-size: 1rem; }
.bill { width: 116px; height: 54px; border-radius: 8px; background: repeating-linear-gradient(90deg, transparent, transparent 10px, rgba(255,255,255,0.25) 10px, rgba(255,255,255,0.25) 12px), #d8f3c8; font-size: 1.2rem; }
.bill.five { background: repeating-linear-gradient(90deg, transparent, transparent 10px, rgba(255,255,255,0.28) 10px, rgba(255,255,255,0.28) 12px), #f3e2a8; }

.legend { margin: 10px 0; font-size: 0.92rem; font-weight: 800; }

.end {
  text-align: center;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 4px 4px 0 var(--line);
  padding: 22px 16px;
}

.end h2 { margin: 0 0 8px; font-size: clamp(1.6rem, 5vw, 2.2rem); }
.end-score { margin: 0; font-size: 1.5rem; font-weight: 800; }
.end p { margin: 6px 0; }

.shake { animation: edu-shake 0.35s linear; }

@keyframes edu-shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (min-width: 700px) {
  .grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .choices { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1020px) {
  .grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

@media (hover: hover) {
  .card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .card, .runner, .key, .choice, .letter, .primary, .ghost { transition: none; }
  .shake { animation: none; }
  .card:hover { transform: none; }
}
