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

body {
    font-family: 'Cinzel', serif;
    background: #0a0a15;
    color: #d4af37;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

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

#scene-container {
    width: 100%;
    height: 100%;
}

#scene-container canvas {
    display: block;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(20, 20, 35, 0.95) 0%, rgba(10, 10, 21, 0.98) 100%);
    z-index: 100;
}

.screen.hidden {
    display: none;
}

/* Start Screen */
#start-screen {
    overflow: hidden;
}

.torch-effect {
    position: absolute;
    width: 100px;
    height: 200px;
    background: radial-gradient(ellipse at center, rgba(233, 69, 96, 0.4) 0%, transparent 70%);
    animation: torchFlicker 0.5s infinite alternate;
}

.torch-effect.left {
    left: 10%;
    top: 30%;
}

.torch-effect.right {
    right: 10%;
    top: 30%;
}

@keyframes torchFlicker {
    0% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.1); }
}

.title-container {
    text-align: center;
    margin-bottom: 40px;
}

.game-title {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 900;
    color: #d4af37;
    text-shadow: 
        0 0 20px rgba(212, 175, 55, 0.5),
        0 0 40px rgba(212, 175, 55, 0.3),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.1em;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 20px rgba(212, 175, 55, 0.5), 0 0 40px rgba(212, 175, 55, 0.3), 2px 2px 4px rgba(0, 0, 0, 0.8); }
    100% { text-shadow: 0 0 30px rgba(212, 175, 55, 0.7), 0 0 60px rgba(212, 175, 55, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.8); }
}

.game-subtitle {
    font-size: clamp(1rem, 3vw, 1.8rem);
    font-weight: 400;
    color: #8b7355;
    letter-spacing: 0.3em;
    margin-top: 10px;
}

.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    font-weight: 700;
    padding: 15px 40px;
    margin: 10px;
    background: linear-gradient(180deg, #3a3a45 0%, #2a2a35 100%);
    border: 2px solid #d4af37;
    color: #d4af37;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu-btn:hover {
    background: linear-gradient(180deg, #4a4a55 0%, #3a3a45 100%);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    transform: scale(1.05);
}

.menu-btn:active {
    transform: scale(0.98);
}

.menu-btn.secondary {
    background: transparent;
    border: 1px solid #666;
    color: #888;
}

.menu-btn.secondary:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.sword-icon {
    font-size: 1.2em;
}

.controls-info {
    margin-top: 40px;
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #3a3a45;
}

.controls-info h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #d4af37;
}

.controls-info p {
    font-size: 0.9rem;
    margin: 8px 0;
    color: #aaa;
}

.key {
    display: inline-block;
    padding: 4px 10px;
    background: #2a2a35;
    border: 1px solid #4a4a55;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: #d4af37;
}

.high-score-display {
    margin-top: 30px;
    font-size: 1.1rem;
    color: #8b7355;
}

.skull-icon {
    font-size: 1.3em;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
}

#hud.hidden {
    display: none;
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-left {
    align-items: flex-start;
}

.hud-right {
    align-items: flex-end;
}

.health-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.heart-icon {
    font-size: 1.5rem;
    color: #ff0000;
    animation: heartbeat 1s ease-in-out infinite;
}

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

.health-bar {
    width: 150px;
    height: 20px;
    background: #1a1a2e;
    border: 2px solid #4a4a55;
    border-radius: 3px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    background: linear-gradient(180deg, #ff4444 0%, #8b0000 100%);
    transition: width 0.3s ease;
}

#health-text {
    font-size: 1rem;
    color: #ff4444;
    min-width: 30px;
}

.wave-counter {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 700;
    color: #d4af37;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.kill-counter {
    font-size: 1rem;
    color: #aaa;
    margin-top: 5px;
}

