/* ==========================================================================
   Charred: the burnt.autos design system, shared with the Android app
   (burnt-android/.../ui/theme/Color.kt). Dark is the default; light mode is set
   by partials/theme.ejs as <html data-theme="light">.
   ========================================================================== */

@font-face {
    font-family: 'Barlow Condensed';
    src: url('/fonts/BarlowCondensed-Bold.woff2') format('woff2'), url('/fonts/BarlowCondensed-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Manrope';
    src: url('/fonts/Manrope-Variable.woff2') format('woff2'), url('/fonts/Manrope-Variable.ttf') format('truetype');
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;

    --bg: #0E0C0B;
    --surface: #1A1715;
    --raised: #24201D;
    --nav: #121010;
    --stage: #2B2622;
    --border: #3A342F;
    --border-subtle: #2A2521;
    --text: #F5EFE9;
    --text-2: #B3A89E;
    --text-3: #8C8178;
    --body-text: #D9D0C7;
    --primary: #FF6B2C;
    --primary-hover: #FF8A55;
    --primary-pressed: #E85A1C;
    --primary-soft: rgba(255, 107, 44, 0.16);
    --on-primary: #1A0B03;
    --flame: #FFB23F;
    --flame-soft: rgba(255, 178, 63, 0.10);
    --flame-line: rgba(255, 178, 63, 0.40);
    --correct: #3FD68F;
    --correct-soft: rgba(63, 214, 143, 0.08);
    --correct-line: rgba(63, 214, 143, 0.50);
    --wrong: #FF5C5C;
    --wrong-text: #FF8A8A;
    --wrong-line: rgba(255, 92, 92, 0.50);

    /* Anything drawn over a photo is light-on-dark in both themes */
    --scrim: rgba(14, 12, 11, 0.66);
    --scrim-strong: rgba(14, 12, 11, 0.86);
    --hud-flame: #FFB23F;

    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --radius-card: 20px;
    --radius-field: 14px;
    --radius-small: 12px;
    --pill: 999px;

    --topbar-h: 64px;
    --tabbar-h: 68px;
    --gutter: 32px;
}

:root[data-theme="light"] {
    color-scheme: light;

    --bg: #FAF7F4;
    --surface: #FFFFFF;
    --raised: #F3EEE9;
    --nav: #FFFFFF;
    --stage: #E6DFD8;
    --border: #DDD4CB;
    --border-subtle: #EAE3DC;
    --text: #1C1917;
    --text-2: #6B6058;
    --text-3: #766B62;
    --body-text: #3A332E;
    --primary: #C2410C;
    --primary-hover: #A8380A;
    --primary-pressed: #A8380A;
    --primary-soft: rgba(194, 65, 12, 0.10);
    --on-primary: #FFFFFF;
    --flame: #B45309;
    --flame-soft: rgba(180, 83, 9, 0.08);
    --flame-line: rgba(180, 83, 9, 0.40);
    --correct: #15803D;
    --correct-soft: rgba(21, 128, 61, 0.08);
    --correct-line: rgba(21, 128, 61, 0.45);
    --wrong: #DC2626;
    --wrong-text: #DC2626;
    --wrong-line: rgba(220, 38, 38, 0.45);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---------- Type ---------- */

.display {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.01em;
}

.page-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 56px;
    line-height: 54px;
}

.section-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 40px;
    line-height: 40px;
}

.label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-2);
}

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

kbd {
    display: inline-block;
    min-width: 14px;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    background: var(--raised);
    color: var(--text);
    font: 700 12px var(--font-body);
    text-align: center;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 24px;
    border-radius: var(--pill);
    border: 1px solid transparent;
    font: 800 16px var(--font-body);
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn svg { flex-shrink: 0; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-primary:disabled { background: var(--raised); color: var(--text-3); }
.btn-primary.is-loading, .btn-primary.is-loading:disabled { background: var(--primary); color: var(--on-primary); }

.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); font-size: 15px; }
.btn-secondary:hover { background: var(--raised); color: var(--text); }

.btn-flame { height: 44px; padding: 0 16px; background: transparent; color: var(--flame); border-color: var(--flame-line); font-size: 14px; }
.btn-flame:hover { background: var(--flame-soft); color: var(--flame); }
.btn-flame:disabled { opacity: 0.6; }
.hint-cost {
    margin-left: 4px;
    padding: 2px 8px;
    border-radius: var(--pill);
    border: 1px solid var(--flame-line);
    background: var(--flame-soft);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.btn-danger { height: 44px; padding: 0 18px; background: transparent; color: var(--wrong-text); border-color: var(--wrong-line); font-size: 14px; }
.btn-danger:hover { background: rgba(255, 92, 92, 0.08); color: var(--wrong-text); }

.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 8px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font: 600 14px var(--font-body);
}
.btn-text:hover { color: var(--text-2); }

.btn-block { width: 100%; }

.btn kbd {
    padding: 2px 7px;
    border: none;
    background: rgba(26, 11, 3, 0.16);
    color: inherit;
    font-size: 11px;
}

