/* ============================================================
   QUIZHUB — Paper & Ink
   ----------------------------------------------------------
   Three colors with intent:
     paper  — the page itself
     ink    — every line, every letter
     red    — only what demands attention (CTA, live, you)
   Spacing scale: 4 / 8 / 16 / 24 / 32 / 48 / 64 / 96
   ============================================================ */

:root {
    --paper: #FBF7F0;
    --paper-2: #F4EFE4;
    --ink: #1A1714;
    --ink-70: rgba(26, 23, 20, 0.7);
    --ink-55: rgba(26, 23, 20, 0.55);
    --ink-30: rgba(26, 23, 20, 0.3);
    --hairline: rgba(26, 23, 20, 0.12);
    --red: #D94B3A;
    --red-wash: #FBE6E2;
    --olive: #5C6B3B;

    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --t: 200ms;
}

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

html, body { background: var(--paper); }

body {
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

.d-none { display: none !important; }

::selection { background: var(--ink); color: var(--paper); }

/* ============================================================
   TOP PROGRESS — full-bleed, only visible during quiz
   ============================================================ */
.top-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: var(--hairline);
    z-index: 50;
    overflow: hidden;
    transition: height 200ms var(--ease);
}
body.quiz-active .top-progress { height: 10px; }

.top-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--ink);
    transition: width 500ms var(--ease);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.wrapper {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 48px 96px;
    min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 96px;
}

.logo {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.logo span {
    color: var(--ink-55);
    font-weight: 700;
}

.connection-dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-30);
    transition: background var(--t) var(--ease);
}
.connection-dot.connected { background: var(--olive); }
.connection-dot::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
}

/* ============================================================
   SCREENS — gentle opacity fade, no transform fanfare
   ============================================================ */
.screen { animation: fade 280ms var(--ease) both; }
@keyframes fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   ATOMS — eyebrow label, hairline rule
   ============================================================ */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-55);
}
.eyebrow::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 1px;
    background: var(--ink-30);
}
.eyebrow--live { color: var(--red); }
.eyebrow--live::before { background: var(--red); }
.eyebrow--live .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red);
    animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ============================================================
   START SCREEN — left-aligned, asymmetric
   Arena grid drifts in from top-right corner
   ============================================================ */
.screen--start {
    max-width: 640px;
    position: relative;
}
.screen--start::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -240px;
    width: 820px;
    height: 620px;
    background-image:
        repeating-linear-gradient(0deg, var(--hairline) 0 1px, transparent 1px 44px),
        repeating-linear-gradient(90deg, var(--hairline) 0 1px, transparent 1px 44px);
    -webkit-mask-image: radial-gradient(ellipse 60% 50% at 75% 30%, #000 0%, transparent 70%);
            mask-image: radial-gradient(ellipse 60% 50% at 75% 30%, #000 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: arenaDrift 14s linear infinite;
}
@keyframes arenaDrift {
    from { transform: translate(0, 0); }
    to   { transform: translate(-44px, -44px); }
}
.screen--start > * { position: relative; z-index: 1; }

.start-eyebrow { margin-bottom: 32px; }

.start-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 8vw, 84px);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    margin-bottom: 24px;
}

.start-sub {
    font-size: 18px;
    line-height: 1.5;
    color: var(--ink-70);
    margin-bottom: 48px;
    max-width: 440px;
}

.input-wrap {
    margin-bottom: 32px;
    max-width: 420px;
}

.nick-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--ink-30);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 500;
    padding: 12px 0;
    outline: none;
    transition: border-color var(--t) var(--ease), padding var(--t) var(--ease);
}
.nick-input::placeholder { color: var(--ink-30); }
.nick-input:focus {
    border-bottom-color: var(--ink);
    border-bottom-width: 2px;
    padding-bottom: 11px;
}
.nick-input.shake { animation: shake 360ms var(--ease); border-bottom-color: var(--red); }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

/* ============================================================
   BUTTON — the only loud element on the page
   "Real button" effect: hard offset that collapses on press
   ============================================================ */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--red);
    color: var(--paper);
    border: 2px solid var(--ink);
    border-radius: 0;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 14px 24px;
    cursor: pointer;
    box-shadow: 4px 4px 0 0 var(--ink);
    transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 var(--ink);
}
.btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 0 var(--ink);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 4px 4px 0 0 var(--ink);
}
.btn svg { stroke-width: 2; }

.btn--ghost {
    background: transparent;
    color: var(--ink);
    box-shadow: 4px 4px 0 0 var(--ink);
}

