/* ==========================================================================
   BeastlyBrainBurst - shared design system
   White cards on a light ground, an indigo accent and six cheerful tones, set in Google Sans. Every view
   builds on these tokens and components and only adds page-specific rules.
   ========================================================================== */

/* Google Sans (SIL Open Font License 1.1, vendor/google-sans/OFL.txt), served from
   here instead of fonts.googleapis.com: no extra connection on a slow network, no
   visitor data to Google. A variable font: one file per subset covers weights 400-700. */
@font-face {
    font-family: 'Google Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../vendor/google-sans/google-sans-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Google Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../vendor/google-sans/google-sans-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* --- Palette --- */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --on-primary: #ffffff;
    --primary-container: #e4e3fd;
    --on-primary-container: #27237a;
    --secondary-container: #ebeafd;
    --on-secondary-container: #2c2878;

    --surface: #f4f5f9;             /* page ground */
    --surface-bright: #ffffff;      /* cards, dialogs */
    --surface-low: #f8f8fc;
    --surface-container: #f0f1f6;
    --surface-high: #e7e8f0;
    --surface-highest: #dedfe9;
    --on-surface: #1c1b24;
    --on-surface-variant: #5b5d6b;
    --outline: #7d7f8e;
    --outline-variant: #e2e3ec;
    --field-border: #bec0cf;
    --inverse-surface: #2b2a36;
    --inverse-on-surface: #f2f1fa;

    /* State layers: the ink colour at low opacity */
    --hover-neutral: rgba(28, 27, 36, 0.05);
    --hover-primary: rgba(79, 70, 229, 0.08);
    --press-primary: rgba(79, 70, 229, 0.14);

    --success: #15803d;
    --success-container: #dcf5e4;
    --on-success-container: #14532d;
    --danger: #dc2626;
    --danger-container: #fde4e4;
    --on-danger-container: #7f1d1d;
    --warn: #b45309;
    --warn-container: #fef1cc;
    --on-warn-container: #78350f;

    /* Accent tones: answer options (A, B, C, ...), categories, avatars, stat tiles.
       Pick one with a .tone-N class (below) or the Tone helper in C#. */
    --tone-1: #2f6fed;
    --tone-1-soft: #e7efff;
    --tone-2: #e5484d;
    --tone-2-soft: #fdeaea;
    --tone-3: #f0a202;
    --tone-3-soft: #fff3d4;
    --tone-4: #16a34a;
    --tone-4-soft: #e0f6e8;
    --tone-5: #db2777;
    --tone-5-soft: #fde7f1;
    --tone-6: #0891b2;
    --tone-6-soft: #dcf3f8;

    /* Question types */
    --type-choice: #2f6fed;
    --type-choice-soft: #e7efff;
    --type-dragdrop: #7c3aed;
    --type-dragdrop-soft: #efe7fe;
    --type-estimate: #d97706;
    --type-estimate-soft: #fdf1d8;
    --type-hotspot: #e5484d;
    --type-hotspot-soft: #fdeaea;
    --type-other: #7d7f8e;

    --gold: #e0a800;
    --silver: #9ea3b0;
    --bronze: #c2703d;

    --elev-1: 0 1px 2px rgba(40, 38, 70, 0.08), 0 1px 3px 1px rgba(40, 38, 70, 0.05);
    --elev-2: 0 1px 2px rgba(40, 38, 70, 0.10), 0 2px 8px 2px rgba(40, 38, 70, 0.07);
    --elev-3: 0 4px 10px 3px rgba(40, 38, 70, 0.11), 0 1px 3px rgba(40, 38, 70, 0.12);

    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-panel: 24px;
    --radius-xl: 28px;
    --radius-full: 999px;

    --font: 'Google Sans', 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ease: cubic-bezier(0.2, 0, 0, 1);

    /* Older names that page-level styles still use */
    --bg-color: var(--surface);
    --accent-primary: var(--primary);
    --accent-hover: var(--primary-hover);
    --text-main: var(--on-surface);
    --text-secondary: var(--on-surface-variant);
    --glass-panel: var(--surface-bright);
    --glass-border: var(--outline-variant);
    --danger-bg: var(--danger-container);
    --success-bg: var(--success-container);
    --warn-bg: var(--warn-container);
    --line: var(--outline-variant);
    --shadow-sm: var(--elev-1);
    --shadow-md: var(--elev-2);
    --shadow-lg: var(--elev-3);
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    font-family: var(--font);
    color: var(--on-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--surface);
    font-size: 14px;
    line-height: 1.5;
}

/* Form controls do not inherit the page font on their own */
button, input, select, textarea {
    font: inherit;
    color: inherit;
}

h1, h2, h3, h4 {
    font-weight: 500;
    letter-spacing: 0;
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.text-danger {
    color: var(--danger);
}

.text-secondary {
    color: var(--on-surface-variant);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.98) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Top app bar (Profile, Categories, Questions, Sessions, Game host views)
   ========================================================================== */

.app-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 8px 24px;
    background: var(--surface);
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s, background-color 0.2s;
}

/* The bar melts into the page until the content scrolls under it (site.js) */
body.is-scrolled .app-nav {
    border-bottom-color: var(--outline-variant);
}

.app-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 500;
    color: var(--on-surface);
    text-decoration: none;
    white-space: nowrap;
}

    .app-nav-brand img {
        width: 32px;
        height: 32px;
        display: block;
    }

.app-nav-links {
    list-style: none;
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

    .app-nav-links form {
        margin: 0;
    }

.app-nav-link,
.app-nav-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), color 0.2s;
}

    .app-nav-link:hover,
    .app-nav-logout:hover {
        background: var(--hover-neutral);
        color: var(--on-surface);
    }

    .app-nav-link.active {
        background: var(--secondary-container);
        color: var(--on-secondary-container);
    }

@media (max-width: 720px) {
    .app-nav {
        padding: 8px 12px;
    }

    .app-nav-brand span {
        display: none;
    }

    .app-nav-link span.link-label,
    .app-nav-logout span.link-label {
        display: none;
    }

    .app-nav-link,
    .app-nav-logout {
        padding: 0 12px;
    }
}

/* --- Join QR in the dashboard header: a thumbnail, the full size opens on click --- */
.qr-thumbnail {
    display: block;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-sm);
    cursor: zoom-in;
    transition: box-shadow 0.2s, border-color 0.2s;
}

    /* No transform on hover: a scale promotes the image to its own layer and the
       browser resamples it, so the thumbnail would visibly change on hover. */
    .qr-thumbnail:hover {
        box-shadow: var(--elev-1);
        border-color: var(--outline);
    }

    .qr-thumbnail img {
        display: block;
        width: 100%;
        height: 100%;
        /* The QR is an SVG: ~40 modules in 40px is about one pixel per module, so
           nearest-neighbour ("pixelated") drops whole modules and looks grainy.
           Let the browser anti-alias it instead. */
        image-rendering: auto;
    }

