:root {
    --bg-1: #0a1622;
    --bg-2: #14314b;
    --bg-3: #1b5c73;
    --panel: rgba(9, 23, 36, 0.92);
    --panel-soft: rgba(255, 255, 255, 0.05);
    --line: rgba(161, 214, 255, 0.18);
    --text: #eff8ff;
    --muted: #bfd6e5;
    --accent: #ffd166;
    --accent-2: #59e3c1;
    --danger: #ff7d7d;
    --success: #59e3a7;
    --success-soft: rgba(89, 227, 167, 0.18);
    --error: #ff7474;
    --error-soft: rgba(255, 116, 116, 0.16);
    --shadow: 0 20px 44px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top center, rgba(255, 209, 102, 0.18), transparent 25%),
        radial-gradient(circle at bottom left, rgba(89, 227, 193, 0.2), transparent 35%),
        linear-gradient(180deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
}

body {
    min-height: 100vh;
}

.mobile-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
}

.topbar,
.card {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.35rem, 4.1vw, 2.2rem);
    line-height: 0.98;
}

.topbar-actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-pill,
.phase-badge,
.timer-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
}

.status-pill {
    min-height: 38px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    text-align: center;
    font-size: 0.92rem;
}

.main-stack {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.card {
    padding: 18px;
    overflow: hidden;
}

.card h2,
.card h3 {}

.supporting-text {
    color: var(--muted);
    line-height: 1.35;
    font-size: 0.95rem;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 700;
}

#nameForm {
    display: grid;
    gap: 12px;
}

#nameInput {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
}

#nameInput::placeholder {
    color: rgba(239, 248, 255, 0.55);
}

.primary-button,
.ghost-button,
.answer-button {
    border: 0;
    font: inherit;
    cursor: pointer;
}

.primary-button,
.ghost-button {
    border-radius: 999px;
    font-weight: 700;
}

.primary-button {
    padding: 13px 18px;
    background: linear-gradient(135deg, var(--accent), #ff9f68);
    color: #14202b;
}

.ghost-button {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 0.92rem;
}

.form-actions {
    margin-top: 4px;
    flex-wrap: wrap;
}

.meta-row,
.leaderboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.meta-row.subtle {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.phase-badge {
    padding: 8px 12px;
    background: rgba(255, 209, 102, 0.14);
    color: var(--accent);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.timer-pill {
    min-width: 58px;
    min-height: 46px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.28rem;
}

.question-title {
    margin: 18px 0 14px;
    font-size: clamp(1.28rem, 4.4vw, 2.05rem);
    line-height: 1.06;
}

#quizCard.phase-question .question-title {
    animation: answerStageSwap 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

#quizCard.phase-reveal .question-title {
    animation: answerStageSwap 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.answers-grid,
.leaderboard-list {
    display: grid;
    gap: 10px;
}

.answer-button {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    border-radius: 18px;
    color: var(--text);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    text-align: left;
    position: relative;
    overflow: hidden;
    transition:
        transform 220ms ease,
        border-color 220ms ease,
        background 220ms ease,
        box-shadow 220ms ease,
        opacity 220ms ease;
}

.answer-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.answer-button:active:not(:disabled) {
    transform: translateY(2px) scale(0.992);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.answer-button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.14) 45%, transparent 100%);
    opacity: 0;
    transform: translateX(-60%);
    pointer-events: none;
}

.answer-button.answer-enter {
    animation: answerButtonIn 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.answer-button.selected {
    border-color: rgba(255, 209, 102, 0.85);
    background: rgba(255, 209, 102, 0.14);
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(255, 209, 102, 0.12);
}

.answer-button.correct {
    border-color: rgba(89, 227, 167, 0.82);
    background: var(--success-soft);
    box-shadow: 0 16px 30px rgba(89, 227, 167, 0.14);
}

.answer-button.correct::after {
    opacity: 1;
    animation: revealFlash 700ms ease;
}

.answer-button.incorrect {
    border-color: rgba(255, 116, 116, 0.78);
    background: var(--error-soft);
    box-shadow: 0 12px 26px rgba(255, 116, 116, 0.12);
    opacity: 1;
}

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

.answer-index {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
    transition: background 220ms ease, color 220ms ease, transform 220ms ease;
}

.answer-button.correct .answer-index {
    background: rgba(89, 227, 167, 0.24);
    color: var(--success);
    transform: scale(1.04);
}

.answer-button.incorrect .answer-index {
    background: rgba(255, 116, 116, 0.2);
    color: #ffd1d1;
}

.answer-trailing {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.answer-button.correct .answer-trailing {
    color: var(--success);
}

.answer-button.incorrect .answer-trailing {
    color: #ffbcbc;
}

.result-panel,
.leaderboard-panel {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.result-panel:not([hidden]) {
    animation: answerStageSwap 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-panel p {
    margin: 0 0 10px;
}

.leaderboard-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.leaderboard-item.you {
    border-color: rgba(255, 209, 102, 0.75);
    background: rgba(255, 209, 102, 0.12);
}

.leaderboard-item.winner {
    border-color: rgba(89, 227, 167, 0.78);
    background: rgba(89, 227, 167, 0.14);
    box-shadow: 0 14px 26px rgba(89, 227, 167, 0.14);
}

.leaderboard-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.leaderboard-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent);
    font-weight: 700;
}

.leaderboard-score {
    color: var(--muted);
}

.winner-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(255, 209, 102, 0.16);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-good {
    color: var(--accent-2);
}

.status-warn {
    color: var(--accent);
}

.status-bad {
    color: var(--danger);
}

@keyframes answerStageSwap {
    0% {
        opacity: 0;
        transform: translateY(16px);
        filter: blur(8px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes answerButtonIn {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.975);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes revealFlash {
    0% {
        opacity: 0;
        transform: translateX(-60%);
    }

    25% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateX(60%);
    }
}

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

    .topbar,
    .card {
        padding: 16px;
        border-radius: 22px;
    }

    .meta-row,
    .leaderboard-header {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar {
        align-items: center;
        gap: 12px;
    }

    .topbar-actions {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        flex-shrink: 0;
        gap: 8px;
    }

    .answer-button {
        grid-template-columns: auto 1fr;
    }
}

@media (max-width: 430px) {
    .mobile-shell {
        padding: 10px;
    }

    .topbar,
    .card {
        padding: 14px;
        border-radius: 20px;
    }

    .topbar {
        gap: 10px;
    }

    .topbar h1 {
        font-size: 1.2rem;
    }

    .status-pill,
    .ghost-button {
        font-size: 0.84rem;
    }

    .status-pill {
        min-height: 34px;
        padding: 7px 10px;
    }

    .ghost-button {
        padding: 7px 10px;
    }

    .phase-badge {
        font-size: 0.72rem;
    }

    .timer-pill {
        min-width: 52px;
        min-height: 42px;
        font-size: 1.15rem;
    }

    .question-title {
        margin: 16px 0 12px;
        font-size: 1.15rem;
    }

    .supporting-text,
    .meta-row.subtle {
        font-size: 0.84rem;
    }

    .answer-button {
        padding: 12px 13px;
        gap: 10px;
        border-radius: 16px;
    }

    .answer-index {
        width: 30px;
        height: 30px;
        font-size: 0.84rem;
    }

    .answer-trailing {
        font-size: 0.78rem;
    }

    .leaderboard-item {
        padding: 10px 12px;
    }
}
