/* CSS Canvas Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    border-radius: 0;
    box-shadow: none;
    font-family: "Microsoft JhengHei", Arial, sans-serif;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Background */
body {
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* 1024x768 Outer Container */
.container {
    width: 1024px;
    height: 768px;
    background-color: #00b4e0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    filter: blur(0.55px) contrast(1.04);
}

/* Main App Window */
.vqc-window {
    width: 900px;
    height: 650px;
    background-color: #e8e8e8;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
    background-color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px;
    height: 72px;
    border-bottom: 2px solid #d0d0d0;
    flex-shrink: 0;
}

.header-content {
    text-align: center;
}

.header-content h1 {
    font-size: 19px;
    color: #cc0000;
    font-weight: bold;
}

.header-content .subtitle {
    font-size: 13px;
    color: #800080;
}

.header-content .instruction {
    font-size: 17px;
    color: #0055bb;
    font-weight: bold;
}

/* ── Tab Bar ──────────────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    background-color: #003a6e;
    height: 32px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 0 20px;
    font-size: 14px;
    font-weight: bold;
    color: #88bbdd;
    background: transparent;
    cursor: pointer;
    height: 100%;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: #ffffff;
    background-color: #005099;
    border-bottom: 3px solid #00c8f0;
}

.tab-btn:hover:not(.active) {
    background-color: #004488;
    color: #ddeeff;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 14px 22px;
    background-color: #e8e8e8;
    overflow: hidden;
}

.panel.active {
    display: flex;
}

/* ── Dictionary Panel ─────────────────────────────────────────────────────── */
.dict-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 10px 0;
    background-color: #e8e8e8;
    flex-shrink: 0;
}

.dict-search-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 16px;
    background-color: #ffffff;
    border: 2px solid #cccccc;
    color: #000;
}

.dict-search-input:focus {
    border-color: #0066cc;
}

.dict-sort-select {
    padding: 6px 8px;
    font-size: 14px;
    background-color: #dcdcdc;
    color: #000;
    cursor: pointer;
    flex-shrink: 0;
}

.dict-count {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
    min-width: 78px;
    text-align: right;
}

.dict-list {
    flex: 1;
    overflow-y: auto;
    background-color: #ffffff;
}

.dict-row {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    border-bottom: 1px solid #eeeeee;
    gap: 10px;
}

.dict-row-alt {
    background-color: #f4f8ff;
}

.dict-row:hover {
    background-color: #d8eeff !important;
}