/* --- Footer with the running version (partial _AppFooter) --- */
.app-footer {
    padding: 16px 20px 20px;
    text-align: center;
    color: var(--on-surface-variant);
    font-size: 12px;
    opacity: 0.85;
}

    .app-footer .sep {
        margin: 0 6px;
        opacity: 0.6;
    }

/* Keeps the footer at the bottom of short pages */
body.has-footer {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

    body.has-footer > main {
        flex: 1 0 auto;
        width: 100%;
    }

/* --- Page shell / max-width content wrapper --- */
.shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 48px;
    animation: fadeIn 0.3s var(--ease);
}

.shell-narrow {
    max-width: 900px;
}

.shell-tight {
    max-width: 760px;
}

@media (max-width: 640px) {
    .shell {
        padding: 16px 16px 40px;
    }
}

/* --- Plain surface card --- */
.glass-panel,
.surface-card {
    background: var(--surface-bright);
    border-radius: var(--radius-panel);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s, color 0.2s;
}

    .btn:hover {
        background: var(--hover-primary);
    }

    .btn:active {
        background: var(--press-primary);
    }

    .btn:disabled,
    .btn[disabled] {
        opacity: 0.4;
        cursor: not-allowed;
        background: transparent;
        box-shadow: none;
    }

    .btn i {
        font-size: 0.95em;
    }

/* Filled: the one main action of a screen */
.btn-primary {
    background: var(--primary);
    border-color: transparent;
    color: var(--on-primary);
}

    .btn-primary:hover {
        background: var(--primary-hover);
        box-shadow: var(--elev-1);
    }

    .btn-primary:active {
        background: var(--primary-hover);
        box-shadow: none;
    }

    .btn-primary:disabled,
    .btn-primary[disabled] {
        background: var(--primary);
    }

/* Tonal: important, but not the main action */
.btn-tonal {
    background: var(--secondary-container);
    border-color: transparent;
    color: var(--on-secondary-container);
}

    .btn-tonal:hover {
        background: #dddcfb;
        box-shadow: var(--elev-1);
    }

    .btn-tonal:disabled,
    .btn-tonal[disabled] {
        background: var(--secondary-container);
    }

/* Outlined, neutral ink: navigation like "Zurück" */
.btn-secondary {
    color: var(--on-surface);
}

    .btn-secondary:hover {
        background: var(--hover-neutral);
    }

/* Text only: dialog cancel, low-emphasis actions */
.btn-text {
    border-color: transparent;
    padding: 0 12px;
}

.btn-danger {
    background: var(--danger-container);
    border-color: transparent;
    color: var(--on-danger-container);
}

    .btn-danger:hover {
        background: #fbd3d3;
    }

/* Filled red: the confirm button of a destructive dialog */
.btn-danger-filled {
    background: var(--danger);
    border-color: transparent;
    color: #fff;
}

    .btn-danger-filled:hover {
        background: #b91c1c;
        box-shadow: var(--elev-1);
    }

.btn-danger-ghost {
    width: 40px;
    padding: 0;
    border-color: transparent;
    color: var(--on-surface-variant);
    flex-shrink: 0;
}

    .btn-danger-ghost:hover {
        background: var(--danger-container);
        color: var(--danger);
    }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px 0 12px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s;
}

    .btn-back:hover {
        background: var(--hover-neutral);
        color: var(--on-surface);
    }

.btn-sm {
    height: 32px;
    padding: 0 14px;
    font-size: 13px;
}

.btn-lg {
    height: 48px;
    padding: 0 28px;
    font-size: 15px;
}

.btn-full {
    width: 100%;
}

/* --- Segmented control (e.g. list/grid view toggle) --- */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-full);
    overflow: hidden;
}

    .view-toggle a,
    .view-toggle button {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 32px;
        padding: 0 14px;
        border: none;
        background: transparent;
        color: var(--on-surface-variant);
        font-size: 13px;
        font-weight: 500;
        text-decoration: none;
        cursor: pointer;
        transition: background-color 0.2s;
    }

        .view-toggle a + a,
        .view-toggle button + button {
            border-left: 1px solid var(--outline-variant);
        }

        .view-toggle a:hover,
        .view-toggle button:hover {
            background: var(--hover-neutral);
        }

        .view-toggle a.active,
        .view-toggle button.active {
            background: var(--secondary-container);
            color: var(--on-secondary-container);
        }

/* --- Small round icon buttons --- */
.icon-btn {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

    .icon-btn:hover {
        background: var(--hover-neutral);
        color: var(--on-surface);
    }

    .icon-btn.is-danger:hover {
        background: var(--danger-container);
        color: var(--danger);
    }

    .icon-btn.is-primary:hover {
        background: var(--hover-primary);
        color: var(--primary);
    }

/* ==========================================================================
   Avatars, status labels, badges
   ========================================================================== */

.avatar {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-container);
    color: var(--on-primary-container);
    font-size: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.avatar[class*="tone-"] {
    background: var(--tone);
    color: var(--tone-ink);
}

/* "Session läuft": the one green thing in a header */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--success-container);
    color: var(--on-success-container);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

    .status-pill::before {
        content: '';
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--success);
    }

    .status-pill.is-warn {
        background: var(--warn-container);
        color: var(--on-warn-container);
    }

        .status-pill.is-warn::before {
            background: var(--warn);
        }

    .status-pill.is-info {
        background: var(--secondary-container);
        color: var(--on-secondary-container);
    }

        .status-pill.is-info::before {
            background: var(--primary);
            animation: pulse 1.6s ease-in-out infinite;
        }

@keyframes pulse {
    50% { opacity: 0.35; }
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-active {
    background: var(--success-container);
    color: var(--on-success-container);
}

.status-paused {
    background: var(--warn-container);
    color: var(--on-warn-container);
}

.status-closed {
    background: var(--surface-high);
    color: var(--on-surface-variant);
}

.badge-correct {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--success-container);
    color: var(--on-success-container);
    font-size: 12px;
    font-weight: 500;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--radius-full);
    background: var(--surface-container);
    color: var(--on-surface-variant);
    font-size: 12px;
    font-weight: 500;
}

/* ==========================================================================
   Content panels
   ========================================================================== */

.content-panel {
    background: var(--surface-bright);
    border-radius: var(--radius-panel);
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

    .panel-header h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 10px;
    }

