/* ==========================================================================
   🎨 TYPING EXPERT MODERN UI THEME ENGINE (VERSION 1.1 - ALL THEMES FIXED)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght=400;600&family=Poppins:wght=400;500;700&display=swap');

@font-face {
    font-family: 'KrutiDevLocal';
    src: local('Kruti Dev 010'), local('KrutiDev010'), local('Kruti Dev 011');
}

:root {
    --bg-primary: #f7fafc;
    --bg-card: #ffffff;
    --text-main: #2d3748;
    --accent: #3182ce;
    --accent-hover: #2b6cb0;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --ad-bg: #edf2f7;
    --ad-border: #cbd5e0;
}

.theme-dark {
    --bg-primary: #1a202c;
    --bg-card: #2d3748;
    --text-main: #f7fafc;
    --accent: #4fd1c5;
    --accent-hover: #38b2ac;
    --border-color: #4a5568;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.5);
    --ad-bg: #2d3748;
    --ad-border: #4a5568;
}

.theme-cyber {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --text-main: #38bdf8;
    --accent: #f43f5e;
    --accent-hover: #e11d48;
    --border-color: #334155;
    --shadow: 0 0 15px rgba(244,63,94,0.3);
    --ad-bg: #111827;
    --ad-border: #f43f5e;
}

/* 🌲 EMERALD FOREST THEME (Premium Green & Clean White) */
.theme-emerald {
    --bg-primary: #f0f7f4;
    --bg-card: #ffffff;
    --text-main: #1b4332;
    --accent: #2d6a4f;
    --accent-hover: #1b4332;
    --border-color: #d8f3dc;
    --shadow: 0 4px 6px -1px rgba(45, 106, 79, 0.1);
    --ad-bg: #e9f5ee;
    --ad-border: #b7e4c7;
}

/* 🔮 ROYAL AMETHYST THEME (Luxury Dark Purple) */
.theme-amethyst {
    --bg-primary: #0f0c1b;
    --bg-card: #1d1833;
    --text-main: #e2dbf0;
    --accent: #9d4edd;
    --accent-hover: #7b2cbf;
    --border-color: #3c3263;
    --shadow: 0 0 15px rgba(157, 78, 221, 0.25);
    --ad-bg: #130f24;
    --ad-border: #5a189a;
}

