@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --correct: #22c55e;
    --incorrect: #ef4444;
    --hover: #334155;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

body.large-text {
    font-size: 112.5%;
}

body.theme-light {
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --hover: #e2e8f0;
    background-color: var(--bg-dark);
}

body.theme-light header,
body.theme-light .settings-menu,
body.theme-light .menu-section,
body.theme-light .seo-panel,
body.theme-light .content-page,
body.theme-light .result-card,
body.theme-light .stats-mini {
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

body.theme-light .seo-panel,
body.theme-light .content-page,
body.theme-light .stats-mini {
    background: rgba(255, 255, 255, 0.86);
}

body.theme-light .setting-toggle,
body.theme-light .menu-btn,
body.theme-light .option,
body.theme-light .seo-grid article,
body.theme-light .result-breakdown .row,
body.theme-light .explanation {
    background: #f1f5f9;
}

body.theme-light .subtitle {
    color: #dbeafe;
}

.app-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.app-toolbar {
    position: sticky;
    top: 12px;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    min-height: 0;
}

.settings-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.24);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
    font-size: 1.25rem;
    line-height: 1;
    text-align: center;
}

.settings-button:hover {
    background: var(--hover);
    transform: translateY(-1px);
}

.settings-menu {
    position: absolute;
    top: 52px;
    right: 0;
    width: min(290px, calc(100vw - 24px));
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.36);
}

.settings-menu.open {
    display: flex;
}

.screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: screenEnter 0.35s ease-out both;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge {
    background: var(--accent);
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

#mode-text {
    font-style: italic;
    color: var(--accent);
    font-weight: 600;
}

.card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

h1 {
    font-size: 1.6rem;
    line-height: 1.4;
    margin-bottom: 30px;
    color: #ffffff;
}

#options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* The Option Button styling */
.option {
    position: relative;
    background: var(--bg-dark);
    color: var(--text-main);
    animation: optionFadeIn 0.22s ease-out both;
    transition: transform 0.12s ease, background 0.12s ease;
    padding: 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    text-align: left;
    z-index: 1; /* Establish stacking context */
}

.option:hover:not(.disabled) {
    background: var(--hover);
    transform: translateY(-2px);
}

.option.disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.option.selected {
    background: var(--bg-dark);
    border-color: transparent;
}

/* --- THE SVG SNAKE TRACER (Seamless Loop) --- */
.tracer-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    border-radius: 12px;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tracer-svg rect {
    fill: none;
    stroke: var(--correct);
    stroke-width: 4px;
    stroke-dasharray: 20 80; /* 20% line, 80% gap */
    stroke-dashoffset: 0;
    /* Optional: drop shadow on the SVG stroke to make it glow */
    filter: drop-shadow(0 0 4px var(--correct));
}

.option.selected .tracer-svg {
    opacity: 1;
}

.option.selected .tracer-svg rect {
    animation: snake 2.5s linear infinite;
}

/* Because pathLength="100", stroke-dashoffset of -100 is exactly one full lap */
@keyframes snake {
    to { stroke-dashoffset: -100; }
}
/* Submitting States */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.option.correct-reveal {
    background: rgba(34, 197, 94, 0.1) !important;
    border-color: var(--correct) !important;
    color: var(--correct) !important;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
}
.option.correct-reveal .tracer-svg {
    display: none; /* Turn off tracer on submit */
}

.option.wrong-reveal {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: var(--incorrect) !important;
    color: var(--incorrect) !important;
}
.option.wrong-reveal .tracer-svg {
    display: none; /* Turn off tracer on submit */
}

/* Feedback Area */
#feedback-area {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 800;
    animation: fadeIn 0.3s ease;
}

.feedback-correct {
    background: rgba(34, 197, 94, 0.15);
    color: var(--correct);
    border: 1px solid var(--correct);
}

.feedback-wrong {
    background: rgba(239, 68, 68, 0.15);
    color: var(--incorrect);
    border: 1px solid var(--incorrect);
}

.hidden {
    display: none !important;
}

/* Buttons */
.controls {
    display: flex;
    justify-content: flex-end;
}

button {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

#btn-submit {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

#btn-submit:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
}

#btn-submit:disabled {
    background: var(--hover);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

#btn-next {
    background: white;
    color: var(--bg-dark);
}

#btn-next:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}

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

@keyframes flipOut {
    0%   { transform: perspective(1200px) rotateY(0deg)   scale(1);    }
    100% { transform: perspective(1200px) rotateY(90deg)  scale(0.96); }
}

@keyframes flipIn {
    0%   { transform: perspective(1200px) rotateY(-90deg) scale(0.96); }
    100% { transform: perspective(1200px) rotateY(0deg)   scale(1);    }
}

.card.flip-out {
    animation: flipOut 0.18s ease-in forwards;
}

