/* --- 1. GLOBAL VARIABLES & RESET --- */
:root { 
    --primary: #1e3a8a; --accent: #3b82f6; --success: #10b981; 
    --error: #ef4444; --missed: #64748b; --extra: #d97706; --bg: #f1f5f9; --active: #fef08a; 
    --disabled: #cbd5e1;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); margin: 0; padding: 0; overflow-x: hidden; }

.w-95 { width: 95%; margin: 0 auto; max-width: 1600px; }

/* ============================================================
   FONT DECLARATIONS
   ============================================================ */

/* KrutiDev — loaded from plugin folder, enables Hindi via English keyboard */
@font-face {
    font-family: 'Krutidev010';
    src: url('/wp-content/plugins/speedy-typing-hindi/assets/fonts/krutidev010.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Mangal — system font on Windows; fallback chain for other OS */
@font-face {
    font-family: 'MangalInscript';
    src: local('Mangal');
    font-weight: normal;
    font-style: normal;
}

/* ============================================================
   FONT UTILITY CLASSES (applied by JS on font change)
   ============================================================ */

.font-krutidev {
    font-family: 'Krutidev010', monospace !important;
    line-height: 1.8 !important;
}

.font-mangal {
    font-family: 'MangalInscript', 'Mangal', 'Noto Sans Devanagari', serif !important;
    line-height: 1.8 !important;
}

/* ============================================================
   DEFAULT FONT FOR TYPING BOXES (KrutiDev as default)
   Overridden by .font-mangal or .font-krutidev when JS applies them
   ============================================================ */

#independent-display,
#type-box,
#res-original-text,
#res-typed-text,
.comparison-scroll-box {
    font-family: 'Krutidev010', monospace !important;
    line-height: 1.8 !important;
    text-align: justify;
}
/* --- FONT SELECTOR GLOW (before test starts) --- */
#font-selector {
    border: 2px solid #f59e0b !important;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.85rem;
    height: 34px;
    cursor: pointer;
    font-weight: 700;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
    animation: font-glow-pulse 2s infinite;
    transition: all 0.3s ease;
}

/* Stop glowing once test has started (class added by JS) */
#font-selector.font-locked {
    animation: none !important;
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
}

@keyframes font-glow-pulse {
    0%   { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4); }
    50%  { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4); }
}

/* --- FONT CONFIRM MODAL --- */
.font-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 30%; height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: flex !important;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

/* Override hidden for modal — when hidden class present, truly hide */
.font-modal-overlay.hidden {
    display: none !important;
}