/* Small heading above a group, e.g. "Extra-Runden" */
.section-label {
    margin: 24px 0 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-variant);
}

.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

    .toggle-btn:hover {
        background: var(--hover-primary);
    }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--on-surface-variant);
    font-size: 14px;
}

    .empty-state i {
        display: block;
        font-size: 28px;
        margin-bottom: 12px;
        opacity: 0.45;
    }

    .empty-state p {
        margin: 0;
    }

.mini-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 12px;
    font-size: 13px;
    color: var(--on-surface-variant);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-variant);
}

    label small {
        font-weight: 400;
    }

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--surface-bright);
    color: var(--on-surface);
    font-size: 16px;
    line-height: 1.4;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    input[type="text"]:hover,
    input[type="number"]:hover,
    input[type="password"]:hover,
    textarea:hover,
    select:hover {
        border-color: var(--on-surface-variant);
    }

    input[type="text"]:focus,
    input[type="number"]:focus,
    input[type="password"]:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: inset 0 0 0 1px var(--primary);
    }

    input::placeholder,
    textarea::placeholder {
        color: #8c8e9c;
    }

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

input[type="range"] {
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    color: var(--on-surface);
    cursor: pointer;
    user-select: none;
}

.field-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 520px) {
    .field-row-2 {
        grid-template-columns: 1fr;
    }
}

.field-panel {
    background: var(--surface-low);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.field-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--on-surface-variant);
}

    .field-hint i {
        margin-top: 3px;
    }

/* Sub-heading inside a form, e.g. "Antworten" */
.form-section-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

/* --- Editor rows (dynamic answer/pair lists in forms) --- */
.editor-row {
    background: var(--surface-bright);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .editor-row:last-child {
        margin-bottom: 0;
    }

    .editor-row.editor-row-line {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .editor-row.editor-row-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .editor-row.is-correct {
        background: var(--success-container);
        border-color: transparent;
    }

/* --- File upload dropzone --- */
.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: block;
    width: 100%;
}

.file-upload-label {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    margin: 0;
    padding: 16px;
    border: 1px dashed var(--field-border);
    border-radius: var(--radius-md);
    background: var(--surface-low);
    color: var(--on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

    .file-upload-label:hover {
        border-color: var(--primary);
        background: var(--hover-primary);
        color: var(--primary);
    }

input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* --- Search field: a filled pill, like the search bar of a Google app --- */
.search-field {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 480px;
}

    .search-field i {
        position: absolute;
        left: 18px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--on-surface-variant);
        font-size: 14px;
        pointer-events: none;
    }

    .search-field input {
        width: 100%;
        height: 48px;
        margin: 0 !important;
        padding-left: 46px !important;
        border: none;
        border-radius: var(--radius-full);
        background: var(--surface-high);
        font-size: 15px;
    }

        .search-field input:hover {
            background: var(--surface-highest);
        }

        .search-field input:focus {
            background: var(--surface-bright);
            box-shadow: var(--elev-2);
        }

/* ==========================================================================
   Dialogs
   ========================================================================== */

dialog.app-dialog {
    width: calc(100% - 32px);
    max-width: 480px;
    padding: 0;
    border: none;
    border-radius: var(--radius-xl);
    background: var(--surface-bright);
    color: var(--on-surface);
    box-shadow: var(--elev-3);
}

    dialog.app-dialog[open] {
        animation: popIn 0.2s var(--ease);
    }

    dialog.app-dialog::backdrop {
        background: rgba(28, 27, 36, 0.32);
    }

dialog.app-dialog.is-wide {
    max-width: 620px;
}

.dialog-content {
    padding: 24px;
}

    .dialog-content header {
        margin-bottom: 16px;
        font-size: 24px;
        font-weight: 400;
        line-height: 1.3;
    }

.dialog-subtitle {
    margin: -8px 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--on-surface-variant);
    overflow-wrap: anywhere;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

/* ==========================================================================
   Banners
   ========================================================================== */

.alert-error,
.alert-success,
.alert-info {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.45;
}

    .alert-error i,
    .alert-success i,
    .alert-info i {
        margin-top: 3px;
    }

.alert-error {
    background: var(--danger-container);
    color: var(--on-danger-container);
}

.alert-success {
    background: var(--success-container);
    color: var(--on-success-container);
}

.alert-info {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

/* ==========================================================================
   Auth pages (Login / Register)
   ========================================================================== */

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 40px 36px 32px;
    background: var(--surface-bright);
    border-radius: var(--radius-xl);
    animation: slideUp 0.35s var(--ease);
}

    .auth-card .header {
        text-align: center;
        margin-bottom: 28px;
    }

        .auth-card .header img {
            width: 48px;
            height: 48px;
            display: block;
            margin: 0 auto 16px;
        }

        .auth-card .header h1 {
            margin: 0;
            font-size: 28px;
            font-weight: 400;
            line-height: 1.25;
        }

        .auth-card .header p {
            margin: 8px 0 0;
            color: var(--on-surface-variant);
            font-size: 15px;
        }

.auth-success {
    text-align: center;
    padding: 16px 0 4px;
}

    .auth-success .success-icon {
        display: block;
        margin-bottom: 16px;
        font-size: 44px;
        color: var(--success);
    }

    .auth-success h2 {
        margin: 0 0 8px;
        font-size: 24px;
        font-weight: 400;
    }

    .auth-success p {
        margin: 0 0 24px;
        color: var(--on-surface-variant);
    }

.footer-links {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--on-surface-variant);
}

    .footer-links a {
        color: var(--primary);
        font-weight: 500;
        text-decoration: none;
    }

        .footer-links a:hover {
            text-decoration: underline;
        }

.auth-back-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-surface-variant);
    font-size: 16px;
    text-decoration: none;
    transition: background-color 0.2s;
}

    .auth-back-btn:hover {
        background: var(--hover-neutral);
        color: var(--on-surface);
    }

