:root {
    --bg-color: #030712;
    --primary: #EC4899;      /* Pink */
    --secondary: #8B5CF6;    /* Purple */
    --accent: #06B6D4;       /* Cyan */
    --text-main: #FFFFFF;
    --text-dim: #9CA3AF;
    --danger: #EF4444;
    --success: #10B981;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body, html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    overflow: hidden;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1e1b4b 0%, var(--bg-color) 100%);
}

#game-canvas {
    max-width: 100%;
    max-height: 100%;
    /* Keep aspect ratio to something like 3:4 or 4:5 for vertical shmups, but lets make it fill up to a max width so it feels right on desktop but expands on mobile */
    aspect-ratio: 3 / 4;
    height: 100%; 
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.2);
    image-rendering: auto; /* smooth rendering for modern feel */
}

@media (max-width: 768px), (max-aspect-ratio: 3/4) {
    #game-canvas {
        width: 100%;
        height: auto;
        aspect-ratio: auto; /* Allow full screen height on mobile if wanted, or just letterbox */
    }
}

.hidden {
    display: none !important;
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

/* UI Overlay */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.hud-top {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.score-container {
    display: flex;
    flex-direction: column;
}

.label {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    font-weight: 600;
}

#score-display {
    font-size: 2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
    text-shadow: 0 0 10px var(--primary);
}

.stats-container {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat {
    font-size: 1rem;
    font-weight: 600;
}

#graze-display { color: var(--accent); text-shadow: 0 0 5px var(--accent); }
#multiplier-display { color: var(--primary); text-shadow: 0 0 5px var(--primary); }
#weapon-display { color: var(--secondary); text-shadow: 0 0 5px var(--secondary); }

.hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.lives-container, .bombs-container {
    display: flex;
    gap: 8px;
}

.life-icon, .bomb-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}

.life-icon { background: var(--accent); color: var(--accent); }
.bomb-icon { background: var(--primary); color: var(--primary); }
.icon-empty { background: transparent; border: 2px solid var(--text-dim); box-shadow: none; }

#rhythm-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
}

#rhythm-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--secondary), var(--primary));
    transition: width 0.1s linear;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
    z-index: 100;
}

#start-screen {
    background: radial-gradient(circle at center, rgba(3, 7, 18, 0.9) 0%, rgba(3, 7, 18, 1) 100%);
    width: 100%;
    height: 100%;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    text-transform: uppercase;
    background: linear-gradient(to right, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 15px rgba(236, 72, 153, 0.4));
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    text-shadow: 0 0 15px var(--secondary);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 3rem;
    letter-spacing: 0.2em;
}

.warning {
    font-size: 0.8rem;
    color: var(--danger);
    margin: 2rem 0;
    opacity: 0.8;
}

/* Button */
.btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn:hover, .btn.active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2), 0 0 15px var(--secondary);
    border-color: var(--secondary);
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
}

.btn.primary:hover {
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.6), 0 0 20px var(--primary);
}

.btn.danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}
.btn.danger:hover {
    background: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 15px var(--danger);
}

.difficulty-select {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.diff-btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

/* Game Over specific */
.final-stats {
    margin: 2rem 0;
    font-size: 1.2rem;
    line-height: 1.6;
}
.final-stats span {
    font-weight: 800;
    color: var(--primary);
}

.leaderboard-entry {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

input[type="text"] {
    background: rgba(0,0,0,0.5);
    border: 2px solid var(--secondary);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    padding: 0.8rem;
    width: 100px;
    text-align: center;
    text-transform: uppercase;
    font-family: inherit;
    font-weight: bold;
}
input[type="text"]:focus {
    outline: none;
    box-shadow: 0 0 10px var(--secondary);
}

/* Leaderboard Panel */
.glass-panel {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    padding: 1.5rem;
    min-width: 250px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.glass-panel h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--accent);
}

#score-list {
    list-style: none;
}

#score-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-family: monospace;
    font-size: 1.1rem;
}

#score-list li span:last-child {
    font-weight: bold;
    color: var(--primary);
}

/* Touch Controls */
#touch-controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    height: 150px;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    pointer-events: none;
    z-index: 50;
}

#joystick-zone {
    width: 120px;
    height: 120px;
    position: relative;
    pointer-events: auto;
}

#joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#joystick-stick {
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
    position: absolute;
}

#action-zone {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    pointer-events: auto;
}

.touch-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.touch-btn:active {
    background: rgba(255,255,255,0.3);
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary);
}

@media (max-width: 768px) {
    #hud {
        padding: 10px;
    }
    .hud-top {
        top: 10px; left: 10px; right: 10px;
    }
    #score-display {
        font-size: 1.5rem;
    }
    .glass-panel {
        display: none; /* hide leaderboard on small screens while playing */
    }
    h1 { font-size: 2rem; }
    h2 { font-size: 1.8rem; }
    .overlay { padding: 1.5rem; width: 90%; }
}
