@font-face {
  font-family: "Fredoka";
  src: url("fonts/Fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --cream: #FFF8E6;
  --ink: #14213D;
  --ink-soft: #4A5578;
  --white: #FFFFFF;
  --sun: #FFD43B;
  --red: #F03E5E;
  --orange: #FF8A1F;
  --blue: #1C9BEF;
  --green: #2FB344;
  --purple: #8B3FD9;
  --pink: #F45AA5;
  --good: #2FB344;
  --bad: #F03E5E;
  --radius: 28px;
  --shadow: 0 6px 0 rgba(20, 33, 61, 0.14);
  --font: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 212, 59, 0.35) 0 90px, transparent 91px),
    radial-gradient(circle at 88% 8%, rgba(28, 155, 239, 0.18) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 70%, rgba(244, 90, 165, 0.14) 0 110px, transparent 111px),
    radial-gradient(circle at 6% 82%, rgba(47, 179, 68, 0.14) 0 100px, transparent 101px);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--blue); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; border-radius: 12px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; max-width: 980px; width: 100%; margin: 0 auto;
}
.topbar-home { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 1.25rem; }
.topbar-home img { width: 44px; height: 44px; object-fit: contain; }
.sound-toggle {
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink);
  background: var(--white); display: grid; place-items: center; box-shadow: var(--shadow);
}
.sound-toggle svg { width: 26px; height: 26px; }
.sound-toggle .icon-off { display: none; }
.sound-toggle[aria-pressed="false"] .icon-on { display: none; }
.sound-toggle[aria-pressed="false"] .icon-off { display: block; }

main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px 24px; }

.hero { text-align: center; padding: 4px 0 8px; }
.hero-logo { width: min(300px, 70vw); height: auto; margin: 0 auto; animation: bob 4s ease-in-out infinite; }
.hero-tag { font-size: 1.35rem; font-weight: 500; margin: 6px 0 0; color: var(--ink-soft); }

.panel {
  background: var(--white); border: 4px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink); padding: 22px 18px 26px; margin: 22px 0 30px;
}
.game-title { font-size: clamp(2rem, 7vw, 3rem); margin: 0; text-align: center; font-weight: 700; color: var(--red); letter-spacing: 0.01em; }
.game-sub { text-align: center; margin: 4px 0 20px; font-size: 1.15rem; color: var(--ink-soft); }