.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Round icon button (theme toggle, dialog close) */
.icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--pill);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }

/* Round icon button over a photo */
.scrim-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--pill);
    border: none;
    background: var(--scrim);
    color: #FFFFFF;
}
.scrim-btn:hover { background: var(--scrim-strong); color: #FFFFFF; }

/* ---------- Chips (score, streak) ---------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--pill);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
}

.chip-num { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; }
.chip-unit { font-size: 12px; font-weight: 600; color: var(--text-2); }
.chip-streak { padding-left: 10px; border-color: var(--flame-line); color: var(--flame); }

/* Chips over a photo */
.chip.chip-hud { background: var(--scrim); border-color: rgba(255, 255, 255, 0.16); color: #FFFFFF; }
.chip.chip-hud .chip-unit { color: rgba(255, 255, 255, 0.7); }
.chip.chip-hud.chip-streak { border-color: rgba(255, 178, 63, 0.4); color: var(--hud-flame); }

.chip.pop { animation: pop 420ms cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 40% { transform: scale(1.2); } }

/* ---------- Cards and fields ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
}

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border-radius: var(--radius-field);
    border: 1px solid var(--border);
    background: var(--raised);
    color: var(--text);
    font: 500 16px var(--font-body);
    transition: border-color 150ms ease;
}
.field::placeholder { color: var(--text-3); }
.field:focus { outline: none; border: 2px solid var(--primary); padding: 0 15px; }
.field.is-locked, .field.is-locked:focus {
    border: 1px solid var(--correct-line);
    background: var(--correct-soft);
    padding: 0 44px 0 16px;
    font-weight: 600;
}
.field-wrap { position: relative; }
.field-lock { position: absolute; right: 16px; top: 16px; color: var(--correct); pointer-events: none; }

textarea.field { height: auto; min-height: 110px; padding: 14px 16px; resize: vertical; line-height: 1.5; }
textarea.field:focus { padding: 13px 15px; }

.label.is-correct { color: var(--correct); }

/* Autocomplete (public/js/autocomplete.js) */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
    display: none;
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    border-radius: var(--radius-field);
    background: var(--raised);
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.autocomplete-dropdown.active { display: block; }
.autocomplete-list { list-style: none; margin: 0; padding: 0; }
.autocomplete-item {
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}
.autocomplete-item.highlighted, .autocomplete-item:hover { background: var(--primary-soft); color: var(--primary); }

/* Toggle switch */
.switch-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-field);
    background: var(--raised);
    cursor: pointer;
}
.switch-row span { flex-grow: 1; font-size: 15px; font-weight: 700; }
.switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 28px;
    margin: 0;
    border-radius: var(--pill);
    background: var(--border);
    cursor: pointer;
    transition: background-color 150ms ease;
}
.switch::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text);
    transition: transform 150ms ease;
}
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); background: var(--on-primary); }

/* Status banner */
.banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-field);
    font-size: 14px;
    font-weight: 700;
    line-height: 20px;
}
.banner svg { flex-shrink: 0; margin-top: 1px; }
.banner-flame { background: var(--flame-soft); border: 1px solid var(--flame-line); color: var(--flame); }
.banner-wrong { background: rgba(255, 92, 92, 0.08); border: 1px solid var(--wrong-line); color: var(--wrong-text); }
.banner-correct { background: var(--correct-soft); border: 1px solid var(--correct-line); color: var(--correct); }

/* Attempt meter: one bar per guess */
.meter { display: flex; gap: 6px; }
.meter span { width: 28px; height: 6px; border-radius: var(--pill); background: var(--border); transition: background-color 300ms ease; }
.meter span.is-current { background: var(--primary); }
.meter span.is-wrong { background: var(--text-3); }
.meter span.is-half { background: var(--flame); }
.meter span.is-right { background: var(--correct); }
.meter.small { gap: 4px; }
.meter.small span { width: 16px; height: 5px; }

/* ---------- Top bar (tablet and desktop) ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 36px;
    padding: 0 var(--gutter);
    background: var(--nav);
    border-bottom: 1px solid var(--border-subtle);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand img { width: 36px; height: 36px; }
.brand span { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 26px; line-height: 1; }

.nav { display: flex; gap: 4px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--pill);
    color: var(--text-2);
    font-size: 15px;
    font-weight: 600;
}
.nav a:hover { color: var(--text); background: var(--raised); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-end .icon-btn { width: 40px; height: 40px; margin-left: 4px; }

.theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-light { display: block; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ---------- Tab bar (phones) ---------- */

.tabbar { display: none; }

@media (max-width: 759px) {
    .topbar { display: none; }

    .tabbar {
        position: fixed;
        z-index: 30;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--nav);
        border-top: 1px solid var(--border-subtle);
    }

    .tabbar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-2);
        font-size: 11px;
        font-weight: 700;
    }
    .tabbar a span {
        width: 56px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--pill);
    }
    .tabbar a[aria-current="page"] { color: var(--primary); font-weight: 800; }
    .tabbar a[aria-current="page"] span { background: var(--primary-soft); }

    /* Keep the page clear of the tab bar; hide the bar while typing so it can't sit on the keyboard */
    body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
    body.is-typing .tabbar { display: none; }
    body.is-typing.has-tabbar { padding-bottom: 0; }
}