.card.flip-in {
    animation: flipIn 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

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

@keyframes gradePop {
    0%   { opacity: 0; transform: scale(0.35); }
    65%  { opacity: 1; transform: scale(1.12); }
    100% { opacity: 1; transform: scale(1); }
}

.controls button {
    transition: transform 0.1s ease;
}
.controls button:active:not(:disabled) {
    transform: scale(0.97);
}

/* === BOOM EXPLOSION === */

/* 1. Violent Screen Shake */
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-8px, -4px); }
    20% { transform: translate(6px, 5px); }
    30% { transform: translate(-5px, 3px); }
    40% { transform: translate(7px, -6px); }
    50% { transform: translate(-3px, 4px); }
    60% { transform: translate(5px, -2px); }
    70% { transform: translate(-6px, 5px); }
    80% { transform: translate(4px, -3px); }
    90% { transform: translate(-2px, 6px); }
}

.screen-shake {
    animation: screen-shake 0.5s ease-in-out;
}

/* 2. The BOOM container overlays the entire screen */
.boom-container {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 9999;
}

/* 3. Radial Flash - bright orange flash that fades instantly */
.boom-flash {
    position: absolute;
    width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.6) 0%, transparent 70%);
    animation: flash-out 0.6s ease-out forwards;
}

@keyframes flash-out {
    0% { opacity: 1; transform: scale(0.5); }
    100% { opacity: 0; transform: scale(2); }
}

/* 4. Spark / Ember Particles */
.spark {
    position: fixed;
    top: 50%; left: 50%;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    opacity: 1;
}

@keyframes spark-fly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--dx), var(--dy)) scale(0);
        opacity: 0;
    }
}

/* ====================================================== */
/* ============== MENU SCREEN ============================= */
/* ====================================================== */

.menu-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: center;
    gap: 18px;
    text-align: left;
    padding: 28px 20px 18px;
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background:
        radial-gradient(circle at 18% 20%, rgba(34, 197, 94, 0.18), transparent 26%),
        linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(30, 41, 59, 0.44) 55%, rgba(15, 23, 42, 0.72));
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.hero-icon {
    width: 118px;
    height: 118px;
    display: block;
    border-radius: 22px;
    object-fit: cover;
    box-shadow: 0 18px 34px rgba(2, 6, 23, 0.42), 0 0 28px rgba(14, 165, 233, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-copy {
    min-width: 0;
}

.brand-kicker {
    width: fit-content;
    margin-bottom: 8px;
    padding: 5px 9px;
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.14);
    border: 1px solid rgba(34, 197, 94, 0.24);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.logo {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 5vw, 3.6rem);
    letter-spacing: 0;
    margin: 0;
    line-height: 0.95;
    color: var(--text-main);
    text-wrap: balance;
}

.subtitle {
    max-width: 520px;
    color: #cbd5e1;
    font-weight: 600;
    margin-top: 12px;
    letter-spacing: 0;
    line-height: 1.45;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

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

}

.menu-section {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-toggle {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-dark);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 700;
}

.setting-toggle input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    flex: 0 0 auto;
}

.menu-section h2 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 6px;
    font-weight: 800;
}

.menu-btn {
    background: var(--bg-dark);
    color: var(--text-main);
    padding: 14px 18px;
    font-size: 1rem;
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
    font-weight: 700;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Inter', sans-serif;
}

.menu-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: var(--hover);
}

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

.menu-btn:active:not(:disabled) {
    transform: scale(0.97) !important;
    transition: transform 0.08s ease;
}

.menu-btn.exam {
    border-color: var(--accent);
}
.menu-btn.exam:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.15);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.menu-btn.study {
    border-color: var(--correct);
}
.menu-btn.study:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.menu-btn.smart {
    border-color: #ec4899;
}
.menu-btn.smart:hover:not(:disabled) {
    background: rgba(236, 72, 153, 0.15);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.3);
}

.menu-btn.review {
    border-color: #f97316;
}
.menu-btn.review:hover:not(:disabled) {
    background: rgba(249, 115, 22, 0.15);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.3);
}

.menu-btn.drill {
    border-color: #a855f7;
}
.menu-btn.drill:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}

.menu-btn.pt-practice {
    border-color: #0ea5e9;
}
.menu-btn.pt-practice:hover:not(:disabled) {
    background: rgba(14, 165, 233, 0.15);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.3);
}

.menu-btn.diagnostic {
    border-color: #eab308;
}
.menu-btn.diagnostic:hover:not(:disabled) {
    background: rgba(234, 179, 8, 0.15);
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.3);
}

.diagnostic-rec {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 8px;
    color: #fef08a;
    font-size: 0.9rem;
    text-align: center;
}

.menu-btn .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 8px;
}

.stats-mini {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 12px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 10px;
}