.font-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modal-slide-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-slide-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.font-modal-header {
    background: linear-gradient(135deg, #1e293b, #475569);
    color: white;
    padding: 18px 24px;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.font-modal-body {
    padding: 24px;
}

.font-modal-msg {
    font-size: 0.92rem;
    color: #475569;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.font-modal-selector-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.font-modal-label {
    font-weight: 700;
    font-size: 0.88rem;
    color: #1e293b;
    white-space: nowrap;
}

.font-modal-select {
    flex: 1;
    height: 40px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.font-modal-select:focus {
    border-color: #475569;
}

.font-modal-info {
    background: #f8fafc;
    border-left: 4px solid #475569;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.6;
    min-height: 48px;
}

.font-modal-actions {
    display: flex;
    gap: 12px;
    padding: 0 24px 24px 24px;
}

.font-modal-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.font-modal-btn-confirm {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.font-modal-btn-confirm:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.font-modal-btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
}

.font-modal-btn-cancel:hover {
    background: #e2e8f0;
}

@media (max-width: 480px) {
    .font-modal-actions {
        flex-direction: column;
    }
}
/* --- COMPACT ACTION ROW --- */
.header-action-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.hidden {
    display: none !important;
}

/* --- UNIFIED CENTERED HEADER --- */
.app-header {
    background: linear-gradient(135deg, #1e293b, #475569);
    min-height: 60px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.header-content {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 25px; 
    width: 100%;
}

.header-left {
    display: flex !important;
    align-items: center;
}

.header-logo {
    height: 35px !important;
    width: auto !important;
    display: block !important;
}

.header-selectors {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sel-label {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#test-select { width: 260px; height: 34px; border-radius: 4px; border: none; font-weight: 600; padding: 0 10px; }
#time-select { width: 110px; height: 34px; border-radius: 4px; border: none; font-weight: 600; padding: 0 10px; }

.header-right {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.compact-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    width: auto !important;
    height: 36px !important;
    border-radius: 6px !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    padding: 0 10px !important;
}

.compact-btn:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 10px 0 !important;
    }

    .header-logo {
        height: 0px !important;
        width: 0px !important;
    }

    .header-selectors {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .sel-label {
        font-size: 0.8rem !important;
    }

    #test-select {
        width: 100% !important;
        max-width: 300px;
    }

    #time-select {
        width: 80px !important;
    }
}

.btn-submit {
    width: 35% !important;
    max-width: 200px;
    padding: 6px 0 !important;
    margin: 0 !important;
}

.main-grid {
    gap: 4px !important;
    margin-top: 5px;
}

.independent-wrapper {
    margin: 2px auto !important;
}

.action-row .sel-label {
    white-space: nowrap;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .action-row {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    .action-row .header-item {
        width: 100%;
        justify-content: center;
    }
}

/* Font Selector in action row */
#font-selector {
    border: 2px solid var(--accent);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 0.85rem;
    height: 30px;
    cursor: pointer;
}

/* --- INDEPENDENT SETTINGS CONTAINER --- */
.independent-settings-container {
    width: 95%; 
    margin: 5px auto !important;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px); 
    overflow: hidden;
}

.settings-toggle-btn {
    width: 100%; 
    padding: 16px; 
    background: #0f172a;
    color: #f8fafc;
    border: none; 
    font-weight: 800; 
    font-size: 0.85rem; 
    letter-spacing: 2px;
    cursor: pointer; 
    text-transform: uppercase; 
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.settings-toggle-btn:hover {
    background: #1e293b;
}

.settings-horizontal-row {
    display: flex; 
    flex-direction: row; 
    flex-wrap: nowrap;
    gap: 12px; 
    padding: 20px; 
    background: #f8fafc;
    overflow-x: auto;
}

.inline-progress {
    flex-grow: 1;
    max-width: 72%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    margin: 0 15px;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: #10b981;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transition: width 0.2s ease;
    min-width: 0;
}

#progress-text {
    color: white;
    font-size: 0.04rem;
    font-weight: bold;
    padding-right: 5px;
    z-index: 10;
}

.bar-low #progress-text {
    color: #1e293b;
    position: absolute;
    left: 105%;
}

.settings-group {
    flex: 1; 
    min-width: 200px; 
    padding: 18px;
    background: #ffffff;
    border-radius: 12px; 
    border: 1px solid #edf2f7;
    border-top: 5px solid #cbd5e1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.settings-group:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 6px 15px rgba(0,0,0,0.08); 
}

.group-blue { border-top-color: #3b82f6; }
.group-green { border-top-color: #10b981; }
.group-purple { border-top-color: #8b5cf6; }
.group-teal { border-top-color: #14b8a6; }
.group-orange { border-top-color: #f59e0b; }

.group-header {
    font-size: 0.75rem; 
    font-weight: 900; 
    color: #475569;
    text-transform: uppercase; 
    margin-bottom: 15px; 
    letter-spacing: 1px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    display: flex;
    align-items: center;
}

.vertical-stack { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    align-items: flex-start;
}

.setting-item {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 0.85rem;
    color: #334155; 
    cursor: pointer; 
    white-space: nowrap;
    text-align: left;
}

.flex-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    width: 100%; 
    gap: 10px; 
    font-size: 0.85rem; 
}

.compact-input, .compact-select {
    padding: 4px 6px; 
    border-radius: 6px; 
    border: 1px solid #e2e8f0; 
    font-size: 0.8rem; 
    outline: none;
    background: #fff;
}

.compact-input { width: 65px; }
.compact-select { cursor: pointer; }

#exam-inputs-container.exam-disabled {
    opacity: 0.4 !important;
    pointer-events: none !important;
    filter: grayscale(100%);
}

@media (max-width: 1200px) {
    .settings-horizontal-row { flex-wrap: wrap; }
    .settings-group { flex: 1 1 30%; }
}

@media (max-width: 768px) {
    .settings-group { flex: 1 1 45%; }
}

@media (max-width: 480px) {
    .settings-horizontal-row { flex-direction: column; }
    .settings-group { width: 100%; }
}

.hidden { display: none !important; }

#progress-container { width: 100%; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#progress-track { flex-grow: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
#progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--success)); transition: width 0.3s ease; }
#progress-text { font-weight: bold; color: var(--primary); font-size: 0.9rem; min-width: 45px; text-align: right; }

.typing-panel { 
    width: 100%;
    gap: 5px;
}

@media (min-width: 901px) {
    .exam-mode .typing-panel { width: 100%; margin-left: auto; margin-right: auto; }
    .exam-mode #exercise-display, .exam-mode .type-box { width: 100%; height: 250px; }
}

.exam-layout-active .app-header, 
.exam-layout-active #tools-group, 
.exam-layout-active #settings-toggle-btn {
    display: none !important;
}

.exam-layout-active .control-bar,
.exam-layout-active .control-flex,
.exam-layout-active #timer-display,
.exam-layout-active #progress-container,
.exam-layout-active #btn-submit {
    display: flex !important;
    visibility: visible !important;
}

.btn-exit-alt {
    background: linear-gradient(135deg, #475569, #1e293b);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

body.exam-layout-active .app-header, 
body.exam-layout-active #tools-group, 
body.exam-layout-active #settings-toggle-btn {
    display: none !important;
}

body.exam-layout-active #btn-exam-exit {
    display: inline-flex !important;
}

body.exam-layout-active .control-bar {
    display: block !important;
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
}

body.exam-layout-active .action-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 15px;
    position: static !important;
}

body.exam-layout-active .control-flex {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

body.exam-layout-active #btn-submit,
body.exam-layout-active #btn-exit-exam {
    position: static !important;
    margin: 0 !important;
}

.independent-wrapper {
    width: 99% !important;
    margin: 10px 0 !important;
    padding: 0 !important;
}

.hl-active, .hl-error {
    display: inline-block;
    padding: 0 2px;
    margin: 0 -2px;
}

#progress-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.5s linear;
    display: flex;
    align-items: center;
    justify-content: center;
}

#progress-text {
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
}

