:root {
  color-scheme: dark;
  --night: #0c0920;
  --paper: #f8f2eb;
  --ink: #171124;
  --pink: #ff3da4;
  --coral: #ff674d;
  --cyan: #57e7e2;
  --yellow: #ffd166;
  --muted: #a69dbb;
  --line: rgba(255,255,255,.13);
  --safe-bottom: max(1.2rem, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--night); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--paper);
  background:
    radial-gradient(circle at 90% 0%, rgba(255,61,164,.17), transparent 32rem),
    radial-gradient(circle at 0% 76%, rgba(87,231,226,.10), transparent 28rem),
    linear-gradient(155deg, #100a2a 0%, #0b091b 52%, #15102b 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

.ambient {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(90px);
  opacity: .22;
  pointer-events: none;
}
.ambient-one { width: 18rem; height: 18rem; right: -8rem; top: 25%; background: var(--pink); }
.ambient-two { width: 15rem; height: 15rem; left: -8rem; bottom: 8%; background: var(--cyan); }

.shell { position: relative; z-index: 1; width: min(100%, 560px); min-height: calc(100vh - 5rem); margin: 0 auto; }
.topbar {
  min-height: 4.75rem;
  padding: max(.9rem, env(safe-area-inset-top)) 1.15rem .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.brand-six {
  width: 2.25rem; height: 2.25rem; display: grid; place-items: center;
  border-radius: .75rem; color: white; background: linear-gradient(145deg, var(--pink), var(--coral));
  font-size: 1.45rem; font-weight: 950; font-style: italic; transform: skew(-5deg); box-shadow: 0 0 25px rgba(255,61,164,.35);
}
.brand b, .brand small { display: block; }
.brand b { font-size: .9rem; letter-spacing: .08em; }
.brand small { margin-top: .12rem; color: var(--muted); font-size: .58rem; letter-spacing: .12em; text-transform: uppercase; }
.sound {
  width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%;
  color: var(--paper); background: rgba(255,255,255,.05); cursor: pointer;
}
.sound.off { color: var(--muted); opacity: .7; }

.screen { padding: .4rem 1.15rem 2rem; animation: enter .42s cubic-bezier(.2,.8,.2,1); }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } }
.cover-wrap { position: relative; margin: .2rem 0 1.4rem; }
.cover {
  display: block; width: 100%; aspect-ratio: 1.25/1; object-fit: cover; object-position: center 42%;
  border-radius: 1.75rem; border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 28px 80px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,255,255,.08);
}
.unofficial {
  position: absolute; right: .8rem; top: .8rem; padding: .45rem .62rem;
  border: 1px solid rgba(255,255,255,.36); border-radius: 999px;
  background: rgba(10,7,27,.62); backdrop-filter: blur(10px);
  color: white; font-size: .56rem; font-weight: 850; letter-spacing: .14em;
}
.kicker { margin: 0 0 .65rem; color: var(--cyan); font-size: .66rem; font-weight: 900; letter-spacing: .17em; }
.intro h1 { margin: 0; font-size: clamp(2.85rem, 12.5vw, 4.7rem); line-height: .91; letter-spacing: -.065em; font-weight: 900; }
.intro h1 em { color: transparent; background: linear-gradient(90deg, #ff7b56, #ff3da4 60%, #bb6cff); background-clip: text; -webkit-background-clip: text; font-style: italic; }
.lede { margin: 1.1rem 0 1.4rem; color: #c6bdd4; font-size: .98rem; line-height: 1.55; }
.stats-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-bottom: 1rem; }
.stats-preview div { padding: .85rem .7rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(255,255,255,.045); }
.stats-preview strong, .stats-preview span { display: block; }
.stats-preview strong { color: white; font-size: 1.22rem; font-style: italic; }
.stats-preview span { margin-top: .2rem; color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; }

.primary, .secondary, .next-button {
  width: 100%; min-height: 3.8rem; border: 0; border-radius: 1.1rem; padding: .8rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  font-weight: 850; transition: transform .16s ease, filter .16s ease;
}
.primary { color: white; background: linear-gradient(105deg, #ed2f8c, #ff684c); box-shadow: 0 12px 35px rgba(255,61,164,.24); }
.secondary { justify-content: center; color: var(--paper); background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.primary:active, .secondary:active, .next-button:active, .answer:active, .cal-button:active { transform: scale(.98); }
.primary b { font-size: 1.35rem; }
.text-button { display: block; margin: .9rem auto 0; border: 0; padding: .55rem; color: var(--muted); background: transparent; cursor: pointer; font-size: .78rem; text-decoration: underline; text-underline-offset: .25rem; }

.game-head { margin: .15rem 0 1rem; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: .55rem; font-size: .65rem; letter-spacing: .12em; }
.progress-copy span { color: var(--muted); }
.progress-copy strong { color: var(--cyan); }
.progress-track { height: .32rem; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.09); }
.progress-track i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--pink)); transition: width .35s ease; }
.case-card {
  min-height: 30rem; padding: 1.2rem; border-radius: 1.55rem; color: var(--ink);
  background: linear-gradient(160deg, #fffaf4, #f1e9e5);
  box-shadow: 0 24px 70px rgba(0,0,0,.32); position: relative; overflow: hidden;
}
.case-card::before { content: ""; position: absolute; width: 9rem; height: 9rem; top: -5.5rem; right: -4rem; border-radius: 50%; background: rgba(255,61,164,.12); }
.case-meta { display: flex; justify-content: space-between; align-items: center; position: relative; }
.category, .streak { padding: .4rem .55rem; border-radius: .5rem; font-size: .57rem; font-weight: 900; letter-spacing: .12em; }
.category { color: white; background: #211347; }
.streak { color: #a4276c; background: #ffd8ea; }
.case-number { margin: 1.4rem 0 .55rem; color: #8b8292; font: 750 .62rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .14em; }
.case-card h2 { margin: 0 0 1.3rem; font-size: clamp(1.45rem, 6.4vw, 2rem); line-height: 1.08; letter-spacing: -.035em; }
.answers { display: grid; gap: .65rem; }
.answer {
  width: 100%; min-height: 3.45rem; padding: .75rem .8rem; border: 1px solid #d8cfd7; border-radius: .85rem;
  display: flex; align-items: center; gap: .75rem; color: #33293c; background: rgba(255,255,255,.72); cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s, transform .15s;
}
.answer:hover { border-color: #9e8ba3; }
.answer .key { width: 1.9rem; height: 1.9rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: .55rem; color: #665a6c; background: #eee6ec; font-size: .68rem; font-weight: 900; }
.answer .answer-text { font-size: .88rem; font-weight: 720; line-height: 1.25; }
.answer.correct { border-color: #2e9b77; background: #d9f6e9; }
.answer.correct .key { color: white; background: #2e9b77; }
.answer.wrong { border-color: #d24a70; background: #ffe0e8; }
.answer.wrong .key { color: white; background: #d24a70; }
.answer.dimmed { opacity: .34; pointer-events: none; }
.answer:disabled { cursor: default; }
.explanation { margin-top: 1rem; padding: .85rem .9rem; border-left: .25rem solid var(--pink); border-radius: 0 .65rem .65rem 0; background: #e8e0e5; }
.explanation strong { font-size: .82rem; }
.explanation p { margin: .28rem 0 0; color: #665b69; font-size: .76rem; line-height: 1.42; }
.game-actions { display: grid; gap: .7rem; margin-top: .8rem; }
.cal-button {
  min-height: 3.6rem; padding: .55rem .85rem; border: 1px solid var(--line); border-radius: 1rem;
  display: flex; align-items: center; gap: .75rem; color: var(--paper); background: rgba(255,255,255,.055); cursor: pointer; text-align: left;
}
.cal-avatar { width: 2.35rem; height: 2.35rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #211347; background: var(--cyan); font-weight: 950; }
.cal-button b, .cal-button small { display: block; }
.cal-button b { font-size: .78rem; }
.cal-button small { margin-top: .12rem; color: var(--muted); font-size: .62rem; }
.cal-button.used { opacity: .38; pointer-events: none; }
.next-button { color: var(--night); background: var(--cyan); }

.result { padding-top: 1.3rem; text-align: center; }
.rank-badge { width: 8rem; height: 8rem; margin: 1.2rem auto 1rem; padding: .45rem; border-radius: 50%; background: conic-gradient(var(--pink), var(--coral), var(--yellow), var(--cyan), var(--pink)); animation: pulse 2.8s ease-in-out infinite; }
.rank-badge span { width: 100%; height: 100%; display: grid; place-items: center; border: .4rem solid var(--night); border-radius: 50%; color: white; background: linear-gradient(145deg, #24174b, #120d2a); font-size: 4rem; font-weight: 950; font-style: italic; }
@keyframes pulse { 50% { box-shadow: 0 0 45px rgba(255,61,164,.28); transform: translateY(-4px); } }
.result-overline { margin: .2rem 0 .3rem; color: var(--muted); font-size: .62rem; font-weight: 850; letter-spacing: .16em; }
.result h2 { margin: 0; font-size: 2.45rem; letter-spacing: -.05em; }
.result-copy { max-width: 24rem; margin: .55rem auto 1.25rem; color: #c1b8d0; font-size: .88rem; line-height: 1.48; }
.score-card { display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--line); border-radius: 1.2rem; overflow: hidden; background: rgba(255,255,255,.045); }
.score-card div { padding: .9rem .35rem; border-right: 1px solid var(--line); }
.score-card div:last-child { border: 0; }
.score-card span, .score-card strong { display: block; }
.score-card span { color: var(--muted); font-size: .48rem; font-weight: 850; letter-spacing: .09em; }
.score-card strong { margin-top: .35rem; color: white; font-size: 1.05rem; }
.personal-best { min-height: 1.1rem; margin: .8rem 0; color: var(--yellow); font-size: .7rem; font-weight: 800; }
.result-actions { display: grid; gap: .65rem; }

dialog {
  width: min(calc(100% - 2rem), 500px); padding: 1.35rem; border: 1px solid rgba(255,255,255,.2); border-radius: 1.5rem;
  color: var(--paper); background: #17112f; box-shadow: 0 30px 90px rgba(0,0,0,.65);
}
dialog::backdrop { background: rgba(5,3,15,.78); backdrop-filter: blur(7px); }
.dialog-close { float: right; width: 2.2rem; height: 2.2rem; border: 1px solid var(--line); border-radius: 50%; color: white; background: rgba(255,255,255,.06); font-size: 1.4rem; cursor: pointer; }
dialog h2 { margin: 0 0 1.1rem; font-size: 2rem; letter-spacing: -.04em; }
dialog ol { margin: 0 0 1.1rem; padding: 0; list-style: none; counter-reset: rules; }
dialog li { display: grid; grid-template-columns: 2.1rem 1fr; gap: .55rem; padding: .75rem 0; border-top: 1px solid var(--line); counter-increment: rules; }
dialog li::before { content: "0" counter(rules); grid-row: span 2; color: var(--pink); font-weight: 900; }
dialog li b, dialog li span { grid-column: 2; }
dialog li b { font-size: .82rem; }
dialog li span { color: var(--muted); font-size: .72rem; line-height: 1.4; }

footer { position: relative; z-index: 1; width: min(100%, 560px); margin: 0 auto; padding: 1rem 1.15rem var(--safe-bottom); color: #756d89; font-size: .58rem; line-height: 1.45; text-align: center; }
footer p { margin: 0 0 .3rem; }
footer a { color: #958aa9; }

@media (min-width: 700px) { .shell { padding-top: 1rem; } .cover { aspect-ratio: 1.45/1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }
