/* Game Configuration Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --road-color: #34495e;
    --lane-color: #ecf0f1;
    --truck-color: #e67e22;
    --text-color: #2c3e50;
    --background-color: #ecf0f1;
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--background-color);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Game UI */
#gameUI {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
}

#healthBar {
    position: relative;
    width: 200px;
    height: 30px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid white;
}

#healthFill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--warning-color), var(--success-color));
    width: 100%;
    transition: width 0.3s ease;
}

#healthText {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

#score {
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* Game Area */
#gameArea {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #87CEEB 0%, #98FB98 100%);
}

#road {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: var(--road-color);
    border-top: 4px solid var(--lane-color);
}

#laneMarkings {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    transform: translateY(-50%);
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 30px,
        var(--lane-color) 30px,
        var(--lane-color) 50px
    );
    animation: moveLanes 1s linear infinite;
    animation-duration: calc(1s / var(--move-speed, 1));
}

@keyframes moveLanes {
    0% { transform: translateY(-50%) translateX(0); }
    100% { transform: translateY(-50%) translateX(-100px); }
}

/* Truck */
#truck {
    position: absolute;
    left: 15%;
    bottom: 50%;
    width: 60px;
    height: 40px;
    background: var(--truck-color);
    border-radius: 8px;
    transition: bottom 0.1s ease;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#truck::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 10px;
    width: 40px;
    height: 20px;
    background: var(--truck-color);
    border-radius: 4px;
}

#truck::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 5px;
    width: 15px;
    height: 10px;
    background: #2c3e50;
    border-radius: 2px;
}

#truck::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 5px;
    width: 15px;
    height: 10px;
    background: #2c3e50;
    border-radius: 2px;
}

/* Hide CSS-generated truck parts when using image */
#truck.using-image {
    border-radius: 0 !important;
    box-shadow: none !important;
}

#truck.using-image::before,
#truck.using-image::after {
    display: none;
}

/* Obstacles */
.obstacle {
    position: absolute;
    z-index: 5;
    transition: left 0.1s linear;
}

.obstacle.dog-poop {
    width: 20px;
    height: 20px;
    background: #8B4513;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.obstacle.kitten {
    width: 25px;
    height: 20px;
    background: #FFB6C1;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.obstacle.pedestrian {
    width: 15px;
    height: 30px;
    background: #4169E1;
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.obstacle.bicycle {
    width: 30px;
    height: 20px;
    background: #32CD32;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.obstacle.car {
    width: 40px;
    height: 25px;
    background: #FF6347;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.obstacle.other-truck {
    width: 50px;
    height: 30px;
    background: #9370DB;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Controls */
#controls {
    position: absolute;
    left: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.control-btn:active {
    transform: scale(0.95);
    background: var(--primary-color);
}

.control-btn:hover {
    background: var(--primary-color);
}

/* Game Over Screen */
#gameOverScreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(255, 100, 0, 0.8) 0%, rgba(255, 0, 0, 0.6) 30%, rgba(0, 0, 0, 0.9) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    animation: explosionFadeIn 0.5s ease-out;
}

@keyframes explosionFadeIn {
    0% { 
        background: rgba(0, 0, 0, 0);
        transform: scale(0.5);
    }
    50% {
        background: radial-gradient(circle, rgba(255, 200, 0, 0.9) 0%, rgba(255, 100, 0, 0.8) 30%, rgba(255, 0, 0, 0.7) 60%, rgba(0, 0, 0, 0.8) 100%);
        transform: scale(1.1);
    }
    100% { 
        background: radial-gradient(circle, rgba(255, 100, 0, 0.8) 0%, rgba(255, 0, 0, 0.6) 30%, rgba(0, 0, 0, 0.9) 100%);
        transform: scale(1);
    }
}

#gameOverContent {
    background: linear-gradient(45deg, #ff6b35, #f7931e, #ffd23f);
    padding: 40px;
    border-radius: 50% 20% 50% 20%;
    text-align: center;
    box-shadow: 
        0 0 50px rgba(255, 100, 0, 0.8),
        0 0 100px rgba(255, 0, 0, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
    max-width: 400px;
    width: 90%;
    border: 3px solid #ff4500;
    position: relative;
    animation: explosionPulse 2s ease-in-out infinite;
}

@keyframes explosionPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 0 50px rgba(255, 100, 0, 0.8),
            0 0 100px rgba(255, 0, 0, 0.6),
            inset 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 
            0 0 60px rgba(255, 100, 0, 1),
            0 0 120px rgba(255, 0, 0, 0.8),
            inset 0 0 25px rgba(255, 255, 255, 0.4);
    }
}

#gameOverContent h2 {
    color: #8B0000;
    margin-bottom: 20px;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    font-weight: bold;
}

#gameOverContent p {
    color: #8B0000;
    margin-bottom: 30px;
    font-size: 18px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-weight: bold;
}

#restartBtn {
    background: linear-gradient(45deg, #ff4500, #ff6347);
    color: white;
    border: 2px solid #8B0000;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
}

#restartBtn:hover {
    background: linear-gradient(45deg, #ff6347, #ff4500);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
}

.hidden {
    display: none !important;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    #gameUI {
        padding: 8px 15px;
    }
    
    #healthBar {
        width: 150px;
        height: 25px;
    }
    
    #healthText {
        font-size: 10px;
    }
    
    #score {
        font-size: 16px;
    }
    
    #truck {
        width: 50px;
        height: 35px;
    }
    
    #truck::before {
        width: 35px;
        height: 18px;
    }
    
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    #gameOverContent {
        padding: 30px 20px;
    }
    
    #gameOverContent h2 {
        font-size: 20px;
    }
    
    #gameOverContent p {
        font-size: 16px;
    }
}

/* Landscape mode specific */
@media (orientation: landscape) and (max-height: 500px) {
    #gameUI {
        padding: 5px 15px;
    }
    
    #healthBar {
        width: 120px;
        height: 20px;
    }
    
    #healthText {
        font-size: 9px;
    }
    
    #score {
        font-size: 14px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    #controls {
        left: 15px;
        bottom: 15px;
        gap: 8px;
    }
}