/* ---------- Page layouts ---------- */

.page {
    width: 100%;
    max-width: 1184px;
    margin: 0 auto;
    padding: 40px var(--gutter) 56px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.page-narrow { max-width: 784px; }

.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
}
.site-footer a { color: var(--text-3); }
.site-footer a:hover { color: var(--text-2); }

@media (max-width: 759px) {
    :root { --gutter: 20px; }
    .page { padding-top: 20px; padding-bottom: 28px; gap: 16px; }
    .page-title { font-size: 34px; line-height: 36px; }
    .section-title { font-size: 26px; line-height: 28px; }
}

/* ---------- Dialogs ---------- */

dialog.sheet {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    padding: 32px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
dialog.sheet::backdrop { background: rgba(14, 12, 11, 0.72); }
dialog.sheet[open] { display: flex; flex-direction: column; gap: 18px; }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 40px; line-height: 40px; }
.sheet-head .icon-btn { border: none; background: var(--raised); color: var(--text); }
.sheet p { margin: 0; color: var(--text-2); line-height: 1.55; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 759px) {
    dialog.sheet { padding: 24px 20px; }
    .sheet-head h2 { font-size: 32px; line-height: 32px; }
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: var(--pill);
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 759px) {
    .toast { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
}

/* ---------- Lists with bars (leaderboards, everyone's guesses) ---------- */

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.bar-row .rank { width: 16px; flex-shrink: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--text-3); }
.bar-row .rank.first { color: var(--flame); }
.bar-row .name { width: 40%; max-width: 160px; flex-shrink: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex-grow: 1; height: 8px; border-radius: var(--pill); background: var(--raised); overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: var(--pill); background: var(--primary); }
.bar-row .count { min-width: 36px; text-align: right; color: var(--text-2); }
.bar-row.is-answer .name { color: var(--correct); }
.bar-row.is-answer .fill { background: var(--correct); }

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

/* ==========================================================================
   Game (views/random.ejs)
   ========================================================================== */

.desktop-only { display: none; }
@media (min-width: 1024px) and (hover: hover) {
    .desktop-only { display: inline; }
}

.game {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px var(--gutter) 40px;
}

.stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.stage-photo {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-card);
    background: var(--stage);
    aspect-ratio: 4 / 3;
    max-height: 62vh;
    touch-action: pan-y;
}

.stage-photo > img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}

.hud { display: none; }

.stage-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }

.stage-nav { position: absolute; top: 50%; margin-top: -22px; }
.stage-prev { left: 16px; }
.stage-next { right: 16px; }

.stage-count {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 56px;
    height: 28px;
    padding: 0 12px;
    border-radius: var(--pill);
    background: var(--scrim);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-dots { display: none; }

.stage-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--pill);
    background: var(--scrim);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
}
.stage-badge.is-solved { border-color: rgba(63, 214, 143, 0.5); color: #3FD68F; }
.stage-badge.is-stumped { border-color: rgba(255, 92, 92, 0.5); color: #FF8A8A; }

.thumbs { display: flex; gap: 10px; flex-shrink: 0; overflow-x: auto; }
.thumb {
    flex-shrink: 0;
    width: 108px;
    height: 72px;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-small);
    border: 1px solid var(--border-subtle);
    background: var(--stage);
    opacity: 0.7;
    transition: opacity 150ms ease;
}
.thumb:hover { opacity: 1; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb[aria-current="true"] { border: 2px solid var(--primary); opacity: 1; }

/* Panel */
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.guess-card { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.guess-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guess-title { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 44px; line-height: 42px; }

.tried { margin: -8px 0 0; font-size: 13px; color: var(--text-3); }
.tried s { color: var(--text-2); }

.guess-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.panel-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px; font-size: 13px; }
.panel-links .btn-text { padding: 0; height: 32px; color: var(--primary); font-weight: 700; }
.panel-footer { padding: 0 8px; }

/* Result */
.result { display: flex; flex-direction: column; gap: 16px; }
.result-card { padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.result-head { display: flex; flex-direction: column; gap: 8px; }
.result-head .label.is-solved { color: var(--correct); }
.result-head .label.is-stumped { color: var(--wrong-text); }
.result-answer {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 56px;
    line-height: 52px;
    overflow-wrap: anywhere;
}
.result-answer:focus { outline: none; }
.result-note { margin: 0; font-size: 14px; color: var(--text-2); }
.result-wiki { font-size: 14px; font-weight: 700; }

.result-score {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}
.result-points { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 600; }
.result-points span:first-child { font-family: var(--font-display); font-weight: 700; font-size: 76px; line-height: 64px; color: var(--primary); }
.result-points.is-zero span:first-child { color: var(--text-3); }
.result-streak { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; font-size: 13px; text-align: right; }

.result-guesses { display: flex; flex-direction: column; gap: 8px; }
.guess-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.guess-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--radius-small);
    background: var(--raised);
    font-size: 15px;
}
.guess-list .n { width: 14px; flex-shrink: 0; font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text-3); }
.guess-list .words { flex-grow: 1; min-width: 0; overflow-wrap: anywhere; }
.guess-list .ok { color: var(--correct); font-weight: 700; }
.guess-list .no { color: var(--wrong-text); text-decoration: line-through; }
.guess-list .gain { flex-shrink: 0; font-size: 13px; font-weight: 700; color: var(--flame); }
.guess-list .gain.full { color: var(--correct); }