.score-display {
    font-size: 1.2rem;
    color: #d4af37;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.combo-display {
    font-size: 1.1rem;
    color: #ff6600;
    margin-top: 5px;
    text-shadow: 0 0 10px rgba(255, 102, 0, 0.5);
}

.combo-display.hidden {
    display: none;
}

@keyframes comboPulse {
    0% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Controls Hint */
.controls-hint {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #3a3a45;
    border-radius: 5px;
    font-size: 0.85rem;
    color: #888;
    z-index: 50;
    animation: fadeInOut 10s forwards;
}

.controls-hint.hidden {
    display: none;
}

@keyframes fadeInOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Wave Transition */
#wave-transition {
    background: rgba(10, 10, 21, 0.9);
}

.wave-complete-text {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(1.8rem, 5vw, 3rem);
    color: #39ff14;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
    margin-bottom: 20px;
    animation: pulseGlow 1s ease-in-out infinite;
}

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

.wave-stats {
    font-size: 1.1rem;
    color: #aaa;
    margin-bottom: 30px;
}

.wave-stats p {
    margin: 8px 0;
}

.next-wave-text {
    font-size: 1.3rem;
    color: #e94560;
    margin-bottom: 15px;
}

.countdown {
    font-size: 4rem;
    font-weight: 900;
    color: #d4af37;
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
}

/* Pause Menu */
.pause-title {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 3rem;
    color: #d4af37;
    margin-bottom: 40px;
}

/* Game Over */
.game-over-title {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(2.5rem, 7vw, 4rem);
    margin-bottom: 30px;
}

.game-over-title.defeat {
    color: #8b0000;
    text-shadow: 0 0 30px rgba(139, 0, 0, 0.6);
}

.game-over-title.victory {
    color: #39ff14;
    text-shadow: 0 0 30px rgba(57, 255, 20, 0.6);
    animation: victoryPulse 1s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); text-shadow: 0 0 30px rgba(57, 255, 20, 0.6); }
    50% { transform: scale(1.05); text-shadow: 0 0 50px rgba(57, 255, 20, 0.8); }
}

.final-stats {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 40px;
    text-align: center;
}

.final-stats p {
    margin: 10px 0;
}

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

/* Mobile Controls */
.mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    pointer-events: none;
    z-index: 60;
}

.mobile-controls.hidden {
    display: none;
}

.joystick-container {
    pointer-events: auto;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: rgba(50, 50, 60, 0.6);
    border: 3px solid rgba(212, 175, 55, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.joystick-stick {
    width: 50px;
    height: 50px;
    background: rgba(212, 175, 55, 0.8);
    border-radius: 50%;
    transition: transform 0.05s ease-out;
}

.attack-btn {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    background: linear-gradient(180deg, rgba(139, 0, 0, 0.8) 0%, rgba(100, 0, 0, 0.9) 100%);
    border: 3px solid #d4af37;
    border-radius: 50%;
    font-size: 2rem;
    color: #d4af37;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.attack-btn:active {
    transform: scale(0.95);
    background: linear-gradient(180deg, rgba(180, 0, 0, 0.9) 0%, rgba(139, 0, 0, 1) 100%);
}

/* Footer */
.game-footer {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(150, 150, 150, 0.5);
    z-index: 40;
    pointer-events: auto;
}

.game-footer a {
    color: rgba(212, 175, 55, 0.6);
    text-decoration: none;
}

.game-footer a:hover {
    color: #d4af37;
}

/* Responsive */
@media (max-width: 768px) {
    #hud {
        padding: 10px 15px;
    }
    
    .health-bar {
        width: 100px;
    }
    
    .controls-info {
        display: none;
    }
    
    .game-footer {
        bottom: 2px;
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .health-bar {
        width: 80px;
        height: 15px;
    }
    
    .heart-icon {
        font-size: 1.2rem;
    }
    
    .joystick-base {
        width: 100px;
        height: 100px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
    
    .attack-btn {
        width: 70px;
        height: 70px;
    }
}