/* ==========================================
   REACTION TIME - Styles
   ========================================== */

/* Variables */
:root {
    --primary: #00d9ff;
    --secondary: #a855f7;
    --accent: #f472b6;
    --bg-dark: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    
    /* Game colors */
    --color-red: #dc2626;
    --color-green: #16a34a;
    --color-yellow: #eab308;
    
    --success: #22c55e;
    --error: #ef4444;
}

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

/* Body */
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Background Grid */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Floating Orbs */
.floating-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: var(--secondary);
    bottom: 20%;
    left: -80px;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: var(--accent);
    bottom: -50px;
    right: 20%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Game Wrapper */
.game-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

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

.game-logo {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sound-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.sound-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sound-btn.muted {
    opacity: 0.5;
}

/* Game Container */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ==========================================
   MENU SCREEN
   ========================================== */

.menu-screen {
    justify-content: center;
    padding: 1rem 0;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.title-glow {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    text-align: center;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 12px;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.3);
}

.btn-glow {
    animation: buttonGlow 2s ease-in-out infinite;
}

@keyframes buttonGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 217, 255, 0.3); }
    50% { box-shadow: 0 0 40px rgba(168, 85, 247, 0.4); }
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Instructions */
.instructions {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
}

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

.instruction-grid {
    display: grid;
    gap: 0.8rem;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.instruction .icon {
    font-size: 1.2rem;
    width: 2rem;
    text-align: center;
}

.keyboard-hint {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--secondary);
    opacity: 0.8;
}

/* Leaderboard */
.leaderboard-preview,
.leaderboard-full {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1rem;
    width: 100%;
}

.leaderboard-preview h3,
.leaderboard-full h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 0.8rem;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-full .leaderboard-list {
    max-height: 300px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.85rem;
}

.leaderboard-entry.top-3 {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.1), rgba(168, 85, 247, 0.1));
}

.rank {
    width: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.name {
    flex: 1;
    color: var(--text);
}

.points {
    font-weight: 600;
    color: var(--success);
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
}

/* ==========================================
   GAME SCREEN
   ========================================== */

.game-screen {
    gap: 1rem;
}

.game-hud {
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem;
}

.hud-item {
    text-align: center;
}

.hud-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.hud-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

/* Reaction Zone */
.reaction-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.15s;
    min-height: 300px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.reaction-zone.waiting {
    background: var(--color-red);
    border-color: var(--color-red);
}

.reaction-zone.ready {
    background: var(--color-green);
    border-color: var(--color-green);
    animation: pulse-green 0.5s ease-in-out;
}

@keyframes pulse-green {
    0% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.reaction-zone.too-early {
    background: var(--color-yellow);
    border-color: var(--color-yellow);
    animation: shake 0.3s ease-in-out;
}

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

.reaction-zone.result {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(168, 85, 247, 0.2));
    border-color: var(--primary);
}

.reaction-content {
    text-align: center;
    pointer-events: none;
}

.reaction-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    transition: transform 0.3s;
}

.reaction-zone.ready .reaction-icon {
    animation: bounce 0.5s ease-in-out;
}

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

.reaction-text {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
}

.reaction-text.time {
    font-size: 4rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.reaction-subtext {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Trials Display */
.trials-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
}

.trial-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.3s;
}

.trial-dot.current {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
}

.trial-dot.completed {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: white;
}

.trial-dot.failed {
    background: var(--color-yellow);
    border-color: transparent;
    color: white;
}

/* ==========================================
   GAME OVER SCREEN
   ========================================== */

.gameover-screen {
    justify-content: flex-start;
    padding: 1rem 0;
    overflow-y: auto;
}

.gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.gameover-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-final {
    text-align: center;
}

.score-big {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.score-label {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: 0.5rem;
}

.rating {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.5rem 1.5rem;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

/* Trials Results */
.trials-results {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 350px;
}

.trial-result {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    text-align: center;
    min-width: 60px;
}

.trial-result-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.trial-result-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

.trial-result.failed .trial-result-value {
    color: var(--color-yellow);
}

/* Save Form */
.save-score-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 300px;
}

.pseudo-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    color: var(--text);
    font-family: inherit;
}

.pseudo-input:focus {
    outline: none;
    border-color: var(--primary);
}

.pseudo-input::placeholder {
    color: var(--text-muted);
}

.save-status {
    font-size: 0.9rem;
    min-height: 1.5rem;
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--error);
}

/* Actions */
.gameover-actions {
    display: flex;
    gap: 1rem;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 480px) {
    .title-glow {
        font-size: 2rem;
    }
    
    .reaction-text {
        font-size: 1.5rem;
    }
    
    .reaction-text.time {
        font-size: 3rem;
    }
    
    .reaction-icon {
        font-size: 3rem;
    }
    
    .reaction-zone {
        min-height: 250px;
    }
    
    .score-big {
        font-size: 3rem;
    }
    
    .gameover-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .gameover-actions button {
        width: 100%;
    }
    
    .trial-dot {
        width: 35px;
        height: 35px;
    }
}

/* Touch feedback */
@media (hover: none) {
    .btn-primary:hover,
    .btn-secondary:hover {
        transform: none;
    }
    
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
    }
}