.result-actions { display: flex; gap: 10px; }
.result-actions .btn-primary { flex-grow: 1; }

.everyone-card { padding: 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.solve-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.solve-stat { display: flex; flex-direction: column; }
.solve-value { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 44px; color: var(--primary); }
.solve-value.is-flame { color: var(--flame); }
.solve-label { font-size: 13px; font-weight: 700; color: var(--text-3); }
.solve-note { grid-column: 1 / -1; margin: 8px 0 0; font-size: 14px; color: var(--text-2); }
.everyone-cols { display: flex; flex-direction: column; gap: 16px; }
.everyone-sub { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--text-3); }
.everyone-card .bar-list { gap: 8px; }
.everyone-card .bar-row .name { width: 45%; }

/* Dialog content */
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--body-text); line-height: 1.5; }
.steps li::marker { color: var(--primary); font-weight: 800; }
.spotting summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.spotting ul { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--body-text); font-size: 14px; }
.shortcuts { display: flex; flex-direction: column; }
.shortcuts .label { padding-bottom: 8px; }
.shortcuts div { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border-subtle); font-size: 14px; color: var(--body-text); }
.shortcuts.desktop-only { display: none; }
@media (min-width: 1024px) and (hover: hover) { .shortcuts.desktop-only { display: flex; } }

.sheet-form { display: flex; flex-direction: column; gap: 18px; }
.form-error { margin: 0; font-size: 14px; font-weight: 700; color: var(--wrong-text) !important; }

