:root {
    --bg: #eef3f8;
    --bg-soft: #dce7f2;
    --surface: #ffffff;
    --surface-strong: #f8fbff;
    --ink: #142033;
    --muted: #5f6f85;
    --line: #cbd8e6;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --accent: #f59e0b;
    --accent-soft: #fef3c7;
    --correct: #12805c;
    --correct-soft: #dcfce7;
    --wrong: #c2410c;
    --wrong-soft: #ffedd5;
    --shadow: 0 24px 70px rgba(31, 41, 55, 0.12);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.18), transparent 26rem),
        radial-gradient(circle at 88% 0%, rgba(245, 158, 11, 0.18), transparent 24rem),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 52%, #e8eef6 100%);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

button,
input,
textarea {
    font: inherit;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.38);
    outline-offset: 3px;
}

.topbar {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem 0.75rem;
}

.topbar h1 {
    color: var(--ink);
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    letter-spacing: -0.04em;
}

.tagline {
    color: var(--muted);
    margin-top: 0.35rem;
    font-size: 1rem;
}

#app {
    flex: 1;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 2.5rem;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.86rem;
    padding: 1rem;
}

.footer a {
    color: var(--primary-dark);
}

.hero-card,
.rules-card,
.question-panel,
.ladder,
.result-card,
.review-item {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(203, 216, 230, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: clamp(1.25rem, 4vw, 3rem);
    align-items: center;
    border-radius: var(--radius-lg);
    padding: clamp(1.4rem, 4vw, 3rem);
    overflow: hidden;
    position: relative;
}

.hero-card::after {
    content: "";
    position: absolute;
    width: 20rem;
    height: 20rem;
    right: -8rem;
    top: -8rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.14), transparent 68%);
    pointer-events: none;
}

.hero-copy,
.start-panel {
    position: relative;
    z-index: 1;
}

.eyebrow {
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    margin-bottom: 0.85rem;
    text-transform: uppercase;
}

.hero-copy h2 {
    font-size: clamp(2rem, 5vw, 4.45rem);
    letter-spacing: -0.07em;
    line-height: 0.96;
    max-width: 12ch;
}

.hero-copy p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.65;
    max-width: 63ch;
    margin-top: 1.1rem;
}

.start-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 1rem;
    display: grid;
    gap: 0.72rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    border-radius: 15px;
    background: var(--surface-strong);
    border: 1px solid #e5edf6;
    padding: 0.85rem 0.95rem;
}

.stat-row span {
    color: var(--muted);
}

.stat-row strong {
    color: var(--ink);
    white-space: nowrap;
}

.mode-toggle {
    border: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 0.2rem;
    padding: 0;
}

.mode-toggle label {
    align-items: center;
    background: var(--surface-strong);
    border: 1px solid #e5edf6;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.7rem 0.8rem;
    transition: border-color 0.16s, box-shadow 0.16s, background-color 0.16s;
}

.mode-toggle label:has(input:checked) {
    background: var(--primary-soft);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.mode-toggle input {
    accent-color: var(--primary);
}

.mode-toggle span {
    color: var(--ink);
    font-weight: 800;
}

.rules-card {
    border-radius: 24px;
    margin-top: 1.1rem;
    padding: clamp(1rem, 2.5vw, 1.5rem);
}

.rules-card h3 {
    font-size: 1rem;
    margin-bottom: 0.9rem;
}

.rule-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.rule-grid p {
    background: var(--surface-strong);
    border: 1px solid #e5edf6;
    border-radius: 16px;
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem;
}

.rule-grid strong {
    color: var(--ink);
}

.rule-grid span {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.35;
}

.loading,
.empty-state,
.error-state {
    color: var(--muted);
    text-align: center;
    padding: 3rem 1rem;
}

.error-state {
    color: var(--wrong);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 1rem;
    align-items: stretch;
}

.question-panel {
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 3vw, 1.65rem);
    display: grid;
    gap: 1rem;
    height: 100%;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.7rem;
}

#q-meta,
#q-score {
    background: var(--primary-soft);
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 999px;
    color: #1e3a8a;
    font-size: 0.86rem;
    font-weight: 700;
    padding: 0.45rem 0.72rem;
}

#q-score {
    background: var(--accent-soft);
    border-color: rgba(245, 158, 11, 0.24);
    color: #92400e;
}

.question-text {
    color: var(--ink);
    font-size: clamp(1.35rem, 3vw, 2.05rem);
    font-weight: 780;
    letter-spacing: -0.045em;
    line-height: 1.12;
    max-width: 22cm;
}

.options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.72rem;
}

.option {
    align-items: center;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    gap: 0.8rem;
    min-height: 4.25rem;
    padding: 0.95rem 1rem;
    text-align: left;
    transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s, background-color 0.16s;
}

