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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    touch-action: manipulation;
    overflow: hidden;
    margin: 0;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 900px;
    background-color: #fff;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

#game-screen {
    position: relative;
    width: 100%;
    height: 85%;
    overflow: hidden;
}

.scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: hidden;
}

.scene.active {
    display: block;
}

/* Cafe Scene */
#cafe-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('background_cafe.png');
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#coffee-cup {
    position: absolute;
    width: 70px;
    height: 90px;
    background-color: #ffffff;
    border: 3px solid #4e342e;
    border-radius: 5px 5px 25px 25px;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.interactive {
    cursor: pointer;
    animation: pulse 1.5s infinite;
}

/* Street Scene */
#street-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('background_street.png');
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#player {
    position: absolute;
    width: 60px;
    height: 110px;
    background-color: #546e7a;
    border-radius: 50% 50% 0 0;
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
}

#player-coffee {
    position: absolute;
    width: 65px;
    height: 90px;
    background-color: #ffffff;
    border: 3px solid #4e342e;
    border-radius: 5px 5px 25px 25px;
    bottom: 20%; /* Changed from 30% to 20% to move cup down */
    left: calc(50% - 20px);
    z-index: 4;
    transition: transform 0.2s ease;
}

#obstacles-container {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.obstacle {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #ff5722;
    border-radius: 50%;
    z-index: 2;
}

.horizontal-obstacle {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #2196F3;
    border-radius: 50%;
    z-index: 2;
}

/* Home Scene */
#home-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background: url('background_home.png');
    background-size: cover;
    background-position: center;
    z-index: 1;
}

#table {
    position: absolute;
    width: 150px;
    height: 60px;
    background-color: #8d6e63;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

#player-home {
    position: absolute;
    width: 60px;
    height: 110px;
    background-color: #546e7a;
    border-radius: 50% 50% 0 0;
    bottom: 20%;
    left: 40%;
    z-index: 3;
}

#coffee-home {
    position: absolute;
    width: 45px;
    height: 60px;
    background-color: #ffffff;
    border: 2px solid #4e342e;
    border-radius: 3px 3px 15px 15px;
    bottom: 40%;
    left: 60%;
    z-index: 3;
}

/* Game Over Scene */
#game-over-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #ffcdd2;
    z-index: 1;
}

#spilled-coffee {
    position: absolute;
    width: 100px;
    height: 50px;
    background-color: #795548;
    border-radius: 50%;
    bottom: 40%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

/* Dialog Box */
.dialog-box {
    position: absolute;
    bottom: 5%;
    left: 5%;
    width: 90%;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.dialog-box p {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
    line-height: 1.4;
}

#restart-button, #try-again-button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
}

#restart-button:hover, #try-again-button:hover {
    background-color: #388e3c;
}

/* Coffee Meter */
#coffee-meter-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 20;
    display: none;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 10px;
}

#coffee-meter-label {
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    text-align: center;
    font-weight: bold;
}

#coffee-meter {
    width: 120px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #fff;
}

#coffee-level {
    height: 100%;
    width: 100%;
    background-color: #795548;
    transition: width 0.3s ease;
}

/* Progress Bar */
#progress-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20;
    display: none;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 10px;
}

#progress-label {
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    text-align: center;
    font-weight: bold;
}

#progress-bar {
    width: 120px;
    height: 15px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #fff;
}

#progress-level {
    height: 100%;
    width: 0%;
    background-color: #4caf50;
    transition: width 0.3s ease;
}

/* Controls */
#controls {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 15%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background-color: rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 10;
}

#jump-button {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
}

#crouch-button {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 90px;
}

.control-button {
    width: 70px;
    height: 70px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    user-select: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-button:active {
    background-color: rgba(255, 255, 255, 0.9);
}

@keyframes pulse {
    0% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
    100% {
        transform: translateX(-50%) scale(1);
    }
}

@keyframes walking {
    0% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-3px) rotate(-2deg);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(-3px) rotate(2deg);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes jump {
    0% {
        transform: translateY(0);
    }
    20% {
        transform: translateY(-40px);
    }
    50% {
        transform: translateY(-100px);
    }
    80% {
        transform: translateY(-40px);
    }
    100% {
        transform: translateY(0);
    }
}

.jumping {
    animation: jump 0.8s cubic-bezier(0.45, 0, 0.55, 1);
}

/* Coffee spill animation */
@keyframes spillCoffee {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

/* Crouching animation */
.crouching {
    transform: scale(0.7) translateY(20px);
    transition: transform 0.2s ease;
}

.hidden {
    display: none;
}

.high-obstacle {
    height: 80px;
    border-radius: 10px;
    background-color: #9C27B0;
}

#final-score {
    font-size: 24px;
    font-weight: bold;
    color: #4e342e;
    margin: 15px 0;
}

#score-value {
    color: #ff5722;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    #game-container {
        width: 100%;
        height: 100vh;
        max-width: none;
        max-height: none;
    }
    
    .control-button {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .dialog-box {
        font-size: 14px;
        padding: 10px;
    }
    
    .dialog-box p {
        font-size: 14px;
    }
    
    #restart-button, #try-again-button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    #progress-container {
        top: 35px;
        right: 10px;
    }
    
    #progress-bar {
        width: 100px;
        height: 12px;
    }
    
    #coffee-meter-container,
    #progress-container {
        padding: 5px;
    }
    
    #coffee-meter-container {
        left: 10px;
        top: 10px;
    }
    
    #progress-container {
        right: 10px;
        top: 10px;
    }
    
    #controls-instructions {
        top: 100px;
        font-size: 12px;
        padding: 8px;
    }
}

/* Controls Instructions */
#controls-instructions {
    position: absolute;
    top: 80px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 20;
    line-height: 1.3;
}

#controls-instructions p {
    margin: 5px 0;
}