/* Full-screen photo viewer */
dialog.viewer {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    background: #000000;
}
dialog.viewer::backdrop { background: #000000; }
dialog.viewer[open] { display: flex; align-items: center; justify-content: center; }
dialog.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Zoom and pan (game.js): the page handles every touch gesture inside the viewer */
dialog.viewer { overflow: hidden; touch-action: none; }
dialog.viewer img { cursor: zoom-in; transition: transform 0.2s ease; user-select: none; -webkit-user-drag: none; }
dialog.viewer.is-zoomed img { cursor: grab; }
dialog.viewer.is-dragging img { cursor: grabbing; transition: none; }
@media (prefers-reduced-motion: reduce) { dialog.viewer img { transition: none; } }
.viewer-close { position: absolute; top: 16px; right: 16px; }
.viewer-nav { position: absolute; top: 50%; margin-top: -22px; }
.viewer-prev { left: 16px; }
.viewer-next { right: 16px; }

/* Desktop: photo left, panel right, everything on one screen */
@media (min-width: 1024px) {
    .game {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 420px;
        gap: 32px;
        max-width: none;
        height: calc(100dvh - var(--topbar-h));
        padding: 24px var(--gutter) 28px;
    }
    .stage { min-height: 0; }
    .stage-photo { flex-grow: 1; aspect-ratio: auto; max-height: none; min-height: 0; }
    .panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
    .panel-footer { margin-top: 8px; }
}

/* Phones: full-bleed photo with the score over it, the app's layout */
@media (max-width: 759px) {
    .game { padding: 0 0 24px; gap: 0; }
    .stage-photo { border-radius: 0; aspect-ratio: 4 / 3; max-height: 46dvh; transition: max-height 250ms ease; }
    .thumbs, .stage-count, .stage-nav { display: none; }
    .stage { gap: 0; }

    .hud {
        position: absolute;
        top: 12px;
        left: 12px;
        right: 12px;
        display: flex;
        align-items: center;
        gap: 8px;
        pointer-events: none;
    }
    .hud > * { pointer-events: auto; }
    .hud .chip { height: 36px; padding: 0 12px; }
    .hud .chip-num { font-size: 20px; }
    .hud-logo {
        width: 40px;
        height: 40px;
        margin-right: auto;
        border-radius: var(--pill);
        background: var(--scrim);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .stage-tools { top: auto; bottom: 8px; right: 12px; }
    .stage-badge { top: auto; bottom: 12px; left: 12px; }

    /* On a dark pill, like the buttons over the photo, so they show up on bright photos too */
    .stage-dots {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 8px;
        border-radius: var(--pill);
        background: var(--scrim);
        pointer-events: none;
    }
    .stage-dots span { width: 6px; height: 6px; border-radius: var(--pill); background: rgba(255, 255, 255, 0.6); transition: width 200ms ease; }
    .stage-dots span.is-current { width: 18px; background: #FFFFFF; }

    .panel { padding: 18px var(--gutter) 0; gap: 16px; }
    .guess-card { padding: 0; border: none; background: transparent; gap: 14px; }
    .guess-title { font-size: 34px; line-height: 34px; }
    /* Meter sits on the title's line, as in the app */
    .guess-card { position: relative; }
    .guess-head { position: absolute; top: 14px; right: 0; }
    .guess-head .label { display: none; }

    .result-card, .everyone-card { padding: 0; border: none; background: transparent; }
    .result-answer { font-size: 44px; line-height: 42px; }
    .result-points span:first-child { font-size: 64px; line-height: 54px; }

    /* Round over: shrink the photo, drop the tab bar, pin Next car to the bottom */
    body.is-result .stage-photo { max-height: 220px; }
    body.is-result .tabbar { display: none; }
    body.is-result.has-tabbar { padding-bottom: 0; }
    body.is-result .stage-tools #shareCar { display: none; }
    .result-actions {
        position: sticky;
        bottom: 0;
        z-index: 5;
        margin: 0 calc(-1 * var(--gutter));
        padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
        background: var(--nav);
        border-top: 1px solid var(--border-subtle);
        order: 10;
    }
    .result-actions .btn-secondary span { display: none; }
    .result-actions .btn-secondary { width: 52px; padding: 0; }
    .result { gap: 20px; }
    .result-card { display: contents; }
    .panel-links { padding: 0; }
    .panel-footer { padding: 0 0 8px; }
}

/* ---------- Stat cards (stats, completion) ---------- */

.stat-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1024px) { .stat-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 760px) and (max-width: 1023px) { .stat-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 40px;
    line-height: 40px;
    overflow-wrap: anywhere;
}
.stat-value.is-primary { color: var(--primary); }
.stat-value.is-flame { color: var(--flame); }
.stat-value.is-correct { color: var(--correct); }

@media (max-width: 759px) {
    .stat-grid { gap: 10px; }
    .stat { padding: 14px 16px; gap: 4px; }
    .stat .label { font-size: 11px; }
    .stat-value { font-size: 32px; line-height: 32px; }
}

.sheet-actions .btn { height: 48px; }

/* ---------- Completion ---------- */

.complete { align-items: center; text-align: center; padding-top: 72px; }
.complete-logo { width: 120px; height: 120px; }
.complete-title { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 76px; line-height: 72px; }
.complete-text { margin: 0; max-width: 520px; font-size: 17px; line-height: 26px; color: var(--text-2); }
.complete-upload { width: 100%; max-width: 640px; margin-top: 8px; padding: 20px; display: flex; align-items: center; gap: 16px; text-align: left; border-color: var(--primary); background: var(--primary-soft); }
.complete-upload-icon { flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary); color: var(--on-primary); }
.complete-upload-body { flex-grow: 1; min-width: 0; }
.complete-upload-body h2 { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 26px; line-height: 28px; }
.complete-upload-body p { margin: 4px 0 0; font-size: 15px; line-height: 22px; color: var(--text-2); }
.complete-upload .btn { flex-shrink: 0; }
.complete .stat-grid { width: 100%; max-width: 640px; margin-top: 8px; text-align: left; }
.complete-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }

@media (max-width: 759px) {
    .complete { padding-top: 40px; }
    .complete-logo { width: 88px; height: 88px; }
    .complete-title { font-size: 44px; line-height: 42px; }
    .complete-actions { flex-direction: column; width: 100%; }
    .complete-upload { flex-wrap: wrap; }
    .complete-upload-body { flex-basis: calc(100% - 68px); }
    .complete-upload .btn { width: 100%; }
}

/* Tablets: the full top bar doesn't fit, so drop the wordmark and tighten it up */
@media (min-width: 760px) and (max-width: 1023px) {
    .topbar { gap: 16px; padding: 0 24px; }
    .brand span { display: none; }
    .nav a { padding: 0 12px; }
}
.brand span { white-space: nowrap; }

/* ==========================================================================
   Stats and history
   ========================================================================== */

.page-head { display: flex; align-items: center; gap: 8px; }
.back-btn { border: none; margin-left: -10px; color: var(--text); }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.empty p { margin: 0; color: var(--text-2); }
.card.empty { padding: 24px; }

