:root {
    --primary-color: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #22d3ee;
    --secondary-color: #1a1a2e;
    --accent-color: #f59e0b;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --bg-dark: #0f0f1e;
    --bg-card: #1a1a2e;
    --border-color: #2d2d3d;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
}

/* Light mode */
[data-theme="light"] {
    --secondary-color: #ffffff;
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --border-color: #e0e0e0;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
}

[data-theme="light"] .loader-spinner {
    border-color: rgba(8,145,178,0.15);
    border-top-color: var(--primary-color);
}
[data-theme="light"] .challenge-badge {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .result-description {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .scores-section,
[data-theme="light"] .radar-section {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .share-section {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .ad-container {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .lang-btn,
[data-theme="light"] .theme-toggle {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
    color: var(--text-primary);
}
[data-theme="light"] .lang-btn:hover,
[data-theme="light"] .theme-toggle:hover {
    background: rgba(8,145,178,0.08);
}
[data-theme="light"] .lang-menu {
    background: rgba(245,245,250,0.98);
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
[data-theme="light"] .lang-option:hover {
    background: rgba(8,145,178,0.06);
}
[data-theme="light"] .app-loader {
    background: #f5f5f5;
}
[data-theme="light"] ::-webkit-scrollbar-track {
    background: #f0f0f0;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
}
[data-theme="light"] .age-display {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
[data-theme="light"] .memory-cell {
    background: rgba(0,0,0,0.06);
    border-color: rgba(0,0,0,0.12);
}
[data-theme="light"] .memory-cell.highlighted {
    background: rgba(8,145,178,0.25);
    border-color: var(--primary-color);
}
[data-theme="light"] .memory-cell.selected {
    background: rgba(8,145,178,0.2);
    border-color: var(--primary-color);
}
[data-theme="light"] .reaction-area {
    background: rgba(0,0,0,0.04);
}
[data-theme="light"] .pattern-option,
[data-theme="light"] .word-option,
[data-theme="light"] .stroop-option,
[data-theme="light"] .emotion-option {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.1);
    color: var(--text-primary);
}
[data-theme="light"] .pattern-option:hover,
[data-theme="light"] .word-option:hover,
[data-theme="light"] .stroop-option:hover,
[data-theme="light"] .emotion-option:hover {
    background: rgba(8,145,178,0.06);
    border-color: rgba(8,145,178,0.25);
}
[data-theme="light"] .number-input {
    background: rgba(0,0,0,0.03);
    border-color: rgba(0,0,0,0.15);
    color: var(--text-primary);
}
[data-theme="light"] .challenge-instruction {
    background: rgba(245,245,250,0.97);
}
[data-theme="light"] .score-feedback {
    background: rgba(245,245,250,0.97);
}
[data-theme="light"] .score-bar-fill {
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

/* Dark mode body.light-mode fallback */
body.light-mode {
    --secondary-color: #ffffff;
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --border-color: #e0e0e0;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Touch optimization */
button, a, input, [role="button"], [role="link"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

input[type="text"], input[type="number"], textarea {
    -webkit-user-select: text;
    user-select: text;
}

html {
    font-size: 16px;
}

/* === App Loader === */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.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: loader-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-color);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

.loader-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 500;
}

@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

@keyframes loader-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
}

/* Language Selector */
.language-selector {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
}

.lang-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
}

.lang-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.5);
}

.lang-toggle:active {
    transform: scale(0.95);
}

.lang-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 140px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.lang-menu.hidden {
    display: none;
}

.lang-option {
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.lang-option:hover {
    background: var(--primary-color);
}

.lang-option.active {
    background: var(--primary-color);
    font-weight: bold;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 76px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.5);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Ad Container */
.ad-container {
    padding: 8px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-top { order: 1; }

.ad-bottom {
    order: 3;
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    margin-top: auto;
}

/* Screen Management */
.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 20px;
    order: 2;
}

.screen.active {
    display: flex;
}

/* ============== INTRO SCREEN ============== */
#intro-screen {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.intro-content {
    width: 100%;
    text-align: center;
}

.brain-emoji-animation {
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

.brain-emoji {
    font-size: 80px;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.intro-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.intro-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.intro-description {
    margin: 24px 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.intro-description p {
    margin: 8px 0;
}

.challenge-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 32px 0;
}

.challenge-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.challenge-badge:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Button Styles */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    text-transform: none;
    display: inline-block;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    max-width: 320px;
    margin: 16px 0;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(8, 145, 178, 0.5);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    width: 100%;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

.time-estimate {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============== CHALLENGE SCREEN ============== */
#challenge-screen {
    padding: 20px;
    position: relative;
    min-height: 500px;
}

.challenge-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 14.28%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 35px;
}

/* Challenge Instruction Overlay */
.challenge-instruction {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 30, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.challenge-instruction.hidden {
    display: none;
}

.instruction-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

.instruction-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary-light);
}

.instruction-text {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.instruction-countdown {
    font-size: 48px;
    font-weight: 900;
    color: var(--accent-color);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Challenge Area */
.challenge-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
}

/* Timer Bar */
.timer-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

.timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--error-color));
    transition: width 0.1s linear;
    width: 100%;
}

/* ---- Memory Grid ---- */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

.memory-cell {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    min-width: 56px;
    min-height: 56px;
}

.memory-cell.highlighted {
    background: rgba(8, 145, 178, 0.4);
    border-color: var(--primary-light);
    box-shadow: 0 0 12px rgba(8, 145, 178, 0.3);
}

.memory-cell.selected {
    background: rgba(8, 145, 178, 0.3);
    border-color: var(--primary-color);
}

.memory-cell.correct {
    background: rgba(76, 175, 80, 0.3);
    border-color: var(--success-color);
}

.memory-cell.wrong {
    background: rgba(244, 67, 54, 0.3);
    border-color: var(--error-color);
}

.memory-cell:active {
    transform: scale(0.95);
}

/* ---- Reaction Speed ---- */
.reaction-area {
    width: 100%;
    max-width: 320px;
    height: 280px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    padding: 20px;
    user-select: none;
}

.reaction-area.waiting {
    background: var(--bg-card);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.reaction-area.ready {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--success-color);
    color: var(--success-color);
    animation: reaction-pulse 0.5s ease infinite;
}

.reaction-area.too-early {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--error-color);
    color: var(--error-color);
}

