/* === Color Blindness Test - Primary: #00cec9 === */

:root {
    --primary: #00cec9;
    --primary-light: #55efc4;
    --primary-dark: #00a8a3;
    --bg: #0a0a1e;
    --surface: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.08);
    --text: #f0f0f5;
    --text-sec: #a0a0b8;
    --text-dim: #5a5a70;
    --danger: #ff6b6b;
    --success: #55efc4;
    --warning: #feca57;
}

/* Light mode overrides */
[data-theme="light"] {
    --bg: #f0fffe;
    --surface: rgba(0, 206, 201, 0.06);
    --border: rgba(0, 206, 201, 0.12);
    --text: #0a1e1e;
    --text-sec: #3d6b6a;
    --text-dim: #7aa0a0;
}
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] .app-loader { background: var(--bg); }
[data-theme="light"] .start-container,
[data-theme="light"] .result-card {
    background: rgba(0, 206, 201, 0.04);
    border-color: rgba(0, 206, 201, 0.12);
    box-shadow: 0 4px 24px rgba(0, 206, 201, 0.08);
}
[data-theme="light"] .game-header {
    background: rgba(0, 206, 201, 0.06);
    border-color: rgba(0, 206, 201, 0.12);
}
[data-theme="light"] .lang-btn {
    background: rgba(0, 206, 201, 0.08);
    color: var(--text);
    border-color: rgba(0, 206, 201, 0.18);
}
[data-theme="light"] .lang-menu {
    background: rgba(240, 255, 254, 0.95);
    border-color: rgba(0, 206, 201, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .lang-option { color: #3d6b6a; }
[data-theme="light"] .lang-option:hover { background: rgba(0, 206, 201, 0.1); color: var(--text); }
[data-theme="light"] .lang-option.active { background: rgba(0, 206, 201, 0.15); color: var(--text); }
[data-theme="light"] .loader-spinner {
    border-color: rgba(0, 206, 201, 0.12);
    border-top-color: var(--primary);
}
[data-theme="light"] .back-link { color: var(--primary-dark); }
[data-theme="light"] .start-meta span { background: rgba(0, 206, 201, 0.08); color: var(--text-sec); }
[data-theme="light"] .preview-grid .preview-tile { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
[data-theme="light"] .result-stats .stat-item { background: rgba(0, 206, 201, 0.06); border-color: rgba(0, 206, 201, 0.12); }
[data-theme="light"] .result-grade { background: rgba(0, 206, 201, 0.06); border-color: rgba(0, 206, 201, 0.12); }
[data-theme="light"] .share-section { background: rgba(0, 206, 201, 0.04); border-color: rgba(0, 206, 201, 0.1); }

/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* === Skip Link === */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    z-index: 99999;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.2s;
}
.skip-link:focus { top: 16px; }

/* === Theme Toggle === */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.theme-toggle:hover { transform: scale(1.1); border-color: var(--primary); }

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

/* === Language Selector === */
.language-selector { position: fixed; top: 16px; left: 16px; z-index: 1000; }
.lang-btn {
    width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
}
.lang-btn:hover { transform: scale(1.1); border-color: var(--primary); }
.lang-menu {
    position: absolute; top: 52px; left: 0;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    min-width: 160px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: all 0.3s;
}
.lang-menu.hidden { opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none; }
.lang-option {
    display: block; width: 100%;
    padding: 8px 12px; border: none;
    background: transparent; color: var(--text-sec);
    text-align: left; font-size: 13px;
    border-radius: 8px; cursor: pointer;
    transition: all 0.2s;
}
.lang-option:hover { background: rgba(0, 206, 201, 0.15); color: var(--text); }
.lang-option.active { background: rgba(0, 206, 201, 0.2); color: var(--primary); font-weight: 600; }

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

/* === Start Screen === */
.start-container {
    max-width: 480px; width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 28px;
    text-align: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.start-icon { font-size: 64px; margin-bottom: 16px; animation: bounce 2s infinite; }
.start-title {
    font-size: 28px; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}
.start-subtitle { font-size: 16px; color: var(--text-sec); margin-bottom: 8px; }
.start-desc { font-size: 14px; color: var(--text-dim); margin-bottom: 20px; line-height: 1.6; }
.start-meta {
    display: flex; justify-content: center; gap: 12px;
    flex-wrap: wrap; margin-bottom: 24px;
}
.start-meta span {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-sec);
}
.start-preview {
    margin-bottom: 24px;
    padding: 20px;
    background: rgba(0, 206, 201, 0.05);
    border: 1px solid rgba(0, 206, 201, 0.1);
    border-radius: 16px;
}
.preview-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 8px; max-width: 120px; margin: 0 auto 12px;
}
.preview-tile {
    width: 52px; height: 52px;
    border-radius: 10px;
    transition: transform 0.3s;
}
.preview-tile.different { animation: pulse-tile 1.5s infinite; }
.preview-hint { font-size: 13px; color: var(--text-dim); }
@keyframes pulse-tile { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.btn-start {
    width: 100%; padding: 16px 32px;
    font-size: 18px; font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px;
    position: relative;
    overflow: hidden;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 206, 201, 0.4); }
.btn-start:active { transform: scale(0.98); }
.btn-pulse { animation: pulse-btn 2s infinite; }
@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 206, 201, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(0, 206, 201, 0); }
}
.user-count { font-size: 12px; color: var(--text-dim); margin-top: 16px; }

