:root {
    --primary-kids: #4CAF50;
    --secondary-kids: #FF9800;
    --bg-color: #f0f8ff;
    --text-color: #333;
    --box-bg: #fff;
    --keyboard-bg: #e0e5ec;
}

/* NEW: Dark Mode Variables */
body.dark-mode {
    --bg-color: #1a1a2e;
    --text-color: #e0e0e0;
    --box-bg: #16213e;
    --keyboard-bg: #0f3460;
}

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    text-align: center;
    transition: background-color 0.3s, color 0.3s;
}

/* NEW: Dyslexia Mode */
body.dyslexia-mode {
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 2px;
    line-height: 1.6;
}
body.dyslexia-mode #target-text { letter-spacing: 5px; }

/* Ninja Mode (build muscle memory) */
body.ninja-mode .key { color: transparent; }
body.ninja-mode .active-key { color: white; }

/* Settings Bar */
#settings-bar {
    display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
#settings-bar button {
    background: #555; color: white; border: none; font-size: 1rem; padding: 5px 15px; border-radius: 20px; cursor: pointer;
}

#site-logo { max-height: 100px; margin-bottom: 10px; }
header { padding: 20px; }
.hidden { display: none !important; }

/* Menu Screen, Locker & Stars */
#level-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; padding: 20px; max-width: 900px; margin: 0 auto;
}
.level-card {
    background: var(--box-bg); border: 3px solid var(--primary-kids); padding: 20px; border-radius: 15px; cursor: pointer; transition: transform 0.2s;
}
.level-card:hover { transform: scale(1.05); }
.level-card.completed-card {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1); /* Light green tint */
}
.stars { font-size: 1.2rem; margin-top: 5px; color: gold; text-shadow: 0 0 2px #000; }

#avatar-locker { background: var(--box-bg); padding: 15px; margin: 10px auto; max-width: 400px; border-radius: 15px; border: 2px solid gold; box-shadow: 0 4px 8px rgba(212, 175, 55, 0.3); }
#avatar-selector { padding: 5px; font-size: 1.1rem; border-radius: 5px; background: var(--box-bg); color: var(--text-color); }

/* Teacher Mode */
#teacher-mode {
    background: var(--box-bg); padding: 20px; margin: 20px auto; max-width: 600px; border-radius: 15px; border: 2px dashed #999;
}
#custom-words-input {
    width: 60%; padding: 10px; font-size: 1.2rem; border-radius: 5px; border: 1px solid #ccc; margin-right: 10px; background: var(--box-bg); color: var(--text-color);
}

/* Game Screen */
#display-area {
    background: var(--box-bg); width: 80%; max-width: 800px; margin: 20px auto; padding: 40px; border-radius: 20px; box-shadow: 0 10px 20px rgba(0,0,0,0.1); position: relative;
}

