/* Reset and Base Styles */
:root {
    --bg-dark: #020208;
    --neon-blue: #00f0ff;
    --neon-red: #ff3366;
    --neon-green: #39ff14;
    --neon-yellow: #ffd700;
    --neon-purple: #b06cff;
    --card-bg: rgba(5, 5, 18, 0.7);
    --card-border: rgba(0, 240, 255, 0.12);
}

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

body {
    background-color: var(--bg-dark);
    color: #ffffff;
    font-family: 'Orbitron', sans-serif;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Radar scanning grid background overlay */
.matrix-grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: radial-gradient(circle at center, #0a0a20 0%, #020208 100%);
}

/* Game Wrapper Layout */
.game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 800px;
    max-height: 800px;
    aspect-ratio: 1/1;
    background-color: rgba(2, 2, 8, 0.95);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 35px rgba(0, 240, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
}

@media (max-width: 800px) {
    .game-wrapper {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        aspect-ratio: auto;
        border: none;
        border-radius: 0;
    }
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Glassmorphism Cyberpunk Cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 15px 40px rgba(0, 240, 255, 0.15);
    padding: 24px;
    transition: all 0.3s ease;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 2, 8, 0.85);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    transition: opacity 0.3s ease;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* Menu Content & Typography */
.menu-content {
    max-width: 480px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.logo-title {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 5px;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 25px rgba(0, 240, 255, 0.35);
}

.logo-subtitle {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    color: #8888aa;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* HUD styling */
.hud-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
    pointer-events: none;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(5, 5, 18, 0.7);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 12px;
    padding: 10px 15px;
    backdrop-filter: blur(10px);
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 0.65rem;
    color: #8888aa;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.hud-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.4rem;
    font-weight: bold;
}

.text-yellow { color: var(--neon-yellow); }
.text-purple { color: var(--neon-purple); }
.text-green { color: var(--neon-green); }
.text-blue { color: var(--neon-blue); }
.text-red { color: var(--neon-red); }

/* Powerups countdown bar */
.powerup-bar-container {
    width: 100%;
    background: rgba(5, 5, 18, 0.8);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.powerup-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
}

#powerup-label {
    color: var(--neon-yellow);
}

#powerup-timer {
    font-family: 'Share Tech Mono', monospace;
    color: white;
}

.powerup-progress-bg {
    background: rgba(0, 0, 0, 0.5);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.powerup-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-yellow), #ffa500);
    width: 100%;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* Legend detailing items */
.legend-box {
    text-align: left;
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.legend-box h3, .controls-guide h3 {
    font-size: 0.8rem;
    color: var(--neon-blue);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.legend-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
    color: #ccc;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.core-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px currentColor;
}

.bg-green { background-color: var(--neon-green); color: var(--neon-green); }
.bg-yellow { background-color: var(--neon-yellow); color: var(--neon-yellow); }
.bg-blue { background-color: var(--neon-blue); color: var(--neon-blue); }
.bg-red { background-color: var(--neon-red); color: var(--neon-red); }
.bg-rainbow {
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
    color: #ffffff;
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
}

/* Controls guide */
.controls-guide {
    text-align: left;
    width: 100%;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: #aaa;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 1px 4px;
    color: #fff;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    color: white;
}

.btn-glow:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
}

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

/* Game Over Stats layout */
.final-stats {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 10px;
    padding: 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Share Tech Mono', monospace;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: #ccc;
}

.new-high-badge {
    background: rgba(176, 108, 255, 0.15);
    border: 1px solid var(--neon-purple);
    border-radius: 6px;
    padding: 6px;
    font-size: 0.8rem;
    color: #dfbfff;
    text-shadow: 0 0 5px var(--neon-purple);
    margin-top: 5px;
    animation: flashPurple 1s infinite alternate;
}

@keyframes flashPurple {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.menu-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.pop-in {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Unified Top Navigation Bar */
.unified-nav {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 10, 25, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 99;
}

.unified-nav .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unified-nav .brand-icon {
    font-size: 1.6rem;
    color: #39ff14;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

.unified-nav .brand-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff, #8888aa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.unified-nav .nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.unified-nav .btn {
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transition: all 0.2s ease;
    text-decoration: none;
}

.unified-nav .btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,255,255,0.05);
}

.unified-nav .btn-home {
    background: linear-gradient(135deg, #00f0ff, #0072ff);
    border-color: #00f0ff;
    color: #050515;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.unified-nav .btn-home:hover {
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
    color: #ffffff;
}

/* Ensure mobile layout doesn't break header */
@media (max-width: 600px) {
    .unified-nav {
        padding: 10px 16px;
    }
    .unified-nav .brand-title {
        font-size: 1.1rem;
    }
    .unified-nav .btn span {
        display: none;
    }
    .unified-nav .btn {
        padding: 8px;
    }
}
