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

body {
    background: #000;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

.back-to-vault {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid #e94560;
    border-radius: 8px;
    color: #e94560;
    text-decoration: none;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.back-to-vault:hover {
    background: #e94560;
    color: white;
    box-shadow: 0 0 25px rgba(233, 69, 96, 0.5);
    transform: translateX(-5px);
}

.back-icon {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.back-to-vault:hover .back-icon {
    transform: translateX(-3px);
}

.back-text {
    text-transform: uppercase;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

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

.health-icon {
    font-size: 28px;
    animation: pulse 1s ease-in-out infinite;
}

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

.health-bar {
    width: 250px;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 0, 0, 0.5);
}

.health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #e94560 0%, #ff6b6b 50%, #ff8e8e 100%);
    border-radius: 12px;
    transition: width 0.3s ease;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.6), inset 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.health-fill.low {
    background: linear-gradient(90deg, #ff0000 0%, #cc0000 100%);
    animation: healthPulse 0.5s ease-in-out infinite;
}

@keyframes healthPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); }
    50% { opacity: 0.7; box-shadow: 0 0 40px rgba(255, 0, 0, 1); }
}

#healthText {
    color: white;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    min-width: 40px;
}

.stats {
    display: flex;
    gap: 15px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

#overlay, #levelComplete {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#overlay.hidden, #levelComplete.hidden {
    display: none;
}

.title {
    font-size: 72px;
    font-weight: bold;
    background: linear-gradient(135deg, #e94560, #ff6b6b, #feca57, #4ade80);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    animation: gradientShift 3s ease infinite, titleFloat 2s ease-in-out infinite;
    text-shadow: none;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    color: #888;
    font-size: 24px;
    margin-bottom: 50px;
    font-style: italic;
}

.menu-btn {
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 24px;
    border-radius: 35px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 30px rgba(233, 69, 96, 0.5);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    pointer-events: auto;
}

.menu-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 40px rgba(233, 69, 96, 0.7);
}

.menu-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.instructions {
    color: #aaa;
    margin-top: 50px;
    text-align: center;
    line-height: 2;
}

.instructions h3 {
    color: #e94560;
    margin-bottom: 20px;
    font-size: 20px;
    letter-spacing: 2px;
}

.key {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin: 0 4px;
    font-family: monospace;
    font-size: 14px;
    color: white;
}

.warning-text {
    color: #e94560;
    margin-top: 15px;
    font-weight: bold;
}

.hint-text {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}

.level-title {
    font-size: 56px;
    font-weight: bold;
    color: #4ade80;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(74, 222, 128, 0.5);
}

.level-score {
    font-size: 32px;
    color: #feca57;
    margin-bottom: 30px;
}

#damageFlash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(255, 0, 0, 0.5) 100%);
    pointer-events: none;
    opacity: 0;
    z-index: 5;
    transition: opacity 0.1s ease;
}

#healFlash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(74, 222, 128, 0.3) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0;
    z-index: 5;
    transition: opacity 0.2s ease;
}

#levelIndicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 30px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 10;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
}

.crosshair::before {
    width: 2px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair::after {
    width: 100%;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
}

#blackoutOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    transition: opacity 0.3s ease;
}

#blackoutOverlay.active {
    opacity: 1;
}

#reverseIndicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000;
    font-size: 36px;
    font-weight: bold;
    text-shadow: 0 0 20px #ff0000, 0 0 40px #ff0000;
    pointer-events: none;
    opacity: 0;
    z-index: 60;
    animation: glitch 0.3s infinite;
    letter-spacing: 5px;
}

#reverseIndicator.active {
    opacity: 1;
}

@keyframes glitch {
    0%, 100% { transform: translate(-50%, -50%) skewX(0deg); }
    25% { transform: translate(-52%, -48%) skewX(2deg); }
    50% { transform: translate(-48%, -52%) skewX(-2deg); }
    75% { transform: translate(-51%, -49%) skewX(1deg); }
}

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5px, -5px); }
    20% { transform: translate(5px, -5px); }
    30% { transform: translate(-5px, 5px); }
    40% { transform: translate(5px, 5px); }
    50% { transform: translate(-3px, -3px); }
    60% { transform: translate(3px, -3px); }
    70% { transform: translate(-3px, 3px); }
    80% { transform: translate(3px, 3px); }
    90% { transform: translate(-1px, -1px); }
}

#gameCanvas.shake {
    animation: screenShake 0.5s ease;
}