/* ============================================================
   QUIZ SCREEN — content takes the page; leaderboard a rail
   ============================================================ */
.quiz-layout {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 80px;
    align-items: start;
}

/* Meta row above timer — just the question counter */
.quiz-meta {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.progress-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-55);
    white-space: nowrap;
}
.progress-label strong {
    color: var(--ink);
    font-weight: 700;
}

/* ============================================================
   TIMER — the dominant element on the question page
   ============================================================ */
.timer-wrap {
    margin-bottom: 40px;
}

.timer-number {
    display: block;
    font-family: var(--font-body);
    font-size: clamp(40px, 6vw, 56px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    margin-bottom: 10px;
    transition: color 150ms var(--ease);
}
.timer-number.urgent {
    color: var(--red);
    animation: timerPulse 1s var(--ease) infinite;
}
@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

.timer-track {
    height: 8px;
    background: var(--hairline);
    position: relative;
    overflow: hidden;
}

.timer-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
    background: var(--ink);
    transition: width 1s linear, background 150ms var(--ease);
}
.timer-fill.urgent { background: var(--red); }

/* Question — big, bare, no card */
.question-container {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    max-width: 640px;
}

.question-text {
    font-family: var(--font-display);
    font-size: clamp(26px, 3.2vw, 32px);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.015em;
    margin-bottom: 32px;
}

.answers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
}

/* Answer rows — full-width bordered buttons */
.answer-label {
    display: grid;
    grid-template-columns: 36px 1fr;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    border: 2px solid var(--hairline);
    background: var(--paper);
    transition: transform 150ms var(--ease),
                border-color 150ms var(--ease),
                background 150ms var(--ease),
                color 150ms var(--ease);
}
.answer-label:hover {
    transform: translateX(-4px);
    border-color: var(--ink);
    background: var(--paper-2);
}
.answer-label:hover .answer-letter { color: var(--ink); }

.answer-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.answer-letter {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--ink-30);
    transition: color 150ms var(--ease);
}

.answer-text {
    font-size: 17px;
    font-weight: 500;
    line-height: 1.4;
}

/* Selected state — locked-in red fill */
.answer-label:has(input:checked) {
    transform: translateX(-4px);
    background: var(--red);
    border-color: var(--ink);
    color: var(--paper);
    box-shadow: 4px 4px 0 0 var(--ink);
}
.answer-label:has(input:checked) .answer-letter {
    color: rgba(255, 255, 255, 0.65);
}

/* Locked answers-list — disable hover on unselected rows after submit */
.answers-list.locked .answer-label {
    cursor: default;
}
.answers-list.locked .answer-label:not(:has(input:checked)):hover {
    transform: none;
    border-color: var(--hairline);
    background: var(--paper);
}
.answers-list.locked .answer-label:not(:has(input:checked)):hover .answer-letter {
    color: var(--ink-30);
}

/* Reveal flashes — applied after server response */
.answer-label.reveal-correct {
    background: #2D6A4F !important;
    border-color: var(--ink) !important;
    color: var(--paper) !important;
    box-shadow: 4px 4px 0 0 var(--ink) !important;
}
.answer-label.reveal-correct .answer-letter { color: rgba(255, 255, 255, 0.65) !important; }
.answer-label.reveal-wrong {
    background: var(--red) !important;
    border-color: var(--ink) !important;
    color: var(--paper) !important;
    box-shadow: 4px 4px 0 0 var(--ink) !important;
}
.answer-label.reveal-wrong .answer-letter { color: rgba(255, 255, 255, 0.65) !important; }

.btn-submit { margin-top: 8px; }

/* ============================================================
   LEADERBOARD — no card chrome, just a rail
   ============================================================ */
.leaderboard-panel {
    position: sticky;
    top: 32px;
    padding-top: 0;
}

.lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 8px;
}

.lb-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink);
}

.lb-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--red);
}
.lb-live::before {
    content: '';
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 0 var(--red);
    animation: livePulse 1.6s ease-out infinite;
}
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(217, 75, 58, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(217, 75, 58, 0); }
    100% { box-shadow: 0 0 0 0 rgba(217, 75, 58, 0); }
}

.lb-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    position: relative;
}

