@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@view-transition { navigation: auto; }

:root {
  --bg: #0e0f13;
  --surface: #17181d;
  --surface-2: #1f2026;
  --surface-3: #2a2c33;
  --line: rgba(255, 255, 255, .08);
  --ink: #e9eaee;
  --ink-2: #9ea3ad;
  --dim: #4a4d56;
  --g1: #4796e3;
  --g2: #9177c7;
  --g3: #ca6673;
  --grad: linear-gradient(90deg, var(--g1), var(--g2) 50%, var(--g3));
  --good: #6dd58c;
  --good-soft: rgba(109, 213, 140, .12);
  --bad: #f28b82;
  --bad-soft: rgba(242, 139, 130, .08);
  --bad-ink: #2a0e0b;
  --input-bg: rgba(31, 32, 38, .82);
  --shadow: #000;
  --backdrop: rgba(5, 6, 9, .6);
  --aura-strength: 1;
  --theme-color: #0e0f13;
  --font: 'Urbanist', sans-serif;
  --spring: cubic-bezier(.3, 1.45, .5, 1);
  --out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --surface-3: #e1e7f0;
  --line: rgba(16, 24, 40, .1);
  --ink: #1b1d22;
  --ink-2: #5b616e;
  --dim: #b3b9c5;
  --good: #188a3e;
  --good-soft: rgba(24, 138, 62, .1);
  --bad: #d1453b;
  --bad-soft: rgba(209, 69, 59, .07);
  --bad-ink: #fff;
  --input-bg: rgba(255, 255, 255, .86);
  --shadow: rgba(40, 60, 100, .35);
  --backdrop: rgba(30, 40, 60, .3);
  --aura-strength: .55;
  --theme-color: #f7f9fc;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; font-family: var(--font); color: var(--ink); background: var(--bg); transition: background-color .4s, color .4s; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--g1); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.aura { position: fixed; left: 50%; bottom: -38vh; z-index: 0; width: 120vw; height: 70vh; translate: -50% 0; border-radius: 50%; background: radial-gradient(closest-side, rgba(71, 150, 227, .35), rgba(145, 119, 199, .22) 45%, rgba(202, 102, 115, .1) 70%, transparent); filter: blur(30px); opacity: var(--aura-strength); pointer-events: none; animation: aura 12s ease-in-out infinite alternate; }

/* ---------- Header ---------- */
.top { position: relative; z-index: 2; display: flex; align-items: center; gap: .8rem; padding: max(1.1rem, env(safe-area-inset-top)) max(1.6rem, env(safe-area-inset-right)) 1.1rem max(1.6rem, env(safe-area-inset-left)); animation: fade .8s both; }
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.2rem; font-weight: 600; text-decoration: none; white-space: nowrap; view-transition-name: brand; }
.spark { width: 26px; height: 26px; flex: none; }
.brand .spark { animation: spin-once 1.6s .2s var(--out) both; }
.switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-left: 1rem; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.switch-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); translate: 100% 0; border-radius: 999px; background: var(--surface-3); view-transition-name: mode-pill; }
.switch a { position: relative; z-index: 1; padding: .45rem 1.1rem; border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--ink-2); text-align: center; text-decoration: none; white-space: nowrap; transition: color .3s; }
.switch a:hover, .switch a[aria-current="page"] { color: var(--ink); }
.stats { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats b { display: inline-block; color: var(--ink); }
.stats b.is-bumped { animation: bump .5s var(--spring); }
.stat-buttons { display: flex; gap: .45rem; }
.icon-btn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--ink); transition: transform .3s var(--spring); }
.icon-btn:hover { transform: translateY(-2px); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-ringed::before { content: ''; position: absolute; inset: -3px; z-index: -1; border-radius: 50%; background: conic-gradient(from var(--a), var(--g1), var(--g2), var(--g3), var(--g1)); animation: spin 4s linear infinite; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme="dark"]) .icon-sun { display: none; }