.garage { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.garage-score { padding: 28px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.garage-total { display: flex; flex-direction: column; gap: 4px; }
.garage-total-value { font-family: var(--font-display); font-weight: 700; font-size: 96px; line-height: 88px; color: var(--primary); }
.garage-minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mini { background: var(--raised); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mini-value { font-family: var(--font-display); font-weight: 700; font-size: 36px; line-height: 36px; }
.mini-value.is-flame { color: var(--flame); }

.garage-recent { padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; }
.garage-recent-head { display: flex; align-items: baseline; justify-content: space-between; }
.garage-recent-head h2 { margin: 0; }
.garage-recent-head a { font-size: 14px; font-weight: 700; }
.garage-summary { margin: -8px 0 0; font-size: 13px; }

.round-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.round-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.round-thumb { width: 56px; height: 42px; flex-shrink: 0; border-radius: 8px; background: var(--stage); object-fit: cover; }
.round-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.round-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-detail { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); min-width: 0; }
.round-detail > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-detail .meter span { width: 12px; height: 4px; }
.round-detail .is-stumped { color: var(--wrong-text); }
.round-detail .is-hint { color: var(--flame); }
.round-points { flex-shrink: 0; min-width: 40px; text-align: right; font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--primary); }
.round-points.is-zero { color: var(--text-3); }

.stats-everyone { margin-top: 24px; }

.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.stats-row-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-row .label { margin: 0; }

.activity { grid-column: span 2; padding: 24px 28px; display: flex; flex-direction: column; gap: 18px; }
.activity-series { display: flex; flex-direction: column; gap: 8px; }
.activity-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.activity-title { font-size: 15px; font-weight: 700; }
.activity-numbers { font-size: 13px; color: var(--text-2); }
.activity-numbers strong { color: var(--text); }
.trend.is-up { color: var(--correct); }
.trend.is-down { color: var(--wrong-text); }
.activity-bars { height: 96px; display: flex; align-items: flex-end; gap: 4px; }
.activity-series + .activity-series .activity-bars { height: 56px; }
.activity-bars span { flex-grow: 1; min-width: 0; border-radius: 3px 3px 0 0; background: var(--primary); }
.activity-bars.is-flame span { background: var(--flame); }
.activity-bars span.is-empty { background: var(--border); }
.activity-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }

.hardest { padding: 24px 28px; display: flex; flex-direction: column; gap: 10px; }
.hardest .label { margin-bottom: 8px; }
.hardest-name { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 40px; line-height: 40px; overflow-wrap: anywhere; }

.leaderboard { padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; }
.leaderboard .bar-list { list-style: none; margin: 0; padding: 0; }
.leaderboard .bar-row { font-size: 15px; }

.history-page .muted { margin: -8px 0 0; }
.history-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.history-group .label { margin: 0; }
.round-list-card { padding: 4px 0; gap: 0; }
.round-list-card .round-row { padding: 12px 18px; border-top: 1px solid var(--border-subtle); }
.round-list-card .round-row:first-child { border-top: none; }

@media (max-width: 1023px) {
    .garage, .stats-row, .stats-row-even { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .activity { grid-column: auto; }
}

@media (max-width: 759px) {
    .garage-score, .garage-recent, .activity, .hardest, .leaderboard { padding: 18px 20px; }
    .garage-total-value { font-size: 76px; line-height: 72px; }
    .garage-minis { gap: 8px; }
    .mini { padding: 10px 12px; border-radius: 12px; }
    .mini .label { font-size: 11px; }
    .mini-value { font-size: 30px; line-height: 30px; }
    .stats-everyone { margin-top: 12px; }
    .activity-bars { gap: 3px; height: 64px; }
    .activity-series + .activity-series .activity-bars { height: 36px; }
    .hardest-name { font-size: 28px; line-height: 28px; }
    .round-list-card .round-row { padding: 12px 16px; }
}

/* ==========================================================================
   Upload (views/upload.ejs)
   ========================================================================== */

.upload {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 24px var(--gutter) 40px;
}

.upload-title-phone { display: none; }
.upload-photos { display: flex; flex-direction: column; gap: 12px; min-width: 0; border-radius: var(--radius-card); }
.upload-photos-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.upload-photos-head .label { margin: 0; }
.upload-photos-head .faint { font-size: 13px; }

.upload-pickers { display: none; }
.camera-btn { display: none; }

.dropzone {
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius-card);
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-2);
    font: inherit;
}
.dropzone:hover { border-color: var(--primary); color: var(--text); }
.dropzone svg { color: var(--primary); }
.dropzone-title { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 32px; line-height: 32px; color: var(--text); }
.dropzone-text { font-size: 15px; }
.dropzone-link { color: var(--primary); font-weight: 700; }
.upload-photos.is-dragging .dropzone, .upload-photos.is-dragging .slots { outline: 2px dashed var(--primary); outline-offset: 6px; }

.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.slot {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 16px;
    background: var(--stage);
    display: flex;
    align-items: center;
    justify-content: center;
}
.slot img { width: 100%; height: 100%; object-fit: cover; }
.slot.is-loading { color: var(--text-2); }
.slot-add {
    flex-direction: column;
    gap: 8px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-2);
    font: 700 15px var(--font-body);
}
.slot-add:hover { border-color: var(--primary); color: var(--text); }
.slot-remove { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; }
.slot-badge {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border-radius: var(--pill);
    background: var(--scrim);
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 700;
}