.reaction-area.done {
    background: rgba(8, 145, 178, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

@keyframes reaction-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(76, 175, 80, 0); }
}

/* ---- Pattern Recognition ---- */
.pattern-display {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.pattern-item {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
}

.pattern-item.mystery {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--accent-color);
    font-size: 20px;
    color: var(--accent-color);
}

.pattern-options {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.pattern-option {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pattern-option:hover {
    border-color: var(--primary-color);
    background: rgba(8, 145, 178, 0.1);
}

.pattern-option:active {
    transform: scale(0.95);
}

.pattern-option.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--success-color);
}

.pattern-option.wrong {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--error-color);
}

/* ---- Word Association ---- */
.word-display {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--primary-light);
    text-align: center;
}

.word-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.word-option {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.word-option:hover {
    border-color: var(--primary-color);
    background: rgba(8, 145, 178, 0.1);
}

.word-option:active {
    transform: scale(0.97);
}

.word-option.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--success-color);
}

.word-option.wrong {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--error-color);
}

/* ---- Stroop Focus ---- */
.stroop-word {
    font-size: 48px;
    font-weight: 900;
    margin-bottom: 24px;
    text-align: center;
    letter-spacing: 2px;
}

.stroop-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.stroop-option {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.stroop-option:hover {
    border-color: var(--primary-color);
    background: rgba(8, 145, 178, 0.1);
}

.stroop-option:active {
    transform: scale(0.97);
}

.stroop-option.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--success-color);
}

.stroop-option.wrong {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--error-color);
}

/* ---- Emotional Reading ---- */
.emotion-scenario {
    font-size: 16px;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.6;
}

.emotion-emoji {
    font-size: 64px;
    margin-bottom: 16px;
    text-align: center;
}

.emotion-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.emotion-option {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.emotion-option:hover {
    border-color: var(--primary-color);
    background: rgba(8, 145, 178, 0.1);
}

.emotion-option:active {
    transform: scale(0.97);
}

.emotion-option.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: var(--success-color);
}

.emotion-option.wrong {
    background: rgba(244, 67, 54, 0.2);
    border-color: var(--error-color);
}

/* ---- Number Memory ---- */
.number-display {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 8px;
    color: var(--primary-light);
    margin-bottom: 24px;
    text-align: center;
    min-height: 60px;
}

.number-input-wrap {
    width: 100%;
    max-width: 280px;
    text-align: center;
}

.number-input {
    width: 100%;
    padding: 14px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 6px;
    text-align: center;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease;
}

.number-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.2);
}

