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

body {
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
}

#score-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

#health {
    font-size: 28px;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    letter-spacing: 2px;
}

#score {
    font-size: 32px;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
    letter-spacing: 2px;
}

#game-container {
    position: relative;
    width: 700px;
    height: 525px;
    background-image: url('assets/background_1.png');
    background-repeat: repeat;
    background-size: 75px 75px;
    background-position: 0 0;
    border: 3px solid #4a4a4a;
    border-radius: 8px;
    overflow: visible; /* Allow player image to extend beyond container edges */
}

#box {
    position: absolute;
    width: 75px;
    height: 75px;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
    transition: box-shadow 0.1s, transform 0.05s;
    top: 275px;
    left: 375px;
}

#box::before {
    content: '';
    position: absolute;
    width: 112.5px; /* 1.5x the hitbox size */
    height: 112.5px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-image: url('assets/bike_body.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none; /* Don't interfere with collision detection */
}

#box.facing-left::before {
    transform: translate(-50%, -50%) scaleX(-1);
}

#box.facing-right::before {
    transform: translate(-50%, -50%) scaleX(1);
}

#box.facing-left.invincible::before {
    animation: invincible-flash-left 0.2s infinite;
}

#box.facing-right.invincible::before {
    animation: invincible-flash-right 0.2s infinite;
}

#box:active {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.8);
}

@keyframes invincible-flash-left {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scaleX(-1);
    }
    50% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scaleX(-1);
    }
}

@keyframes invincible-flash-right {
    0%, 100% {
        opacity: 1;
        transform: translate(-50%, -50%) scaleX(1);
    }
    50% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scaleX(1);
    }
}

.enemy {
    position: absolute;
    width: 50px;
    height: 50px;
    background-image: url('assets/tree.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    transition: filter 0.1s;
}

.enemy-hit {
    filter: brightness(3) saturate(2);
    box-shadow: 0 0 40px rgba(255, 255, 255, 1) !important;
}

.enemy-shooter {
    background-image: url('assets/squirrel.png');
    box-shadow: 0 0 25px rgba(255, 100, 100, 0.8);
    border: 2px solid rgba(255, 68, 68, 0.5);
    border-radius: 4px;
}

.enemy-porcupine {
    background-image: url('assets/porcupine.png');
    box-shadow: 0 0 30px rgba(255, 102, 0, 0.8);
    border: 2px solid rgba(255, 102, 0, 0.6);
    border-radius: 4px;
}

.enemy-beaver {
    background-image: url('assets/beaver.png');
    box-shadow: 0 0 28px rgba(139, 69, 19, 0.8);
    border: 2px solid rgba(139, 69, 19, 0.6);
    border-radius: 4px;
}

.enemy-slowed {
    filter: brightness(0.7) saturate(0.5) hue-rotate(180deg);
    border: 2px solid rgba(0, 212, 255, 0.8) !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8) !important;
    animation: slow-effect 0.5s infinite;
}

@keyframes slow-effect {
    0%, 100% {
        filter: brightness(0.7) saturate(0.5) hue-rotate(180deg);
    }
    50% {
        filter: brightness(0.9) saturate(0.7) hue-rotate(180deg);
    }
}

.bullet {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #ffaa00;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.8);
    z-index: 10;
    will-change: transform; /* Hint to browser for performance optimization */
}

.health-pickup {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background-color: rgba(255, 68, 68, 0.2);
    border: 2px solid #ff4444;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.6);
    animation: pulse-pickup 1s infinite;
    z-index: 5;
}

@keyframes pulse-pickup {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 68, 68, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(255, 68, 68, 0.9);
    }
}

.weapon-pickup {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background-color: rgba(255, 170, 0, 0.2);
    border: 2px solid #ffaa00;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    animation: pulse-weapon 1s infinite;
    z-index: 5;
}

@keyframes pulse-weapon {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
    }
    50% {
        transform: scale(1.1) rotate(180deg);
        box-shadow: 0 0 30px rgba(255, 170, 0, 0.9);
    }
}

.bullet-slow {
    background-color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.8), 0 0 5px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.bullet-arc {
    background-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
}

.bullet-cluster {
    background-color: #ff00ff;
    border: 2px solid #ffaaff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.9);
    animation: cluster-pulse 0.3s infinite;
}