.upload-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.upload-card { padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.upload-card > .label { margin-bottom: -8px; }
.upload-title { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 44px; line-height: 42px; }
.upload-note { margin: -6px 0 0; font-size: 13px; }
.field:disabled { opacity: 0.45; }

.upload-tips { padding: 20px 24px; display: flex; flex-direction: column; gap: 8px; }
.upload-tips h2 { margin: 0; font-size: 15px; font-weight: 800; }
.upload-tips p { margin: 0; font-size: 14px; line-height: 21px; color: var(--text-2); }
.upload-footer { padding: 0 8px; }

.done { align-items: center; text-align: center; padding-top: 96px; }
.done-icon {
    width: 96px;
    height: 96px;
    border-radius: var(--pill);
    background: var(--correct-soft);
    border: 2px solid var(--correct-line);
    color: var(--correct);
    display: flex;
    align-items: center;
    justify-content: center;
}
.done-title { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 56px; line-height: 54px; }
.done-title:focus { outline: none; }
.done-text { margin: 0; max-width: 420px; font-size: 17px; line-height: 26px; color: var(--text-2); }
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; margin-top: 8px; }
.done-see { color: var(--primary); font-weight: 700; }

@media (min-width: 1024px) {
    .upload {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 420px;
        gap: 32px;
        max-width: none;
        height: calc(100dvh - var(--topbar-h));
        min-height: 600px;
        padding: 24px var(--gutter) 28px;
    }
    .upload-photos { min-height: 0; }
    .dropzone { flex-grow: 1; }
    .slots { flex-grow: 1; min-height: 0; grid-template-rows: repeat(2, minmax(0, 1fr)); }
    .slot { aspect-ratio: auto; min-height: 0; }
    .slot img { position: absolute; inset: 0; }
    .upload-side { min-height: 0; overflow-y: auto; }
    .upload-footer { margin-top: 8px; }
}

@media (pointer: coarse) {
    .camera-btn { display: inline-flex; }
}

@media (max-width: 759px) {
    .upload { padding: 20px var(--gutter) 28px; gap: 16px; }
    .upload-title-phone { display: block; }
    .upload-title { display: none; }
    .upload-photos-head { display: none; }
    .upload-pickers { display: flex; gap: 10px; }
    .upload-pickers .btn { flex: 1 1 0; }
    .dropzone { display: none; }
    .slots { gap: 10px; }
    .slot { border-radius: 14px; }
    .slot-add span { font-size: 13px; }
    .upload-card { padding: 0; border: none; background: transparent; gap: 16px; }
    .upload-tips { order: -1; padding: 16px 18px; }
    .upload-tips p + p { display: none; }
    .upload-footer { padding: 0; }
    .done { padding-top: 64px; }
    .done-title { font-size: 44px; line-height: 42px; }
    .done-actions { flex-direction: column; width: 100%; }
    .done-actions .btn { width: 100%; }
}

/* ==========================================================================
   Android beta (/app)
   ========================================================================== */

.beta-kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--primary); }
.beta-intro { margin: 0; max-width: 60ch; font-size: 17px; line-height: 26px; color: var(--body-text); }
.beta-perk { padding: 20px; display: flex; gap: 16px; align-items: center; background: var(--flame-soft); border-color: var(--flame-line); }
.beta-perk-icon { flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--flame-soft); color: var(--flame); }
.beta-perk h2 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 24px; line-height: 26px; color: var(--flame); }
.beta-perk p { margin: 0; font-size: 15px; line-height: 22px; }
.beta-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.beta-step { padding: 20px; display: flex; gap: 16px; align-items: flex-start; }
.beta-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    font: 700 20px var(--font-display);
}
.beta-step-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; }
.beta-step-body h2 { margin: 6px 0 0; font-size: 17px; font-weight: 800; }
.beta-step-body p { margin: 0; font-size: 15px; line-height: 22px; }
.beta-notes { padding: 20px; }
.beta-notes .label { margin: 0 0 10px; }
.beta-notes ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--body-text); font-size: 14px; line-height: 21px; }

@media (max-width: 759px) {
    .beta-step { padding: 16px; gap: 12px; }
    .beta-step-body .btn { width: 100%; }
}

/* ==========================================================================
   Settings
   ========================================================================== */

.settings { gap: 14px; }
.settings .page-title { margin-bottom: 12px; }
.settings-section { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.settings-section > .label { margin: 0; }

.segmented { padding: 6px; border-radius: var(--pill); display: flex; gap: 4px; }
.segmented button {
    flex: 1 1 0;
    height: 44px;
    border-radius: var(--pill);
    border: none;
    background: transparent;
    color: var(--text-2);
    font: 700 14px var(--font-body);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 800; }
.seg-short { display: none; }

.settings-reset { padding: 20px; display: flex; align-items: center; gap: 20px; }
.settings-reset p { margin: 0; flex-grow: 1; font-size: 15px; line-height: 22px; color: var(--text-2); }

.settings-list { overflow: hidden; display: flex; flex-direction: column; }
.settings-list > * + * { border-top: 1px solid var(--border-subtle); }
.settings-info { padding: 14px 20px; display: flex; flex-direction: column; gap: 2px; }
.settings-info-title { font-size: 15px; font-weight: 700; }
.settings-info .faint { font-size: 13px; }

.settings-details summary { padding: 14px 20px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--primary); }
.settings-details dl { margin: 0; padding: 0 20px 16px; display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 13px; }
.settings-details dt { color: var(--text-3); }
.settings-details dd { margin: 0; color: var(--text-2); overflow-wrap: anywhere; }

