/* ─── reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

/* `hidden` is only a UA stylesheet rule, so any author rule that sets
   `display` (our .screen does) would keep hidden panels painted. */
[hidden] { display: none !important; }

:root {
  --ink:      #241046;
  --ink-soft: #5b4a7d;
  --paper:    #fffdf9;
  --c1: #ff5c8a;   /* pink   */
  --c2: #ffa41b;   /* amber  */
  --c3: #17b9a0;   /* teal   */
  --c4: #4c7dff;   /* blue   */
  --good: #17a34a;
  --bad:  #e23d3d;
  --radius: 22px;
  --shadow: 0 18px 40px rgba(30, 8, 66, .28);
}

/* ─── page ──────────────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  font-family: "Fredoka", ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 12% -10%, #7b3fe4 0%, transparent 60%),
    radial-gradient(900px 600px at 92% 0%, #ff6fae 0%, transparent 55%),
    radial-gradient(900px 700px at 50% 110%, #24c6dc 0%, transparent 60%),
    linear-gradient(160deg, #3a1c71 0%, #241046 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* twinkly star field, drawn with two repeating gradients */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.9), transparent),
    radial-gradient(2px 2px at 70% 15%, rgba(255,255,255,.7), transparent),
    radial-gradient(1.5px 1.5px at 45% 70%, rgba(255,255,255,.8), transparent),
    radial-gradient(2px 2px at 85% 60%, rgba(255,255,255,.6), transparent),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,.7), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .35; } to { opacity: .9; } }

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.stage { width: min(560px, 100%); position: relative; z-index: 2; }

/* ─── card / screens ────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 30px);
  text-align: center;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: pop-in .32s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* ─── home ──────────────────────────────────────────────────────────────── */
.logo {
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.05;
}
.logo-pop {
  background: linear-gradient(92deg, var(--c1), var(--c2) 45%, var(--c3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-rocket { display: inline-block; animation: hover-up 2.4s ease-in-out infinite; }
@keyframes hover-up { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-9px) rotate(4deg); } }

.tagline { color: var(--ink-soft); font-size: 1.05rem; margin-top: -6px; }

.picker { border: 0; padding: 0; }
.picker legend {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
  width: 100%;
  text-align: center;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid #e7e0f2;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.chip:hover { transform: translateY(-2px); border-color: #cbb9ea; }
.chip[aria-checked="true"] {
  background: linear-gradient(180deg, #f4ecff, #ece0ff);
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .18);
}

.best-line { color: var(--ink-soft); font-size: .95rem; }

.hint { color: var(--ink-soft); font-size: .82rem; line-height: 1.7; }
kbd {
  font: inherit;
  font-size: .78rem;
  background: #efe9fb;
  border: 1px solid #dbd0f0;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}

/* ─── buttons ───────────────────────────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  border-radius: 16px;
  padding: 15px 22px;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(2px) scale(.99); }

.btn-go {
  font-size: 1.25rem;
  color: #fff;
  background: linear-gradient(180deg, #ff7aa4, #ff3d78);
  box-shadow: 0 8px 0 #cf265c, 0 14px 24px rgba(207, 38, 92, .35);
}
.btn-go:hover { filter: brightness(1.05); }
.btn-go:active { box-shadow: 0 4px 0 #cf265c, 0 8px 16px rgba(207, 38, 92, .3); }

.btn-ghost {
  background: #f1ecfa;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: #e7e0f5; }

/* ─── play screen ───────────────────────────────────────────────────────── */
.hud { display: flex; justify-content: space-between; gap: 8px; }
.hud-item { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.hud-label { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.hud-value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.timer { height: 12px; border-radius: 999px; background: #eee6f7; overflow: hidden; }
.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--c3), var(--c2));
  transform-origin: left center;
}
.timer-fill.low { background: linear-gradient(90deg, #ff8f5a, var(--c1)); }

.mascot { font-size: 2.6rem; line-height: 1; height: 3rem; }
.mascot.cheer { animation: cheer .5s ease; }
.mascot.oops  { animation: shake .4s ease; }
@keyframes cheer { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px) rotate(-5deg); } 75% { transform: translateX(8px) rotate(5deg); } }

.question {
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  font-weight: 700;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}
.question.swap { animation: pop-in .3s cubic-bezier(.2, 1.3, .4, 1) both; }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.choice {
  font: inherit;
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
  cursor: pointer;
  border: 0;
  border-radius: 18px;
  padding: 18px 10px;
  position: relative;
  transition: transform .12s ease, filter .12s ease, opacity .2s ease;
}
.choice:nth-child(1) { background: var(--c1); box-shadow: 0 7px 0 #d43a68; }
.choice:nth-child(2) { background: var(--c2); box-shadow: 0 7px 0 #d17e00; }
.choice:nth-child(3) { background: var(--c3); box-shadow: 0 7px 0 #0d8c78; }
.choice:nth-child(4) { background: var(--c4); box-shadow: 0 7px 0 #3358cc; }
.choice:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.choice:active:not(:disabled) { transform: translateY(4px); }
.choice .key {
  position: absolute;
  top: 6px;
  left: 9px;
  font-size: .7rem;
  font-weight: 600;
  opacity: .75;
}
.choice:disabled { cursor: default; }
.choice.dim { opacity: .35; }
.choice.right { background: var(--good) !important; box-shadow: 0 7px 0 #0f7a37 !important; animation: cheer .45s ease; }
.choice.wrong { background: var(--bad)  !important; box-shadow: 0 7px 0 #ad2626 !important; animation: shake .4s ease; }

.feedback { min-height: 1.6em; font-weight: 600; font-size: 1.05rem; }
.feedback.good { color: var(--good); }
.feedback.bad  { color: var(--bad); }

/* ─── game over ─────────────────────────────────────────────────────────── */
.over-title { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 700; }
.stars { font-size: 2.6rem; letter-spacing: .1em; }
.stars .lit { animation: pop-in .4s cubic-bezier(.2, 1.5, .4, 1) both; }
.over-line { font-size: 1.25rem; }
.over-line strong { font-size: 1.6rem; color: var(--c1); }
.over-sub { color: var(--ink-soft); }
.new-best { font-weight: 600; color: var(--c2); font-size: 1.1rem; }
.over-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ─── misc ──────────────────────────────────────────────────────────────── */
.sound-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 60;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(6px);
}
.sound-toggle:hover { background: rgba(255, 255, 255, .3); }

.credit { color: rgba(255, 255, 255, .7); font-size: .8rem; position: relative; z-index: 2; }
.credit a { color: #fff; }

:focus-visible { outline: 3px solid #ffd447; outline-offset: 3px; }

@media (max-width: 380px) {
  .choices { gap: 8px; }
  .choice { padding: 15px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
