        :root {
            --primary: #2563eb;
            --primary-dark: #1d4ed8;
            --accent: #f59e0b;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --bg-dark: #0f172a;
            --bg-card: #1e293b;
            --bg-hover: #334155;
            --text: #f1f5f9;
            --text-muted: #94a3b8;
            --border: #334155;
        }
        
        * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background: var(--bg-dark);
            color: var(--text);
            overflow-x: hidden;
            min-height: 100vh;
        }
        
        @keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes spin { to { transform: rotate(360deg); } }
        
        .fade-in { animation: fadeIn 0.6s ease-out forwards; }
        
        /* Offline Bar */
        .offline-bar {
            background: var(--danger);
            color: white;
            text-align: center;
            padding: 0.5rem;
            font-size: 0.85rem;
            font-weight: 600;
            display: none;
            position: sticky;
            top: 0;
            z-index: 300;
        }
        .offline-bar.show { display: block; }
        
        /* Install Banner */
        .install-banner {
            background: linear-gradient(90deg, var(--primary), var(--primary-dark));
            padding: 0.75rem 1rem;
            display: none;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            position: sticky;
            top: 0;
            z-index: 200;
        }
        .install-banner.show { display: flex; }
        .install-banner p { font-size: 0.9rem; font-weight: 600; }
        .install-banner button {
            background: white;
            color: var(--primary);
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            font-weight: 700;
            cursor: pointer;
            white-space: nowrap;
        }
        .install-banner button:last-child {
            background: transparent;
            color: white;
        }
        
        /* Header */
        .app-header {
            background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
            border-bottom: 1px solid var(--border);
            padding: 1.2rem 2rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(10px);
        }
        
        .logo-area { display: flex; align-items: center; gap: 12px; }
        .logo-area img {
            width: 40px; height: 40px;
            min-width: 40px; max-width: 40px;
            border-radius: 10px; flex-shrink: 0; display: block;
        }
        .brand-name { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.5px; }
        .brand-text span { font-size: 0.8rem; color: var(--text-muted); }
        
        .security-badge {
            display: flex; align-items: center; gap: 6px;
            color: var(--text-muted); font-size: 0.8rem;
            background: rgba(16, 185, 129, 0.1);
            padding: 0.5rem 1rem; border-radius: 20px;
            border: 1px solid rgba(16, 185, 129, 0.2);
        }
        
        /* Layout */
        .container { max-width: 1200px; margin: 0 auto; padding: 2rem; }
        .section { display: none; }
        .section.active { display: block; animation: fadeIn 0.5s ease-out; }
        
        /* Hero */
        .hero { text-align: center; padding: 3rem 1rem; }
        .hero h1, .hero h2 { font-size: 2.5rem; margin-bottom: 1rem; background: linear-gradient(to right, #60a5fa, #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
        .hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 600px; margin: 0 auto 2rem; }
        
        /* Notices */
        .disclaimer-banner {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.2);
            border-radius: 12px;
            padding: 1rem;
            margin-bottom: 2rem;
            font-size: 0.85rem;
            color: var(--text-muted);
            display: none;
        }
        .disclaimer-banner.show { display: block; }
        .accuracy-notice {
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.3);
            border-radius: 12px;
            padding: 1rem;
            margin: 1rem 0;
            font-size: 0.85rem;
            color: var(--warning);
            display: flex;
            align-items: flex-start;
            gap: 0.75rem;
        }
        
        /* Level Cards */
        .levels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
        .level-card {
            background: var(--bg-card); border: 2px solid var(--border); border-radius: 20px;
            padding: 2rem; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden;
        }
        .level-card:hover { transform: translateY(-5px); border-color: var(--primary); box-shadow: 0 20px 40px rgba(37, 99, 235, 0.15); }
        .level-card.selected { border-color: var(--accent); background: linear-gradient(135deg, var(--bg-card) 0%, rgba(245, 158, 11, 0.05) 100%); }
        
        .level-badge {
            position: absolute; top: 1rem; right: 1rem;
            padding: 0.25rem 0.75rem; border-radius: 20px;
            font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
        }
        .badge-quick { background: var(--success); color: #000; }
        .badge-standard { background: var(--warning); color: #000; }
        .badge-deep { background: var(--danger); color: #fff; }
        
        .level-icon { font-size: 3rem; margin-bottom: 1rem; }
        .level-card h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
        .level-time { color: var(--accent); font-weight: 600; margin-bottom: 1rem; display: block; }
        
        .test-list { list-style: none; margin: 1rem 0; }
        .test-list li {
            padding: 0.5rem 0; color: var(--text-muted); font-size: 0.9rem;
            display: flex; align-items: center; gap: 0.5rem;
            border-bottom: 1px solid rgba(255,255,255,0.05);
        }
        .test-list li::before { content: "✓"; color: var(--success); font-weight: bold; }
        .test-list li.missing::before { content: "—"; color: var(--text-muted); }
        
        .btn-primary {
            background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
            color: white; border: none; padding: 1rem 2rem; border-radius: 12px;
            font-size: 1rem; font-weight: 600; cursor: pointer; width: 100%; margin-top: 1rem;
            transition: all 0.3s; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
        }
        .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4); }
        .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
        
        /* Modal */
        .modal-overlay {
            position: fixed; inset: 0; background: rgba(0,0,0,0.85);
            backdrop-filter: blur(5px); display: none; align-items: center; justify-content: center;
            z-index: 1000; padding: 1rem;
        }
        .modal-overlay.active { display: flex; }
        .modal-box {
            background: var(--bg-card); border: 1px solid var(--border);
            border-radius: 24px; max-width: 600px; width: 100%;
            max-height: 90vh; overflow-y: auto; padding: 2rem;
        }
        .modal-box h3 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--accent); }
        .modal-box .legal-text {
            background: rgba(0,0,0,0.3); border-left: 3px solid var(--primary);
            padding: 1rem; margin: 1rem 0; border-radius: 0 8px 8px 0;
            font-size: 0.85rem; color: var(--text-muted); line-height: 1.6;
        }
        .consent-item {
            display: flex; gap: 0.75rem; padding: 1rem;
            background: rgba(255,255,255,0.03); border-radius: 12px;
            margin-bottom: 0.75rem; align-items: flex-start;
        }
        .consent-item input[type="checkbox"] {
            width: 20px; height: 20px; margin-top: 2px;
            accent-color: var(--primary); cursor: pointer;
        }
        .consent-item label { cursor: pointer; font-size: 0.9rem; line-height: 1.5; }
        .consent-item strong { color: var(--text); display: block; margin-bottom: 0.25rem; }
        .purpose-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
            gap: 0.85rem;
            margin: 1rem 0;
        }
        .purpose-option {
            display: flex;
            gap: 0.8rem;
            align-items: flex-start;
            padding: 1rem;
            border-radius: 14px;
            border: 1px solid var(--border);
            background: rgba(255,255,255,0.03);
            cursor: pointer;
            transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
        }
        .purpose-option:hover {
            transform: translateY(-2px);
            border-color: rgba(37, 99, 235, 0.45);
        }
        .purpose-option.active {
            border-color: var(--primary);
            background: rgba(37,99,235,0.08);
            box-shadow: 0 0 0 1px rgba(37,99,235,0.18) inset;
        }
        .purpose-option input[type="radio"] {
            width: 18px;
            height: 18px;
            margin-top: 0.2rem;
            accent-color: var(--primary);
            cursor: pointer;
            flex: 0 0 auto;
        }
        .purpose-option-title {
            display: block;
            color: var(--text);
            font-weight: 700;
            margin-bottom: 0.35rem;
        }
        .purpose-option-note {
            display: block;
            color: var(--text-muted);
            font-size: 0.88rem;
            line-height: 1.5;
        }
         
        /* Dashboard */
        .dashboard { display: grid; grid-template-columns: 280px 1fr; gap: 2rem; min-height: 70vh; }
        .sidebar {
            background: var(--bg-card); border-radius: 16px; padding: 1.5rem;
            height: fit-content; position: sticky; top: 100px;
        }
        .progress-container { margin-bottom: 2rem; }
        .progress-bar-bg { background: rgba(255,255,255,0.1); height: 8px; border-radius: 4px; overflow: hidden; margin-top: 0.5rem; }
        .progress-bar-fill {
            height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
            width: 0%; transition: width 0.5s ease; border-radius: 4px;
        }
        .test-menu { list-style: none; }
        .test-menu-item {
            padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 0.5rem;
            display: flex; align-items: center; gap: 0.75rem;
            font-size: 0.9rem; color: var(--text-muted); transition: all 0.2s; cursor: pointer;
        }
        .test-menu-item:hover { background: rgba(255,255,255,0.05); }
        .test-menu-item.active { background: rgba(37, 99, 235, 0.15); color: var(--text); font-weight: 600; }
        .test-menu-item.completed { color: var(--success); }
        .test-menu-item.completed::after { content: "✓"; margin-left: auto; }
        .test-menu-item.failed { color: var(--danger); }
        .test-menu-item.locked { opacity: 0.4; cursor: not-allowed; }
        
        .main-stage { background: var(--bg-card); border-radius: 16px; padding: 2rem; min-height: 500px; }
        .test-panel { display: none; }
        .test-panel.active { display: block; animation: fadeIn 0.4s; }
        .test-header { margin-bottom: 2rem; }
        .test-header h3 { font-size: 1.5rem; margin-bottom: 0.5rem; }
        .test-header p { color: var(--text-muted); }
        .control-bar { display: flex; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
        
        .btn-secondary {
            background: rgba(255,255,255,0.1); color: var(--text); border: 1px solid var(--border);
            padding: 0.75rem 1.5rem; border-radius: 10px; cursor: pointer; transition: all 0.2s;
        }
        .btn-secondary:hover { background: rgba(255,255,255,0.15); }
        .btn-success { background: var(--success); color: #000; border: none; }
        .btn-danger { background: var(--danger); color: #fff; border: none; }
        
        .permission-box {
            text-align: center; padding: 3rem 2rem;
            border: 2px dashed var(--border); border-radius: 16px; margin: 2rem 0;
        }
        .permission-box button { margin-top: 1rem; }
        
        /* Screen Tests */
        .touch-grid-canvas {
            width: 100%; height: 400px; background: #000;
            border-radius: 12px; touch-action: none; cursor: crosshair;
        }
        .touch-multi-canvas {
            width: 100%; height: 300px; background: #000; border-radius: 12px; touch-action: none;
        }
        .audio-visualizer {
            width: 100%; height: 120px; background: rgba(0,0,0,0.3);
            border-radius: 12px; margin: 1rem 0;
        }
        .sensor-chart {
            width: 100%; height: 200px; background: rgba(0,0,0,0.2);
            border-radius: 12px; margin: 1rem 0; position: relative; overflow: hidden;
        }
        .camera-preview {
            width: 100%; max-width: 400px; border-radius: 12px;
            background: #000; margin: 1rem auto; display: block;
        }
        .spinner {
            width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.1);
            border-top-color: var(--primary); border-radius: 50%;
            animation: spin 1s linear infinite; margin: 2rem auto;
        }
        
        /* Results */
        .results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
        .result-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; text-align: center; }
        .result-score { font-size: 3rem; font-weight: 800; margin: 1rem 0; }
        .score-excellent { color: var(--success); }
        .score-good { color: #34d399; }
        .score-fair { color: var(--warning); }
        .score-poor { color: var(--danger); }
        .used-report-highlight {
            margin-top: 1.2rem;
            padding: 1rem 1.1rem;
            border-radius: 14px;
            border: 1px solid var(--border);
            background: rgba(255,255,255,0.03);
            line-height: 1.7;
        }
        .disclaimer-list {
            margin: 1rem 0 0 1.25rem;
            color: var(--text-muted);
            line-height: 1.75;
        }
        .disclaimer-list li { margin-bottom: 0.6rem; }
        .status-badge {
            display: inline-block; padding: 0.5rem 1rem; border-radius: 20px;
            font-size: 0.85rem; font-weight: 700; margin-top: 0.5rem;
        }
        
        /* Share Section */
        .share-section {
            background: linear-gradient(135deg, rgba(37,99,235,0.1) 0%, rgba(139,92,246,0.1) 100%);
            border: 1px solid rgba(37,99,235,0.3);
            border-radius: 20px;
            padding: 2rem;
            margin: 2rem 0;
            text-align: center;
        }
        .share-buttons { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
        .share-btn {
            padding: 0.75rem 1.5rem; border-radius: 12px; border: none;
            font-weight: 600; cursor: pointer; transition: all 0.2s;
            display: flex; align-items: center; gap: 0.5rem;
        }
        .share-twitter { background: #1da1f2; color: white; }
        .share-facebook { background: #4267B2; color: white; }
        .share-whatsapp { background: #25d366; color: white; }
        .share-copy { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
        .share-btn:hover { transform: translateY(-2px); }
        
        .og-preview {
            background: white; color: #333; border-radius: 12px;
            padding: 1rem; margin: 1rem auto; max-width: 400px;
            text-align: left; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }
        .og-preview h4 { color: var(--primary); margin-bottom: 0.5rem; }
        .og-preview .og-score { font-size: 2rem; font-weight: 800; color: #10b981; }
        
        /* --- Interaction Gate System --- */
        .gate-locked {
            opacity: 0.38;
            cursor: not-allowed !important;
            pointer-events: none;
            filter: grayscale(0.6);
        }
        .gate-hint {
            width: 100%;
            font-size: 0.82rem;
            color: var(--text-muted);
            padding: 0.45rem 0.75rem;
            background: rgba(245,158,11,0.08);
            border-left: 3px solid var(--warning);
            border-radius: 0 6px 6px 0;
            line-height: 1.5;
            margin-bottom: 0.5rem;
            flex-basis: 100%;
        }
        .gate-hint-alert {
            background: rgba(239,68,68,0.12) !important;
            border-left-color: var(--danger) !important;
            color: var(--danger) !important;
        }
        @keyframes gateShake {
            0%,100% { transform: translateX(0); }
            20%,60%  { transform: translateX(-7px); }
            40%,80%  { transform: translateX(7px); }
        }
        .gate-shake { animation: gateShake 0.5s ease-in-out; }

        /* Print / PDF */
        .pdf-header { display: none; }
        .pdf-page-header { display: none; }

        @media print {
            body { background: white !important; color: black !important; font-family: Arial, sans-serif; margin: 0; }
            .no-print, .app-header, .sidebar, .control-bar, .btn-primary, .install-banner, .share-section, .offline-bar { display: none !important; }
            .section { display: none !important; }
            #section-results { display: block !important; position: static !important; }
            .container { max-width: 100%; padding: 0.5cm 1cm 1cm; }

            /* Slim branded header repeated on every page */
            .pdf-page-header {
                display: flex !important;
                align-items: center;
                gap: 10px;
                position: fixed;
                top: 0; left: 0; right: 0;
                background: white;
                padding: 5px 1cm;
                border-bottom: 2px solid #2563eb;
                z-index: 9999;
            }
            .pdf-page-header img {
                width: 28px !important;
                height: 28px !important;
                min-width: 28px !important;
                max-width: 28px !important;
                border-radius: 6px;
                display: block !important;
            }
            .pdf-page-header span { font-size: 12pt; font-weight: 700; color: #2563eb; }

            /* Push content below the fixed header */
            #section-results .container { padding-top: 1.4cm; }

            /* Main first-page header */
            .pdf-header {
                display: block !important;
                text-align: center;
                margin-bottom: 1cm;
                padding-bottom: 0.5cm;
                border-bottom: 1px solid #e5e7eb;
            }
            .pdf-header > img {
                width: 48px !important;
                height: 48px !important;
                min-width: 48px !important;
                max-width: 48px !important;
                border-radius: 10px;
                display: block !important;
                margin: 0 auto 0.4cm !important;
            }
            .pdf-header h1 { color: #2563eb !important; font-size: 20pt; margin: 0; }
            .pdf-header p { color: #666 !important; margin: 0.15cm 0; font-size: 10pt; }

            /* Cards */
            .result-card { border: 1px solid #e5e7eb !important; background: rgba(248,250,252,0.85) !important; break-inside: avoid; page-break-inside: avoid; color: black !important; border-radius: 8px; }
            .results-grid .result-card { background: rgba(235,242,255,0.6) !important; }
            .result-score { color: #2563eb !important; -webkit-text-fill-color: #2563eb !important; }
            .main-stage { background: white !important; color: black !important; box-shadow: none !important; border: 1px solid #e5e7eb; }
            table { color: black !important; }
            th, td { border-bottom: 1px solid #ddd !important; color: black !important; }
            .used-report-highlight, .accuracy-notice { background: rgba(248,250,252,0.85) !important; color: #111827 !important; border-color: #d1d5db !important; }
            .disclaimer-list, .disclaimer-list li { color: #374151 !important; }
        }
        
        @media (max-width: 768px) {
            .dashboard { grid-template-columns: 1fr; }
            .sidebar { position: relative; top: 0; order: 2; }
            .hero h2 { font-size: 1.75rem; }
            .levels-grid { grid-template-columns: 1fr; }
            .container { padding: 1rem; }
            .share-buttons { flex-direction: column; }
            .share-btn { width: 100%; justify-content: center; }
        }
        
        .hidden { display: none !important; }
        .text-center { text-align: center; }
        .mt-2 { margin-top: 1rem; }