@media (max-width: 480px) {
    .auth-card {
        padding: 36px 20px 24px;
    }
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.layout-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 960px) {
    .layout-grid-2 {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.is-hidden {
    display: none !important;
}

/* "Präsentieren" with several screens attached: which one, and fullscreen or not (site.js) */
.present-place {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.present-place-screen {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    font-weight: 400;
    cursor: pointer;
}

    .present-place-screen:has(input:checked) {
        border-color: var(--primary);
        background: var(--secondary-container);
    }

    .present-place-screen span {
        display: flex;
        flex-direction: column;
        line-height: 1.3;
    }

    .present-place-screen strong {
        font-weight: 500;
    }

    .present-place-screen small {
        color: var(--text-secondary);
    }

.present-place .checkbox-wrapper {
    margin-top: 8px;
}

/* The [hidden] attribute must win over component display rules (flex/grid) */
[hidden] {
    display: none !important;
}

/* ==========================================================================
   A tap that loads the next page (site.js): the tapped control shows that it
   works, a thin bar runs along the top once it takes a moment, and further
   taps wait. On a slow network that is seconds - without it, it looked as if
   nothing had happened, and people tapped again.
   ========================================================================== */

.is-busy {
    cursor: progress;
}

    .btn.is-busy,
    .btn-submit.is-busy,
    .category-card.is-busy {
        opacity: 0.75;
    }

        .btn.is-busy::after,
        .btn-submit.is-busy::after {
            content: "";
            display: inline-block;
            width: 0.9em;
            height: 0.9em;
            margin-left: 8px;
            border: 2px solid currentColor;
            border-right-color: transparent;
            border-radius: 50%;
            vertical-align: -0.1em;
            animation: busy-spin 0.7s linear infinite;
        }

html.is-navigating body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent) 0 0 / 40% 100% no-repeat;
    opacity: 0;
    animation: busy-bar 1.2s linear 0.4s infinite;
    pointer-events: none;
}

@keyframes busy-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes busy-bar {
    from {
        opacity: 1;
        background-position: -40% 0;
    }

    to {
        opacity: 1;
        background-position: 140% 0;
    }
}

/* ==========================================================================
   Accent tones
   A .tone-N class hands --tone (solid), --tone-soft (tint) and --tone-ink (text
   on solid) to the components inside it.
   ========================================================================== */

.tone-1 { --tone: var(--tone-1); --tone-soft: var(--tone-1-soft); --tone-ink: #fff; }
.tone-2 { --tone: var(--tone-2); --tone-soft: var(--tone-2-soft); --tone-ink: #fff; }
.tone-3 { --tone: var(--tone-3); --tone-soft: var(--tone-3-soft); --tone-ink: #3d2800; }
.tone-4 { --tone: var(--tone-4); --tone-soft: var(--tone-4-soft); --tone-ink: #fff; }
.tone-5 { --tone: var(--tone-5); --tone-soft: var(--tone-5-soft); --tone-ink: #fff; }
.tone-6 { --tone: var(--tone-6); --tone-soft: var(--tone-6-soft); --tone-ink: #fff; }

/* Letter badge of an answer option (A, B, C, ...): same colour on the phone and the projector */
.opt-badge {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--tone, var(--primary));
    color: var(--tone-ink, #fff);
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

/* Entry and player screens: soft colour washes behind the cards */
body.has-glow {
    background:
        radial-gradient(48rem 34rem at 8% -4%, rgba(99, 102, 241, 0.26), transparent 70%),
        radial-gradient(40rem 30rem at 100% 8%, rgba(245, 158, 11, 0.22), transparent 70%),
        radial-gradient(44rem 32rem at 90% 104%, rgba(219, 39, 119, 0.16), transparent 70%),
        radial-gradient(40rem 30rem at -2% 98%, rgba(8, 145, 178, 0.17), transparent 70%),
        var(--surface);
    background-attachment: fixed;
}

/* ==========================================================================
   Chips
   ========================================================================== */

/* Category picker in the question forms */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip,
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--on-surface-variant);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

    .chip:hover,
    .filter-chip:hover {
        background: var(--hover-neutral);
        color: var(--on-surface);
    }

    .chip input[type="checkbox"] {
        display: none;
    }

    /* Radio chips stay focusable for the keyboard, just invisible */
    .chip input[type="radio"] {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        pointer-events: none;
    }

    .chip:has(input:focus-visible) {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }

    .chip:has(input:checked),
    .chip.checked,
    .filter-chip.active {
        background: var(--secondary-container);
        border-color: transparent;
        color: var(--on-secondary-container);
    }

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.chip-count {
    display: inline-block;
    margin-left: 2px;
    font-size: 12px;
    opacity: 0.7;
}

/* ==========================================================================
   Question type picker (big choice cards)
   ========================================================================== */

.type-picker {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 28px;
}

@media (min-width: 640px) {
    .type-picker {
        grid-template-columns: repeat(4, 1fr);
    }
}

.type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 16px 10px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--on-surface);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

    .type-card i {
        font-size: 20px;
        margin-bottom: 4px;
        color: var(--on-surface-variant);
    }

    .type-card .type-card-title {
        font-size: 14px;
        font-weight: 500;
    }

    .type-card .type-card-desc {
        font-size: 12px;
        line-height: 1.35;
        color: var(--on-surface-variant);
    }

    .type-card:hover {
        background: var(--hover-neutral);
    }

    .type-card.active {
        background: var(--secondary-container);
        border-color: transparent;
    }

        .type-card.active i {
            color: var(--primary);
        }

/* ==========================================================================
   Drag & drop board (category <-> question assignment)
   ========================================================================== */

.dnd-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 800px) {
    .dnd-board {
        grid-template-columns: 1fr 1fr;
    }
}

.dnd-column {
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

.dnd-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 0 4px;
}

    .dnd-column-header h2 {
        margin: 0;
        font-size: 15px;
        font-weight: 500;
        display: flex;
        align-items: center;
        gap: 8px;
    }

.dnd-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 20px;
    padding: 0 7px;
    border-radius: var(--radius-full);
    background: var(--surface-container);
    color: var(--on-surface-variant);
    font-size: 12px;
    font-weight: 500;
}

.dnd-dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    border: 1px dashed var(--outline-variant);
    border-radius: var(--radius-lg);
    background: var(--surface-low);
    transition: background-color 0.15s, border-color 0.15s;
}

    .dnd-dropzone.drag-over {
        background: var(--hover-primary);
        border-color: var(--primary);
    }

.dnd-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    background: var(--surface-bright);
    cursor: grab;
    transition: box-shadow 0.15s, opacity 0.15s;
}

    .dnd-card:hover {
        box-shadow: var(--elev-1);
    }

    .dnd-card.dragging {
        opacity: 0.4;
    }

    .dnd-card .dnd-handle {
        color: var(--outline);
        font-size: 13px;
    }

    .dnd-card .dnd-text {
        flex: 1;
        font-size: 14px;
        line-height: 1.4;
    }

    .dnd-card .dnd-move-btn {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--on-surface-variant);
        cursor: pointer;
        transition: background-color 0.15s, color 0.15s;
    }

        .dnd-card .dnd-move-btn:hover {
            background: var(--secondary-container);
            color: var(--primary);
        }

.dnd-empty {
    margin: auto;
    padding: 24px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--on-surface-variant);
}

    .dnd-empty i {
        display: block;
        margin-bottom: 8px;
        font-size: 22px;
        opacity: 0.45;
    }