/* 🌅 SUNSET GLOW THEME (Energetic Warm Vibes) */
.theme-sunset {
    --bg-primary: #fff8f5;
    --bg-card: #ffffff;
    --text-main: #4a1e17;
    --accent: #f77f00;
    --accent-hover: #d62828;
    --border-color: #fcd5ce;
    --shadow: 0 4px 6px -1px rgba(247, 127, 0, 0.1);
    --ad-bg: #ffebe5;
    --ad-border: #ffb5a7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    transition: all 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 🌐 LAYOUT STRUCTURE */
.app-container { display: flex; flex-direction: row; justify-content: space-between; align-items: flex-start; width: 100%; max-width: 1600px; margin: 0 auto; padding: 15px; gap: 20px; }
.main-content-area { flex: 1; width: 70%; display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* 📢 AD BOXES */
.ad-space { width: 15%; min-width: 160px; max-width: 200px; height: 600px; background-color: var(--ad-bg); border: 2px dashed var(--ad-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; position: sticky; top: 15px; }
.ad-placeholder { font-size: 0.85rem; font-weight: bold; color: #718096; }
.ad-timer { font-size: 0.7rem; font-style: italic; color: var(--accent); }
.bottom-ad-space { width: 100%; max-width: 1600px; margin: 10px auto; padding: 0 15px; }
.ad-placeholder-banner { width: 100%; height: 90px; background-color: var(--ad-bg); border: 2px dashed var(--ad-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: bold; color: #718096; }

/* 🏢 UI ELEMENTS */
.app-header { text-align: center; margin-bottom: 10px; }
.app-header h1 { font-size: 2.2rem; color: var(--accent); }
.card { background-color: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 25px; box-shadow: var(--shadow); }
.hidden { display: none !important; }

.form-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
label { font-size: 0.85rem; font-weight: 500; }
input[type="text"], select { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 6px; background-color: var(--bg-primary); color: var(--text-main); font-size: 0.9rem; outline: none; transition: all 0.2s ease; }
input[type="text"]:focus, select:focus { border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; }
.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: background 0.2s ease; }
.btn-primary { background-color: var(--accent); color: white; }
.btn-primary:hover { background-color: var(--accent-hover); }
.btn-secondary { background-color: #718096; color: white; }
.btn-success { background-color: #48bb78; color: white; }
.btn-danger { background-color: #e53e3e; color: white; }
.btn-warning { background-color: #dd6b20; color: white; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

/* ⌨️ TYPING BOX */
.test-meta { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg-primary); padding: 12px; border-radius: 8px; text-align: center; font-weight: bold; font-size: 0.95rem; gap: 10px; }
.test-text-area { width: 100%; height: 180px; border: 2px solid var(--border-color); border-radius: 8px; padding: 15px; background-color: var(--bg-primary); overflow-y: auto; text-align: left; margin-top: 15px; margin-bottom: 15px; }
.test-input-box { width: 100%; padding: 12px; border: 2px solid var(--border-color); border-radius: 8px; background-color: var(--bg-card); color: var(--text-main); font-size: 1.1rem; outline: none; margin-bottom: 15px; }
.test-input-box:focus { border-color: var(--accent); }
.typing-box-container { padding-top: 40px !important; padding-bottom: 40px !important; }

/* 🎨 WORD HIGHLIGHT COLORS */
.word-span { display: inline-block; border-radius: 4px; padding: 0 2px; }
.word-current { background-color: rgba(49, 130, 206, 0.2); border-bottom: 2px solid var(--accent); }
.word-correct { color: #48bb78; }
.word-wrong { color: #e53e3e; background-color: rgba(229, 62, 62, 0.1); border-radius: 4px; }

/* 👻 GHOST RUNER TARGET BAR */
.ghost-container { margin-top: 15px; background: var(--bg-primary); padding: 10px; border-radius: 8px; }
.ghost-label { font-size: 0.85rem; font-weight: bold; margin-bottom: 5px; }
.ghost-bar-bg { width: 100%; height: 10px; background: var(--border-color); border-radius: 5px; overflow: hidden; }
.ghost-bar-fill { width: 0%; height: 100%; background: #ed64a6; transition: width 0.5s linear; }

/* 🕶️ FIX: MODERN & COMPACT SETTINGS MODAL PANELS */
.modal { 
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background-color: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(4px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 2000; 
    padding: 10px;
}
#settingsModal.hidden { display: none !important; }

.modal-content { 
    background: var(--bg-card); 
    padding: 20px; 
    border-radius: 12px; 
    width: 100%; 
    max-width: 440px; 
    max-height: 90vh; 
    overflow-y: auto; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.4); 
    border: 1px solid var(--border-color);
}
.modal-content h3 {
    font-size: 1.3rem;
    color: var(--accent);
    margin-bottom: 10px;
}

/* 🔍 ERROR REVIEW BADGES */
.wrong-words-container, .correct-words-container { display: flex; flex-wrap: wrap; gap: 8px; }
.word-badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-weight: bold; font-size: 0.95rem; }
.word-badge.wrong { background-color: rgba(229, 62, 62, 0.15); color: #e53e3e; border: 1px solid #e53e3e; }
.word-badge.correct { background-color: rgba(72, 187, 120, 0.15); color: #48bb78; border: 1px solid #48bb78; }

/* 🏆 LEADERBOARD TABLE */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table th, table td { padding: 12px; border-bottom: 1px solid var(--border-color); }
.badge { background: #cbd5e0; color: #2d3748; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }

/* 🔤 FONTS LOCKING */
.kruti-text, .kruti-text * { font-family: 'KrutiDevLocal', sans-serif !important; font-size: 1.5rem !important; line-height: 2.4rem !important; }
.english-font-lock, .english-font-lock * { font-family: 'JetBrains Mono', monospace !important; font-size: 1.3rem !important; line-height: 2.1rem !important; }

#selectParagraph { max-width: 100%; width: 100%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }