:root {
    --bg-color: #0c0a09;
    --panel-color: #1c1917;
    --teal: #2dd4bf;
    --copper: #d97706;
    --gold: #fcd34d;
    --ice: #67e8f9;
    --danger: #ef4444;
    --text-main: #e7e5e4;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    overflow: hidden;
    font-family: var(--font-stack);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1c1917;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 20%, rgba(0,0,0,0.8) 100%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), 
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 50px 50px, 50px 50px;
    transition: background-color 0.5s;
}

#game-container.frozen-bg {
    background-color: #0f172a; /* Dark blue tint */
}

#game-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    will-change: transform;
}

.high-quality #game-layer {
    filter: drop-shadow(0 0 3px rgba(45, 212, 191, 0.3));
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    box-sizing: border-box;
}

.hud-panel {
    display: flex;
    justify-content: space-between;
    color: var(--text-main);
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    font-weight: 700;
    font-size: 16px;
    pointer-events: none;
    letter-spacing: 1px;
}

.bar-wrapper {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.bar-container {
    height: 10px;
    background: #292524;
    border: 1px solid #57534e;
    position: relative;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 50px;
}

#hp-bar {
    width: 100%;
    height: 100%;
    background-color: var(--danger);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.bar-container.overhealed {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(252, 211, 77, 0.4);
}
.bar-container.overhealed #hp-bar {
    background: linear-gradient(90deg, var(--danger), #f59e0b);
}

#hp-text {
    font-size: 10px;
    margin-left: 8px;
    color: #a8a29e;
}

#score-display {
    text-align: right;
    color: var(--copper);
    font-size: 22px;
    font-family: monospace;
}

#stats-display {
    text-align: right;
    font-size: 11px;
    color: var(--teal);
    margin-top: 4px;
    opacity: 0.8;
}

#wave-display {
    text-align: center;
    color: var(--teal);
    font-size: 24px;
    font-weight: 800;
    position: absolute;
    width: 100%;
    top: 60px;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s;
    text-shadow: 0 0 10px rgba(45, 212, 191, 0.5);
    letter-spacing: 3px;
}

#joystick-zone {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    width: 100px; height: 100px;
    border: 2px solid rgba(217, 119, 6, 0.3);
    border-radius: 50%;
    display: none; pointer-events: none;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
#joystick-knob {
    position: absolute; top: 50%; left: 50%;
    width: 40px; height: 40px;
    background: rgba(217, 119, 6, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255,255,255,0.2);
}

.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(12, 10, 9, 0.95);
    z-index: 20;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    pointer-events: auto;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s;
}
.hidden { display: none !important; opacity: 0; pointer-events: none; }

h1 {
    color: var(--copper); text-transform: uppercase;
    letter-spacing: 4px; margin-bottom: 10px;
    font-size: 32px; text-align: center;
    border-bottom: 2px solid var(--teal); padding-bottom: 10px;
}

.btn {
    background: linear-gradient(to bottom, #44403c, #292524);
    color: var(--copper); border: 1px solid #78350f;
    padding: 15px 50px; font-size: 18px; font-weight: bold;
    text-transform: uppercase; cursor: pointer;
    margin-top: 25px; transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    border-radius: 2px;
}
.btn:active { transform: scale(0.96); background: var(--copper); color: #000; }

.info-text {
    color: #a8a29e; margin-top: 10px; font-size: 13px;
    text-align: center; max-width: 80%; font-style: italic;
}

#debug-fps { position: absolute; bottom: 5px; right: 5px; color: #57534e; font-size: 10px; font-family: monospace; }

#pause-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: var(--copper);
    border: 2px solid var(--copper);
    border-radius: 4px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#pause-btn:hover { background: rgba(217, 119, 6, 0.2); border-color: var(--gold); }
#pause-btn:active { transform: scale(0.95); }
#pause-btn svg { width: 24px; height: 24px; fill: #E8E8E8; }

.audio-toggle-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: var(--copper);
    border: 2px solid var(--copper);
    border-radius: 4px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.audio-toggle-btn:hover { 
    background: var(--copper) !important; 
    border-color: var(--gold); 
}
.audio-toggle-btn:active { 
    transform: scale(0.95); 
    background: var(--copper) !important;
}
.audio-toggle-btn:focus {
    background: var(--copper) !important;
    outline: none;
}
.audio-toggle-btn svg { 
    width: 24px; 
    height: 24px; 
}

.music-toggle-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    background: var(--copper);
    border: 2px solid var(--copper);
    border-radius: 4px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.music-toggle-btn:hover { 
    background: var(--copper) !important; 
    border-color: var(--gold); 
}
.music-toggle-btn:active { 
    transform: scale(0.95); 
    background: var(--copper) !important;
}
.music-toggle-btn:focus {
    background: var(--copper) !important;
    outline: none;
}
.music-toggle-btn svg { 
    width: 24px; 
    height: 24px; 
}


@keyframes shake {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, 2px); }
    100% { transform: translate(0, 0); }
}
.shake-screen { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }

.floating-text {
    position: absolute;
    font-weight: bold;
    font-size: 14px;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    z-index: 15;
    text-shadow: 0 1px 2px black;
}

@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}
    