.btn-exit-exam {
    background: linear-gradient(135deg, #ef4444, #991b1b) !important;
    color: white !important;
    border: none;
    box-shadow: 0 3px 8px rgba(239, 64, 64, 0.2);
}

.action-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    flex-wrap: nowrap !important; 
}

body.exam-layout-active #btn-exit-exam {
    display: inline-flex !important;
}

body.exam-layout-active #btn-pause,
body.exam-layout-active #tools-group {
    display: none !important;
}

.helper-text {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 8px;
}

.group-purple, .group-teal, .group-orange {
    transition: all 0.3s ease;
}

.control-bar {
    background: #ffffff;
    border-bottom: 2px solid #e2e8f0;
    padding: 6px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.control-flex {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.action-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 95%;
    margin: 0 auto;
}

#timer-display {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    text-align: center;
    padding: 0 10px;
    border-left: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
    line-height: 28px;
}

.timer-low #btn-submit {
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 64, 64, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 64, 64, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 64, 64, 0); }
}

.btn {
    padding: 6px 14px;
    border-radius: 5px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.75rem;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn:active {
    transform: scale(0.92);
}

.btn-start {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
    animation: pulse-green 2s infinite;
    font-size: 1rem;
}

.btn-pause {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-tool {
    background: white;
    border: 1px solid var(--disabled);
    color: var(--primary);
    width: 28px;
    padding: 0;
    font-size: 1rem;
}

.btn-tool:hover {
    transform: rotate(8deg) scale(1.1);
}

.btn-submit {
    width: 2px;
    background: #FA8072;
    color: white;
    box-shadow: 0 3px 10px rgba(30, 58, 138, 0.2);
}

#timer-display {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    padding: 0 10px;
    border-left: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
    line-height: 28px;
    animation: slideIn 0.5s ease-out;
}

.inline-progress {
    width: 100%;
    max-width: 800px;
    height: 14px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    position: relative;
}

#progress-fill {
    height: 100%;
    width: 0%; 
    background-color: hsl(0, 80%, 45%);
    transition: width 0.3s ease, background-color 0.5s linear; 
    display: flex;
    align-items: center;
    justify-content: center;
}

