/* * Filename: assets/css/style.css
 * Description: Stylesheet for Khang's Learning Quest (V6.5 - Text Box Size Fixed)
 * Changes: Increased Text Container Height (Not Font Size)
 */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary: #FF9800;    
    --primary-dark: #F57C00;
    --secondary: #2196F3;  
    --accent: #4CAF50;     
    --accent-dark: #388E3C;
    --danger: #FF5252;     
    --gold: #FFC107;       
    --text: #5D4037;       
    
    --font-main: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
    --radius-lg: 20px;
    --radius-md: 12px;
}

html { margin-top: 0 !important; }
#wpadminbar { display: none !important; }

body {
    margin: 0; padding: 0;
    overflow: hidden;
    font-family: var(--font-main);
}

/* =========================================
   2. GAME WRAPPER
   ========================================= */
#klq-game-wrapper {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    background: linear-gradient(-45deg, #FF9A9E, #FECFEF, #A18CD1, #84FAB0);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
    z-index: 999999;
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

#klq-game-container { width: 100%; height: 100%; display: block; }
#klq-game-container canvas { display: block; width: 100%; height: 100%; outline: none; }

#klq-ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 10;
}

.klq-top-bar, #klq-dialog-box, #klq-shop-modal, #klq-alert-modal, 
.game-btn, #essay-input, #klq-powerups-bar, .action-buttons button { 
    pointer-events: auto !important; 
}

/* =========================================
   3. TOP BAR
   ========================================= */
.klq-top-bar {
    position: absolute; top: 5px; left: 5px; right: 5px;
    display: flex; justify-content: space-between; align-items: flex-start;
    z-index: 20;
    padding: 5px;
}

.coin-display {
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 12px; border-radius: 20px;
    border: 2px solid #FFF; 
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    display: flex; align-items: center; gap: 4px;
    font-size: 1.1rem; font-weight: bold; color: var(--gold);
}
.coin-icon { font-size: 1.3rem; }

.action-buttons button {
    background: rgba(255, 255, 255, 0.95); border: none;
    border-radius: 10px; 
    padding: 6px 10px;
    font-family: var(--font-main); 
    font-size: 1rem; 
    font-weight: bold;
    color: var(--secondary); cursor: pointer; margin-left: 4px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}
.action-buttons button:active { transform: translateY(2px); }
#btn-powerup-toggle { color: var(--primary); }

/* =========================================
   4. DIALOG BOX (BA TRUNG)
   ========================================= */
#klq-dialog-box {
    position: absolute; 
    bottom: 10px; 
    left: 50%; transform: translateX(-50%);
    width: 96%; max-width: 650px;
    
    /* Chiều cao tối đa 85% màn hình */
    max-height: 85vh;
    
    /* --- ĐIỂM CẦN SỬA: Tăng chiều cao tối thiểu cho cả hộp thoại --- */
    min-height: 300px; 
    
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
    border-radius: var(--radius-lg); 
    padding: 15px;
    border-bottom: 5px solid rgba(0,0,0,0.1);
    box-shadow: 0 -5px 30px rgba(0,0,0,0.15);
    
    display: flex; flex-direction: column;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Fix bàn phím */
#klq-dialog-box.keyboard-active {
    position: absolute; 
    bottom: 5px !important; top: 5px !important;
    height: auto; max-height: 98vh; width: 98%;
    z-index: 100; margin: 0;
}
#klq-dialog-box.keyboard-active .avatar-circle { opacity: 0; pointer-events: none; }

.avatar-circle {
    position: absolute; top: -25px; left: 10px; width: 50px; height: 50px;
    background: #FFEB3B; border-radius: 50%; border: 3px solid #FFF;
    display: flex; align-items: center; justify-content: center;
    font-size: 25px; box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    transform: rotate(-10deg); z-index: 25;
}

#klq-speaker { 
    margin: 0 0 2px 55px; 
    color: var(--primary); font-size: 1.2rem; font-weight: 900; 
    text-transform: uppercase; 
}

/* --- KHUNG CHỨA NỘI DUNG (ĐÃ MỞ RỘNG) --- */
#klq-text {
    margin: 0; color: var(--text);
    font-size: 1.2rem; line-height: 1.5;
    
    /* Flex 1: Tự động chiếm hết khoảng trống còn lại */
    flex: 1; 
    
    /* --- ĐIỂM CẦN SỬA: Chiều cao tối thiểu lớn hơn --- */
    min-height: 150px; 
    
    /* Giới hạn tối đa lớn hơn để chứa nhiều chữ hơn */
    max-height: 50vh; 
    
    overflow-y: auto !important;
    padding-right: 5px;
    
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto !important;
    user-select: text;
}