/* ---------- Round ---------- */
.quiz { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; padding: 1.2rem max(1.5rem, env(safe-area-inset-right)) 10rem max(1.5rem, env(safe-area-inset-left)); }
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); font-weight: 600; line-height: 1.12; letter-spacing: -.02em; }
.grad-text { background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3), var(--g2), var(--g1)) 0 0 / 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: rise .9s var(--out) both, shimmer 8s linear infinite; }
.dim { display: block; color: var(--dim); animation: rise .9s .15s var(--out) both; }
.label { margin: 2.2rem 0 .9rem; font-size: .95rem; font-weight: 600; color: var(--ink-2); animation: fade .6s .4s both; }

.opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.opt {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; justify-content: space-between; gap: 1.2rem;
  min-height: 150px; padding: 1.1rem 1.1rem 1rem;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 1.12rem; font-weight: 600; line-height: 1.25; text-align: left;
  transition: background .3s, transform .4s var(--spring), opacity .4s;
  animation: rise .7s var(--out) backwards;
  animation-delay: calc(.5s + var(--i) * 80ms);
}
.opt::before, .glow::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--a), transparent 0 55%, var(--g1), var(--g2), var(--g3), transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spin 5s linear infinite;
}
.opt::before { opacity: 0; transition: opacity .4s; }
.opt:hover, .opt:focus-visible { background: var(--surface-2); transform: translateY(-4px); }
.opt:hover::before, .opt:focus-visible::before { opacity: .7; }
.opt-icon { width: 34px; height: 34px; transition: filter .8s .25s, opacity .8s .25s; }
.opt-name { position: relative; z-index: 1; overflow-wrap: anywhere; }
.opt-meta { display: block; margin-top: .25rem; font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.opt-verdict { display: none; }
.key { position: absolute; top: .9rem; right: .9rem; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); font-size: .85rem; font-weight: 700; color: var(--ink-2); transition: .4s; }
.key svg { display: none; width: 18px; }

.sunset { position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: linear-gradient(to top, rgba(202, 102, 115, .78), rgba(145, 119, 199, .32) 60%, transparent); clip-path: inset(100% 0 0 0 round 20px); transition: clip-path 1.1s .25s var(--out); }

