* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* PWA update toast */
.pwa-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}
.pwa-toast.visible { transform: translateX(-50%) translateY(0); }
.pwa-toast button {
    background: #50e6ff;
    color: #222;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* Install floating button */
.install-fab {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 9999;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(6px);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.install-fab:hover { background: rgba(0,0,0,0.5); }

/* Space for floating install button */
body { padding-bottom: 60px; }

/* Hamburger menu */
.hamburger-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10001;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.hamburger-btn:hover { background: rgba(0,0,0,0.4); }

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 10002;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.menu-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: #fff;
    z-index: 10003;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
    overflow-y: auto;
}
.menu-drawer.open { right: 0; }

.menu-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.6rem;
    color: #666;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.menu-close:hover { color: #222; }

.menu-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e0e0e0;
    padding: 50px 16px 0;
}
.menu-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.menu-tab:hover { color: #0078d4; }
.menu-tab.active {
    color: #0078d4;
    border-bottom-color: #0078d4;
}

.menu-panel {
    display: none;
    padding: 20px 16px;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.6;
}
.menu-panel.active { display: block; }
.menu-panel h3 {
    color: #0078d4;
    font-size: 1rem;
    margin: 16px 0 8px;
}
.menu-panel h3:first-child { margin-top: 0; }
.menu-panel ul, .menu-panel ol {
    margin: 0 0 12px 20px;
    padding: 0;
}
.menu-panel li { margin: 4px 0; }
.menu-panel p { margin: 8px 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0078d4 0%, #004578 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Landing Page */
.hero {
    text-align: center;
    padding: 80px 20px;
    color: white;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.hero h2 {
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 10px;
    opacity: 0.9;
}

.hero .subtitle {
    font-size: 1.1rem;
    opacity: 0.75;
    margin-bottom: 40px;
}

.info-cards {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 50px;
    flex-wrap: wrap;
}

.info-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.info-number {
    font-size: 2rem;
    font-weight: 700;
}

.info-label {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Buttons */
.btn {
    padding: 14px 40px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: white;
    color: #0078d4;
}

.btn-primary:hover {
    background: #e6e6e6;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-submit {
    background: #28a745;
    color: white;
}

.btn-submit:hover {
    background: #218838;
}

/* Quiz Page */
.quiz-header {
    margin-bottom: 30px;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: #50e6ff;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    color: white;
    font-size: 0.9rem;
    opacity: 0.9;
    padding-right: 44px;
}

.question-container {
    background: white;
    border-radius: 12px;
    padding: 35px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-height: 350px;
}

.question-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 25px;
    color: #222;
}

.question-text:focus {
    outline: none;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    line-height: 1.4;
}

.option:hover {
    border-color: #0078d4;
    background: #f0f7ff;
}

.option.selected {
    border-color: #0078d4;
    background: #e3f2fd;
    font-weight: 500;
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Results Page */
.results-container {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.results-container h2 {
    margin-bottom: 30px;
    color: #222;
}

.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    border: 8px solid;
}

.score-circle.pass {
    border-color: #28a745;
    color: #28a745;
}

.score-circle.fail {
    border-color: #dc3545;
    color: #dc3545;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.result-message {
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.result-message.pass {
    color: #28a745;
}

.result-message.fail {
    color: #dc3545;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.result-stats span {
    font-size: 0.95rem;
    color: #555;
}

/* Review */
.review-container {
    text-align: left;
    margin-bottom: 30px;
}

.review-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 12px;
}

.review-item.correct {
    border-left: 4px solid #28a745;
}

.review-item.incorrect {
    border-left: 4px solid #dc3545;
}

.review-question {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.review-answer {
    font-size: 0.9rem;
    color: #555;
    margin: 4px 0;
}

.review-answer.user-wrong {
    color: #dc3545;
    text-decoration: line-through;
}

.review-answer.correct-answer {
    color: #28a745;
    font-weight: 600;
}

.review-answer-list {
    font-size: 0.9rem;
    margin: 4px 0 4px 20px;
    padding: 0;
    list-style: disc;
}

.review-answer-list.user-wrong {
    color: #dc3545;
    text-decoration: line-through;
}

.review-answer-list.correct-answer {
    color: #28a745;
    font-weight: 600;
}

.review-answer-list li {
    margin: 2px 0;
}

.review-explanation {
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-style: italic;
}

/* Responsive */
@media (max-width: 600px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    .question-container {
        padding: 20px;
    }

    .info-cards {
        gap: 15px;
    }

    .info-card {
        padding: 15px 20px;
    }

    .result-stats {
        gap: 20px;
    }
}

/* Question type hints */
.single-select-hint {
    font-size: 0.85rem;
    color: #0078d4;
    font-weight: 600;
    margin-bottom: 10px;
    font-style: italic;
}

.multi-select-hint {
    font-size: 0.9rem;
    color: #004578;
    font-weight: 700;
    margin-bottom: 12px;
    padding: 8px 14px;
    background: #e3f2fd;
    border-left: 4px solid #0078d4;
    border-radius: 4px;
}

/* Single-select questions (radio) */
.option.single {
    padding-left: 40px;
    position: relative;
}

.option.single::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 50%;
    background: white;
    transition: all 0.2s ease;
}

.option.single.selected::before {
    border-color: #0078d4;
}

.option.single.selected::after {
    content: '';
    position: absolute;
    left: 17px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #0078d4;
}

/* Multi-select questions (checkbox) */
.option.multi {
    padding-left: 40px;
    position: relative;
}

.option.multi::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    background: white;
    transition: all 0.2s ease;
}

.option.multi.selected::before {
    background: #0078d4;
    border-color: #0078d4;
}

.option.multi.selected::after {
    content: '\2713';
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
}

/* Focus styles for keyboard navigation */
.option:focus {
    outline: none;
}

.option:focus-visible {
    outline: 2px solid #0078d4;
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid #0078d4;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Guide Page (guide.html)
   ======================================== */

.guide-page {
    background: linear-gradient(135deg, #0078d4 0%, #004578 100%);
    color: #1e1e1e;
    min-height: 100vh;
}

.guide-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.guide-header {
    text-align: center;
    padding: 40px 20px 10px;
}

.guide-header h1 {
    color: white;
    font-size: 2.2rem;
    font-weight: 700;
}

.guide-subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 20px;
}

.guide-back {
    display: inline-block;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}

.guide-back:hover {
    color: white;
    text-decoration: underline;
}

/* Tabs */
.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0;
}

.guide-page .tab-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #0078d4 0%, #004578 100%);
    padding-top: 8px;
}

.tab-btn {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    color: white;
    border-bottom-color: #50e6ff;
}

.tab-panel {
    position: absolute;
    left: -10000px;
    top: auto;
    visibility: visible;
}

.tab-panel.active {
    position: static;
    left: auto;
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}



.guide-page .section {
    background: #f8fafc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: none;
}

.guide-page .section h2 {
    color: #005fb8;
    margin-bottom: 15px;
}

.guide-page .section h3 {
    color: #005fb8;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.card {
    border-left: 5px solid #005fb8;
    padding: 15px;
    background: #fafafa;
    border-radius: 6px;
}

.card.weak {
    border-left-color: #c62828;
}

.card ul {
    margin: 8px 0 8px 20px;
    padding: 0;
}

.card li {
    margin: 4px 0;
}

.keywords {
    background: #eef6ff;
    padding: 8px;
    font-size: 0.9em;
    border-radius: 4px;
    margin-top: 6px;
}

.selfcheck {
    background: #fff3e0;
    padding: 8px;
    font-size: 0.9em;
    border-radius: 4px;
    margin-top: 6px;
}

.trap {
    background: #fdecea;
    padding: 8px;
    font-size: 0.9em;
    border-radius: 4px;
    margin-top: 6px;
}

.guide-footer {
    text-align: center;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.6);
    padding: 20px;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
}

.compare-table th,
.compare-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.compare-table th {
    background: #eef6ff;
    color: #005fb8;
    font-weight: 600;
}

.compare-table tr:nth-child(even) {
    background: #fafafa;
}

.checklist {
    background: #e8f5e9;
    border-left: 5px solid #28a745;
    padding: 15px 20px;
    border-radius: 6px;
    margin-top: 10px;
}

.checklist ol {
    margin: 8px 0 0 20px;
    padding: 0;
}

.checklist li {
    margin: 6px 0;
}

.can-do {
    color: #28a745;
    font-weight: 600;
}

.cannot-do {
    color: #c62828;
    font-weight: 600;
}

/* Vertical sub-tabs within each horizontal tab */
.vtab-layout {
    display: flex;
    gap: 0;
    min-height: 400px;
}

.vtab-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    max-width: 200px;
    border-right: 2px solid #ddd;
    padding-right: 0;
    flex-shrink: 0;
}