/* GAMIFICATION RACE TRACK */
#combo-meter { position: absolute; top: 15px; right: 20px; font-size: 1.2rem; font-weight: bold; color: #ff5722; transition: all 0.2s; }
.combo-glow { text-shadow: 0 0 15px #ff5722; transform: scale(1.1); }
.runner-fire { filter: drop-shadow(0 0 8px #ff9800); transform: scale(1.2) translateY(-5px) !important; }

#race-track {
    width: 100%; height: 50px; background: #e0e5ec; border-radius: 25px; margin-bottom: 30px; position: relative; box-shadow: inset 0 4px 8px rgba(0,0,0,0.15); display: flex; align-items: center;
}
/* z-index ensures player is on top of ghost */
#player-character { position: absolute; left: 0%; font-size: 35px; z-index: 2; transition: left 0.1s ease-out, transform 0.1s ease-out; }
#ghost-character { position: absolute; left: 0%; font-size: 35px; z-index: 1; opacity: 0.4; filter: grayscale(100%); }
#finish-line { position: absolute; right: 15px; font-size: 30px; }

#target-text { font-size: 2rem; letter-spacing: 3px; margin-bottom: 20px; color: #888; }
#target-text span { white-space: pre-wrap; }

.correct { color: var(--primary-kids); }
.incorrect { color: #f44336; text-decoration: underline; background: #ffebee; }

#typing-input {
    font-size: 1.5rem; padding: 10px; width: 80%; border: 3px solid #ddd; border-radius: 10px; text-align: center; outline: none; transition: all 0.1s; background: var(--box-bg); color: var(--text-color);
}

.input-error { animation: shake 0.2s ease-in-out; border-color: #f44336 !important; background-color: #ffebee !important; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(5px); }
    50% { transform: translateX(-5px); }
}

/* Virtual Keyboard */
#virtual-keyboard {
    margin: 20px auto; display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--keyboard-bg); padding: 20px; border-radius: 15px; width: fit-content; box-shadow: inset 0 4px 6px rgba(0,0,0,0.1);
}
.row { display: flex; gap: 8px; }
.key {
    width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; border-radius: 8px; font-weight: bold; color: #333; background: white; box-shadow: 0 4px 0 #b0b5bc; transition: all 0.1s;
}
.space-bar { width: 300px; }
.home-key { border-bottom: 4px solid #555; }
.pinky-l, .pinky-r { background-color: #ffcce6; }
.ring-l, .ring-r { background-color: #cce6ff; }
.middle-l, .middle-r { background-color: #ccffcc; }
.index-l, .index-r { background-color: #ffffcc; }
.thumb { background-color: #e6ccff; }

.key.active-key { background-color: #ff3366 !important; color: white; box-shadow: 0 0 15px #ff3366, 0 2px 0 #cc0033; transform: translateY(2px); }

/* Certificate Screen & Heatmap */
#cert-logo { max-height: 80px; margin-bottom: 10px; }
.stars-display { font-size: 3rem; letter-spacing: 10px; text-shadow: 0 0 5px gold; margin: 10px 0; }
#student-name { font-size: 1.5rem; padding: 10px; text-align: center; border: 3px dashed var(--secondary-kids); border-radius: 10px; margin: 10px 0; width: 80%; max-width: 300px; background: var(--box-bg); color: var(--text-color); }

#certificate-heatmap { margin: 20px auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-width: 600px; }
.heat-key { padding: 5px 15px; border-radius: 5px; font-weight: bold; border: 1px solid #ccc; font-size: 1.2rem; }
.heat-perfect { background-color: #c8e6c9; color: #2e7d32; } 
.heat-okay { background-color: #fff9c4; color: #f57f17; } 
.heat-bad { background-color: #ffcdd2; color: #c62828; } 

.action-buttons { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
button { background: var(--secondary-kids); color: white; border: none; padding: 10px 20px; font-size: 1.2rem; border-radius: 10px; cursor: pointer; font-family: inherit; }
button:hover { filter: brightness(1.1); }
.reset-btn { background-color: #ffcccc; color: #cc0000; font-size: 0.9rem; padding: 5px 10px;}

#privacy-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--box-bg); color: var(--text-color); padding: 30px; border-radius: 20px; max-width: 500px; text-align: left; position: relative; }
.close-btn { position: absolute; top: 10px; right: 10px; font-size: 2rem; background: none; color: inherit; border: none; cursor: pointer; }

/* Dashboard Specific styling */
.dashboard-body { background: #f9f9f9; }
#history-table th { background: #eee; color: #333; }
.dark-mode #history-table th { background: #333; color: white; }
.dark-mode #history-table td { border-bottom: 1px solid #444; }

/* Printing Rules (A4 Landscape Diploma) */
.print-only { display: none; }
@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body { background: white; margin: 0; padding: 0; color: black; }
    .no-print, header, footer { display: none !important; }
    
    #main-stage { margin: 0; padding: 0; box-shadow: none; }
    
    #result-modal { 
        display: flex !important; 
        position: absolute; left: 0; top: 0; 
        width: 100%; height: 100%; 
        justify-content: center; 
        align-items: center; 
    }
    
    .certificate-border {
        border: 15px double #D4AF37; 
        padding: 40px; 
        margin: 0;
        background: #fff; 
        width: 100%; 
        box-sizing: border-box; 
        text-align: center;
        page-break-inside: avoid;
    }
    
    .print-only { 
        display: block !important; 
        color: #D4AF37; 
        font-size: 3rem; 
        text-decoration: underline; 
        margin: 15px 0; 
    }
    
    #final-stats { font-size: 1.5rem; line-height: 1.8; color: black; }
    .heat-key { font-size: 1rem; border: 1px solid black; } 
}