#progress-text {
    font-size: 0.7rem;
    font-weight: 800;
    transition: color 0.3s ease;
}

.bar-low #progress-text {
    color: var(--primary);
    margin-left: 40px;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}

.independent-container {
    margin: 20px 0;
    width: 100%;
    max-width: 800px;
}

.independent-header {
    background: #334155;
    color: white;
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 8px 8px 0 0;
}

.independent-wrapper {
    width: 100%;
    margin: 5px auto;
}

.independent-wrapper {
    width: 95%; 
    margin: 20px auto;
    max-width: 1600px;
    display: flex;
    justify-content: center;
}

/* --- UNIFIED TYPING WORKSPACE (PC) --- */
.independent-box, 
#independent-display, 
.independent-type-box {
    width: 70% !important; 
    max-width: 1100px !important;
    height: 220px !important;
    margin: 5px auto !important;
    padding: 15px !important;
    box-sizing: border-box;
    background: #ffffff !important;
    border: 2px solid var(--primary) !important;
    border-radius: 12px !important;
    font-size: 1.15rem !important;
    line-height: 1.8 !important;
    color: #1e293b !important;
    text-align: justify !important;
    text-justify: inter-word;
    overflow-y: auto !important;
    white-space: pre-wrap !important;
    word-break: normal;
    overflow-wrap: break-word;
    position: relative;
    scroll-behavior: smooth;
}

.independent-type-box {
    border-color: var(--accent) !important;
    resize: none;
    outline: none;
}

@media (max-width: 768px) {
    .independent-box, 
    #independent-display, 
    .independent-type-box {
        width: 97% !important;
        height: 220px !important; 
        font-size: 1.1rem !important;
        border-radius: 5px !important;
    }
}

.independent-wrapper {
    width: 95%; 
    margin: 20px auto; 
    max-width: 1600px;
    display: flex;
    justify-content: center;
}

.hl-active { background-color: #fef08a; color: #000; border-radius: 3px; }
.hl-error { background-color: #fecaca; color: #dc2626; text-decoration: underline; }
.hl-correct { color: #10b981; }

.independent-type-box:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.independent-type-box:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    border-color: #cbd5e1;
}

@media (max-width: 768px) {
    .independent-box, .independent-type-box {
        font-size: 1rem;
        height: 200px;
        padding: 15px;
    }
}

#independent-display {
    display: block;
    white-space: pre-wrap;
}

#independent-display br {
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0.1 !important;
}

.char {
    display: inline;
    margin: 0;
    padding: 0;
}

#independent-display, #type-box {
    transition: font-size 0.2s ease-in-out;
    line-height: 1.8;
}

/* --- RESULT OVERLAY --- */
#result-panel { 
    position: absolute; top: 0; left: 0; width: 100%; 
    background: var(--bg); z-index: 2000; padding: 20px;
    display: none; justify-content: center;
}

.result-paper {
    max-width: 1200px !important;
    width: 95%;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.res-tables-flex-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: stretch;
}

.res-category-box {
    flex: 1;
    min-width: 320px;
}

.watermark {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 6rem; font-weight: 900; color: rgba(0,0,0,0.04) !important; 
    z-index: 0; pointer-events: none; white-space: nowrap; user-select: none;
}

.res-header-main { text-align: center; border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 15px; }
.res-header-main h1 { margin: 0; font-size: 1.8rem; color: var(--primary); }
.section-title { text-decoration: underline; margin: 20px 0 15px 0; font-size: 1.2rem; }

