:root {
    --ink: #18311d;
    --ink-soft: rgba(24, 49, 29, 0.78);
    --cream: #fff7e8;
    --card: rgba(255, 250, 240, 0.93);
    --line: rgba(24, 49, 29, 0.12);
    --green: #5f8128;
    --green-deep: #284b2d;
    --orange: #e8a03f;
    --shadow: 0 22px 60px rgba(15, 35, 17, 0.18);
    --correct: #2d7a2d;
    --wrong: #b83232;
    --timer-full: #5f8128;
    --timer-low: #c94f1a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(232, 160, 63, 0.35), transparent 26%),
        radial-gradient(circle at top right, rgba(95, 129, 40, 0.28), transparent 22%),
        linear-gradient(180deg, #16361f 0%, #2f6a3d 23%, #dce6bf 58%, #f5e8ce 100%);
}

a { color: inherit; }

.game-page {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 2rem;
}

.game-panel,
.card,
.overlay-card {
    background: var(--card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.control-button,
.primary-button { border-radius: 999px; }

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.game-panel {
    border-radius: 1.8rem;
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    flex-wrap: wrap;
}

.title-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.eyebrow {
    margin: 0;
    color: #75510a;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
    font-weight: 700;
}

h1, h2 { font-family: Georgia, "Times New Roman", serif; }

h1 {
    margin: 0.25rem 0 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 0.98;
}

.lead {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.6;
    font-size: 1rem;
}

/* HUD */
.hud {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(95, 129, 40, 0.12);
    border-radius: 0.75rem;
    padding: 0.5rem 1rem;
    min-width: 5rem;
    flex: 1;
}

.hud-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    font-weight: 600;
}

.hud-item strong {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--green-deep);
}

/* Quiz shell */
.quiz-shell {
    position: relative;
    border-radius: 1.2rem;
    overflow: hidden;
    background: rgba(255, 252, 244, 0.6);
    border: 1px solid var(--line);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Timer bar */
.timer-bar-bg {
    height: 8px;
    background: rgba(24, 49, 29, 0.1);
    border-radius: 4px 4px 0 0;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: var(--timer-full);
    transition: width 0.25s linear, background-color 0.5s ease;
    border-radius: 4px;
}

.timer-bar.low { background: var(--timer-low); }

/* Overlay */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 54, 31, 0.55);
    backdrop-filter: blur(6px);
    border-radius: inherit;
    z-index: 10;
    padding: 1rem;
}

.overlay.hidden { display: none; }

.overlay-card {
    border-radius: 1.2rem;
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.overlay-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.overlay-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.overlay-brand-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.overlay-kicker {
    margin: 0;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--orange);
    font-weight: 700;
}

.overlay-card h2 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
}

.overlay-card p {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.6;
    font-size: 0.96rem;
}

.overlay-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

/* Question area */
.question-area {
    flex: 1;
    padding: 1.25rem 1.4rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-number {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
}

.question-text {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(1.05rem, 2.5vw, 1.35rem);
    line-height: 1.4;
    font-weight: 600;
    color: var(--green-deep);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.option-btn {
    background: rgba(255, 250, 240, 0.9);
    border: 2px solid var(--line);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.96rem;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    line-height: 1.35;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--green);
    background: rgba(95, 129, 40, 0.1);
    transform: translateY(-1px);
}

.option-btn.correct {
    background: rgba(45, 122, 45, 0.15);
    border-color: var(--correct);
    color: var(--correct);
    font-weight: 700;
}

.option-btn.wrong {
    background: rgba(184, 50, 50, 0.1);
    border-color: var(--wrong);
    color: var(--wrong);
}

.option-btn:disabled { cursor: default; }

.option-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    border-radius: 4px;
    background: rgba(24, 49, 29, 0.1);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.answer-feedback {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 600;
    min-height: 1.4rem;
    transition: color 0.2s;
}

.answer-feedback.correct { color: var(--correct); }
.answer-feedback.wrong { color: var(--wrong); }
.answer-feedback.timeout { color: var(--wrong); }

/* Fullscreen */
.canvas-fullscreen-button {
    background: rgba(24, 49, 29, 0.1);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    width: 2.2rem;
    height: 2.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
    fill: var(--ink);
    flex-shrink: 0;
}

.canvas-fullscreen-button:hover { background: rgba(24, 49, 29, 0.2); }

/* Fullscreen mode */
.quiz-shell:fullscreen,
.quiz-shell:-webkit-full-screen,
.quiz-shell:-moz-full-screen,
.quiz-shell:-ms-fullscreen {
    background: #1a3d22;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
}

.quiz-shell:fullscreen .question-area,
.quiz-shell:-webkit-full-screen .question-area {
    background: var(--card);
    border-radius: 1.2rem;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
}

/* Buttons */
.primary-button {
    background: #284b2d;
    color: #fffaf0;
    border: none;
    padding: 0.72rem 1.5rem;
    font-size: 0.96rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.18s, transform 0.1s;
}

.primary-button:hover { background: #1a3320; transform: translateY(-1px); }
.primary-button:active { transform: none; }

.control-button {
    background: rgba(24, 49, 29, 0.08);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.control-button:hover { background: rgba(24, 49, 29, 0.15); }

.hidden-action { display: none; }

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    border-radius: 1.2rem;
    padding: 1.2rem;
}

.card-heading {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--green-deep);
}

/* Leaderboard */
.leaderboard-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.leaderboard-tab {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: transparent;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--ink-soft);
    transition: background 0.15s, color 0.15s;
}