.number-submit {
    margin-top: 16px;
    padding: 12px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.number-submit:hover {
    background: var(--primary-dark);
}

/* ---- Challenge Round Counter ---- */
.round-counter {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}

/* ---- Score Feedback Overlay ---- */
.score-feedback {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 30, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

.score-feedback.hidden {
    display: none;
}

.score-stars {
    font-size: 48px;
    margin-bottom: 12px;
    letter-spacing: 4px;
}

.score-points {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary-light);
    margin-bottom: 8px;
}

.score-label {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ============== ANALYZING SCREEN ============== */
#analyzing-screen {
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.analyzing-content {
    text-align: center;
}

.brain-scan {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 32px;
}

.brain-scan-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: rotate 3s linear infinite;
}

.brain-scan-wave {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: pulse-ring 2s ease-out infinite;
}

.brain-scan-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    animation: float 3s ease-in-out infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.2); opacity: 0; }
}

#analyzing-screen h2 {
    font-size: 20px;
    margin-bottom: 12px;
}

#analyzing-screen p {
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.loading-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 1; }
    30% { transform: translateY(-10px); }
}

/* ============== RESULT SCREEN ============== */
#result-screen {
    padding-bottom: 20px;
}

.result-content {
    width: 100%;
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.result-header {
    text-align: center;
    margin-bottom: 32px;
}

.age-display {
    font-size: 96px;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    text-shadow: none;
}

.age-label {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes bounce-in {
    0% { opacity: 0; transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

.result-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.result-tagline {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Radar Chart Section */
.radar-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.radar-section h3 {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 16px;
    font-weight: 600;
}

#radar-chart {
    max-width: 100%;
    height: auto;
}

.result-description {
    background: var(--bg-card);
    border-left: 4px solid var(--primary-color);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    line-height: 1.8;
}

/* Scores Section */
.scores-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.scores-section h3 {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 16px;
    font-weight: 600;
}

.scores-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

.score-info {
    flex: 1;
}

.score-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.score-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 3px;
    transition: width 0.6s ease;
}

.score-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-light);
    min-width: 36px;
    text-align: right;
}

/* Share Section */
.share-section {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.share-section h3 {
    font-size: 14px;
    color: var(--primary-color);
    margin-bottom: 16px;
    font-weight: 600;
}

.share-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.share-btn {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
}

.share-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.share-btn.twitter:hover {
    border-color: #1da1f2;
    color: #1da1f2;
}

.share-btn.facebook:hover {
    border-color: #1877f2;
    color: #1877f2;
}

.share-btn.copy:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

#retry-btn {
    margin-top: 8px;
}

/* Footer */
.game-footer {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.3s ease;
}

.back-link:hover {
    color: var(--primary-color);
}

/* ============== RESPONSIVE ============== */
@media (max-width: 480px) {
    html { font-size: 14px; }
    .intro-title { font-size: 24px; }
    .result-title { font-size: 24px; }
    .age-display { font-size: 72px; }
    .memory-grid { max-width: 240px; gap: 6px; }
    .memory-cell { min-width: 48px; min-height: 48px; }
    .reaction-area { height: 220px; }
    .number-display { font-size: 36px; letter-spacing: 6px; }
    .stroop-word { font-size: 36px; }
    .share-buttons { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
    .challenge-preview { gap: 6px; }
    .challenge-badge { padding: 6px 8px; font-size: 11px; }
    .intro-title { font-size: 20px; }
    .brain-emoji { font-size: 60px; }
    .age-display { font-size: 60px; }
    .memory-grid { max-width: 200px; }
}

/* ============== ACCESSIBILITY ============== */
button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    button:active,
    [role="button"]:active {
        transform: none;
    }
}

@media print {
    .language-selector,
    .ad-container,
    .share-section {
        display: none;
    }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid #0891b2;
    outline-offset: 2px;
}

button, a[href], input[type="button"], input[type="submit"], [role="button"] {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #0891b2;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus { top: 0; }

@media (prefers-contrast: more) {
    button,
    input[type="button"],
    input[type="submit"],
    [role="button"] {
        border: 2px solid currentColor;
        font-weight: bold;
    }
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
textarea,
select {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-dark, #f1f5f9); }
::-webkit-scrollbar-thumb { background: var(--primary-color, #0891b2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dark, #0e7490); }

* {
    scrollbar-color: var(--primary-color, #0891b2) var(--bg-dark, #f1f5f9);
    scrollbar-width: thin;
}

::selection { background: #0891b2; color: white; }
::-moz-selection { background: #0891b2; color: white; }

/* Glassmorphism Enhancement */
.header, .modal, .overlay, [role="dialog"], .menu {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.card, .panel, .sidebar, [class*="card"] {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
