:root {
  --bg: #0b1026;
  --bg2: #141b3d;
  --card: #1a2350;
  --card2: #222c63;
  --line: rgba(255, 255, 255, .12);
  --ink: #f4f6ff;
  --ink2: #b9c1ea;
  --neon: #3df5c0;
  --sun: #ffd23f;
  --pA: #2ee6a8;
  --pB: #6aa8ff;
  --pC: #ff8a4c;
  --radius: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", "Baloo 2", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }

.sky {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 62%, #cfe 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 71%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 56% 34%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 84%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 64% 90%, #cfe 50%, transparent 51%),
    radial-gradient(60% 45% at 50% 0%, #26327a 0%, transparent 70%),
    radial-gradient(50% 40% at 100% 100%, #3a1d6e 0%, transparent 70%),
    var(--bg);
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

.app {
  position: relative; z-index: 1;
  max-width: 540px; min-height: 100dvh; margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.screen { flex: 1; display: flex; flex-direction: column; animation: pop .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.screen.slide { animation: slide .3s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
.screen.slide-back { animation: slideb .3s ease-out; }
@keyframes slideb { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }

.mute {
  position: fixed; z-index: 5; top: max(12px, env(safe-area-inset-top)); right: 12px;
  width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 18px;
}

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; padding: 16px 20px; border-radius: 999px;
  font-weight: 900; font-size: 1.12rem; letter-spacing: .01em;
  background: linear-gradient(180deg, #5cffd2, #1fd6a2); color: #062b22;
  box-shadow: 0 6px 0 #0d8f6b, 0 14px 30px rgba(61, 245, 192, .25);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0d8f6b, 0 6px 14px rgba(61, 245, 192, .2); }
.btn[disabled] { opacity: .45; filter: grayscale(.6); pointer-events: none; }
.btn.ghost { background: rgba(255, 255, 255, .08); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); font-weight: 800; }
.btn.ghost:active { transform: scale(.98); }
.btn + .btn { margin-top: 14px; }
.link { background: none; color: var(--ink2); text-decoration: underline; padding: 10px; font-size: .95rem; }

/* ---------- home ---------- */
.home { text-align: center; justify-content: center; gap: 18px; }
.radar {
  position: relative; width: min(64vw, 260px); aspect-ratio: 1; margin: 6px auto 0; border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 24%, rgba(61, 245, 192, .35) 24.5% 25.5%, transparent 26% 49%, rgba(61, 245, 192, .35) 49.5% 50.5%, transparent 51% 74%, rgba(61, 245, 192, .35) 74.5% 75.5%, transparent 76%),
    linear-gradient(rgba(61, 245, 192, .22), rgba(61, 245, 192, .22)) center / 100% 1.5px no-repeat,
    linear-gradient(rgba(61, 245, 192, .22), rgba(61, 245, 192, .22)) center / 1.5px 100% no-repeat,
    radial-gradient(circle, #10305a, #0a1533 75%);
  box-shadow: 0 0 0 3px rgba(61, 245, 192, .6), 0 0 50px rgba(61, 245, 192, .35), inset 0 0 40px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.radar::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(61, 245, 192, .7), rgba(61, 245, 192, 0) 28%, transparent 100%);
  animation: sweep 3s linear infinite;
}
@keyframes sweep { to { transform: rotate(-360deg); } }
.radar .blip {
  position: absolute; width: 13%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%);
  animation: blip 3s ease-out infinite; display: grid; place-items: center; font-size: clamp(14px, 5vw, 22px);
}
@keyframes blip { 0%, 100% { opacity: .25; transform: translate(-50%, -50%) scale(.8); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); } 45% { opacity: .7; transform: translate(-50%, -50%) scale(1); } }
.home h1 { font-size: clamp(1.7rem, 7.4vw, 2.4rem); line-height: 1.1; margin: 8px 0 0; font-weight: 900; }
.home h1 em { font-style: normal; color: var(--neon); text-shadow: 0 0 22px rgba(61, 245, 192, .6); }
.tag { display: inline-block; align-self: center; padding: 6px 14px; border-radius: 999px; background: rgba(255, 210, 63, .15); color: var(--sun); font-weight: 800; font-size: .85rem; }
.rule { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink2); font-size: .98rem; text-align: left; display: flex; gap: 12px; align-items: flex-start; }
.rule b { color: var(--ink); }
.rule .ico { font-size: 1.6rem; line-height: 1; }
.meta { color: var(--ink2); font-size: .85rem; }

/* ---------- setup ---------- */
.setup h2 { font-size: 1.5rem; margin: 46px 0 4px; font-weight: 900; }
.setup p.sub { color: var(--ink2); margin: 0 0 14px; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.avatar {
  aspect-ratio: 1; border-radius: 20px; background: var(--card); font-size: clamp(1.7rem, 9vw, 2.4rem);
  box-shadow: inset 0 0 0 2px var(--line); transition: transform .12s, box-shadow .12s, background .12s;
}
.avatar.on { background: var(--card2); box-shadow: inset 0 0 0 3px var(--neon), 0 0 22px rgba(61, 245, 192, .45); transform: scale(1.08) rotate(-4deg); }
.ages { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.age { padding: 14px 8px; border-radius: 16px; background: var(--card); font-weight: 800; box-shadow: inset 0 0 0 2px var(--line); }
.age.on { box-shadow: inset 0 0 0 3px var(--sun); background: var(--card2); color: var(--sun); }
.setup .spacer { flex: 1; min-height: 18px; }

/* ---------- question ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding-right: 50px; min-height: 42px; }
.back { width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 18px; flex: none; }
.back[disabled] { opacity: .25; }
.me { font-size: 1.6rem; flex: none; }
.dots { flex: 1; display: flex; gap: 5px; align-items: center; }
.dot { flex: 1; height: 9px; border-radius: 9px; background: rgba(255, 255, 255, .13); transition: background .3s; }
.dot.done { background: var(--neon); box-shadow: 0 0 10px rgba(61, 245, 192, .7); }
.dot.now { background: var(--sun); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.scene {
  position: relative; margin-top: 14px; height: clamp(120px, 24vh, 190px); border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 6%;
  box-shadow: inset 0 0 0 1px var(--line), 0 14px 34px rgba(0, 0, 0, .35);
}
.scene::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 120%, rgba(0, 0, 0, .35), transparent 60%); pointer-events: none; }
.scene .e { font-size: clamp(2.6rem, 14vw, 4.4rem); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .35)); animation: float 3.4s ease-in-out infinite; position: relative; z-index: 1; }
.scene .e:nth-child(2) { font-size: clamp(3.4rem, 19vw, 5.8rem); animation-delay: -.9s; }
.scene .e:nth-child(3) { animation-delay: -1.8s; }
@keyframes float { 0%, 100% { transform: translateY(5px) rotate(-5deg); } 50% { transform: translateY(-9px) rotate(5deg); } }
.scene .bub { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .13); }
.place { position: absolute; left: 12px; top: 12px; z-index: 2; background: rgba(8, 12, 32, .6); backdrop-filter: blur(6px); border-radius: 999px; padding: 5px 12px; font-size: .8rem; font-weight: 800; }
.count { position: absolute; right: 12px; top: 12px; z-index: 2; background: rgba(8, 12, 32, .6); border-radius: 999px; padding: 5px 12px; font-size: .8rem; font-weight: 900; color: var(--sun); }

.qtext { font-size: clamp(1.08rem, 4.6vw, 1.28rem); font-weight: 800; margin: 16px 2px 14px; line-height: 1.32; }
.opts { display: flex; flex-direction: column; gap: 11px; }
.opt {
  position: relative; text-align: left; padding: 14px 16px 14px 54px; border-radius: 18px; background: var(--card);
  box-shadow: inset 0 0 0 2px var(--line), 0 5px 0 rgba(0, 0, 0, .28); font-size: .98rem; line-height: 1.35; font-weight: 600;
  transition: transform .1s, box-shadow .15s, background .15s; animation: optin .4s backwards cubic-bezier(.2, .9, .3, 1.2);
}
.opt:nth-child(2) { animation-delay: .07s; } .opt:nth-child(3) { animation-delay: .14s; }
@keyframes optin { from { opacity: 0; transform: translateY(16px); } }
.opt::before {
  content: attr(data-ico); position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, .1); display: grid; place-items: center; font-size: 1rem;
}
.opt:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--line), 0 2px 0 rgba(0, 0, 0, .28); }
.opt.on { background: #17574a; box-shadow: inset 0 0 0 3px var(--neon), 0 0 26px rgba(61, 245, 192, .4); }
.opt.on::before { content: "✔"; background: var(--neon); color: #062b22; font-weight: 900; }
.opts.locked .opt { pointer-events: none; }
.opts.locked .opt:not(.on) { opacity: .4; }
.hint { text-align: center; color: var(--ink2); font-size: .82rem; margin-top: 14px; }

/* ---------- scanning ---------- */
.scan { align-items: center; justify-content: center; text-align: center; gap: 22px; }
.scan h2 { font-size: 1.5rem; margin: 0; font-weight: 900; }
.scan p { color: var(--ink2); margin: 0; min-height: 1.5em; }
.scan .radar::before { animation-duration: .9s; }

/* ---------- result ---------- */
.result { text-align: center; gap: 16px; padding-top: 34px; }
.result .kicker { color: var(--ink2); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.hero { border-radius: 28px; padding: 18px 16px 20px; position: relative; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, .4), inset 0 0 0 2px rgba(255, 255, 255, .16); }
.hero .mascots { display: flex; justify-content: center; gap: 4px; }
.hero svg.mascot { width: min(48vw, 190px); height: auto; animation: bob 2.6s ease-in-out infinite; }
.hero .mascots.two svg.mascot { width: min(38vw, 150px); }
.hero .mascots.two svg.mascot:nth-child(2) { animation-delay: -1.3s; }
@keyframes bob { 0%, 100% { transform: translateY(4px); } 50% { transform: translateY(-8px); } }
.hero h2 { font-size: clamp(1.6rem, 7.4vw, 2.2rem); line-height: 1.1; margin: 6px 0 0; font-weight: 900; text-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.hero .mix { font-weight: 800; opacity: .9; margin-top: 4px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: left; box-shadow: inset 0 0 0 1px var(--line); }
.panel h3 { margin: 0 0 6px; font-size: 1.02rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.panel p { margin: 0; color: #dfe4ff; font-size: .98rem; }
.panel .who { font-weight: 900; margin: 10px 0 2px; }
.panel .who:first-of-type { margin-top: 0; }
.chart { display: block; width: 100%; max-width: 330px; margin: 0 auto; }
.bars { display: grid; gap: 10px; margin-top: 6px; }
.bar { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 8px; font-size: .88rem; font-weight: 800; }
.bar .track { height: 14px; border-radius: 4px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 0 4px 4px 0; width: 0; transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.bar .v { text-align: right; color: var(--ink2); }
.bar.me .name::after { content: " ← Ty"; color: var(--sun); }
.small { color: var(--ink2); font-size: .82rem; margin-top: 10px !important; }
.actions { margin-top: 6px; }

/* ---------- misc ---------- */
.loading { flex: 1; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink2); }
.mini-radar { width: 54px; height: 54px; border-radius: 50%; border: 3px solid rgba(61, 245, 192, .3); border-top-color: var(--neon); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 40;
  background: #fff; color: #10173a; font-weight: 900; padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.2, .9, .3, 1.3), opacity .2s; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #ff5d6c; color: #fff; }

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