.res-category-box {
    margin-bottom: 25px;
}

.cat-blue {
    margin-top: 20px; 
}

.res-stats-grid {
    width: 60% !important;
    margin: 20px auto;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr); 
    gap: 1px;
    background-color: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.res-stat-item {
    background-color: #ffffff;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: background 0.2s;
}

.res-stat-label {
    font-weight: 700;
    color: #64748b;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.res-stat-val {
    font-weight: 800;
    color: var(--text-main);
    font-size: 1.2rem;
    line-height: 1.2;
}

@media (max-width: 900px) {
    .res-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        width: 80% !important;
    }
}

@media (max-width: 480px) {
    .res-stats-grid {
        grid-template-columns: 1fr;
        width: 95% !important;
    }
}

.res-tables-row {
    display: flex; gap: 20px; margin-bottom: 10px; position: relative; z-index: 1;
}

.res-category-box.cat-orange, 
.res-category-box.cat-blue {
    width: 60% !important; 
    margin: 10px auto;
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.res-cat-label {
    display: block;
    padding: 12px 10px;
    color: white;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: normal;
    word-wrap: break-word;
}

.res-category-box {
    flex: 1;
    width: 42% !important;
    min-width: 320px;
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 40px 20px 20px 20px;
    background: white;
    margin: 40px auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.res-cat-label {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cat-orange .res-cat-label { background: #f97316; }
.cat-blue .res-cat-label { background: #2563eb; }
.cat-orange { border-color: #fdba74; }
.cat-blue { border-color: #93c5fd; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; row-gap: 8px; font-size: 0.95rem; }
.dg-label { font-weight: 600; color: #555; }
.dg-val { font-weight: 700; text-align: right; }

.methods-flex {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-top: 10px;
}

.methods-flex .method-section {
    flex: 1;
    background: #fcfcfc;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #f1f5f9;
}

.method-title {
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 5px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.method-sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: #64748b;
    display: block;
}

@media (max-width: 600px) {
    .methods-flex {
        flex-direction: column !important;
        gap: 15px;
    }
}

.ahc-comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    table-layout: fixed;
}

.ahc-comparison-table th {
    background-color: var(--primary);
    color: white;
    padding: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
    text-align: center;
    border: 1px solid #1e3a8a;
}

.ahc-comparison-table td {
    padding: 15px;
    vertical-align: top;
    border: 1px solid #e2e8f0;
}

.ahc-row {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-bottom: 8px;
    border-bottom: 1px dashed #f1f5f9;
    padding-bottom: 4px;
}

.ahc-row:last-child {
    border-bottom: none;
}

.ahc-status-cell {
    background-color: #f8fafc;
    text-align: center;
    padding: 20px !important;
}

.ahc-res-final {
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
}

@media (max-width: 600px) {
    .ahc-comparison-table thead { display: none; }
    .ahc-comparison-table td {
        display: block;
        width: 100%;
    }
    .ahc-comparison-table tr {
        display: flex;
        flex-direction: column;
    }
}

#res-comparison-box {
    width: 95% !important;
    max-width: 1400px;
    margin: 40px auto;
}

.comparison-container {
    display: flex;
    gap: 0px;
    width: 100%;
    align-items: stretch;
    border: 2px solid #94a3b8;
    border-radius: 12px;
    overflow: hidden;
}

.res-box-half {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.res-box-half:first-child {
    border-right: 2px solid #94a3b8;
}

.res-box-half h4 {
    margin: 0 !important;
    padding: 15px;
    background: #f1f5f9;
    color: var(--primary);
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid #94a3b8;
    /* ✅ FIX: Force result panel headers to use system font, not Hindi font */
    font-family: 'Segoe UI', Arial, sans-serif !important;
}

.comparison-scroll-box {
    padding: 20px;
    height: auto !important;
    overflow: visible !important;
    font-size: 1.1rem;
    line-height: 1.8;
    text-align: justify;
}

@media (max-width: 768px) {
    #res-comparison-box {
        width: 100% !important;
        padding: 0 !important;
    }

    .comparison-container {
        flex-direction: column !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    .res-box-half:first-child {
        border-right: none !important;
        border-bottom: 2px solid #94a3b8 !important;
    }

    .comparison-scroll-box {
        padding: 15px !important;
        font-size: 1rem !important;
    }

    .res-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
    }

    .res-actions {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        width: 100% !important;
    }

    .res-btn {
        width: 90% !important;
        justify-content: center !important;
    }
}

.ref-not-typed {
    color: #cbd5e1;
    opacity: 0.5;
}

.cmp-skipped-text {
    color: var(--missed);
    text-decoration: line-through;
    background-color: #f1f5f9;
    padding: 0 2px;
}

.legend-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
}

.cmp-correct-text { color: var(--success); }
.cmp-wrong-text { color: var(--error); text-decoration: underline; }
.cmp-extra-text { color: var(--extra); border-bottom: 2px solid var(--extra); background: #fef9c3; }
.cmp-skipped-text { color: var(--missed); opacity: 0.6; }

.legend-row { display: flex; gap: 15px; margin-bottom: 10px; font-size: 0.85rem; }
.leg-item { display: flex; align-items: center; gap: 5px; }
.cmp-correct { color: #000; }
.cmp-wrong { color: var(--error); text-decoration: line-through; }
.cmp-corr-ref { color: var(--success); font-weight: bold; font-size: 0.85rem; }
.cmp-extra { color: var(--extra); text-decoration: underline; font-style: italic; }
.cmp-skipped { color: var(--missed); background: #eee; padding: 0 2px; border-radius: 2px; }

@media print {
    /* Hide everything first */
    body * {
        visibility: hidden;
    }

    /* Show only result panel and all its children */
    #result-panel,
    #result-panel * {
        visibility: visible !important;
    }

    /* Hide non-print elements inside result panel */
    #result-panel .res-actions,
    #result-panel .no-print,
    #result-panel .res-btn {
        display: none !important;
    }

    /* Position result panel to fill page */
    #result-panel {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: 100% !important;
    display: block !important;
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
}
#wpadminbar { display: none !important; }
html { margin-top: 0 !important; }
body { margin: 0 !important; padding: 0 !important; }
    /* PC: comparison boxes side by side */
    .comparison-container {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
    }

    .res-box-half {
        flex: 1 !important;
        width: 50% !important;
        min-width: 0 !important;
    }

    /* Stats grid full width */
    .res-stats-grid {
        width: 80% !important;
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
    }

    /* Force color printing */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Hide WordPress admin bar */
    #wpadminbar {
        display: none !important;
    }

    /* Remove all margins/padding from body */
    body {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Mobile print — stack comparison boxes */
@media print and (max-width: 768px) {
    .comparison-container {
        flex-direction: column !important;
    }

    /* Typed text box ABOVE original text box */
    .res-box-half:last-child {
        order: -1 !important;
    }

    .res-box-half {
        width: 100% !important;
    }

    .res-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
    }
}

.res-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
    padding-bottom: 20px;
    width: 100%;
}

.res-btn {
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    /* ✅ FIX: Result buttons always use system font */
    font-family: 'Segoe UI', Arial, sans-serif !important;
}

.res-btn-reattempt {
    background-color: #475569;
    color: #ffffff;
}

.res-btn-reattempt:hover {
    background-color: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.res-btn-print {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
}

.res-btn-print:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(30, 58, 138, 0.25);
}

.res-btn i, .res-btn span {
    font-size: 1.1rem;
}

@media print {
    .res-actions {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .result-paper, 
    #res-comparison-box, 
    .res-stats-grid, 
    .res-category-box {
        width: 99% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .res-stats-grid {
        display: flex !important;
        flex-direction: column !important;
        background: #e2e8f0 !important;
        gap: 2px !important;
        border: 2px solid #e2e8f0 !important;
    }

    .res-stat-item {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 15px 20px !important;
        background: #ffffff !important;
    }

    .res-stat-label {
        text-align: left !important;
        margin-bottom: 0 !important;
        font-size: 0.8rem !important;
    }

    .res-stat-val {
        text-align: right !important;
        font-size: 1.1rem !important;
    }

    .res-stat-item[style*="grid-column: span 4"] {
        flex-direction: column !important;
        gap: 5px !important;
    }

    .comparison-container {
        flex-direction: column !important;
        width: 100% !important;
    }

    .res-box-half {
        width: 100% !important;
        border-right: none !important;
    }
}
/* Correct word shown in green after a wrong word in the typed result box */
.cmp-correction-text {
    color: var(--success);
    font-weight: 700;
    background: #dcfce7;
    border-radius: 3px;
    padding: 0 3px;
    margin-right: 3px;
}
@media (max-width: 768px) {
    #independent-display {
        width: 100% !important;
        max-width: 97% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
    }

    .independent-wrapper {
        width: 100% !important;
        padding: 0 !important;
        margin: 10px 0 !important;
        display: flex !important;
        justify-content: center !important;
    }

    .independent-type-box {
        width: 97% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}
/* --- FONT SELECTOR GLOW (before test starts) --- */
#font-selector {
    border: 2px solid #f59e0b !important;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.85rem;
    height: 34px;
    cursor: pointer;
    font-weight: 700;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
    animation: font-glow-pulse 2s infinite;
    transition: all 0.3s ease;
}

/* Stop glowing once test has started (class added by JS) */
#font-selector.font-locked {
    animation: none !important;
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
}

@keyframes font-glow-pulse {
    0%   { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4); }
    50%  { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15); }
    100% { box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4); }
}
/* --- RESULT INFO ROW --- */
.result-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    width: 100%;
    margin: 10px auto 20px auto;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #ffffff;
}