/* ==========================================================================
   Dashboard / library components
   Page header, stat tiles, collapsible category cards, question cards and the
   assignment dialog shared by the dashboard and the category views.
   ========================================================================== */

/* --- Page header: title on the page itself, actions on the right --- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    margin-bottom: 24px;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.page-header-title {
    min-width: 0;
}

    .page-header-title h1 {
        margin: 0;
        font-size: 28px;
        font-weight: 400;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .page-header-title p {
        margin: 4px 0 0;
        color: var(--on-surface-variant);
        font-size: 14px;
    }

    /* A small line above the title ("Live-Auswertung") */
    .page-header-title .kicker {
        margin: 0 0 4px;
        font-size: 13px;
        font-weight: 500;
        color: var(--primary);
    }

.page-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

    .page-header-right form {
        margin: 0;
    }

@media (max-width: 640px) {
    .page-header-title h1 {
        font-size: 24px;
    }
}

/* --- Stat tiles --- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--surface-bright);
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.2s, background-color 0.2s;
}

a.stat-tile:hover,
button.stat-tile:hover {
    box-shadow: var(--elev-1);
}

/* Interactive stat tile ("Ohne Kategorie" acts as a filter shortcut) */
button.stat-tile {
    width: 100%;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.stat-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tone-soft, var(--secondary-container));
    color: var(--tone, var(--on-secondary-container));
    font-size: 15px;
}

.stat-tile.is-warn .stat-icon {
    background: var(--warn-container);
    color: var(--warn);
}

.stat-tile.is-success .stat-icon {
    background: var(--success-container);
    color: var(--success);
}

.stat-num {
    display: block;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.25;
}

.stat-cap {
    display: block;
    font-size: 13px;
    color: var(--on-surface-variant);
}

/* --- Toolbar with search --- */
.dash-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

    .dash-toolbar .spacer {
        flex: 1;
    }

@media (max-width: 640px) {
    .dash-toolbar .search-field {
        flex-basis: 100%;
        max-width: none;
    }

    .dash-toolbar .spacer {
        display: none;
    }

    /* The row under a category name keeps to one line next to the action buttons;
       assigning and opening are also in the expanded body */
    .cat-sub .cat-date,
    .cat-actions .cat-action-extra {
        display: none;
    }
}

/* --- Question type badges --- */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-container);
    color: var(--on-surface);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.type-dot {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-container);
    color: var(--type-other);
    font-size: 12px;
}

.type-choice i { color: var(--type-choice); }
.type-dragdrop i { color: var(--type-dragdrop); }
.type-estimate i { color: var(--type-estimate); }
.type-hotspot i { color: var(--type-hotspot); }

.type-dot.type-choice, .type-badge.type-choice { background: var(--type-choice-soft); }
.type-dot.type-dragdrop, .type-badge.type-dragdrop { background: var(--type-dragdrop-soft); }
.type-dot.type-estimate, .type-badge.type-estimate { background: var(--type-estimate-soft); }
.type-dot.type-hotspot, .type-badge.type-hotspot { background: var(--type-hotspot-soft); }

.points-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-container);
    color: var(--on-surface);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* --- Collapsible category card --- */
.cat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cat-card {
    background: var(--surface-bright);
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

    .cat-card.open {
        border-color: var(--field-border);
    }

.cat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

    .cat-head:hover {
        background: var(--surface-low);
    }

.cat-chevron {
    flex: 0 0 16px;
    width: 16px;
    text-align: center;
    color: var(--on-surface-variant);
    font-size: 12px;
    transition: transform 0.2s var(--ease);
}

/* Colour square in front of a category name, in the category's tone */
.cat-swatch {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--tone-soft, var(--surface-container));
    color: var(--tone, var(--on-surface-variant));
    font-size: 14px;
}

.cat-card.open .cat-chevron {
    transform: rotate(90deg);
    color: var(--primary);
}

.cat-title {
    flex: 1;
    min-width: 0;
}

    .cat-title h3 {
        margin: 0;
        font-size: 15px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.cat-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--on-surface-variant);
}

    .cat-sub .sep {
        opacity: 0.6;
    }

.cat-actions {
    display: flex;
    align-items: center;
    gap: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.cat-card:hover .cat-actions,
.cat-card.open .cat-actions,
.cat-actions:focus-within {
    opacity: 1;
}

.cat-body {
    display: none;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--outline-variant);
    background: var(--surface-low);
}

.cat-card.open .cat-body {
    display: block;
    animation: fadeIn 0.2s var(--ease);
}

/* --- Compact question rows inside a category --- */
.q-mini-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.q-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 8px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-sm);
    background: var(--surface-bright);
}

.q-mini-text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

    .q-mini-text:hover {
        color: var(--primary);
    }

.q-mini-remove {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--on-surface-variant);
    font-size: 12px;
    cursor: pointer;
}

    .q-mini-remove:hover {
        background: var(--danger-container);
        color: var(--danger);
    }

.cat-body-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* --- Question cards in the library --- */
.q-library.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
    align-items: start;
}

.q-library.mode-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.q-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 12px 14px 16px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    background: var(--surface-bright);
    transition: box-shadow 0.2s, border-color 0.2s;
}

    .q-card:hover {
        border-color: transparent;
        box-shadow: var(--elev-2);
    }

.q-card-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

    .q-card-top .spacer {
        flex: 1;
    }

.q-card-text {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.45;
    cursor: pointer;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

    .q-card-text:hover {
        color: var(--primary);
    }

.q-card-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: auto;
}

/* Links inside cards keep the card typography */
.q-card-text,
.q-mini-text {
    text-decoration: none;
    color: inherit;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    height: 28px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-container);
    color: var(--on-surface);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .cat-chip i {
        font-size: 11px;
        opacity: 0.7;
    }

.cat-chip[class*="tone-"] {
    background: var(--tone-soft);
}

    .cat-chip[class*="tone-"] i {
        color: var(--tone);
        opacity: 1;
    }

.cat-chip-none {
    background: var(--warn-container);
    color: var(--on-warn-container);
}

.cat-chip-add {
    border-color: var(--outline-variant);
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    transition: background-color 0.15s;
}

    .cat-chip-add:hover {
        background: var(--hover-primary);
    }

    .cat-chip-add i {
        opacity: 1;
    }

/* --- Assignment dialog --- */
.assign-list {
    list-style: none;
    margin: 0;
    padding: 0 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: min(46vh, 380px);
    overflow-y: auto;
}

