/* ============================================
   TEST CELADOR SACYL 2.0 — Blanco + Azul Sanitario + Rojo Celador
   ============================================ */
:root {
    --blue: #0077B6;
    --blue-light: #00B4D8;
    --blue-dark: #005f8a;
    --blue-bg: rgba(0,119,182,.08);
    --blue-bg2: rgba(0,119,182,.15);
    --red: #C8102E;
    --red-light: #E63946;
    --red-bg: rgba(200,16,46,.08);
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #1a2a3a;
    --text-secondary: #5a6a7a;
    --border: rgba(0,40,80,.08);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0,119,182,.07) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 90%, rgba(200,16,46,.04) 0%, transparent 50%);
    pointer-events: none; z-index: 0;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* --- Utility --- */
.hidden { display: none !important; }
.text-gradient {
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Screens --- */
.screen {
    display: none;
    position: relative;
    min-height: 100dvh;
    padding-bottom: 80px;
}
.screen.active { display: block; animation: fadeUp .35s ease; }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==============================
   BOTTOM NAVIGATION
   ============================== */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    box-shadow: 0 -2px 20px rgba(0,40,80,.06);
}
.bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 8px 0;
    font-size: .65rem; font-weight: 500; letter-spacing: .02em;
    color: var(--text-secondary); transition: color .2s;
}
.bnav-item svg { width: 22px; height: 22px; transition: transform .2s; }
.bnav-item.active { color: var(--blue); }
.bnav-item.active svg { transform: scale(1.12); }
.bottom-nav.hidden-nav { transform: translateY(100%); }

/* ==============================
   LOGIN SCREEN
   ============================== */
.login-scroll { 
    padding: 0 20px; 
    display: flex; flex-direction: column; 
    min-height: 100vh;
}

.scroll-hint-wrap {
    text-align: center;
    padding: 10px 0 30px;
    color: var(--blue);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.6;
    animation: bounceDown 2s infinite;
}

.scroll-hint-wrap span { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.scroll-hint-wrap svg { width: 20px; height: 20px; }

@keyframes bounceDown {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(6px); }
    60% { transform: translateY(3px); }
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header .main-logo { width: 130px; margin: 0 auto -10px; mix-blend-mode: multiply; }
.login-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 8px; line-height: 1.4; }

.login-form { background: var(--surface); padding: 24px 20px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,40,80,.08); }
.input-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.custom-input { width: 100%; padding: 14px 16px; border-radius: 12px; font-size: 0.95rem; background: var(--bg); border: 1px solid var(--border); color: var(--text); outline: none; transition: all .2s; }
.custom-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,119,182,.15); }
.custom-input::placeholder { color: #a0aec0; }

.login-options { margin-top: -4px; margin-bottom: 20px; }
.checkbox-label { 
    display: inline-flex; align-items: center; gap: 10px; 
    font-size: 0.85rem; color: var(--text-secondary); 
    cursor: pointer; user-select: none;
    padding: 4px 0;
}
.checkbox-label input[type="checkbox"] { 
    width: 18px; height: 18px; accent-color: var(--blue); 
    cursor: pointer; border-radius: 6px;
    border: 2px solid var(--border);
}

.login-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.login-error { color: var(--red); font-size: 0.8rem; text-align: center; margin-top: 16px; background: var(--red-bg); padding: 10px; border-radius: 8px; }

.login-seo-text {
    text-align: left;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 40, 80, 0.04);
    margin-bottom: 32px;
    animation: fadeUp 0.8s ease backwards;
    animation-delay: 0.2s;
}

.login-seo-text h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue-dark);
    margin-bottom: 12px;
    line-height: 1.3;
}

.login-seo-text h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 20px;
    margin-bottom: 10px;
}

.login-seo-text p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
}

.login-seo-text strong {
    color: var(--blue);
    font-weight: 700;
}

.seo-features-grid {
    background: var(--bg);
    padding: 16px;
    border-radius: 14px;
    margin: 18px 0;
    border: 1px solid rgba(0, 119, 182, 0.05);
}

