/* ThaiDrive - styles
 * Light "road" theme with a subtle Thai touch: Thai flag navy as the main
 * colour, warning-sign yellow for progress, Thai flag red for errors.
 * Dark mode follows the system setting.
 */

:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #f1eee7;
    --border: #e3dfd5;
    --text: #1c1b2e;
    --muted: #6a6878;
    --primary: #2b2d6e;          /* Thai flag navy */
    --primary-hover: #212358;
    --primary-text: #2b2d6e;
    --on-primary: #ffffff;
    --accent: #f5b700;           /* warning sign yellow */
    --accent-soft: #fff3c4;
    --accent-text: #8a6500;
    --error: #a51931;            /* Thai flag red */
    --error-soft: #fbe8eb;
    --success: #1f8a5b;
    --success-soft: #e2f3ea;
    --road: #3a3f4b;
    --sign-tile: #ffffff;
    --shadow: 0 1px 2px rgba(28, 27, 46, 0.04), 0 8px 24px rgba(28, 27, 46, 0.06);
    --shadow-lg: 0 2px 4px rgba(28, 27, 46, 0.05), 0 20px 48px rgba(28, 27, 46, 0.12);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12131c;
        --surface: #1b1d29;
        --surface-2: #242737;
        --border: #2f3245;
        --text: #ececf3;
        --muted: #9c9eb2;
        --primary: #4a4fb8;
        --primary-hover: #5a60cc;
        --primary-text: #a9adf5;
        --on-primary: #ffffff;
        --accent: #f5c542;
        --accent-soft: rgba(245, 197, 66, 0.14);
        --accent-text: #f5c542;
        --error: #f06a7e;
        --error-soft: rgba(240, 106, 126, 0.13);
        --success: #4cc38a;
        --success-soft: rgba(76, 195, 138, 0.13);
        --road: #2a2e3a;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 20px 48px rgba(0, 0, 0, 0.45);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

button {
    font: inherit;
    color: inherit;
}

/* Thai flag proportions: red, white, blue (double), white, red */
.flag-stripe {
    height: 5px;
    background: linear-gradient(to bottom,
        #a51931 0 16.66%, #f4f5f8 16.66% 33.33%, #2d2a4a 33.33% 66.66%,
        #f4f5f8 66.66% 83.33%, #a51931 83.33% 100%);
}

#app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fade-in {
        animation: none;
    }
}

.icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo-mark {
    width: 34px;
    height: 34px;
}

.logo-text .accent {
    color: var(--primary-text);
}

.main-nav {
    display: flex;
    gap: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem;
}

.nav-link {
    background: none;
    border: none;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    transition: background 0.2s, color 0.2s;
}

a.nav-link {
    display: inline-block;
    text-decoration: none;
}

a.logo {
    color: inherit;
    text-decoration: none;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: var(--on-primary);
}

/* Hero (first visit) */
#hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 3rem;
    align-items: center;
    margin-bottom: 4rem;
}

.eyebrow {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary-text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    margin-bottom: 1.25rem;
}

h1 {
    font-size: 3.4rem;
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -0.035em;
    margin-bottom: 1.25rem;
}

