:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --dark-color: #2C3E50;
    --text-light: #6c757d;
    --success-color: #28a745;
    --error-color: #dc3545;
}

.jla-container {
    max-width: 800px;
    margin: 10px auto;
    padding: 10px 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    color: var(--dark-color);
    position: relative;
}

.jla-fullscreen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.8);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 26px;
    text-align: center;
}
.jla-fullscreen-btn:hover { background: rgba(255,255,255,0.4); }

.jla-header { text-align: center; color: white; margin-bottom: 12px; }
.jla-title { font-size: 1.5em; margin: 0 0 4px; padding-right: 20px; }

.jla-mode-selector, .jla-learning-modes { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.jla-mode-btn { background: white; border: none; padding: 5px 12px; border-radius: 8px; font-size: 0.85em; font-weight: 600; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.jla-mode-btn:hover { transform: translateY(-2px); }
.jla-mode-btn.active { background: var(--primary-color); color: white; transform: scale(1.05); }
.jla-mode-icon { font-size: 1em; margin-right: 4px; }

.jla-learning-mode-btn { background: rgba(255,255,255,0.8); border: 1px solid transparent; padding: 5px 12px; border-radius: 8px; font-size: 0.8em; font-weight: 500; cursor: pointer; transition: all 0.3s ease; }
.jla-learning-mode-btn:hover { background: white; border-color: var(--secondary-color); }
.jla-learning-mode-btn.active { background: var(--secondary-color); color: white; border-color: var(--secondary-color); }
.jla-icon { margin-right: 3px; }

.jla-stats { display: flex; justify-content: space-around; background: rgba(255,255,255,0.9); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.jla-stat-item { text-align: center; }
.jla-stat-label { font-size: 0.7em; color: var(--text-light); margin-bottom: 0; text-transform: uppercase; }
.jla-stat-value { font-size: 1.3em; font-weight: 700; color: var(--primary-color); line-height: 1.1; }

.jla-content { 
    background: white; 
    border-radius: 10px; 
    padding: 15px; 
    min-height: 200px; 
    max-height: 450px; 
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.jla-content::-webkit-scrollbar { display: none; }

.jla-view { display: none; }
.jla-view.active { display: block; animation: fadeIn 0.4s ease; }

.jla-chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; }
.jla-char-card { background: #f8f9fa; border-radius: 6px; padding: 6px; text-align: center; cursor: pointer; transition: all 0.2s ease; border: 1px solid #e9ecef; }
.jla-char-card:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.jla-char-card:hover .jla-char-main, .jla-char-card:hover .jla-char-romaji { color: white; }
.jla-char-main { font-size: 1.6em; color: var(--dark-color); margin-bottom: 0; font-weight: 600; }
.jla-char-romaji { font-size: 0.7em; color: var(--text-light); font-weight: 500; }

.jla-flashcard-container { 
    max-width: 400px; 
    margin: 0 auto; 
    text-align: center; 
}
.jla-flashcard { 
    width: 100%; 
    height: 180px; 
    perspective: 1000px; 
    position: relative;
}
.jla-flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform 0.6s; transform-style: preserve-3d; }
.jla-flashcard.flipped .jla-flashcard-inner { transform: rotateY(180deg); }
.jla-flashcard-front, .jla-flashcard-back { position: absolute; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; border-radius: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); }
.jla-flashcard-front { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.jla-flashcard-back { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); transform: rotateY(180deg); }
.jla-character-display { font-size: 4.5em; color: white; line-height: 1; }

/* SỬA LỖI GIAO DIỆN NÚT LOA */
.jla-audio-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid white;
    color: white;
    padding: 8px 15px;
    border-radius: 20px; /* Bo tròn góc nhẹ */
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px; /* Tăng khoảng cách với chữ cái ở trên */
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.jla-audio-btn:hover { background: rgba(255, 255, 255, 0.4); }

.jla-romaji { font-size: 2em; color: white; margin-bottom: 8px; font-weight: bold; }
.jla-example { font-size: 0.9em; color: rgba(255,255,255,0.9); text-align: center; }

.jla-flashcard-controls { 
    display: flex; 
    justify-content: center; 
    gap: 8px;
    width: 100%;
    margin-top: 20px;
}

.jla-practice-container { max-width: 350px; margin: 0 auto; text-align: center; }
.jla-practice-prompt h3 { font-size: 1.3em; margin: 0 0 5px 0; }
.jla-practice-hint { font-size: 0.8em; color: #777; margin: 0 0 10px 0; }
.jla-canvas-wrapper { position: relative; width: 200px; height: 200px; margin: 0 auto 10px; }
#practice-canvas { width: 100%; height: 100%; border: 2px solid var(--secondary-color); border-radius: 10px; background: #fafafa; position: absolute; top: 0; left: 0; z-index: 1; touch-action: none; cursor: crosshair; }
.jla-practice-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; font-size: 8em; color: rgba(0, 0, 0, 0.15); pointer-events: none; z-index: 2; }
.jla-practice-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-bottom: 10px; }
.jla-writing-guide { display: none; }
.jla-practice-navigation { display: flex; justify-content: space-between; margin-bottom: 10px; width: 100%; }
.jla-practice-top-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; width: 100%; }
#practice-position { font-size: 0.85em; font-weight: 600; color: #666; background: rgba(0,0,0,0.05); padding: 3px 8px; border-radius: 12px; }
#practice-mode-toggle, #select-character { font-size: 0.8em; padding: 5px 10px; }
#character-selector-modal .jla-modal-content { max-width: 500px; padding: 20px; }
.character-selector-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.character-selector-header h3 { margin: 0; font-size: 1.2em; }
.character-selector-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; max-height: 300px; overflow-y: auto; padding: 10px 5px; }
.selector-char-btn { width: 100%; aspect-ratio: 1; border: 1px solid #ddd; background: #f8f9fa; border-radius: 6px; font-size: 1.2em; cursor: pointer; transition: all 0.2s ease; display: flex; justify-content: center; align-items: center; }
.selector-char-btn:hover { transform: scale(1.1); background: #e9ecef; }
.selector-char-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.jla-quiz-container { max-width: 500px; margin: 0 auto; }
.jla-progress-bar { width: 100%; height: 10px; background: #e0e0e0; border-radius: 10px; overflow: hidden; margin-bottom: 5px; }
.jla-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); transition: width 0.5s ease; }
#quiz-counter { display: block; text-align: center; color: #666; font-weight: 600; font-size: 0.85em; margin-bottom: 10px; }
.jla-quiz-question { text-align: center; margin-bottom: 20px; }
.jla-quiz-question h3 { font-size: 1.1em; margin: 10px 0; }
.jla-quiz-character { font-size: 3.8em; margin-bottom: 10px; }
.jla-quiz-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 15px; }
.jla-quiz-option { padding: 10px; border-radius: 8px; font-size: 0.9em; text-align: center; cursor: pointer; background: #f8f9fa; border: 1px solid #e0e0e0; transition: all 0.3s ease; }
.jla-quiz-option:hover { background: #e9ecef; }
.jla-quiz-option.correct { background: var(--success-color); color: white; border-color: var(--success-color); }
.jla-quiz-option.incorrect { background: var(--error-color); color: white; border-color: var(--error-color); }
.jla-quiz-feedback { text-align: center; font-size: 1em; min-height: 24px; margin-bottom: 10px; }
.jla-quiz-result h2 { font-size: 1.3em; margin: 0 0 10px 0; }
.jla-result-score { font-size: 2.5em; color: var(--primary-color); font-weight: bold; margin: 20px 0; }
.jla-modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; overflow: hidden; }
.jla-modal.active { display: flex; }
.jla-modal-content { background: white; padding: 20px; border-radius: 12px; max-width: 360px; width: 90%; animation: slideIn 0.3s ease; box-shadow: 0 8px 30px rgba(0,0,0,0.3); position: relative; max-height: 90vh; overflow-y: auto; overflow-x: hidden; }
.jla-modal-close { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.1); border: none; font-size: 20px; font-weight: bold; cursor: pointer; color: #333; transition: background 0.3s; line-height: 1; padding: 0; z-index: 100; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.jla-modal-close:hover { background: rgba(0,0,0,0.2); }
.jla-modal-navigation { position: absolute; bottom: 15px; left: 0; width: 100%; display: flex; justify-content: space-between; padding: 0 15px; box-sizing: border-box; z-index: 10; }
.jla-modal-nav { background: rgba(0,0,0,0.1); color: var(--dark-color); border: none; border-radius: 50%; width: 36px; height: 36px; font-size: 20px; cursor: pointer; transition: background 0.3s; display: flex; align-items: center; justify-content: center; padding: 0; }
.jla-modal-nav:hover { background: rgba(0,0,0,0.2); }
.jla-modal-body { padding: 0 0 50px; }
.jla-character-large { font-size: 5em; text-align: center; color: var(--primary-color); margin: 0 0 10px; line-height: 1.2; }
.jla-character-info { text-align: center; margin-bottom: 15px; }
.jla-character-info h3 { font-size: 1.5em; color: var(--dark-color); margin: 5px 0 10px; }
.jla-audio-btn-large { background: var(--secondary-color); color: white; border: none; padding: 8px 16px; border-radius: 50px; font-size: 0.9em; cursor: pointer; }
.jla-audio-btn-large:hover { background-color: #3ab8b0; }
.jla-modal-section { margin: 15px 0; padding: 12px; background: #f8f9fa; border-radius: 8px; }
.jla-modal-section h4 { font-size: 1em; color: var(--dark-color); margin: 0 0 8px 0; }
.jla-stroke-container { text-align: center; min-height: 80px; display: flex; justify-content: center; align-items: center; background: #e9ecef; border-radius: 8px; padding: 10px 0; }
.jla-stroke-container img, .jla-stroke-container video { max-width: 100%; max-height: 150px; border-radius: 5px; }
.jla-stroke-container span { font-size: 3em; color: var(--primary-color); }
.jla-example-item { padding: 8px 12px; margin: 5px 0; background: white; border-left: 3px solid var(--secondary-color); border-radius: 4px; font-size: 0.9em; }
.stroke-guide-modal-content { max-width: 300px; padding: 15px; text-align: center; }
.stroke-guide-modal-header { margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.stroke-guide-modal-header h3 { margin: 0; font-size: 1.2em; color: var(--dark-color); }
.stroke-guide-modal-body { padding: 0 0 10px; }
#stroke-guide-modal-content { padding: 15px; min-height: 150px; }
#stroke-guide-modal-content img, #stroke-guide-modal-content video { max-width: 100%; max-height: 200px; border-radius: 8px; }
#stroke-guide-modal-content .no-media { font-size: 5em; color: #aaa; display: flex; justify-content: center; align-items: center; height: 150px; }

/* CSS cho Luyện đọc từ */
.jla-word-practice-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.jla-word-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px 10px;
    text-align: center;
    font-size: 1.1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.jla-word-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: var(--secondary-color);
    color: white;
}

.jla-btn { padding: 6px 12px; border-radius: 6px; font-size: 0.8em; border: none; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.1); background: #ddd; color: #333; font-weight: 600; }
.jla-btn-primary { background: var(--primary-color); color: white; }
.jla-btn-secondary { background: var(--secondary-color); color: white; }
.jla-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.jla-btn:active { transform: translateY(0); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-15px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes correctPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (max-width: 768px) { 
    .jla-container { padding: 8px; } 
    .jla-title { font-size: 1.3em; } 
    .jla-mode-selector, .jla-learning-modes { gap: 6px; } 
    .jla-mode-btn { padding: 5px 10px; font-size: 0.8em; } 
    .jla-chart { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); } 
    .jla-quiz-options { grid-template-columns: 1fr; } 
    .character-selector-grid { grid-template-columns: repeat(5, 1fr); } 
    .jla-word-practice-list { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } 

    /* === Tối ưu hóa giao diện Luyện Viết cho mobile === */
    .jla-content { padding: 10px; }
    .jla-practice-container { max-width: 100%; }

    .jla-practice-top-controls {
        flex-wrap: wrap;
        gap: 5px;
        margin-bottom: 5px; /* Giảm margin */
    }
    #practice-position {
        order: 3;
        width: 100%;
        margin-top: 5px;
    }

    .jla-practice-prompt h3 { font-size: 1.1em; }
    .jla-practice-hint { margin: 0 0 5px 0; } /* Giảm margin */

    .jla-canvas-wrapper {
        width: 180px;  /* Giảm kích thước canvas */
        height: 180px;
        margin: 0 auto 5px; /* Giảm margin */
    }
    .jla-practice-overlay { font-size: 7em; } /* Giảm kích thước chữ mờ */

    .jla-practice-controls {
        gap: 5px;
        margin-bottom: 8px; /* Giảm margin */
    }
    .jla-practice-controls .jla-btn {
        padding: 5px 8px; /* Giảm padding nút */
        font-size: 0.75em;
    }

    .jla-practice-navigation {
        margin-bottom: 5px; /* Giảm margin */
    }
}