.result-info-item {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-right: 1px solid #e2e8f0;
    text-align: center;
}

.result-info-item:last-child {
    border-right: none;
}

.result-info-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.result-info-val {
    font-size: 0.95rem;
    font-weight: 800;
    color: #1e293b;
    font-family: 'Segoe UI', sans-serif !important;
}

@media (max-width: 600px) {
    .result-info-item {
        flex: 1 1 45%;
        border-bottom: 1px solid #e2e8f0;
    }
}

/* --- WATERMARK VISIBLE IN PRINT --- */
@media print {
    .watermark {
        visibility: visible !important;
        display: block !important;
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) rotate(-30deg) !important;
        font-size: 6rem !important;
        font-weight: 900 !important;
        color: rgba(0, 0, 0, 0.06) !important;
        z-index: 9999 !important;
        pointer-events: none !important;
        white-space: nowrap !important;
        user-select: none !important;
        width: 100% !important;
        text-align: center !important;
    }
}
/* --- FONT CONFIRM MODAL --- */
.font-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9999;
    display: flex !important;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

/* Override hidden for modal — when hidden class present, truly hide */
.font-modal-overlay.hidden {
    display: none !important;
}

.font-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modal-slide-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-slide-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.font-modal-header {
    background: linear-gradient(135deg, #1e293b, #475569);
    color: white;
    padding: 18px 24px;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.font-modal-body {
    padding: 24px;
}

.font-modal-msg {
    font-size: 0.92rem;
    color: #475569;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.font-modal-selector-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.font-modal-label {
    font-weight: 700;
    font-size: 0.88rem;
    color: #1e293b;
    white-space: nowrap;
}

.font-modal-select {
    flex: 1;
    height: 40px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.font-modal-select:focus {
    border-color: #475569;
}

.font-modal-info {
    background: #f8fafc;
    border-left: 4px solid #475569;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.6;
    min-height: 48px;
}

.font-modal-actions {
    display: flex;
    gap: 12px;
    padding: 0 24px 24px 24px;
}

.font-modal-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.font-modal-btn-confirm {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.font-modal-btn-confirm:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.font-modal-btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
}

.font-modal-btn-cancel:hover {
    background: #e2e8f0;
}

@media (max-width: 480px) {
    .font-modal-actions {
        flex-direction: column;
    }
}