.quiz.is-answered .opt { pointer-events: none; }
.quiz.is-answered .opt:not(.is-answer):not(.is-picked) { opacity: .6; }
.quiz.is-answered .opt-type { display: none; }
.quiz.is-answered .opt-verdict { display: inline; font-weight: 700; animation: fade .5s .3s both; }
.opt-verdict.is-alive { color: var(--good); }
.opt-verdict.is-impostor { color: var(--ink-2); }
.quiz.is-answered .opt.is-answer { background: linear-gradient(160deg, rgba(71, 150, 227, .16), rgba(145, 119, 199, .1) 50%, rgba(202, 102, 115, .12)); animation: pop .7s var(--spring); }
.quiz.is-answered .opt.is-answer::before { opacity: 1; background: conic-gradient(from var(--a), var(--g1), var(--g2), var(--g3), var(--g1)); animation-duration: 3s; }
.quiz.is-answered .opt.is-answer .sunset { clip-path: inset(0 0 0 0 round 20px); }
.quiz.is-answered .opt.is-answer .opt-icon { filter: grayscale(1); opacity: .6; }
.quiz.is-answered .opt.is-answer .opt-meta, .quiz.is-answered .opt.is-answer .opt-verdict { color: #fff; }
.quiz.is-answered .opt.is-answer .key { background: var(--grad); color: #fff; }
.quiz.is-answered .opt .key span { display: none; }
.quiz.is-answered .opt:not(.is-answer):not(.is-picked) .key { opacity: 0; scale: .5; }
.quiz.is-answered .opt.is-answer .key .icon-tick, .quiz.is-answered .opt.is-picked:not(.is-answer) .key .icon-cross { display: block; }
.opt.is-picked:not(.is-answer) { box-shadow: inset 0 0 0 1.5px var(--bad); background: var(--bad-soft); animation: shake .5s; }
.opt.is-picked:not(.is-answer) .key { background: var(--bad); color: var(--bad-ink); }

.sparks { display: none; position: absolute; right: 1.5rem; bottom: 1.5rem; pointer-events: none; }
.opt.is-answer.is-picked .sparks { display: block; }
.sparks svg { position: absolute; width: var(--s); height: var(--s); margin: calc(var(--s) / -2); animation: sparkle 1.2s var(--out) forwards; animation-delay: var(--d); }

/* ---------- Response ---------- */
.response { display: flex; gap: 1rem; margin-top: 1.8rem; scroll-margin: 1.5rem; }
.response > .spark { width: 28px; height: 28px; animation: think 1.3s var(--out) both; }
.response-body { flex: 1; min-width: 0; }
.loading { display: grid; gap: .55rem; overflow: hidden; padding-top: .3rem; animation: collapse .25s 1s forwards; }
.loading i { height: 14px; border-radius: 7px; background: linear-gradient(90deg, rgba(71, 150, 227, .12), rgba(145, 119, 199, .55), rgba(202, 102, 115, .12), rgba(71, 150, 227, .12)) 0 0 / 200% 100%; animation: shimmer 1.1s linear infinite; }
.loading i:nth-child(2) { width: 82%; }
.loading i:nth-child(3) { width: 56%; }
.answer-text { font-size: 1.15rem; line-height: 1.6; animation: reveal 1s 1s var(--out) both; }
.answer-text strong { font-weight: 700; }
.answer-detail { margin-top: .6rem; color: var(--ink-2); line-height: 1.6; animation: reveal 1s 1.15s var(--out) both; }
.answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.1rem; animation: fade .6s 1.4s both; }
.points, .game-over, .best-badge, .when { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 999px; font-size: .9rem; font-weight: 700; }
.points { background: var(--good-soft); color: var(--good); }
.game-over { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.best-badge { background: var(--grad); color: #fff; }
.when { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.when svg, .link-chip svg { width: 15px; height: 15px; flex: none; }
.link-chip { display: inline-flex; align-items: center; gap: .45rem; max-width: 100%; padding: .45rem .95rem; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font-size: .9rem; font-weight: 600; text-decoration: none; transition: transform .3s var(--spring), background .3s; }
.link-chip:hover { background: var(--surface-3); transform: translateY(-2px); }
.next { padding: .65rem 1.3rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 700; transition: transform .3s var(--spring); }
.next:hover { transform: translateY(-2px); }
.error-card { display: grid; gap: .8rem; justify-items: start; margin-top: 1.6rem; padding: 1.3rem 1.5rem; border-radius: 20px; background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad); }

/* ---------- Composer ---------- */
.composer { position: fixed; left: 50%; bottom: 0; z-index: 3; width: min(820px, calc(100% - 2rem)); translate: -50% 0; padding-bottom: max(1rem, env(safe-area-inset-bottom)); animation: fade .8s .8s both; transition: translate .6s var(--out), opacity .4s; }
body.is-answered .composer { translate: -50% 120%; opacity: 0; pointer-events: none; }
.input { display: flex; align-items: center; gap: .8rem; padding: .6rem .6rem .6rem 1.4rem; border-radius: 32px; background: var(--input-bg); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: inset 0 0 0 1px var(--line), 0 20px 40px -20px var(--shadow); }
.input p { flex: 1; color: var(--ink-2); }
.input kbd { padding: .05rem .4rem; border-radius: 6px; background: var(--surface-3); color: var(--ink); font: inherit; font-weight: 700; }
.composer-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--ink-2); transition: background .2s, color .2s; }
.composer-btn:hover { background: var(--surface-3); color: var(--ink); }
.composer-btn svg { width: 22px; height: 22px; }
.disclaimer { margin-top: .7rem; text-align: center; font-size: .78rem; color: var(--ink-2); opacity: .75; }

/* ---------- Modals ---------- */
.modal { width: min(500px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
.modal::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal[open] .glow { animation: pop .5s var(--spring); }
.glow { position: relative; display: grid; gap: 1rem; max-height: calc(100dvh - 2rem); overflow: auto; padding: 1.8rem 1.7rem 1.5rem; border-radius: 28px; background: var(--surface); box-shadow: 0 30px 60px -30px var(--shadow); }
.glow h2 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.glow h2 .grad-text { animation: shimmer 8s linear infinite; }
.glow p, .glow li { color: var(--ink-2); line-height: 1.55; }
.glow ul { display: grid; gap: .45rem; padding-left: 1.1rem; }
.glow strong { color: var(--ink); }
.glow .small { font-size: .85rem; }
.modal-close { position: absolute; top: 1rem; right: 1rem; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; margin-top: .4rem; }
.btn { padding: .7rem 1.25rem; border-radius: 999px; font-weight: 700; transition: transform .3s var(--spring), background .2s; }
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-ghost { background: var(--surface-3); }
.btn-danger { background: var(--bad); color: var(--bad-ink); }

/* ---------- Motion ---------- */
::view-transition-group(mode-pill) { animation-duration: .55s; animation-timing-function: var(--spring); }

@keyframes spin { to { --a: 360deg; } }
@keyframes spin-once { from { rotate: -180deg; scale: .2; opacity: 0; } }
@keyframes think { 0% { rotate: 0deg; scale: .6; } 80% { rotate: 540deg; scale: 1.1; } 100% { rotate: 540deg; scale: 1; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes aura { to { scale: 1.15 .9; filter: blur(30px) hue-rotate(25deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; translate: 0 18px; } }
@keyframes pop { 0% { scale: .8; opacity: 0; } 60% { scale: 1.04; opacity: 1; } }
@keyframes reveal { from { opacity: 0; filter: blur(10px); translate: 0 6px; } }
@keyframes collapse { to { opacity: 0; height: 0; padding: 0; gap: 0; } }
@keyframes shake { 20%, 60% { translate: -6px 0; } 40%, 80% { translate: 6px 0; } }
@keyframes bump { 40% { scale: 1.3; } }
@keyframes sparkle { from { transform: translate(0, 0) scale(0) rotate(0); opacity: 1; } 60% { opacity: 1; } to { transform: translate(var(--x), var(--y)) scale(1) rotate(180deg); opacity: 0; } }

@media (max-width: 860px) {
  .top { flex-wrap: wrap; }
  .switch { order: 3; width: 100%; margin: .4rem 0 0; }
  .opts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .top { gap: .6rem; padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right)); }
  .brand { font-size: 1rem; }
  .brand .spark { width: 22px; height: 22px; }
  .stats { gap: .7rem; font-size: .85rem; }
  .icon-btn { width: 34px; height: 34px; }
  .switch a { padding: .45rem .6rem; font-size: .85rem; }
  .quiz { padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right)); padding-bottom: 8.5rem; }
  .label { margin-top: 1.6rem; }
  .opts { gap: .6rem; }
  .opt { min-height: 132px; padding: .95rem .9rem .9rem; font-size: 1rem; }
  .opt-icon { width: 28px; height: 28px; }
  .key { top: .75rem; right: .75rem; width: 30px; height: 30px; }
  .response { gap: .7rem; }
  .answer-text { font-size: 1.05rem; }
  .composer { width: calc(100% - 1.4rem); }
  .input { padding-left: 1.1rem; }
  .input p { font-size: .92rem; }
  .disclaimer { display: none; }
}
@media (hover: none) { .input .kbd-hint { display: none; } }
@media (max-width: 440px) {
  .brand-text { display: none; }
  .switch { margin-top: .2rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