.assign-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-md);
    background: var(--surface-bright);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

    .assign-row:hover {
        background: var(--surface-low);
    }

    .assign-row.checked {
        background: var(--secondary-container);
        border-color: transparent;
    }

    .assign-row input {
        margin: 0;
        flex: 0 0 auto;
    }

.assign-row-body {
    flex: 1;
    min-width: 0;
}

.assign-row-text {
    display: block;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .assign-row-text i {
        margin-right: 8px;
        opacity: 0.6;
    }

.assign-row-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--on-surface-variant);
}

.assign-create {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--outline-variant);
}

    .assign-create input {
        flex: 1;
        margin: 0 !important;
    }

    .assign-create .btn {
        height: 48px;
    }

/* Category row on the question detail page */
.q-categories {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--outline-variant);
}

.q-categories-label {
    margin-right: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-variant);
}

/* ==========================================================================
   Participant screens (_GameLayout)
   ========================================================================== */

.game-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 15px;
    /* Height comes from body.has-footer (flex column), so the footer fits below
       without forcing a scrollbar. */
}

/* Mark and wordmark above the player bar */
.game-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding-top: 4px;
    font-size: 17px;
    font-weight: 500;
    color: var(--on-surface);
}

    .game-brand img {
        width: 28px;
        height: 28px;
        display: block;
    }

/* Player status bar: who am I, how am I doing, what is at stake.
   One line: the name gives way (ellipsis) before the chips wrap. */
.player-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-lg);
    background: var(--surface-bright);
    font-size: 13px;
}

    .player-bar .who {
        flex: 1 1 auto;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding-right: 4px;
        font-weight: 500;
    }

        .player-bar .who span {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

    .player-bar .spacer {
        flex: 1;
    }

.player-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-container);
    color: var(--on-surface-variant);
    font-weight: 500;
    white-space: nowrap;
}

    .player-chip strong {
        color: var(--on-surface);
        font-weight: 500;
    }

    .player-chip.is-score {
        background: var(--success-container);
        color: var(--on-success-container);
    }

        .player-chip.is-score strong {
            color: inherit;
        }

    .player-chip.is-stake {
        background: var(--primary-container);
        color: var(--on-primary-container);
    }

        .player-chip.is-stake strong {
            color: inherit;
        }

/* The big card a participant works in */
.play-card {
    background: var(--surface-bright);
    border-radius: var(--radius-xl);
    padding: 28px;
    animation: slideUp 0.35s var(--ease);
}

@media (max-width: 640px) {
    .game-shell {
        padding: 12px 12px 32px;
    }

    .play-card {
        padding: 22px 18px;
    }

    .player-bar {
        gap: 6px;
        padding: 8px;
    }

    .player-chip {
        height: 28px;
        padding: 0 9px;
        gap: 5px;
        font-size: 12px;
    }
}

@media (max-width: 370px) {
    .player-chip.hide-narrow {
        display: none;
    }
}

/* Full-width action at the bottom of a play card */
.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 56px;
    margin-top: 24px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--on-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

    .btn-submit:hover {
        background: var(--primary-hover);
        box-shadow: var(--elev-1);
    }

    .btn-submit:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        box-shadow: none;
        background: var(--primary);
    }

/* The option a player picked, shown back to them after submitting */
.my-pick {
    border-color: var(--tone, var(--primary)) !important;
    background: var(--tone-soft, var(--secondary-container)) !important;
    position: relative;
}

    .my-pick::after {
        content: "\f00c";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        position: absolute;
        top: 8px;
        right: 10px;
        font-size: 12px;
        color: var(--tone, var(--primary));
    }

/* ==========================================================================
   Leaderboards (final result and the pause screen)
   ========================================================================== */

.lb-card {
    background: var(--surface-bright);
    border-radius: var(--radius-xl);
    padding: 32px;
    animation: slideUp 0.35s var(--ease);
}

    .lb-card .header {
        text-align: center;
        margin-bottom: 28px;
    }

        .lb-card .header h1 {
            margin: 0;
            font-size: 32px;
            font-weight: 400;
            line-height: 1.2;
        }

        .lb-card .header p {
            margin: 8px 0 0;
            color: var(--on-surface-variant);
            font-size: 15px;
        }

.lb-trophy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: var(--tone-3-soft);
    color: var(--gold);
    font-size: 28px;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lb-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--surface-low);
}

    .lb-item.is-me {
        outline: 2px solid var(--primary);
        outline-offset: -2px;
    }

.rank-col {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.rank-badge {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-high);
    color: var(--on-surface-variant);
    font-size: 14px;
    font-weight: 500;
}

.lb-item.rank-1 .rank-badge { background: var(--gold); color: #fff; }
.lb-item.rank-2 .rank-badge { background: var(--silver); color: #fff; }
.lb-item.rank-3 .rank-badge { background: var(--bronze); color: #fff; }

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.username {
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--on-surface-variant);
}

    .score-detail span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

.score-col {
    text-align: right;
    flex-shrink: 0;
}

.total-score {
    display: block;
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--primary);
}

.total-label {
    display: block;
    font-size: 12px;
    color: var(--on-surface-variant);
}

.lb-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
}

    .lb-actions form {
        margin: 0;
    }

@media (max-width: 640px) {
    .lb-card {
        padding: 24px 16px;
    }

        .lb-card .header h1 {
            font-size: 26px;
        }
}

/* ==========================================================================
   SweetAlert2, dressed as Material dialogs and snackbars (see site.js)
   ========================================================================== */

.swal2-container {
    font-family: var(--font);
}

.swal2-popup:not(.swal2-toast):not(.stage-dialog) {
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    border-radius: var(--radius-xl);
    background: var(--surface-bright);
    color: var(--on-surface);
    box-shadow: var(--elev-3);
}

    .swal2-popup:not(.swal2-toast):not(.stage-dialog) .swal2-icon {
        display: none !important;
    }

    .swal2-popup:not(.swal2-toast):not(.stage-dialog) .swal2-title {
        margin: 0 0 16px;
        padding: 0;
        text-align: left;
        font-size: 24px;
        font-weight: 400;
        line-height: 1.3;
        color: var(--on-surface);
    }

    .swal2-popup:not(.swal2-toast):not(.stage-dialog) .swal2-html-container {
        margin: 0;
        padding: 0;
        text-align: left;
        font-size: 14px;
        line-height: 1.5;
        color: var(--on-surface-variant);
    }

    .swal2-popup:not(.swal2-toast):not(.stage-dialog) .swal2-actions {
        width: 100%;
        margin: 24px 0 0;
        padding: 0;
        justify-content: flex-end;
        gap: 8px;
    }

    .swal2-popup .swal2-actions .btn {
        margin: 0;
    }

