/* ============================================
   REACTION TIME GAME - PostHog Inspired UI
   ============================================ */

:root {
    --bg-primary: #0d0f14;
    --bg-secondary: #151822;
    --bg-tertiary: #1d2130;
    --bg-card: rgba(29, 33, 48, 0.8);
    
    --accent-primary: #f7a600;
    --accent-secondary: #f54e00;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-purple: #a855f7;
    
    --waiting-color: #dc2626;
    --ready-color: #22c55e;
    
    --text-primary: #f9fafb;
    --text-secondary: #a0a9b8;
    --text-muted: #6b7280;
    
    --gradient-primary: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   NAVIGATION
   ============================================ */
.game-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(13, 15, 20, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.back-link svg {
    width: 20px;
    height: 20px;
}

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

.other-game {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.other-game:hover {
    color: var(--accent-secondary);
}

/* ============================================
   GAME CONTAINER
   ============================================ */
.game-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5rem 1.5rem 2rem;
    position: relative;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
    display: none;
    width: 100%;
    max-width: 500px;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.screen-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* ============================================
   INTRO SCREEN
   ============================================ */
.game-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

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

.intro-screen h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.how-to-play {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    text-align: left;
}

.how-to-play h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.how-to-play ol {
    list-style: none;
    counter-reset: steps;
}

.how-to-play li {
    counter-increment: steps;
    padding: 0.5rem 0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.how-to-play li::before {
    content: counter(steps);
    width: 28px;
    height: 28px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.how-to-play .green {
    color: var(--accent-green);
    font-weight: 600;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--gradient-primary);
    color: var(--bg-primary);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
    width: 100%;
    max-width: 280px;
}

.btn-primary svg {
    width: 20px;
    height: 20px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px rgba(247, 166, 0, 0.4);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-muted);
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-base);
    font-family: inherit;
}

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

.best-time {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.best-time .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.best-time .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
}

/* ============================================
   WAITING SCREEN
   ============================================ */
.waiting-screen .screen-content {
    background: var(--waiting-color);
    border-color: var(--waiting-color);
    cursor: pointer;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.waiting-screen h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.waiting-screen p {
    opacity: 0.8;
}

.pulse-ring {
    position: absolute;
    width: 150px;
    height: 150px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: pulseRing 1.5s ease-out infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.waiting-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================
   READY SCREEN (GREEN)
   ============================================ */
.ready-screen .screen-content {
    background: var(--ready-color);
    border-color: var(--ready-color);
    cursor: pointer;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: flashIn 0.1s ease;
}

@keyframes flashIn {
    0% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.ready-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 0.5s ease infinite;
}

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

.ready-screen h2 {
    font-size: 2.5rem;
    font-weight: 800;
    text-transform: uppercase;
}

/* ============================================
   EARLY SCREEN
   ============================================ */
.early-screen .screen-content {
    background: #7c2d12;
    border-color: #7c2d12;
}

.early-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.early-screen h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.early-screen p {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
}

/* ============================================
   RESULT SCREEN
   ============================================ */
.result-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.result-screen h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.result-time {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.time-value {
    font-size: 5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.time-unit {
    font-size: 2rem;
    color: var(--text-muted);
    font-weight: 600;
}

.result-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.result-stats .stat {
    text-align: center;
}

.result-stats .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.result-stats .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Speed Meter */
.speed-meter {
    margin-bottom: 2rem;
}

.meter-bar {
    position: relative;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.meter-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.meter-markers {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
}

.meter-markers span {
    display: none;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.result-actions .btn-primary {
    flex: 1;
    min-width: 140px;
    max-width: 180px;
}

.result-actions .btn-secondary {
    flex: 1;
    min-width: 140px;
    max-width: 180px;
}

/* ============================================
   LEADERBOARD
   ============================================ */
.leaderboard {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.history-list li:last-child {
    border-bottom: none;
}

.history-list .attempt-num {
    color: var(--text-muted);
}

.history-list .attempt-time {
    font-weight: 600;
    color: var(--accent-primary);
}

.history-list .attempt-time.best {
    color: var(--accent-green);
}

.history-list .empty-state {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem 0;
}

.btn-clear {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-clear:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .leaderboard {
        display: none;
    }
}

@media (max-width: 768px) {
    .game-nav {
        padding: 1rem;
    }
    
    .screen-content {
        padding: 2rem 1.5rem;
    }
    
    .game-icon {
        font-size: 4rem;
    }
    
    .intro-screen h1 {
        font-size: 2rem;
    }
    
    .time-value {
        font-size: 4rem;
    }
    
    .result-stats {
        gap: 1rem;
        padding: 1rem;
    }
    
    .result-stats .stat-value {
        font-size: 1.25rem;
    }
    
    .waiting-screen .screen-content,
    .ready-screen .screen-content {
        min-height: 350px;
    }
}

@media (max-width: 480px) {
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn-primary,
    .result-actions .btn-secondary {
        max-width: 100%;
    }
    
    .how-to-play {
        padding: 1rem;
    }
}