.vtab-btn {
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    border-left: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vtab-btn:hover {
    color: #005fb8;
    background: #f0f7ff;
}

.vtab-btn.active {
    color: #005fb8;
    border-left-color: #005fb8;
    background: #eef6ff;
}

.vtab-content {
    flex: 1;
    padding-left: 20px;
    min-width: 0;
}

.vtab-pane {
    position: absolute;
    left: -10000px;
    top: auto;
    visibility: visible;
}

.vtab-pane.active {
    position: static;
    left: auto;
}

/* Show All mode — expand everything for reading / Listen to this page */
.show-all-btn {
    padding: 8px 20px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.show-all-btn:hover {
    background: rgba(255,255,255,0.25);
}
.show-all-btn[aria-pressed="true"] {
    background: #50e6ff;
    color: #004578;
    border-color: #50e6ff;
}

.guide-audio {
    text-align: center;
    margin-bottom: 20px;
}
.guide-audio-label {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.guide-page.show-all .tab-bar {
    display: none;
}
.guide-page.show-all .tab-panel {
    position: static;
    left: auto;
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.guide-page.show-all .vtab-sidebar {
    display: none;
}
.guide-page.show-all .vtab-layout {
    display: block;
}
.guide-page.show-all .vtab-content {
    padding-left: 0;
}
.guide-page.show-all .vtab-pane {
    position: static;
    left: auto;
}

@media (max-width: 600px) {
    .guide-header h1 {
        font-size: 1.6rem;
    }

    .guide-page .card-grid {
        grid-template-columns: 1fr;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .vtab-layout {
        flex-direction: column;
    }

    .vtab-sidebar {
        flex-direction: row;
        min-width: 0;
        max-width: none;
        border-right: none;
        border-bottom: 2px solid #ddd;
        overflow-x: auto;
        padding-bottom: 0;
    }

    .vtab-btn {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .vtab-btn.active {
        border-left-color: transparent;
        border-bottom-color: #005fb8;
    }

    .vtab-content {
        padding-left: 0;
        padding-top: 16px;
    }
}
