:root {
    --bg-color: #050608;
    --card-bg: rgba(10, 15, 25, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-color: #e2e8f0;
    --text-muted: #64748b;
    --accent-yellow: #f59e0b;
    --accent-yellow-glow: rgba(245, 158, 11, 0.4);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.4);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.4);
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #0c101b 0%, #040508 100%);
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
}

.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.8) 100%);
    pointer-events: none;
    z-index: 2;
}

/* Glassmorphism utility card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: rgba(4, 5, 8, 0.5);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Typography styles */
.font-mono {
    font-family: var(--font-mono);
}

.game-title {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #fff 30%, var(--accent-yellow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--accent-yellow-glow);
    margin-bottom: 0.5rem;
}

.game-tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Instructions */
.game-instructions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    text-align: left;
}

.instruction-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 1rem;
    align-items: center;
}

.instruction-icon {
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
}

.instruction-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 0.15rem;
}

.instruction-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Buttons */
.glow-button {
    background: #fff;
    color: #000;
    border: none;
    outline: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
    width: 100%;
    position: relative;
    overflow: hidden;
}

.glow-button:hover {
    background: var(--accent-yellow);
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--accent-yellow-glow);
}

.glow-button:active {
    transform: translateY(0);
}

/* Logos & Glowing Decorators */
.flashlight-logo-glow {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, var(--accent-yellow) 0%, transparent 70%);
    opacity: 0.6;
    filter: blur(5px);
    position: absolute;
    top: -20px;
    left: calc(50% - 30px);
    pointer-events: none;
    animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

.best-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--accent-yellow);
    margin-bottom: 1.5rem;
}

/* HUD System */
#hud {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    right: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.hud-item {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.hud-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.hud-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

/* Battery HUD specific styles */
.battery-container {
    width: 200px;
}

.battery-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.battery-bar-outer {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

#battery-bar-inner {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-green), #34d399);
    border-radius: 3px;
    transition: width 0.1s linear, background-color 0.3s ease;
    box-shadow: 0 0 8px var(--accent-green-glow);
}

/* Game Over CSS */
.game-over-card {
    border-color: rgba(239, 68, 68, 0.2);
}

.skull-glow {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 15px var(--accent-red-glow));
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    20%, 60% { transform: rotate(-5deg); }
    40%, 80% { transform: rotate(5deg); }
}

.game-over-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #fff 30%, var(--accent-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--accent-red-glow);
    margin-bottom: 0.25rem;
}

.game-over-reason {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 600;
    color: #fff;
}

.new-high-score {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--accent-green);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    animation: flashGreen 1s infinite alternate;
}

@keyframes flashGreen {
    from { opacity: 0.7; box-shadow: 0 0 5px transparent; }
    to { opacity: 1; box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
}

.restart-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.restart-tip kbd {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    color: #f8fafc;
    font-family: inherit;
}

/* Touch Helper (Mobile Only) */
#touch-helper {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    z-index: 5;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    animation: fadePulse 2s infinite ease-in-out;
}

.touch-ring {
    width: 40px;
    height: 40px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: spin 8s linear infinite;
}

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

@keyframes fadePulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Responsiveness Settings */
@media (max-width: 640px) {
    .desktop-only {
        display: none;
    }
    
    #hud {
        top: 1rem;
        left: 1rem;
        right: 1rem;
        gap: 0.5rem;
    }
    
    .hud-item {
        padding: 0.5rem 0.75rem;
        border-radius: 10px;
    }
    
    .hud-value {
        font-size: 1rem;
    }
    
    .battery-container {
        width: 130px;
    }
    
    .glass-card {
        padding: 1.75rem 1.25rem;
        border-radius: 20px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .game-instructions {
        margin-bottom: 1.5rem;
    }
    
    .instruction-card {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
}

@media (min-width: 641px) {
    .mobile-only {
        display: none;
    }
}
