:root {
    --sky-top: #00ffd9;
    --sky-bottom: #00ffd9;
    --ink: #16324f;
    --muted: #56738f;
    --card: rgba(255, 255, 255, 0.86);
    --card-border: rgba(22, 50, 79, 0.12);
    --accent: #ff7a59;
    --accent-strong: #e65d3b;
    --good: #17976a;
    --bad: #d94f4f;
    --shadow: 0 24px 60px rgba(22, 50, 79, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Baloo 2", cursive;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
        radial-gradient(circle at top right, rgba(255, 234, 180, 0.8), transparent 24%),
        linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
    display: flex;
    flex-direction: column;
}

body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0.65;
}

body::before {
    width: 260px;
    height: 260px;
    left: -70px;
    bottom: -70px;
    background: rgba(255, 122, 89, 0.16);
}

body::after {
    width: 300px;
    height: 300px;
    right: -120px;
    top: 90px;
    background: rgba(65, 145, 255, 0.14);
}

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

.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 - 24px);
}

.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;
    justify-content: flex-start;
    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,
.feedback-message,
.result-copy,
.save-message,
.leaderboard-copy,
.leaderboard-status,
.leaderboard-table,
.name-input,
.start-button,
.next-button,
.restart-button {
    font-family: "Nunito", sans-serif;
}

.eyebrow {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

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

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

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

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

.name-form {
    padding: 14px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(227, 244, 255, 0.92));
    border: 1px solid rgba(22, 50, 79, 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(22, 50, 79, 0.18);
    border-radius: 16px;
    font-size: 0.98rem;
    color: var(--ink);
    background: white;
    appearance: none;
}

.name-input:focus {
    outline: 2px solid rgba(255, 122, 89, 0.28);
    border-color: rgba(255, 122, 89, 0.55);
}

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

.helper-copy.error {
    color: var(--bad);
}

.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.92);
    border: 1px solid rgba(22, 50, 79, 0.08);
    font-size: 0.84rem;
    font-weight: 800;
}

#bonus-pill {
    background: rgba(255, 122, 89, 0.14);
    color: var(--accent-strong);
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: rgba(22, 50, 79, 0.1);
    overflow: hidden;
}

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

.prompt-panel {
    margin: 10px 0 10px;
    padding: 10px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(227, 244, 255, 0.92));
    border: 1px solid rgba(22, 50, 79, 0.08);
}

.prompt-label {
    margin: 0 0 6px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--muted);
}

#country-name {
    font-size: clamp(1.35rem, 2.5vw, 2rem);
}

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

.flag-option {
    border: 3px solid transparent;
    border-radius: 18px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 14px 34px rgba(22, 50, 79, 0.08);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.flag-option:hover:not(:disabled),
.flag-option:focus-visible:not(:disabled) {
    transform: translateY(-4px);
    border-color: rgba(255, 122, 89, 0.5);
    box-shadow: 0 18px 36px rgba(22, 50, 79, 0.14);
    outline: none;
}

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

.flag-option img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    max-height: 92px;
    border-radius: 14px;
    border: 1px solid rgba(22, 50, 79, 0.08);
    background: #eff6fb;
}

.flag-option span {
    display: none;
    margin-top: 8px;
    font-family: "Nunito", sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--muted);
}

.flag-option.revealed span {
    display: block;
}

.flag-option.correct {
    border-color: rgba(23, 151, 106, 0.7);
    background: rgba(23, 151, 106, 0.09);
}

.flag-option.correct span {
    color: var(--good);
}

.flag-option.wrong {
    border-color: rgba(217, 79, 79, 0.7);
    background: rgba(217, 79, 79, 0.09);
}

.flag-option.wrong span {
    color: var(--bad);
}

.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(--muted);
}

.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: white;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(230, 93, 59, 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(255, 122, 89, 0.14);
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    color: var(--accent-strong);
}

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

.result-copy {
    margin: 8px 0 0;
    color: var(--muted);
    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: var(--accent-strong);
}

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

.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: white;
    color: var(--ink);
    border: 1px solid rgba(22, 50, 79, 0.12);
    box-shadow: 0 10px 22px rgba(22, 50, 79, 0.08);
}

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

.leaderboard-copy {
    margin: 6px 0 10px;
    color: var(--muted);
    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(22, 50, 79, 0.12);
    border-radius: 999px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--muted);
    font-family: "Nunito", sans-serif;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.leaderboard-tab.is-active {
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color: white;
    border-color: transparent;
}

.leaderboard-status {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 122, 89, 0.12);
    color: var(--accent-strong);
    font-size: 0.88rem;
    font-weight: 800;
}

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

.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(22, 50, 79, 0.08);
}

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

.leaderboard-table th {
    font-size: 0.77rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

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

.empty-row td {
    text-align: center;
    color: var(--muted);
    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(22, 50, 79, 0.7);
}

@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;
    }

    .flag-option img {
        max-height: none;
    }

    .flag-option span {
        font-size: 0.88rem;
    }

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

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

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