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

body {
    background: #0a0505;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    color: #ff3333;
    user-select: none;
    -webkit-user-select: none;
}

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

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

#scene-container canvas {
    image-rendering: pixelated;
}

/* Title Screen */
#title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a0505 0%, #330808 50%, #1a0505 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.title-content {
    text-align: center;
}

.doom-title {
    font-size: clamp(3rem, 15vw, 8rem);
    color: #ff0000;
    text-shadow: 
        0 0 20px #ff0000,
        0 0 40px #ff0000,
        0 5px 0 #660000,
        0 10px 0 #330000;
    letter-spacing: 0.2em;
    animation: titlePulse 2s infinite;
}

.drip {
    display: inline-block;
    position: relative;
}

.drip::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 4px;
    height: 20px;
    background: linear-gradient(to bottom, #ff0000, transparent);
    animation: drip 2s infinite;
    animation-delay: calc(var(--i, 0) * 0.3s);
}

.drip:nth-child(1) { --i: 0; }
.drip:nth-child(2) { --i: 1; }
.drip:nth-child(3) { --i: 2; }
.drip:nth-child(4) { --i: 3; }

@keyframes drip {
    0%, 100% { height: 20px; opacity: 1; }
    50% { height: 40px; opacity: 0.5; }
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px #ff0000, 0 0 40px #ff0000, 0 5px 0 #660000; }
    50% { text-shadow: 0 0 40px #ff0000, 0 0 80px #ff0000, 0 5px 0 #660000; }
}

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

.skulls {
    font-size: 2rem;
    margin: 2rem 0;
    animation: skullBounce 1s infinite alternate;
}

@keyframes skullBounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.difficulty-select {
    margin: 2rem 0;
}

.diff-option {
    padding: 0.8rem 1.5rem;
    margin: 0.3rem 0;
    font-size: clamp(0.4rem, 1.5vw, 0.7rem);
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-option:hover {
    color: #ff6600;
    transform: scale(1.05);
}

.diff-option.selected {
    color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
    text-shadow: 0 0 10px #ff0000;
}

.start-text {
    font-size: clamp(0.5rem, 2vw, 0.9rem);
    color: #00ff00;
    animation: blink 1s infinite;
    margin-top: 2rem;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.high-score {
    margin-top: 1rem;
    font-size: 0.6rem;
    color: #666;
}

/* HUD */
#hud {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1rem;
    background: linear-gradient(to top, rgba(30, 10, 10, 0.95), transparent);
    z-index: 50;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hud-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.hud-label {
    font-size: clamp(0.4rem, 1vw, 0.6rem);
    color: #666;
}

.hud-value {
    font-size: clamp(1rem, 4vw, 2rem);
}

.hud-percent {
    font-size: clamp(0.6rem, 2vw, 1rem);
}

.ammo .hud-value { color: #ffff00; }
.health .hud-value { color: #ff3333; }
.armor .hud-value { color: #3388ff; }
.time .hud-value { 
    color: #aaa; 
    font-size: clamp(0.6rem, 2vw, 1rem);
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

#face-container {
    width: clamp(50px, 12vw, 80px);
    height: clamp(50px, 12vw, 80px);
    background: #222;
    border: 3px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
}

#doomguy-face {
    font-size: clamp(1.5rem, 6vw, 3rem);
}

.kill-counter {
    font-size: clamp(0.5rem, 1.5vw, 0.8rem);
    color: #ff6600;
}

/* Weapon */
#weapon {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    z-index: 40;
    transition: transform 0.05s;
}

#weapon.shooting {
    transform: translateX(-50%) translateY(-20px) scale(1.1);
}

.shotgun {
    position: relative;
}

.barrel {
    width: clamp(80px, 20vw, 150px);
    height: clamp(30px, 8vw, 50px);
    background: linear-gradient(to bottom, #555, #333, #222);
    border-radius: 5px 5px 0 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.stock {
    width: clamp(60px, 15vw, 100px);
    height: clamp(40px, 10vw, 60px);
    background: linear-gradient(to bottom, #4a3020, #3a2515);
    margin: 0 auto;
    border-radius: 0 0 10px 10px;
}

/* Damage overlay */
#damage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, transparent 30%, rgba(255, 0, 0, 0.5) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 30;
}

/* Kill message */
#kill-message {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1rem, 4vw, 2rem);
    color: #ff0000;
    text-shadow: 0 0 20px #ff0000;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 60;
}

/* Game Over */
#game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.game-over-content {
    text-align: center;
}

.game-over-title {
    font-size: clamp(2rem, 10vw, 5rem);
    color: #ff0000;
    text-shadow: 0 0 30px #ff0000;
    animation: deathPulse 0.5s infinite;
}

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

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

.final-stats span {
    color: #ff6600;
}

.restart-text {
    font-size: clamp(0.5rem, 2vw, 0.9rem);
    color: #00ff00;
    animation: blink 1s infinite;
}

/* Controls hint / Legend */
#controls-hint {
    position: absolute;
    top: 1rem;
    left: 1rem;
    transition: opacity 0.5s;
    z-index: 40;
}

.controls-legend {
    background: rgba(10, 5, 5, 0.9);
    border: 2px solid #442222;
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 0.45rem;
    color: #aa8888;
    line-height: 1.6;
    min-width: 180px;
}

.legend-title {
    font-size: 0.6rem;
    color: #ff6600;
    text-align: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #442222;
    text-shadow: 0 0 10px #ff6600;
}

.legend-section {
    margin-bottom: 0.6rem;
}

.legend-header {
    font-size: 0.4rem;
    color: #ff3333;
    margin-bottom: 0.3rem;
    letter-spacing: 0.1em;
}

.key {
    display: inline-block;
    background: linear-gradient(to bottom, #333, #1a1a1a);
    border: 1px solid #555;
    border-radius: 3px;
    padding: 0.15rem 0.4rem;
    margin-right: 0.3rem;
    color: #ffcc00;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.4rem;
    min-width: 1.2rem;
    text-align: center;
    box-shadow: 0 2px 0 #000;
}

.legend-tip {
    font-size: 0.35rem;
    color: #00ff00;
    text-align: center;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid #442222;
    animation: blink 2s infinite;
}

/* Mobile controls */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 120px;
    left: 0;
    right: 0;
    padding: 1rem;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 45;
    pointer-events: none;
}

#joystick-zone {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: auto;
}

#shoot-button {
    background: linear-gradient(to bottom, #ff3300, #aa2200);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-family: 'Press Start 2P', monospace;
    box-shadow: 0 5px 0 #660000, 0 0 20px rgba(255, 50, 0, 0.5);
    pointer-events: auto;
    active: {
        transform: translateY(3px);
        box-shadow: 0 2px 0 #660000;
    }
}

#shoot-button:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #660000;
}

/* Footer */
#footer {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}

#footer a {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.5rem;
    color: #ff6600;
    text-decoration: none;
    text-shadow: 0 0 10px #ff6600;
    animation: firePulse 1.5s infinite;
}

@keyframes firePulse {
    0%, 100% { text-shadow: 0 0 10px #ff6600; }
    50% { text-shadow: 0 0 20px #ff0000, 0 0 40px #ff6600; }
}

#footer a:hover {
    color: #ff0000;
}

/* Crosshair */
#scene-container::after {
    content: '+';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}