.leaderboard-tab.active,
.leaderboard-tab:hover {
    background: var(--green);
    color: #fff;
    border-color: var(--green);
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 220px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.4rem;
}

.leaderboard-item:nth-child(odd) { background: rgba(95, 129, 40, 0.06); }

.lb-rank {
    min-width: 1.5rem;
    font-weight: 700;
    color: var(--ink-soft);
    font-size: 0.8rem;
    text-align: right;
}

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score { font-weight: 700; color: var(--green-deep); white-space: nowrap; }

.leaderboard-empty {
    color: var(--ink-soft);
    font-size: 0.9rem;
    padding: 0.5rem 0;
    text-align: center;
}

.refresh-button { margin-top: 0.5rem; font-size: 0.82rem; padding: 0.35rem 0.7rem; }

/* Submit card */
.form-label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.4rem; }

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: rgba(255, 252, 244, 0.9);
    color: var(--ink);
    margin-bottom: 0.6rem;
}

.form-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }

#leaderboard-form { display: flex; flex-direction: column; gap: 0; }

.leaderboard-status {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
    min-height: 1.2rem;
}

/* Share card */
.share-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.share-btn {
    padding: 0.5rem 0.6rem;
    border: none;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    color: #fff;
}

.share-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.share-facebook { background: #1877f2; }
.share-twitter { background: #1da1f2; }
.share-whatsapp { background: #25d366; }
.share-copy { background: #555; }
.share-leaderboard { background: var(--green-deep); }
.share-card .social-share-container { margin: 0; }

/* How to play */
.how-list {
    padding: 0;
    margin: 0;
    list-style: none;
    font-size: .88rem;
    color: var(--ink-soft);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.how-list li {
    display: flex;
    gap: .5rem;
    line-height: 1.5;
    align-items: flex-start;
}
.how-list li::before {
    content: "›";
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
    min-width: 1.2rem;
    text-align: center;
}
.how-list li:has(.icon)::before { display: none; }

/* Result banner */
.result-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    gap: 0.4rem;
    text-align: center;
}

.result-emoji { font-size: 3rem; line-height: 1; }
.result-label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--ink-soft); }
.result-score { font-size: 3rem; font-weight: 700; color: var(--green-deep); font-family: Georgia, serif; }
.result-sub { font-size: 0.96rem; color: var(--ink-soft); }
.result-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; margin-top: 0.5rem; }

/* Fact box */
.fact-box {
    background: rgba(95, 129, 40, 0.1);
    border-left: 3px solid var(--green);
    border-radius: 0 0.5rem 0.5rem 0;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
    margin-top: 0.25rem;
    line-height: 1.5;
    display: none;
}

.fact-box.visible { display: block; }

@media (max-width: 720px) {
    .layout { grid-template-columns: 1fr; }
    .options-grid { grid-template-columns: 1fr; }
    .game-page { width: calc(100% - 1rem); }
    h1 { font-size: 1.8rem; }
    .leaderboard-tabs { flex-direction: column; }
    .leaderboard-tab { text-align: center; }
    .leaderboard-form-row { flex-direction: column; }
    .leaderboard-input { width: 100%; }
}
