/* ==========================================
   Quiz App Styles
   ========================================== */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: #333;
}

.container {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    text-align: center;
}

h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

h2 {
    color: #444;
    margin: 0 0 15px;
    font-size: 1.3rem;
}

/* Dashboard Cards */
.dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.stat-card.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    margin-top: 5px;
    opacity: 0.8;
}

/* Setup Screen */
.input-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-weight: bold;
}

input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="number"]:focus {
    border-color: #667eea;
    outline: none;
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-group label {
    margin: 0;
    cursor: pointer;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #6c757d;
    font-size: 14px;
    padding: 10px 20px;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
}

.btn-success {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
}

.btn-sound {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    width: auto;
    padding: 12px 20px;
    font-size: 1.5rem;
    margin: 0;
}

.btn-sound:hover {
    transform: scale(1.1);
}

#choices-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

@media (max-width: 480px) {
    #choices-container {
        grid-template-columns: 1fr;
    }
}

/* Choice Buttons */
.choice-btn {
    background: #ffffff;
    color: #444;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 0;
    text-align: center;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    min-height: 80px;
    line-height: 1.4;
}

.choice-btn:hover {
    background-color: #ffffff;
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(102, 126, 234, 0.2);
    color: #667eea;
}

.choice-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

/* Feedback Colors */
.correct {
    background-color: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.2) !important;
}

.wrong {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.2) !important;
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.4s ease;
}

.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Game Elements */
.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    color: #888;
    font-size: 0.9rem;
}

.word-display {
    font-size: 2.8rem;
    font-weight: 800;
    margin: 15px 0 10px;
    color: #2c3e50;
    line-height: 1.2;
}

.part-of-speech {
    font-size: 1.1rem;
    color: #6c757d;
    font-weight: normal;
    margin-top: 5px;
    display: block;
}

.sound-section {
    margin: 15px 0 25px;
}

.score-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    padding: 25px;
    border-radius: 15px;
    margin: 20px 0;
}

/* Wrong Answers List */
.wrong-list {
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
}

.wrong-item {
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-radius: 0 10px 10px 0;
}

.wrong-item .word {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1rem;
}

.wrong-item .your-answer {
    color: #e74c3c;
    font-size: 0.9rem;
    margin: 5px 0;
}

.wrong-item .correct-answer {
    color: #27ae60;
    font-size: 0.9rem;
}

.resume-banner {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    color: #6c5a00;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.action-buttons .btn {
    flex: 1;
}

.loading {
    color: #666;
    margin: 20px 0;
}

.divider {
    height: 1px;
    background: #eee;
    margin: 25px 0;
}

.section-title {
    font-size: 1rem;
    color: #888;
    margin-bottom: 10px;
    text-align: left;
}

.empty-state {
    color: #999;
    font-style: italic;
    padding: 20px;
}

/* ==========================================
   Mode Selection Grid
   ========================================== */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 15px 0;
}

.mode-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #eef1fa 100%);
    border: 2px solid #e0e4f0;
    border-radius: 16px;
    padding: 20px 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-align: center;
}

.mode-card:hover {
    border-color: #667eea;
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.mode-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}

.mode-card.selected .mode-desc {
    color: rgba(255,255,255,0.8);
}

.mode-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
    line-height: 1;
}

.mode-title {
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.mode-desc {
    font-size: 0.75rem;
    color: #888;
    line-height: 1.4;
}

/* Settings row (side by side inputs) */
.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Start button */
.btn-start {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    font-size: 1.2rem;
    padding: 16px;
    margin-top: 15px;
}

.btn-start:hover {
    box-shadow: 0 6px 18px rgba(0, 184, 148, 0.35);
}

/* ==========================================
   Mobile Responsive
   ========================================== */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .container {
        padding: 1.2rem;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    .mode-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .mode-card {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        text-align: left;
        padding: 14px 16px;
        gap: 0 12px;
    }

    .mode-icon {
        grid-row: 1 / 3;
        font-size: 2rem;
        display: flex;
        align-items: center;
    }

    .mode-title {
        margin-bottom: 2px;
    }

    .mode-desc {
        font-size: 0.72rem;
    }

    .mode-desc br {
        display: none;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .word-display {
        font-size: 2rem;
    }

    .settings-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 16px;
    }

    .choice-btn {
        min-height: 60px;
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Toolbar mobile tweaks */
    .game-toolbar {
        padding: 6px 2px;
        margin-bottom: 0.7rem;
    }

    .toolbar-btn {
        font-size: 0.78rem;
        padding: 6px 9px;
        border-radius: 8px;
        gap: 3px;
    }

    .toolbar-info {
        font-size: 0.78rem;
        gap: 1px;
    }

    /* Exam english word smaller on phone */
    .english-word {
        font-size: 2rem !important;
    }
}

/* ==========================================
   Game Toolbar (Home / Info / Skip)
   ========================================== */
.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 8px 4px;
    border-bottom: 1px solid #eee;
}

.toolbar-btn {
    background: none;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 7px 11px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    color: #555;
    font-family: 'Sarabun', sans-serif;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #f0f4ff;
    border-color: #667eea;
    color: #667eea;
    transform: scale(1.05);
}

/* Home toolbar button — red tonal on hover */
.toolbar-btn.btn-go-home:hover,
.toolbar-btn-home:hover {
    background: #fff3f0;
    border-color: #ff6b6b;
    color: #e74c3c;
}

.toolbar-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #555;
    line-height: 1.3;
}

/* Score pill inside toolbar */
.score-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 0.8rem;
    font-weight: 800;
}

/* ==========================================
   History Button
   ========================================== */
.btn-history {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    font-size: 15px;
    padding: 12px 20px;
}

.btn-history:hover {
    box-shadow: 0 6px 18px rgba(108, 92, 231, 0.35);
}

/* ==========================================
   Modal
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 550px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #999;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

/* History session card */
.history-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #eff1fa 100%);
    border: 1px solid #e0e4f0;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-mode {
    font-weight: 700;
    font-size: 0.9rem;
}

.history-date {
    font-size: 0.75rem;
    color: #999;
}

.history-score {
    font-size: 1.3rem;
    font-weight: 800;
    color: #667eea;
}

.history-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.history-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 30px;
    font-style: italic;
}

/* History detail question list */
.history-q-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.history-q-item:last-child {
    border-bottom: none;
}

.history-q-status {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.history-q-word {
    font-weight: 700;
    min-width: 100px;
}

.history-q-answer {
    color: #888;
    flex: 1;
    text-align: right;
}
