@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/space-grotesk-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/space-grotesk-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Space Grotesk';
    src: url('fonts/space-grotesk-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #EAEEF2;
    color: #2D2D2D;
    line-height: 1.5;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    padding-top: 12px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
}

/* Button Styles */
.btn-primary {
    background: #2D5A8E;
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    flex-shrink: 0;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:active {
    opacity: 0.8;
}

.btn-primary:disabled {
    background: #D5D5D3;
    color: #999;
    cursor: not-allowed;
}

.btn-secondary {
    background: #EAEEF2;
    color: #2D2D2D;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 4px 4px 8px #d0d4d8, -4px -4px 8px #ffffff;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-secondary:hover {
    box-shadow: 6px 6px 12px #d0d4d8, -6px -6px 12px #ffffff;
}

/* Article Buttons */
.article-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-family: inherit;
    color: white;
    box-shadow: 6px 6px 12px #d0d4d8, -6px -6px 12px #ffffff;
}

.article-btn.masc { background: #5B7AA5; }
.article-btn.fem { background: #B56576; }
.article-btn.neut { background: #6A8D73; }

.article-btn:hover:not(:disabled) {
    transform: scale(1.02);
}

.article-btn:active:not(:disabled),
.article-btn.selected {
    box-shadow: inset 3px 3px 6px rgba(0,0,0,0.15);
    transform: scale(0.98);
}

.article-btn.correct {
    background: #4A7C59 !important;
}

.article-btn.wrong {
    background: #C44536 !important;
}

.article-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.article-btn .article {
    font-size: 36px;
    font-weight: 700;
}

.article-btn .gender {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress Dots */
.progress-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
    max-width: 100%;
    flex-shrink: 0;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: #cdd1d5;
    transition: all 0.3s ease;
}

.dot.active {
    background: #2D5A8E;
    width: 28px;
    border-radius: 3px;
}

.dot.completed {
    background: #4A7C59;
}

.dot.wrong {
    background: #C44536;
}

/* Page Sections */
.page {
    display: none;
    visibility: hidden;
    animation: fadeIn 0.3s ease;
    overflow: hidden;
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: -1;
    opacity: 0;
}

.page.active {
    display: block;
    visibility: visible;
    position: relative;
    top: auto;
    left: auto;
    z-index: 1;
    opacity: 1;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Game pages (practice/quiz) */
.page.game-page.active {
    display: block;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

.game-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 0;
}

.game-card .word-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.game-stat {
    color: #333;
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(30%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-30%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Feedback overlay */
.feedback-overlay {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 28px;
    font-weight: 700;
    color: white;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 20px;
    max-width: 360px;
    width: 90%;
    text-align: center;
}
.modal-box p {
    font-size: 15px;
    color: #333;
    line-height: 1.5;
    margin-bottom: 20px;
    white-space: pre-line;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.modal-actions button {
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
}
.modal-btn-primary {
    background: #2D5A8E;
    color: #fff;
}
.modal-btn-cancel {
    background: #dde1e5;
    color: #555;
}

/* Download progress bar */
.download-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 10px 20px;
    z-index: 150;
    display: none;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.download-bar.show { display: flex; }
.download-bar-label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}
.download-bar-track {
    flex: 1;
    height: 6px;
    background: #dde1e5;
    border-radius: 3px;
    overflow: hidden;
}
.download-bar-fill {
    height: 100%;
    background: #2D5A8E;
    border-radius: 3px;
    width: 0%;
    transition: width 0.2s ease;
}

.feedback-overlay.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.feedback-overlay.correct {
    background: #4A7C59;
    box-shadow: 0 4px 20px rgba(74, 124, 89, 0.4);
}

.feedback-overlay.wrong {
    background: #C44536;
    box-shadow: 0 4px 20px rgba(196, 69, 54, 0.4);
}

.feedback-overlay.second-chance {
    background: #2D5A8E;
    box-shadow: 0 4px 20px rgba(45, 90, 142, 0.4);
}

/* Navigation */
.nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
}

.nav-btn {
    background: #EAEEF2;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 6px 6px 12px #d0d4d8, -6px -6px 12px #ffffff;
    color: #555;
    transition: all 0.15s ease;
}

.nav-btn:active {
    box-shadow: inset 3px 3px 6px #d0d4d8, inset -3px -3px 6px #ffffff;
}

.nav-btn.next {
    background: #2D5A8E;
    color: white;
}

/* Mode Indicator */
.mode-indicator {
    text-align: center;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #666;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 4px;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-item {
    color: #666;
}

.stat-item strong {
    color: #2D2D2D;
}

/* Word Display */
.word-display {
    padding: 0 12px;
    text-align: center;
}

.word-progress {
    font-size: 18px;
    color: #888;
    margin-bottom: 4px;
}

.word-image {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 400px;
    margin: 0 auto 4px;
    cursor: pointer;
    overflow: hidden;
}

.word-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.word-text {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 4px;
    cursor: pointer;
}

.word-hint {
    font-size: 22px;
    color: #888;
    font-style: italic;
    min-height: 28px;
    cursor: pointer;
}

.word-hint.hidden {
    visibility: hidden;
}

/* Article Buttons Row */
.article-buttons {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 8px 0;
    flex-shrink: 0;
}

/* Tutorial Page */
.tutorial-content {
    display: flex;
    flex-direction: column;
    padding: 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
}

.tutorial-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tutorial-bottom {
    flex-shrink: 0;
}

.tutorial-step {
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #2D5A8E;
    margin-bottom: 12px;
}

.tutorial-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
}

.tutorial-text {
    font-size: 24px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 20px;
}

.tutorial-visual {
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 12px;
}

.gender-circles {
    display: flex;
    justify-content: center;
    gap: 32px;
}

.gender-item {
    text-align: center;
}

.gender-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    overflow: hidden;
    box-shadow: 2px 2px 4px #d0d4d8, -2px -2px 4px #ffffff;
    background: #e2e6ea;
}

.gender-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gender-label {
    font-size: 20px;
    font-weight: 600;
    color: #444;
}

.gender-label .article {
    font-weight: 700;
}

.gender-label.masc .article { color: #4A6FA5; }
.gender-label.fem .article { color: #B56576; }
.gender-label.neut .article { color: #6A8D73; }

/* Example Sentences */
.example-sentences {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.example-sentence {
    font-size: 24px;
    color: #444;
    line-height: 1.5;
    text-align: left;
}

.hl-der { color: #4A6FA5; font-weight: 700; }
.hl-die { color: #B56576; font-weight: 700; }
.hl-das { color: #6A8D73; font-weight: 700; }

.hl-who { color: #4A6FA5; font-weight: 600; }
.hl-what { color: #B56576; font-weight: 700; }
.hl-whom { color: #6A8D73; font-weight: 700; }

.abbr-tag {
    font-size: 18px;
    font-weight: 600;
    color: #888;
}

.tutorial-hint {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 20px;
    color: #666;
    margin-bottom: 16px;
}

.tutorial-hint span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tutorial-hint .key {
    background: #dde1e5;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 18px;
    box-shadow: 1px 1px 2px #d0d4d8, -1px -1px 2px #ffffff;
}

.example-word {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.example-word img {
    width: 100%;
    max-width: 500px;
    object-fit: contain;
    margin-bottom: 12px;
}

.example-word .word-name {
    font-size: 24px;
    font-weight: 600;
}

/* Results Page */
.results-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    background: #EAEEF2;
    border-radius: 16px;
    box-shadow: 12px 12px 24px #d0d4d8, -12px -12px 24px #ffffff;
    padding: 24px;
}

.results-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #4A7C59;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 48px;
    font-weight: 700;
}

.results-title {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 32px;
}

.score-boxes {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.score-box {
    padding: 24px 36px;
    text-align: center;
    min-width: 140px;
    border-radius: 14px;
}

.score-box.correct {
    background: rgba(74, 124, 89, 0.15);
}

.score-box.wrong {
    background: rgba(196, 69, 54, 0.15);
}

.score-number {
    font-size: 56px;
    font-weight: 700;
}

.score-box.correct .score-number { color: #4A7C59; }
.score-box.wrong .score-number { color: #C44536; }

.score-label {
    font-size: 22px;
    color: #666;
    margin-top: 4px;
}

.results-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Certificate Page */
.certificate-content {
    text-align: center;
    padding: 24px;
    background: #EAEEF2;
    border-radius: 16px;
    box-shadow: 12px 12px 24px #d0d4d8, -12px -12px 24px #ffffff;
}

.certificate-title {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #2D5A8E;
}

.certificate-box {
    padding: 36px 32px;
    border: 3px solid #D4AF37;
    position: relative;
    margin-bottom: 28px;
    border-radius: 16px;
}

.certificate-box::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid #D4AF37;
    border-radius: 12px;
    pointer-events: none;
}

.cert-header {
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #888;
    margin-bottom: 10px;
}

.cert-main {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 16px;
}

.cert-subject {
    font-size: 24px;
    color: #555;
    margin-bottom: 24px;
}

.cert-score {
    font-size: 64px;
    font-weight: 700;
    color: #4A7C59;
    margin-bottom: 10px;
}

.cert-date {
    font-size: 20px;
    color: #888;
}

.cert-seal {
    width: 80px;
    height: 80px;
    background: #D4AF37;
    border-radius: 50%;
    margin: 20px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    font-weight: 700;
}

/* Batch Grid */
.batch-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.batch-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: all 0.1s ease;
}

.batch-card:hover {
    background: #f5f5f3;
}

.batch-card.completed {
    background: #4A7C59;
    border-color: #4A7C59;
}

.batch-card.current {
    border-color: #2D5A8E;
    border-width: 2px;
}

.batch-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.batch-card .batch-num {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.batch-card.completed .batch-num {
    color: #fff;
}

.batch-card .batch-score {
    font-size: 9px;
    color: #888;
    margin-top: 2px;
}

.batch-card.completed .batch-score {
    color: rgba(255,255,255,0.8);
}

/* Dictionary */
#dict-search {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    border-radius: 12px;
    border: none;
    background: #f5f5f3;
    box-shadow: inset 2px 2px 4px #d0d4d8, inset -2px -2px 4px #ffffff;
    outline: none;
    box-sizing: border-box;
}

#dict-search:focus {
    box-shadow: inset 2px 2px 4px #c0c4c8, inset -2px -2px 4px #ffffff;
}

.dict-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    border: 1px solid #d8d0c8;
    border-radius: 6px;
    overflow: hidden;
}

.dict-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid #e8e2da;
    cursor: pointer;
}

.dict-item:active {
    background: rgba(0,0,0,0.04);
}

.dict-item img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
}

.dict-item .dict-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.dict-item .dict-word {
    font-size: 12px;
    font-weight: 600;
}

.dict-item .dict-article {
    font-size: 12px;
    font-weight: 600;
}

.dict-item .dict-hint {
    font-size: 10px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dict-popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.dict-popup-overlay.show {
    display: flex;
}

.dict-popup {
    background: #EAEEF2;
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 340px;
    text-align: center;
    box-shadow: 8px 8px 16px #999, -8px -8px 16px #ddd;
    position: relative;
}

.dict-popup-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.dict-popup img {
    max-width: 240px;
    max-height: 240px;
    object-fit: contain;
    margin-bottom: 12px;
}

.dict-popup .dp-word {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
}

.dict-popup .dp-hint {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
}

.dict-popup .dp-article {
    font-size: 18px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 8px;
    display: inline-block;
    background: #EAEEF2;
    box-shadow: inset 1px 1px 3px #d0d4d8, inset -1px -1px 3px #ffffff;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .app-container {
        max-width: 100%;
        padding: 12px;
    }

    .tutorial-content {
        padding: 16px;
    }

    .tutorial-step {
        font-size: 12px;
    }

    .tutorial-title {
        font-size: 24px;
    }

    .tutorial-text {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .nav-btn {
        padding: 12px 20px;
        font-size: 16px;
    }

    .btn-primary, .btn-secondary {
        padding: 14px 24px;
        font-size: 18px;
    }

    .article-btn {
        width: 80px;
        height: 80px;
    }

    .article-btn .article {
        font-size: 24px;
    }

    .article-btn .gender {
        font-size: 10px;
    }

    .article-buttons {
        gap: 16px;
    }

    .word-image {
        max-width: 280px;
        max-height: 35vh;
    }

    .word-text {
        font-size: 28px;
    }

    .word-hint {
        font-size: 16px;
    }

    .word-progress {
        font-size: 14px;
    }

    .mode-indicator {
        font-size: 12px;
    }

    .stats-bar {
        font-size: 14px;
        gap: 16px;
    }

    .gender-circles {
        gap: 16px;
    }

    .gender-circle {
        width: 70px;
        height: 70px;
    }

    .gender-label {
        font-size: 14px;
    }

    .tutorial-hint {
        font-size: 14px;
        gap: 16px;
    }

    .tutorial-hint .key {
        font-size: 12px;
        padding: 4px 8px;
    }

    .feedback-overlay {
        font-size: 20px;
        padding: 14px 28px;
    }

    .results-title {
        font-size: 28px;
    }

    .results-icon {
        width: 70px;
        height: 70px;
        font-size: 32px;
    }

    .score-number {
        font-size: 36px;
    }

    .score-label {
        font-size: 16px;
    }

    .score-box {
        padding: 16px 24px;
        min-width: 100px;
    }

    .certificate-title {
        font-size: 28px;
    }

    .cert-main {
        font-size: 24px;
    }

    .cert-subject {
        font-size: 16px;
    }

    .cert-score {
        font-size: 42px;
    }

    .cert-date {
        font-size: 14px;
    }

    .cert-header {
        font-size: 12px;
    }

    .cert-seal {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .example-word img {
        max-width: 300px !important;
    }

    .example-word .word-name {
        font-size: 20px !important;
    }

    .progress-dots {
        gap: 5px;
        margin-top: 8px;
    }

    .dot {
        width: 6px;
        height: 6px;
    }

    .dot.active {
        width: 18px;
    }

    /* Hide tutorial step 8 (keyboard shortcuts) on mobile */
    #tutorial8 {
        display: none !important;
        visibility: hidden !important;
    }

    /* Hide 8th progress dot on all tutorial pages (step 8 removed) */
    .tutorial-content .progress-dots .dot:nth-child(8) {
        display: none;
    }

    /* Dictionary: 2 columns on mobile */
    .dict-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Peek-a-boo character */
.peek-disc { fill: #EAEEF2; }
.peek-char {
    position: absolute;
    width: 60px;
    height: 60px;
    object-fit: contain;
    z-index: 1;
    pointer-events: auto;
    cursor: pointer;
    top: calc(50% - 30px);
    left: calc(50% - 30px);
    transform-origin: 30px 30px;
}

/* Dark Mode */
[data-theme="dark"] .peek-disc { fill: #1a1e24; }

[data-theme="dark"] body {
    background: #1a1e24;
    color: #e0ddd8;
}

[data-theme="dark"] .app-container {
    color: #e0ddd8;
}

[data-theme="dark"] .nav-btn {
    background: #2a2f38;
    color: #b0ada8;
    box-shadow: 4px 4px 8px #111418, -4px -4px 8px #242830;
}

[data-theme="dark"] .nav-btn:active {
    box-shadow: inset 3px 3px 6px #111418, inset -3px -3px 6px #242830;
}

[data-theme="dark"] .nav-btn.next {
    color: white;
}

[data-theme="dark"] .btn-secondary {
    background: #2a2f38;
    color: #e0ddd8;
    box-shadow: 4px 4px 8px #111418, -4px -4px 8px #242830;
}

[data-theme="dark"] .btn-secondary:hover {
    box-shadow: 6px 6px 12px #111418, -6px -6px 12px #242830;
}

[data-theme="dark"] .article-btn {
    box-shadow: 4px 4px 8px #111418, -4px -4px 8px #242830;
}

[data-theme="dark"] .article-btn:active:not(:disabled),
[data-theme="dark"] .article-btn.selected {
    box-shadow: inset 3px 3px 6px rgba(0,0,0,0.3);
}

[data-theme="dark"] .btn-primary:disabled {
    background: #333840;
    color: #666;
}

[data-theme="dark"] .dot {
    background: #3a3f48;
    border-radius: 3px;
}

[data-theme="dark"] .results-content {
    background: #2a2f38;
    box-shadow: 8px 8px 16px #111418, -8px -8px 16px #242830;
}

[data-theme="dark"] .certificate-content {
    background: #2a2f38;
    box-shadow: 8px 8px 16px #111418, -8px -8px 16px #242830;
}

[data-theme="dark"] .modal-box {
    background: #2a2f38;
}

[data-theme="dark"] .modal-box p {
    color: #ccc;
}

[data-theme="dark"] .modal-btn-cancel {
    background: #3a3f48;
    color: #ccc;
}

[data-theme="dark"] .download-bar {
    background: #2a2f38;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

[data-theme="dark"] .download-bar-track {
    background: #3a3f48;
}

[data-theme="dark"] .gender-circle {
    background: #2a2f38;
    box-shadow: 2px 2px 4px #111418, -2px -2px 4px #333840;
}

[data-theme="dark"] .gender-label {
    color: #b0ada8;
}

[data-theme="dark"] .tutorial-text {
    color: #b0ada8;
}

[data-theme="dark"] .tutorial-hint {
    color: #999;
}

[data-theme="dark"] .tutorial-hint .key {
    background: #3a3f48;
    box-shadow: 1px 1px 2px #111418, -1px -1px 2px #444a55;
}

[data-theme="dark"] .stat-item {
    color: #888;
}

[data-theme="dark"] .stat-item strong {
    color: #e0ddd8;
}

[data-theme="dark"] .word-hint {
    color: #777;
}

[data-theme="dark"] .mode-indicator {
    color: #888;
}

[data-theme="dark"] .game-stat {
    color: #e0ddd8;
}

[data-theme="dark"] .score-label {
    color: #888;
}

[data-theme="dark"] .batch-card {
    background: #2a2f38;
    border-color: #3a3f48;
}

[data-theme="dark"] .batch-card:hover {
    background: #333840;
}

[data-theme="dark"] .batch-card .batch-num {
    color: #ccc;
}

[data-theme="dark"] .batch-card.current {
    border-color: #4A7BB5;
}

[data-theme="dark"] #dict-search {
    background: #2a2f38;
    color: #e0e0e0;
    box-shadow: inset 2px 2px 4px #1a1e24, inset -2px -2px 4px #3a3f48;
}

[data-theme="dark"] .dict-grid {
    border-color: #3a3f48;
}

[data-theme="dark"] .dict-item {
    border-color: #3a3f48;
}

[data-theme="dark"] .dict-item:active {
    background: rgba(255,255,255,0.04);
}

[data-theme="dark"] .dict-item .dict-word {
    color: #e0e0e0;
}

[data-theme="dark"] .dict-item .dict-hint {
    color: #777;
}

[data-theme="dark"] .dict-popup {
    background: #2a2f38;
    box-shadow: 8px 8px 16px #000, -8px -8px 16px #3a3f48;
}

[data-theme="dark"] .dict-popup .dp-word {
    color: #e0e0e0;
}

[data-theme="dark"] .dict-popup .dp-hint {
    color: #999;
}

[data-theme="dark"] .dict-popup .dp-article {
    background: #333840;
    box-shadow: inset 1px 1px 3px #1a1e24, inset -1px -1px 3px #3a3f48;
}

[data-theme="dark"] .dict-popup-close {
    color: #666;
}

[data-theme="dark"] .cert-subject {
    color: #999;
}

[data-theme="dark"] .results-title {
    color: #e0ddd8;
}

[data-theme="dark"] .cert-main {
    color: #e0ddd8;
}

/* Dark mode: override inline styles on dashboard and help page */
[data-theme="dark"] #batch-select h1,
[data-theme="dark"] #help h1,
[data-theme="dark"] #dictionary h1 {
    color: #e0ddd8 !important;
}

[data-theme="dark"] #batch-select [style*="color: #333"],
[data-theme="dark"] #help [style*="color: #333"] {
    color: #ccc !important;
}

[data-theme="dark"] #batch-details {
    background: #2a2f38 !important;
}

/* Dark mode: tutorial inline styles */
[data-theme="dark"] .tutorial-content h1,
[data-theme="dark"] .tutorial-content h3 {
    color: #e0ddd8 !important;
}

[data-theme="dark"] .tutorial-content [style*="background: rgba(255,255,255"] {
    background: rgba(255,255,255,0.05) !important;
}

[data-theme="dark"] #progress-percent {
    color: #e0ddd8 !important;
}

[data-theme="dark"] #words-learned,
[data-theme="dark"] #total-xp-display {
    color: #e0ddd8 !important;
}

[data-theme="dark"] #daily-limit-btn {
    color: #6fa8dc;
    border-color: #6fa8dc;
}

/* Dark mode: help page video thumbnails */
[data-theme="dark"] .video-thumb [style*="color: #555"] {
    color: #b0ada8 !important;
}

/* ===== Treasure Chest Menu ===== */
.chest-menu-area {
    position: relative;
    z-index: 50;
    margin-bottom: 10px;
}

.chest-handle {
    display: flex;
    justify-content: center;
    cursor: pointer;
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.chest-handle-img {
    position: absolute;
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(2px 3px 5px rgba(0,0,0,0.2));
    transition: opacity 0.3s;
}

.chest-img-closed { opacity: 1; }
.chest-img-open { opacity: 0; }

/* Lid opening animation */
.chest-handle.opening .chest-img-closed { opacity: 0; transition: opacity 0.15s; }
.chest-handle.opening .chest-img-open { opacity: 1; transition: opacity 0.15s; }
.chest-handle.opening {
    animation: chest-lid-open 0.5s ease-out forwards;
}

@keyframes chest-lid-open {
    0% { transform: scale(1); }
    30% { transform: scale(1.15) translateY(-6px); }
    60% { transform: scale(1.1) translateY(-4px); }
    100% { transform: scale(0.9) translateY(0); opacity: 0; }
}

/* Lid closing animation */
.chest-handle.closing .chest-img-closed { opacity: 1; transition: opacity 0.15s 0.1s; }
.chest-handle.closing .chest-img-open { opacity: 0; transition: opacity 0.15s 0.1s; }
.chest-handle.closing {
    animation: chest-lid-close 0.4s ease-out forwards;
}

@keyframes chest-lid-close {
    0% { transform: scale(0.9); opacity: 0; }
    40% { opacity: 1; transform: scale(1.05) translateY(-3px); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.chest-menu-area.open .chest-handle {
    pointer-events: none;
}

/* Pull-up panel */
.chest-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #EAEEF2;
    border-radius: 20px 20px 0 0;
    padding: 12px 16px 20px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 52;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
    max-width: 800px;
    margin: 0 auto;
}

.chest-menu-area.open .chest-panel {
    transform: translateY(0);
}

.chest-panel-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.chest-panel-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.15));
}

.chest-panel-close {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2D5A8E;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chest-panel-close:active {
    opacity: 0.8;
}

.chest-panel-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.chest-panel-item {
    width: 72px;
    text-align: center;
    padding: 10px 4px 8px;
    border-radius: 12px;
    cursor: pointer;
    background: #EAEEF2;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #555;
    box-shadow: 3px 3px 6px #d0d4d8, -3px -3px 6px #ffffff;
    transition: box-shadow 0.15s, transform 0.15s;
}

.chest-panel-item:active {
    box-shadow: inset 2px 2px 4px #d0d4d8, inset -2px -2px 4px #ffffff;
    transform: scale(0.97);
}

.chest-panel-item svg {
    flex-shrink: 0;
}

.chest-panel-item span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #555;
}

/* Backdrop */
.chest-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 51;
}

.chest-menu-area.open .chest-backdrop {
    display: block;
}

/* Dark mode chest panel */
[data-theme="dark"] .chest-panel {
    background: #1a1e24;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
}

[data-theme="dark"] .chest-panel-item {
    background: #252a32;
    box-shadow: 3px 3px 6px #0e1115, -3px -3px 6px #2e343d;
    color: #b0ada8;
}

[data-theme="dark"] .chest-panel-item:active {
    box-shadow: inset 2px 2px 4px #0e1115, inset -2px -2px 4px #2e343d;
}

[data-theme="dark"] .chest-panel-item span {
    color: #b0ada8;
}

[data-theme="dark"] .chest-panel-close {
    background: #4A7BB5;
}

[data-theme="dark"] .chest-backdrop {
    background: rgba(0,0,0,0.5);
}

/* ========================================
   Paywall
   ======================================== */

.paywall-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.paywall-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.paywall-sheet {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 800px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 20px 24px calc(24px + env(safe-area-inset-bottom, 0px));
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.paywall-backdrop.show .paywall-sheet {
    transform: translateX(-50%) translateY(0);
}

.paywall-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 0 auto 16px;
}

.paywall-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    z-index: 1;
}

.paywall-title {
    font-size: 20px;
    font-weight: 600;
    color: #2D5A8E;
    text-align: center;
    margin-bottom: 6px;
}

.paywall-subtitle {
    font-size: 14px;
    color: #666;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 20px;
}

.paywall-styles {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.paywall-style-item {
    text-align: center;
    width: 56px;
}

.paywall-style-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
}

.paywall-style-label {
    font-size: 8px;
    color: #888;
    letter-spacing: 0.3px;
    margin-top: 3px;
    text-transform: capitalize;
}

.paywall-btn-purchase {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    background: #097C87;
    color: #fff;
    font-family: inherit;
    transition: opacity 0.15s;
    text-align: center;
    text-decoration: none;
}

.paywall-btn-purchase:hover {
    opacity: 0.9;
}

.paywall-note {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 8px;
}

.paywall-restore {
    display: block;
    width: 100%;
    padding: 12px;
    background: none;
    border: none;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    margin-top: 4px;
}

.paywall-restore:hover {
    color: #555;
}

.paywall-already {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 12px;
}

/* Paywalled batch cards */
.batch-card.paywalled {
    opacity: 0.5;
    cursor: pointer;
}

.batch-card.paywalled .batch-score {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Locked dictionary items */
.dict-item.dict-locked {
    opacity: 0.6;
    cursor: pointer;
}

/* Dark mode paywall */
[data-theme="dark"] .paywall-sheet {
    background: #2a2f38;
}

[data-theme="dark"] .paywall-handle {
    background: #444;
}

[data-theme="dark"] .paywall-close {
    color: #666;
}

[data-theme="dark"] .paywall-title {
    color: #7aaad4;
}

[data-theme="dark"] .paywall-subtitle {
    color: #999;
}

[data-theme="dark"] .paywall-style-label {
    color: #777;
}

[data-theme="dark"] .paywall-note,
[data-theme="dark"] .paywall-already {
    color: #666;
}

/* ========================================
   Certificate
   ======================================== */

.certificate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
}

.cert-illustration {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 16px;
}

.cert-body {
    max-width: 300px;
}

.cert-congrats {
    font-size: 24px;
    font-weight: 600;
    color: #2D5A8E;
    margin-bottom: 4px;
}

.cert-sub {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
}

.cert-score {
    font-size: 48px;
    font-weight: 300;
    color: #4A7C59;
}

.cert-score-label {
    font-size: 12px;
    color: #888;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.cert-divider {
    width: 40px;
    height: 2px;
    background: #ddd;
    margin: 0 auto 20px;
}

.cert-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    background: #097C87;
    color: #fff;
    font-family: inherit;
    margin-bottom: 8px;
}

.cert-btn:hover {
    opacity: 0.9;
}

.cert-btn-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    background: none;
    border: none;
    font-size: 14px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
}

.cert-btn-secondary:hover {
    color: #555;
}

[data-theme="dark"] .cert-congrats {
    color: #7aaad4;
}

[data-theme="dark"] .cert-sub {
    color: #999;
}

[data-theme="dark"] .cert-score {
    color: #6A9E73;
}

[data-theme="dark"] .cert-divider {
    background: #444;
}
