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

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --accent: #e74c3c;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dcdde1;
    --success: #27ae60;
    --warning: #f39c12;
    --radius: 10px;
    --card-hover: rgba(0,0,0,0.08);
    --correct-bg: #eafaf1;
    --incorrect-bg: #fdedec;
    --manual-bg: #fef9e7;
    --tips-bg: #eaf2f8;
    --overlay-bg: rgba(0,0,0,0.8);
    --nav-bg: #ffffff;
    --footer-bg: #2c3e50;
    --header-gradient-start: #1a5276;
    --header-gradient-end: #2980b9;
}

[data-theme="dark"] {
    --primary: #4aa3df;
    --primary-light: #7ac0ea;
    --accent: #ff6b5b;
    --bg: #0f1724;
    --card-bg: #1a2540;
    --text: #f2f3f5;
    --text-light: #b8bdc9;
    --border: #3a4560;
    --success: #3ddc84;
    --warning: #f5b041;
    --card-hover: rgba(255,255,255,0.06);
    --correct-bg: #153d2a;
    --incorrect-bg: #3d1a1a;
    --manual-bg: #3d3518;
    --tips-bg: #1c2e48;
    --overlay-bg: rgba(0,0,0,0.92);
    --nav-bg: #1a2540;
    --footer-bg: #0a0f1c;
    --header-gradient-start: #0f3460;
    --header-gradient-end: #1a2540;
}

/* Targeted dark-mode polish — better contrast & readability */
[data-theme="dark"] .nav-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
[data-theme="dark"] .nav-btn.active {
    background: var(--primary);
    color: #0f1724;
    font-weight: 600;
}
[data-theme="dark"] .image-placeholder {
    background: rgba(74,163,223,0.10);
    border-color: var(--primary-light);
    color: var(--text);
}
[data-theme="dark"] .mistake-item,
[data-theme="dark"] .exam-item,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .type-card,
[data-theme="dark"] .intro-card,
[data-theme="dark"] .exam-full-card {
    border-color: var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
[data-theme="dark"] .mistakes-tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}
[data-theme="dark"] .tab-count {
    background: #2a3550;
    color: var(--text);
}
[data-theme="dark"] .mistakes-tab.active .tab-count {
    background: var(--primary);
    color: #0f1724;
}
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: var(--primary-light);
    outline: 2px solid rgba(74,163,223,0.25);
}
[data-theme="dark"] .results-table th {
    background: #243052;
    color: var(--text);
}
[data-theme="dark"] .exam-structure table {
    color: var(--text);
}
[data-theme="dark"] .exam-structure th {
    background: #243052;
    color: var(--text);
}
[data-theme="dark"] .section-desc,
[data-theme="dark"] .exam-item-desc,
[data-theme="dark"] .type-card p,
[data-theme="dark"] .mistake-meta {
    color: var(--text-light);
}
[data-theme="dark"] .btn-feladat,
[data-theme="dark"] .btn-megoldas {
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] code {
    background: #243052;
    color: var(--primary-light);
}
[data-theme="dark"] .mistake-task-id code {
    background: #243052;
    color: var(--text);
    border-color: var(--border);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--header-gradient-start) 0%, var(--header-gradient-end) 100%);
    color: white;
    padding: 40px 0 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.05rem;
    opacity: 0.9;
}

/* Navigation */
nav {
    background: var(--nav-bg);
    border-bottom: 2px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

nav .container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 20px;
}

.nav-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-light);
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