.option:hover:not(:disabled) {
    background: #ffffff;
    border-color: rgba(37, 99, 235, 0.5);
    box-shadow: 0 14px 36px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.option:disabled {
    cursor: default;
    opacity: 0.68;
}

.option .letter {
    align-items: center;
    background: var(--primary-soft);
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.88rem;
    font-weight: 800;
    height: 2rem;
    justify-content: center;
    width: 2rem;
}

.option.correct {
    background: var(--correct-soft);
    border-color: rgba(18, 128, 92, 0.5);
    box-shadow: 0 0 0 4px rgba(18, 128, 92, 0.1);
}

.option.correct .letter {
    background: #bbf7d0;
    border-color: rgba(18, 128, 92, 0.25);
    color: #166534;
}

.option.wrong {
    background: var(--wrong-soft);
    border-color: rgba(194, 65, 12, 0.52);
    box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.1);
}

.option.wrong .letter {
    background: #fed7aa;
    border-color: rgba(194, 65, 12, 0.28);
    color: #9a3412;
}

.option.eliminated {
    opacity: 0.34;
    text-decoration: line-through;
}

.feedback {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--ink);
    line-height: 1.5;
    padding: 0.9rem 1rem;
}

.feedback.correct {
    border-left-color: var(--correct);
}

.feedback.wrong {
    border-left-color: var(--wrong);
}

.feedback.hint {
    border-left-color: var(--accent);
}

.question-actions {
    border-top: 1px solid #e5edf6;
    display: flex;
    gap: 0.85rem;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 1rem;
}

.lifelines {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.lifelines button,
.quit-button,
.next-button,
.btn {
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.16s, background-color 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.lifelines button {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--primary-dark);
    padding: 0.58rem 0.85rem;
}

.lifelines button:hover:not(:disabled) {
    border-color: rgba(37, 99, 235, 0.46);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.lifelines button:disabled {
    color: var(--muted);
    cursor: default;
    opacity: 0.55;
}

.quit-button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    margin-left: auto;
    padding: 0.58rem 0.9rem;
    white-space: nowrap;
}

.quit-button:hover {
    background: var(--wrong-soft);
    border-color: rgba(194, 65, 12, 0.34);
    color: var(--wrong);
}

.next-button,
.btn.primary,
.btn:not(.secondary) {
    background: var(--primary);
    border: 1px solid var(--primary);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.18);
    color: white;
    padding: 0.78rem 1.2rem;
}

.next-button:hover,
.btn.primary:hover,
.btn:not(.secondary):hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--primary-dark);
    padding: 0.78rem 1.2rem;
}

.btn.secondary:hover {
    border-color: rgba(37, 99, 235, 0.5);
    transform: translateY(-1px);
}

.start-panel .btn {
    margin-top: 0.35rem;
    text-align: center;
    width: 100%;
}

.ladder {
    border-radius: 22px;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.22rem;
    padding: 0.85rem;
}

.ladder-step {
    border-radius: 11px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    padding: 0.42rem 0.55rem;
}

.ladder-step.safety {
    color: #92400e;
    font-weight: 800;
}

.ladder-step.current {
    background: var(--primary);
    color: white;
    font-weight: 850;
}

.ladder-step.passed {
    color: var(--ink);
}

.ladder-step .num {
    opacity: 0.65;
    margin-right: 0.7rem;
}

.result-card {
    border-radius: var(--radius-lg);
    padding: clamp(1.4rem, 4vw, 2.4rem);
    text-align: center;
}

.result-card.won {
    border-color: rgba(245, 158, 11, 0.58);
}

.result-card.lost {
    border-color: rgba(194, 65, 12, 0.5);
}

.result-card .verdict {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
}

.result-card .score {
    color: var(--ink);
    font-size: clamp(2.4rem, 7vw, 4.6rem);
    font-weight: 900;
    letter-spacing: -0.07em;
    line-height: 1;
    margin: 0.4rem 0 0.85rem;
}

.result-card p {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.35rem;
}

.review {
    margin-top: 1.4rem;
}

.review h2 {
    font-size: 1.2rem;
    margin-bottom: 0.85rem;
}

.review-item {
    border-radius: var(--radius-md);
    margin-bottom: 0.72rem;
    padding: 1rem;
}

.review-item .q {
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 0.55rem;
}

.review-item .ans {
    color: var(--muted);
    font-size: 0.94rem;
    margin-bottom: 0.25rem;
}

.review-item .ans.user.correct {
    color: var(--correct);
    font-weight: 800;
}

.review-item .ans.user.wrong {
    color: var(--wrong);
    font-weight: 800;
}

.review-item .explanation {
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.48;
    margin-top: 0.55rem;
}

@media (max-width: 900px) {
    .hero-card,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .hero-copy h2 {
        max-width: 15ch;
    }

    .rule-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ladder {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        font-size: 0.78rem;
    }

    .ladder-step {
        justify-content: center;
        text-align: center;
    }

    .ladder-step .num {
        display: none;
    }
}

@media (max-width: 620px) {
    .topbar {
        padding-top: 1.25rem;
    }

    #app {
        padding-inline: 0.75rem;
    }

    .hero-card,
    .rules-card,
    .question-panel,
    .result-card {
        border-radius: 20px;
    }

    .rule-grid,
    .options {
        grid-template-columns: 1fr;
    }

    .question-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .lifelines,
    .actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .lifelines button,
    .quit-button,
    .next-button,
    .btn {
        margin-left: 0;
        width: 100%;
    }
}