.seo-features-grid .features-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--blue);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.seo-features-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
}

.seo-features-list li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.seo-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.seo-tag {
    font-size: 0.75rem;
    background: rgba(0, 119, 182, 0.08);
    color: var(--blue-dark);
    padding: 5px 12px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid rgba(0, 119, 182, 0.1);
}

/* ==============================
   HOME SCREEN
   ============================== */
.home-scroll { padding: 0 20px; }
.home-spacer { height: 24px; }

/* Header */
.home-header { position: relative; padding-top: max(env(safe-area-inset-top, 50px), 50px); margin-bottom: 24px; text-align: center; }
.header-actions { position: absolute; top: max(env(safe-area-inset-top, 16px), 16px); right: 0; display: flex; gap: 8px; }
.btn-logout { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; font-size: .75rem; font-weight: 600; background: rgba(200,16,46,.08); border: 1px solid rgba(200,16,46,.2); color: var(--red); transition: all .2s; }
.btn-logout:active { transform: scale(0.95); background: rgba(200,16,46,.15); }
.btn-logout svg { width: 14px; height: 14px; }
.btn-install { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; font-size: .75rem; font-weight: 600; background: var(--blue-bg); border: 1px solid rgba(0,119,182,.2); color: var(--blue); transition: all .2s; }
.btn-install:active { transform: scale(0.95); background: var(--blue-bg2); }
.btn-install svg { width: 14px; height: 14px; }
.main-logo { width: 150px; max-width: 100%; height: auto; margin: 0 auto -15px; display: block; animation: fadeUp .5s ease; mix-blend-mode: multiply; }
.main-title { font-size: 2rem; font-weight: 800; color: var(--text); animation: fadeUp .6s ease; letter-spacing: -0.02em; }
.contact-email { display: inline-block; font-size: 0.8rem; font-weight: 600; color: var(--blue); margin-top: 4px; text-decoration: underline; text-underline-offset: 3px; transition: color .2s; animation: fadeUp .6s ease; }
.contact-email:hover { color: var(--blue-dark); }