/* === Game Screen === */
#game-screen.active { justify-content: flex-start; padding-top: 16px; }
.game-header {
    display: flex; justify-content: space-around;
    width: 100%; max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 8px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    margin-bottom: 12px;
}
.game-stat { text-align: center; }
.stat-label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { display: block; font-size: 18px; font-weight: 700; color: var(--text); }
#lives-display { color: var(--danger); }

.timer-bar {
    width: 100%; max-width: 480px; height: 6px;
    background: var(--surface);
    border-radius: 3px;
    margin-bottom: 16px;
    overflow: hidden;
}
.timer-fill {
    height: 100%; width: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.1s linear;
}
.timer-fill.warning { background: linear-gradient(90deg, var(--warning), #ff9f43); }
.timer-fill.danger { background: linear-gradient(90deg, var(--danger), #ee5a24); }

.game-instruction {
    font-size: 16px; font-weight: 600;
    color: var(--primary);
    margin-bottom: 20px;
    text-align: center;
    animation: fadeIn 0.3s;
}

.grid-container {
    display: grid;
    gap: 6px;
    max-width: 480px;
    width: 100%;
    aspect-ratio: 1;
    margin: 0 auto;
}

.color-tile {
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    min-height: 0;
    border: 2px solid transparent;
}
.color-tile:hover { transform: scale(0.96); }
.color-tile:active { transform: scale(0.9); }
.color-tile.correct {
    animation: correct-pop 0.5s;
    border-color: var(--success);
    box-shadow: 0 0 20px rgba(85, 239, 196, 0.5);
}
.color-tile.wrong {
    animation: wrong-shake 0.5s;
    border-color: var(--danger);
    opacity: 0.5;
}
@keyframes correct-pop {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@keyframes wrong-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.level-indicator {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px; font-weight: 900;
    color: var(--primary);
    pointer-events: none;
    opacity: 0;
    z-index: 100;
    text-shadow: 0 0 40px rgba(0, 206, 201, 0.6);
}
.level-indicator.show {
    animation: level-flash 1s forwards;
}
@keyframes level-flash {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* === Result Screen === */
.result-card {
    max-width: 480px; width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 28px;
    text-align: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.result-score-ring {
    position: relative;
    width: 140px; height: 140px;
    margin: 0 auto 24px;
}
.score-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-bg-circle {
    fill: none;
    stroke: var(--surface);
    stroke-width: 8;
}
.score-fill-circle {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1.5s ease-out;
}
.score-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.score-number { font-size: 36px; font-weight: 900; color: var(--primary); }
.score-label { font-size: 14px; color: var(--text-dim); }

.result-title {
    font-size: 24px; font-weight: 800;
    color: var(--text); margin-bottom: 8px;
}
.result-desc {
    font-size: 14px; color: var(--text-sec);
    line-height: 1.6; margin-bottom: 24px;
}

.result-stats {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; margin-bottom: 24px;
}
.stat-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 8px;
}
.stat-item-value {
    display: block; font-size: 22px; font-weight: 800;
    color: var(--primary);
}
.stat-item-label {
    display: block; font-size: 11px;
    color: var(--text-dim); margin-top: 4px;
}

.result-grade {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--text-sec);
    line-height: 1.6;
}

.share-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}
.share-section h3 {
    font-size: 16px; font-weight: 700;
    color: var(--text); margin-bottom: 12px;
}
.share-buttons { display: flex; gap: 12px; }
.btn-share {
    flex: 1; padding: 12px 16px;
    border: none; border-radius: 12px;
    font-size: 14px; font-weight: 600;
    cursor: pointer; min-height: 44px;
    transition: all 0.3s;
}
.btn-twitter {
    background: #1da1f2; color: #fff;
}
.btn-twitter:hover { background: #0d8bd9; }
.btn-copy {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-copy:hover { border-color: var(--primary); }

/* === Footer === */
.game-footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-dim); text-decoration: none;
    font-size: 14px; transition: color 0.3s;
}
.back-link:hover { color: var(--primary); }

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === Mobile Responsive === */
@media (max-width: 480px) {
    .start-container, .result-card { padding: 28px 20px; border-radius: 20px; }
    .start-title { font-size: 24px; }
    .game-header { padding: 10px 6px; }
    .grid-container { gap: 4px; }
    .color-tile { border-radius: 8px; }
}
@media (max-width: 360px) {
    .start-meta { gap: 8px; }
    .start-meta span { font-size: 11px; padding: 4px 10px; }
    .result-stats { gap: 8px; }
}
