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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --bad: #dc2626;
    --bad-bg: #fee2e2;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 10px 24px rgba(0,0,0,.06);
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

/* ── Header ─────────────────────────────────── */
.header {
    text-align: center;
    padding: 2rem 0 1rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.subtitle {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

/* ── Stats Bar ──────────────────────────────── */
.stats-bar {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .75rem 1rem .5rem;
    margin-bottom: 1.25rem;
    display: none;
}

.stats-bar.visible {
    display: block;
}

.stats-inner {
    display: flex;
    justify-content: space-around;
    gap: .5rem;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.stat-value.ok { color: var(--ok); }
.stat-value.bad { color: var(--bad); }
.stat-value.pct { color: var(--primary); }

.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: .6rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0;
    transition: width .4s ease;
}

/* ── Screens ────────────────────────────────── */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn .3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards ──────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem 1.5rem;
}

.card-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: .75rem;
}

/* ── Start Screen ───────────────────────────── */
.start-card {
    text-align: center;
}

.start-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: .35rem;
}

.start-card p {
    font-size: .9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.select-tema {
    display: block;
    width: 100%;
    padding: .75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    cursor: pointer;
    transition: border-color .2s;
}

.select-tema:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Buttons ────────────────────────────────── */
.btn {
    display: block;
    width: 100%;
    padding: .85rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s, transform .1s;
    margin-top: .75rem;
}

.btn:active:not(:disabled) {
    transform: scale(.98);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: .9rem;
}

.btn-secondary:hover {
    color: var(--text);
}

/* ── Question ───────────────────────────────── */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    background: #eff6ff;
    color: var(--primary);
    font-size: .75rem;
    font-weight: 600;
    padding: .3rem .7rem;
    border-radius: 20px;
}

.question-num {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.question-text {
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
    white-space: pre-line;
}

/* ── Options ────────────────────────────────── */
.options {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    width: 100%;
    padding: .9rem 1rem;
    font-size: .95rem;
    font-family: inherit;
    line-height: 1.5;
    text-align: left;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .1s;
}

.option-btn:hover {
    border-color: var(--primary);
    background: #f8faff;
}

.option-btn:active {
    transform: scale(.985);
}

.option-btn .option-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    background: var(--border);
    color: var(--text-muted);
    transition: background .2s, color .2s;
}

.option-btn:hover .option-num {
    background: var(--primary);
    color: #fff;
}

.option-btn .option-text {
    padding-top: 2px;
}

.option-btn.selected {
    border-color: var(--primary);
    background: #eff6ff;
    pointer-events: none;
}

.option-btn.selected .option-num {
    background: var(--primary);
    color: #fff;
}

.option-btn.correct {
    border-color: var(--ok);
    background: var(--ok-bg);
    pointer-events: none;
}

.option-btn.correct .option-num {
    background: var(--ok);
    color: #fff;
}

.option-btn.wrong {
    border-color: var(--bad);
    background: var(--bad-bg);
    pointer-events: none;
}

.option-btn.wrong .option-num {
    background: var(--bad);
    color: #fff;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: .55;
}

/* ── Result ─────────────────────────────────── */
.result-icon {
    text-align: center;
    font-size: 3.5rem;
    margin-bottom: .5rem;
}

.result-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: .75rem;
}

.result-title.ok  { color: var(--ok); }
.result-title.bad { color: var(--bad); }

.result-answer {
    text-align: center;
    font-size: .9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.commentary {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    font-size: .9rem;
    line-height: 1.65;
    color: var(--text);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-line;
}

/* ── Finished ───────────────────────────────── */
.finished-card {
    text-align: center;
}

.finished-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.final-stats {
    font-size: 1rem;
    line-height: 2;
    margin-bottom: 1rem;
}

/* ── Loading spinner ────────────────────────── */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 480px) {
    .app { padding: 0 .65rem 1.5rem; }
    .header { padding: 1.25rem 0 .75rem; }
    .header h1 { font-size: 1.25rem; }
    .card { padding: 1.25rem 1rem; }
    .question-text { font-size: 1rem; }
    .option-btn { padding: .75rem .85rem; font-size: .9rem; }
    .stats-inner { gap: .25rem; }
    .stat-value { font-size: 1rem; }
}
