/* ==========================================================================
       RESET & BASE STYLES
       CRITICAL: Do NOT apply font-family to '*' so MathJax fonts stay sharp!
       ========================================================================== */
    * { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
    body { 
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
        font-size: 14px; 
        background-color: #f1f5f9; 
        color: #1f2937; 
        user-select: none; 
        -webkit-user-select: none; 
        overflow: hidden; 
        height: 100vh; 
        height: 100dvh;
        line-height: 1.5;
    }

    @media print { body { display: none !important; } }
    
    #instruction-screen, #result-screen { 
        display: none; height: 100%; width: 100%; background: #f8fafc; 
        overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; 
    }
    #instruction-screen.active, #result-screen.active { display: block; }

    #exam-container { 
        display: none; height: 100%; width: 100%; flex-direction: row; background: #ffffff; overflow: hidden;
    }
    #exam-container.active { display: flex; }

    /* ==========================================================================
       TOP HEADER (QWIK STUDY THEME)
       ========================================================================== */
    .top-header { 
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 10px 24px;
        border-bottom: 1px solid #E5E7EB;
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 62px;
        flex-shrink: 0;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
        z-index: 100;
    }
    .header-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
    .header-logo { width: 35px; height: 35px; object-fit: contain; transform: scale(1.08); }
    .header-title-text { font-size: 17px; font-weight: 800; color: #111827; letter-spacing: -0.2px; }
    
    .nav-actions { display: flex; align-items: center; gap: 10px; }
    .nav-actions .nav-link {
        text-decoration: none; font-weight: 600; font-size: 13.5px; color: #4B5563;
        display: inline-flex; align-items: center; gap: 6px; padding: 7px 15px;
        border-radius: 9999px; background: #EDF2F7; transition: all 0.2s;
    }
    .nav-actions .nav-link:hover, .nav-actions .nav-link.active { color: #FF007A; background: #fce7f3; }
    .join-telegram-btn {
        background: #EDF2F7; color: #0284C7; border-radius: 9999px; height: 36px;
        padding: 0 15px; font-weight: 700; font-size: 13.5px; text-decoration: none;
        display: inline-flex; align-items: center; gap: 6px; transition: all 0.2s;
    }
    .join-telegram-btn:hover { background: #E0F2FE; transform: translateY(-1px); }

    /* MOBILE DRAWER LINKS */
    .palette-mobile-nav {
        display: none; padding: 12px 16px; border-bottom: 1px solid #E5E7EB;
        background: #ffffff; gap: 8px; flex-direction: column;
    }
    .join-home-btn {
        background: #EDF2F7; color: #475569; border: 1px solid #E2E8F0; border-radius: 9999px;
        height: 36px; padding: 0 14px; font-weight: 700; font-size: 13px; text-decoration: none;
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    }

    /* ==========================================================================
       START SCREEN (RESTORED ORIGINAL QWIK STUDY PINK-ORANGE GRADIENT THEME)
       ========================================================================== */
    .sp-hero { 
        background: linear-gradient(135deg, #ff007f 0%, #ff7f00 100%); 
        color: white; text-align: center; padding: 40px 20px 80px 20px;
    }
    .sp-hero h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }
    .sp-hero p { font-size: 15px; opacity: 0.95; max-width: 600px; margin: 0 auto; font-weight: 500; }

    .start-page-wrapper { 
        max-width: 800px; margin: -42px auto 140px auto; width: 95%; background: #ffffff; 
        border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.08); 
        display: flex; flex-direction: column; position: relative; z-index: 10; border: 1px solid #e2e8f0; 
    }
    .sp-content { padding: 24px 32px; display: flex; flex-direction: column; gap: 20px; }
    .sp-title { font-size: 22px; font-weight: 800; color: #0f172a; margin-bottom: 12px; letter-spacing: -0.4px; }
    .sp-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 18px; }
    .sp-tag { padding: 4px 14px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
    .tag-cat { background: #fee2e2; color: #991b1b; }
    .tag-diff { background: #fef3c7; color: #b45309; }
    
    .sp-metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; text-align: center; border-top: 1px solid #f1f5f9; padding-top: 18px; }
    .sp-metric-val { display: block; font-size: 22px; font-weight: 800; color: #0f172a; margin-bottom: 2px; }
    .sp-metric-lbl { font-size: 11px; color: #64748b; font-weight: 700; text-transform: uppercase; }

    .sp-profile-wrap { display: flex; align-items: center; gap: 16px; background: #f8fafc; padding: 12px 16px; border-radius: 8px; border: 1px solid #e2e8f0; }
    .sp-avatar { width: 46px; height: 46px; background: #e2e8f0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
    .sp-input { flex: 1; padding: 11px 14px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14.5px; font-weight: 600; outline: none; background: #ffffff; color: #1e293b; width: 100%; transition: all 0.2s; }
    .sp-input:focus { border-color: #ff007f; box-shadow: 0 0 0 2px rgba(255, 0, 127, 0.12); }

    .sp-setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .sp-setup-col h4 { font-size: 12px; color: #64748b; margin-bottom: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
    .custom-radio-group { display: flex; flex-direction: column; gap: 8px; }
    .custom-radio-lbl { display: flex; align-items: center; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 6px; cursor: pointer; font-weight: 600; color: #334155; background: #ffffff; font-size: 13.5px; transition: all 0.2s;}
    .custom-radio-lbl:hover { background: #f8fafc; border-color: #cbd5e1; }
    .custom-radio-lbl input { display: none; }
    .custom-radio-lbl input:checked ~ .cr-box { border-color: #ff007f; background: #ff007f; box-shadow: inset 0 0 0 3px #ffffff; }
    .cr-box { width: 18px; height: 18px; border: 2px solid #cbd5e1; border-radius: 50%; margin-right: 12px; flex-shrink: 0; }

    .sp-details { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; background: #ffffff; }
    .sp-summary { padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: #f8fafc; font-weight: 700; color: #1e293b; font-size: 14px; }
    .sp-summary::-webkit-details-marker { display: none; }
    .sp-inst-content { padding: 18px 20px; font-size: 14px; line-height: 1.6; color: #475569; }

    .sp-footer {
        position: fixed; bottom: 0; left: 0; right: 0; background: #ffffff; 
        padding: 14px 24px env(safe-area-inset-bottom, 14px);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.06); border-top: 1px solid #e2e8f0;
        display: flex; flex-direction: column; align-items: center; gap: 12px; z-index: 100;
    }
    .sp-checkbox-lbl { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: #1e293b; }
    .sp-checkbox-lbl input { display: none; }
    .sp-cb-box { width: 20px; height: 20px; border: 2px solid #cbd5e1; border-radius: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #ffffff; }
    .sp-checkbox-lbl input:checked + .sp-cb-box { background: #22c55e; border-color: #22c55e; }
    .sp-cb-box svg { fill: none; stroke: white; stroke-width: 3; stroke-linecap: round; width: 12px; height: 12px; opacity: 0; }
    .sp-checkbox-lbl input:checked + .sp-cb-box svg { opacity: 1; }
    
    .btn-start-massive {
        background: linear-gradient(135deg, #ff007f 0%, #ff7f00 100%);
        color: white; border: none; padding: 14px 32px; font-size: 15px; font-weight: 800;
        border-radius: 6px; cursor: pointer; width: 100%; max-width: 400px;
        transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.5px; box-shadow: 0 4px 10px rgba(255, 0, 102, 0.2);
    }
    .btn-start-massive:disabled { background: #cbd5e1; color: #94a3b8; cursor: not-allowed; box-shadow: none; }
    .btn-start-massive:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(255, 0, 102, 0.3); }

    /* ==========================================================================
       EXAM INTERFACE (TCS iON + FULL-SIZE CLEAR MATHJAX)
       ========================================================================== */
    .secondary-header { 
        background-color: #337ab7; color: #ffffff; padding: 6px 20px; display: flex; 
        justify-content: space-between; align-items: center; font-size: 13px; gap: 12px; flex-shrink: 0; border-bottom: 1px solid #286090;
    }
    .sec-header-controls { display: flex; align-items: center; gap: 12px; margin-left: auto; }
    .secondary-header select { 
        padding: 4px 8px; font-size: 12.5px; border: 1px solid #204d74; border-radius: 4px;
        background: #ffffff; color: #1e293b; font-weight: 600; outline: none; cursor: pointer;
    }
    .btn-rough-toggle {
        background: #ffffff; color: #1e3a8a; border: 1px solid #204d74; padding: 4px 10px;
        border-radius: 4px; font-size: 12.5px; font-weight: 700; cursor: pointer; display: inline-flex;
        align-items: center; gap: 5px; white-space: nowrap;
    }
    .btn-rough-toggle.active { background: #fef08a; color: #854d0e; border-color: #ca8a04; }

    /* SOLUTION FILTER BAR */
    .sol-filter-bar {
        display: none; background: #f1f5f9; padding: 7px 20px; border-bottom: 1px solid #cbd5e1;
        align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
    }
    .sol-filter-bar.active { display: flex; }
    .sol-filter-lbl { font-size: 11.5px; font-weight: 800; color: #475569; text-transform: uppercase; }
    .filter-pill {
        background: #ffffff; border: 1px solid #cbd5e1; color: #334155; padding: 3px 11px;
        border-radius: 999px; font-size: 11.5px; font-weight: 700; cursor: pointer;
    }
    .filter-pill.active { background: #337ab7; color: #ffffff; border-color: #286090; }

    .mobile-top-bar { 
        display: none; background: #337ab7; padding: 8px 14px; justify-content: space-between; align-items: center; color: white; border-bottom: 1px solid #286090; flex-shrink: 0;
    }
    .mobile-nav-toggle { 
        background: #286090; color: white; border: 1px solid #204d74; padding: 6px 12px; border-radius: 4px; font-size: 13px; font-weight: 700; cursor: pointer; 
    }

    .left-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #ffffff; position: relative; }
    .q-header { 
        display: flex; justify-content: space-between; align-items: center; padding: 8px 20px; 
        border-bottom: 1px solid #cbd5e1; font-weight: 700; font-size: 14.5px; background: #f8fafc; 
        flex-shrink: 0; color: #0f172a; 
    }
    .q-header-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .topic-badge { background: #e0f2fe; color: #0369a1; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 4px; }
    .live-q-timer { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 4px; background: #dcfce7; color: #166534; }
    
    .marks { font-size: 13.5px; font-weight: 700; color: #64748b; white-space: nowrap; }
    .pos-mark { color: #16a34a; }
    .neg-mark { color: #dc2626; }
    
    /* DYNAMIC PANE SYSTEM: 2-Column for Speed Maths & DI | Single Full-Width for Arithmetic */
    .q-content { flex: 1; display: flex; flex-direction: row; overflow: hidden; position: relative; }
    .directions-pane { 
        width: 46%; padding: 20px 24px; overflow-y: auto; border-right: 1px solid #cbd5e1; 
        font-size: 15px; line-height: 1.65; color: #1e293b; background: #ffffff;
    }
    .question-pane { 
        width: 54%; padding: 20px 24px; overflow-y: auto; 
        font-size: 15.5px; line-height: 1.65; color: #0f172a; background: #ffffff;
    }
    /* Single-Column Merged Mode for Arithmetic Word Problems */
    .q-content.single-col-mode .directions-pane {
        display: none !important;
    }
    .q-content.single-col-mode .question-pane {
        width: 100% !important;
        max-width: 960px;
        padding: 24px 32px;
    }

    /* MATHJAX SIZE & CLARITY FIX */
    .directions-pane mjx-container, .question-pane mjx-container, .opt-row mjx-container { 
        display: inline-block !important;
        margin: 2px 2px !important;
        vertical-align: middle;
    }
    .question-text mjx-container {
        font-size: 116% !important;
    }
    .opt-row mjx-container {
        font-size: 108% !important;
    }

    .question-text { margin-bottom: 18px; font-weight: 600; font-size: 16px; line-height: 1.7; color: #0f172a; }
    .quad-line { margin-bottom: 8px; display: block; font-size: 16.5px; }
    
    .opt-row { margin-bottom: 10px; }
    .opt-row label { 
        display: flex; align-items: center; padding: 10px 14px; border-radius: 6px; cursor: pointer; 
        border: 1px solid #cbd5e1; transition: all 0.15s; background: #ffffff; width: 100%; color: #1e293b; font-weight: 500;
        min-height: 44px; font-size: 15px;
    }
    .opt-row label:hover { background: #f8fafc; border-color: #94a3b8; }
    .opt-row input[type="radio"] { margin-right: 12px; cursor: pointer; transform: scale(1.15); flex-shrink: 0; accent-color: #337ab7; }
    
    /* DIGITAL ROUGH SHEET OVERLAY */
    .rough-pad-overlay {
        display: none; position: absolute; inset: 0; background: rgba(254, 252, 232, 0.9);
        z-index: 50; flex-direction: column;
    }
    .rough-pad-overlay.active { display: flex; }
    .rough-toolbar {
        background: #fef08a; border-bottom: 1px solid #fde047; padding: 6px 16px;
        display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: #713f12;
    }
    .rough-tools-group { display: flex; gap: 6px; }
    .rough-btn {
        background: #ffffff; border: 1px solid #eab308; color: #713f12; padding: 4px 10px;
        border-radius: 4px; font-size: 11.5px; font-weight: 700; cursor: pointer;
    }
    .rough-btn.active { background: #ca8a04; color: #ffffff; }
    #rough-canvas { flex: 1; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }

    /* EXAM FOOTER (NO !IMPORTANT ON DISPLAY SO JS CAN HIDE SOL BUTTONS!) */
    .q-footer { padding: 10px 20px; border-top: 1px solid #cbd5e1; background: #f8fafc; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
    .footer-left, .footer-right { display: flex; gap: 10px; }
    .btn { padding: 9px 16px; font-size: 13.5px; border-radius: 4px; cursor: pointer; border: 1px solid #cbd5e1; background: #ffffff; color: #334155; font-weight: 600; }
    .btn:hover { background: #e2e8f0; }
    .btn-primary { background: #337ab7; color: #ffffff; border-color: #286090; }
    .btn-primary:hover { background: #286090; }

    /* PALETTE DRAWER */
    .right-panel { width: 275px; display: flex; flex-direction: column; background: #f8fafc; flex-shrink: 0; transition: transform 0.3s ease; z-index: 100; border-left: 1px solid #94a3b8; }
    .candidate-info { display: flex; padding: 12px 14px; border-bottom: 1px solid #e2e8f0; background: #ffffff; align-items: center; }
    .cand-img { width: 44px; height: 44px; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px; margin-right: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
    .time-left { font-size: 17px; font-weight: 800; color: #0f172a; }

    .legend-box { padding: 10px 12px; font-size: 11.5px; border-bottom: 1px solid #e2e8f0; color: #475569; font-weight: 600; background: #ffffff; }
    .legend-row { display: flex; margin-bottom: 6px; }
    .leg-item { width: 50%; display: flex; align-items: center; gap: 6px; }
    
    .pal-item { width: 29px; height: 27px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #ffffff; font-size: 12px; border-radius: 3px; cursor: pointer; }
    .pal-item.filtered-out { opacity: 0.2; pointer-events: none; }
    .not-vis { background-color: #ffffff; color: #475569; border: 1px solid #cbd5e1; }
    .not-ans { background-color: #ef4444; border-radius: 0 0 8px 8px; border: 1px solid #dc2626; }
    .ans { background-color: #22c55e; border-radius: 8px 8px 0 0; border: 1px solid #16a34a; }
    .mark { background-color: #9333ea; border-radius: 50%; border: 1px solid #7e22ce; }
    .mark-ans { background-color: #9333ea; border-radius: 50%; position: relative; border: 1px solid #7e22ce; }
    .mark-ans::after { content: ''; position: absolute; right: -2px; bottom: -2px; background: #22c55e; border-radius: 50%; width: 9px; height: 9px; border: 1.5px solid #ffffff; }
    .current-q { box-shadow: 0 0 0 2px #ffffff, 0 0 0 3.5px #0f172a !important; }

    .palette-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #eef2f6; }
    .pal-header { padding: 8px 14px; font-weight: 700; font-size: 12.5px; border-bottom: 1px solid #cbd5e1; color: #fff; background: #337ab7;}
    .palette-grid { padding: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; overflow-y: auto; flex: 1; align-content: start; }

    .right-footer { padding: 12px; background: #ffffff; border-top: 1px solid #cbd5e1; }
    .btn-submit { width: 100%; background: #22c55e; color: #ffffff; border: 1px solid #16a34a; padding: 11px; border-radius: 5px; font-size: 14.5px; font-weight: 700; cursor: pointer; }
    .btn-submit:hover { background: #16a34a; }

    .solution-box { background-color: #f0fdf4; color: #14532d; padding: 16px; border-radius: 8px; margin-top: 18px; border: 1px solid #bbf7d0; display: none; font-size: 14.5px; line-height: 1.7;}

    /* MODALS */
    .overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); display: none; align-items: center; justify-content: center; z-index: 1000; }
    .overlay.active { display: flex; }
    .modal-box { background: #ffffff; border-radius: 10px; width: 420px; max-width: 92%; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
    .modal-header { background: #337ab7; color: #ffffff; padding: 14px 18px; font-size: 15px; font-weight: 700; }
    .modal-body { padding: 20px 18px; font-size: 14.5px; text-align: center; color: #334155; }
    .modal-footer { padding: 12px 18px; background: #f8fafc; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #e2e8f0; }
    .modal-footer button { padding: 8px 16px; border-radius: 5px; font-weight: 700; cursor: pointer; border: none; font-size: 13px; }
    #mod-btn-no { background: #e2e8f0; color: #475569; }
    #mod-btn-yes { background: #22c55e; color: #ffffff; }

    /* ==========================================================================
       RESULT DASHBOARD (CLEAN LAYOUT + QWIK STUDY BRAND THEME)
       ========================================================================== */
    .res-container { 
        max-width: 920px; width: 95%; margin: 24px auto 60px auto; 
        display: flex; flex-direction: column; gap: 18px;
    }
    .res-top-banner {
        background: linear-gradient(135deg, #ff007f 0%, #ff7f00 100%);
        color: #ffffff; border-radius: 12px; padding: 24px 28px;
        display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
        box-shadow: 0 8px 20px rgba(255, 0, 127, 0.18);
    }
    .res-banner-left h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; color: #ffffff; letter-spacing: -0.3px; }
    .res-banner-left p { font-size: 13.5px; color: rgba(255,255,255,0.92); font-weight: 600; }
    
    .res-score-pill {
        background: rgba(255,255,255,0.18); backdrop-filter: blur(8px);
        border: 1px solid rgba(255,255,255,0.35);
        padding: 12px 24px; border-radius: 10px; text-align: center;
    }
    .res-score-pill .score-big { font-size: 36px; font-weight: 800; color: #ffffff; line-height: 1; }
    .res-score-pill .score-lbl { font-size: 11px; color: #ffffff; text-transform: uppercase; font-weight: 800; letter-spacing: 0.6px; margin-top: 4px; display: block; }

    /* Dedicated Action Buttons Bar (Never cuts off on mobile!) */
    .res-actions-bar {
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    }
    .btn-res {
        padding: 12px 16px; font-size: 13.5px; font-weight: 800; border-radius: 8px; cursor: pointer;
        border: none; color: white; display: inline-flex; align-items: center; justify-content: center;
        gap: 8px; transition: transform 0.15s, box-shadow 0.15s; text-transform: uppercase; letter-spacing: 0.3px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    }
    .btn-res:hover { transform: translateY(-2px); }
    .btn-sol { background: #f59e0b; }
    .btn-rank { background: #0ea5e9; }
    .btn-hist { background: #8b5cf6; }
    .btn-restart { background: #22c55e; }

    .res-card {
        background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 24px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    }
    .res-card-header {
        font-size: 14px; font-weight: 800; color: #0f172a; text-transform: uppercase; letter-spacing: 0.4px;
        margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9;
        display: flex; align-items: center; justify-content: space-between;
    }

    .stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
    .stat-box { border: 1px solid #e2e8f0; background: #f8fafc; padding: 14px 10px; text-align: center; border-radius: 8px; }
    .stat-box h3 { font-size: 21px; font-weight: 800; margin-bottom: 2px; color: #0f172a; }
    .stat-box p { font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 700; }
    .text-green { color: #16a34a !important; }
    .text-red { color: #dc2626 !important; }
    .text-blue { color: #2563eb !important; }

    .res-two-col { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; }

    .table-responsive { width: 100%; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
    .tac-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
    .tac-table th, .tac-table td { padding: 11px 12px; text-align: center; border-bottom: 1px solid #e2e8f0; }
    .tac-table th { background: #f8fafc; font-weight: 800; color: #475569; text-transform: uppercase; font-size: 11px; }
    .tac-table td:first-child, .tac-table th:first-child { text-align: left; font-weight: 700; color: #1e293b; }

    .topic-cards { display: flex; flex-direction: column; gap: 12px; }
    .tc-card { border: 1px solid #e2e8f0; padding: 14px 16px; border-radius: 8px; position: relative; overflow: hidden; background: #f8fafc; display: flex; justify-content: space-between; align-items: center; }
    .tc-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
    .tc-card.strong::before { background: #22c55e; }
    .tc-card.weak::before { background: #ef4444; }
    .tc-title { font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 800; margin-bottom: 2px; }
    .tc-topic { font-size: 14.5px; font-weight: 800; color: #0f172a; }
    .tc-acc { font-size: 20px; font-weight: 800; }

    .q-map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; }
    .q-map-box { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 13px; font-weight: 800; cursor: pointer; color: white; transition: transform 0.15s; }
    .q-map-box:hover { transform: scale(1.08); }
    .qmb-cor { background-color: #22c55e; }
    .qmb-wr { background-color: #ef4444; }
    .qmb-skp { background-color: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

    .intel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .intel-card { border: 1px solid #e2e8f0; background: #f8fafc; padding: 14px; border-radius: 8px; }
    .intel-rec-card { background: #f0fdf4; border-color: #bbf7d0; }
    .intel-title { font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 800; margin-bottom: 6px; }
    .intel-val { font-size: 15px; font-weight: 800; color: #0f172a; margin-bottom: 4px; }
    .intel-sub { font-size: 12.5px; color: #475569; line-height: 1.45; }
    .intel-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 800; text-transform: uppercase; margin-bottom: 6px; }
    .intel-elite { background: #dcfce7; color: #166534; }
    .intel-advanced { background: #dbeafe; color: #1e40af; }
    .intel-good { background: #fef9c3; color: #854d0e; }
    .intel-average { background: #ffedd5; color: #9a3412; }
    .intel-needs-practice { background: #fee2e2; color: #991b1b; }

    /* ==========================================================================
       MOBILE RESPONSIVE FIXES (NO CUTOFF, NO DOUBLE FOOTER, READABLE FONTS)
       ========================================================================== */
    .palette-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 99; }

    @media (max-width: 768px) {
        body { font-size: 14px; }
        .hide-on-mobile { display: none !important; }
        
        .top-header { padding: 8px 14px; height: 54px; }
        .header-logo { width: 28px; height: 28px; }
        .header-title-text { font-size: 15px; }

        #exam-container .top-header { display: none !important; }
        .palette-mobile-nav { display: flex !important; }
        .mobile-top-bar { display: flex !important; }

        /* Clean 1-row Mobile Secondary Bar */
        .secondary-header { 
            padding: 6px 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; color: #334155; 
        }
        .sec-header-controls { width: 100%; justify-content: space-between; gap: 6px; margin-left: 0; }
        .secondary-header select { border: 1px solid #cbd5e1; color: #1e293b; font-weight: 600; padding: 4px 6px; font-size: 12px; }
        .btn-rough-toggle { padding: 4px 8px; font-size: 12px; border-color: #cbd5e1; }

        .q-header { padding: 8px 12px; font-size: 13.5px; }
        
        /* Mobile Question Content & Font Sizing */
        .q-content { flex-direction: column !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
        .directions-pane { 
            width: 100% !important; flex: none !important; border-right: none; 
            border-bottom: 3px solid #e2e8f0; overflow-y: visible !important; 
            padding: 14px 14px !important; font-size: 15px !important; 
        }
        .question-pane, .q-content.single-col-mode .question-pane { 
            width: 100% !important; flex: none !important; overflow-y: visible !important; 
            padding: 16px 14px 24px 14px !important; font-size: 15.5px !important; 
        }
        .question-text { font-size: 16px !important; }
        .opt-row label { font-size: 15px !important; padding: 11px 14px !important; }
        
        /* Fixed Mobile Footer: Do NOT use display:flex !important so JS can hide/show properly! */
        .q-footer { padding: 8px 10px; flex-direction: column; gap: 6px; }
        .footer-left, .footer-right { width: 100%; gap: 6px; }
        .footer-left .btn, .footer-right .btn { flex: 1; text-align: center; padding: 10px 6px; font-size: 13px; }
        
        .right-panel {
            position: fixed; top: 0; left: 0; bottom: 0; width: 82% !important; max-width: 290px !important;
            transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,0.25); z-index: 105;
        }
        .right-panel.open { transform: translateX(0); }
        .palette-backdrop.open { display: block; }
        
        /* Mobile Start Page */
        .sp-hero { padding: 24px 16px 52px 16px; }
        .sp-hero h1 { font-size: 22px; }
        .start-page-wrapper { width: calc(100% - 20px); margin: -28px auto 150px auto; }
        .sp-content { padding: 18px 14px; gap: 16px; }
        .sp-metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
        .sp-setup-grid { grid-template-columns: 1fr; gap: 14px; }

        /* Mobile Result Screen Fit */
        .res-container { width: 94%; margin: 14px auto 40px auto; gap: 14px; }
        .res-top-banner { padding: 18px 16px; flex-direction: column; text-align: center; }
        .res-score-pill { width: 100%; }
        .res-actions-bar { grid-template-columns: repeat(2, 1fr); gap: 8px; }
        .btn-res { padding: 11px 10px; font-size: 12.5px; }
        .res-card { padding: 16px 14px; }
        .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
        .stat-box { padding: 10px 6px; }
        .stat-box h3 { font-size: 18px; }
        .res-two-col, .intel-grid { grid-template-columns: 1fr; }
    }

    .score-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 13px; }
    .score-table th, .score-table td { border: 1px solid #e2e8f0; padding: 10px; text-align: left; }
    .score-table th { background: #f8fafc; color: #334155; font-weight: 700; }

    .watermark-grid { position: fixed; inset: 0; pointer-events: none; z-index: 99999; display: flex; flex-wrap: wrap; opacity: 0.025; font-size: 18px; font-weight: 800; color: #000; justify-content: space-around; align-content: space-around; }
    .wm-item { padding: 40px; transform: rotate(-35deg); white-space: nowrap; }

    .text-size-medium .directions-pane, .text-size-medium .question-pane { font-size: 15px; }
    .text-size-large .directions-pane, .text-size-large .question-pane,
    .text-size-large .question-text, .text-size-large .opt-row label { font-size: 17.5px !important; }
    .text-size-xlarge .directions-pane, .text-size-xlarge .question-pane,
    .text-size-xlarge .question-text, .text-size-xlarge .opt-row label { font-size: 20px !important; }