:root {
    --bg: #f2f2f2;
    --card: #ffffff;
    --text: #000;
    --border: #ccc;
    --header: #2c6fb7;
    --btn-primary: #2c6fb7;
    --btn-success: #1a9b2a;
    --correct: #cceeff;
    --wrong: #ffb3b3;
    /* नई क्लास के लिए कलर */
    --half-wrong: #fff3cd; 
    --half-text: #856404;
}

body.dark {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #eaeaea;
    --border: #333;
    --header: #1f4f85;
    
    /* ✨ DARK MODE READABILITY FIX ✨ */
    --correct: #1a4369;      /* Dark Blue background */
    --wrong: #5c1616;        /* Dark Red background */
    --half-wrong: #4a3b00;   /* Dark Brownish Yellow background */
    --half-text: #ffe082;    /* Bright Yellow Text */
}

* {
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10 and IE 11 */
    user-select: none; /* Standard syntax */
}

/* HEADER */
.exam-header {
    background: var(--header);
    color: #fff;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.exam-header .left {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* EXAM */
.exam-screen {
    padding: 15px;
}

.exam-screen.half {
    width: 50%;
}

.exam-text {
    background: var(--card);
    padding: 15px;
    height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    line-height: 1.6;
}

textarea {
    width: 100%;
    height: 210px;
    margin-top: 10px;
    padding: 12px;
    font-size: 16px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
}

/* BUTTONS */
.submit-area {
    text-align: right;
    margin-top: 12px;
}

button {
    padding: 10px 22px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

#submitBtn {
    background: var(--btn-primary);
    color: #fff;
}

.result-screen button {
    background: var(--btn-success);
    color: #fff;
}

/* RESULT */
.result-screen {
    display: none;
    padding: 20px;
}

.status {
    font-size: 22px;
    font-weight: bold;
    margin: 15px 0;
}

.qualified { color: #1a9b2a; }
.fail { color: #d62828; }

/* ========================================================= */
/* QUALIFY TABLE - OLD DESIGN (For SSC Category Check Tables)*/
/* ========================================================= */
.qualify-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    background: var(--card);
}

.qualify-table td,
.qualify-table th {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: center;
}

.qualify-table th {
    background: #333;
    color: #fff;
}

/* ========================================================= */
/* --- ✨ NEW MODERN BOX STYLE FOR RESULT TABLE (.stats) ✨ --- */
/* ========================================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background: transparent;
    border: none;
    margin-bottom: 25px;
    width: 100%;
}

/* Table ki tbody aur tr ko block cards me badalna */
.stats tbody {
    display: contents; 
}

.stats tr {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* 🚀 Center ki jagah top se align karega taaki upar space na bache */
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px 10px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-bottom: 4px solid var(--btn-primary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stats tr:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.stats td {
    display: block;
    border: none;
    padding: 0;
    text-align: center;
    width: 100%;
}

/* Table ka Left Column (Ab Card ka Title banega) */
.stats td:first-child {
    font-size: 12px;
    font-weight: bold;
    color: var(--text);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stats tr td:first-child::before {
    display: block;
    font-size: 22px; 
    margin-bottom: 4px; 
}

/* Table ka Right Column (Ab Card ki Value banega) */
.stats td:last-child {
    font-size: 26px;
    font-weight: bold;
    color: var(--btn-primary);
}

/* --- Specific Box Colors --- */
.stats tr:nth-child(1) { border-bottom-color: #6c757d; } /* Gross Speed */

.stats tr:nth-child(2) { border-bottom-color: #28a745; } /* Net Speed */
.stats tr:nth-child(2) td:last-child { color: #28a745; } 

.stats tr:nth-child(4) { border-bottom-color: #dc3545; } /* Error % */

.stats tr:nth-child(8), 
.stats tr:nth-child(9), 
.stats tr:nth-child(10) { border-bottom-color: #dc3545; } /* Mistakes */
.stats tr:nth-child(10) td:last-child { color: #dc3545; }

.stats tr:nth-child(3) { border-bottom-color: #17a2b8; } /* Min Required Speed */

.stats tr#railwayIgnoredRow { border-bottom-color: #198754; }
.stats tr#railwayIgnoredRow td:last-child { color: #198754; }

/* 🚨 FIX: Height badhne se rokne ke liye 🚨 */
.stats td:first-child br {
    display: none !important; /* Extra line break hide kar diya */
}
.stats td:first-child span {
    position: static !important;
    transform: none !important;
    display: block !important;
    margin-top: 3px !important;
    font-size: 10px !important; /* Font compact kar diya */
    color: #d32f2f !important;
    line-height: 1.1 !important;
}

/* ========================================================= */
/* GENERAL & PARAGRAPHS */
/* ========================================================= */
.result-pass {
    background: #c7f5c7;
    font-weight: bold;
}

.result-fail {
    background: #ff4d4d;
    color: #fff;
    font-weight: bold;
}

.para {
    background: var(--card);
    padding: 12px;
    border: 1px solid var(--border);
    white-space: pre-wrap;
}

.correct { background: var(--correct); }
.wrong { background: var(--wrong); }
.half-wrong { 
    background: var(--half-wrong) !important; 
    color: var(--half-text) !important;
    border-bottom: 2px solid orange;
}
/* ========================================================= */
/* ✨ ADD ICONS TO CARDS USING CSS (No HTML change needed) ✨ */
/* ========================================================= */

/* Omission word pe cross line (strikethrough) ke liye */
.omission-word {
    background: var(--wrong);
    text-decoration: line-through;
    color: #b71c1c; /* Text ko thoda dark red karega taaki cross line alag dikhe */
    font-weight: bold;
}

/* Har row number ke hisaab se uska specific icon */
.stats tr:nth-child(1) td:first-child::before { content: "📊"; } /* Gross Speed */
.stats tr:nth-child(2) td:first-child::before { content: "⚡"; } /* Net Speed */
.stats tr:nth-child(3) td:first-child::before { content: "🎯"; } /* Required Speed */
.stats tr:nth-child(4) td:first-child::before { content: "📉"; } /* Error % */
.stats tr:nth-child(5) td:first-child::before { content: "📝"; } /* Given Keystrokes */
.stats tr:nth-child(6) td:first-child::before { content: "⌨️"; } /* Typed Keystrokes */
.stats tr:nth-child(7) td:first-child::before { content: "✂️"; } /* Omissions */
.stats tr:nth-child(8) td:first-child::before { content: "❌"; } /* Full Mistakes */
.stats tr:nth-child(9) td:first-child::before { content: "⚠️"; } /* Half Mistakes */
.stats tr:nth-child(10) td:first-child::before { content: "🚨"; } /* Total Error Units */
.stats tr#railwayIgnoredRow td:first-child::before { content: "🚂"; } /* Railway Ignored */
.stats tr:nth-child(12) td:first-child::before { content: "⏱️"; } /* Time Taken */

/* --- NEW: BACKSPACE COUNT BOX STYLE --- */
.stats tr#backspaceRow { border-bottom-color: #fd7e14; } 
.stats tr#backspaceRow td:last-child { color: #fd7e14; }
.stats tr#backspaceRow td:first-child::before { content: "🔙"; }

/* ========================================================= */
/* 💡 EXAM SPECIFIC LIVE HIGHLIGHTING (DDA / UPSSSC)       */
/* ========================================================= */
.live-hl-correct {
    color: #198754 !important; /* Green for correct */
    font-weight: 500;
    background-color: transparent !important;
}

.live-hl-wrong {
    color: #dc3545 !important; 
    background-color: #ffe6e6 !important; 
}
.live-hl-current {
    background-color: #d0e7ff !important; /* Light Blue */
    border-radius: 3px;
    padding: 2px 0px;
    color: #000 !important;
}

.live-hl-current-wrong {
    background-color: #ffcccc !important; /* Light Red */
    border-radius: 3px;
    padding: 2px 0px;
    color: #000 !important;
}

/* Dark mode adjustments for live highlight */
body.dark .live-hl-current { color: #000 !important; }
body.dark .live-hl-current-wrong { color: #000 !important; }
body.dark .live-hl-wrong { 
    background-color: rgba(220, 53, 69, 0.2) !important; 
    color: #ff6b6b !important; 
}

/* Dark Mode Omission Fix */
body.dark .omission-word {
    background-color: transparent !important;
    color: #ff5252 !important; 
    text-decoration-color: #ff5252 !important;
}