.settings-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 52px;
    padding: 0 20px;
    border: none;
    background: transparent;
    color: var(--text);
    font: 600 15px var(--font-body);
    text-align: left;
}
.settings-row span { flex-grow: 1; }
.settings-row svg { color: var(--text-3); }
.settings-row:hover { background: var(--raised); color: var(--text); }
.desktop-row { display: none; }
@media (min-width: 1024px) and (hover: hover) { .desktop-row { display: flex; } }

.settings-foot { margin: 12px 0 0; text-align: center; font-size: 12px; }
.settings-version { margin-top: 4px; }
.settings-version code { font-family: inherit; font-variant-numeric: tabular-nums; }

@media (max-width: 759px) {
    .seg-long { display: none; }
    .seg-short { display: inline; }
    .segmented button svg { display: none; }
    .settings-reset { flex-direction: column; align-items: stretch; gap: 14px; padding: 18px; }
    .settings-reset .btn { height: 48px; }
    .settings-info, .settings-details summary, .settings-row { padding-left: 18px; padding-right: 18px; }
}

/* ==========================================================================
   Privacy and error pages
   ========================================================================== */

.privacy { flex-direction: row; align-items: flex-start; gap: 64px; max-width: 1104px; }
.privacy-toc {
    position: sticky;
    top: calc(var(--topbar-h) + 32px);
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.privacy-toc .label { padding: 0 12px 10px; }
.privacy-toc a { padding: 6px 12px; border-radius: 8px; font-size: 14px; color: var(--text-2); }
.privacy-toc a:hover { background: var(--surface); color: var(--text); }

.prose { flex-grow: 1; min-width: 0; max-width: 700px; }
.prose h2 { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 30px; line-height: 32px; margin: 40px 0 12px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.prose h3 { font-size: 17px; font-weight: 800; margin: 24px 0 8px; }
.prose p, .prose li { font-size: 16px; line-height: 27px; color: var(--body-text); }
.prose ul { padding-left: 22px; margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }
.privacy-updated { margin: 8px 0 0 !important; font-size: 14px !important; color: var(--text-3) !important; }
.contact-box { padding: 8px 24px; margin-top: 16px; }

.error-page { align-items: center; text-align: center; padding-top: 72px; gap: 16px; }
.error-code { font-family: var(--font-display); font-weight: 700; font-size: 200px; line-height: 170px; color: var(--primary); }
.error-title { margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 44px; line-height: 44px; }
.error-text { margin: 0; max-width: 480px; font-size: 17px; line-height: 26px; color: var(--text-2); }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.error-meta { margin: 12px 0 0; font-size: 12px; line-height: 20px; }

@media (max-width: 1023px) {
    .privacy { flex-direction: column; gap: 24px; }
    .privacy-toc { display: none; }
}

@media (max-width: 759px) {
    .prose h2 { font-size: 24px; line-height: 26px; margin-top: 32px; }
    .prose p, .prose li { font-size: 15px; line-height: 25px; }
    .error-page { padding-top: 40px; }
    .error-code { font-size: 140px; line-height: 120px; }
    .error-title { font-size: 34px; line-height: 36px; }
    .error-actions { flex-direction: column; width: 100%; }
}

/* Ko-fi support link (partials/kofi-link.ejs) */
.site-footer { align-items: center; }
.site-footer a.kofi-link, .kofi-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px 0 10px;
    border-radius: var(--pill);
    border: 1px solid var(--flame-line);
    color: var(--flame);
    font-size: 13px;
    font-weight: 700;
}
.site-footer a.kofi-link:hover, .kofi-link:hover { background: var(--flame-soft); color: var(--flame); }

.app-nudge { position: relative; padding: 16px 48px 16px 16px; display: flex; align-items: center; gap: 14px; border-color: var(--primary); background: var(--primary-soft); }
.app-nudge-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary); color: var(--on-primary); }
.app-nudge-body { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 20px; min-width: 0; }
.app-nudge-body strong { font-size: 15px; }
.app-nudge-cta { flex-shrink: 0; height: 40px; padding: 0 16px; font-size: 14px; }
.app-nudge-close { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: none; color: var(--text-3); }
@media (max-width: 420px) {
    .app-nudge { flex-wrap: wrap; }
    .app-nudge-body { flex-basis: calc(100% - 58px); }
    .app-nudge-cta { margin-left: 58px; }
}
.settings-row.settings-kofi { color: var(--flame); }
.settings-row.settings-kofi svg:first-child { color: var(--flame); }