body .swal2-container.swal2-backdrop-show {
    background: rgba(28, 27, 36, 0.32);
}

/* Snackbar: dark bar at the bottom, no icon */
.swal2-popup.swal2-toast.snackbar {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: var(--radius-xs);
    background: var(--inverse-surface);
    box-shadow: var(--elev-3);
}

    .swal2-popup.swal2-toast.snackbar .swal2-icon {
        display: none !important;
    }

    .swal2-popup.swal2-toast.snackbar .swal2-title {
        margin: 0;
        padding: 0;
        font-size: 14px;
        font-weight: 400;
        color: var(--inverse-on-surface);
    }

/* ==========================================================================
   Question editor: points factor, partial points and countdown (_ScoringFields)
   ========================================================================== */

.scoring-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.scoring-row {
    display: grid;
    grid-template-columns: minmax(0, 220px) 1fr;
    align-items: start;
    gap: 16px;
}

    .scoring-row .field-hint {
        margin-top: 6px;
    }

    .scoring-row .checkbox-wrapper {
        min-height: 48px;
        margin-top: 26px;
    }

.time-limit .form-section-title {
    display: block;
}

@media (max-width: 520px) {
    .scoring-row {
        grid-template-columns: 1fr;
    }

        .scoring-row .checkbox-wrapper {
            min-height: 0;
            margin-top: 0;
        }
}

/* --- Picture of a choice question --- */
.question-image-preview {
    display: block;
    max-width: 100%;
    max-height: 240px;
    margin-top: 12px;
    border-radius: var(--radius-md);
}

.question-image-view {
    display: block;
    max-width: 100%;
    max-height: 360px;
    margin: 0 0 20px;
    border-radius: var(--radius-lg);
}

/* On the phone: tap to see it full screen */
.question-image {
    display: block;
    width: 100%;
    margin: 0 0 20px;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}

    .question-image img {
        display: block;
        max-width: 100%;
        max-height: 38vh;
        margin: 0 auto;
        border-radius: var(--radius-lg);
    }

    .question-image.is-small img {
        max-height: 160px;
    }

    .question-image.is-zoomed {
        position: fixed;
        inset: 0;
        z-index: 200;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 16px;
        background: rgba(0, 0, 0, 0.88);
        cursor: zoom-out;
    }

        .question-image.is-zoomed img {
            max-height: 100%;
            border-radius: var(--radius-md);
        }

/* ==========================================================================
   Countdown of a live question (driven by site.js, [data-countdown])
   ========================================================================== */

/* Phone: a bar that runs down, with the seconds next to it */
.countdown {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -4px 0 20px;
}

.countdown-track {
    flex: 1;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--surface-container);
    overflow: hidden;
}

.countdown-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transform-origin: left center;
    transition: transform 0.12s linear, background-color 0.3s;
}

.countdown-num {
    min-width: 2ch;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--primary);
    transition: color 0.3s;
}

.countdown.is-ending .countdown-fill {
    background: var(--tone-2);
}

.countdown.is-ending .countdown-num {
    color: var(--tone-2);
}

/* Projector: a ring around the seconds */
.countdown-ring {
    position: relative;
    flex: 0 0 auto;
    width: 128px;
    height: 128px;
}

    .countdown-ring svg {
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
    }

    .countdown-ring circle {
        fill: none;
        stroke-width: 10;
    }

    .countdown-ring .ring-bg {
        stroke: var(--surface-container);
    }

    .countdown-ring .ring-fg {
        stroke: var(--primary);
        stroke-linecap: round;
        stroke-dasharray: 100;
        transition: stroke-dashoffset 0.12s linear, stroke 0.3s;
    }

    .countdown-ring .countdown-num {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        font-size: 44px;
        text-align: center;
    }

    .countdown-ring.is-ending .ring-fg {
        stroke: var(--tone-2);
    }

    .countdown-ring.is-ending .countdown-num {
        color: var(--tone-2);
        animation: pulse-scale 1s ease-in-out infinite;
    }

@keyframes pulse-scale {
    50% { transform: scale(1.08); }
}

/* Reading time before the countdown: question and answers are there, the
   countdown and the inputs wait (site.js, [data-reading]) */
.reading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -4px 0 20px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

    .reading .reading-label {
        flex: 1;
        font-weight: 500;
    }

    .reading .reading-num {
        min-width: 2ch;
        font-size: 22px;
        font-weight: 700;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

body.is-reading .countdown,
body.is-reading .countdown-ring {
    display: none;
}

/* Everything that answers waits for the countdown */
body.is-reading [data-locked-while-reading] {
    pointer-events: none;
    opacity: 0.6;
}

/* ==========================================================================
   After a question: result on the phone, streaks and rank changes
   ========================================================================== */

.result-card {
    text-align: center;
    padding: 8px 0 4px;
    animation: popIn 0.35s var(--ease);
}

.result-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: var(--surface-container);
    color: var(--on-surface-variant);
    font-size: 32px;
}

.result-card h2 {
    margin: 0;
    font-size: 30px;
    font-weight: 500;
    line-height: 1.2;
}

.result-points {
    margin: 6px 0 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.result-sub {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--on-surface-variant);
}

.result-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.result-card.is-right .result-icon {
    background: var(--success-container);
    color: var(--success);
}

.result-card.is-partial .result-icon {
    background: var(--tone-3-soft);
    color: #9a6700;
}

.result-card.is-wrong .result-icon {
    background: var(--danger-container);
    color: var(--danger);
}

/* A poll: counted, neither right nor wrong */
.result-card.is-neutral .result-icon {
    background: var(--primary-container);
    color: var(--primary);
}

/* "3 richtig in Folge" */
.streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    background: var(--tone-3-soft);
    color: #7a4b00;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

    .streak-chip i {
        color: #f08c00;
    }

    .streak-chip.is-small {
        height: 22px;
        padding: 0 8px;
        font-size: 12px;
    }

/* Places gained or lost */
.rank-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--on-surface-variant);
}

    .rank-change.is-up {
        color: var(--success);
    }

    .rank-change.is-down {
        color: var(--danger);
    }

.rank-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    background: var(--surface-container);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

/* The solution under the result card */
.solution-block {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--outline-variant);
}

    .solution-block .block-label {
        margin: 0 0 10px;
        font-size: 13px;
        font-weight: 500;
        color: var(--on-surface-variant);
    }

.solution-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--surface-low);
    font-size: 15px;
}

    .solution-line + .solution-line {
        margin-top: 6px;
    }

    .solution-line .mark {
        margin-left: auto;
        font-size: 14px;
    }

    .solution-line.is-right {
        background: var(--success-container);
        color: var(--on-success-container);
    }