.menu-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.menu-btn.small {
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    border-color: var(--text-muted);
    color: var(--text-muted);
    background: transparent;
}

.menu-btn.small:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
}

.seo-panel,
.content-page {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 24px;
}

.seo-panel h2,
.content-page h1 {
    margin-bottom: 14px;
}

.seo-panel h2 {
    font-size: 1.25rem;
}

.seo-panel p,
.content-page p,
.content-page li {
    color: var(--text-muted);
    line-height: 1.65;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 18px 0;
}

.seo-grid article {
    background: rgba(15, 23, 42, 0.75);
    border-radius: 10px;
    padding: 14px;
}

.seo-grid h3,
.content-page h2 {
    color: var(--text-main);
    margin-bottom: 8px;
}

.seo-grid h3 {
    font-size: 1rem;
}

.disclaimer,
.muted-note {
    font-size: 0.92rem;
}

.page-container {
    max-width: 820px;
}

.content-page {
    margin-top: 20px;
}

.content-page h1 {
    font-size: 2rem;
}

.content-page h2 {
    font-size: 1.2rem;
    margin-top: 24px;
}

.content-page ul {
    margin-left: 22px;
}

.content-page a,
.site-footer a,
.back-link {
    color: var(--text-main);
}

.back-link {
    display: inline-block;
    margin-bottom: 18px;
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.site-footer {
    padding: 18px 0 8px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
}

.ad-slot {
    width: 100%;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-slot .adsbygoogle {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
}

.ad-slot-top-outer {
    position: relative;
    padding-top: 90px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px 12px 0 0;
}

.ad-slot-top-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.ad-slot-result {
    margin: 12px 0;
    min-height: 60px;
}

.ad-slot-result .adsbygoogle {
    min-height: 60px;
}

.site-footer nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 10px;
}

.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--text-main);
}

@media (max-width: 768px) {
    .seo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ====================================================== */
/* ============== QUIZ HEADER EXTRAS ====================== */
/* ====================================================== */

.quit-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quit-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--incorrect);
    color: var(--incorrect);
}

/* ====================================================== */
/* ============== PROGRESS BAR ============================ */
/* ====================================================== */

.progress-bar {
    height: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--correct));
    border-radius: 6px;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================================================== */
/* ============== EXPLANATION FIELD ======================= */
/* ====================================================== */

.explanation {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-main);
    text-align: left;
    line-height: 1.5;
}

/* ====================================================== */
/* ============== KEYBOARD HINT FOOTER ==================== */
/* ====================================================== */

.kbd-hints {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 1px;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .kbd-hints {
        display: none;
    }
}

/* ====================================================== */
/* ============== RESULT SCREEN =========================== */
/* ====================================================== */

.result-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.result-grade {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 4rem;
    color: var(--accent);
    text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
    margin-bottom: 12px;
    animation: gradePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.result-pct {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
    animation: fadeIn 0.35s ease 0.28s both;
}

.result-passfail {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    animation: fadeIn 0.35s ease 0.46s both;
    padding: 10px 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    letter-spacing: 3px;
}

.result-passfail.pass {
    background: rgba(34, 197, 94, 0.2);
    color: var(--correct);
    border: 2px solid var(--correct);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.result-passfail.fail {
    background: rgba(239, 68, 68, 0.2);
    color: var(--incorrect);
    border: 2px solid var(--incorrect);
}

.result-summary {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 24px;
    animation: fadeIn 0.35s ease 0.6s both;
}

.result-breakdown {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
    animation: fadeIn 0.35s ease 0.72s both;
}

.result-breakdown h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.result-breakdown .row {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    margin-bottom: 8px;
    font-weight: 600;
}

.result-breakdown .row .pct {
    color: var(--accent);
}

.result-breakdown .row.weak .pct {
    color: var(--incorrect);
}

.result-breakdown .row.strong .pct {
    color: var(--correct);
}

.result-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

#btn-back-menu {
    background: white;
    color: var(--bg-dark);
}

#btn-back-menu:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}

#btn-review-missed-now {
    background: #f97316;
    color: white;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

#btn-review-missed-now:hover {
    background: #fb923c;
    transform: translateY(-2px);
}