.lb-item {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--hairline);
    position: relative;
    will-change: transform;
}
.lb-item:last-child { border-bottom: none; }
.lb-item.flip-animating {
    transition: transform 360ms var(--ease);
}
.lb-item.is-new {
    animation: slideIn 260ms var(--ease) both;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lb-rank {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 800;
    color: var(--ink-55);
}
.lb-item:nth-child(1) .lb-rank { color: var(--ink); }

.lb-info { min-width: 0; }

.lb-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-progress {
    font-size: 11px;
    color: var(--ink-55);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.lb-score-wrap {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    position: relative;
}

.lb-score {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.lb-delta {
    position: absolute;
    right: 0;
    top: -14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--olive);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}
.lb-delta.show {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.lb-delta.fade {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}

.lb-item.is-me .lb-name {
    color: var(--red);
}
.lb-item.is-me .lb-name::after {
    content: ' \2190 you';
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--red);
    margin-left: 6px;
}

/* ============================================================
   RESULT — score takes the page
   ============================================================ */
.screen--result {
    max-width: 640px;
}

.result-eyebrow { margin-bottom: 48px; }

.result-title {
    font-family: var(--font-display);
    font-size: clamp(40px, 6vw, 64px);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    margin-bottom: 56px;
}

.result-score-wrap {
    display: flex;
    align-items: baseline;
    gap: 20px;
    margin-bottom: 8px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--hairline);
}

.result-score {
    font-family: var(--font-display);
    font-size: clamp(96px, 16vw, 168px);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.04em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.result-score-of {
    font-family: var(--font-display);
    font-size: clamp(24px, 4vw, 36px);
    font-weight: 600;
    color: var(--ink-55);
    letter-spacing: -0.02em;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 24px;
    margin-bottom: 56px;
    font-size: 13px;
    color: var(--ink-55);
}
.result-meta strong {
    color: var(--ink);
    font-weight: 600;
}

/* Subtle emoji as a decorative mark, not a centered hero */
.result-mark {
    display: inline-block;
    font-size: 28px;
    margin-bottom: 24px;
    animation: nudge 600ms var(--ease) both;
}
@keyframes nudge {
    0%   { opacity: 0; transform: translateY(-6px) rotate(-8deg); }
    100% { opacity: 1; transform: translateY(0) rotate(0); }
}

/* ============================================================
   FEEDBACK TOAST — slides up from bottom-left
   ============================================================ */
.feedback-toast {
    position: fixed;
    bottom: 32px;
    left: 48px;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    border-radius: 0;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 4px 4px 0 0 var(--ink);
    z-index: 100;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 260ms var(--ease), opacity 260ms var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.feedback-toast.show {
    transform: translateY(0);
    opacity: 1;
}
.feedback-toast .mark {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
}
.feedback-toast.correct .mark { color: var(--olive); }
.feedback-toast.wrong   .mark { color: var(--red); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
    .wrapper { padding: 24px 24px 64px; }
    .header { padding-bottom: 64px; }
    .quiz-layout {
        grid-template-columns: 1fr;
        gap: 48px;
    }
    .leaderboard-panel {
        position: static;
        order: 2;
    }
    .question-text { margin-bottom: 32px; }
    .timer-wrap { margin-bottom: 32px; }
    .screen--start::before { right: -200px; }
}

@media (max-width: 520px) {
    .wrapper { padding: 20px 20px 56px; }
    .header { padding-bottom: 48px; }
    .feedback-toast { left: 20px; right: 20px; bottom: 20px; }
    .answer-label {
        grid-template-columns: 28px 1fr;
        gap: 12px;
        padding: 14px 16px;
    }
    .answer-text { font-size: 16px; }
    .timer-number { font-size: clamp(36px, 10vw, 44px); }
    .timer-track { height: 6px; }
    body.quiz-active .top-progress { height: 8px; }
    .screen--start::before {
        top: -80px;
        right: -160px;
        width: 480px;
        height: 400px;
        background-size: 32px 32px;
    }
}

/* ============================================================
   AUTH PAGE — reuses start-screen language
   ============================================================ */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--ink-55);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.logout-btn:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}

.auth-screen { max-width: 460px; }

.auth-tabs {
    display: inline-flex;
    gap: 28px;
    margin: 16px 0 40px;
}

.auth-tab {
    background: transparent;
    border: none;
    color: var(--ink-30);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    padding: 0 0 6px;
    border-bottom: 2px solid transparent;
    transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.auth-tab:hover { color: var(--ink-70); }
.auth-tab.is-active {
    color: var(--ink);
    border-bottom-color: var(--red);
}

.auth-title {
    font-size: clamp(36px, 6vw, 56px);
    margin-bottom: 40px;
}

.auth-form .input-wrap { max-width: 100%; }

.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 8px 0 36px;
    cursor: pointer;
    user-select: none;
}
.auth-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.auth-checkbox-box {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    border: 2px solid var(--ink);
    background: var(--paper);
    position: relative;
    transition: background var(--t) var(--ease);
}
.auth-checkbox input:checked + .auth-checkbox-box {
    background: var(--red);
}
.auth-checkbox input:checked + .auth-checkbox-box::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 1px;
    width: 6px;
    height: 12px;
    border: solid var(--paper);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.auth-checkbox input:focus-visible + .auth-checkbox-box {
    outline: 2px solid var(--red);
    outline-offset: 2px;
}
.auth-checkbox-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
}
.auth-checkbox-text small {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-55);
    margin-top: 2px;
}

