:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-rgb: 124, 58, 237;
    --bg: #0a0a1e;
    --surface: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.08);
    --text: #f0f0f5;
    --text-sec: #a0a0b8;
    --text-dim: #5a5a70;
    --handle: #22c55e;
    --handle-rgb: 34, 197, 94;
    --limit: #ef4444;
    --limit-rgb: 239, 68, 68;
}

[data-theme="light"] {
    --bg: #f5f3ff;
    --surface: rgba(124,58,237,0.06);
    --border: rgba(124,58,237,0.12);
    --text: #1a1025;
    --text-sec: #5a4a70;
    --text-dim: #8a7aa0;
}
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] .app-loader { background: var(--bg); }
[data-theme="light"] .stimulus-card { background: rgba(124,58,237,0.04); border-color: rgba(124,58,237,0.12); }
[data-theme="light"] .detail-section { background: rgba(124,58,237,0.04); border-color: rgba(124,58,237,0.1); }
[data-theme="light"] .gauge-inner { background: rgba(124,58,237,0.08); }
[data-theme="light"] .back-link { color: var(--primary); }
[data-theme="light"] .lang-btn { background: rgba(124,58,237,0.08); color: var(--text); border-color: rgba(124,58,237,0.18); }
[data-theme="light"] .lang-menu { background: rgba(245,243,255,0.95); border-color: rgba(124,58,237,0.18); }
[data-theme="light"] .lang-option { color: #5a4a70; }
[data-theme="light"] .lang-option:hover { background: rgba(124,58,237,0.1); }
[data-theme="light"] .lang-option.active { background: rgba(124,58,237,0.15); color: var(--text); }
[data-theme="light"] .loader-spinner { border-color: rgba(124,58,237,0.12); border-top-color: var(--primary); }
[data-theme="light"] .meter-inner { background: var(--bg); }
[data-theme="light"] .intensity-bg { opacity: 0.3; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button, a, [role="button"] { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

/* App Loader */
.app-loader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 10000; transition: opacity 0.3s, visibility 0.3s; }
.app-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-content { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.loader-emoji { font-size: 48px; animation: bounce 1s ease-in-out infinite; }
.loader-spinner { width: 40px; height: 40px; border: 3px solid rgba(255,255,255,0.1); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loader-text { font-size: 14px; color: var(--text-sec); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* Screens */
.screen { display: none; min-height: 100vh; padding: 20px; }
.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Intro */
.intro-icon { font-size: 72px; animation: bounce 3s ease-in-out infinite; }
.intro-title { font-size: 32px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--primary-light)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-align: center; margin-top: 12px; }
.intro-subtitle { color: var(--text-sec); font-size: 16px; margin-top: 4px; }
.hero-badge { background: rgba(var(--primary-rgb),0.15); color: var(--primary-light); padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; margin-top: 12px; border: 1px solid rgba(var(--primary-rgb),0.3); }
.hero-desc { color: var(--text-sec); font-size: 15px; line-height: 1.6; max-width: 360px; text-align: center; margin-top: 16px; }
.intro-meta { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.intro-meta span { background: var(--surface); border: 1px solid var(--border); padding: 6px 14px; border-radius: 20px; font-size: 13px; color: var(--text-sec); }
.type-preview { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 380px; margin-top: 16px; }
.type-chip { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }
.btn-start { padding: 16px 48px; font-size: 18px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #5b21b6); border: none; border-radius: 16px; cursor: pointer; transition: all 0.3s; min-height: 52px; margin-top: 20px; position: relative; overflow: hidden; }
.btn-start:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(var(--primary-rgb),0.5); }
.btn-start:active { transform: scale(0.98); }
.btn-pulse { animation: ctaPulse 2.5s ease-in-out 1s infinite; }
@keyframes ctaPulse { 0%,100% { box-shadow: 0 4px 15px rgba(var(--primary-rgb),0.3); } 50% { box-shadow: 0 6px 30px rgba(var(--primary-rgb),0.6); } }
.disclaimer { font-size: 12px; color: var(--text-dim); margin-top: 12px; text-align: center; }

/* Test Screen */
#screen-test { position: relative; justify-content: flex-start; padding-top: 32px; gap: 20px; }
.intensity-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; transition: all 0.6s ease; border-radius: 0; }
#screen-test > *:not(.intensity-bg) { position: relative; z-index: 1; }

/* Intensity levels - progressive visual overload */
.intensity-1 .intensity-bg { box-shadow: inset 0 0 80px rgba(var(--primary-rgb),0.05); }
.intensity-2 .intensity-bg { box-shadow: inset 0 0 120px rgba(var(--primary-rgb),0.12); animation: bgPulse 3s ease infinite; }
.intensity-3 .intensity-bg { box-shadow: inset 0 0 200px rgba(var(--primary-rgb),0.22); animation: bgPulse 1.5s ease infinite; }
.intensity-4 .intensity-bg { box-shadow: inset 0 0 300px rgba(var(--limit-rgb),0.3); animation: bgPulse 0.7s ease infinite; }
.intensity-3 .stimulus-card,
.intensity-4 .stimulus-card { animation: cardShake 0.4s ease; }
.intensity-4 .meter-ring { animation: meterGlow 0.5s ease infinite alternate; }
@keyframes bgPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }
@keyframes cardShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes meterGlow { from { box-shadow: 0 0 20px rgba(var(--limit-rgb),0.3); } to { box-shadow: 0 0 40px rgba(var(--limit-rgb),0.6); } }

/* Test Header */
.test-header { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 420px; }
.category-badge { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); padding: 8px 16px; border-radius: 24px; }
.cat-emoji { font-size: 22px; }
.cat-name { font-size: 15px; font-weight: 600; }
.cat-progress { font-size: 14px; color: var(--text-sec); font-weight: 600; background: var(--surface); padding: 8px 14px; border-radius: 20px; }

/* Intensity Meter */
.intensity-meter { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.meter-ring { width: 160px; height: 160px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: box-shadow 0.5s; }
.meter-fill { width: 160px; height: 160px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--primary) 0deg, var(--primary) 0deg, rgba(255,255,255,0.08) 0deg); transition: background 0.6s ease; }
.meter-inner { width: 120px; height: 120px; border-radius: 50%; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.meter-level { font-size: 42px; font-weight: 900; color: var(--text); line-height: 1; }
.meter-label { font-size: 12px; color: var(--text-sec); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

/* Level Dots */
.level-dots { display: flex; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.15); transition: all 0.3s; }
.dot.active { background: var(--primary); border-color: var(--primary-light); }
.dot.current { box-shadow: 0 0 12px rgba(var(--primary-rgb),0.6); transform: scale(1.2); }

/* Stimulus Card */
.stimulus-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; text-align: center; transition: all 0.3s; }
.stim-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.stim-desc { font-size: 15px; color: var(--text-sec); line-height: 1.6; }
@keyframes cardSlideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Choice Buttons */
.choice-buttons { display: flex; gap: 12px; width: 100%; max-width: 420px; }
.choice-btn { flex: 1; padding: 16px 12px; font-size: 15px; font-weight: 700; border: 2px solid; border-radius: 16px; cursor: pointer; transition: all 0.25s; min-height: 56px; position: relative; overflow: hidden; }
.choice-handle { background: rgba(var(--handle-rgb),0.1); border-color: rgba(var(--handle-rgb),0.3); color: var(--handle); }
.choice-handle:hover { background: rgba(var(--handle-rgb),0.2); border-color: var(--handle); transform: scale(1.03); box-shadow: 0 4px 20px rgba(var(--handle-rgb),0.3); }
.choice-limit { background: rgba(var(--limit-rgb),0.1); border-color: rgba(var(--limit-rgb),0.3); color: var(--limit); }
.choice-limit:hover { background: rgba(var(--limit-rgb),0.2); border-color: var(--limit); transform: scale(1.03); box-shadow: 0 4px 20px rgba(var(--limit-rgb),0.3); }
.choice-btn:active { transform: scale(0.97); }
.choice-btn.pressed { transform: scale(0.95); }

/* Category transition */
@keyframes categoryFade { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.category-enter { animation: categoryFade 0.5s ease; }

/* Result Screen */
#screen-result { justify-content: flex-start; padding-top: 28px; gap: 0; }
.result-header { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-light)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* Radar Chart */
.radar-container { width: 100%; max-width: 420px; text-align: center; margin-bottom: 20px; }
.radar-container h3 { font-size: 15px; color: var(--text-sec); margin-bottom: 12px; }
.radar-svg { width: 100%; max-width: 300px; height: auto; }
.radar-svg text { fill: var(--text-sec); }
.radar-data { transition: all 0.8s ease; }

/* Gauge */
.result-gauge-area { display: flex; justify-content: center; margin: 12px 0; }
.gauge-ring { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.gauge-fill { width: 150px; height: 150px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--primary) 0deg, var(--primary) 0deg, rgba(255,255,255,0.08) 0deg); transition: background 1.2s ease; }
.gauge-inner { width: 114px; height: 114px; border-radius: 50%; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-percent { font-size: 36px; font-weight: 900; }
.gauge-label { font-size: 11px; color: var(--text-sec); margin-top: 2px; }

.result-name { font-size: 26px; font-weight: 800; text-align: center; margin-top: 12px; }
.result-desc { font-size: 14px; color: var(--text-sec); line-height: 1.7; text-align: center; max-width: 420px; padding: 0 8px; margin: 8px 0 16px; }

/* Detail Sections */
.detail-section { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; margin-bottom: 12px; animation: fadeUp 0.5s ease both; }
.detail-section h3 { font-size: 15px; margin-bottom: 10px; }
.detail-section p { font-size: 14px; color: var(--text-sec); line-height: 1.6; }
.detail-section ul { list-style: none; }
.detail-section li { padding: 6px 0; font-size: 14px; color: var(--text-sec); border-bottom: 1px solid var(--border); }
.detail-section li:last-child { border-bottom: none; }
.detail-section li::before { content: '\2022'; color: var(--primary-light); margin-right: 8px; }
.compat-section { background: rgba(var(--primary-rgb),0.1); border-color: rgba(var(--primary-rgb),0.2); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* Share & Retake */
.share-buttons { display: flex; gap: 10px; width: 100%; max-width: 420px; margin: 12px 0; }
.share-btn { flex: 1; padding: 14px 12px; font-size: 14px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: all 0.25s; min-height: 48px; }
.share-btn:hover { background: rgba(var(--primary-rgb),0.15); border-color: var(--primary); transform: translateY(-2px); }
.btn-retake { width: 100%; max-width: 420px; padding: 16px; font-size: 16px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #5b21b6); border: none; border-radius: 14px; cursor: pointer; transition: all 0.3s; min-height: 52px; margin-bottom: 16px; }
.btn-retake:hover { transform: scale(1.03); box-shadow: 0 8px 30px rgba(var(--primary-rgb),0.4); }

/* Footer */
.game-footer { text-align: center; padding: 20px 0; margin-top: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.4); text-decoration: none; font-size: 13px; padding: 12px 0; transition: color 0.2s; }
.back-link:hover { color: rgba(255,255,255,0.7); }

/* Language Selector */
.language-selector { position: fixed; top: 20px; right: 20px; z-index: 1000; }
.lang-btn { background: rgba(var(--primary-rgb),0.3); backdrop-filter: blur(10px); border: 1px solid rgba(var(--primary-rgb),0.4); color: #fff; font-size: 20px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; transition: all 0.2s; }
.lang-btn:hover { background: rgba(var(--primary-rgb),0.5); transform: scale(1.05); }
.lang-menu { position: absolute; top: 52px; right: 0; background: rgba(15,10,30,0.95); backdrop-filter: blur(20px); border: 1px solid rgba(var(--primary-rgb),0.3); border-radius: 12px; padding: 8px; min-width: 150px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.lang-menu.hidden { display: none; }
.lang-option { width: 100%; padding: 10px 14px; background: transparent; border: none; text-align: left; cursor: pointer; border-radius: 8px; font-size: 14px; color: #e0d8f8; transition: background 0.2s; }
.lang-option:hover { background: rgba(var(--primary-rgb),0.2); }
.lang-option.active { background: rgba(var(--primary-rgb),0.3); font-weight: 600; color: #fff; }

/* Theme Toggle */
.theme-toggle { position: fixed; top: 20px; right: 76px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 1000; transition: all 0.3s; }
.theme-toggle:hover { transform: scale(1.1); }
[data-theme="light"] .theme-toggle { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); color: #333; }

/* Accessibility */
.skip-link { position: absolute; top: -40px; left: 0; background: var(--primary); color: white; padding: 8px; text-decoration: none; z-index: 10001; }
.skip-link:focus { top: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
button, a[href], [role="button"] { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
@media (prefers-contrast: more) { button { border: 2px solid currentColor; font-weight: bold; } }

/* Responsive */
@media (max-width: 380px) {
    .screen { padding: 16px; }
    .intro-title { font-size: 26px; }
    .btn-start { padding: 14px 28px; font-size: 16px; }
    .meter-ring, .meter-fill { width: 130px; height: 130px; }
    .meter-inner { width: 100px; height: 100px; }
    .meter-level { font-size: 34px; }
    .stimulus-card { padding: 18px; }
    .stim-title { font-size: 17px; }
    .choice-btn { font-size: 13px; padding: 14px 8px; min-height: 48px; }
}