.dict-num {
    font-size: 12px;
    color: #bbb;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

.dict-word {
    font-size: 16px;
    font-weight: bold;
    color: #003d99;
    min-width: 140px;
    flex-shrink: 0;
}

.dict-meaning {
    font-size: 15px;
    color: #222;
    flex: 1;
}

.dict-play {
    background: linear-gradient(to bottom, #28ccf0 0%, #009dc8 50%, #007099 100%);
    border-bottom: 2px solid #004f70;
    border-top:    1px solid rgba(255,255,255,0.25);
    box-shadow: 0 2px 0 #003a55, inset 0 1px 0 rgba(255,255,255,0.2);
    color: white;
    padding: 3px 10px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.05s;
}

.dict-play:hover {
    background: linear-gradient(to bottom, #18b8e0 0%, #0088b0 50%, #005e88 100%);
}

.dict-play:active {
    border-bottom: 1px solid #003a55;
    box-shadow: 0 1px 0 #003a55;
    transform: translateY(1px);
}

.dict-no-results {
    padding: 40px;
    text-align: center;
    font-size: 18px;
    color: #999;
}

/* ── Practice Setup ───────────────────────────────────────────────────────── */
.setup-layout {
    display: flex;
    gap: 14px;
    flex: 1;
}

.setup-left {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setup-right {
    flex: 1;
}

.panel-box {
    background-color: #ffffff;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.box-title {
    color: #0055bb;
    font-size: 17px;
    font-weight: bold;
    padding: 10px 12px;
    border-bottom: 2px solid #e8e8e8;
}

.settings-box {
    background-color: #ffffff;
    padding: 14px;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: bold;
}

.flat-input-small {
    background-color: #e0e0e0;
    padding: 7px;
    width: 58px;
    margin-left: 10px;
    font-size: 16px;
    text-align: center;
}

/* ── Flat Rows & Checkboxes ───────────────────────────────────────────────── */
.module-grid {
    display: flex;
    flex-direction: column;
}

.flat-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background-color: #ffffff;
    cursor: pointer;
    font-size: 17px;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
}

.flat-row:hover {
    background-color: #f5f8ff;
}

/* Module SVG icon alignment */
.module-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.flat-cb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background-color: #fdf5e6;
    border: 1px solid #a9a9a9;
    margin-right: 6px;
    position: relative;
    flex-shrink: 0;
}

.flat-cb:checked::after {
    content: '✔';
    color: #cc0000;
    font-size: 18px;
    font-weight: bold;
    position: absolute;
    top: -3px;
    left: 1px;
}

/* ── Action Bars & Flat Buttons ───────────────────────────────────────────── */
.action-bar {
    display: flex;
    justify-content: center;
    gap: 35px;
    padding: 13px;
    background-color: #d8d8d8;
    margin: 8px -22px 0 -22px;
    flex-shrink: 0;
}

.flat-btn {
    padding: 11px 36px;
    font-size: 19px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    transition: background 0.08s, transform 0.05s, box-shadow 0.05s;
    position: relative;
}

/* ── 2.5D Cyan Button ─────────────────────────────────────────────────────── */
.cyan-btn {
    /* Gradient: bright highlight at top → main colour → slightly darker at base */
    background: linear-gradient(
        to bottom,
        #3ad8ff 0%,
        #10b8e4 18%,
        #009dc8 50%,
        #0086b0 80%,
        #006e96 100%
    );
    /* Dark bottom ledge gives the "raised platform" illusion */
    border-bottom: 4px solid #004f70;
    border-right:  2px solid #005f84;
    border-top:    1px solid rgba(255,255,255,0.35);
    border-left:   1px solid rgba(255,255,255,0.15);
    /* Outer shadow deepens the depth */
    box-shadow:
        0 4px 0 #003a55,
        inset 0 1px 0 rgba(255,255,255,0.25);
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.cyan-btn:hover {
    background: linear-gradient(
        to bottom,
        #28ccf4 0%,
        #08aad8 18%,
        #008eba 50%,
        #0077a0 80%,
        #006288 100%
    );
}

/* Pressed: button sinks down by consuming the bottom ledge */
.cyan-btn:active {
    background: linear-gradient(
        to bottom,
        #0070a0 0%,
        #009dc8 100%
    );
    border-bottom: 1px solid #003a55;
    border-top:    1px solid rgba(0,0,0,0.2);
    box-shadow:
        0 1px 0 #003a55,
        inset 0 2px 3px rgba(0,0,0,0.2);
    transform: translateY(3px);
    text-shadow: none;
}

.full-width {
    width: 100%;
    margin-bottom: 10px;
    padding: 13px 0;
}

/* ── Game Screen ──────────────────────────────────────────────────────────── */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: bold;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.game-header-label {
    color: #0055bb;
    flex: 1;
}

.timer-display {
    color: #000;
    font-size: 16px;
}

/* Skip button "›" in game header */
.skip-btn {
    background: linear-gradient(to bottom, #3ad8ff 0%, #009dc8 50%, #006e96 100%);
    border-bottom: 3px solid #004f70;
    border-top:    1px solid rgba(255,255,255,0.3);
    box-shadow: 0 3px 0 #003a55, inset 0 1px 0 rgba(255,255,255,0.2);
    color: #ffffff;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 12px 4px 12px;
    margin-left: 12px;
    line-height: 1;
    transition: transform 0.05s, box-shadow 0.05s;
}

.skip-btn:hover {
    background: linear-gradient(to bottom, #28ccf4 0%, #0088b2 50%, #006080 100%);
}

.skip-btn:active {
    background: linear-gradient(to bottom, #006080 0%, #009dc8 100%);
    border-bottom: 1px solid #003a55;
    box-shadow: 0 1px 0 #003a55, inset 0 2px 3px rgba(0,0,0,0.2);
    transform: translateY(2px);
}

.question-area {
    background-color: #e8e8e8;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.question-prompt {
    font-size: 26px;
    color: #000;
    margin-bottom: 16px;
    padding: 4px 0;
}

/* ── MCQ Options Grid ─────────────────────────────────────────────────────── */
.options-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #ffffff;
}

.option-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    background-color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    color: #000;
    border-bottom: 1px solid #e8e8e8;
    width: 100%;
    text-align: left;
}

.option-btn:hover {
    background-color: #d8f0ff;
}

/* Right-pointing arrow chevron (matches screenshot) */
.option-btn::after {
    content: '›';
    font-size: 28px;
    color: #009dc8;
    font-weight: bold;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 10px;
}

.option-btn.correct {
    background-color: #c8ecd8;
    color: #155724;
}

.option-btn.wrong {
    background-color: #f8d7da;
    color: #721c24;
}

/* ── Parts 5 & 6 Listening Rows ─────────────────────────────────────────── */
.listening-option-row {
    display: flex;
    align-items: center;
    background-color: transparent;
    border-bottom: 1px solid #d0d0d0;
    cursor: pointer;
    width: 100%;
}

.listening-option-row.disabled {
    cursor: default;
    pointer-events: none;
}

.speaker-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(to bottom, #3ad8ff 0%, #009dc8 50%, #006e96 100%);
    border: none;
    border-right: 1px solid rgba(0,0,0,0.1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.speaker-btn:hover {
    background: linear-gradient(to bottom, #28ccf4 0%, #0088b2 50%, #006080 100%);
}

.speaker-btn:active {
    background: linear-gradient(to bottom, #006080 0%, #009dc8 100%);
}

.speaker-btn.playing {
    background: linear-gradient(to bottom, #ffaa00 0%, #ff8800 100%);
    box-shadow: 0 0 8px rgba(255,170,0,0.5);
}

.answer-select-area {
    flex: 1;
    padding-left: 20px;
    font-size: 24px;
    color: #000;
    display: flex;
    align-items: center;
    height: 60px;
    background-color: transparent;
}

.listening-option-row:hover .answer-select-area {
    background-color: #d8f0ff;
}

.listening-option-row.correct .answer-select-area {
    background-color: #c8ecd8;
    color: #155724;
}

.listening-option-row.wrong .answer-select-area {
    background-color: #f8d7da;
    color: #721c24;
}

/* ── Parts 5 & 6 Audio-select rows ───────────────────────────────────────── */
.play-icon-btn {
    background-color: #009dc8;
    color: white;
    padding: 8px 18px;
    font-size: 18px;
    cursor: pointer;
}

.play-icon-btn:hover { background-color: #007799; }
.play-icon-btn:active { background-color: #005577; }

.play-icon-btn.playing {
    background-color: #ff8800;
}

/* ── Typing Input (Part 1) ────────────────────────────────────────────────── */
.flat-text-input {
    width: 100%;
    padding: 13px;
    font-size: 22px;
    background-color: #ffffff;
    border: 2px solid #aaaaaa;
    margin-bottom: 8px;
}

.char-counter {
    font-size: 17px;
    color: #444;
    margin-bottom: 8px;
}

/* ── Status Bar ───────────────────────────────────────────────────────────── */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 10px 22px;
    background-color: #d8d8d8;
    font-size: 14px;
    margin: 0 -22px;
    flex-shrink: 0;
}

.status-left {
    color: #444;
    line-height: 1.5;
    flex: 1;
}

.status-right {
    font-size: 18px;
    color: #000;
    font-weight: bold;
    white-space: nowrap;
}

/* ── Confirm Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-box {
    background-color: #e0e0e0;
    padding: 36px;
    width: 490px;
}

.modal-box p {
    color: #0044aa;
    font-size: 19px;
    line-height: 1.6;
    margin-bottom: 36px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 70px;
}

/* ── Results ──────────────────────────────────────────────────────────────── */
.results-layout {
    display: flex;
    gap: 18px;
    flex: 1;
    margin-top: 8px;
    overflow: hidden;
}

.results-main {
    flex: 1;
    background-color: #ffffff;
    padding: 18px;
    font-size: 17px;
    line-height: 1.9;
    color: #222;
    overflow-y: auto;
}

.results-sidebar {
    flex: 0 0 150px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.results-action-bar {
    display: flex;
    justify-content: flex-start;
    padding: 10px 0 0 0;
    flex-shrink: 0;
}

.results-action-bar .flat-btn {
    padding: 10px 30px;
}

/* ── Feedback Banner (hidden — silent scoring) ────────────────────────────── */
.feedback-banner {
    margin: 6px 0;
    padding: 8px;
    font-weight: bold;
    text-align: center;
    font-size: 18px;
}

.feedback-correct {
    background-color: #c8ecd8;
    color: #155724;
}

.feedback-wrong {
    background-color: #f8d7da;
    color: #721c24;
}

.hidden {
    display: none !important;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    background-color: #003a6e;
    color: #ffff00;
    display: flex;
    justify-content: space-between;
    padding: 7px 18px;
    font-size: 13px;
    flex-shrink: 0;
}

.footer span {
    color: #ffffff;
}

/* ── Dictionary Star & Notes ─────────────────────────────────────────────── */
.dict-star {
    font-size: 20px;
    color: #ccc;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    padding: 0 5px;
    transition: color 0.2s;
}

.dict-star:hover {
    color: #ffcc00;
}

.dict-star.starred {
    color: #ffaa00;
}

.dict-note-input {
    width: 100%;
    padding: 6px;
    margin-top: 6px;
    font-size: 14px;
    border: 1px solid #ccc;
    background-color: #fff9e6;
    color: #333;
}

.dict-row-container {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #eeeeee;
}

.dict-row-container .dict-row {
    border-bottom: none;
}

.dict-note-wrapper {
    padding: 0 12px 10px 45px;
    display: none;
    background-color: inherit;
}

.dict-note-wrapper.show {
    display: block;
}

/* ── Normal Theme Overrides ──────────────────────────────────────────────── */
body.normal-theme {
    background-color: #f5f5f5;
}
body.normal-theme .container {
    filter: none;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
}
body.normal-theme .vqc-window {
    background-color: #ffffff;
    border-radius: 8px;
}
body.normal-theme .header {
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
}
body.normal-theme .tab-bar {
    background-color: #e9ecef;
}
body.normal-theme .tab-btn {
    color: #495057;
}
body.normal-theme .tab-btn.active {
    background-color: #ffffff;
    color: #0056b3;
    border-bottom: 3px solid #0056b3;
}
body.normal-theme .tab-btn:hover:not(.active) {
    background-color: #dee2e6;
    color: #212529;
}
body.normal-theme .panel {
    background-color: #ffffff;
}
body.normal-theme .dict-toolbar {
    background-color: #ffffff;
}
body.normal-theme .dict-row-alt {
    background-color: #f8f9fa;
}
body.normal-theme .panel-box, body.normal-theme .settings-box, body.normal-theme .flat-row {
    background-color: #ffffff;
    border: 1px solid #eee;
    box-shadow: none;
}
body.normal-theme .action-bar, body.normal-theme .status-bar {
    background-color: #f8f9fa;
}
body.normal-theme .footer {
    background-color: #343a40;
    color: #f8f9fa;
}

/* ── Mobile Responsiveness ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .container {
        width: 100%;
        height: 100%;
        min-height: 100vh;
        border-radius: 0 !important;
    }
    .vqc-window {
        width: 100%;
        height: 100%;
        min-height: 100vh;
        border-radius: 0 !important;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
    }
    .logo-glad, .logo-vqc {
        transform: scale(0.8);
    }
    .setup-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    .setup-left, .setup-right {
        flex: none;
    }
    .action-bar {
        flex-wrap: wrap;
        gap: 10px;
    }
    .modal-box {
        width: 90%;
        padding: 20px;
    }
    .dict-toolbar {
        flex-wrap: wrap;
    }
    .dict-search-input {
        width: 100%;
        flex: none;
    }
    .results-layout {
        flex-direction: column;
        overflow-y: auto;
    }
    .results-sidebar {
        flex-direction: row;
        flex: none;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 10px;
    }
    .results-sidebar .full-width {
        width: auto;
        flex: 1;
        min-width: 100px;
    }
}