#klq-text::-webkit-scrollbar { width: 5px; }
#klq-text::-webkit-scrollbar-track { background: #EEE; border-radius: 10px; }
#klq-text::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* --- VÙNG ĐÁP ÁN --- */
#klq-options { 
    display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px;
    flex-shrink: 0; 
    /* Giới hạn chiều cao nút bấm để nhường chỗ cho Text */
    max-height: 30vh; 
    overflow-y: auto; touch-action: pan-y;
    padding-bottom: 2px;
}

/* Tự luận */
#klq-essay-area { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
#essay-input {
    width: 100%; height: 80px; padding: 10px;
    border: 2px solid #CFD8DC; border-radius: var(--radius-md);
    font-family: var(--font-main); font-size: 1.1rem; color: #333;
    resize: none; outline: none; background: #F9FAFB;
    user-select: text !important; -webkit-user-select: text !important; pointer-events: auto !important;
}
#essay-input:focus { border-color: var(--primary); background: #FFF; }

/* Buttons */
.game-btn {
    background: var(--accent); color: white; border: none;
    padding: 12px 15px;
    border-radius: 10px;
    font-family: var(--font-main); 
    font-size: 1.1rem; 
    font-weight: bold;
    cursor: pointer; box-shadow: 0 3px 0 var(--accent-dark);
    text-align: left; width: 100%; transition: all 0.1s;
    white-space: normal; line-height: 1.3;
}
.game-btn:active { transform: translateY(3px); box-shadow: none; }
.game-btn:disabled { background: #CFD8DC; color: #999; box-shadow: none; }

.start-btn { background: var(--primary); box-shadow: 0 3px 0 var(--primary-dark); text-align: center; }

/* =========================================
   5. POWER-UPS BAR
   ========================================= */
#klq-powerups-bar {
    position: absolute; 
    bottom: 20px; left: 50%; transform: translateX(-50%);
    width: 94%; max-width: 500px;
    background: rgba(255,255,255,0.98); border-radius: 15px; padding: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2); border: 2px solid var(--primary);
    display: flex; flex-direction: column; gap: 5px; z-index: 30;
    transition: all 0.3s ease;
}
#klq-powerups-bar.hidden { bottom: -300px; opacity: 0; visibility: hidden; }

.powerup-label { text-align: center; font-size: 0.9rem; color: #666; font-weight: bold; }
.powerup-grid { display: flex; gap: 8px; }
.powerup-btn {
    flex: 1; background: #FFF; border: 1px solid #DDD; border-radius: 10px;
    padding: 8px 2px; font-family: var(--font-main); font-size: 0.9rem; font-weight: bold; color: var(--text);
    cursor: pointer; display: flex; flex-direction: column; align-items: center;
}
.powerup-btn span { font-size: 1.4rem; }
.close-powerup { width: 100%; background: #EEE; border: none; padding: 5px; border-radius: 8px; font-family: var(--font-main); cursor: pointer; font-size: 0.9rem; }

/* =========================================
   6. MODALS
   ========================================= */
#klq-shop-modal, #klq-alert-modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; opacity: 0; }

.shop-content, .alert-content { background: #FFF; width: 92%; max-width: 400px; border-radius: var(--radius-lg); padding: 15px; text-align: center; pointer-events: auto !important; max-height: 85vh; display: flex; flex-direction: column; }
.modal-header { color: var(--primary); font-size: 1.6rem; font-weight: bold; margin-bottom: 8px; flex-shrink: 0; }
.shop-tabs { display: flex; gap: 8px; margin-bottom: 8px; justify-content: center; flex-shrink: 0; }
.tab-btn { background: #EEE; border: none; padding: 6px 12px; border-radius: 12px; font-weight: bold; color: #666; font-family: var(--font-main); font-size: 1rem; cursor: pointer; }
.tab-btn.active { background: var(--primary); color: white; box-shadow: 0 2px 0 var(--primary-dark); }

.shop-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 5px 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 2px; }
.shop-item { background: #F1F8E9; border: 2px solid #DCEDC8; border-radius: 10px; padding: 8px; cursor: pointer; }
.item-icon { font-size: 2.2rem; display: block; margin-bottom: 2px; }
.item-name { font-size: 0.9rem; font-weight: bold; display: block; }
.item-price { font-size: 0.85rem; color: var(--danger); font-weight: bold; background: rgba(255, 82, 82, 0.1); padding: 2px 6px; border-radius: 6px; }
.close-btn { background: var(--danger); color: white; border: none; padding: 8px 15px; border-radius: 10px; font-family: var(--font-main); margin-top: 8px; flex-shrink: 0; font-size: 1rem; }

#loading-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 200; }
.loader { border: 5px solid #f3f3f3; border-top: 5px solid var(--primary); border-radius: 50%; width: 45px; height: 45px; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media screen and (max-width: 600px) {
    #klq-dialog-box { width: 96%; padding: 10px; bottom: 5px; }
    .avatar-circle { width: 45px; height: 45px; font-size: 22px; top: -22px; }
    .shop-items { grid-template-columns: repeat(2, 1fr); }
}