/* ============================================================================
 * TriviArena — Play (free training) page
 * Brand: dark, Cinzel (display) + Outfit (UI), warm amber accent
 * Vanilla CSS, no preprocessor. Mirrors the spectate.css aesthetic.
 * ========================================================================== */

:root {
    --bg-1: #0D0705;
    --bg-2: #1A0F0A;
    --surface: #1F1410;
    --surface-2: #2A1B14;
    --line: rgba(255, 220, 180, 0.12);
    --line-strong: rgba(255, 220, 180, 0.25);
    --ink: #F5EBDF;
    --ink-dim: #C7B9A8;
    --ink-mute: #8C7E6C;
    --accent: #F4B860;       /* warm amber */
    --accent-2: #E89148;
    --correct: #6FCF8A;
    --wrong: #E36A6A;
    --shadow-1: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 32px rgba(0, 0, 0, 0.55);
    --radius-md: 12px;
    --radius-lg: 18px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg-1) 70%);
    color: var(--ink);
    font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    overflow-x: hidden;
}

body { min-height: 100dvh; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

.screen {
    width: 100%;
    min-height: 100dvh;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* `.screen` sets `display: flex`, which overrides the browser's default
 * `[hidden] { display: none }`. Re-assert it with a higher-specificity rule so
 * the screen-switching logic in play.js actually toggles visibility. */
.screen[hidden] { display: none; }

/* ========================== INTRO ========================== */

.intro-card {
    max-width: 460px;
    width: 100%;
    padding: 32px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-2);
}

.intro-logo {
    width: 96px;
    height: 96px;
    border-radius: 22px;
    margin: 0 auto 16px;
    display: block;
    box-shadow: var(--shadow-1);
}

.intro-title {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 30px;
    letter-spacing: 0.5px;
    margin: 8px 0 4px;
}

.intro-sub {
    color: var(--ink-dim);
    margin: 0 0 24px;
}

.intro-options {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 24px;
    text-align: left;
}

.opt-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.opt-select {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: inherit;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
                      linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
    background-position: calc(100% - 18px) center, calc(100% - 13px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.opt-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.play-button {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #2B1808;
    border-radius: var(--radius-md);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.4px;
    box-shadow: 0 4px 18px rgba(244, 184, 96, 0.35);
    transition: transform 80ms ease, box-shadow 200ms ease;
}

.play-button:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(244, 184, 96, 0.5); }
.play-button:active { transform: translateY(0); }

.best-score-line {
    margin: 14px 0 0;
    font-size: 14px;
    color: var(--ink-dim);
}
.best-score-line span { color: var(--accent); font-weight: 600; }

.intro-footer {
    margin-top: 28px;
    text-align: center;
    color: var(--ink-mute);
    font-size: 14px;
}
.intro-footer p { margin: 0 0 6px; }

.store-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.store-link:hover { color: var(--accent-2); }

/* ========================== GAME ========================== */

.game-screen {
    justify-content: flex-start;
    padding: 12px 12px 20px;
    gap: 16px;
}

.game-top {
    width: 100%;
    max-width: 600px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
}

.round-chip,
.score-chip {
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 14px;
    color: var(--ink-dim);
    white-space: nowrap;
}
.round-chip { justify-self: start; }
.score-chip { justify-self: end; }
.round-chip span,
.score-chip span { color: var(--ink); font-weight: 600; }

.timer-ring {
    position: relative;
    width: 56px;
    height: 56px;
    justify-self: center;
}
.timer-ring svg {
    width: 100%; height: 100%;
    transform: rotate(-90deg);
}
.timer-track {
    fill: none;
    stroke: var(--line-strong);
    stroke-width: 3;
}
.timer-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 100.5; /* 2π × 16 ≈ 100.53 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 250ms linear, stroke 300ms ease;
}
.timer-progress.low { stroke: var(--wrong); }
.timer-ring span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
}

.question-stage {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-1);
    text-align: center;
}

.question-category {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    background: rgba(244, 184, 96, 0.1);
    padding: 4px 10px;
    border-radius: 999px;
}

.question-text {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    line-height: 1.35;
}

.correct-pct-line {
    margin: 12px 0 0;
    color: var(--ink-mute);
    font-size: 13px;
}

.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.answer-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    min-height: 76px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    text-align: left;
    color: var(--ink);
    font-size: 16px;
    line-height: 1.3;
    transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.answer-btn:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--line-strong);
}
.answer-btn:active:not(:disabled) { transform: scale(0.99); }
.answer-btn:disabled { cursor: default; }

.answer-letter {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border-radius: 8px;
    font-weight: 700;
    color: var(--accent);
    font-size: 14px;
}

.answer-text { flex: 1; }

.answer-btn.is-correct {
    background: rgba(111, 207, 138, 0.18);
    border-color: var(--correct);
    color: var(--ink);
}
.answer-btn.is-correct .answer-letter { background: var(--correct); color: #0D2412; }

.answer-btn.is-wrong {
    background: rgba(227, 106, 106, 0.18);
    border-color: var(--wrong);
}
.answer-btn.is-wrong .answer-letter { background: var(--wrong); color: #2A0808; }

.answer-btn.faded { opacity: 0.45; }

/* ========================== RESULT ========================== */

.result-card {
    max-width: 460px;
    width: 100%;
    padding: 32px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-2);
}
.result-title {
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 26px;
    margin: 0 0 12px;
}
.result-score {
    font-family: 'Cinzel', serif;
    font-size: 56px;
    font-weight: 900;
    color: var(--accent);
    margin: 8px 0;
    line-height: 1;
}
.result-score-of {
    color: var(--ink-dim);
    font-size: 28px;
    font-weight: 500;
}
.result-sub {
    color: var(--ink-dim);
    margin: 0 0 16px;
}
.result-new-best {
    color: var(--accent);
    font-weight: 600;
    margin: 0 0 16px;
}
.result-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 8px;
}
.result-actions .store-link {
    padding: 14px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    display: block;
}

