/* EZ Kotoba - Minimalist Zen Design | White · Black · Red */

:root {
    --red:       #cc0000;
    --red-dark:  #990000;
    --border:    #f0f0f0;
    --muted:     #999;
    --text-mid:  #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    direction: ltr !important;
    unicode-bidi: bidi-override !important;
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: #ffffff;
    color: #000000;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================
   UTILITIES
   ============================================ */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt {
    margin-top: 30px;
}

.mb {
    margin-bottom: 30px;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 40px;
    text-transform: uppercase;
}

h2 {
    font-size: 1.8rem;
    font-weight: 300;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
}

p {
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 300;
}

/* ============================================
   BUTTONS
   ============================================ */

button {
    background-color: #cc0000;
    color: #ffffff;
    border: none;
    padding: 15px 30px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 2px;
}

button:hover {
    background-color: #990000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background-color: #000000;
}

.btn-secondary:hover {
    background-color: #333333;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================
   NAVIGATION
   ============================================ */

nav {
    background-color: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    padding: 15px 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

nav button {
    padding: 10px 20px;
    font-size: 0.9rem;
}

/* ============================================
   MAIN MENU PAGE
   ============================================ */

#main-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
    padding: 20px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.menu-buttons button {
    min-width: 220px;
    padding: 14px 32px;
    font-size: 1rem;
}

.stats-preview {
    margin-top: 20px;
    border-top: 1px solid #f0f0f0;
    padding-top: 16px;
    width: 100%;
    max-width: 380px;
}

.quick-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.quick-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 7px 4px;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
}

.quick-stat-level {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.quick-stat-bar {
    width: 100%;
    height: 4px;
    background-color: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
}

.quick-stat-fill,
.progress-fill,
.stat-bar-fill,
.stat-progress {
    height: 100%;
    background-color: #cc0000;
    transition: width 0.3s ease;
}

.quick-stat-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cc0000;
}

.quick-stat-count span {
    font-weight: 400;
    color: #999;
    font-size: 0.72rem;
}

.stat-item {
    margin-bottom: 20px;
    text-align: left;
}

.stat-label {
    font-weight: 600;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.stat-bar {
    height: 8px;
    background-color: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
}



/* ============================================
   LEVEL SELECTION PAGE
   ============================================ */

#level-selection {
    padding: 40px 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.level-btn {
    background-color: white;
    color: #000000;
    border: 2px solid #000000;
    padding: 30px 20px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 2px;
}

.level-btn:hover {
    background-color: #000000;
    color: #ffffff;
    transform: translateY(-2px);
}

.level-btn.active {
    background-color: #cc0000;
    color: #ffffff;
    border-color: #cc0000;
}

.settings-section {
    margin-bottom: 30px;
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.settings-section h3 {
    margin-bottom: 15px;
}

#level-selection h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.option-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

/* Counter Control for Question Count */
.counter-control {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.counter-btn {
    background-color: #000000;
    color: #ffffff;
    border: 2px solid #000000;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.counter-btn:hover {
    background-color: #333333;
    transform: scale(1.1);
}

.counter-btn:active {
    transform: scale(0.95);
}

.count-display {
    font-size: 2rem;
    font-weight: 600;
    color: #cc0000;
    min-width: 80px;
    text-align: center;
}

.option-btn {
    background-color: white;
    color: #000000;
    border: 2px solid #000000;
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.option-btn:hover {
    background-color: #f0f0f0;
}

.option-btn.active {
    background-color: #cc0000;
    color: #ffffff;
    border-color: #cc0000;
}

.start-quiz-btn {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

/* ============================================
   QUIZ PAGE
   ============================================ */

#quiz-page {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 12px;
}

.quiz-level {
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quiz-counter {
    font-size: 1rem;
    color: #666666;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background-color: #f0f0f0;
    border-radius: 2px;
    margin-bottom: 20px;
    overflow: hidden;
}



.quiz-question {
    text-align: center;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    padding: 10px 0;
}

.question-text {
    font-size: 2.5rem;
    margin-bottom: 12px;
    font-weight: 700;
    line-height: 1.3;
    color: #000000;
}

.question-reading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.question-reading {
    font-size: 1.3rem;
    color: #666666;
    font-weight: 500;
}

.speaker-btn {
    background-color: #cc0000;
    color: white;
    border: none;
    width: 46px;
    min-width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.speaker-btn:hover {
    background-color: #990000;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.4);
}

.speaker-btn:active {
    transform: scale(0.95);
}

.answers-container {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}

.answer-btn {
    background-color: white;
    color: #000000;
    border: 2px solid #000000;
    padding: 16px 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    border-radius: 4px;
    font-weight: 500;
    min-height: 56px;
    display: flex;
    align-items: center;
    width: 100%;
}

.answer-btn:hover:not(:disabled) {
    background-color: #f5f5f5;
    border-color: #cc0000;
    transform: translateX(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.answer-btn:active:not(:disabled) {
    transform: translateX(4px);
}

.answer-btn:disabled {
    cursor: not-allowed;
}

.answer-btn.correct {
    background-color: #009900;
    color: white;
    border-color: #009900;
    font-weight: 600;
}

.answer-btn.incorrect {
    background-color: #cc0000;
    color: white;
    border-color: #cc0000;
    font-weight: 600;
}

.feedback-message {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-correct {
    color: #ffffff;
    background-color: #009900;
}

.feedback-incorrect {
    color: #ffffff;
    background-color: #cc0000;
}

.next-btn {
    width: 100%;
    max-width: 300px;
    display: block;
    margin: 20px auto 0;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
}

.next-btn:hover {
    transform: translateY(-2px);
}

/* ============================================
   STATISTICS PAGE
   ============================================ */

#statistics-page {
    padding: 40px 20px;
}

.stats-grid {
    max-width: 600px;
    margin: 0 auto;
}

.stats-summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.stats-summary-item {
    text-align: center;
    padding: 10px 6px;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
}

.stats-summary-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: #000;
    line-height: 1.2;
}

.stats-summary-label {
    font-size: 0.75rem;
    color: #999;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin: 16px 0 10px;
}

.stat-card {
    margin-bottom: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 10px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card[data-level]:hover {
    border-color: #cc0000;
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.15);
    transform: translateY(-2px);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.stat-header h3 {
    margin: 0;
    font-size: 1rem;
}

.stat-header .percentage {
    font-size: 1rem;
    font-weight: 600;
    color: #cc0000;
}

.stat-bar-container {
    width: 100%;
    height: 6px;
    background-color: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
}



/* ============================================
   SETTINGS PAGE
   ============================================ */

#settings-page {
    padding: 40px 20px;
}

.settings-group {
    max-width: 600px;
    margin: 0 auto 40px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 30px;
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-group h2 {
    margin-bottom: 20px;
}

.settings-button {
    width: 100%;
    margin-bottom: 10px;
}

.danger-zone {
    background-color: #fff5f5;
    padding: 20px;
    border-left: 4px solid #cc0000;
    margin-top: 30px;
}

.danger-zone h3 {
    color: #cc0000;
    margin-bottom: 15px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
}

/* ============================================
   MODALS & OVERLAYS
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: white;
    border: 2px solid #000000;
    padding: 30px;
    border-radius: 2px;
    max-width: 400px;
    text-align: center;
}

.modal h2 {
    margin-bottom: 20px;
}

.modal p {
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    flex: 1;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
        margin-bottom: 30px;
    }

    h2 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    button {
        padding: 12px 25px;
        font-size: 0.95rem;
    }

    .menu-buttons button {
        min-width: 200px;
        padding: 15px 30px;
    }

    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .quiz-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .question-text {
        font-size: 1.3rem;
    }

    .question-reading-container {
        gap: 10px;
    }

    .speaker-btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .modal {
        margin: 20px;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    button {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .menu-buttons button {
        min-width: 150px;
    }

    .level-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Quiz page optimized for small phones */
    #quiz-page {
        padding: 12px 12px;
    }

    .quiz-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .quiz-level {
        font-size: 0.95rem;
    }

    .quiz-counter {
        font-size: 0.85rem;
    }

    .progress-bar {
        height: 3px;
        margin-bottom: 12px;
    }

    .quiz-question {
        min-height: 110px;
        margin-bottom: 8px;
        padding: 6px 0;
    }

    .question-text {
        font-size: 1.8rem;
        margin-bottom: 8px;
        font-weight: 700;
    }

    .question-reading {
        font-size: 1rem;
        font-weight: 500;
    }

    .question-reading-container {
        gap: 8px;
    }

    .speaker-btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .feedback-message {
        margin-bottom: 10px;
        font-size: 0.95rem;
        min-height: 44px;
        padding: 8px 10px;
    }

    .answers-container {
        gap: 8px;
        margin-bottom: 12px;
    }

    .answer-btn {
        padding: 13px 12px;
        font-size: 0.95rem;
        min-height: 52px;
    }

    .word-grid { grid-template-columns: 1fr; }
    .word-card { padding: 10px; }
    .filter-tab { padding: 6px 12px; font-size: 0.8rem; }
    input[type="text"]#search-input { padding: 10px 12px; font-size: 0.95rem; }
    .speaker-btn { width: 45px; height: 45px; }
    .modal { margin: 15px; max-width: 95%; max-height: 90vh; padding: 20px; }
    .word-checkbox { width: 18px; height: 18px; }
    .option-group { flex-wrap: wrap; gap: 8px; }
    #custom-study-btn { min-height: 40px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
}

/* ============================================
   LANDSCAPE MODE OPTIMIZATION
   ============================================ */

@media (orientation: landscape) {
    body {
        min-height: auto;
    }

    #app-container {
        min-height: auto;
    }

    /* Main Menu adjustment */
    #main-menu {
        min-height: auto;
        padding: 20px 0;
    }

    h1 {
        margin-bottom: 20px;
    }

    h2 {
        margin-bottom: 15px;
    }

    /* Level Selection horizontal layout */
    #level-selection {
        padding: 20px !important;
    }

    .level-header-row {
        max-width: 500px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .level-grid {
        margin-bottom: 20px !important;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }

    .settings-section {
        margin-bottom: 15px;
    }

    .settings-section h3 {
        margin-bottom: 10px;
    }

    /* Counter control horizontal */
    .counter-control {
        gap: 15px;
        margin-bottom: 15px;
    }

    .counter-btn {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }

    .count-display {
        font-size: 1.5rem;
        min-width: 60px;
    }

    /* Mode buttons horizontal */
    .option-group {
        gap: 8px;
        margin-bottom: 15px;
    }

    .option-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .start-quiz-btn {
        margin-top: 10px;
    }

    /* Quiz page landscape */
    #quiz-page {
        padding: 12px 20px;
    }

    .quiz-header {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }

    .progress-bar {
        margin-bottom: 12px;
    }

    .quiz-question {
        min-height: 100px;
        margin-bottom: 8px;
        padding: 8px;
    }

    .question-text {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .question-reading {
        font-size: 1.1rem;
    }

    .question-reading-container {
        gap: 12px;
    }

    .speaker-btn {
        width: 40px;
        min-width: 40px;
        height: 40px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    .answers-container {
        gap: 10px;
        margin-bottom: 15px;
    }

    .answer-btn {
        padding: 14px 16px;
        font-size: 1rem;
        min-height: 54px;
    }

    .next-btn {
        padding: 14px 35px;
        font-size: 1rem;
    }

    /* Statistics landscape */
    #statistics-page .container {
        max-width: 100%;
        padding: 15px 30px;
    }

    .stats-summary-row {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Level cards: all 5 in one row */
    #statistics-page .stats-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 12px;
        max-width: 100%;
    }

    /* History table compact */
    #statistics-page table {
        font-size: 0.85rem;
    }

    /* Menu buttons compact */
    .menu-buttons {
        gap: 15px;
    }

    .menu-buttons button {
        min-width: 200px;
        padding: 15px 30px;
    }

    /* Stats preview compact */
    .stats-preview {
        margin-top: 20px;
        padding-top: 15px;
    }
}

/* Inputs: direction covered by *, keep placeholder alignment */
input::placeholder, textarea::placeholder { text-align: left; }

/* ============================================
   WORD SELECTION & DETAIL VIEWS
   ============================================ */

/* Word selection modal */
.word-select-item {
    cursor: pointer;
}

.word-select-item:hover {
    background-color: #fff5f5 !important;
    border-color: #cc0000 !important;
}

.word-checkbox {
    cursor: pointer;
    accent-color: #cc0000;
}

/* Word list view - card grid */
.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.word-card {
    border: 2px solid #f0f0f0;
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.word-card:hover {
    border-color: #cc0000;
    box-shadow: 0 2px 8px rgba(204, 0, 0, 0.1);
}

/* Filter tabs */
.filter-tab {
    padding: 8px 16px;
    border: none;
    background: #f0f0f0;
    color: #000;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 400;
    transition: all 0.2s ease;
}

.filter-tab.active {
    background: #cc0000;
    color: white;
    font-weight: 600;
}

.filter-tab:hover:not(:disabled) {
    background: #e0e0e0;
}

.filter-tab.active:hover {
    background: #990000;
}

/* ============================================
   DESKTOP LAYOUT (min-width: 900px)
   ============================================ */

@media (min-width: 900px) {
    .container {
        max-width: 960px;
        padding: 24px 40px;
    }

    /* Typography scale-up */
    h1 {
        font-size: 3rem;
        letter-spacing: 4px;
        margin-bottom: 32px;
    }

    h2 {
        font-size: 1.8rem;
        margin-bottom: 24px;
        letter-spacing: 1px;
    }

    h3 {
        font-size: 1.2rem;
    }

    p {
        font-size: 1rem;
    }

    /* Navigation */
    nav {
        padding: 14px 32px;
        gap: 18px;
    }

    nav button {
        padding: 12px 26px;
        font-size: 0.95rem;
        letter-spacing: 1.5px;
    }

    /* Main menu */
    #main-menu {
        padding: 32px 40px;
    }

    .menu-buttons {
        gap: 12px;
        margin-top: 0;
    }

    .menu-buttons button {
        min-width: 300px;
        padding: 16px 40px;
        font-size: 1rem;
        letter-spacing: 1.5px;
    }

    .stats-preview {
        margin-top: 32px;
        padding-top: 20px;
        max-width: 560px;
    }

    .quick-stats-grid {
        gap: 12px;
    }

    .quick-stat-card {
        padding: 12px 8px;
        gap: 6px;
        border-radius: 6px;
    }

    .quick-stat-level {
        font-size: 0.95rem;
        letter-spacing: 0.5px;
    }

    .quick-stat-bar {
        height: 5px;
    }

    .quick-stat-count {
        font-size: 0.95rem;
    }

    .quick-stat-count span {
        font-size: 0.82rem;
    }

    /* Level selection */
    #level-selection {
        padding: 16px 32px 24px;
    }

    .level-header-row {
        max-width: 580px !important;
        margin: 0 auto 10px auto !important;
    }

    .level-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 580px;
        gap: 12px;
        margin: 0 auto 18px !important;
    }

    .level-btn {
        padding: 18px 12px;
        font-size: 1.05rem;
    }

    .counter-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .count-display {
        font-size: 1.7rem;
        min-width: 64px;
    }

    .option-btn {
        padding: 9px 13px;
        font-size: 0.86rem;
    }

    .settings-section {
        max-width: 580px;
        margin: 0 auto 18px;
    }

    .start-quiz-btn {
        width: 100%;
        max-width: 580px;
        margin: 0 auto;
        padding: 14px 28px;
        font-size: 0.98rem;
    }

    /* Quiz page */
    #quiz-page {
        max-width: 580px;
        padding: 12px 0 18px;
    }

    .quiz-level {
        font-size: 1.1rem;
    }

    .quiz-counter {
        font-size: 0.96rem;
    }

    .progress-bar {
        height: 4px;
        margin-bottom: 10px;
    }

    .quiz-question {
        min-height: 84px;
        margin-bottom: 10px;
        padding: 4px 0;
    }

    .question-text {
        font-size: 2.1rem;
        margin-bottom: 6px;
    }

    .question-reading {
        font-size: 1.05rem;
    }

    .speaker-btn {
        width: 44px;
        min-width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    .answer-btn {
        padding: 14px 16px;
        font-size: 0.98rem;
        min-height: 54px;
    }

    .answers-container {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 12px;
    }

    .feedback-message {
        font-size: 0.98rem;
        min-height: 40px;
        padding: 8px 14px;
        margin-bottom: 8px;
    }

    .next-btn {
        max-width: 280px;
        padding: 12px 24px;
        font-size: 0.95rem;
    }

    /* Statistics page */
    #statistics-page {
        padding: 32px 40px;
    }

    .stats-grid {
        max-width: 720px;
    }

    .stats-summary-row {
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .stats-summary-item {
        padding: 12px 8px;
    }

    .stats-summary-num {
        font-size: 1.6rem;
    }

    .stats-summary-label {
        font-size: 0.8rem;
        margin-top: 4px;
    }

    .stats-section-title {
        font-size: 0.9rem;
        margin: 18px 0 10px;
    }

    .stat-card {
        padding: 12px 16px;
    }

    .stat-header h3 {
        font-size: 1.1rem;
    }

    .stat-bar-container {
        height: 8px;
    }

    /* Settings page */
    #settings-page {
        padding: 32px 40px;
    }

    .settings-group {
        max-width: 660px;
        margin-bottom: 36px;
        padding-bottom: 32px;
    }

    .settings-button {
        padding: 14px 28px;
        font-size: 1rem;
    }

    /* Modals */
    .modal {
        max-width: 480px;
        padding: 36px;
    }

    /* Word grid */
    .word-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 14px;
    }

    .word-card {
        padding: 14px;
    }
}

@media (min-width: 900px) and (max-height: 820px) {
    nav {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    #level-selection {
        padding-top: 10px;
        padding-bottom: 16px;
    }

    .level-header-row {
        margin-bottom: 8px !important;
    }

    .level-grid {
        gap: 10px;
        margin-bottom: 14px !important;
    }

    .level-btn {
        padding: 16px 10px;
        font-size: 0.98rem;
    }

    .settings-section {
        margin-bottom: 14px;
    }

    .settings-section h3 {
        margin-bottom: 10px;
    }

    .counter-control {
        gap: 14px;
        margin-bottom: 12px;
    }

    .option-group {
        gap: 8px;
        margin-bottom: 14px;
    }

    #quiz-page {
        padding-top: 10px;
        padding-bottom: 14px;
    }

    .quiz-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .progress-bar {
        margin-bottom: 8px;
    }

    .quiz-question {
        min-height: 76px;
        margin-bottom: 6px;
    }

    .question-text {
        font-size: 1.9rem;
        margin-bottom: 4px;
    }

    .question-reading-container {
        gap: 10px;
    }

    .answers-container {
        grid-template-columns: 1fr;
        gap: 6px;
        margin-bottom: 8px;
    }

    .answer-btn {
        min-height: 48px;
        padding: 11px 14px;
    }

    .feedback-message {
        min-height: 36px;
        margin-bottom: 6px;
    }
}

/* Search input */
input[type="text"]#search-input {
    width: 100%;
    border: 2px solid #f0f0f0;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
    color: #000;
}

input[type="text"]#search-input:focus {
    outline: none;
    border-color: #cc0000;
    box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1);
}

input[type="text"]#search-input::placeholder {
    color: #999;
}

/* Word selection badge */
.selection-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #cc0000;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mastery badge */
.mastery-badge {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    color: #2e7d32;
    font-weight: 600;
}