@media (max-width: 640px) {
    body {
        align-items: flex-start;
        padding: 12px;
    }

    .app-container,
    .screen {
        gap: 14px;
    }

    .app-toolbar {
        top: 8px;
    }

    .menu-hero {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 12px;
        padding: 18px 14px;
    }

    .hero-icon {
        width: 88px;
        height: 88px;
        border-radius: 18px;
    }

    .brand-kicker {
        margin-inline: auto;
    }

    .logo {
        font-size: 2.05rem;
    }

    .subtitle {
        margin-top: 8px;
        font-size: 0.95rem;
    }

    header {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px 10px;
        align-items: center;
        padding: 12px;
    }

    #section-badge,
    #progress-text,
    #mode-text {
        min-width: 0;
    }

    #mode-text {
        grid-column: 1 / -1;
        font-size: 0.9rem;
    }

    .quit-btn {
        grid-row: 1 / 3;
        grid-column: 2;
        align-self: start;
        padding: 7px 12px;
    }

    .card,
    .result-card {
        padding: 22px 16px;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.25rem;
        margin-bottom: 18px;
    }

    #options-container {
        gap: 10px;
    }

    .option {
        padding: 15px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .controls {
        justify-content: stretch;
    }

    .controls button {
        width: 100%;
    }

    button {
        padding: 13px 18px;
        font-size: 1rem;
    }

    .menu-footer {
        flex-direction: column;
    }

    .menu-btn.small {
        justify-content: center;
    }

    .ad-slot {
        min-height: 80px;
    }

    .seo-panel,
    .content-page {
        padding: 18px 16px;
        border-radius: 14px;
    }

    .seo-grid {
        grid-template-columns: 1fr;
    }

    .content-page h1 {
        font-size: 1.55rem;
    }

    .result-grade {
        font-size: 3rem;
    }

    .result-pct {
        font-size: 2rem;
    }
}

/* ====================================================== */
/* ============== MODAL & PT CHART ======================== */
/* ====================================================== */

.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

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

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--accent);
}

.table-responsive {
    overflow-x: auto;
}

.pt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.pt-table th, .pt-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.pt-table th {
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    font-weight: 700;
}

.pt-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.pt-table tbody tr:hover {
    background: rgba(14, 165, 233, 0.1);
}

.pt-chart-btn {
    background: rgba(14, 165, 233, 0.15);
    color: #0ea5e9;
    border: 1px solid #0ea5e9;
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-right: 10px;
}

.pt-chart-btn:hover {
    background: #0ea5e9;
    color: white;
}

@media (max-width: 640px) {
    .modal-content {
        padding: 16px 12px;
        max-height: 95vh;
    }

    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }

    .pt-table th, .pt-table td {
        padding: 8px 4px;
        font-size: 0.85rem;
    }

    .close-btn {
        top: 10px;
        right: 10px;
    }
}

/* ====================================================== */
/* ============== PROGRESS DASHBOARD ===================== */
/* ====================================================== */

/* Stats mini bar: inline with dashboard button */
.stats-mini-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-mini-bar .stats-mini {
    flex: 1;
}

.menu-btn.dashboard-btn {
    flex: 0 0 auto;
    padding: 10px 16px;
    font-size: 0.9rem;
    border-color: #a855f7;
    color: var(--text-main);
    background: rgba(168, 85, 247, 0.1);
    white-space: nowrap;
}

.menu-btn.dashboard-btn:hover {
    background: rgba(168, 85, 247, 0.25);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
    transform: translateY(-2px);
}

/* Dashboard header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
}

.dashboard-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.dashboard-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* KPI Strip */
.dashboard-kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 18px 14px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.kpi-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 6px;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* Section label */
.dashboard-section-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 0 2px;
}

/* Per-section readiness cards grid */
.dashboard-sections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.dash-section-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dash-section-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.dash-section-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-section-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.dash-readiness-badge {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1.5px solid;
}

.dash-readiness-bar-bg {
    height: 8px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    overflow: hidden;
}

.dash-readiness-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

.dash-section-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.dash-stat {
    text-align: center;
    padding: 8px 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.dash-stat-val {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.dash-stat-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Color helpers */
.mastered-color { color: #22c55e; }
.weak-color     { color: #f97316; }
.muted-color    { color: #94a3b8; }
.accent-color   { color: #3b82f6; }

/* History feed */
.dashboard-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: background 0.15s ease;
}

.history-row:hover {
    background: var(--hover);
}

.history-mode {
    font-weight: 700;
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-score {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}

.history-pct {
    color: var(--accent);
}

.history-badge {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.history-pass {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.history-fail {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.dash-empty {
    color: var(--text-muted);
    font-size: 0.95rem;
    text-align: center;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Light theme overrides */
body.theme-light .dash-section-card,
body.theme-light .kpi-card,
body.theme-light .history-row,
body.theme-light .dashboard-header {
    border-color: rgba(15, 23, 42, 0.1);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

body.theme-light .dash-stat {
    background: rgba(15, 23, 42, 0.06);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-kpi-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stats-mini-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .menu-btn.dashboard-btn {
        justify-content: center;
    }

    .dashboard-header {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .dashboard-title {
        font-size: 1.2rem;
    }

    .dashboard-kpi-strip {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .dashboard-sections-grid {
        grid-template-columns: 1fr;
    }

    .dash-section-stats {
        grid-template-columns: repeat(4, 1fr);
    }

    .history-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .history-date {
        width: 100%;
    }
}
