/* ── Palette ─────────────────────────────────────────────────────────────────
   Taken from the concept image: a cold blue-grey manor lit by warm orange candlelight, with the four
   player accents doing the colour-coding work. Everything else stays desaturated so the accents and
   the flashlight read. */
:root {
    --bg: #0a0910;
    --panel: rgba(20, 17, 27, 0.9);
    --panel-solid: #16131f;
    --panel-edge: #4a3f57;
    --panel-edge-lit: #7a5a3a;
    --text: #ece6f2;
    --muted: #9a90ab;
    --accent: #ff8a3d;
    --accent-deep: #b35d24;
    --danger: #e04b4b;
    --ok: #6fd08c;
    --warn: #ffd166;

    --p1: #ff9c3c;
    --p2: #4aa8ff;
    --p3: #b47cff;
    --p4: #74e08a;

    --shadow: 0 6px 22px rgba(0, 0, 0, .55);
    --shadow-lift: 0 14px 40px rgba(0, 0, 0, .6);
    /* Generously rounded everywhere. The whole UI should read as soft plastic buttons on glass, which
       is the language players already know from a phone game. */
    --radius: 18px;
    --radius-lg: 26px;
    --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Inter, system-ui, sans-serif;
    /* Was 15px. Everything downstream is relative, so this one number is most of "make it bigger". */
    font-size: 17px;
    -webkit-font-smoothing: antialiased;

    /* This is a game, not a document. Without it, dragging to aim selects the HUD, double-clicking to
       attack highlights a nameplate, and Ctrl+A lights the whole screen up. */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Text you type into is the one place selection has to keep working — Ctrl+A inside a field selects
   that field's own contents, which is what a player expects. */
input, textarea, select, [contenteditable="true"] {
    user-select: text;
    -webkit-user-select: text;
}

h1, h2, h3 { margin: 0 0 .5rem; font-weight: 750; letter-spacing: .01em; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .95rem; margin: .2rem 0 .8rem; }
.hidden { display: none !important; }

/* ── Controls ────────────────────────────────────────────────────────────── */
button, .primary, .ghost {
    font: inherit;
    border-radius: var(--radius);
    padding: .7rem 1.3rem;
    cursor: pointer;
    border: 1px solid var(--panel-edge);
    background: #241f31;
    color: var(--text);
    font-weight: 600;
    transition: background .12s, border-color .12s, transform .08s, box-shadow .12s;
}
button:hover, .primary:hover, .ghost:hover { background: #2f2740; border-color: #6a5c7d; }
button:active { transform: translateY(2px); }
button:disabled { opacity: .45; cursor: default; transform: none; }

/* A chunky pressable slab with a hard bottom edge — it should look like it moves when you push it. */
.primary {
    background: linear-gradient(180deg, #ff9445, #d0631c);
    border-color: #8f4a17;
    color: #1c0f04;
    font-weight: 800;
    box-shadow: 0 5px 0 #7a3f14, 0 10px 24px rgba(255, 138, 61, .3);
}
.primary:hover { background: linear-gradient(180deg, #ffa55c, #e2711f); }
.primary:active { box-shadow: 0 2px 0 #7a3f14, 0 6px 16px rgba(255, 138, 61, .25); }

.danger-button {
    background: linear-gradient(180deg, #ef6a5f, #b8362c);
    border-color: #7c2820; color: #240805;
    box-shadow: 0 5px 0 #6d231c, 0 10px 24px rgba(224, 75, 75, .3);
}
.danger-button:hover { background: linear-gradient(180deg, #f57c70, #c94236); }

.ghost { background: transparent; color: var(--muted); }
.wide { width: 100%; }
.small { padding: .3rem .8rem; font-size: .85rem; }
a.primary, a.ghost { text-decoration: none; display: inline-block; text-align: center; }

.icon-button {
    padding: 0; width: 34px; height: 34px; line-height: 1;
    border-radius: 12px; font-size: 1.15rem; background: transparent;
    border-color: transparent; color: var(--muted); pointer-events: auto;
}
.icon-button:hover { color: var(--accent); background: #241f31; }

.round-close {
    width: 44px; height: 44px; border-radius: 50%; padding: 0;
    font-size: 1.05rem; color: var(--muted); background: #1d1826;
}

.chip {
    border-radius: var(--radius-pill); padding: .5rem 1.1rem;
    font-size: .95rem; background: rgba(35, 29, 46, .8); color: var(--muted);
}
.chip:hover { color: var(--text); }
.wide-chip { width: 100%; padding: .8rem 1.1rem; }

input, select {
    font: inherit;
    background: #100d18;
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: 14px;
    padding: .75rem 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent-deep); outline-offset: 1px; }

/* ── Big pressable buttons ───────────────────────────────────────────────── */
.mega {
    display: flex; flex-direction: column; align-items: center; gap: .15rem;
    width: 100%; padding: clamp(1rem, 1.3vw, 1.9rem) 1.4rem; border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #ff9445, #d0631c);
    border: 1px solid #8f4a17; color: #1c0f04; text-decoration: none;
    box-shadow: 0 6px 0 #7a3f14, 0 16px 34px rgba(255, 138, 61, .32);
}
.mega:hover { background: linear-gradient(180deg, #ffa55c, #e2711f); border-color: #a4551a; }
.mega:active { transform: translateY(3px); box-shadow: 0 3px 0 #7a3f14, 0 8px 20px rgba(255, 138, 61, .26); }
.mega-label { font-size: clamp(1.3rem, 1.7vw, 2.4rem); font-weight: 850; letter-spacing: .01em; line-height: 1.1; }
.mega-sub { font-size: clamp(.85rem, .95vw, 1.35rem); font-weight: 600; opacity: .72; }
.mega.compact { padding: .9rem 1.2rem; }
.mega.compact .mega-label { font-size: 1.2rem; }

.mega.secondary {
    background: linear-gradient(180deg, #322a44, #241d31);
    border-color: var(--panel-edge); color: var(--text);
    box-shadow: 0 5px 0 #17121f, 0 12px 26px rgba(0, 0, 0, .45);
}
.mega.secondary:hover { background: linear-gradient(180deg, #3b3151, #2b2339); }
.mega.secondary .mega-sub { opacity: .6; }

/* ── Segmented picker ────────────────────────────────────────────────────── */
.segmented {
    display: flex; gap: .35rem; padding: .35rem;
    background: #100d18; border: 1px solid var(--panel-edge); border-radius: var(--radius);
}
.segmented button {
    flex: 1; border: none; background: transparent; color: var(--muted);
    border-radius: 13px; padding: .6rem .4rem; font-weight: 700;
}
.segmented button:hover { background: #201a2c; color: var(--text); }
.segmented button.on {
    background: linear-gradient(180deg, #ff9445, #d0631c);
    color: #1c0f04; box-shadow: 0 2px 0 #7a3f14;
}

.switch {
    display: flex; align-items: center; gap: .7rem; margin: .2rem 0 1rem;
    padding: .8rem 1rem; border-radius: var(--radius);
    background: rgba(16, 13, 24, .6); border: 1px solid var(--panel-edge);
    cursor: pointer; font-size: .95rem;
}
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.switch small { display: block; color: var(--muted); font-size: .82rem; }

input[type="range"] {
    appearance: none; padding: 0; height: 5px; background: #2b2438; border: none; border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none; width: 15px; height: 15px; border-radius: 50%;
    background: var(--accent); border: 2px solid #1c1626; cursor: pointer;
}

.code { font-family: ui-monospace, "Cascadia Mono", monospace; letter-spacing: .2em; color: var(--accent); }
.code.big { font-size: 3rem; font-weight: 800; text-shadow: 0 0 30px rgba(255, 138, 61, .5); letter-spacing: .28em; }

/* ── Start screen ────────────────────────────────────────────────────────── */
/* The first thing anyone sees. It is a title screen with the manor behind it and one button that
   matters, not a settings page with a play link buried in it. */
.start-screen { position: fixed; inset: 0; overflow: hidden; display: grid; place-items: stretch center; }

.start-scene { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.start-bg {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    /* The gate is the focal point of the painting; keeping it centred means the manor stays in frame
       on a wide monitor and the path still leads the eye on a narrow one. */
    object-position: 55% 50%;
    animation: bgDrift 60s ease-in-out infinite alternate;
}
.start-scene::after {
    /* A scrim so the buttons always have something dark to sit on, heaviest where they actually are. */
    content: ""; position: absolute; inset: 0;
    background:
        linear-gradient(180deg, rgba(6, 5, 12, .55) 0%, rgba(6, 5, 12, .1) 26%, rgba(6, 5, 12, .72) 62%, rgba(5, 4, 9, .92) 100%),
        radial-gradient(ellipse 55% 45% at 50% 62%, rgba(5, 4, 10, .7), transparent 75%);
}
@keyframes bgDrift { from { transform: scale(1.06) translateX(-1%); } to { transform: scale(1.12) translateX(1%); } }

.fog {
    position: absolute; left: -25%; width: 150%; height: 40vh; bottom: -6vh;
    background: radial-gradient(ellipse at center, rgba(150, 140, 180, .13), transparent 68%);
    animation: drift 46s linear infinite;
}
.fog-b { bottom: 4vh; opacity: .6; animation-duration: 71s; animation-direction: reverse; }
@keyframes drift { from { transform: translateX(-8%); } 50% { transform: translateX(8%); } to { transform: translateX(-8%); } }
@media (prefers-reduced-motion: reduce) { .fog, .start-bg { animation: none; } }

/* Title high, buttons low, the painting breathing in between — the shape of a console title screen
   rather than a card floating in the middle of a page. */
/* Sized against the viewport, not in fixed pixels: on a 2500px-wide desktop a 520px column of buttons
   is a postage stamp in the middle of the screen. */
.start-content {
    position: relative; z-index: 2;
    height: 100%; width: clamp(320px, 40vw, 860px);
    display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;
    padding: clamp(1rem, 4vh, 3rem) 0 clamp(1.5rem, 5vh, 3.5rem); text-align: center;
}

.title-block { margin: 0; }
.game-logo {
    display: block; width: 100%; max-width: 100%; margin: 0 auto; height: auto;
    filter: drop-shadow(0 14px 38px rgba(0, 0, 0, .8));
}
.tagline {
    color: #d6cbe4; margin: .9rem 0 0; font-weight: 600;
    font-size: clamp(1rem, 1.1vw, 1.6rem);
    text-shadow: 0 2px 12px #000, 0 0 30px #000;
}

.who { margin: 0 auto; }
.start-actions { display: flex; flex-direction: column; gap: .8rem; margin-top: auto; }
.start-content > .error { margin: .6rem 0 0; }

/* On a short viewport the logo is the first thing to give up space — the button has to stay reachable. */
@media (max-height: 760px) {
    .game-logo { max-width: min(420px, 80vw); }
    .tagline { display: none; }
}

.who {
    display: flex; align-items: center; justify-content: center; gap: .7rem;
    padding: .55rem .8rem; border-radius: var(--radius-pill);
    background: rgba(20, 17, 27, .72); border: 1px solid var(--panel-edge);
    align-self: center;
}
.who-name { font-weight: 700; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--accent-deep); object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; background: #2a2338; font-weight: 800; }

.start-actions { display: flex; flex-direction: column; gap: .8rem; }
.local-login { display: flex; flex-direction: column; gap: .8rem; }
.local-login input { text-align: center; font-size: 1.05rem; }

.error { color: var(--danger); min-height: 1.3rem; font-weight: 600; }

/* ── Sheets ──────────────────────────────────────────────────────────────── */
/* Options and the join flow slide up over the title screen rather than living beside it. */
.sheet {
    position: fixed; inset: 0; z-index: 30; display: grid; place-items: end center;
    /* A flat scrim rather than backdrop-filter: blurring a composited, transform-animated background
       image tears it into mirrored copies in Chrome, and the sheet is opaque anyway. */
    background: rgba(5, 4, 9, .88);
}
.sheet-card {
    width: min(520px, 100vw); max-height: 92vh; overflow-y: auto;
    background: var(--panel-solid); border: 1px solid var(--panel-edge);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.4rem 1.5rem 2rem; box-shadow: var(--shadow-lift);
    animation: sheetUp .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .4; } }
@media (min-height: 780px) {
    .sheet { place-items: center; }
    .sheet-card { border-radius: var(--radius-lg); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.sheet-head h2 { margin: 0; font-size: 1.5rem; }
.sheet-divider {
    display: flex; align-items: center; gap: .8rem; color: var(--muted);
    font-size: .85rem; margin: 1.4rem 0 .9rem;
}
.sheet-divider::before, .sheet-divider::after {
    content: ""; flex: 1; height: 1px; background: var(--panel-edge);
}

.big-field { display: block; margin-bottom: 1rem; }
.big-field > span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .4rem; font-weight: 600; }
.big-field > span small { color: #6f6580; font-weight: 400; }
.big-field > input { width: 100%; }

.code-input {
    text-transform: uppercase; letter-spacing: .42em; font-weight: 800;
    text-align: center; font-size: 1.8rem; padding: .8rem .6rem .8rem 1rem;
    font-family: ui-monospace, "Cascadia Mono", monospace;
}
.join-preview { font-size: .9rem; color: var(--muted); min-height: 2.4rem; margin: 0 0 .7rem; }

.server-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.server-row {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9rem;
    width: 100%; text-align: left; padding: .8rem 1rem; border-radius: var(--radius);
    background: #1b1626; border: 1px solid var(--panel-edge);
}
.server-row:not(:disabled):hover { background: #241d31; border-color: var(--accent-deep); }
.server-row.full { opacity: .5; }
.server-code { font-size: 1.05rem; font-weight: 800; }
.server-main { display: flex; flex-direction: column; min-width: 0; }
.server-host { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-status { font-size: .84rem; color: var(--muted); }
.server-count { font-weight: 800; color: var(--accent); }

/* ── Game shell ──────────────────────────────────────────────────────────────
   The manor and its HUD are one canvas. Everything that used to live in here — the roster, the
   minimap, the item bar, the meters, the nameplates, the vignette — is drawn as quads in a second
   unlit pass over the same buffer; see wwwroot/game/js/ui. What is left below styles the three things
   the DOM is still the right tool for: the chat field, the modal screens, and the dev readout. */
#game-root { position: fixed; inset: 0; overflow: hidden; }
/* The crosshair.

   Aiming is a mouse position on the floor — the torch beam and the shotgun both point at it — so the
   pointer is what the player is actually aiming with, and an arrow is a poor sight. Hot-spotted at the
   middle of the 32px art rather than at its corner, because the corner is not where the barrel points.

   `crosshair` is the fallback, and it matters: the PNG is fetched, and until it arrives (or if it
   never does) the cursor should still be a cross rather than snapping from an arrow to one.

   The HUD writes `cursor: pointer` straight onto this element when the pointer is over one of its
   drawn controls, which overrides this rule for as long as it is there. See updateCursor in main.js. */
#world {
    position: absolute; inset: 0; width: 100%; height: 100%; display: block;
    cursor: url("/assets/ui/crosshair.png") 16 16, crosshair;
}

/* The same base the drawn HUD scales off — see baseUnit in ui/theme.js — so the chat log stays the
   size of the panels beside it on any display. */
#hud {
    position: absolute; inset: 0; pointer-events: none;
    font-size: clamp(15px, 0.95vw, 27px);
}

/* Chat -------------------------------------------------------------------- */
/* The one part of the old HUD that is genuinely a document: a scrollback to drag through and a field
   with a caret, a selection and an IME behind it. `bottom` is written by the HUD, which knows how tall
   the drawn objectives panel underneath it is this frame. */
#chat {
    position: absolute; left: 1.1em; bottom: 1.1em; width: 25em;
    pointer-events: auto; display: flex; flex-direction: column; gap: .35rem;
    padding: .5rem .6rem;
    border: 1px solid var(--panel-edge); border-radius: var(--radius);
    background-color: rgba(20, 17, 27, .94); box-shadow: var(--shadow);
}
#chatLog { max-height: 12em; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: .95rem; }
#chatLog .msg { line-height: 1.35; transition: opacity .6s; }
#chatLog .msg.faded { opacity: .22; }
#chatLog .msg .who { font-weight: 700; }
#chatLog .msg.system { color: var(--muted); font-style: italic; }
#chatLog .msg.spectator .who { color: var(--muted); }
#chatInput { display: none; }
#chat.typing #chatInput { display: block; }
#chat.typing #chatLog .msg { opacity: 1 !important; }

@keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

#centerMessage {
    position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
    text-align: center; padding: 2rem;
    background: radial-gradient(ellipse at center, rgba(6, 4, 10, .55), rgba(6, 4, 10, .9));
}
.center-title {
    font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 900; letter-spacing: .04em;
    text-shadow: 0 3px 28px #000;
}
.center-title.danger { color: var(--danger); letter-spacing: .2em; text-shadow: 0 0 40px rgba(224, 75, 75, .5); }
.center-sub {
    font-size: 1.15rem; font-weight: 500; color: var(--muted); margin-top: .8rem;
    min-height: 1.4rem; text-shadow: 0 2px 10px #000;
}
.center-actions { display: flex; gap: .8rem; margin-top: 1.8rem; flex-wrap: wrap; justify-content: center; }
.center-actions button { pointer-events: auto; font-size: 1.15rem; padding: .9rem 1.8rem; }

/* The board at the end of a run. Wide enough for a name and five numbers, and no wider. */
.center-score {
    margin-top: 1.6rem; width: min(46rem, 88vw);
    background: rgba(12, 9, 20, .82); border: 1px solid var(--edge); border-radius: 1rem;
    padding: 1.2rem 1.4rem;
}
.center-score .total {
    display: flex; align-items: baseline; justify-content: center; gap: .6rem;
    font-size: 2.2rem; font-weight: 900; color: var(--accent); letter-spacing: .02em;
}
.center-score .total span { font-size: .9rem; font-weight: 700; color: var(--muted); letter-spacing: .18em; }
.center-score .tallies {
    display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1.6rem; margin-top: .9rem;
    font-size: .95rem; color: var(--muted);
}
.center-score .tallies b { color: var(--text); font-weight: 700; }
.center-score table { width: 100%; margin-top: 1.1rem; border-collapse: collapse; font-size: .95rem; }
.center-score th {
    text-align: right; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; padding-bottom: .5rem;
}
.center-score th:first-child, .center-score td:first-child { text-align: left; }
.center-score td { text-align: right; padding: .34rem 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.center-score td:last-child { color: var(--accent); font-weight: 800; }

/* The ghost's quiz ----------------------------------------------------------
   A card in the same language as the lobby and settings — solid panel, soft edge, warm glow — with a
   parchment tint so it reads as the note you just picked up. The chat stays above it (z-index) and
   un-faded while it is up: the manor is paused, and talking the question over is the point. */
#quiz {
    position: absolute; inset: 0; z-index: 4;
    display: grid; place-items: center; padding: 1.5rem;
    background: radial-gradient(ellipse at center, rgba(6, 4, 10, .45), rgba(6, 4, 10, .82));
}
#chat { z-index: 6; }
#hud.quiz-open #chatLog .msg.faded { opacity: 1; }
#hud.quiz-open #chat { border-color: var(--panel-edge-lit); }

.quiz-card {
    position: relative; overflow: hidden; pointer-events: auto;
    width: min(40em, 92vw); max-height: 86vh; overflow-y: auto;
    padding: 1.4em 1.6em 1.3em;
    background:
        linear-gradient(180deg, rgba(255, 214, 150, .05), transparent 40%),
        var(--panel-solid);
    border: 1px solid var(--panel-edge-lit); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift), inset 0 0 0 1px rgba(255, 200, 140, .05);
}
.quiz-card.appear { animation: quizIn .28s cubic-bezier(.2, .8, .3, 1.15); }
@keyframes quizIn { from { transform: translateY(18px) scale(.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .quiz-card.appear { animation: none; } }

.quiz-card.right { border-color: #3f8a55; }
.quiz-card.right .card-glow { background: radial-gradient(ellipse at center, rgba(111, 208, 140, .2), transparent 70%); }
.quiz-card.wrong { border-color: #8a3434; }
.quiz-card.wrong .card-glow { background: radial-gradient(ellipse at center, rgba(224, 75, 75, .22), transparent 70%); }

.quiz-head { position: relative; display: flex; align-items: center; gap: .9em; margin-bottom: 1em; }
.quiz-note-art {
    width: 3.6em; height: 3.6em; flex: none; transform: rotate(-8deg);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6));
}
.quiz-kicker {
    font-size: .78em; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--accent);
}
.quiz-reader { color: var(--muted); font-size: .95em; margin-top: .2em; }
.quiz-reader b { color: var(--text); }
.quiz-card.right .quiz-reader { color: var(--ok); font-weight: 700; font-size: 1.05em; }
.quiz-card.wrong .quiz-reader { color: var(--danger); font-weight: 700; font-size: 1.05em; }

.quiz-question {
    position: relative; font-size: 1.35em; font-weight: 750; line-height: 1.35;
    padding: .9em 1em; margin-bottom: 1em; border-radius: var(--radius);
    color: #f6ecd9; background: rgba(16, 13, 24, .6); border: 1px solid var(--panel-edge);
    text-wrap: pretty;
}

.quiz-answers { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
@media (max-width: 640px) { .quiz-answers { grid-template-columns: 1fr; } }

.quiz-answer {
    display: flex; align-items: center; gap: .7em; text-align: left;
    padding: .8em 1em; border-radius: var(--radius); font-size: 1em;
    background: linear-gradient(180deg, #322a44, #241d31);
    border: 1px solid var(--panel-edge); color: var(--text);
    box-shadow: 0 4px 0 #17121f, 0 10px 22px rgba(0, 0, 0, .35);
}
.quiz-answer:not(:disabled):hover {
    background: linear-gradient(180deg, #3d3252, #2b2339); border-color: var(--accent-deep);
}
.quiz-answer:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 #17121f, 0 6px 14px rgba(0, 0, 0, .3); }
.quiz-answer:disabled { opacity: 1; cursor: default; }
.quiz-answer.spectating { cursor: not-allowed; }

.quiz-letter {
    flex: none; display: grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%;
    font-weight: 900; font-size: .9em; color: #1c0f04;
    background: linear-gradient(180deg, #ff9445, #d0631c); box-shadow: 0 2px 0 #7a3f14;
}
.quiz-text { font-weight: 650; line-height: 1.25; }

.quiz-answer.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-deep), 0 4px 0 #17121f; }
.quiz-answer.correct {
    background: linear-gradient(180deg, #2f7a45, #22573a); border-color: var(--ok); color: #eafff0;
    box-shadow: 0 0 0 2px rgba(111, 208, 140, .5), 0 0 28px rgba(111, 208, 140, .35);
}
.quiz-answer.correct .quiz-letter { background: var(--ok); box-shadow: none; }
.quiz-answer.wrong {
    background: linear-gradient(180deg, #7c2a2a, #561c1c); border-color: var(--danger); color: #ffecec;
    box-shadow: 0 0 0 2px rgba(224, 75, 75, .45);
}
.quiz-answer.wrong .quiz-letter { background: var(--danger); box-shadow: none; }
.quiz-answer.faded { opacity: .38; }

.quiz-footer {
    position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 1em;
    margin-top: 1.1em;
}
.quiz-verdict { display: flex; flex-direction: column; gap: .45em; min-height: 2.4em; }
.quiz-stakes { display: flex; flex-wrap: wrap; gap: .4em .9em; font-size: .88em; font-weight: 700; }
.quiz-stakes .good { color: var(--ok); }
.quiz-stakes .bad { color: #f08a7a; }
.quiz-hint { color: var(--muted); font-size: .85em; }
.quiz-result { font-size: 1.05em; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: .4em; }
.quiz-result.good { color: var(--ok); }
.quiz-result.bad { color: #f08a7a; }
.quiz-gift {
    display: inline-flex; align-items: center; gap: .35em; padding: .25em .7em .25em .35em;
    border-radius: var(--radius-pill); background: rgba(111, 208, 140, .14); border: 1px solid rgba(111, 208, 140, .4);
    color: var(--text);
}
.quiz-gift img { width: 1.6em; height: 1.6em; }

#devHud {
    /* Beside the roster, not across it — the roster is the thing you actually read while playing. The
       offset is written in the drawn HUD's own unit rather than in `em`, which would have resolved
       against this element's own 11px monospace and put the readout a third of the way into the
       roster on any display wide enough to matter. */
    position: absolute; top: 1.1em; left: calc(24.6 * clamp(15px, 0.95vw, 27px));
    background: rgba(0, 0, 0, .72); border: 1px solid var(--panel-edge); border-radius: 8px;
    padding: .4rem .6rem; font-family: ui-monospace, monospace; font-size: 11px; color: #8fe08f;
    white-space: pre;
}

/* ── Overlays ────────────────────────────────────────────────────────────── */
.overlay {
    position: absolute; inset: 0; z-index: 20;
    display: grid; place-items: center;
    background: rgba(5, 4, 9, .88); backdrop-filter: blur(5px);
    pointer-events: auto;
}
.lobby-card {
    position: relative; overflow: hidden;
    background: var(--panel-solid); border: 1px solid var(--panel-edge); border-radius: var(--radius-lg);
    padding: 2rem 2.2rem; width: min(560px, 94vw); box-shadow: var(--shadow-lift);
}
.card-glow {
    position: absolute; inset: -40% -20% auto; height: 220px; pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(255, 138, 61, .16), transparent 70%);
}
.lobby-card h1 { font-size: 2rem; letter-spacing: .03em; text-align: center; }
.code-display {
    display: flex; flex-direction: column; align-items: center; gap: .4rem; margin: 1.2rem 0;
    padding: 1rem; border-radius: var(--radius); background: rgba(16, 13, 24, .6);
    border: 1px solid var(--panel-edge);
}
.lobby-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; margin: 1.4rem 0; }
.lobby-columns h3 { font-size: 1rem; }
.lobby-columns ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.lobby-columns li {
    display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem;
    border-radius: 12px; background: rgba(16, 13, 24, .5); font-weight: 600;
}
.lobby-columns .tag { font-size: .74rem; color: var(--accent); letter-spacing: .1em; font-weight: 900; }
.lobby-columns li.hint { background: none; padding: .3rem 0; font-weight: 400; }
.lobby-actions { display: flex; gap: .7rem; align-items: center; flex-direction: column; }
.lobby-actions > * { width: 100%; }
.lobby-actions #hostControls { display: contents; }
.lobby-actions button { padding: .9rem 1.4rem; font-size: 1.1rem; }

/* ── Settings ────────────────────────────────────────────────────────────── */
#settingsOverlay { z-index: 60; }
.settings-card {
    background: var(--panel-solid); border: 1px solid var(--panel-edge); border-radius: 18px;
    width: min(680px, 92vw); max-height: 88vh; display: flex; flex-direction: column;
    box-shadow: var(--shadow);
}
.settings-card header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem .8rem;
}
.settings-card header h1 { margin: 0; font-size: 1.4rem; }

.settings-tabs { display: flex; gap: .3rem; padding: 0 1.4rem; border-bottom: 1px solid var(--panel-edge); }
.settings-tabs .tab {
    background: transparent; border: none; border-bottom: 2px solid transparent;
    border-radius: 0; color: var(--muted); padding: .5rem .8rem;
}
.settings-tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-body { padding: 1.2rem 1.4rem; overflow-y: auto; }
.slider-row { display: grid; grid-template-columns: 110px 1fr 62px; align-items: center; gap: .8rem; margin-bottom: .9rem; }
.slider-row b { font-weight: 600; color: var(--muted); font-size: .85rem; text-align: right; }
.check-row { display: flex; align-items: center; gap: .55rem; margin-bottom: .9rem; }

.bindings { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.binding-row { display: grid; grid-template-columns: 1fr 110px 110px; gap: .5rem; align-items: center; }
.binding {
    font-family: ui-monospace, monospace; font-size: .8rem; padding: .3rem .5rem;
    background: #100d18; border-radius: 7px;
}
.binding.unbound { color: #5c536b; }
.binding.capturing { border-color: var(--accent); color: var(--accent); animation: flicker .6s infinite; }
.binding:disabled { opacity: .8; cursor: default; }

.pad-status {
    font-size: .82rem; color: var(--muted); padding: .5rem .7rem; margin-bottom: 1rem;
    border: 1px dashed var(--panel-edge); border-radius: 9px;
}
.pad-status.ok { color: var(--ok); border-style: solid; }

/* ── Character picker ─────────────────────────────────────────────────────────
   Taken characters stay visible and greyed rather than being removed: "Nova is
   taken" tells you somebody is already Nova, a shorter list tells you nothing. */
.character-choice { display: flex; flex-direction: column; gap: .45rem; margin: 1rem 0; }

.choice-label {
    color: var(--muted);
    font-size: .85rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.character-picker {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: .5rem;
}

.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .4rem .2rem .3rem;
    border: 2px solid #2c2438;
    border-radius: 10px;
    background: #1a1524;
    color: var(--muted);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease, transform .12s ease;
}

.character canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    image-rendering: auto;
}

.character:hover:not(:disabled) { border-color: var(--accent-deep); transform: translateY(-2px); }

.character.selected {
    border-color: var(--accent, #ff8a3d);
    background: #241b2e;
    color: var(--text);
    box-shadow: 0 0 12px color-mix(in srgb, var(--accent, #ff8a3d) 45%, transparent);
}

.character.taken, .character:disabled { opacity: .35; cursor: not-allowed; filter: grayscale(1); }

@media (max-width: 620px) {
    .character-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