.auth-error {
    margin-top: 24px;
    padding: 12px 16px;
    background: var(--red-wash);
    border-left: 3px solid var(--red);
    color: var(--red);
    font-size: 14px;
    font-weight: 500;
    max-width: 420px;
}

/* ============================================================
   SHARED — small button, back link, user tag
   ============================================================ */
.btn--sm {
    padding: 10px 18px;
    font-size: 13px;
    box-shadow: 3px 3px 0 0 var(--ink);
}
.btn--sm:hover { box-shadow: 5px 5px 0 0 var(--ink); }

.link-back {
    color: var(--ink-55);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.link-back:hover { color: var(--ink); border-bottom-color: var(--ink); }

.user-tag {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink-70);
}

/* ============================================================
   LOBBY — rooms grid + leaderboard rail
   ============================================================ */
.lobby-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 64px;
    align-items: start;
}

.lobby-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
}

.lobby-title {
    font-family: var(--font-display);
    font-size: clamp(40px, 6vw, 64px);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    margin-top: 16px;
}

.lobby-state {
    color: var(--ink-55);
    font-size: 15px;
    padding: 24px 0;
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.room-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    background: var(--paper-2);
    border: 2px solid var(--ink);
    box-shadow: 4px 4px 0 0 var(--ink);
    text-decoration: none;
    color: var(--ink);
    transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.room-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 0 var(--ink);
}

.room-card-top { display: flex; flex-wrap: wrap; gap: 8px; }

.room-card-pill {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 8px;
    background: var(--ink);
    color: var(--paper);
}
.room-card-pill--ghost {
    background: transparent;
    color: var(--ink-70);
    border: 1px solid var(--ink-30);
}

.room-card-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.room-card-desc {
    font-size: 14px;
    color: var(--ink-70);
    line-height: 1.4;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.room-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--hairline);
}
.room-card-quiz { font-size: 12px; font-weight: 600; color: var(--ink-55); }
.room-card-go { font-size: 12px; font-weight: 700; color: var(--red); }

.quiz-delete {
    background: transparent;
    border: none;
    color: var(--ink-55);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    transition: color var(--t) var(--ease);
}
.quiz-delete:hover { color: var(--red); }

.lobby-lb { position: sticky; top: 32px; }
.lb-note {
    margin-top: 16px;
    font-size: 12px;
    color: var(--ink-30);
    font-style: italic;
}

/* ============================================================
   FORM — create room (admin)
   ============================================================ */
.form-screen { max-width: 560px; }
.form-title { font-size: clamp(40px, 6vw, 60px); margin-bottom: 40px; }

.room-form { display: flex; flex-direction: column; gap: 28px; }

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

.field-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-55);
}
.field-label--sub { margin-top: 12px; }
.field-label strong { color: var(--red); font-variant-numeric: tabular-nums; }

.field-hint {
    font-size: 13px;
    color: var(--ink-55);
    line-height: 1.4;
}

.textarea { resize: vertical; line-height: 1.4; }

select.nick-input { cursor: pointer; }

/* Segmented switch: existing vs new quiz */
.seg {
    display: inline-flex;
    border: 2px solid var(--ink);
    width: fit-content;
}
.seg-btn {
    background: transparent;
    border: none;
    color: var(--ink-55);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.seg-btn + .seg-btn { border-left: 2px solid var(--ink); }
.seg-btn.is-active { background: var(--ink); color: var(--paper); }

/* Toggle switch */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
    position: absolute;
    inset: 0;
    border: 2px solid var(--ink);
    background: var(--paper);
    transition: background var(--t) var(--ease);
}
.switch-track::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 18px;
    height: 18px;
    background: var(--ink);
    transition: transform var(--t) var(--ease);
}
.switch input:checked + .switch-track { background: var(--red); }
.switch input:checked + .switch-track::before {
    transform: translateX(20px);
    background: var(--paper);
}