.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.level-card {
  --c: var(--sun);
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: var(--c); border: 4px solid var(--ink); border-radius: 24px; overflow: hidden;
  box-shadow: 0 7px 0 var(--ink); transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.level-card:hover { transform: translateY(-3px); box-shadow: 0 10px 0 var(--ink); }
.level-card:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.level-card .cover { aspect-ratio: 4 / 3; overflow: hidden; border-bottom: 4px solid var(--ink); position: relative; background: #ddd; }
.level-card .cover img { width: 100%; height: 100%; object-fit: cover; filter: blur(10px) saturate(1.2); transform: scale(1.15); }
.level-card .cover .q {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 5rem; font-weight: 700; color: var(--white); text-shadow: 0 4px 0 var(--ink), 0 0 2px var(--ink);
}
.level-card .body { padding: 12px 16px 16px; }
.level-card .lvl { font-size: 1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.level-card .name { font-size: 1.6rem; font-weight: 700; line-height: 1.1; margin: 2px 0 8px; }
.level-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pill { background: var(--white); border: 3px solid var(--ink); border-radius: 999px; padding: 2px 12px; font-weight: 600; font-size: 0.95rem; }
.best { font-size: 0.95rem; font-weight: 500; }
.stars { letter-spacing: 2px; color: var(--ink); }

.social-panel { text-align: center; }
.social-panel h2 { margin: 0; font-size: 1.8rem; color: var(--blue); }
.social-note { margin: 2px 0 16px; color: var(--ink-soft); font-size: 1.05rem; }
.social-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.social {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 12px;
  border: 4px solid var(--ink); border-radius: 20px; text-decoration: none; color: var(--white);
  font-weight: 600; font-size: 1.15rem; box-shadow: 0 6px 0 var(--ink); transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.social:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.social:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.social svg { width: 28px; height: 28px; flex: none; }
.social-yt { background: #FF0033; }
.social-yt svg { color: var(--white); }
.social-yt svg path { fill: #FF0033; }
.social-tt { background: #111; }
.social-ig { background: linear-gradient(45deg, #F9A23B, #E1306C 50%, #833AB4); }
.social-x { background: #111; }

.values-panel h2, .app-panel h2 { margin: 0 0 14px; font-size: 1.8rem; text-align: center; color: var(--green); }
.values { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.values li { background: var(--c); border: 4px solid var(--ink); border-radius: 22px; padding: 14px 16px 16px; box-shadow: 0 6px 0 var(--ink); }
.values strong { display: block; font-size: 1.35rem; margin-bottom: 4px; }
.values span { font-size: 1.05rem; line-height: 1.35; }

.app-panel { display: flex; align-items: center; gap: 20px; background: var(--sun); }
.app-panel h2 { text-align: left; color: var(--ink); margin-bottom: 8px; }
.app-text { flex: 1; }
.app-text p { margin: 0 0 14px; font-size: 1.1rem; line-height: 1.4; }
.soon-tag { display: inline-block; background: var(--red); color: var(--white); border: 3px solid var(--ink); border-radius: 999px; padding: 2px 14px; font-weight: 600; margin-bottom: 8px !important; }
.stores { display: flex; flex-wrap: wrap; gap: 10px; }
.store { background: var(--ink); color: var(--white); border-radius: 14px; padding: 10px 18px; font-weight: 600; font-size: 1.05rem; opacity: 0.85; }
.app-art { width: 170px; height: auto; flex: none; animation: bob 4s ease-in-out infinite; }

.home-video { max-width: 720px; margin: 0 auto 18px; }
.video-panel { text-align: center; }
.video-panel h2 { margin: 0; font-size: 1.6rem; color: var(--red); }
.video-panel > p { margin: 4px 0 16px; font-size: 1.1rem; color: var(--ink-soft); }
.video { position: relative; aspect-ratio: 16 / 9; border: 4px solid var(--ink); border-radius: 22px; overflow: hidden; background: var(--ink); box-shadow: 0 6px 0 var(--ink); }
.video-play { all: unset; position: absolute; inset: 0; cursor: pointer; display: grid; place-items: center; }
.video-play img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-play .play-icon { position: relative; width: clamp(56px, 13vw, 84px); transition: transform 0.15s ease; filter: drop-shadow(0 4px 0 rgba(20, 33, 61, 0.5)); }
.video-play:hover .play-icon, .video-play:focus-visible .play-icon { transform: scale(1.1); }
.video-play:focus-visible { outline: 5px solid var(--blue); outline-offset: -5px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-note { margin: 10px 0 0; font-size: 0.95rem; color: var(--ink-soft); }
.video-note a { color: var(--ink); font-weight: 600; }

.footer { text-align: center; padding: 20px 16px 28px; color: var(--ink-soft); font-size: 0.95rem; max-width: 720px; margin: 0 auto; }
.footer p { margin: 6px 0; }

/* Play */
.play-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.play-head h1 { margin: 0; font-size: clamp(1.3rem, 4.5vw, 1.8rem); line-height: 1.1; }
.play-head .lvl-tag { display: block; font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.back-btn { flex: none; background: var(--white); border: 3px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-weight: 600; text-decoration: none; color: var(--ink); box-shadow: 0 4px 0 var(--ink); }

.btn {
  --c: var(--sun);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--c); border: 4px solid var(--ink); border-radius: 22px; padding: 14px 26px;
  font-size: 1.4rem; font-weight: 700; color: var(--ink); text-decoration: none;
  box-shadow: 0 7px 0 var(--ink); transition: transform 0.1s ease, box-shadow 0.1s ease; min-height: 64px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 9px 0 var(--ink); }
.btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.btn.secondary { --c: var(--white); }

.start-card { text-align: center; }
.start-card .cover { width: min(320px, 80%); aspect-ratio: 1; margin: 6px auto 16px; border-radius: 50%; overflow: hidden; border: 5px solid var(--ink); box-shadow: 0 8px 0 var(--ink); }
.start-card .cover img { width: 100%; height: 100%; object-fit: cover; filter: blur(12px); transform: scale(1.2); }
.start-card h2 { font-size: 1.6rem; margin: 0 0 6px; }
.start-card p { margin: 0 0 18px; font-size: 1.15rem; color: var(--ink-soft); }
.mode-pick { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 22px; }
.mode-opt {
  border: 4px solid var(--ink); border-radius: 18px; background: var(--white); padding: 10px 18px; font-weight: 600; font-size: 1.1rem;
  box-shadow: 0 4px 0 var(--ink); text-align: left; min-width: 200px;
}
.mode-opt small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.9rem; }
.mode-opt[aria-pressed="true"] { background: var(--c, var(--sun)); }

.progress { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.progress span { width: 14px; height: 14px; border-radius: 50%; background: var(--white); border: 2.5px solid var(--ink); }
.progress span.right { background: var(--good); }
.progress span.wrong { background: var(--bad); }
.progress span.now { background: var(--sun); transform: scale(1.3); }

.question { display: grid; gap: 14px; }
.prompt { text-align: center; font-size: clamp(1.5rem, 5.5vw, 2.2rem); font-weight: 700; margin: 0; }
.photo-wrap { position: relative; }
.photo {
  aspect-ratio: 4 / 3; width: 100%; max-height: 44dvh; margin: 0 auto; border-radius: var(--radius); overflow: hidden;
  border: 5px solid var(--ink); box-shadow: 0 8px 0 var(--ink); background: #e8e2d0;
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.reveal-good { border-color: var(--good); box-shadow: 0 8px 0 var(--good); }
.reveal-name {
  position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%) scale(0.6); opacity: 0;
  background: var(--sun); border: 4px solid var(--ink); border-radius: 999px; padding: 6px 22px;
  font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; white-space: nowrap; box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}
.reveal-name.show { transform: translateX(-50%) scale(1); opacity: 1; }
.credit { font-size: 0.75rem; color: var(--ink-soft); text-align: right; margin: 18px 6px 0; }
.timer { height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--white); overflow: hidden; }
.timer span { display: block; height: 100%; width: 100%; background: var(--green); transform-origin: left; }
.timer.run span { animation: drain var(--secs, 5s) linear forwards; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer {
  --c: var(--white);
  border: 4px solid var(--ink); border-radius: 20px; background: var(--c); padding: 14px 10px; min-height: 72px;
  font-size: clamp(1.2rem, 4.5vw, 1.6rem); font-weight: 600; box-shadow: 0 6px 0 var(--ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.2s ease;
}
.answer:nth-child(1) { --c: #FFE3E8; }
.answer:nth-child(2) { --c: #DDF0FF; }
.answer:nth-child(3) { --c: #FFF1C2; }
.answer:nth-child(4) { --c: #E2F7E5; }
.answer:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.answer:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.answer:disabled { cursor: default; }
.answer.is-right { background: var(--good); color: var(--white); animation: pop 0.4s ease; }
.answer.is-wrong { background: var(--bad); color: var(--white); animation: shake 0.4s ease; }
.answer.dim { opacity: 0.45; }
.next-row { display: flex; justify-content: center; min-height: 78px; }

.toast {
  position: fixed; left: 50%; top: 18%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; z-index: 20;
  background: var(--purple); color: var(--white); border: 4px solid var(--ink); border-radius: 24px; padding: 14px 26px;
  font-size: 1.6rem; font-weight: 700; box-shadow: 0 7px 0 var(--ink); text-align: center; width: max-content; max-width: calc(100vw - 32px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.results { text-align: center; }
.results .big-score { font-size: clamp(4rem, 18vw, 7rem); font-weight: 700; line-height: 1; margin: 6px 0; color: var(--red); }
.results .big-score small { font-size: 0.4em; color: var(--ink); }
.results .medal { font-size: clamp(2.4rem, 10vw, 3.6rem); letter-spacing: 6px; margin: 0; }
.results .medal .off { opacity: 0.2; }
.results h2 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: 8px 0 4px; }
.results p { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 20px; }
.results .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.missed { margin-top: 26px; text-align: left; }
.missed h3 { text-align: center; margin: 0 0 10px; }
.missed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.missed-grid figure { margin: 0; border: 3px solid var(--ink); border-radius: 16px; overflow: hidden; background: var(--white); }
.missed-grid img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.missed-grid figcaption { text-align: center; font-weight: 600; padding: 4px; }

/* Credits */
.credits h1 { margin-top: 0; text-align: center; }
.credits p.lead { text-align: center; color: var(--ink-soft); }
.credits h2 { margin: 22px 0 8px; }
.credits ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.credits li { display: flex; gap: 12px; align-items: center; font-size: 0.95rem; }
.credits li img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; border: 2px solid var(--ink); flex: none; }
.credits li b { display: block; }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall var(--d, 1.6s) cubic-bezier(0.2, 0.6, 0.4, 1) forwards; }

@keyframes drain { to { transform: scaleX(0); background: var(--red); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
@keyframes fall { to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 540deg)); } }

@media (max-width: 420px) {
  .progress { gap: 4px; }
  .progress span { width: 12px; height: 12px; border-width: 2px; }
  .answers { gap: 10px; }
  .answer { min-height: 64px; padding: 10px 6px; }
  .panel { padding: 18px 14px 22px; }
}

@media (max-width: 600px) {
  .app-panel { flex-direction: column-reverse; text-align: center; }
  .app-panel h2 { text-align: center; }
  .stores { justify-content: center; }
  .app-art { width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .timer.run span { animation-duration: var(--secs, 5s) !important; }
  .confetti { display: none; }
}
