:root {
    --pitch-top: #0f7a41;
    --pitch-bottom: #084c2a;
    --ink: #f8fafc;
    --copy: #d7f4e3;
    --card: rgba(5, 26, 15, 0.78);
    --card-border: rgba(255, 255, 255, 0.12);
    --accent: #f59e0b;
    --accent-strong: #dc7a00;
    --good: #86efac;
    --bad: #fda4af;
    --shadow: 0 26px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Baloo 2", cursive;
    color: var(--ink);
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.16), transparent 22%),
        radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.16), transparent 18%),
        linear-gradient(180deg, var(--pitch-top), var(--pitch-bottom));
    display: flex;
    flex-direction: column;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    pointer-events: none;
    opacity: 0.22;
}

body::before {
    top: 0;
    left: 8%;
    width: 84%;
    height: 100%;
    background:
        linear-gradient(90deg, transparent 0, transparent 24%, rgba(255, 255, 255, 0.55) 24.5%, transparent 25%, transparent 49%, rgba(255, 255, 255, 0.55) 49.5%, transparent 50%, transparent 74%, rgba(255, 255, 255, 0.55) 74.5%, transparent 75%);
}

body::after {
    right: -60px;
    bottom: -60px;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
}

.app-shell {
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 14px;
}

.layout-grid {
    width: min(1240px, 100%);
    display: grid;
    grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    min-height: calc(100vh - 28px);
}

.quiz-card,
.leaderboard-card {
    border: 1px solid var(--card-border);
    border-radius: 28px;
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.quiz-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 18px 20px;
}

.leaderboard-card {
    order: -1;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 18px 16px;
}

.eyebrow,
.intro,
.helper-copy,
.status-pill,
.prompt-label,
.question-meta,
.feedback-message,
.result-copy,
.save-message,
.leaderboard-copy,
.leaderboard-status,
.leaderboard-table,
.name-input,
.start-button,
.next-button,
.restart-button,
.answer-option {
    font-family: "Nunito", sans-serif;
}

.eyebrow {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ffd166;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
}

h1 {
    margin-top: 6px;
    font-size: clamp(1.9rem, 3vw, 2.9rem);
}

.intro {
    max-width: 620px;
    margin: 4px 0 10px;
    color: var(--copy);
    font-size: 0.92rem;
}

.start-panel {
    padding: 10px 0 0;
}

.name-form,
.prompt-panel {
    padding: 14px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(8, 44, 25, 0.84), rgba(13, 77, 42, 0.78));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.name-label {
    display: block;
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: 800;
}

.name-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.name-input {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    font-size: 0.98rem;
    color: #05210f;
    background: #f8fafc;
    appearance: none;
}

.name-input:focus {
    outline: 2px solid rgba(245, 158, 11, 0.32);
    border-color: rgba(245, 158, 11, 0.7);
}

.helper-copy {
    margin: 8px 0 0;
    color: var(--copy);
    font-size: 0.88rem;
    font-weight: 700;
}

.helper-copy.error {
    color: #fecdd3;
}

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.status-pill {
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.84rem;
    font-weight: 800;
}

#bonus-pill {
    background: rgba(245, 158, 11, 0.18);
    color: #ffe3a6;
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 10%;
    border-radius: inherit;
    background: linear-gradient(90deg, #fcd34d, var(--accent));
    transition: width 0.25s ease;
}

.prompt-panel {
    margin: 10px 0 10px;
}

.prompt-label,
.question-meta {
    margin: 0;
    font-size: 0.84rem;
    font-weight: 700;
    color: #b7ebc9;
}

.question-meta {
    margin-top: 4px;
}

#question-prompt {
    margin-top: 8px;
    font-size: clamp(1.35rem, 2.5vw, 2rem);
}

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.answer-option {
    border: 2px solid transparent;
    border-radius: 18px;
    padding: 16px 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    text-align: left;
    font-size: 0.96rem;
    font-weight: 800;
    color: #0b2d18;
}

.answer-option:hover:not(:disabled),
.answer-option:focus-visible:not(:disabled) {
    transform: translateY(-4px);
    border-color: rgba(245, 158, 11, 0.7);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
    outline: none;
}

.answer-option:disabled {
    cursor: default;
}

.answer-option.correct {
    border-color: rgba(134, 239, 172, 0.8);
    background: rgba(134, 239, 172, 0.18);
    color: #eafff1;
}

.answer-option.wrong {
    border-color: rgba(253, 164, 175, 0.8);
    background: rgba(253, 164, 175, 0.16);
    color: #fff1f3;
}

.answer-option.revealed:not(.correct):not(.wrong) {
    opacity: 0.72;
}

.feedback-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.feedback-message {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--copy);
}

.feedback-message.good {
    color: var(--good);
}

.feedback-message.bad {
    color: var(--bad);
}

.start-button,
.next-button,
.restart-button {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 11px 18px;
    font-size: 0.93rem;
    font-weight: 800;
    color: #05210f;
    background: linear-gradient(180deg, #ffd166, var(--accent));
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(245, 158, 11, 0.26);
    text-decoration: none;
}

.start-button:disabled,
.next-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

.hidden {
    display: none;
}

#result-screen {
    padding: 12px 0 2px;
}

.result-badge {
    display: inline-flex;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.16);
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    color: #ffe3a6;
}

#final-score {
    margin-top: 12px;
    font-size: clamp(1.7rem, 3vw, 2.7rem);
}

.result-copy {
    margin: 8px 0 0;
    color: var(--copy);
    font-size: 0.95rem;
}

.placement-message {
    min-height: 1.2em;
    margin: 10px 0 0;
    font-family: "Nunito", sans-serif;
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffe3a6;
}

.save-message {
    min-height: 1.3em;
    margin: 12px 0 0;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--copy);
}

.save-message.success {
    color: var(--good);
}

.save-message.error {
    color: var(--bad);
}

.result-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.leaderboard-header h2 {
    margin-top: 6px;
    font-size: 1.7rem;
}

.leaderboard-copy {
    margin: 6px 0 10px;
    color: var(--copy);
    font-size: 0.88rem;
}

.leaderboard-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.leaderboard-tab {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--copy);
    font-family: "Nunito", sans-serif;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.leaderboard-tab.is-active {
    background: linear-gradient(180deg, #ffd166, var(--accent));
    color: #05210f;
    border-color: transparent;
}

.leaderboard-status {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.16);
    color: #ffe3a6;
    font-size: 0.88rem;
    font-weight: 800;
}

.table-wrap {
    flex: 1;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.08);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.placement-cell {
    font-weight: 800;
}

.leaderboard-table th {
    font-size: 0.77rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #b7ebc9;
}

.leaderboard-table tbody tr:last-child td {
    border-bottom: 0;
}

.empty-row td {
    text-align: center;
    color: var(--copy);
    font-weight: 700;
}

.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confetti-canvas.is-active {
    opacity: 1;
}

.version-stamp {
    margin: 0;
    padding: 0 12px 10px;
    text-align: center;
    font-family: "Nunito", sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    color: rgba(248, 250, 252, 0.72);
}

@media (max-width: 980px) {
    .layout-grid {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .leaderboard-card {
        order: 2;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 12px;
    }

    .quiz-card,
    .leaderboard-card {
        padding: 18px;
        border-radius: 24px;
    }

    .name-row,
    .choices-grid {
        grid-template-columns: 1fr;
    }

    .feedback-row {
        flex-direction: column;
        align-items: stretch;
    }

    .start-button,
    .next-button,
    .restart-button,
    .secondary-button {
        width: 100%;
    }

    .result-actions {
        flex-direction: column;
    }
}