.share-button {
    width: 100%;
    padding: 14px 24px;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.share-button:hover { background: var(--surface); border-color: var(--accent); }
.share-button:active { transform: translateY(1px); }
.share-icon {
    display: inline-block;
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    transform: translateY(-1px);
}

.share-toast {
    margin: 4px 0 0;
    padding: 8px 12px;
    background: rgba(111, 207, 138, 0.15);
    border: 1px solid var(--correct);
    border-radius: var(--radius-md);
    color: var(--correct);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* ========================== LEADERBOARD ========================== */

.leaderboard-panel {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    text-align: left;
}

.leaderboard-title {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 10px;
    text-align: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.leaderboard-list {
    list-style: none;
    counter-reset: lb;
    margin: 0;
    padding: 0;
}

.leaderboard-row {
    counter-increment: lb;
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 14px;
}

.leaderboard-row::before {
    content: counter(lb);
    color: var(--ink-mute);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.leaderboard-row:nth-child(1)::before { color: #F4D060; font-weight: 700; }
.leaderboard-row:nth-child(2)::before { color: #D9D9D9; font-weight: 700; }
.leaderboard-row:nth-child(3)::before { color: #C28E5C; font-weight: 700; }

.leaderboard-row.is-me {
    background: rgba(244, 184, 96, 0.12);
    border: 1px solid rgba(244, 184, 96, 0.25);
}

.leaderboard-name {
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.leaderboard-myrank {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--ink-mute);
    text-align: center;
}

/* ========================== SUBMIT FORM ========================== */

.submit-form {
    margin: 20px 0 8px;
    text-align: left;
}

.submit-label {
    display: block;
    font-size: 13px;
    color: var(--ink-dim);
    margin-bottom: 8px;
    text-align: center;
}

.submit-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.submit-input {
    flex: 1;
    min-width: 0;       /* allow shrinking on narrow viewports */
    padding: 12px 14px;
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    font-size: 16px;    /* 16px prevents iOS zoom on focus */
    font-family: inherit;
}
.submit-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.submit-button {
    flex: 0 0 auto;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #2B1808;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    min-height: 46px;
}
.submit-button:disabled { opacity: 0.5; cursor: default; }

.submit-error {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--wrong);
    text-align: center;
}

/* ========================== IN-QUIZ LANG SWITCHER ============== */

.ingame-langswitch {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: -6px;
}

.ingame-langswitch__label {
    font-size: 16px;
    opacity: 0.7;
    cursor: pointer;
}

.ingame-langswitch__select {
    appearance: none;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 26px 6px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
                      linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
    background-position: calc(100% - 14px) center, calc(100% - 9px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    min-height: 36px;       /* mobile tap target */
}
.ingame-langswitch__select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ========================== ERROR ========================== */

.error-card {
    max-width: 420px;
    padding: 32px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    text-align: center;
}
.error-card h2 {
    font-family: 'Cinzel', serif;
    margin: 0 0 8px;
}
.error-card p { color: var(--ink-dim); margin: 0 0 20px; }

/* ========================== RESPONSIVE ========================== */

@media (min-width: 720px) {
    .question-text { font-size: 24px; }
    .answer-btn { font-size: 17px; min-height: 84px; }
    .game-top { gap: 20px; }
}

/* Devvit embed mode: hide CTAs that point at the app store, since Reddit
 * policy is sensitive about external links being too prominent. */
body.embed-devvit .intro-footer,
body.embed-devvit .result-actions .store-link { display: none; }
