/* Layout: one column, header + views; the game view fills the whole screen on every device.
   Look follows the Kaotim campaign key art (Kaotim Ngap / Kaotim Run): glossy chunky type
   with thick outlines, juicy pill buttons, bright sky, magenta and gold sparkles.
   Fonts: Lilita One (display) and Fredoka (labels) are OFL-licensed Google Fonts; Poppins for body text. */
:root {
  --magenta: #D62CF0;
  --purple: #C93BF2;
  --purple-deep: #8E1CC2;
  --violet: #5B0E96;
  --ink: #2A0F3D;
  --ink-soft: #6B5A7E;
  --lilac: #F7F0FC;
  --line: #EBDDF5;
  --card: #FFFFFF;
  --gold: #FFC94D;
  --gold-deep: #F2A007;
  --gold-soft: #FFF3D1;
  --sky: #3DA5F5;
  --grass: #5DB548;
  --danger: #D92D5B;
  --font: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --display: 'Lilita One', 'Fredoka', 'Poppins', system-ui, sans-serif;
  --round: 'Fredoka', 'Poppins', system-ui, sans-serif;
  --radius: 20px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --chunky: 0 6px 0 #E6CFF3, 0 14px 28px rgba(110, 30, 160, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--lilac);
  background-image:
    radial-gradient(rgba(201, 59, 242, 0.10) 1.2px, transparent 1.6px),
    radial-gradient(1200px 520px at 100% 0%, rgba(214, 44, 240, 0.10), transparent 60%),
    radial-gradient(900px 480px at 0% 100%, rgba(255, 201, 77, 0.14), transparent 60%);
  background-size: 22px 22px, auto, auto;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* Speed streaks in the corners, as on the Kaotim Ngap banner. */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none; width: 360px; height: 160px;
  background:
    linear-gradient(90deg, transparent, var(--magenta)) 0 20px / 100% 10px no-repeat,
    linear-gradient(90deg, transparent, var(--gold)) 60px 50px / 80% 7px no-repeat,
    linear-gradient(90deg, transparent, var(--magenta)) 120px 76px / 60% 5px no-repeat;
  border-radius: 999px; opacity: 0.35;
}
body::before { left: -80px; top: 90px; transform: rotate(-24deg); }
body::after { right: -80px; bottom: 60px; transform: rotate(156deg); }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button, a, input { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Glossy headline type: white face, thick magenta outline, purple extrusion, warm rim glow. */
.gloss {
  font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; line-height: 0.95;
  color: #FFFFFF;
  -webkit-text-stroke: 0.12em var(--purple-deep);
  paint-order: stroke fill;
  text-shadow:
    0 0.05em 0 #7A13B4, 0 0.09em 0 #5B0E96, 0 0.13em 0 #44097A,
    0 0.2em 0.25em rgba(50, 0, 90, 0.45),
    0 0 0.6em rgba(255, 201, 77, 0.45);
}
/* Dark variant for light backgrounds (Kaotim Ngap style). */
.gloss-ink {
  font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; line-height: 1;
  color: var(--ink);
  -webkit-text-stroke: 0.14em #FFFFFF;
  paint-order: stroke fill;
  text-shadow: 0 0.06em 0 #F3D6FB, 0 0.1em 0 rgba(201, 59, 242, 0.55), 0 0.14em 0.2em rgba(110, 30, 160, 0.2);
}

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: max(8px, env(safe-area-inset-top, 0px));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1120px;
  width: 100%;
  margin: 8px auto 0;
  padding: 8px 10px 8px 12px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
  border: 2px solid #FFFFFF;
  border-radius: 999px;
  box-shadow: 0 4px 0 #EAD6F6, 0 12px 30px rgba(110, 30, 160, 0.12);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-badge { width: 38px; height: 38px; border-radius: 12px; box-shadow: 0 3px 0 var(--purple-deep); transition: transform 0.3s var(--spring); }
.brand:hover .brand-badge { transform: rotate(-10deg) scale(1.08); }
.brand-name { font-family: var(--display); font-size: 1.45rem; letter-spacing: 0.01em; color: var(--ink); }
.campaign-pill {
  font-family: var(--round); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em;
  color: var(--ink); background: linear-gradient(180deg, #FFE08A, var(--gold)); padding: 3px 10px; border-radius: 999px;
  box-shadow: 0 2px 0 var(--gold-deep), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: rotate(-4deg);
}
.tabs { display: flex; gap: 4px; margin-left: auto; background: #F4E9FB; padding: 4px; border-radius: 999px; }
.tab {
  font-family: var(--round); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  padding: 7px 18px; border-radius: 999px; color: var(--ink-soft);
  transition: color 0.2s ease, background 0.2s ease, transform 0.25s var(--spring);
}
.tab:hover { color: var(--purple-deep); }
.tab:active { transform: scale(0.94); }
.tab[aria-current="page"] {
  color: #FFFFFF; text-shadow: 0 1px 0 rgba(90, 0, 130, 0.45);
  background: linear-gradient(180deg, #E565FF 0%, var(--purple) 50%, #A51FDB 100%);
  box-shadow: 0 3px 0 #7412A8, inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.player-chip {
  font-family: var(--round); border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 0.92rem; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  white-space: nowrap; box-shadow: 0 3px 0 var(--line);
  transition: transform 0.25s var(--spring), border-color 0.2s ease;
}
.player-chip:hover { border-color: var(--purple); transform: translateY(-1px); }
.player-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.player-chip b { color: var(--purple-deep); }
.audio-toggles { display: flex; gap: 6px; }
.audio-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  border: 2px solid var(--line); background: var(--card); color: var(--purple-deep);
  border-radius: 999px; cursor: pointer; box-shadow: 0 3px 0 var(--line);
  transition: transform 0.25s var(--spring);
}
.audio-btn:hover { transform: translateY(-1px) rotate(-6deg); }
.audio-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.audio-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.audio-btn .ab-off { display: none; }
.audio-btn[aria-pressed="false"] { color: var(--ink-soft); background: #F4EEF8; }
.audio-btn[aria-pressed="false"] .ab-on { display: none; }
.audio-btn[aria-pressed="false"] .ab-off { display: inline; }
.audio-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- shared ---------- */
.view { max-width: 1120px; width: 100%; margin: 0 auto; padding-block: 18px 32px; display: flex; flex-direction: column; gap: 30px; }
.eyebrow { font-family: var(--round); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--purple-deep); }
.lede { color: var(--ink-soft); max-width: 56ch; line-height: 1.6; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; letter-spacing: 0.01em; color: var(--ink);
  -webkit-text-stroke: 0.12em #FFFFFF; paint-order: stroke fill; text-shadow: 0 3px 0 rgba(201, 59, 242, 0.35); }
.section-note { font-family: var(--round); color: var(--ink-soft); font-size: 0.95rem; font-weight: 500; }
.section-note b { font-family: var(--display); font-weight: 400; font-size: 1.15em; color: var(--purple-deep); font-variant-numeric: tabular-nums; }
.link { font-family: var(--round); font-weight: 600; font-size: 0.95rem; color: var(--purple-deep); text-underline-offset: 3px; }
.link:hover { color: var(--magenta); }

/* Juicy pill buttons: glossy top highlight, chunky base, springy press. */
.btn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 24px;
  font-family: var(--round); font-weight: 700; font-size: 1rem; letter-spacing: 0.01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 0.25s var(--spring), box-shadow 0.15s ease, filter 0.2s ease;
}
.btn::before {
  content: ""; position: absolute; z-index: -1; left: 8%; right: 8%; top: 3px; height: 45%;
  border-radius: 999px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn::after {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg); transition: left 0.5s ease; pointer-events: none;
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:hover::after { left: 120%; }
.btn:active { transform: translateY(3px) scale(0.97); transition-duration: 0.08s; }
.btn:disabled { filter: grayscale(0.6) opacity(0.7); cursor: progress; }
.btn-primary {
  color: #FFFFFF; text-shadow: 0 2px 0 rgba(90, 0, 130, 0.45);
  background: linear-gradient(180deg, #EA6BFF 0%, var(--purple) 48%, #A21FD8 100%);
  box-shadow: 0 5px 0 #7412A8, 0 10px 20px rgba(142, 28, 194, 0.35), inset 0 -3px 0 rgba(60, 0, 100, 0.18);
}
.btn-primary:active { box-shadow: 0 2px 0 #7412A8, 0 4px 10px rgba(142, 28, 194, 0.3), inset 0 -2px 0 rgba(60, 0, 100, 0.18); }
.btn-ghost {
  color: var(--purple-deep); background: linear-gradient(180deg, #FFFFFF 0%, #F6ECFC 100%);
  border: 2px solid #ECD8F7; box-shadow: 0 4px 0 #E3C9F2;
}
.btn-ghost:active { box-shadow: 0 1px 0 #E3C9F2; }
.btn-danger {
  color: #FFFFFF; text-shadow: 0 2px 0 rgba(110, 0, 30, 0.4);
  background: linear-gradient(180deg, #FF6A8F 0%, var(--danger) 55%, #B41E48 100%);
  box-shadow: 0 5px 0 #8E1636, 0 10px 18px rgba(217, 45, 91, 0.3);
}
.btn-danger-ghost { background: transparent; color: var(--danger); border: 2px solid #F2C3D0; font-size: 0.9rem; padding: 9px 18px; }
.btn-danger-ghost::before, .btn-danger-ghost::after { display: none; }
.btn-danger-ghost:hover { background: #FDEFF3; }
.btn-icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* View change: content rises in, a section at a time. */
.view.enter > * { animation: rise 0.55s var(--spring) backwards; }
.view.enter > *:nth-child(2) { animation-delay: 0.06s; }
.view.enter > *:nth-child(3) { animation-delay: 0.12s; }
.view.enter > *:nth-child(4) { animation-delay: 0.18s; }
.view-game.enter .stage-frame { animation: zoom-in 0.45s var(--spring) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.94); } }

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 24px; align-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 55%, rgba(110, 20, 190, 0.55) 100%),
    linear-gradient(180deg, #2E98F2 0%, #5CB8FF 38%, #9F7BF4 72%, #8A2BE0 100%);
  color: #FFFFFF; border-radius: 28px; padding: 34px 36px 30px;
  position: relative; overflow: hidden;
  border: 3px solid #FFFFFF;
  box-shadow: 0 8px 0 #D9B8F0, 0 22px 50px rgba(110, 30, 160, 0.25);
}
/* soft sun glow + speed lines along the base, as on the Kaotim Run poster */
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(420px 260px at 82% 12%, rgba(255, 255, 255, 0.55), transparent 70%),
    repeating-linear-gradient(-8deg, transparent 0 26px, rgba(255, 255, 255, 0.07) 26px 28px);
}
.hero::after {
  content: ""; position: absolute; left: -10%; right: -10%; bottom: -2px; height: 46px; pointer-events: none;
  background:
    linear-gradient(90deg, transparent 5%, rgba(255, 216, 102, 0.9) 30%, transparent 55%) 0 8px / 100% 4px no-repeat,
    linear-gradient(90deg, transparent 35%, rgba(255, 255, 255, 0.8) 60%, transparent 85%) 0 22px / 100% 3px no-repeat,
    linear-gradient(90deg, transparent 15%, rgba(244, 120, 255, 0.9) 40%, transparent 70%) 0 34px / 100% 5px no-repeat;
  animation: streak 3.5s linear infinite;
}
@keyframes streak { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
.hero .eyebrow { color: #FFE38A; text-shadow: 0 2px 0 rgba(60, 0, 110, 0.35); }
.hero > * { position: relative; z-index: 1; }
.hero > .hero-clouds, .hero > .hero-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hc { position: absolute; left: 0; opacity: 0.85; max-width: none; animation: drift linear infinite; will-change: transform; }
.hc-1 { top: 4%; width: 200px; animation-duration: 40s; animation-delay: -6s; }
.hc-2 { top: 50%; width: 150px; animation-duration: 54s; animation-delay: -30s; opacity: 0.6; }
.hc-3 { top: 20%; width: 120px; animation-duration: 66s; animation-delay: -12s; opacity: 0.55; }
@keyframes drift { from { transform: translateX(-220px); } to { transform: translateX(1200px); } }

/* Floating glossy Kaotim marks (the logo shape, filled with a magenta gloss). */
.hero-mark {
  position: absolute; width: var(--s, 56px); aspect-ratio: 218 / 256;
  -webkit-mask: url("../assets/kaotim-mark-white.png") center / contain no-repeat;
  mask: url("../assets/kaotim-mark-white.png") center / contain no-repeat;
  background:
    radial-gradient(60% 45% at 35% 25%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, #F58BFF 0%, var(--magenta) 45%, #8A12C8 100%);
  animation: floaty 5s ease-in-out infinite; will-change: transform;
}
.hero-mark-glow { filter: drop-shadow(0 0 6px rgba(255, 214, 102, 0.9)) drop-shadow(0 4px 0 rgba(70, 0, 120, 0.45)); position: absolute; inset: 0; }
.hm-1 { --s: 74px; right: 5%; top: 8%; animation-delay: -1s; }
.hm-2 { --s: 40px; right: 34%; top: 6%; animation-delay: -2.4s; animation-duration: 6s; }
.hm-3 { --s: 52px; right: 1.5%; bottom: 2%; animation-delay: -3.2s; animation-duration: 5.6s; }
.hm-4 { --s: 30px; left: 46%; bottom: 10%; animation-delay: -0.6s; animation-duration: 4.4s; }
.hm-5 { --s: 34px; right: 28%; bottom: 3%; animation-delay: -4s; animation-duration: 6.4s; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-12px) rotate(6deg); }
}
/* Twinkling 4-point sparkles. */
.spark {
  position: absolute; width: var(--s, 18px); height: var(--s, 18px);
  background: radial-gradient(circle, #FFFFFF 0 20%, #FFE38A 45%, rgba(255, 201, 77, 0) 72%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: twinkle 2.2s ease-in-out infinite; will-change: transform, opacity;
}
.sp-1 { --s: 22px; left: 40%; top: 12%; }
.sp-2 { --s: 16px; right: 18%; top: 38%; animation-delay: -0.7s; }
.sp-3 { --s: 26px; left: 8%; bottom: 18%; animation-delay: -1.3s; }
.sp-4 { --s: 14px; right: 40%; bottom: 22%; animation-delay: -1.8s; }
.sp-5 { --s: 18px; right: 12%; top: 4%; animation-delay: -0.3s; }
@keyframes twinkle {
  0%, 100% { transform: scale(0.4) rotate(0deg); opacity: 0.3; }
  50% { transform: scale(1.1) rotate(45deg); opacity: 1; }
}

.hero h1 { font-size: clamp(2.8rem, 7vw, 4.6rem); margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 0 0.25em; }
.hero h1 .t1 { display: inline-block; transform: rotate(-3deg); }
.hero h1 .t2 {
  display: inline-block; transform: rotate(-3deg) translateY(2px);
  background: none; color: #FFFFFF;
  -webkit-text-stroke-color: #C21FE0;
  text-shadow:
    0 0.05em 0 #9A15CF, 0 0.09em 0 #7410AD, 0 0.13em 0 #540A86,
    0 0.2em 0.25em rgba(50, 0, 90, 0.5),
    0 0 0.35em rgba(255, 201, 77, 0.9);
}
.hero .tagline { font-family: var(--round); font-weight: 700; font-size: 0.95rem; letter-spacing: 0.22em; text-transform: uppercase; color: #FFFFFF; text-shadow: 0 2px 0 rgba(60, 0, 110, 0.4); margin-bottom: 10px; }
.hero .lede { color: rgba(255, 255, 255, 0.95); text-shadow: 0 1px 2px rgba(40, 0, 80, 0.35); }
.hero-cta { margin-top: 18px; padding: 8px 26px 8px 8px; font-size: 1.1rem; }
.hero-cta .cta-icon {
  width: 40px; height: 40px; border-radius: 50%; background: #FFFFFF; display: grid; place-items: center;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.hero-cta .cta-icon svg { width: 26px; height: 26px; }
.hero-cta:hover .cta-icon { animation: wiggle 0.5s ease; }
@keyframes wiggle { 25% { transform: rotate(-12deg); } 75% { transform: rotate(10deg); } }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.how li {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.92); color: var(--ink); border-radius: 16px; padding: 10px 14px; font-size: 0.95rem;
  box-shadow: 0 4px 0 rgba(90, 20, 150, 0.35);
  animation: rise 0.6s var(--spring) backwards;
}
.how li b { font-family: var(--round); color: var(--purple-deep); }
.how li:nth-child(2) { animation-delay: 0.08s; }
.how li:nth-child(3) { animation-delay: 0.16s; }
.how li:nth-child(4) { animation-delay: 0.24s; }
.how-step {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--display); font-size: 1rem; color: var(--ink);
  background: radial-gradient(circle at 35% 30%, #FFF6C9 0 18%, #FFD34D 45%, var(--gold-deep) 100%);
  box-shadow: 0 2px 0 #C67F00, inset 0 -2px 0 rgba(160, 90, 0, 0.3);
  display: grid; place-items: center;
}

.stage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stage-card {
  display: flex; flex-direction: column; text-align: left; font: inherit;
  background: var(--card); border: 3px solid #FFFFFF; border-radius: var(--radius);
  padding: 0; overflow: hidden; cursor: pointer; color: inherit;
  box-shadow: 0 0 0 2px var(--line), var(--chunky);
  transition: transform 0.3s var(--spring), box-shadow 0.2s ease;
  animation: rise 0.5s var(--spring) backwards;
}
.stage-card:nth-child(2) { animation-delay: 0.05s; }
.stage-card:nth-child(3) { animation-delay: 0.1s; }
.stage-card:nth-child(4) { animation-delay: 0.15s; }
.stage-card:nth-child(5) { animation-delay: 0.2s; }
.stage-card:hover:not([aria-disabled="true"]) {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
  box-shadow: 0 0 0 3px var(--purple), 0 10px 0 #D7AEEF, 0 24px 40px rgba(142, 28, 194, 0.25);
}
.stage-card:active:not([aria-disabled="true"]) { transform: translateY(1px) scale(0.98); }
.stage-card[aria-disabled="true"] { cursor: not-allowed; }
.stage-card[aria-disabled="true"]:hover .stage-lock svg { animation: wiggle 0.5s ease; }
.stage-thumb { position: relative; aspect-ratio: 16 / 9; width: 100%; max-width: 100%; background: #CDEBFF; overflow: hidden; }
.stage-thumb canvas { width: 100%; height: 100%; display: block; transition: transform 0.5s ease; }
.stage-card:hover:not([aria-disabled="true"]) .stage-thumb canvas { transform: scale(1.06); }
.stage-num {
  position: absolute; left: 10px; top: 10px; width: 42px; height: 42px; border-radius: 50%;
  font-family: var(--display); font-size: 1.35rem; color: var(--ink);
  background: radial-gradient(circle at 35% 30%, #FFF6C9 0 16%, #FFD34D 45%, var(--gold-deep) 100%);
  border: 3px solid #FFFFFF;
  display: grid; place-items: center;
  box-shadow: 0 3px 0 rgba(120, 60, 0, 0.45);
}
.stage-lock {
  position: absolute; inset: 0; color: #FFFFFF;
  background: linear-gradient(180deg, rgba(91, 14, 150, 0.55), rgba(42, 15, 61, 0.75));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: grid; place-items: center; text-align: center; font-family: var(--round); font-weight: 600; font-size: 0.95rem; padding: 12px;
}
.stage-lock svg { width: 30px; height: 30px; display: block; margin: 0 auto 6px; fill: none; stroke: #FFE38A; stroke-width: 2.2; }
.stage-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.stage-title { font-family: var(--display); font-size: 1.3rem; letter-spacing: 0.01em; color: var(--ink); }
.stage-tag { font-size: 0.85rem; color: var(--ink-soft); }
.stage-meta {
  display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 0.85rem;
  font-family: var(--round); font-weight: 500; background: #F8F1FD; border-radius: 999px; padding: 4px 6px 4px 10px;
}
.stage-meta b { font-family: var(--display); font-weight: 400; font-size: 1.05rem; color: var(--purple-deep); font-variant-numeric: tabular-nums; }
.mini-stars { display: inline-flex; gap: 2px; }
.star { width: 18px; height: 18px; display: inline-block; overflow: visible; }
.star path { fill: #E3D8EC; stroke: #D3C4E0; stroke-width: 1; stroke-linejoin: round; }
.star.on path { fill: url(#star-gold); stroke: #D98A00; stroke-width: 1.4; }
.star.on { filter: drop-shadow(0 1px 0 rgba(160, 90, 0, 0.45)); }

/* ---------- bear picker ---------- */
.bear-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.bear-option {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left; font: inherit;
  background: var(--card); border: 3px solid #FFFFFF; border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; color: inherit;
  box-shadow: 0 0 0 2px var(--line), var(--chunky);
  transition: box-shadow 0.2s ease, transform 0.3s var(--spring);
}
.bear-option canvas { width: 76px; height: 76px; flex: none; border-radius: 18px; }
.bear-boy canvas { background: radial-gradient(circle at 50% 35%, #FFFFFF, #CFE5FF); }
.bear-girl canvas { background: radial-gradient(circle at 50% 35%, #FFFFFF, #FFD6E9); }
.bear-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bear-name { font-family: var(--display); font-size: 1.35rem; letter-spacing: 0.01em; }
.bear-desc { font-size: 0.85rem; color: var(--ink-soft); }
.bear-check {
  margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); background: #FFFFFF;
  transition: transform 0.35s var(--spring);
}
.bear-option:hover { transform: translateY(-3px); }
.bear-option:active { transform: translateY(1px) scale(0.98); }
.bear-boy[aria-checked="true"] { box-shadow: 0 0 0 3px #5AA2F0, 0 6px 0 #B9D8FA, 0 16px 30px rgba(90, 162, 240, 0.28); }
.bear-girl[aria-checked="true"] { box-shadow: 0 0 0 3px #F28BBB, 0 6px 0 #F8C6DD, 0 16px 30px rgba(244, 151, 192, 0.32); }
.bear-option[aria-checked="true"] .bear-check {
  border-color: #FFFFFF; transform: scale(1.1);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 16px no-repeat,
    linear-gradient(180deg, #EA6BFF, #A21FD8);
  box-shadow: 0 3px 0 #7412A8;
}
.bear-option[aria-checked="true"] canvas { animation: hop 1.2s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-5px) rotate(-4deg); } }

/* ---------- leaderboard ---------- */
.board-card {
  background: var(--card); border: 3px solid #FFFFFF; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 2px var(--line), var(--chunky);
}
.lb-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 80px 120px; align-items: center; gap: 12px;
  padding: 12px 18px; border-top: 2px dashed #F1E6F8; font-variant-numeric: tabular-nums;
  animation: slide-in 0.45s var(--spring) backwards;
}
.lb-row:first-child { border-top: 0; }
.lb-row:nth-child(2) { animation-delay: 0.03s; } .lb-row:nth-child(3) { animation-delay: 0.06s; }
.lb-row:nth-child(4) { animation-delay: 0.09s; } .lb-row:nth-child(5) { animation-delay: 0.12s; }
.lb-row:nth-child(6) { animation-delay: 0.15s; } .lb-row:nth-child(7) { animation-delay: 0.18s; }
.lb-row:nth-child(8) { animation-delay: 0.21s; } .lb-row:nth-child(9) { animation-delay: 0.24s; }
.lb-row:nth-child(10) { animation-delay: 0.27s; } .lb-row:nth-child(11) { animation-delay: 0.3s; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-14px); } }
.board-card.quiet .lb-row, .stage-grid.quiet .stage-card { animation: none; }
.lb-head {
  font-family: var(--round); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: #FFFFFF; background: linear-gradient(180deg, #DB5AF8, #A51FDB); text-shadow: 0 1px 0 rgba(80, 0, 120, 0.4);
  animation: none;
}
.lb-rank {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: 1rem; background: #F4ECFA; color: var(--ink-soft);
}
.lb-row[data-rank="1"] .lb-rank, .lb-row[data-rank="2"] .lb-rank, .lb-row[data-rank="3"] .lb-rank {
  width: 38px; height: 38px; font-size: 1.15rem; color: var(--ink); border: 3px solid #FFFFFF; position: relative; overflow: hidden;
}
.lb-row[data-rank="1"] .lb-rank { background: radial-gradient(circle at 35% 30%, #FFF6C9 0 16%, #FFD34D 45%, var(--gold-deep) 100%); box-shadow: 0 3px 0 #C67F00, 0 0 0 2px #FFD34D; }
.lb-row[data-rank="2"] .lb-rank { background: radial-gradient(circle at 35% 30%, #FFFFFF 0 16%, #DCD6E4 50%, #A79DB6 100%); box-shadow: 0 3px 0 #8B8199, 0 0 0 2px #DCD6E4; }
.lb-row[data-rank="3"] .lb-rank { background: radial-gradient(circle at 35% 30%, #FFE8D2 0 16%, #F0B98A 50%, #C97A3D 100%); box-shadow: 0 3px 0 #9A5A2A, 0 0 0 2px #F0B98A; }
.lb-row[data-rank="1"] .lb-rank::after {
  content: ""; position: absolute; top: -20%; bottom: -20%; width: 30%; left: -50%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: skewX(-20deg); animation: shine 2.8s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -50%; } 100% { left: 130%; } }
.lb-id { font-family: var(--round); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.lb-avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; background: #F6EEFB; }
.lb-you {
  font-family: var(--round); font-size: 0.72rem; font-weight: 700; color: #FFFFFF; border-radius: 999px; padding: 2px 9px; margin-left: 4px;
  background: linear-gradient(180deg, #EA6BFF, #A21FD8); box-shadow: 0 2px 0 #7412A8;
}
.lb-row.is-you { background: linear-gradient(90deg, #FBEFFF, #FFF8E6); }
.lb-stars { font-family: var(--round); color: var(--ink-soft); font-size: 0.92rem; font-weight: 500; }
.lb-points { text-align: right; font-family: var(--display); font-size: 1.2rem; color: var(--purple-deep); }
.lb-row[data-rank="1"] .lb-points { color: #C27400; }
.lb-head .lb-points { font-family: var(--round); font-size: inherit; color: inherit; }
.lb-head .lb-stars { font-family: inherit; color: inherit; font-size: inherit; font-weight: inherit; }
.admin-card {
  background: var(--card); border: 3px solid #FFFFFF; border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 14px; max-width: 640px;
  box-shadow: 0 0 0 2px var(--line), var(--chunky);
}
.admin-card h1 { font-size: 2.2rem; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 0; border-block: 2px dashed var(--line); }
.admin-row h2 { font-family: var(--round); font-size: 1.05rem; font-weight: 700; }
.admin-row p { color: var(--ink-soft); font-size: 0.9rem; margin-top: 2px; max-width: 40ch; }
.foot-admin { font-size: 0.7rem; color: var(--ink-soft); opacity: 0.5; text-decoration: none; }
.foot-admin:hover, .foot-admin:focus-visible { opacity: 1; text-decoration: underline; }
.sync-note { margin-top: 14px; font-family: var(--round); font-size: 0.88rem; font-weight: 500; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 8px; }
.sync-note::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--ink-soft); }
.sync-note[data-status="online"]::before { background: var(--grass); box-shadow: 0 0 0 0 rgba(93, 181, 72, 0.6); animation: ping 1.8s ease-out infinite; }
.sync-note[data-status="offline"]::before { background: var(--gold); }
@keyframes ping { 70%, 100% { box-shadow: 0 0 0 8px rgba(93, 181, 72, 0); } }
.field-pin { text-transform: none; letter-spacing: 0.3em; }
.lb-empty { padding: 30px 18px; text-align: center; color: var(--ink-soft); }
.lb-empty b { font-family: var(--display); font-weight: 400; color: var(--ink); display: block; font-size: 1.3rem; margin-bottom: 4px; }

.lb-banner {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 24px 28px; border-radius: 26px; position: relative; overflow: hidden;
  color: #FFFFFF; border: 3px solid #FFFFFF;
  background:
    radial-gradient(360px 200px at 90% 0%, rgba(255, 255, 255, 0.35), transparent 70%),
    repeating-linear-gradient(-8deg, transparent 0 26px, rgba(255, 255, 255, 0.07) 26px 28px),
    linear-gradient(135deg, #D84BF8 0%, #9B1FD3 60%, #6A10B0 100%);
  box-shadow: 0 8px 0 #D9B8F0, 0 20px 44px rgba(110, 30, 160, 0.25);
}
.lb-banner .eyebrow { color: #FFE38A; }
.lb-banner .lede { color: rgba(255, 255, 255, 0.92); }
.lb-banner h1 { font-size: clamp(2.4rem, 5vw, 3.4rem); margin: 6px 0 8px; }
.lb-banner .btn-primary {
  color: var(--ink); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #FFF0A8 0%, #FFD34D 50%, var(--gold-deep) 100%);
  box-shadow: 0 5px 0 #B87300, 0 10px 20px rgba(60, 0, 100, 0.3);
}
.board-full .lb-row { padding-block: 14px; }
.you-rank { margin-top: 12px; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- game ---------- */
.view-game { padding: 0; }
body.playing { overflow: hidden; overscroll-behavior: none; }
body.playing .foot, body.playing .brand, body.playing .tabs, body.playing .player-chip { display: none; }
/* Only the sound and music buttons stay from the header, down in the corner of the stage. */
body.playing .topbar { display: contents; }
body.playing .audio-toggles {
  position: fixed; z-index: 1; margin: 0;
  right: max(10px, env(safe-area-inset-right, 0px)); bottom: max(10px, env(safe-area-inset-bottom, 0px));
}
.stage-frame {
  position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100dvh;
  overflow: hidden; background: #6EC2FF;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#game-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#game-canvas:active { cursor: grabbing; }

.hud {
  --pad: clamp(8px, 1.6vw, 16px);
  position: absolute; inset: 0 0 auto 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: max(var(--pad), env(safe-area-inset-top, 0px)) max(var(--pad), env(safe-area-inset-right, 0px)) 0 max(var(--pad), env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud-stage, .hud-score, .hud-mid {
  background: linear-gradient(180deg, #FFFFFF 0%, #F6EDFC 100%); border: 2px solid #FFFFFF; border-radius: 999px;
  box-shadow: 0 3px 0 rgba(110, 30, 160, 0.35), 0 6px 14px rgba(42, 15, 61, 0.12);
}
.hud-stage { font-family: var(--round); font-weight: 700; padding: 5px 14px; font-size: clamp(0.72rem, 1.4vw, 0.95rem); color: var(--purple-deep); }
.hud-score { display: inline-flex; gap: 8px; align-items: baseline; padding: 3px 14px; font-variant-numeric: tabular-nums; }
.hud-score b { font-family: var(--display); font-weight: 400; font-size: clamp(0.95rem, 2vw, 1.35rem); color: var(--ink); display: inline-block; min-width: 2ch; }
.hud-score small { font-family: var(--round); font-size: clamp(0.6rem, 1vw, 0.72rem); color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.hud-mid { display: flex; gap: 4px; padding: 4px 10px; align-items: center; }
.hud-mid canvas { width: clamp(20px, 2.6vw, 30px); height: clamp(20px, 2.6vw, 30px); transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s var(--spring); }
.hud-mid canvas.used { opacity: 0.25; filter: grayscale(1); transform: scale(0.8); }
.hud-right { display: flex; gap: 8px; }
.icon-btn {
  width: clamp(34px, 4vw, 44px); height: clamp(34px, 4vw, 44px); border-radius: 50%;
  border: 2px solid #FFFFFF; background: linear-gradient(180deg, #FFFFFF, #F1E6F9); cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 3px 0 rgba(110, 30, 160, 0.35); transition: transform 0.25s var(--spring);
}
.icon-btn:hover { transform: rotate(-30deg); }
.icon-btn:active { transform: rotate(-90deg) scale(0.92); }
.end-btn {
  height: clamp(34px, 4vw, 44px); border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.85); padding: 0 16px 0 12px;
  background: linear-gradient(180deg, #4A1E6B 0%, var(--ink) 100%); color: #FFFFFF;
  font-family: var(--round); font-weight: 700; font-size: clamp(0.75rem, 1.4vw, 0.92rem);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; box-shadow: 0 3px 0 #12041C;
  transition: transform 0.25s var(--spring);
}
.end-btn:hover { transform: translateY(-1px); }
.end-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #12041C; }
.end-btn svg { width: 18px; height: 18px; fill: none; stroke: #FFFFFF; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.quit-title { font-family: var(--display); font-weight: 400; font-size: 1.9rem; color: var(--ink) !important; -webkit-text-stroke: 0; text-shadow: 0 3px 0 rgba(201, 59, 242, 0.3) !important; }
.quit-copy { color: var(--ink-soft); font-size: 0.95rem; line-height: 1.5; margin: 4px 0 18px; }
.icon-btn svg { width: 55%; height: 55%; fill: none; stroke: var(--purple-deep); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.hint {
  position: absolute; left: 22%; top: 46%; transform: translate(-50%, -50%);
  font-family: var(--round); font-weight: 600; font-size: clamp(0.78rem, 1.5vw, 1.05rem); color: #FFFFFF;
  background: linear-gradient(180deg, #E565FF, #A51FDB); border: 2px solid #FFFFFF;
  box-shadow: 0 4px 0 #7412A8, 0 10px 20px rgba(60, 0, 100, 0.3);
  padding: 10px 16px 10px 12px; border-radius: 999px; display: flex; align-items: center; gap: 10px;
  pointer-events: none; animation: bob 1.6s ease-in-out infinite; white-space: nowrap;
}
.hint-hand {
  width: 22px; height: 22px; border-radius: 50%; position: relative; animation: tug 1.6s ease-in-out infinite;
  background: radial-gradient(circle at 35% 30%, #FFF6C9 0 18%, #FFD34D 50%, var(--gold-deep) 100%);
}
@keyframes bob { 50% { transform: translate(-50%, calc(-50% - 5px)); } }
@keyframes tug { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-8px, 6px); } }

.overlay {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(91, 14, 150, 0.35), rgba(42, 15, 61, 0.62));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  padding: 16px; animation: fade-in 0.25s ease backwards;
}
@keyframes fade-in { from { opacity: 0; } }
.overlay-page { position: fixed; z-index: 50; }
.result-card, .modal {
  position: relative; isolation: isolate;
  width: min(460px, 100%); background: var(--card); border-radius: 28px; padding: 24px 26px;
  text-align: center; border: 4px solid #FFFFFF;
  box-shadow: 0 0 0 3px var(--purple), 0 10px 0 #A51FDB, 0 30px 60px rgba(42, 15, 61, 0.45);
  max-height: 100%; overflow: auto;
  animation: card-in 0.5s var(--spring) backwards;
}
@keyframes card-in { from { opacity: 0; transform: scale(0.6) translateY(30px); } }
.result-card.lose { animation: card-in 0.5s var(--spring) backwards, nudge 0.5s 0.45s ease; }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
/* Win: a slowly turning sunburst behind the headline. */
#result .result-card:not(.lose)::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 70px; width: 520px; height: 520px; margin: -260px 0 0 -260px;
  background: repeating-conic-gradient(rgba(255, 201, 77, 0.22) 0 10deg, rgba(255, 201, 77, 0) 10deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 62%); mask: radial-gradient(circle, #000 20%, transparent 62%);
  animation: spin 18s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-kicker { font-family: var(--round); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.result-card h2 { font-size: clamp(2.2rem, 6vw, 3.2rem); margin: 6px 0 8px; }
#result-title { animation: title-pop 0.7s 0.15s var(--spring) backwards; }
@keyframes title-pop { from { opacity: 0; transform: scale(0.3) rotate(-8deg); } }
.result-card.lose h2 { color: var(--ink); -webkit-text-stroke-color: #FFFFFF; text-shadow: 0 0.06em 0 #E9D4F5, 0 0.1em 0 rgba(201, 59, 242, 0.4), 0 0.16em 0.2em rgba(42, 15, 61, 0.2); }
.stars { display: flex; justify-content: center; gap: 10px; margin: 4px 0 12px; }
.stars .star { width: clamp(38px, 7vw, 56px); height: clamp(38px, 7vw, 56px); }
.stars .star:nth-child(2) { transform: translateY(-8px) scale(1.12); }
.stars .star.on { animation: star-pop 0.55s var(--spring) backwards; animation-delay: 0.35s; }
.stars .star.on:nth-child(2) { animation-name: star-pop-mid; animation-delay: 0.55s; }
.stars .star.on:nth-child(3) { animation-delay: 0.75s; }
.stars .star.on { filter: drop-shadow(0 3px 0 rgba(160, 90, 0, 0.45)) drop-shadow(0 0 10px rgba(255, 201, 77, 0.7)); }
@keyframes star-pop { from { opacity: 0; transform: scale(0.1) rotate(-120deg); } }
@keyframes star-pop-mid { from { opacity: 0; transform: translateY(-8px) scale(0.1) rotate(-120deg); } }
.breakdown {
  display: grid; grid-template-columns: 1fr auto; gap: 5px 16px; margin: 0 0 10px; text-align: left; font-size: 0.9rem; font-variant-numeric: tabular-nums;
  background: #F9F3FD; border-radius: 16px; padding: 12px 14px;
}
.breakdown dt { color: var(--ink-soft); }
.breakdown dd { margin: 0; text-align: right; font-family: var(--round); font-weight: 600; }
.breakdown .total { border-top: 2px dashed var(--line); padding-top: 8px; font-family: var(--round); font-weight: 700; color: var(--ink); font-size: 1rem; }
.breakdown dd.total { font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: var(--purple-deep); line-height: 1.1; }
.result-note { font-family: var(--round); font-size: 0.9rem; color: var(--purple-deep); font-weight: 600; min-height: 1.2em; margin-bottom: 14px; }
.result-actions, .modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.result-actions .btn { padding: 11px 18px; }

.modal { text-align: left; }
.modal-badge { width: 60px; height: 60px; border-radius: 18px; display: block; margin-bottom: 12px; box-shadow: 0 4px 0 var(--purple-deep); animation: badge-bounce 0.7s 0.2s var(--spring) backwards; }
@keyframes badge-bounce { from { transform: scale(0.3) rotate(-25deg); } }
.modal h2 { font-family: var(--display); font-weight: 400; font-size: 1.9rem; letter-spacing: 0.01em; }
.modal-copy { color: var(--ink-soft); margin: 6px 0 16px; line-height: 1.5; font-size: 0.95rem; }
.field-label { display: block; font-family: var(--round); font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.field {
  width: 100%; border: 3px solid var(--line); border-radius: 16px; padding: 12px 14px;
  font-family: var(--round); font-size: 1.15rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); background: #FBF8FD;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.field:focus { border-color: var(--purple); outline: none; background: #FFFFFF; box-shadow: 0 0 0 5px rgba(201, 59, 242, 0.18); }
.field[aria-invalid="true"] { border-color: var(--danger); animation: nudge 0.4s ease; }
.field-error { color: var(--danger); font-size: 0.85rem; margin-top: 6px; }
.modal-actions { justify-content: flex-end; margin-top: 18px; }

/* 3-2-1 countdown before Stage 1 */
.countdown {
  position: absolute; inset: 0; z-index: 35; display: grid; place-items: center; align-content: center; gap: 4px;
  background: radial-gradient(circle at 50% 50%, rgba(91, 14, 150, 0.15), rgba(42, 15, 61, 0.5));
  pointer-events: auto;
}
.countdown-label {
  font-family: var(--round); font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: #FFFFFF;
  font-size: clamp(0.9rem, 2.4vw, 1.4rem); text-shadow: 0 2px 0 rgba(60, 0, 110, 0.5);
}
.countdown-num { font-size: clamp(5rem, 22vw, 13rem); line-height: 1; }
.countdown-num.tick { animation: count-pop 0.7s var(--spring) both; }
.countdown-num.go { color: #FFE38A; -webkit-text-stroke-color: #C21FE0; }
@keyframes count-pop {
  0% { opacity: 0; transform: scale(2.4) rotate(-10deg); }
  35% { opacity: 1; transform: scale(0.9) rotate(3deg); }
  55% { transform: scale(1.06) rotate(0); }
  100% { opacity: 1; transform: scale(1); }
}

/* Phone held upright during play: suggest turning it (can be dismissed). */
.rotate-card { display: none; position: fixed; z-index: 40; background: rgba(42, 15, 61, 0.92); }
.rotate-phone {
  width: 46px; height: 76px; margin: 4px auto 14px; border: 4px solid var(--purple); border-radius: 10px;
  animation: rotate-hint 2.4s ease-in-out infinite;
}
@keyframes rotate-hint { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }

.foot {
  max-width: 1120px; width: 100%; margin: auto auto 0; padding-block: 16px 20px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--ink-soft); border-top: 2px dashed var(--line);
}

/* Confetti and sparkle layer drawn by js/fx.js */
.fx-layer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }


/* ---------- Kaotim Challenge extras ---------- */
/* Hero call to action: glossy shine that sweeps across, and a gentle heartbeat. */
.hero-cta { position: relative; overflow: hidden; animation: cta-beat 2.4s ease-in-out infinite; }
.hero-cta .cta-text { font-family: var(--display); font-weight: 400; font-size: 1.35rem; letter-spacing: 0.02em; }
.hero-cta::after {
  content: ""; position: absolute; top: -20%; bottom: -20%; width: 28%; left: -40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: skewX(-20deg); animation: shine 3.2s ease-in-out infinite;
}
@keyframes cta-beat { 0%, 70%, 100% { transform: scale(1); } 78% { transform: scale(1.06); } 86% { transform: scale(0.99); } 92% { transform: scale(1.03); } }

/* Mascot bear peeking over the how-to cards, with a speech bubble. */
.hero-side { position: relative; display: flex; flex-direction: column; }
.mascot { position: relative; align-self: flex-end; width: 112px; height: 92px; margin: -14px 18px -26px 0; z-index: 2; pointer-events: none; }
.mascot-bear {
  width: 112px; height: 112px; display: block;
  filter: drop-shadow(0 6px 0 rgba(70, 0, 120, 0.35));
  transform-origin: 50% 100%; animation: mascot-bob 2.6s ease-in-out infinite;
}
@keyframes mascot-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1, 1); }
  10% { transform: translateY(2px) rotate(-4deg) scale(1.06, 0.94); }
  30% { transform: translateY(-16px) rotate(5deg) scale(0.97, 1.04); }
  50% { transform: translateY(0) rotate(-2deg) scale(1.04, 0.96); }
}
.hero-side .how li:first-child { padding-right: 132px; }
.mascot-bubble {
  position: absolute; right: 104px; top: 2px; white-space: nowrap;
  font-family: var(--display); font-size: 1.1rem; color: var(--purple-deep);
  background: #FFFFFF; padding: 6px 14px; border-radius: 16px;
  box-shadow: 0 4px 0 rgba(90, 20, 150, 0.35);
  transform-origin: 100% 100%;
}
.mascot-bubble::after {
  content: ""; position: absolute; right: -8px; bottom: 8px; border: 8px solid transparent; border-left-color: #FFFFFF; border-right: 0;
}
.mascot-bubble.pop { animation: bubble-pop 0.45s var(--spring); }
@keyframes bubble-pop { from { transform: scale(0.4) rotate(-8deg); opacity: 0; } }

/* News ticker: campaign headlines scroll past, pause on hover. */
.ticker {
  display: flex; align-items: center; gap: 0; margin-top: 18px; overflow: hidden;
  background: linear-gradient(180deg, #3A0F5E, #2A0F3D); color: #FFFFFF; border-radius: 999px;
  border: 3px solid #FFFFFF; box-shadow: 0 5px 0 #D9B8F0, 0 14px 30px rgba(70, 10, 120, 0.25);
}
.ticker-tag {
  flex: none; font-family: var(--display); font-size: 1rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink); padding: 8px 16px; border-radius: 999px; margin: 3px;
  background: linear-gradient(180deg, #FFE08A, var(--gold)); box-shadow: 0 2px 0 var(--gold-deep);
  animation: tag-blink 1.6s ease-in-out infinite;
}
@keyframes tag-blink { 50% { filter: brightness(1.15); transform: scale(1.05); } }
.ticker-window { flex: 1; min-width: 0; overflow: hidden; -webkit-mask: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); mask: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
.ticker-track { display: flex; width: max-content; animation: ticker 38s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tk { display: inline-flex; align-items: center; gap: 8px; padding: 0 28px; white-space: nowrap; font-size: 0.95rem; color: rgba(255, 255, 255, 0.92); }
.tk b { font-family: var(--round); color: #FFE38A; }
.tk-dot {
  width: 16px; height: 19px; flex: none;
  -webkit-mask: url("../assets/kaotim-mark-white.png") center / contain no-repeat; mask: url("../assets/kaotim-mark-white.png") center / contain no-repeat;
  background: linear-gradient(160deg, #F58BFF, var(--magenta));
}
.tk-crown { background: linear-gradient(160deg, #FFF3B0, var(--gold)); }

/* Stage journey: a road with five stops, filling up as stages are cleared. */
.journey { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); margin: 4px 0 22px; padding-top: 6px; }
.jr-road { position: absolute; left: 10%; right: 10%; top: 26px; height: 10px; border-radius: 99px; background: #EADCF5; overflow: hidden; box-shadow: inset 0 2px 0 rgba(90, 20, 150, 0.12); }
.jr-fill {
  height: 100%; width: var(--progress, 0%); border-radius: inherit;
  background: repeating-linear-gradient(-45deg, #FFD34D 0 10px, #FFC02E 10px 20px);
  background-size: 28px 28px; animation: road 1s linear infinite; transition: width 0.8s var(--spring);
}
@keyframes road { to { background-position: 28px 0; } }
.jr-stop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.jr-dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  font-family: var(--display); font-size: 1.15rem; color: var(--ink-soft);
  background: #FFFFFF; border: 3px solid #E3D2F0; box-shadow: 0 3px 0 #E3D2F0;
  animation: rise 0.5s var(--spring) backwards; animation-delay: calc(var(--i) * 0.07s);
}
.jr-dot .star { width: 24px; height: 24px; }
.jr-stop.done .jr-dot { background: radial-gradient(circle at 35% 30%, #FFFFFF, #FFF1C2); border-color: #FFD34D; box-shadow: 0 3px 0 #E0A100; }
.jr-stop.next .jr-dot { color: #FFFFFF; background: linear-gradient(180deg, #E565FF, var(--purple)); border-color: #FFFFFF; box-shadow: 0 3px 0 #7412A8, 0 0 0 0 rgba(201, 59, 242, 0.5); animation: jr-pulse 1.6s ease-out infinite; }
@keyframes jr-pulse { 0% { box-shadow: 0 3px 0 #7412A8, 0 0 0 0 rgba(201, 59, 242, 0.55); } 100% { box-shadow: 0 3px 0 #7412A8, 0 0 0 16px rgba(201, 59, 242, 0); } }
.jr-bear { position: absolute; top: -30px; width: 40px; height: 40px; z-index: 2; animation: hop 1s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(70, 0, 120, 0.3)); }
.jr-name { font-family: var(--round); font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); line-height: 1.2; }
.jr-stop.next .jr-name { color: var(--purple-deep); }
.journey.all-clear .jr-fill { background: linear-gradient(90deg, #FFD34D, #F58BFF, #FFD34D); background-size: 200% 100%; }

/* Stage cards: glare that follows the pointer while the card tilts. */
.stage-card { position: relative; transform-style: preserve-3d; }
.stage-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity 0.25s ease;
  background: radial-gradient(260px 180px at var(--gx, 50%) 0%, rgba(255, 255, 255, 0.45), transparent 70%);
}
.stage-card:hover:not([aria-disabled="true"])::after { opacity: 1; }

/* Leaderboard podium: 2nd, 1st, 3rd on steps. */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; margin: 6px 0 20px; padding: 0 4%; }
.pd { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; animation: rise 0.6s var(--spring) backwards; }
.pd-1 { animation-delay: 0.15s; } .pd-3 { animation-delay: 0.3s; }
.pd-avatar { width: 64px; height: 64px; border: 4px solid #FFFFFF; box-shadow: 0 4px 0 #E3D2F0; }
.pd-1 .pd-avatar { width: 84px; height: 84px; box-shadow: 0 4px 0 #E0A100, 0 0 0 4px #FFD34D, 0 0 24px rgba(255, 201, 77, 0.8); animation: hop 1.6s ease-in-out infinite; }
.pd-id { font-family: var(--round); font-weight: 700; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-points { font-family: var(--display); font-size: 1.3rem; color: var(--purple-deep); font-variant-numeric: tabular-nums; }
.pd-1 .pd-points { color: #C27400; font-size: 1.55rem; }
.pd-step {
  width: 100%; margin-top: 6px; border-radius: 16px 16px 6px 6px; display: grid; place-items: start center; padding-top: 10px;
  border: 3px solid #FFFFFF; box-shadow: 0 0 0 2px var(--line), var(--chunky);
}
.pd-1 .pd-step { height: 110px; background: linear-gradient(180deg, #FFE38A, #FFC94D 60%, #F2A007); }
.pd-2 .pd-step { height: 80px; background: linear-gradient(180deg, #FFFFFF, #DCD6E4 60%, #B9B0C6); }
.pd-3 .pd-step { height: 60px; background: linear-gradient(180deg, #FFE8D2, #F0B98A 60%, #C97A3D); }
.pd-rank { font-family: var(--display); font-size: 2rem; color: #FFFFFF; -webkit-text-stroke: 1.5px rgba(70, 20, 110, 0.55); text-shadow: 0 3px 0 rgba(70, 20, 110, 0.35); }
.pd-crown {
  position: absolute; top: -26px; width: 44px; height: 30px; z-index: 1; animation: floaty 2.4s ease-in-out infinite;
  background: linear-gradient(180deg, #FFF3B0, #FFC94D 55%, #E08A00);
  clip-path: polygon(0 100%, 0 30%, 25% 60%, 50% 0, 75% 60%, 100% 30%, 100% 100%);
  filter: drop-shadow(0 2px 0 #B06A00);
}
.pd.is-you .pd-id::after { content: " (you)"; color: var(--purple); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding: 24px 22px; }
  .stage-grid { grid-template-columns: 1fr; }
  .bear-options { gap: 12px; }
  .bear-option { padding: 10px; gap: 10px; }
  .bear-option canvas { width: 58px; height: 58px; }
  .bear-check { display: none; }
  .stage-card { flex-direction: row; }
  .stage-thumb { width: 44%; flex: none; aspect-ratio: 16 / 10; }
  .stage-body { min-width: 0; }
  .hm-2, .hm-4 { display: none; }
  .mascot { margin: -6px 10px -24px 0; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: 10px; border-radius: 24px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tab { flex: 1; text-align: center; }
  .audio-toggles { margin-left: auto; }
  .audio-btn { width: 34px; height: 34px; }
  .lb-row { grid-template-columns: 44px minmax(0, 1fr) auto; padding: 12px 14px; }
  .lb-stars { display: none; }
  .stage-card { flex-direction: column; }
  .stage-thumb { width: 100%; aspect-ratio: 16 / 9; }
  .section-head h2 { font-size: 1.5rem; }
  .lb-banner { padding: 20px; }
  .hero-cta { width: 100%; }
  .hm-1 { --s: 46px; top: 3%; right: 3%; }
  .hm-3 { --s: 40px; }
  .ticker-tag { padding: 6px 10px; font-size: 0.85rem; }
  .tk { font-size: 0.85rem; padding: 0 18px; }
  .jr-name { display: none; }
  .jr-dot { width: 36px; height: 36px; font-size: 1rem; }
  .jr-road { top: 22px; }
  .podium { gap: 8px; padding: 0; }
  .pd-avatar { width: 48px; height: 48px; }
  .pd-1 .pd-avatar { width: 62px; height: 62px; }
  .pd-points { font-size: 1.05rem; } .pd-1 .pd-points { font-size: 1.2rem; }
  .pd-id { font-size: 0.85rem; }
}
@media (max-width: 900px), (max-height: 520px) {
  .result-card { padding: 16px 18px; }
  .stars { margin-block: 4px; }
}
@media (orientation: portrait) and (max-width: 700px) {
  body.playing:not(.portrait-ok) .rotate-card { display: grid; }
}
/* Narrow screen (phone upright): compact HUD so nothing overlaps. */
@media (max-width: 520px) {
  body.playing .audio-toggles { display: none; }
  body.playing .end-label { display: none; }
  body.playing .end-btn { padding: 0 10px; }
  body.playing .hud { --pad: 6px; gap: 4px; }
  body.playing .hud-left { gap: 4px; }
  body.playing .hud-stage, body.playing .hud-score { padding: 2px 8px; font-size: 0.68rem; }
  body.playing .hud-score b { font-size: 0.85rem; }
  body.playing .hud-mid { padding: 2px 6px; }
  body.playing .hud-mid canvas { width: 16px; height: 16px; }
  body.playing .icon-btn, body.playing .end-btn { height: 30px; }
  body.playing .icon-btn { width: 30px; }
  body.playing .hint { font-size: 0.7rem; padding: 6px 10px 6px 8px; left: 50%; top: 58%; }
  body.playing .hint-hand { width: 14px; height: 14px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .topbar { padding-block: 6px; }
  .hud { --pad: 6px; }
  .hud-stage { padding: 3px 10px; }
  .hud-score { padding: 1px 10px; }
  .result-card { padding: 12px 18px; }
  .result-card h2 { font-size: 1.9rem; margin: 2px 0 4px; }
  .stars .star { width: 34px; height: 34px; }
  .breakdown { font-size: 0.8rem; padding: 8px 12px; gap: 2px 12px; }
  .breakdown dd.total { font-size: 1.2rem; }
  .result-note { margin-bottom: 8px; }
  .btn { padding: 9px 18px; font-size: 0.92rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