@keyframes cluster-pulse {
    0%, 100% {
        filter: brightness(1);
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.9);
    }
    50% {
        filter: brightness(1.2);
        box-shadow: 0 0 30px rgba(255, 0, 255, 1);
    }
}

.bullet-cluster-shard {
    background-color: #ff66ff;
    box-shadow: 0 0 10px rgba(255, 102, 255, 0.8);
}

.bullet-rapid {
    background-color: #ffff00;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.9);
    /* Animation disabled for performance */
}

@keyframes rapid-pulse {
    0%, 100% {
        filter: brightness(1);
        box-shadow: 0 0 15px rgba(255, 255, 0, 0.9);
    }
    50% {
        filter: brightness(1.3);
        box-shadow: 0 0 20px rgba(255, 255, 0, 1);
    }
}

.enemy-bullet {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #ff4444;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
    z-index: 10;
}

.enemy-bullet-porcupine {
    background-color: #ff6600;
    box-shadow: 0 0 15px rgba(255, 102, 0, 0.9);
}

.enemy-bullet-beaver {
    background-color: #8B4513;
    box-shadow: 0 0 15px rgba(139, 69, 19, 0.9);
    border: 1px solid rgba(101, 67, 33, 0.8);
}

.laser-wall {
    position: absolute;
    z-index: 5;
    animation: laser-flicker 0.15s infinite;
}

.laser-wall-vertical {
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 0, 0, 0.3) 20%,
        rgba(255, 0, 0, 0.8) 50%,
        rgba(255, 0, 0, 0.3) 80%,
        transparent 100%);
    border-left: 2px solid rgba(255, 0, 0, 0.9);
    border-right: 2px solid rgba(255, 0, 0, 0.9);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8),
                inset 0 0 20px rgba(255, 0, 0, 0.4);
}

.laser-wall-horizontal {
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(255, 0, 0, 0.3) 20%,
        rgba(255, 0, 0, 0.8) 50%,
        rgba(255, 0, 0, 0.3) 80%,
        transparent 100%);
    border-top: 2px solid rgba(255, 0, 0, 0.9);
    border-bottom: 2px solid rgba(255, 0, 0, 0.9);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8),
                inset 0 0 20px rgba(255, 0, 0, 0.4);
}

@keyframes laser-flicker {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

#instructions {
    margin-top: 20px;
    color: #00ff88;
    font-size: 16px;
    text-align: center;
}

#score-submit-container {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#player-name {
    padding: 10px 20px;
    font-size: 16px;
    background-color: #2d2d2d;
    border: 2px solid #4a4a4a;
    border-radius: 4px;
    color: #00ff88;
    width: 300px;
    text-align: center;
}

#player-name:focus {
    outline: none;
    border-color: #00ff88;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

#player-name::placeholder {
    color: #666;
}

#submit-score-btn,
#view-scores-btn {
    display: inline-block;
    text-decoration: none;
    padding: 10px 30px;
    font-size: 16px;
    font-weight: bold;
    color: #1a1a1a;
    background-color: #00ff88;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

#submit-score-btn:hover,
#view-scores-btn:hover {
    background-color: #00cc6a;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
    transform: translateY(-2px);
}

#submit-score-btn:active,
#view-scores-btn:active {
    transform: translateY(0);
}

#submit-score-btn:disabled {
    background-color: #4a4a4a;
    cursor: not-allowed;
    box-shadow: none;
}

#submit-message {
    color: #00ff88;
    font-size: 14px;
    min-height: 20px;
}

#submit-message.error {
    color: #ff4444;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #2d2d2d;
    padding: 30px;
    border: 3px solid #4a4a4a;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 40px rgba(0, 255, 136, 0.3);
}

.modal-content h2 {
    color: #00ff88;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover,
.close:focus {
    color: #00ff88;
}

#highscores-list {
    color: #00ff88;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background-color: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #00ff88;
}

.highscore-rank {
    font-weight: bold;
    margin-right: 10px;
    color: #00cc6a;
}

.highscore-name {
    flex: 1;
}

.highscore-score {
    font-weight: bold;
}

.loading {
    text-align: center;
    color: #aaa;
    padding: 20px;
}

.error-message {
    text-align: center;
    color: #ff4444;
    padding: 20px;
}
