:root {
    --bg-dark: #0f172a;
    --bg-darker: #060b13; 
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.6);
    --success: #34d399;
    --success-glow: rgba(52, 211, 153, 0.5);
    --error: #fb7185;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    --font-sans: 'Inter', sans-serif;
    --font-thai: 'Sarabun', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-darker);
    color: var(--text-primary);
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.glass-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 0%, #1e293b 0%, var(--bg-darker) 100%);
    z-index: 0;
}

.container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1200px;
    height: 100%;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 2rem 1rem 2rem;
}

header {
    text-align: center;
    margin-top: 1rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
    text-shadow: 0 0 10px var(--primary-glow);
}

header h2 {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

header p {
    font-size: 0.9rem;
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.stats-board {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 150px;
    backdrop-filter: blur(10px);
}

.stat-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

#stat-wpm { color: var(--primary); }
#stat-accuracy { color: var(--success); }
#stat-errors { color: var(--error); }

.typing-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    margin: 0.5rem 0;
}

.hidden-input {
    position: absolute;
    opacity: 0;
}

.text-display {
    font-family: var(--font-thai);
    font-size: 2.5rem;
    line-height: 1.5;
    letter-spacing: 3px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.char {
    color: var(--text-muted);
    transition: color 0.1s;
}

.char.correct {
    color: var(--text-primary);
}

.char.error {
    color: var(--error);
    border-bottom: 3px solid var(--error);
}

.char.current {
    color: var(--text-primary);
    position: relative;
}

.char.current::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary);
    box-shadow: 0 0 5px var(--primary-glow);
    animation: blink 1s infinite;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

.keyboard-visualizer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.6);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-bottom: 0.5rem;
}

.key-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    width: 100%;
}

.key {
    width: 44px;
    height: 44px;
    background: #2a3241;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    display: flex;
    position: relative;
    color: var(--text-secondary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.1);
}

.en-upper { position: absolute; top: 4px; left: 4px; font-size: 0.65rem; color: #64748b; font-weight: 600; }
.en-lower { position: absolute; bottom: 4px; left: 4px; font-size: 0.8rem; color: #94a3b8; }
.th-upper { position: absolute; top: 4px; right: 4px; font-size: 0.75rem; font-family: var(--font-thai); }
.th-lower { position: absolute; bottom: 2px; right: 4px; font-size: 1.1rem; font-family: var(--font-thai); font-weight: 600; }

.th-cons { color: #fbbf24; }
.th-vow { color: #ef4444; }
.th-tone { color: #22c55e; }
.th-symbol { color: #94a3b8; }

.key.special {
    background: #1e293b;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
}

.key.active {
    background: #3b82f6;
    border-color: #60a5fa;
    transform: translateY(2px) scale(0.97);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6), inset 0 2px 4px rgba(0,0,0,0.4);
}

.key.active * { color: #fff !important; text-shadow: 0 0 3px rgba(255,255,255,0.8); }

.key.hint {
    border-color: #34d399;
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.4), inset 0 0 0 1px rgba(52, 211, 153, 0.3);
}

.controls { display: flex; justify-content: center; padding-bottom: 0.5rem; }
.btn { padding: 0.75rem 2rem; border-radius: 50px; font-size: 1rem; font-weight: 700; cursor: pointer; border: none; background: var(--primary); color: #1e293b; box-shadow: 0 2px 10px var(--primary-glow); transition: all 0.2s ease; }
.btn:hover { background: #0ea5e9; transform: translateY(-2px); box-shadow: 0 4px 15px var(--primary-glow); }

.translation-display {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    text-align: center;
    letter-spacing: 1px;
}

.key.hint-shift {
    border-color: #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4), inset 0 0 0 1px rgba(245, 158, 11, 0.3);
}

.round-progress-bar {
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

#round-progress {
    display: inline-block;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 20px;
    padding: 0.25rem 1rem;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* ---- Lesson Select ---- */
#lesson-select {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 20px;
    padding: 0.35rem 2.2rem 0.35rem 1rem;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2338bdf8' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: border-color 0.2s;
}

#lesson-select:hover,
#lesson-select:focus {
    border-color: rgba(56, 189, 248, 0.8);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

#lesson-select option {
    background: #1e293b;
    color: var(--text-primary);
}
