:root {
    --bg: #050d16;
    --panel: #0c1e31;
    --panel2: #13304d;
    --line: #22496e;
    --text: #e9f2fb;
    --muted: #93aecb;
    --accent: #ffd166;
    --accent-ink: #2b1d00;
    --good: #2fbf71;
    --bad: #ff5a52;
    --radius: 12px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.7rem; margin: .2rem 0 .6rem; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
p { margin: .35rem 0 .7rem; }
a { color: var(--accent); }
b { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 1rem;
    padding: .55rem max(1rem, env(safe-area-inset-left));
    background: rgba(5, 13, 22, .95);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(3, 8px); gap: 3px; padding: 5px 6px; background: #000; border-radius: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.r { background: #ff2d20; box-shadow: 0 0 6px #ff2d20; }
.dot.w { background: #fff6dc; box-shadow: 0 0 6px #fff6dc; transform: translateY(-3px); }
.dot.g { background: #19ff8c; box-shadow: 0 0 6px #19ff8c; }
.topnav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--muted); text-decoration: none; padding: .4rem .75rem; border-radius: 999px; white-space: nowrap; }
.topnav a:hover { color: var(--text); background: var(--panel); }
.topnav a.active { color: var(--accent-ink); background: var(--accent); font-weight: 600; }
.content { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-left)) 2rem; }
.footer { padding: 1rem; text-align: center; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.footer .build { margin-top: .3rem; opacity: .75; }

.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.score { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .85rem; color: var(--muted); }
.score span { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .65rem; }
.score b { color: var(--text); }
.lede { color: var(--muted); max-width: 60ch; }
.note { color: var(--muted); font-size: .85rem; }
.rule { font-size: .75rem; font-weight: 600; color: var(--accent); background: rgba(255, 209, 102, .1); border: 1px solid rgba(255, 209, 102, .35); border-radius: 999px; padding: .05rem .5rem; margin-left: .3rem; vertical-align: middle; white-space: nowrap; }
.hint { color: #c9dcef; font-style: italic; }
.desc { font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }

/* ------------------------------------------------------------------ night view */
.scene { display: block; width: 100%; height: auto; border-radius: var(--radius); background: #000; border: 1px solid #111c28; }
.scene-label { fill: #8aa3bd; font: 13px system-ui, sans-serif; }
.scene.compact .scene-label { font-size: 11px; }
.scene-empty { fill: #4a6079; font: 16px system-ui, sans-serif; }
.flash { animation: flash .5s steps(1, end) infinite; }
@keyframes flash { 50% { opacity: 0; } }

.hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem 1rem; padding: .45rem .2rem; font-size: .92rem; color: var(--muted); }
.hud b { color: var(--text); }

/* ------------------------------------------------------------------ top view */
.topview { display: block; width: 100%; height: auto; max-width: 460px; border-radius: var(--radius); }
.tv-cap { fill: #c9dcef; font: 13px system-ui, sans-serif; }
.tv-cap.you { fill: #ffd166; }
.tv-n { fill: #e9f2fb; font: bold 9px system-ui, sans-serif; }
.tv-x { fill: #ff5a52; font: bold 18px system-ui, sans-serif; }

/* ------------------------------------------------------------------ quiz */
.quiz-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.q { margin-bottom: 1rem; }
.qn { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--panel2); color: var(--accent); font-size: .85rem; margin-right: .35rem; }
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choice {
    font: inherit; font-size: .9rem; text-align: left;
    color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: .45rem .7rem; cursor: pointer;
}
.choice:hover:not(:disabled) { background: var(--panel2); }
.choice.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #1d2f45; }
.choice:disabled { cursor: default; }
.choice.right { border-color: var(--good); background: rgba(47, 191, 113, .14); color: #d5ffe6; }
.choice.right.picked { box-shadow: inset 0 0 0 2px var(--good); }
.choice.wrong { border-color: var(--bad); background: rgba(255, 90, 82, .14); box-shadow: inset 0 0 0 2px var(--bad); }
.choice.dim { opacity: .45; }

.actions { display: flex; gap: .6rem; margin-top: .4rem; }
button.primary, button.ghost, .chip {
    font: inherit; border-radius: 999px; padding: .5rem 1.2rem; cursor: pointer; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.primary:disabled { opacity: .4; cursor: default; }
button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
button.ghost:hover { color: var(--text); }

.reveal { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.4rem; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); align-items: start; }
.explain h2 { font-size: 1.25rem; }
.lookalike { background: rgba(255, 209, 102, .08); border-left: 3px solid var(--accent); padding: .4rem .7rem; border-radius: 4px; }
.wrong-note { background: rgba(255, 90, 82, .08); border-left: 3px solid var(--bad); padding: .4rem .7rem; border-radius: 4px; }

/* ------------------------------------------------------------------ pick */
.pick-top { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.situation { padding-top: .2rem; }
.pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: 1.2rem; }
.pick { position: relative; padding: 0; border: 2px solid var(--line); border-radius: calc(var(--radius) + 2px); background: #000; cursor: pointer; overflow: hidden; }
.pick:hover:not(:disabled) { border-color: var(--accent); }
.pick:disabled { cursor: default; }
.pick .scene { border: 0; border-radius: 0; }
.pick.right { border-color: var(--good); box-shadow: 0 0 0 2px var(--good); }
.pick.wrong { border-color: var(--bad); }
.pick.dim { opacity: .6; }
.pick-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: .3rem .6rem; font-size: .8rem; color: var(--muted); background: rgba(5, 13, 22, .85); text-align: left; }

/* ------------------------------------------------------------------ explore */
.explore-controls, .explore-aspect { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: end; margin-bottom: .9rem; }
.explore-controls label, .explore-aspect label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--muted); }
.explore-controls label.check { flex-direction: row; align-items: center; gap: .4rem; }
.explore-aspect label.wide { flex: 1 1 320px; }
select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .5rem; }
input[type=range] { accent-color: var(--accent); min-width: 180px; }
.quick { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { padding: .25rem .7rem; font-size: .82rem; background: var(--panel); color: var(--muted); border-color: var(--line); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.explore-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; margin-bottom: 1rem; }

/* ------------------------------------------------------------------ cheat sheet */
.aspect-head { position: sticky; top: 52px; z-index: 5; display: grid; grid-template-columns: 180px repeat(4, minmax(0, 1fr)); gap: .5rem; padding: .4rem 0; background: var(--bg); font-size: .8rem; color: var(--muted); text-align: center; }
.aspect-head::before { content: ""; }
.sheet-kind { margin: 1.4rem 0; }
.sheet-kind .hint { margin-top: -.2rem; font-size: .9rem; }
.sheet-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: .5rem; align-items: center; margin-bottom: .5rem; }
.sheet-label { font-size: .88rem; color: var(--muted); }
.sheet-views { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.sheet-views figure { margin: 0; }
.sheet-views figcaption { display: none; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 860px) {
    .quiz-grid, .reveal, .pick-top, .explore-grid { grid-template-columns: minmax(0, 1fr); }
    .topview { margin: 0 auto; }
    .aspect-head { display: none; }
    .sheet-row { grid-template-columns: minmax(0, 1fr); }
    .sheet-views { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sheet-views figcaption { display: block; font-size: .75rem; color: var(--muted); text-align: center; }
}
@media (max-width: 520px) {
    .pick-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ boot and error */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.loading-progress { width: 7rem; height: 7rem; }
.loading-progress circle { fill: none; stroke: #13304d; stroke-width: .5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text { position: relative; margin-top: -4.6rem; margin-bottom: 3rem; text-align: center; font-weight: bold; color: var(--text); }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: #5c1712; color: #fff; padding: .6rem 1.25rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
