:root {
    --bg: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.06);
    --btn-secondary-bg: #f1f5f9;
    --btn-secondary-text: #1e293b;
    --option-bg: #f1f5f9;
    --option-border: #e2e8f0;
    --correct-bg: #dcfce7;
    --correct-border: #16a34a;
    --correct-text: #166534;
    --incorrect-bg: #fee2e2;
    --incorrect-border: #dc2626;
    --incorrect-text: #991b1b;
    --progress-bg: #f8fafc;
    --timer-bg: #fee2e2;
    --timer-text: #b91c1c;
    --selected-bg: #eff6ff;
    --selected-border: #2563eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --gold: #e5b73e;
}
body.dark {
    --bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #334155;
    --card-shadow: 0 10px 30px rgba(0,0,0,0.4);
    --btn-secondary-bg: #334155;
    --btn-secondary-text: #f1f5f9;
    --option-bg: #334155;
    --option-border: #475569;
    --correct-bg: #14532d;
    --correct-border: #22c55e;
    --correct-text: #bbf7d0;
    --incorrect-bg: #7f1d1d;
    --incorrect-border: #ef4444;
    --incorrect-text: #fecaca;
    --progress-bg: #1e293b;
    --timer-bg: #7f1d1d;
    --timer-text: #fecaca;
    --selected-bg: #1e3a5f;
    --selected-border: #3b82f6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Roboto, system-ui, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    transition: background 0.3s;
}
.container {
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 960px;
    padding: 2rem;
    position: relative;
    color: var(--text);
    transition: background 0.3s, box-shadow 0.3s;
    margin-bottom: 2rem;
}
.top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-bottom: 1.2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}
.top-bar .btn-sm {
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 30px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    white-space: nowrap;
}
.top-bar .btn-sm:hover { filter: brightness(0.9); }
.top-bar .logout-btn { margin-left: auto; background: #fee2e2; color: #b91c1c; }
body.dark .top-bar .logout-btn { background: #7f1d1d; color: #fecaca; }
.top-bar .account-btn { background: #e0f2fe; color: #0369a1; margin-right: 8px; }
body.dark .top-bar .account-btn { background: #1e3a5f; color: #93c5fd; }
.welcome-msg { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; text-align: center; }
.mode-cards { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; margin-bottom: 2rem; }
.mode-card {
    display: flex; flex-direction: column; align-items: center;
    flex: 1 1 280px; max-width: 400px; background: var(--surface);
    border-radius: 24px; padding: 2rem 1.5rem; text-align: center;
    box-shadow: var(--card-shadow); border: 1px solid var(--border);
    transition: all 0.3s ease; cursor: pointer;
}
.mode-card:hover { transform: translateY(-8px); box-shadow: 0 20px 40px rgba(0,38,84,0.12); border-color: var(--primary); }
.mode-card .mode-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.mode-card h3 { font-size: 1.4rem; color: var(--text); margin-bottom: 0.8rem; font-weight: 700; }
.mode-card p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; margin-bottom: 1.5rem; flex: 1; }
.mode-card .btn { margin-top: auto; background: var(--primary); color: white; border: none; padding: 12px 28px; border-radius: 40px; font-weight: 600; font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s; }
.mode-card .btn:hover { background: var(--primary-dark); }
.btn { background: var(--primary); color: white; border: none; padding: 12px 24px; border-radius: 40px; font-weight: 600; font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; margin: 5px; transition: 0.2s; }
.btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-danger { background: #ef4444; color: white; }
.stats-bar { background: var(--progress-bg); border-radius: 16px; padding: 1rem 1.5rem; margin: 1.5rem 0; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: var(--text); }
.timer { background: var(--timer-bg); color: var(--timer-text); padding: 6px 14px; border-radius: 30px; font-weight: 600; }
.progress, .score-display { font-weight: 600; color: var(--text); }
.question-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; margin: 1.5rem 0; }
.question-text { font-size: 1.3rem; font-weight: 600; color: var(--text); margin-bottom: 1.8rem; }
.options { display: grid; gap: 14px; }
.option { background: var(--option-bg); border: 2px solid var(--option-border); border-radius: 12px; padding: 16px 20px; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: 0.2s; color: var(--text); }
.option:hover:not(.disabled) { filter: brightness(0.95); }
.option.selected { background: var(--selected-bg); border-color: var(--selected-border); color: var(--text); }
.option.correct-highlight { background: var(--correct-bg); border-color: var(--correct-border); color: var(--correct-text); }
.option.incorrect-highlight { background: var(--incorrect-bg); border-color: var(--incorrect-border); color: var(--incorrect-text); }
.option.disabled { pointer-events: none; opacity: 0.85; }
.option .prefix { font-weight: bold; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.1); color: #0f172a; }
.actions { display: flex; justify-content: space-between; margin-top: 2rem; flex-wrap: wrap; gap: 10px; }
.hidden { display: none !important; }
.theme-selector { background: var(--progress-bg); border-radius: 16px; padding: 1rem; margin: 1rem 0; }
.theme-selector label { display: block; margin: 5px 0; color: var(--text); }
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { border: 1px solid var(--border); padding: 8px; text-align: left; color: var(--text); }
th { background-color: var(--btn-secondary-bg); }
.stats-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin: 1.5rem 0; }
.stat-card { background: var(--surface); border-radius: 16px; padding: 1.5rem; box-shadow: var(--card-shadow); text-align: center; border: 1px solid var(--border); }
.stat-card h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--text); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-secondary); }
.progress-ring { position: relative; width: 100px; height: 100px; margin: 0 auto 1rem; }
.progress-ring svg { width: 100%; height: 100%; }
.progress-ring .ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 1.2rem; font-weight: 700; color: var(--text); }
.mini-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.8rem; }
.mini-bar .label { width: 120px; font-size: 0.9rem; color: var(--text-secondary); }
.mini-bar .bar-container { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 0 1rem; }
.mini-bar .bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.mini-bar .percent { width: 40px; font-size: 0.9rem; font-weight: 600; text-align: right; }
.history-chart { display: flex; justify-content: center; align-items: flex-end; gap: 12px; height: 150px; padding: 0 10px; margin-top: 1rem; }
.history-bar { width: 36px; background: var(--primary); border-radius: 6px 6px 0 0; position: relative; transition: height 0.4s; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 2px; color: white; font-weight: 600; font-size: 0.7rem; min-height: 10px; }
.history-bar span.date-label { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 0.65rem; color: var(--text-secondary); white-space: nowrap; }
.result-container { text-align: center; }
.result-score-circle { position: relative; width: 150px; height: 150px; margin: 0 auto 1rem; }
.result-score-circle svg { width: 100%; height: 100%; }
.result-score-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 2.2rem; font-weight: 800; color: var(--text); }
.result-details { display: flex; justify-content: center; gap: 2rem; margin: 1.5rem 0; color: var(--text-secondary); }
.result-message { font-size: 1.2rem; margin: 1rem 0; font-weight: 600; }
.account-panel {
    position: fixed; top: 0; right: 0; width: 100%; max-width: 400px; height: 100vh;
    background: var(--surface); box-shadow: -10px 0 30px rgba(0,0,0,0.2);
    z-index: 1000; padding: 2rem; overflow-y: auto;
    transform: translateX(100%); transition: transform 0.3s ease; color: var(--text);
}
.account-panel.open { transform: translateX(0); }
.account-panel h2 { font-size: 1.5rem; margin-bottom: 1.5rem; color: var(--text); }
.account-panel .field { margin-bottom: 1rem; }
.account-panel .field label { display: block; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.3rem; }
.account-panel .field span { display: block; background: var(--progress-bg); padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.95rem; }
.close-panel { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 999; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.footer { text-align: center; padding: 2rem; color: var(--text-secondary); font-size: 0.9rem; width: 100%; max-width: 960px; margin-top: 1rem; }
.footer a { color: var(--text); font-weight: 500; }
@media (max-width: 600px) { .container { padding: 1rem; } }