/* ==========================================
   COLOR MATCH - 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);
    
    /* Color palette for the game */
    --color-red: #ef4444;
    --color-blue: #3b82f6;
    --color-green: #22c55e;
    --color-yellow: #eab308;
    --color-purple: #a855f7;
    --color-orange: #f97316;
    
    --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(--secondary);
}

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

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

.game-screen {
    gap: 1rem;
}

.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.hud-left, .hud-right {
    flex: 1;
}

.hud-center {
    flex: 2;
}

.score-display {
    display: flex;
    gap: 0.5rem;
}

.score-box {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.score-box span:last-child {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

/* Timer */
.timer-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.timer-bar {
    flex: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 6px;
    transition: width 0.1s linear;
    width: 100%;
}

.timer-fill.warning {
    background: linear-gradient(90deg, var(--color-orange), var(--color-red));
}

.timer-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    min-width: 35px;
    text-align: center;
}

/* Word Timer */
.word-timer-container {
    display: flex;
    justify-content: flex-end;
}

.word-timer-bar {
    width: 60px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.word-timer-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.05s linear;
    width: 100%;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.word-container {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem 3rem;
    min-width: 280px;
    text-align: center;
    transition: all 0.3s;
}

.word-container.correct {
    border-color: var(--success);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.3);
}

.word-container.wrong {
    border-color: var(--error);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
    animation: shake 0.3s ease-in-out;
}

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

.color-word {
    font-size: 3.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: color 0.1s;
}

/* Feedback */
.feedback-container {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback {
    font-size: 1.2rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
}

.feedback.show {
    opacity: 1;
}

.feedback.correct {
    color: var(--success);
}

.feedback.wrong {
    color: var(--error);
}

/* Color Buttons */
.color-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    width: 100%;
    max-width: 350px;
}

.color-btn {
    aspect-ratio: 1.5;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
    min-height: 60px;
}

.color-btn::before {
    content: attr(data-key);
    position: absolute;
    top: 4px;
    left: 8px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.color-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.color-btn:active {
    transform: scale(0.95);
}

.color-btn.red { background: var(--color-red); }
.color-btn.blue { background: var(--color-blue); }
.color-btn.green { background: var(--color-green); }
.color-btn.yellow { background: var(--color-yellow); }
.color-btn.purple { background: var(--color-purple); }
.color-btn.orange { background: var(--color-orange); }

/* ==========================================
   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;
}

.stats-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.stat {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    text-align: center;
    min-width: 100px;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--secondary);
}

/* 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;
    }
    
    .color-word {
        font-size: 2.5rem;
    }
    
    .word-container {
        padding: 1.5rem 2rem;
        min-width: 220px;
    }
    
    .color-buttons {
        gap: 0.6rem;
    }
    
    .color-btn {
        min-height: 50px;
    }
    
    .score-big {
        font-size: 3rem;
    }
    
    .gameover-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .gameover-actions button {
        width: 100%;
    }
}

/* Touch feedback */
@media (hover: none) {
    .color-btn:hover {
        transform: none;
    }
    
    .color-btn:active {
        transform: scale(0.95);
    }
}
