/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-color: #080c14;
    --panel-bg: rgba(13, 20, 35, 0.7);
    --panel-border: rgba(0, 243, 255, 0.15);
    --text-primary: #f1f5f9;
    --text-muted: #64748b;
    
    /* Neon Physics Theme Colors */
    --electron-color: #00f3ff;
    --electron-glow: rgba(0, 243, 255, 0.6);
    --proton-color: #ff3e3e;
    --proton-glow: rgba(255, 62, 62, 0.6);
    --shield-color: #10b981;
    --shield-glow: rgba(16, 185, 129, 0.6);
    
    --font-main: 'Outfit', sans-serif;
    --font-code: 'Space Grotesk', sans-serif;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 243, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 62, 62, 0.04) 0%, transparent 40%);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

/* App Container Layout */
#app {
    width: 100%;
    max-width: 650px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 16px;
    justify-content: space-between;
}

/* HUD Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 16px;
}

h1 {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 2px;
    margin: 0;
    font-family: var(--font-code);
}

.logo {
    display: flex;
    align-items: center;
}

.cyan-glow {
    color: var(--electron-color);
    text-shadow: 0 0 10px var(--electron-glow);
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-board {
    display: flex;
    gap: 8px;
}

.score-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 6px 14px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.score-box .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.score-box .value {
    font-family: var(--font-code);
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Icon Buttons (Mute) */
.icon-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.icon-btn:hover {
    border-color: var(--electron-color);
    background: rgba(0, 243, 255, 0.08);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(1px);
}

.hidden {
    display: none !important;
}

/* Main Area - Aspect Ratio Locking Canvas Container */
main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    max-height: calc(100vh - 140px);
}

.canvas-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1;
    position: relative;
    background: #0b0f19;
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,0.03);
    box-shadow: 
        0 24px 48px rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 28px;
}

/* Glassmorphism Overlays */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 1;
    visibility: visible;
}

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

.overlay-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

/* Dynamic Animation logo for Start Overlay */
.atom-animation-icon {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
}

.nucleus-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    background: var(--proton-color);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--proton-glow);
    animation: pulse 1.5s infinite alternate ease-in-out;
}

.orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1.5px dashed rgba(0, 243, 255, 0.3);
    border-radius: 50%;
}

.orbit-ring.o1 {
    width: 50px;
    height: 50px;
    animation: rotateCW 6s linear infinite;
}

.orbit-ring.o2 {
    width: 80px;
    height: 80px;
    animation: rotateCCW 8s linear infinite;
}

.electron-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--electron-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--electron-glow);
    top: 50%;
    left: 50%;
    offset-path: ray(45deg closest-side);
    animation: orbitMove 4s linear infinite;
}

.game-title-large {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 2px;
    font-family: var(--font-code);
    margin-bottom: 12px;
}

.game-title-large.collapse-text {
    color: var(--proton-color);
    text-shadow: 0 0 15px var(--proton-glow);
    animation: shake 0.5s ease-in-out;
}

.description {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 28px;
    max-width: 320px;
}

/* Control Guides on Start Screen */
.controls-guide {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 28px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.guide-key {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 2px 6px;
    font-family: var(--font-code);
    font-size: 11px;
    font-weight: 700;
    color: var(--electron-color);
    box-shadow: 0 2px 0 #0f172a;
}

.guide-text {
    margin-left: auto;
    color: var(--text-muted);
}

/* Premium Buttons */
.primary-btn {
    background: linear-gradient(135deg, #00f3ff 0%, #00a8ff 100%);
    color: #04080f;
    font-family: var(--font-code);
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 1px;
    padding: 14px 36px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 243, 255, 0.25);
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 243, 255, 0.4);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(0, 243, 255, 0.2);
}

.primary-btn.pulse-glow {
    background: linear-gradient(135deg, #ff4d4d 0%, #c21a1a 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(255, 62, 62, 0.25);
}

.primary-btn.pulse-glow:hover {
    box-shadow: 0 12px 28px rgba(255, 62, 62, 0.4);
}

.tip-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

.kbd {
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    padding: 1px 4px;
    font-family: var(--font-code);
}

/* Stats Cards for Game Over */
.stats-grid {
    display: flex;
    gap: 16px;
    width: 100%;
    margin-bottom: 28px;
}

.stat-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    font-family: var(--font-code);
    color: var(--text-primary);
}

/* HUD Indicator (Shield Overlay) */
.hud-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--shield-color);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: pulseGlowGreen 1s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
}

/* Footer Hint Text */
footer {
    display: flex;
    justify-content: center;
    padding: 16px 0 8px;
}

.footer-hint {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    max-width: 80%;
    line-height: 1.5;
}

/* Responsive Utilities */
.mobile-only {
    display: none;
}

/* Media Queries for Responsiveness */
@media (max-width: 480px) {
    #app {
        padding: 12px;
    }
    
    header {
        padding: 4px 0 12px;
    }
    
    h1 {
        font-size: 18px;
    }
    
    .score-box {
        padding: 4px 10px;
        min-width: 55px;
    }
    
    .score-box .value {
        font-size: 15px;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    
    .canvas-container {
        border-radius: 20px;
    }
    
    canvas {
        border-radius: 20px;
    }
    
    .overlay-content {
        padding: 16px;
    }
    
    .game-title-large {
        font-size: 26px;
    }
    
    .description {
        font-size: 12px;
        margin-bottom: 20px;
    }
    
    .controls-guide {
        padding: 10px;
        margin-bottom: 20px;
    }
    
    .guide-item {
        font-size: 11px;
    }
    
    .primary-btn {
        padding: 12px 28px;
        font-size: 13px;
    }
    
    .stats-grid {
        margin-bottom: 20px;
        gap: 10px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .hud-indicator {
        top: 12px;
        left: 12px;
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .desktop-only {
        display: none;
    }
    
    .mobile-only {
        display: block;
    }
}

/* Animations */
@keyframes pulse {
    from {
        transform: translate(-50%, -50%) scale(0.9);
        box-shadow: 0 0 10px var(--proton-glow);
    }
    to {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 22px rgba(255, 62, 62, 0.8);
    }
}

@keyframes rotateCW {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes rotateCCW {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes orbitMove {
    from { transform: translate(-50%, -50%) rotate(0deg) translate(40px) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg) translate(40px) rotate(-360deg); }
}

@keyframes pulseGlowGreen {
    from {
        box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 4px rgba(16, 185, 129, 0.2);
        border-color: rgba(16, 185, 129, 0.3);
    }
    to {
        box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 12px rgba(16, 185, 129, 0.5);
        border-color: rgba(16, 185, 129, 0.6);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.text-anim {
    animation: textPulse 3s linear infinite alternate;
}

@keyframes textPulse {
    0% {
        text-shadow: 0 0 5px var(--electron-glow);
    }
    100% {
        text-shadow: 0 0 20px var(--electron-color), 0 0 30px var(--electron-glow);
    }
}
