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

body {
    overflow: hidden;
    background: #0a0a15;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    transition: box-shadow 0.1s;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#scene-container {
    position: absolute;
    inset: 0;
}

canvas {
    display: block;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    background: linear-gradient(180deg, #0a0a15 0%, #1a1a2e 100%);
}

.fog-overlay {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 80%, rgba(100, 100, 150, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(100, 100, 150, 0.1) 0%, transparent 50%);
    animation: fogMove 10s infinite alternate;
}

@keyframes fogMove {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.title {
    font-family: 'Creepster', cursive;
    font-size: clamp(3rem, 12vw, 8rem);
    color: #ff4444;
    text-shadow: 
        0 0 10px #ff4444,
        0 0 20px #ff4444,
        0 0 40px #ff2222,
        4px 4px 0 #440000;
    letter-spacing: 0.1em;
    animation: titlePulse 2s infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.subtitle {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    color: #8888aa;
    margin-top: 1rem;
    letter-spacing: 0.3em;
}

.instructions {
    margin: 2rem 0;
    text-align: center;
    color: #6666aa;
    font-size: clamp(0.7rem, 1.5vw, 0.9rem);
    line-height: 2;
}

.glow-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 700;
    padding: 1rem 3rem;
    background: linear-gradient(180deg, #4444ff 0%, #2222aa 100%);
    border: 2px solid #6666ff;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    animation: btnGlow 2s infinite;
}

.glow-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(68, 68, 255, 0.5);
}

.glow-btn.red {
    background: linear-gradient(180deg, #ff4444 0%, #aa2222 100%);
    border-color: #ff6666;
}

.glow-btn.red:hover {
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.glow-btn.gold {
    background: linear-gradient(180deg, #ffaa44 0%, #aa6622 100%);
    border-color: #ffcc66;
}

.glow-btn.gold:hover {
    box-shadow: 0 0 30px rgba(255, 170, 68, 0.5);
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(68, 68, 255, 0.3); }
    50% { box-shadow: 0 0 20px rgba(68, 68, 255, 0.5); }
}

.footer {
    position: absolute;
    bottom: 1rem;
    font-size: 0.8rem;
    color: #444;
}

.footer a {
    color: #666;
    text-decoration: none;
}

.footer a:hover {
    color: #888;
}

/* HUD */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

#health-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.heart {
    font-size: 1.5rem;
}

.heart.pulse {
    animation: heartPulse 0.5s infinite;
}

@keyframes heartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.bar-container {
    width: 150px;
    height: 20px;
    background: #333;
    border: 2px solid #555;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    transition: width 0.3s;
}

.hp-text {
    font-size: 0.9rem;
    color: #ff6666;
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
}

#wave-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

#wave-counter {
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 900;
    color: #ffaa44;
    text-shadow: 0 0 10px rgba(255, 170, 68, 0.5);
}

#score {
    font-size: 0.9rem;
    color: #888;
    margin-top: 5px;
}

#combo {
    font-size: 1rem;
    color: #44ff44;
    margin-top: 5px;
    animation: comboPulse 0.3s infinite;
}

@keyframes comboPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#attack-cooldown {
    position: absolute;
    top: 20px;
    right: 20px;
}

.cooldown-ring {
    position: relative;
    width: 50px;
    height: 50px;
}

.cooldown-ring svg {
    transform: rotate(-90deg);
}

.cooldown-ring .bg {
    fill: none;
    stroke: #333;
    stroke-width: 3;
}

.cooldown-ring .progress {
    fill: none;
    stroke: #44aaff;
    stroke-width: 3;
    stroke-dasharray: 100.53;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
}

.sword {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
}

#puzzle-progress {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.rune-slot {
    width: 50px;
    height: 50px;
    background: rgba(30, 30, 50, 0.8);
    border: 2px solid #444;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #666;
    transition: all 0.3s;
}

.rune-slot.filled {
    border-color: #44ffaa;
    color: #fff;
    box-shadow: 0 0 15px rgba(68, 255, 170, 0.5);
}

.rune-slot.wrong {
    border-color: #ff4444;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#wave-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.message-text {
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    color: #ffaa44;
    text-shadow: 
        0 0 20px #ffaa44,
        0 0 40px #ff6622;
    animation: messageSlam 0.5s ease-out;
}

@keyframes messageSlam {
    0% { transform: scale(2); opacity: 0; }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

#interact-prompt {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #44aaff;
    border-radius: 4px;
    color: #44aaff;
    font-size: 0.9rem;
    animation: promptPulse 1s infinite;
}

@keyframes promptPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    pointer-events: none;
    z-index: 20;
}

#joystick-zone {
    position: absolute;
    left: 20px;
    bottom: 20px;
    pointer-events: auto;
}

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

#joystick-stick {
    width: 40px;
    height: 40px;
    background: rgba(68, 136, 255, 0.8);
    border-radius: 50%;
    transition: transform 0.05s;
}

#attack-btn, #interact-btn {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    color: #fff;
    pointer-events: auto;
    cursor: pointer;
}

#attack-btn {
    right: 20px;
    bottom: 40px;
    background: rgba(255, 68, 68, 0.6);
}

#interact-btn {
    right: 100px;
    bottom: 80px;
    background: rgba(68, 170, 255, 0.6);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
}

/* Game Over Screen */
#gameover-screen {
    background: rgba(0, 0, 0, 0.9);
}

.blood-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(139, 0, 0, 0.5) 100%);
    pointer-events: none;
}

.death-title {
    font-family: 'Creepster', cursive;
    font-size: clamp(3rem, 15vw, 8rem);
    color: #ff0000;
    text-shadow: 
        0 0 20px #ff0000,
        0 0 40px #aa0000,
        0 0 60px #660000;
    animation: deathPulse 1s infinite;
}

@keyframes deathPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.stats {
    margin: 2rem 0;
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 2;
    color: #aaa;
}

.stats span {
    color: #fff;
    font-weight: 700;
}

/* Victory Screen */
#victory-screen {
    background: rgba(0, 20, 10, 0.95);
}

.portal-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0, 255, 170, 0.2) 0%, transparent 70%);
    animation: portalPulse 2s infinite;
}

@keyframes portalPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.victory-title {
    font-family: 'Creepster', cursive;
    font-size: clamp(3rem, 12vw, 7rem);
    color: #00ffaa;
    text-shadow: 
        0 0 20px #00ffaa,
        0 0 40px #00aa66,
        0 0 60px #006644;
    animation: victoryBounce 0.5s ease-out;
}

@keyframes victoryBounce {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .bar-container {
        width: 100px;
    }
    
    #puzzle-progress {
        bottom: 220px;
    }
    
    .rune-slot {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    #interact-prompt {
        bottom: 230px;
        font-size: 0.8rem;
    }
}