/* Sections */
.section {
    display: none;
    padding: 30px 0 60px;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

.section h2 {
    font-size: 1.6rem;
    margin-bottom: 12px;
    color: var(--primary);
}

.section-desc {
    color: var(--text-light);
    margin-bottom: 24px;
    font-size: 1.05rem;
}

/* Intro card */
.intro-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 30px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.intro-card h2 {
    margin-bottom: 10px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* Type cards */
.task-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.type-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.type-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.type-icon {
    display: inline-block;
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 12px;
}

.type-card h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
}

.type-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.type-link {
    color: var(--primary-light);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Exam structure table */
.exam-structure {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.exam-structure h3 {
    margin-bottom: 16px;
    color: var(--primary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-light);
}

.total-row td {
    border-top: 2px solid var(--primary);
    border-bottom: none;
    background: var(--bg);
}

/* Tips box */
.tips-box {
    background: var(--tips-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary-light);
}

.tips-box h4 {
    margin-bottom: 12px;
    color: var(--primary);
}

.tips-box ul {
    list-style: none;
    padding: 0;
}

.tips-box li {
    padding: 6px 0 6px 24px;
    position: relative;
    color: var(--text);
}

.tips-box li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

/* Choice tabs */
.choice-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.choice-btn {
    padding: 10px 24px;
    border: 2px solid var(--border);
    background: var(--card-bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.choice-btn:hover {
    border-color: var(--primary-light);
}

.choice-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.choice-content {
    display: none;
}

.choice-content.active {
    display: block;
}

/* Exam list items */
.exam-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.exam-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border-left: 4px solid var(--primary-light);
    transition: all 0.2s;
}

.exam-item:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.exam-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.exam-item-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.exam-badge {
    display: inline-block;
    background: var(--bg);
    color: var(--text-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.exam-item-desc {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 14px;
}

.exam-item-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.exam-item-links a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-feladat {
    background: var(--primary);
    color: white;
}

.btn-feladat:hover {
    background: var(--primary-light);
}

.btn-megoldas {
    background: var(--success);
    color: white;
}

.btn-megoldas:hover {
    background: #219a52;
}

.btn-online {
    background: var(--warning);
    color: white;
}

.btn-online:hover {
    background: #e08e0b;
}

/* Exam grid (full papers) */
.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.exam-full-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s;
}

.exam-full-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.exam-full-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 20px 24px;
}

.exam-full-header h3 {
    font-size: 1.15rem;
}

.exam-full-header .date {
    opacity: 0.85;
    font-size: 0.9rem;
    margin-top: 4px;
}

.exam-full-body {
    padding: 20px 24px;
}

.exam-full-body .links-list {
    list-style: none;
    padding: 0;
}

.exam-full-body .links-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.exam-full-body .links-list li:last-child {
    border-bottom: none;
}

.exam-full-body .links-list a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.exam-full-body .links-list a:hover {
    color: var(--primary);
}

/* Footer */
footer {
    background: var(--footer-bg);
    color: white;
    padding: 20px 0;
    font-size: 0.9rem;
    margin-top: 40px;
}

footer .footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-credit {
    margin: 0;
}

footer a {
    color: #85c1e9;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-insta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #fff !important;
    font-weight: 500;
    transition: background 0.2s;
}
.footer-insta:hover {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    text-decoration: none !important;
}
.footer-insta .ig-icon {
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .task-type-cards { grid-template-columns: 1fr; }
    .exam-grid { grid-template-columns: 1fr; }
    nav .container { padding: 8px 12px; }
    .nav-btn { padding: 8px 14px; font-size: 0.85rem; }
}

/* Timer */
#timer-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    min-width: 80px;
    text-align: center;
}

.timer-green { color: var(--success); background: var(--correct-bg) !important; }
.timer-yellow { color: var(--warning); background: var(--manual-bg) !important; }
.timer-red { color: var(--accent); background: var(--incorrect-bg) !important; }

.timer-blink {
    color: var(--accent);
    background: var(--incorrect-bg) !important;
    animation: timerBlink 0.5s ease-in-out infinite alternate;
}

@keyframes timerBlink {
    from { opacity: 1; }
    to { opacity: 0.3; }
}

.timer-paused { opacity: 0.5; }

.timer-alert {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    z-index: 200;
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 3s forwards;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.timer-alert.warning { background: #f39c12; }
.timer-alert.danger { background: #e74c3c; }

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Filter bar */
.filter-bar {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group { display: flex; align-items: center; gap: 6px; }

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.filter-year, .filter-session {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.filter-year:hover, .filter-session:hover { border-color: var(--primary-light); }

.filter-year.active, .filter-session.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-text {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 200px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-text:focus { border-color: var(--primary-light); }

.filter-clear {
    padding: 6px 14px;
    border: none;
    background: var(--bg);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: all 0.2s;
}

.filter-clear:hover { background: #e74c3c; color: white; }

.no-results {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-text { min-width: unset; width: 100%; }
}

/* ==================== QUIZ ENGINE STYLES ==================== */

/* Gyakorlas button */
.btn-gyakorlas {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-gyakorlas:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* Quiz Start / Mode Selection */
.quiz-start {
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.quiz-start h2 {
    color: var(--primary);
    margin-bottom: 12px;
}

.quiz-start p {
    color: var(--text-light);
    margin-bottom: 24px;
}

.mode-selection {
    margin: 24px 0;
}

.mode-selection h3 {
    margin-bottom: 16px;
    font-size: 1.05rem;
    color: var(--text);
}

.mode-options {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-option {
    cursor: pointer;
    flex: 1;
    min-width: 200px;
    max-width: 260px;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    transition: all 0.2s;
    background: var(--card-bg);
}

.mode-card strong {
    display: block;
    margin-bottom: 6px;
    color: var(--primary);
}

.mode-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-light);
}

.mode-option input:checked + .mode-card {
    border-color: var(--primary);
    background: var(--tips-bg);
    box-shadow: 0 0 0 2px rgba(26,82,118,0.15);
}

.btn-start-quiz {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 36px;
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-start-quiz:hover {
    background: var(--primary-light);
}

.btn-back {
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

/* Quiz Layout */
.quiz-layout {
    position: relative;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.quiz-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.quiz-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-pause {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pause:hover {
    background: rgba(255,255,255,0.3);
}

/* Task Navigation */
.task-nav {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    justify-content: center;
}

.task-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-nav-btn:hover {
    border-color: var(--primary-light);
}

.task-nav-btn.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.task-nav-btn.answered {
    border-color: var(--warning);
    color: var(--warning);
}

.task-nav-btn.checked {
    border-color: var(--success);
    color: var(--success);
}

.task-nav-btn.current.answered,
.task-nav-btn.current.checked {
    color: white;
}

/* Quiz Body - Split View */
.quiz-body {
    display: flex;
    min-height: 500px;
    background: var(--card-bg);
}

.quiz-body.no-source .task-panel {
    width: 100%;
}

.source-panel {
    width: 45%;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.source-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.source-toggle:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.source-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.7;
}

.source-content p {
    margin-bottom: 12px;
}

.task-panel {
    width: 55%;
    padding: 24px;
    overflow-y: auto;
    max-height: 70vh;
}

/* Task Content */
.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.task-number {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.task-points {
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
}

.task-question {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--text);
    white-space: pre-wrap;
}

.task-question img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px auto;
    border: 1px solid var(--border, #ccc);
    background: #fff;
}

/* Quiz Footer */
.quiz-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}

.btn-quiz-nav {
    background: var(--card-bg);
    color: var(--text);
    border: 2px solid var(--border);
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-quiz-nav:hover:not(:disabled) {
    border-color: var(--primary-light);
    color: var(--primary);
}

.btn-quiz-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-quiz-check {
    background: var(--warning);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-quiz-check:hover {
    background: #e08e0b;
}

.btn-quiz-finish {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-quiz-finish:hover {
    background: #c0392b;
}

/* Multiple Choice */
.mc-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mc-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.mc-option:hover {
    border-color: var(--primary-light);
    background: var(--bg);
}

.mc-option.selected {
    border-color: var(--primary);
    background: var(--tips-bg);
}

.mc-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.mc-option.selected .mc-letter {
    background: var(--primary);
    color: white;
}

.mc-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

/* True/False */
.tf-options {
    display: flex;
    gap: 12px;
}

.tf-btn {
    flex: 1;
    padding: 14px 24px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tf-btn:hover {
    border-color: var(--primary-light);
}

.tf-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* Fill-in */
.fill-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    outline: none;
}

.fill-input:focus {
    border-color: var(--primary-light);
}

/* Matching */
.matching-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.matching-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.matching-left {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.matching-select {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--card-bg);
    cursor: pointer;
    outline: none;
}

.matching-select:focus {
    border-color: var(--primary-light);
}

/* Table Fill */
.table-fill {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.table-fill th,
.table-fill td {
    padding: 10px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.table-fill th {
    background: var(--primary);
    color: white;
    font-size: 0.85rem;
}

.given-cell {
    background: var(--bg);
    font-weight: 500;
}

.table-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
}

.table-input:focus {
    border-color: var(--primary-light);
}

/* Short Answer */
.short-answer-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

.short-answer-input:focus {
    border-color: var(--primary-light);
}

.btn-show-sample {
    display: inline-block;
    margin-top: 10px;
    background: none;
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-show-sample:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.sample-answer {
    margin-top: 12px;
    padding: 14px 18px;
    background: var(--tips-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-light);
    font-size: 0.93rem;
    line-height: 1.6;
}

/* Ordering */
.ordering-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ordering-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    transition: all 0.15s;
}

.ordering-number {
    font-weight: 700;
    color: var(--primary);
    min-width: 24px;
}

.ordering-text {
    flex: 1;
    font-size: 0.93rem;
    line-height: 1.4;
}

.ordering-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ordering-up,
.ordering-down {
    background: var(--bg);
    border: 1px solid var(--border);
    width: 28px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ordering-up:hover:not(:disabled),
.ordering-down:hover:not(:disabled) {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

.ordering-up:disabled,
.ordering-down:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Essay */
.essay-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    line-height: 1.7;
    min-height: 200px;
}

.essay-input:focus {
    border-color: var(--primary-light);
}

.word-counter {
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    text-align: right;
}

.word-counter.word-under { color: var(--warning); }
.word-counter.word-over { color: var(--accent); }
.word-counter.word-ok { color: var(--success); }

/* Check Result */
.check-result {
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.check-result.correct {
    background: var(--correct-bg);
    color: var(--success);
    border: 1px solid var(--success);
    flex-direction: column;
    align-items: flex-start;
}

.check-result.incorrect {
    background: var(--incorrect-bg);
    color: var(--accent);
    border: 1px solid var(--accent);
    flex-direction: column;
    align-items: flex-start;
}

.correct-answer {
    margin-top: 10px;
    padding: 12px 16px;
    background: var(--correct-bg);
    border-radius: 6px;
    border-left: 3px solid var(--success);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
    width: 100%;
}

.correct-answer ul, .correct-answer ol {
    margin: 6px 0 0 20px;
}

.correct-answer li {
    padding: 2px 0;
}

.explanation {
    margin-top: 10px;
    padding: 12px 16px;
    background: var(--tips-bg);
    border-radius: 6px;
    border-left: 3px solid var(--primary-light);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.6;
    width: 100%;
}

.check-result.manual {
    background: var(--manual-bg);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.check-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Rubric Self-Evaluation */
.rubric-self-eval {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.rubric-self-eval h4 {
    margin-bottom: 16px;
    color: var(--primary);
}

.rubric-row {
    margin-bottom: 14px;
}

.rubric-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.rubric-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--card-bg);
    cursor: pointer;
    outline: none;
}

.rubric-select:focus {
    border-color: var(--primary-light);
}

.btn-save-rubric {
    display: inline-block;
    margin-top: 12px;
    background: var(--success);
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-rubric:hover {
    background: #219a52;
}

/* Quiz Summary */
.quiz-summary {
    max-width: 650px;
    margin: 30px auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.summary-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 24px 28px;
    text-align: center;
}

.summary-header h2 {
    color: white;
    margin-bottom: 4px;
}

.summary-header p {
    opacity: 0.85;
    font-size: 0.95rem;
}

.summary-stats {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.summary-stat {
    flex: 1;
    text-align: center;
    padding: 20px 12px;
    border-right: 1px solid var(--border);
}

.summary-stat:last-child {
    border-right: none;
}

.summary-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.summary-number.summary-pass {
    color: var(--success);
}

.summary-number.summary-fail {
    color: var(--accent);
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 4px;
}

.summary-tasks {
    padding: 20px 24px;
}

.summary-tasks h3 {
    margin-bottom: 14px;
    font-size: 1rem;
    color: var(--primary);
}

.summary-task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.summary-task-row:last-child {
    border-bottom: none;
}

.summary-task-row.correct {
    background: #f9fef9;
}

.summary-task-row.incorrect {
    background: #fef8f7;
}

.summary-task-row.manual {
    background: #fefcf4;
}

.summary-task-num {
    font-weight: 700;
    color: var(--text-light);
    min-width: 24px;
}

.summary-task-type {
    flex: 1;
    color: var(--text);
}

.summary-task-status {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
}

.summary-task-row.correct .summary-task-status { color: var(--success); }
.summary-task-row.incorrect .summary-task-status { color: var(--accent); }
.summary-task-row.manual .summary-task-status { color: var(--warning); }

.summary-task-score {
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.summary-actions {
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* Pause Overlay */
.quiz-pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26,82,118,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 50;
    cursor: pointer;
}

.pause-message {
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
}

/* Mobile Responsive Quiz */
@media (max-width: 768px) {
    .quiz-body {
        flex-direction: column;
    }

    .source-panel {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .task-panel {
        width: 100%;
        max-height: none;
    }

    .quiz-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .quiz-footer {
        flex-wrap: wrap;
    }

    .mode-options {
        flex-direction: column;
        align-items: center;
    }

    .mode-option {
        max-width: 100%;
    }

    .matching-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tf-options {
        flex-direction: column;
    }

    .summary-stats {
        flex-direction: column;
    }

    .summary-stat {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .summary-stat:last-child {
        border-bottom: none;
    }
}

/* Results page */
.results-averages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.results-avg-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.results-avg-num { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.results-avg-label { color: var(--text-light); font-size: 0.85rem; margin-top: 4px; }

.results-table-wrap {
    background: var(--card-bg);
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.results-table { width: 100%; border-collapse: collapse; }
.results-table th, .results-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.results-table th { background: var(--bg); font-size: 0.85rem; text-transform: uppercase; color: var(--text-light); }
.results-table td.good { color: var(--success); font-weight: 600; }
.results-table td.bad { color: var(--accent); font-weight: 600; }

.btn-clear-results {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-clear-results:hover { background: #c0392b; }

/* Dark mode toggle */
.theme-toggle {
    background: none;
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

header {
    position: relative;
}

[data-theme="dark"] header {
    color: var(--text);
}

/* Ensure theme toggle never overlaps header title on narrow screens */
@media (max-width: 480px) {
    header .container {
        padding-right: 56px;
    }
    .theme-toggle {
        right: 10px;
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
    header h1 {
        padding-right: 0;
    }
}

/* Quiz panel dark-mode tweaks */
[data-theme="dark"] .source-panel,
[data-theme="dark"] .task-panel {
    background: var(--card-bg);
    color: var(--text);
}
[data-theme="dark"] .source-panel {
    border-color: var(--border);
}
[data-theme="dark"] .quiz-header {
    background: #1a2540;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .quiz-footer {
    background: #152037;
    border-color: var(--border);
}
[data-theme="dark"] .task-nav-list button {
    background: #243052;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .task-nav-list button.active,
[data-theme="dark"] .task-nav-list button.current {
    background: var(--primary);
    color: #0f1724;
}
[data-theme="dark"] .choice-btn {
    background: #243052;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .choice-btn.active {
    background: var(--primary);
    color: #0f1724;
}
[data-theme="dark"] .tips-box {
    background: var(--tips-bg);
    color: var(--text);
    border-color: var(--primary);
}
[data-theme="dark"] .mode-option {
    background: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .mode-option:hover,
[data-theme="dark"] .mode-option.selected {
    border-color: var(--primary-light);
    background: rgba(74,163,223,0.08);
}

/* Mobile: reduce source-panel height on landscape phones */
@media (max-width: 768px) and (max-height: 500px) and (orientation: landscape) {
    .source-panel { max-height: 35vh; }
}

/* Mistakes tab container: smoother overflow on mobile */
@media (max-width: 480px) {
    .mistakes-tabs {
        border-bottom: 1px solid var(--border);
    }
    .mistakes-tab {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* Smooth transitions for dark mode */
body, .section, nav, .exam-item, .stat-card, .type-card, .intro-card, .exam-structure, .tips-box, .filter-bar, .exam-full-card {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

@media (max-width: 768px) {
    .results-averages { grid-template-columns: 1fr; }
}

.image-placeholder {
    display: block;
    margin: 10px 0;
    padding: 12px 16px;
    background: var(--tips-bg);
    border: 1px dashed var(--primary-light);
    border-radius: var(--radius);
    color: var(--text-light);
    font-style: italic;
    font-size: 0.95em;
}

/* --- Home page subject blocks --- */
.subject-block {
    margin: 32px 0;
}
.subject-title {
    font-size: 1.4em;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.structure-subheader {
    margin: 24px 0 12px;
    color: var(--primary);
    font-size: 1.1em;
}

/* --- Mistakes (Hibáim) --- */
.mistakes-tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    border-bottom: 1px solid var(--border);
}
.mistakes-tab {
    background: transparent;
    border: none;
    padding: 12px 20px;
    font-size: 1em;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    font-weight: 500;
    transition: color 0.2s, border-color 0.2s;
}
.mistakes-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.mistakes-tab:hover {
    color: var(--primary);
}
.tab-count {
    display: inline-block;
    min-width: 22px;
    padding: 2px 8px;
    margin-left: 6px;
    background: var(--border);
    color: var(--text);
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: 600;
}
.mistakes-tab.active .tab-count {
    background: var(--primary);
    color: white;
}

.mistake-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.mistake-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}
.mistake-subject {
    font-size: 0.85em;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.mistake-exam {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}
.mistake-task-id code {
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--text);
    border: 1px solid var(--border);
}
.mistake-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: var(--text-light);
    margin-bottom: 12px;
}
.mistake-status.ok {
    color: var(--success);
    font-weight: 600;
}
.mistake-status.fail {
    color: var(--warning);
    font-weight: 600;
}
.mistake-actions {
    display: flex;
    justify-content: flex-end;
}
.btn-replay {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-replay:hover {
    background: var(--primary-light);
}

/* ============================================ */
/* Mobile-first responsive polish (<=768px)     */
/* Quick-practice focus: readable, tappable, no */
/* horizontal overflow, stacked layouts.        */
/* ============================================ */
@media (max-width: 768px) {
    /* --- Global --- */
    html { -webkit-text-size-adjust: 100%; }
    body { font-size: 16px; line-height: 1.55; }
    .container { padding-inline: 16px; }

    /* Prevent iOS zoom on input focus */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    textarea,
    select {
        font-size: 16px;
    }

    /* --- Header --- */
    header { padding: 14px 0; }
    header h1 { font-size: 1.35rem; margin-bottom: 4px; }
    .subtitle { font-size: 0.9rem; line-height: 1.4; }
    .theme-toggle { width: 36px; height: 36px; right: 12px; }

    /* --- Nav --- */
    nav .container { padding: 8px 12px; gap: 2px; }
    .nav-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-height: 40px;
    }

    /* --- Sections --- */
    .section { padding: 20px 0 40px; }
    h2 { font-size: 1.4rem; }
    h3 { font-size: 1.15rem; }

    /* --- Home cards & stats --- */
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { padding: 20px 16px; }
    .stat-number { font-size: 2rem; }
    .task-type-cards { grid-template-columns: 1fr; gap: 12px; }
    .type-card { padding: 20px 16px; }
    .subject-title { font-size: 1.2rem; margin-bottom: 12px; }

    /* --- Exam structure table → card rows on mobile --- */
    .exam-structure { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .exam-structure table {
        display: block;
        width: 100%;
    }
    .exam-structure thead { display: none; }
    .exam-structure tbody,
    .exam-structure tr,
    .exam-structure td {
        display: block;
        width: 100%;
    }
    .exam-structure tr {
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 12px;
    }
    .exam-structure td {
        padding: 4px 0;
        border: none;
        font-size: 0.95rem;
    }
    .exam-structure td::before {
        content: attr(data-label);
        display: inline-block;
        width: 88px;
        font-weight: 600;
        color: var(--text-light);
    }
    .exam-structure tr.total-row { background: var(--primary); color: white; }
    .exam-structure tr.total-row td::before { color: rgba(255,255,255,0.85); }

    /* --- Exam lists (exam-item) --- */
    .exam-item { padding: 14px; }
    .exam-item-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .exam-badge { font-size: 0.8rem; }
    .exam-item-links {
        flex-direction: column;
        gap: 8px;
    }
    .exam-item-links a,
    .exam-item-links .btn-gyakorlas,
    .exam-item-links .btn-feladat,
    .exam-item-links .btn-megoldas {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        display: inline-flex;
        align-items: center;
    }

    /* --- Exam full cards (Feladatsorok, Történelem) --- */
    .exam-full-card .exam-item-links { margin-top: 10px; }
    .exam-full-card .btn-gyakorlas {
        width: 100%;
        min-height: 44px;
    }

    /* --- Results table → cards --- */
    .results-table-wrap { overflow: visible; }
    .results-table { display: block; }
    .results-table thead { display: none; }
    .results-table tbody,
    .results-table tr,
    .results-table td { display: block; width: 100%; }
    .results-table tr {
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        margin-bottom: 10px;
    }
    .results-table td {
        padding: 4px 0;
        border: none;
    }
    .results-table td::before {
        content: attr(data-label);
        display: inline-block;
        width: 100px;
        font-weight: 600;
        color: var(--text-light);
    }
    .results-averages { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    .results-avg-card { padding: 12px 8px; }
    .results-avg-num { font-size: 1.4rem; }
    .results-avg-label { font-size: 0.75rem; }

    /* --- Mistakes (Hibáim) --- */
    .mistakes-tabs { gap: 0; overflow-x: auto; }
    .mistakes-tab { padding: 12px 14px; font-size: 0.95rem; flex-shrink: 0; }
    .mistake-item { padding: 14px; }
    .mistake-top { flex-direction: column; gap: 6px; align-items: flex-start; }
    .mistake-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .btn-replay {
        width: 100%;
        min-height: 44px;
    }
    .mistake-actions { margin-top: 4px; }

    /* --- Quiz: stacked view, collapsible source --- */
    .quiz-header { flex-direction: column; gap: 10px; text-align: center; padding: 12px; }
    .quiz-body { flex-direction: column; }
    .source-panel {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .task-panel { width: 100%; max-height: none; padding: 16px 12px; }
    .task-nav-list { flex-wrap: wrap; gap: 4px; }
    .task-nav-list button { min-width: 38px; min-height: 38px; }
    .quiz-footer {
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
    }
    .quiz-footer button { width: 100%; min-height: 44px; }
    .mode-options { flex-direction: column; align-items: stretch; }
    .mode-option { max-width: 100%; }

    /* Answer inputs larger tap targets */
    .task-panel label,
    .task-panel .choice-label {
        min-height: 40px;
        padding: 8px 10px;
    }
    .task-panel input[type="radio"],
    .task-panel input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* --- Intro / tips boxes --- */
    .intro-card, .tips-box { padding: 16px; }

    /* --- Filter bar (search) --- */
    .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-text { min-width: unset; width: 100%; }
    .filter-bar select, .filter-bar input { min-height: 40px; }

    /* --- Footer --- */
    footer .footer-row {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .footer-insta { min-height: 40px; padding: 8px 14px; }
}

/* --- Phone-specific (<=480px) --- */
@media (max-width: 480px) {
    header h1 { font-size: 1.2rem; }
    .subtitle { font-size: 0.82rem; }
    .container { padding-inline: 12px; }
    .nav-btn { padding: 9px 10px; font-size: 0.8rem; }
    h2 { font-size: 1.25rem; }

    .stat-number { font-size: 1.75rem; }
    .stat-label { font-size: 0.8rem; }
    .type-card h3 { font-size: 1.05rem; }
    .type-card p { font-size: 0.9rem; }

    .results-averages { grid-template-columns: 1fr; }
    .exam-structure td::before { width: 70px; font-size: 0.85rem; }
    .results-table td::before { width: 80px; font-size: 0.85rem; }

    /* Mistake card: keep status visible but compact */
    .mistake-exam { font-size: 1rem; }
    .mistake-subject { font-size: 0.78rem; }
}
