*, *:before, *:after { box-sizing: border-box; }

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f6f9; color: #333; margin: 0; padding: 0;
    width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden; overscroll-behavior: none; touch-action: none; display: flex; flex-direction: column;
}

/* --- TIÊU ĐỀ & LOGO --- */
.header {
    display: flex !important; flex-direction: row !important; align-items: center; justify-content: flex-start;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    padding: 10px 15px; border-bottom: 3px solid #d4af37; flex-shrink: 0; width: 100%; z-index: 20; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.header-logo { width: 80px !important; height: auto; max-height: 50px; object-fit: contain; flex-shrink: 0 !important; border-radius: 4px; background-color: #fff; padding: 2px; margin-right: 15px; }
.header-text { flex-grow: 1; text-align: left; }
.header-text h1 { margin: 0; font-size: 16px; font-weight: 700; text-transform: uppercase; color: #d4af37; }
.header-text h2 { margin: 4px 0 0; font-size: 13px; font-weight: 500; color: #fff; line-height: 1.4; }
@media (min-width: 600px) {
    .header-logo { width: 130px !important; max-height: 60px; margin-right: 20px; }
    .header-text h1 { font-size: 20px; } .header-text h2 { font-size: 15px; }
}

/* --- NỘI DUNG CUỘN --- */
.container {
    flex: 1; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch;
    width: 100%; max-width: 900px; margin: 0 auto; padding: 0 10px 150px 10px;
    scrollbar-width: thin; scrollbar-color: #1e3c72 #f4f6f9;
}
.container::-webkit-scrollbar { width: 6px; }
.container::-webkit-scrollbar-track { background: #f4f6f9; }
.container::-webkit-scrollbar-thumb { background-color: #1e3c72; border-radius: 10px; }

/* =========================================================
   WIDGET BẢNG TIẾN ĐỘ GỌN NHẸ, TINH TẾ
   ========================================================= */
.citta-dashboard-container {
    width: 100%;
    box-sizing: border-box;
    margin-top: 15px;
    margin-bottom: 15px;
    background: #ffffff;
    border: 1px solid #d4af37; 
    border-radius: 8px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
    overflow: hidden;
}
.dashboard-header {
    background: #f8f9fa; 
    padding: 8px 15px;
    border-bottom: 1px solid #e9ecef;
    text-align: center;
}
.dashboard-title {
    margin: 0;
    font-size: 13px; 
    font-weight: bold;
    color: #1e3c72;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.progress-section { padding: 12px 15px; }

/* --- TAB CHỌN BÀI & NÚT BÁO CÁO --- */
.menu-wrapper {
    position: sticky; top: 0; z-index: 10; background-color: #f4f6f9; padding: 12px 0 10px 0;
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; gap: 10px; width: 100%;
}
.lesson-selector { flex: 1 1 0% !important; min-width: 0 !important; padding: 10px; font-size: 13px; font-weight: 700; color: #1e3c72; border: 2px solid #d4af37; border-radius: 8px; background-color: #fff; cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }

/* =========================================================
   RÈM CUỐN BÀI HỌC VÀ LỖI LỆCH MŨI TÊN ĐƯỢC GIẢI QUYẾT TẠI ĐÂY
   ========================================================= */
.accordion-item { margin-bottom: 10px; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.05); position: relative; }

.accordion-header { 
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); 
    color: #fff; 
    padding: 12px 15px; 
    font-size: 14px; 
    font-weight: bold; 
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-left: 5px solid #d4af37; 
    transition: background 0.3s ease; 
    user-select: none; 
}
.accordion-header:hover { background: linear-gradient(135deg, #152a52 0%, #1e3c72 100%); }
.header-title { flex: 1; text-align: left; }
.header-arrow { font-size: 12px; margin-left: 10px; }

.accordion-content { background: #fff; padding: 0 15px; max-height: 0; overflow: hidden; transition: max-height 1.5s cubic-bezier(0.25, 0.1, 0.25, 1), padding 1.5s ease; pointer-events: none; }
.accordion-content.active { padding: 15px; max-height: 8000px; border: 1px solid #e0e0e0; border-top: none; pointer-events: auto; overflow: visible; }

/* CSS THANH TIẾN ĐỘ MINI DƯỚI THẺ ACCORDION */
.mini-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 5;
    pointer-events: none;
}
.mini-progress-fill {
    height: 100%;
    width: 0%;
    background: #27ae60;
    transition: width 0.5s ease, background-color 0.5s;
}
.mini-progress-fill.completed {
    background: #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
}

/* --- PHẦN 1 & 2: KARAOKE & CHẤM ĐIỂM --- */
.card { background: #fff; padding: 12px; border-radius: 8px; border-left: 6px solid #1e3c72; box-shadow: 0 2px 6px rgba(0,0,0,0.05); margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; border: 1px solid #eee; }
.card.phonetic { border-left-color: #27ae60; background: #f0fdf4; }
.card.grammar { border-left-color: #8e44ad; background: #fdf5ff; display: block; }
.text-content { width: 100%; }
.hanzi-display { font-size: 24px; font-weight: bold; color: #333; font-family: 'KaiTi', 'SimSun', serif; margin-bottom: 2px; transition: color 0.3s; }
.pinyin-display { font-size: 15px; color: #2980b9; font-style: italic; font-weight: 600; margin-bottom: 2px; }
.meaning-display { font-size: 13px; color: #444; font-weight: 500; }

.karaoke-active { color: #e74c3c !important; text-shadow: 0 0 8px rgba(231, 76, 60, 0.3); font-size: 26px; }

.control-group { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
.btn { background-color: #f1f2f6; color: #2f3542; border: 1px solid #dfe4ea; padding: 6px 12px; border-radius: 50px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all 0.2s; }
.btn:hover { background-color: #d4af37; color: #fff; border-color: #d4af37; }
.btn-mic { background-color: #9b59b6; color: #fff; border-color: #8e44ad; }
.btn-mic:active { background-color: #e74c3c; }
.assess-feedback { font-size: 13px; font-weight: bold; margin-top: 5px; width: 100%; }

/* --- CÁC PHẦN TRẮC NGHIỆM --- */
.quiz-box { background: #fff; padding: 12px; border-radius: 8px; margin-bottom: 12px; border-top: 4px solid #d4af37; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee; }
.quiz-question { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: #1e3c72; }
.quiz-options { display: flex; flex-direction: column; gap: 6px; }
.quiz-options.locked { pointer-events: none; opacity: 0.6; }
.quiz-option { padding: 8px 10px; background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.quiz-option.correct { background: #fdf6e3; border-color: #d4af37; color: #8a6d3b; }
.quiz-option.wrong { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.quiz-feedback { margin-top: 10px; font-weight: bold; font-size: 13px; display: none; padding: 8px; border-radius: 4px; }

/* --- BỘ MÃ NÂNG CẤP PHẦN 3 & 5 --- */
#focus-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.75); z-index: 900; display: none; opacity: 0; transition: opacity 0.4s ease; pointer-events: auto; }
#focus-overlay.active { display: block; opacity: 1; }
.elegant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; width: 100%; }
.elegant-card { background-color: transparent; width: 100%; height: 210px; perspective: 1000px; transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); z-index: 1; }
.elegant-card.focused { transform: scale(1.3) !important; z-index: 1000 !important; position: relative; box-shadow: 0 20px 50px rgba(212, 175, 55, 0.6) !important; }
.elegant-card-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1); transform-style: preserve-3d; }
.elegant-card.flipped .elegant-card-inner { transform: rotateY(180deg); }
.elegant-card-front, .elegant-card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; padding: 10px; border: 2px dashed #d4af37; background: #fff; }
.elegant-card-back { background: #fdfbfb; transform: rotateY(180deg); }
.btn-pink { background-color: #ffeaa7; color: #d63031; border-color: #fab1a0; margin-top: 5px; width: 90%; }
.btn-gold { background-color: #d4af37; color: #fff; border-color: #b8962e; margin-top: 5px; width: 90%; }
.memory-arena { display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 768px) { .memory-arena { flex-direction: row; } .arena-col { flex: 1; } }
.arena-col h3 { text-align: center; color: #1e3c72; font-size: 15px; border-bottom: 2px dashed #d4af37; padding-bottom: 8px; margin-top: 0; }
.success-mark { font-size: 30px; color: #27ae60; margin-top: 5px; animation: popIn 0.5s ease; }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.svg-box { width: 85px; height: 85px; margin: 0 auto; background: #fafafa; border: 1px dashed #ccc; border-radius: 6px; touch-action: none !important; -webkit-touch-callout: none !important; user-select: none !important; }
.svg-box svg { touch-action: none !important; pointer-events: auto !important; }
.quiz-input { margin-top: 10px; padding: 8px; width: 100%; border: 1px solid #1e3c72; border-radius: 6px; text-align: center; font-weight: bold; font-size: 14px; outline: none; background: #fafafa; cursor: pointer; }
.quiz-input:focus { border-color: #d4af37; background: #fff; }

/* ==========================================
   BÀN PHÍM ẢO PINYIN PRO
   ========================================== */
#pinyin-keyboard {
    position: fixed;
    bottom: -100%; 
    left: 50%;
    transform: translateX(-50%);
    width: 98%;
    max-width: 600px;
    background: rgba(240, 242, 245, 0.95);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    padding: 8px 5px;
    z-index: 10000;
    transition: bottom 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    border: 1px solid #e2e8f0;
}

#pinyin-keyboard.active { bottom: 0; }
.vk-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-bottom: 5px; }
.vk-key { background: #ffffff; border: 1px solid #d1d5db; border-radius: 6px; padding: 6px 8px; font-size: 15px; font-weight: 500; color: #1f2937; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05); user-select: none; transition: all 0.1s; min-width: 26px; text-align: center; }
.vk-key:active { background: #e5e7eb; transform: scale(0.92); }
.vk-action { background: #2b6cb0; color: white; border-color: #2b6cb0; flex-grow: 1; font-size: 13px; text-transform: uppercase; font-weight: bold; padding: 8px; letter-spacing: 0.5px; }
.vk-action:active { background: #1e40af; }
.vk-title { font-size: 10px; color: #6b7280; text-align: center; margin: 3px 0; text-transform: uppercase; letter-spacing: 1px; }

/* ==========================================
   MA TRẬN PHÒNG NGỰ
   ========================================== */
body {
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none;
}
img, .svg-box, canvas { pointer-events: none; }