/* Range slider */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 420px;
    height: 4px;
    background: var(--ink-30);
    outline: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--red);
    border: 2px solid var(--ink);
    cursor: pointer;
}
.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--red);
    border: 2px solid var(--ink);
    cursor: pointer;
}

/* Question picker */
.question-picker {
    display: flex;
    flex-direction: column;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--ink-30);
}
.pick-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--hairline);
    cursor: pointer;
}
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: var(--paper-2); }
.pick-cb { width: 16px; height: 16px; accent-color: var(--red); }
.pick-text { font-size: 14px; }

/* ============================================================
   ROOM DETAIL
   ============================================================ */
.room-screen { max-width: 640px; }
.room-name { font-size: clamp(40px, 6vw, 64px); }
.room-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0 40px;
}
.room-lb { position: static; margin-top: 48px; max-width: 420px; }

/* ============================================================
   CREATE QUIZ — sections, question blocks, answer rows
   ============================================================ */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--hairline);
}
.form-section:last-of-type { border-bottom: none; }

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.timer-preview {
    color: var(--olive);
    font-weight: 600;
}

/* Question block */
.q-block {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    background: var(--paper-2);
    border: 2px solid var(--ink);
}

.q-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.q-block-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-55);
}
.q-remove {
    background: transparent;
    border: none;
    color: var(--ink-55);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    transition: color var(--t) var(--ease);
}
.q-remove:hover { color: var(--red); }

/* Answers editor */
.answers-edit {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.answer-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.answer-correct {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--red);
    cursor: pointer;
}
.answer-text { flex: 1; font-size: 16px; }
.answer-remove {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--ink-30);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    transition: color var(--t) var(--ease);
}
.answer-remove:hover { color: var(--red); }

/* Add buttons */
.add-btn {
    align-self: flex-start;
    cursor: pointer;
}
.add-answer-btn {
    background: transparent;
    border: none;
    color: var(--red);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    padding: 2px 0;
}
.add-answer-btn:hover { text-decoration: underline; }

/* Success banner (mirrors .auth-error styling) */
.form-success {
    margin-top: 4px;
    padding: 12px 16px;
    background: rgba(92, 107, 59, 0.12);
    border-left: 3px solid var(--olive);
    color: var(--olive);
    font-size: 14px;
    font-weight: 600;
    max-width: 420px;
}

@media (max-width: 860px) {
    .lobby-grid { grid-template-columns: 1fr; }
    .lobby-lb { position: static; }
}

/* ============================================================
   PLAYER PROFILE TOOLTIP (leaderboard hover)
   ============================================================ */
.lb-player {
    position: relative;
    display: inline-block;
    max-width: 100%;
    cursor: default;
    outline: none;
}
.lb-player .lb-name {
    border-bottom: 1px dotted var(--ink-30);
}

.player-tooltip {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    z-index: 40;
    display: block;
    width: 240px;
    padding: 14px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 12px;
    box-shadow: 6px 6px 0 0 rgba(26, 23, 20, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 150ms var(--ease), transform 150ms var(--ease), visibility 150ms var(--ease);
    pointer-events: none;
    white-space: normal;
}
.lb-player:hover .player-tooltip,
.lb-player:focus .player-tooltip,
.lb-player:focus-within .player-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.player-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 22px;
    border: 7px solid transparent;
    border-top-color: var(--ink);
}

.pt-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.pt-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pt-level {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--red);
    padding: 3px 7px;
    border-radius: 20px;
    flex-shrink: 0;
}
.pt-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 11px;
    color: rgba(251, 247, 240, 0.7);
}
.pt-stat b {
    display: block;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 800;
    color: var(--paper);
    font-variant-numeric: tabular-nums;
}
.pt-badges {
    list-style: none;
    margin: 0;
    padding: 10px 0 0;
    border-top: 1px solid rgba(251, 247, 240, 0.15);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pt-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.pt-badge-icon { font-size: 15px; }
.pt-badge--empty {
    color: rgba(251, 247, 240, 0.5);
    font-style: italic;
}

/* ============================================================
   RESULT SCREEN — points, badges, room leaderboard
   ============================================================ */
.result-points {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: var(--olive);
    margin-top: 6px;
}
.result-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.result-badges-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-55);
    width: 100%;
}
.result-badge {
    font-size: 13px;
    font-weight: 600;
    background: var(--paper-2);
    border: 1px solid var(--hairline);
    border-radius: 20px;
    padding: 6px 12px;
}
.room-lb-wrap {
    width: 100%;
    max-width: 420px;
    margin-top: 28px;
    text-align: left;
}
.room-lb-wrap .lb-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}
