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

body {
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: "Fira Code", "Consolas", "Courier New", monospace;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.terminal {
    width: min(780px, 100%);
    padding: 2.5rem;
    border: 1px solid #30363d;
    border-radius: 6px;
    background-color: #010409;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.08);
}

.hidden {
    display: none !important;
}

.prompt-line {
    margin-bottom: 1.75rem;
    font-size: 0.9rem;
}

.prompt {
    color: #00ff88;
}

.cmd {
    color: #c9d1d9;
    margin-left: 0.5rem;
}

.title {
    color: #00ff88;
    font-size: 3.5rem;
    letter-spacing: 0.15em;
    margin-bottom: 0.75rem;
}

.heading {
    color: #00ff88;
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    letter-spacing: 0.05em;
}

.tagline {
    color: #8b949e;
    margin-bottom: 2.5rem;
    font-size: 0.95rem;
}

.credit {
    margin-top: 2.5rem;
    font-size: 0.85rem;
}

.credit-link {
    color: #00ff88;
    text-decoration: none;
}

.credit-link:hover {
    text-decoration: underline;
}

.credit-link:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}

.muted {
    color: #8b949e;
}

.btn {
    background-color: transparent;
    color: #00ff88;
    border: 1px solid #00ff88;
    padding: 0.65rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
    background-color: #00ff88;
    color: #010409;
}

.btn:disabled {
    cursor: default;
    opacity: 0.7;
}

/* Visible focus ring for keyboard users (mouse clicks won't trigger it) */
.btn:focus-visible,
.chip:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}

.ghost-btn {
    border-color: #30363d;
    color: #8b949e;
    font-size: 0.85rem;
}

.ghost-btn:hover:not(:disabled) {
    background-color: #161b22;
    color: #ff5555;
    border-color: #ff5555;
}

/* Inline code spans inside questions, options, and explanations */
code {
    font-family: inherit;
    background-color: rgba(0, 255, 136, 0.10);
    color: #00ff88;
    padding: 0.05em 0.35em;
    border-radius: 3px;
    font-size: 0.92em;
    word-break: break-word;
}

.option-btn code {
    background-color: rgba(255, 255, 255, 0.06);
    color: inherit;
}

/* Picker / config */
.stats-line {
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.picker-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.config {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.config-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.config-label {
    width: 5.5rem;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.config-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-color: #30363d;
    color: #c9d1d9;
}

.chip:hover:not(:disabled) {
    border-color: #00ff88;
    background-color: #161b22;
    color: #c9d1d9;
}

.chip.sel {
    border-color: #00ff88;
    color: #010409;
    background-color: #00ff88;
}

.launch-btn {
    margin-top: 0.5rem;
}

/* Quiz */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.timer {
    color: #8b949e;
    letter-spacing: 0.05em;
}

.quit-btn {
    background: none;
    border: none;
    color: #8b949e;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

.quit-btn:hover {
    color: #ff5555;
}

.quit-btn:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
    color: #ff5555;
}

.timer.urgent {
    color: #ff5555;
    font-weight: bold;
}

.progress-bar {
    height: 3px;
    background-color: #21262d;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.progress-fill {
    height: 100%;
    width: 0;
    background-color: #00ff88;
    transition: width 0.25s ease;
}

.difficulty {
    color: #8b949e;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    text-transform: lowercase;
}

/* Difficulty tier colours (dim -> bright as difficulty rises) */
.diff-beginner { color: #8b949e; }
.diff-associate { color: #58a6ff; }
.diff-pro { color: #f0883e; }
.diff-architect { color: #00ff88; }

.question {
    color: #c9d1d9;
    font-size: 1.05rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.option-btn {
    text-align: left;
    padding: 0.75rem 1rem;
    border-color: #30363d;
    color: #c9d1d9;
    line-height: 1.4;
}

.option-btn:hover:not(:disabled) {
    background-color: #161b22;
    color: #c9d1d9;
    border-color: #00ff88;
}

.option-btn.correct {
    border-color: #00ff88;
    color: #00ff88;
    background-color: rgba(0, 255, 136, 0.08);
}

.option-btn.incorrect {
    border-color: #ff5555;
    color: #ff5555;
    background-color: rgba(255, 85, 85, 0.08);
}

.feedback {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed #30363d;
}

.feedback-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.correct-text {
    color: #00ff88;
}

.incorrect-text {
    color: #ff5555;
}

.explanation {
    color: #8b949e;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* Result */
.final-score {
    color: #00ff88;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
}

.name-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.name-input input {
    background-color: #010409;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 0.6rem 0.8rem;
    font-family: inherit;
    font-size: 0.95rem;
    flex: 1;
    min-width: 150px;
}

.name-input input:focus {
    outline: none;
    border-color: #00ff88;
}

/* Results breakdown */
.breakdown {
    margin-bottom: 1.5rem;
}

.breakdown-title {
    font-size: 0.8rem;
    margin: 0.75rem 0 0.4rem;
}

.breakdown-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.breakdown-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    font-size: 0.85rem;
    align-items: baseline;
}

.bd-key {
    color: #c9d1d9;
}

.bd-score {
    color: #8b949e;
    text-align: right;
}

.bd-pct {
    text-align: right;
    min-width: 3.2rem;
}

/* Review */
.review {
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px dashed #30363d;
}

.review-list {
    list-style: none;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 0.75rem;
    padding-right: 0.5rem;
}

.review-item {
    padding: 0.85rem 0;
    border-top: 1px solid #161b22;
}

.review-item:first-child {
    border-top: none;
}

.review-q {
    color: #c9d1d9;
    font-size: 0.92rem;
    line-height: 1.5;
    margin-bottom: 0.4rem;
}

.review-yours,
.review-right {
    font-size: 0.85rem;
    line-height: 1.5;
}

.review-exp {
    font-size: 0.82rem;
    line-height: 1.5;
    margin-top: 0.35rem;
}

.leaderboard {
    margin-top: 1rem;
}

.leaderboard-list {
    list-style: none;
    margin: 1rem 0 1.5rem;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #c9d1d9;
    white-space: pre;
    overflow-x: auto;
}

.leaderboard-list li {
    counter-increment: rank;
}

.leaderboard-list li::before {
    content: counter(rank, decimal-leading-zero) ". ";
    color: #00ff88;
}

.leaderboard-list {
    counter-reset: rank;
}

/* Mobile / small screens */
@media (max-width: 600px) {
    body {
        padding: 0.75rem;
        /* top-align so tall screens (config, review) aren't clipped when centered */
        align-items: flex-start;
    }

    .terminal {
        padding: 1.5rem 1.25rem;
    }

    .title {
        font-size: 2.25rem;
        letter-spacing: 0.06em;
        word-break: break-word;
    }

    .prompt-line {
        font-size: 0.8rem;
        margin-bottom: 1.25rem;
    }

    .tagline {
        margin-bottom: 1.75rem;
    }

    /* Stack each config row: label on its own line, chips below */
    .config-label {
        width: 100%;
    }

    .chip {
        padding: 0.45rem 0.7rem;
    }

    .quiz-header {
        flex-wrap: wrap;
        row-gap: 0.35rem;
    }

    .question {
        font-size: 1rem;
    }

    .final-score {
        font-size: 1.15rem;
    }

    /* 16px prevents iOS Safari from auto-zooming when the field is focused */
    .name-input input {
        font-size: 16px;
        width: 100%;
        flex: 1 1 100%;
    }

    .name-input .btn {
        width: 100%;
    }

    .leaderboard-list {
        font-size: 0.75rem;
    }

    .review-list {
        max-height: 50vh;
    }
}