/* Quick Stats */
.quick-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin: 24px 0;
}
.qs-card {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,40,80,.06);
    transition: transform .2s, background .2s;
}
.qs-card:active { transform: scale(.97); }
.qs-icon {
    width: 38px; height: 38px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.qs-icon svg { width: 20px; height: 20px; }
.qs-purple { background: var(--blue-bg2); color: var(--blue); }
.qs-green { background: rgba(16,185,129,.12); color: #059669; }
.qs-orange { background: rgba(245,158,11,.12); color: #d97706; }
.qs-data { display: flex; flex-direction: column; align-items: center; }
.qs-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.qs-label { font-size: .7rem; color: var(--text-secondary); }

/* Action Cards */
.section { margin-bottom: 28px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.section-count { font-size: .75rem; color: var(--text-secondary); }

.action-card {
    display: flex; align-items: center; gap: 14px;
    width: 100%; text-align: left;
    padding: 16px; margin-bottom: 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0,40,80,.05);
    transition: transform .2s, box-shadow .2s;
}
.action-card:active { transform: scale(.98); }
.action-icon-wrap {
    width: 44px; height: 44px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.action-icon-wrap svg { width: 22px; height: 22px; }
.action-info { flex: 1; }
.action-title { display: block; font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.action-desc { display: block; font-size: .75rem; color: var(--text-secondary); line-height: 1.3; }
.action-arrow { width: 18px; height: 18px; color: rgba(0,40,80,.2); flex-shrink: 0; }

.action-primary { background: var(--surface); }
.action-primary .action-icon-wrap { background: var(--blue-bg2); color: var(--blue); }
.action-study { background: var(--surface); }
.action-study .action-icon-wrap { background: rgba(16,185,129,.12); color: #059669; }
.action-exam { background: var(--surface); }
.action-exam .action-icon-wrap { background: rgba(200,16,46,.1); color: var(--red); }
.action-failed { background: var(--surface); }
.action-failed .action-icon-wrap { background: rgba(245,158,11,.12); color: #d97706; }
.action-osakidetza { background: linear-gradient(135deg, rgba(0,148,94,.06), rgba(0,148,94,.12)); border-color: rgba(0,148,94,.25); }
.action-osakidetza .action-icon-wrap { background: rgba(0,148,94,.15); color: #00945E; }
.osakidetza-title {
    font-family: 'Oswald', sans-serif !important;
    font-weight: 700; font-size: 1.1rem !important;
    letter-spacing: .12em;
    color: #00945E !important;
}
.action-osakidetza .action-desc { color: #065f46; }
.action-osakidetza .action-arrow { color: rgba(0,148,94,.35); }

/* Topics List */
.topics-list { display: flex; flex-direction: column; gap: 8px; }
.topic-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; width: 100%; text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: transform .15s, background .15s;
}
.topic-card:active { transform: scale(.98); background: #e8f0f8; }
.topic-emoji { font-size: 1.5rem; width: 40px; text-align: center; flex-shrink: 0; }
.topic-info { flex: 1; min-width: 0; }
.topic-name { display: block; font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-count { display: block; font-size: .7rem; color: var(--text-secondary); margin-top: 2px; }
.topic-progress-bar {
    width: 100%; height: 4px; border-radius: 4px;
    background: rgba(0,119,182,.1); margin-top: 6px; overflow: hidden;
}
.topic-progress-fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    transition: width .4s ease;
}
.topic-arrow { width: 16px; height: 16px; color: rgba(0,40,80,.2); flex-shrink: 0; }
.topic-arrow svg { width: 16px; height: 16px; }

/* ==============================
   CONFIG SCREEN
   ============================== */
.config-scroll { padding: 0 20px; }
.screen-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: max(env(safe-area-inset-top, 12px), 12px) 0 12px;
    position: sticky; top: 0; z-index: 10;
    background: rgba(240,244,248,.9);
    backdrop-filter: blur(12px);
}
.topbar-back {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: background .15s;
}
.topbar-back:active { background: #e0e8f0; }
.topbar-back svg { width: 20px; height: 20px; color: var(--text); }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.topbar-spacer { flex: 1; }

.config-hero { text-align: center; padding: 20px 0 28px; }
.config-emoji { font-size: 3rem; display: block; margin-bottom: 12px; }
.config-heading { font-size: 1.35rem; font-weight: 800; color: var(--text); }
.config-sub { font-size: .85rem; color: var(--text-secondary); margin-top: 4px; }

.config-body { margin-bottom: 32px; }
.config-group { margin-bottom: 24px; }
.config-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }

.custom-select {
    width: 100%; padding: 14px 16px; border-radius: 12px; font-size: .9rem; font-weight: 500; font-family: inherit;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    appearance: none; outline: none; transition: all .2s;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231a2a3a%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat; background-position: right 14px top 50%; background-size: 10px auto;
}
.custom-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,119,182,.15); }
.custom-select option { background-color: #fff; color: var(--text); font-weight: 500; }

.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 10px 18px; border-radius: 12px;
    font-size: .82rem; font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all .2s;
}
.chip:active { transform: scale(.96); }
.chip.selected {
    background: var(--blue-bg2);
    border-color: var(--blue);
    color: var(--blue-dark);
    box-shadow: 0 0 20px rgba(0,119,182,.1);
}

.config-footer { padding-bottom: 100px; }

/* ==============================
   BUTTONS
   ============================== */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 28px; border-radius: 14px;
    font-size: .92rem; font-weight: 700;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    box-shadow: 0 4px 24px rgba(0,119,182,.25);
    transition: transform .15s, box-shadow .15s;
    width: 100%;
}
.btn-primary svg { width: 20px; height: 20px; }
.btn-primary:active { transform: scale(.97); }
.btn-lg { padding: 16px 32px; font-size: 1rem; border-radius: 16px; }

.btn-glass {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 24px; border-radius: 14px;
    font-size: .88rem; font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    transition: transform .15s, background .15s;
    width: 100%;
}
.btn-glass svg { width: 18px; height: 18px; }
.btn-glass:active { transform: scale(.97); background: #e8f0f8; }

.btn-danger-sm {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border-radius: 10px;
    font-size: .8rem; font-weight: 600;
    background: rgba(200,16,46,.06);
    border: 1px solid rgba(200,16,46,.15);
    color: var(--red);
    transition: background .15s;
    width: 100%;
}
.btn-danger-sm svg { width: 16px; height: 16px; }
.btn-danger-sm:active { background: rgba(200,16,46,.12); }

/* ==============================
   TEST SCREEN
   ============================== */
.test-scroll { padding: 0 20px; }

.test-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: max(env(safe-area-inset-top, 12px), 12px) 0 8px;
    position: sticky; top: 0; z-index: 10;
    background: rgba(240,244,248,.92);
    backdrop-filter: blur(12px);
}
.test-topbar-info { display: flex; align-items: center; }
.test-counter { font-size: .85rem; font-weight: 700; color: var(--text); }
.test-timer {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 10px;
    background: var(--blue-bg2);
    font-size: .82rem; font-weight: 600; color: var(--blue);
}
.test-timer svg { width: 15px; height: 15px; }
.test-timer.warning { background: rgba(245,158,11,.12); color: #d97706; }
.test-timer.danger { background: rgba(200,16,46,.1); color: var(--red); animation: timerPulse 1s infinite; }
@keyframes timerPulse { 50% { opacity: .6; } }

.test-progress {
    height: 4px; border-radius: 4px; background: rgba(0,119,182,.1);
    margin: 4px 0 20px; overflow: hidden;
}
.test-progress-fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    transition: width .3s ease;
}

/* Question */
.question-container { min-height: 50vh; }
.question-card {
    padding: 24px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px; margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,40,80,.06);
}
.question-number {
    display: inline-block; font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--blue); margin-bottom: 10px;
}
.question-text { font-size: .95rem; font-weight: 500; line-height: 1.55; color: var(--text); }

/* Options */
.options-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.option-btn {
    display: flex; align-items: flex-start; gap: 12px;
    width: 100%; text-align: left;
    padding: 14px 16px; border-radius: 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    transition: all .2s;
}
.option-btn:active { transform: scale(.98); }
.option-letter {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    font-size: .75rem; font-weight: 700;
    background: #edf2f7;
    color: var(--text-secondary);
    transition: all .2s;
}
.option-text { font-size: .85rem; line-height: 1.45; color: var(--text); padding-top: 3px; transition: color .2s; }

/* Option States */
.option-btn.selected {
    background: var(--blue-bg);
    border-color: var(--blue);
}
.option-btn.selected .option-letter {
    background: var(--blue); color: #fff;
}
.option-btn.selected .option-text { color: var(--blue-dark); }

.option-btn.correct {
    background: rgba(16,185,129,.08);
    border-color: rgba(16,185,129,.4);
}
.option-btn.correct .option-letter {
    background: #10b981; color: #fff;
}
.option-btn.correct .option-text { color: #065f46; }

.option-btn.wrong {
    background: rgba(200,16,46,.06);
    border-color: rgba(200,16,46,.3);
}
.option-btn.wrong .option-letter {
    background: var(--red); color: #fff;
}
.option-btn.wrong .option-text { color: #991b1b; }

.option-btn.disabled { pointer-events: none; opacity: .5; }
.option-btn.correct.disabled, .option-btn.wrong.disabled { opacity: 1; }

/* Feedback Card (Study Mode) */
.feedback-card {
    padding: 16px; border-radius: 14px; margin-bottom: 16px;
    background: rgba(52,211,153,.08);
    border: 1px solid rgba(52,211,153,.2);
    animation: fadeUp .3s ease;
}
.feedback-card.wrong-fb {
    background: rgba(239,68,68,.08);
    border-color: rgba(239,68,68,.2);
}
.feedback-icon { font-size: 1.5rem; margin-bottom: 6px; }
.feedback-meta {
    font-size: .72rem; font-weight: 600; color: var(--blue);
    margin-bottom: 6px; padding: 4px 10px;
    background: rgba(0,119,182,.08); border-radius: 6px;
    display: inline-block; letter-spacing: .02em;
}
.feedback-card.wrong-fb .feedback-meta {
    color: #991b1b; background: rgba(200,16,46,.08);
}
.feedback-text { font-size: .82rem; line-height: 1.5; color: var(--text-secondary); }

/* Test Nav */
.test-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0;
    position: sticky; bottom: 80px; z-index: 5;
}
.btn-nav {
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    transition: all .15s;
}
.btn-nav:disabled { opacity: .25; }
.btn-nav svg { width: 22px; height: 22px; }
.btn-nav:active:not(:disabled) { transform: scale(.93); background: #e8f0f8; }
.btn-nav-next { background: var(--blue-bg2); border-color: var(--blue); color: var(--blue); }

.question-dots {
    display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
    flex: 1; max-height: 48px; overflow: hidden;
}
.q-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(0,119,182,.12);
    transition: all .2s; cursor: pointer;
}
.q-dot.current { background: var(--blue); transform: scale(1.3); }
.q-dot.answered { background: rgba(0,119,182,.35); }
.q-dot.correct-dot { background: #10b981; }
.q-dot.wrong-dot { background: var(--red); }

.test-finish-wrap { padding: 8px 0 20px; }
.btn-finish {
    width: 100%; padding: 14px; border-radius: 14px;
    font-size: .92rem; font-weight: 700;
    background: linear-gradient(135deg, #10b981, #34d399);
    color: #fff;
    box-shadow: 0 4px 20px rgba(16,185,129,.25);
    transition: transform .15s;
}
.btn-finish:active { transform: scale(.97); }

/* ==============================
   RESULTS SCREEN
   ============================== */
.results-scroll { padding: 0 20px; }

.results-top {
    text-align: center;
    padding: max(env(safe-area-inset-top, 40px), 40px) 0 20px;
}
.results-emoji { font-size: 3.5rem; margin-bottom: 12px; animation: bounceIn .5s ease; }
@keyframes bounceIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.results-title { font-size: 1.4rem; font-weight: 800; color: var(--text); }

/* Score Ring */
.score-ring-wrap {
    width: 160px; height: 160px; margin: 24px auto;
    position: relative;
}
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(0,119,182,.1); stroke-width: 8; }
.ring-fill {
    fill: none; stroke: url(#ringGrad); stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 364.42; stroke-dashoffset: 364.42;
    transition: stroke-dashoffset 1.2s ease;
}
.ring-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-value { font-size: 2.2rem; font-weight: 900; color: var(--text); }
.ring-label { font-size: .75rem; color: var(--text-secondary); }

/* SVG gradient for ring */
.score-ring-wrap svg defs { /* Will add via JS */ }

/* Result Cards */
.result-cards {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    margin: 20px 0;
}
.rc {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 14px 6px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,40,80,.05);
}
.rc-val { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.rc-lbl { font-size: .6rem; color: var(--text-secondary); text-align: center; }
.rc-correct .rc-val { color: #059669; }
.rc-wrong .rc-val { color: var(--red); }
.rc-skip .rc-val { color: #d97706; }
.rc-time .rc-val { color: var(--blue); }

.result-note {
    text-align: center; font-size: .82rem; color: var(--text-secondary);
    padding: 12px 16px; border-radius: 12px;
    background: var(--blue-bg);
    margin-bottom: 20px; line-height: 1.4;
}

.result-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

/* Review */
.review-heading {
    font-size: 1rem; font-weight: 700; color: var(--text);
    margin-bottom: 16px; padding-top: 12px;
    border-top: 1px solid var(--border);
}
.review-list { display: flex; flex-direction: column; gap: 16px; padding-bottom: 100px; }
.review-item {
    padding: 16px; border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,40,80,.05);
}
.review-q-num { font-size: .7rem; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.review-q-text { font-size: .85rem; color: var(--text); line-height: 1.4; margin-bottom: 12px; }
.review-option {
    padding: 8px 12px; border-radius: 9px; font-size: .8rem;
    margin-bottom: 4px; display: flex; align-items: flex-start; gap: 8px;
}
.review-option .opt-letter {
    width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; font-weight: 700;
    background: #edf2f7; color: var(--text-secondary);
}
.review-option.r-correct { background: rgba(16,185,129,.08); }
.review-option.r-correct .opt-letter { background: #10b981; color: #fff; }
.review-option.r-wrong { background: rgba(200,16,46,.06); }
.review-option.r-wrong .opt-letter { background: var(--red); color: #fff; }
.review-option.r-user { border: 1px solid rgba(0,119,182,.3); }

/* ==============================
   STATS SCREEN
   ============================== */
.stats-scroll { padding: 0 20px; }
.stats-hero { display: flex; justify-content: center; padding: 20px 0; }
.stats-ring-wrap { width: 120px; height: 120px; position: relative; }
.stats-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.sring-bg { fill: none; stroke: rgba(0,119,182,.1); stroke-width: 7; }
.sring-fill {
    fill: none; stroke: var(--blue); stroke-width: 7;
    stroke-linecap: round;
    stroke-dasharray: 263.89; stroke-dashoffset: 263.89;
    transition: stroke-dashoffset 1s ease;
}
.sring-center {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.sring-val { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.sring-lbl { font-size: .65rem; color: var(--text-secondary); }

.s-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 28px; }
.s-card {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 14px 6px; border-radius: 14px;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,40,80,.05);
}
.s-val { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.s-lbl { font-size: .6rem; color: var(--text-secondary); }

.stats-section-title { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: 12px; }

.stats-topics { margin-bottom: 28px; }
.st-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.st-emoji { font-size: 1.2rem; width: 32px; text-align: center; }
.st-info { flex: 1; }
.st-name { font-size: .8rem; font-weight: 600; color: var(--text); display: block; }
.st-bar { height: 4px; border-radius: 4px; background: rgba(0,119,182,.1); margin-top: 5px; }
.st-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--blue-light)); transition: width .5s ease; }
.st-pct { font-size: .8rem; font-weight: 700; color: var(--blue); min-width: 36px; text-align: right; }

.stats-history { margin-bottom: 28px; }
.sh-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; margin-bottom: 6px;
    background: var(--surface); border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,40,80,.04);
}
.sh-left { display: flex; flex-direction: column; }
.sh-topic { font-size: .8rem; font-weight: 600; color: var(--text); }
.sh-date { font-size: .65rem; color: var(--text-secondary); margin-top: 2px; }
.sh-score {
    font-size: .85rem; font-weight: 700; padding: 4px 10px;
    border-radius: 8px;
}
.sh-score.good { background: rgba(52,211,153,.12); color: #34d399; }
.sh-score.avg { background: rgba(251,191,36,.12); color: #fbbf24; }
.sh-score.bad { background: rgba(239,68,68,.12); color: #f87171; }

.stats-empty {
    text-align: center; padding: 32px 16px;
    color: var(--text-secondary); font-size: .85rem;
}

/* ==============================
   MODAL
   ============================== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 24px 20px;
    max-width: 340px; width: 100%;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,40,80,.15);
    animation: scaleIn .25s ease;
}
@keyframes scaleIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.modal-box p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.4; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns button { flex: 1; }

/* ==============================
   TOPICS SCREEN — ACCORDION
   ============================== */
.topics-scroll { padding: 0 20px; }
.topics-subtitle {
    font-size: .85rem; color: var(--text-secondary);
    text-align: center; margin-bottom: 20px;
}

.accordion-list { display: flex; flex-direction: column; gap: 8px; }

.accordion-item {
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,40,80,.04);
    transition: border-color .3s, background .3s;
}
.accordion-item.open {
    border-color: rgba(0,119,182,.3);
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(0,119,182,.1);
}

.accordion-header {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 14px 16px;
    text-align: left;
    transition: background .15s;
}
.accordion-header:active { background: rgba(0,119,182,.04); }

.accordion-header-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.accordion-emoji { font-size: 1.4rem; width: 36px; text-align: center; flex-shrink: 0; }
.accordion-header-info { flex: 1; min-width: 0; }
.accordion-title {
    display: block; font-size: .85rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.accordion-meta { display: block; font-size: .7rem; color: var(--text-secondary); margin-top: 2px; }

.accordion-chevron {
    width: 18px; height: 18px; color: rgba(0,40,80,.25);
    flex-shrink: 0; transition: transform .3s ease;
}
.accordion-item.open .accordion-chevron { transform: rotate(180deg); color: var(--blue); }

.accordion-body {
    max-height: 0; overflow: hidden;
    transition: max-height .35s ease, padding .35s ease;
    padding: 0 16px;
}
.accordion-item.open .accordion-body {
    max-height: 320px;
    padding: 0 16px 16px;
}

.accordion-desc {
    font-size: .8rem; color: var(--text-secondary);
    line-height: 1.4; margin-bottom: 14px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.accordion-stats-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-bottom: 12px;
}
.accordion-stat {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 6px; border-radius: 10px;
    background: var(--blue-bg);
}
.accordion-stat-val { font-size: .95rem; font-weight: 700; color: var(--text); }
.accordion-stat-lbl { font-size: .6rem; color: var(--text-secondary); }

.accordion-progress {
    height: 4px; border-radius: 4px;
    background: rgba(0,119,182,.1); margin-bottom: 14px;
    overflow: hidden;
}
.accordion-progress-fill {
    height: 100%; border-radius: 4px;
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
    transition: width .4s ease;
}

.accordion-start-btn { font-size: .88rem !important; padding: 13px 20px !important; }

/* ==============================
   PWA & APP ELEMENTS
   ============================== */

/* Swipe Hint */
.swipe-hint {
    display: flex; justify-content: center; margin-bottom: -10px;
    opacity: 0; transform: translateY(-10px); transition: all 0.5s ease;
}
.swipe-hint-inner {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px; border-radius: 20px;
    background: var(--blue-bg2);
    color: var(--blue); font-size: 0.7rem; font-weight: 600;
}
.swipe-hint-inner svg { width: 14px; height: 14px; animation: swipeAnim 1.5s infinite; }
@keyframes swipeAnim {
    0% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    100% { transform: translateX(-3px); }
}

/* Animations for Questions */
.anim-slide-out-left { animation: slideOutLeft 0.3s forwards; }
.anim-slide-in-right { animation: slideInRight 0.3s forwards; }
.anim-slide-out-right { animation: slideOutRight 0.3s forwards; }
.anim-slide-in-left { animation: slideInLeft 0.3s forwards; }

@keyframes slideOutLeft { to { opacity: 0; transform: translateX(-20%); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(20%); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight { to { opacity: 0; transform: translateX(20%); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-20%); } to { opacity: 1; transform: translateX(0); } }


/* ==============================
   RESPONSIVE — TABLET & DESKTOP
   ============================== */
@media (min-width: 640px) {
    .home-scroll, .topics-scroll, .config-scroll, .test-scroll, .results-scroll, .stats-scroll {
        max-width: 600px; margin: 0 auto;
    }
    .hero-title { font-size: 2.2rem; }
    .result-cards { gap: 12px; }
    .quick-stats { gap: 14px; }
}
@media (min-width: 1024px) {
    .home-scroll, .topics-scroll, .config-scroll, .test-scroll, .results-scroll, .stats-scroll {
        max-width: 680px;
    }
    .bottom-nav {
        top: 0; bottom: auto; left: 0; right: auto;
        flex-direction: column; width: 72px; height: 100dvh;
        border-top: none; border-right: 1px solid var(--border);
        padding: 16px 0;
    }
    .bnav-item { padding: 16px 0; }
    .screen { padding-left: 72px; padding-bottom: 20px; }
    .test-nav { bottom: 20px; }
}

/* ==============================
   LEGAL — Login note & Footer
   ============================== */
.login-legal-note {
    margin-top: 14px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}
.login-legal-note a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.login-legal-note a:hover { color: var(--blue-dark); }