/* ==========================================================================
   The question on the big screen (_QuestionStage, _RevealSummary): host view
   and presentation window
   ========================================================================== */

.stage-live {
    padding: 28px;
    border-radius: var(--radius-panel);
    background: var(--surface-bright);
    animation: fadeIn 0.3s var(--ease);
}

.stage-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px 48px;
    margin-bottom: 28px;
}

.stage-fact {
    display: flex;
    flex-direction: column;
}

/* Reading time sits where the countdown ring comes up */
.reading-stage {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    width: 128px;
    height: 128px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    text-align: center;
}

    .reading-stage .reading-num {
        min-width: 0;
        font-size: 44px;
        line-height: 1;
        text-align: center;
    }

    .reading-stage .reading-label {
        flex: 0 0 auto;
        font-size: 13px;
    }

.stage-fact-num {
    font-size: 44px;
    font-weight: 500;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stage-fact-cap {
    font-size: 14px;
    color: var(--text-secondary);
}

.stage-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.stage-option {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 84px;
    padding: 16px 20px;
    border: 2px solid var(--tone);
    border-radius: var(--radius-lg);
    background: var(--tone-soft);
    font-size: 24px;
    font-weight: 500;
    line-height: 1.25;
}

    .stage-option .opt-badge {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        font-size: 20px;
    }

/* Votes as bars behind the options: on the beamer after the round, and while it
   runs once the host puts them up (quiz_status.Show_Votes) */
.stage-options.is-reveal .stage-option,
.stage-options.is-votes .stage-option {
    position: relative;
    overflow: hidden;
}

    .stage-options.is-reveal .stage-option > *,
    .stage-options.is-votes .stage-option > * {
        position: relative;
    }

    .stage-options.is-reveal .stage-option::before,
    .stage-options.is-votes .stage-option::before {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: var(--share, 0%);
        background: var(--tone);
        opacity: 0.22;
        transition: width 0.8s var(--ease);
    }

/* A long word wraps inside the tile instead of pushing the count out of it */
.stage-option-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.stage-option-count {
    display: none;
    flex-shrink: 0;
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stage-options.is-reveal .stage-option-count,
.stage-options.is-votes .stage-option-count {
    display: inline;
}

.stage-hint {
    margin: 0 0 16px;
    font-size: 20px;
    color: var(--text-secondary);
}

.stage-image {
    display: block;
    max-width: 100%;
    max-height: 60vh;
    margin: 0 auto;
    border-radius: var(--radius-lg);
}

.stage-question-image {
    max-height: 42vh;
    margin-bottom: 20px;
}

.stage-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.reveal-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    margin-bottom: 20px;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    animation: popIn 0.35s var(--ease);
}

.reveal-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
}

.reveal-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 16px;
}

    .reveal-facts i {
        color: var(--tone-3);
    }

/* ==========================================================================
   Lobby (_LobbyBoard): code, QR code and who is in
   ========================================================================== */

.lobby {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lobby-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.lobby-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .lobby-actions form {
        margin: 0;
    }

.lobby-join {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 32px 56px;
    padding: 36px 32px;
    border-radius: var(--radius-xl);
    background: var(--surface-bright);
    animation: popIn 0.4s var(--ease);
}

.lobby-qr {
    width: min(300px, 70vw);
    aspect-ratio: 1;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--elev-2);
}

    .lobby-qr img {
        display: block;
        width: 100%;
        height: 100%;
    }

.lobby-how p {
    margin: 0;
}

.lobby-step {
    font-size: 20px;
    color: var(--text-secondary);
}

.lobby-url {
    margin-bottom: 20px !important;
    font-size: clamp(26px, 3.4vw, 40px);
    font-weight: 500;
}

.lobby-code {
    font-size: clamp(56px, 8vw, 104px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.06em;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
}

.lobby-locked {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 500;
    color: var(--on-surface-variant);
}

.lobby-players {
    padding: 24px 28px 28px;
    border-radius: var(--radius-xl);
    background: var(--surface-bright);
}

    .lobby-players h2 {
        display: flex;
        align-items: baseline;
        gap: 10px;
        margin: 0 0 16px;
        font-size: 22px;
        font-weight: 500;
    }

.lobby-count {
    font-size: 40px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.lobby-names {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.lobby-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 18px 0 6px;
    border-radius: var(--radius-full);
    background: var(--surface-container);
    font-size: 18px;
    font-weight: 500;
    animation: popIn 0.35s var(--ease);
}

    .lobby-name .avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

.lobby-empty {
    margin: 0;
    font-size: 16px;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .lobby {
        padding: 12px 16px 24px;
    }

    .lobby-join {
        padding: 24px 16px;
    }
}

/* ==========================================================================
   Final leaderboard (_Podium) and confetti (site.js confettiBurst)
   ========================================================================== */

/* --- Podium: third, second, first come up one after the other --- */
.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    margin: 0 0 28px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(190px, 31%);
}

.podium-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    opacity: 0;
    animation: podium-in 0.5s var(--ease) var(--delay) forwards;
}

    .podium-player .avatar {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

.place-1 .podium-player .avatar {
    width: 72px;
    height: 72px;
    font-size: 30px;
}

.podium-crown {
    color: var(--gold);
    font-size: 28px;
}

.podium-name {
    max-width: 100%;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    overflow-wrap: anywhere;
}

.podium-score {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.podium-step {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: 12px;
    border-radius: 16px 16px 0 0;
    color: #fff;
    font-size: 34px;
    font-weight: 700;
    transform: scaleY(0);
    transform-origin: bottom;
    animation: podium-rise 0.6s var(--ease) calc(var(--delay) - 0.3s) forwards;
}

.place-1 .podium-step { height: 150px; background: var(--gold); }
.place-2 .podium-step { height: 110px; background: var(--silver); }
.place-3 .podium-step { height: 80px; background: var(--bronze); }

.podium-place.is-me .podium-name {
    color: var(--primary);
}

@keyframes podium-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes podium-rise {
    to { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
    .podium-player,
    .podium-step {
        animation-delay: 0s !important;
    }
}

.lb-me {
    margin: -8px 0 20px;
    text-align: center;
    font-size: 16px;
}

.lb-list-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* A short burst of confetti once the winner is up */
.confetti {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 50;
}

    .confetti span {
        position: absolute;
        top: -20px;
        border-radius: 2px;
        animation: confetti-fall var(--dur) cubic-bezier(0.25, 0.4, 0.5, 1) var(--delay) forwards;
    }

@keyframes confetti-fall {
    to {
        transform: translate(var(--drift), 110vh) rotate(var(--spin));
    }
}