.highlight {
    background: linear-gradient(transparent 62%, var(--accent-soft) 62%);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

#hero p {
    font-size: 1.15rem;
    color: var(--muted);
    max-width: 520px;
    margin-bottom: 2rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.hero-stats {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.75rem;
    margin-top: 2rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.hero-stats strong {
    color: var(--text);
    font-size: 1.15rem;
}

.hero-art {
    position: relative;
    aspect-ratio: 10 / 9;
    border-radius: 28px;
    overflow: hidden;
    background: linear-gradient(to bottom, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.hero-road {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 72%;
}

.hero-sign {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* sign post */
.hero-sign::after {
    content: '';
    width: 6px;
    background: #8a8f9c;
    border-radius: 3px;
}

.hero-sign img {
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.18));
}

.hero-sign-a {
    right: 8%;
    top: 12%;
}

.hero-sign-a img {
    width: 120px;
}

.hero-sign-a::after {
    height: 110px;
}

.hero-sign-b {
    left: 8%;
    top: 22%;
}

.hero-sign-b img {
    width: 92px;
}

.hero-sign-b::after {
    height: 90px;
}

.hero-sign-c {
    left: 50%;
    top: 6%;
    transform: translateX(-50%);
}

.hero-sign-c img {
    width: 54px;
}

.hero-sign-c::after {
    height: 34px;
    width: 4px;
}

/* Dashboard (returning visitors) */
.dashboard {
    max-width: 880px;
    margin: 0 auto 3.5rem;
    padding: 2.25rem;
}

.readiness-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.9rem;
}

.readiness-head h2 {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.readiness-value {
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.readiness-bar {
    height: 14px;
}

.readiness-summary {
    margin-top: 1rem;
    font-weight: 600;
}

.readiness-hint {
    margin-top: 0.2rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.75rem;
}

/* Progress bars: warning-sign yellow, green once ready */
.progress-bar-bg {
    display: block;
    height: 8px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s ease;
}

.progress-bar-fill.good {
    background: var(--success);
}

/* Section titles */
.section-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 1.75rem;
}

/* Category rows */
.category-list {
    display: grid;
    gap: 0.75rem;
    max-width: 880px;
    margin: 0 auto;
}

.category-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    padding: 1.1rem 1.4rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.category-row:hover {
    border-color: var(--primary-text);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.category-row:focus-visible,
.btn:focus-visible,
.option-item:focus-visible,
.filter-btn:focus-visible,
.nav-link:focus-visible,
.licence-option:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.category-row .category-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--primary-text);
    font-size: 1.25rem;
}

.category-main {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.category-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.category-desc {
    font-size: 0.85rem;
    color: var(--muted);
}

.category-status {
    font-size: 0.85rem;
    color: var(--muted);
    text-align: right;
    min-width: 11rem;
}

.category-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.category-badge.focus {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.category-badge.done {
    background: var(--success-soft);
    color: var(--success);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.4rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-lg {
    padding: 0.95rem 1.7rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--primary-text);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
}

.btn-ghost:not(:disabled):hover {
    color: var(--text);
    background: var(--surface-2);
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-icon {
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-icon:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Quiz */
#quiz-view,
#results-view {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

#results-view {
    z-index: 101;
}

.quiz-container {
    max-width: 760px;
    width: 100%;
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem 1.4rem;
}

.quiz-progress-wrapper {
    flex-grow: 1;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.45rem;
    font-weight: 700;
    font-size: 0.85rem;
}

#quiz-timer {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.question-card {
    padding: 2.25rem;
}

.category-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--primary-text);
    background: var(--surface-2);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    margin-bottom: 0.75rem;
}

.question-text {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.01em;
    margin-bottom: 1.5rem;
}

.question-image {
    width: 200px;
    height: 200px;
    background: var(--sign-tile);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 0 auto 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.option-item {
    width: 100%;
    text-align: left;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    gap: 0.9rem;
    align-items: center;
    transition: border-color 0.15s, background 0.15s;
}

.option-item:not(:disabled):hover {
    border-color: var(--primary-text);
}

.option-item:disabled {
    cursor: default;
}

.option-item.selected {
    border-color: var(--primary);
    background: var(--surface-2);
}

.option-marker {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--muted);
    transition: background 0.15s, color 0.15s;
}

.option-item.selected .option-marker {
    background: var(--primary);
    color: var(--on-primary);
}

.option-item.correct {
    border-color: var(--success);
    background: var(--success-soft);
}

.option-item.correct .option-marker {
    background: var(--success);
    color: #fff;
}

.option-item.incorrect {
    border-color: var(--error);
    background: var(--error-soft);
}

.option-item.incorrect .option-marker {
    background: var(--error);
    color: #fff;
}

.options-grid .option-item {
    flex-direction: column;
    padding: 0.9rem;
}

.options-grid .option-marker {
    align-self: flex-start;
}

.option-image {
    width: 120px;
    height: 120px;
    background: var(--sign-tile);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-image img,
.option-image img,
.sign-image img,
.review-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.answer-feedback {
    margin-top: 1.25rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    border-left: 4px solid;
}

.answer-feedback.is-correct {
    border-color: var(--success);
    background: var(--success-soft);
}

.answer-feedback.is-incorrect {
    border-color: var(--error);
    background: var(--error-soft);
}

.answer-feedback p {
    margin-top: 0.25rem;
}

.answer-source {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.quiz-footer {
    display: flex;
    justify-content: space-between;
}

/* Results */
.results-container {
    max-width: 680px;
    width: 100%;
    margin: auto 0;
    padding: 3rem 2rem;
    text-align: center;
}

.result-status-icon {
    display: inline-grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.result-status-icon.passed {
    background: var(--success-soft);
    color: var(--success);
}

#result-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

#result-message {
    color: var(--muted);
}

.score-circle {
    width: 170px;
    height: 170px;
    margin: 2rem auto;
    border: 10px solid var(--primary);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#final-score {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.score-percentage {
    font-size: 1.1rem;
    color: var(--muted);
}

.results-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    padding: 0.9rem 0.5rem;
}

.summary-item .label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.summary-item .value {
    font-size: 1.25rem;
    font-weight: 800;
}

.value.success {
    color: var(--success);
}

.value.error {
    color: var(--error);
}

.results-review {
    text-align: left;
    margin-bottom: 2rem;
}

.review-title {
    font-size: 1.1rem;
    margin-bottom: 0.9rem;
}

.review-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--error);
    border-radius: var(--radius-md);
}

.review-image {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    background: var(--sign-tile);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
}

.review-question {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.review-answer {
    font-size: 0.9rem;
}

.review-answer.wrong {
    color: var(--error);
}

.review-answer.right {
    color: var(--success);
    font-weight: 600;
}

.review-explanation {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Signs library */
.signs-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-btn {
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.filter-btn:hover {
    color: var(--text);
    border-color: var(--primary-text);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.signs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
}

.sign-card {
    padding: 1.25rem;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
}

.sign-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.sign-image {
    width: 120px;
    height: 120px;
    background: var(--sign-tile);
    border-radius: var(--radius-md);
    margin: 0 auto 0.9rem;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.sign-title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.sign-meaning {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-text);
    margin-bottom: 0.3rem;
}

.sign-desc {
    font-size: 0.8rem;
    color: var(--muted);
}

.signs-credits {
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

.signs-credits a {
    color: inherit;
}

/* History */
.category-stats {
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    display: grid;
    gap: 1.1rem;
}

.stat-row-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-row-head span:last-child {
    color: var(--muted);
    font-weight: 500;
}

.stat-covered {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 0.4rem;
}

.history-container {
    padding: 0.5rem 1.5rem;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.history-table th {
    padding: 1rem 0.75rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-empty {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
}

.history-tag {
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
}

.tag-pass {
    background: var(--success-soft);
    color: var(--success);
}

.tag-fail {
    background: var(--error-soft);
    color: var(--error);
}

.tag-neutral {
    background: var(--surface-2);
    color: var(--primary-text);
}

/* Licence dialog */
.licence-dialog {
    margin: auto;
    padding: 2.25rem 2rem 1.5rem;
    max-width: 440px;
    width: calc(100% - 2rem);
    color: var(--text);
    text-align: center;
}

.licence-dialog::backdrop {
    background: rgba(18, 19, 28, 0.55);
}

.licence-dialog h3 {
    font-size: 1.3rem;
    font-weight: 800;
}

.licence-dialog p {
    color: var(--muted);
    margin: 0.4rem 0 1.5rem;
}

.licence-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.licence-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 0.75rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.licence-option:hover {
    border-color: var(--primary);
    background: var(--surface-2);
}

.licence-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--primary-text);
    font-size: 1.6rem;
}

/* Responsive */
@media (max-width: 860px) {
    #hero {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .hero-art {
        max-width: 460px;
        width: 100%;
        margin: 0 auto;
    }
}

@media (max-width: 640px) {
    #app {
        padding: 1rem 1rem 3rem;
    }

    .app-header {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
    }

    h1 {
        font-size: 2.3rem;
    }

    #hero p {
        font-size: 1.02rem;
    }

    .hero-actions .btn,
    .dashboard-actions .btn {
        width: 100%;
    }

    .hero-sign-a img {
        width: 86px;
    }

    .hero-sign-a::after {
        height: 70px;
    }

    .hero-sign-b img {
        width: 66px;
    }

    .hero-sign-b::after {
        height: 60px;
    }

    .dashboard {
        padding: 1.5rem;
    }

    .category-row {
        grid-template-columns: auto 1fr;
        gap: 0.4rem 1rem;
        padding: 1rem;
    }

    .category-row .category-icon {
        width: 40px;
        height: 40px;
    }

    .category-status {
        grid-column: 2;
        text-align: left;
        min-width: 0;
    }

    #quiz-view,
    #results-view {
        padding: 0.75rem;
    }

    .quiz-header {
        padding: 0.8rem 1rem;
    }

    .question-card {
        padding: 1.4rem;
    }

    .question-text {
        font-size: 1.15rem;
    }

    .question-image {
        width: 150px;
        height: 150px;
    }

    .option-image {
        width: 90px;
        height: 90px;
    }

    .results-container {
        padding: 2rem 1.1rem;
    }

    .results-summary {
        gap: 0.5rem;
    }
}

/* Cookie consent banner (analytics.js) */
.consent-banner {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    background: var(--surface, #fff);
    color: inherit;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    font-size: 0.92rem;
}

.consent-banner p { flex: 1 1 280px; margin: 0; }
.consent-banner a { color: inherit; text-underline-offset: 3px; }
.consent-actions { display: flex; gap: 0.5rem; }
