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

body {
    font-family: 'Arial', sans-serif;
    background: #f7f7f7;
    height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-area {
    width: 800px;
    height: 400px;
    background: linear-gradient(to bottom, 
        /* Sky */
        #f7f7f7 0%, 
        #f7f7f7 70%, 
        /* Ground transition */
        #f7f7f7 70%, 
        #f7f7f7 100%
    );
    border: 2px solid #535353;
    position: relative;
    overflow: hidden;
    border-radius: 0;
    box-shadow: none;
}

#skyline {
    position: absolute;
    top: 120px;
    left: 0;
    width: 100%;
    height: 120px;
    display: block;
    image-rendering: pixelated;
    z-index: 1;
}

.ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: #535353;
    z-index: 2;
}

.ground::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        #535353 0px,
        #535353 6px,
        transparent 6px,
        transparent 12px
    );
}

.player {
    position: absolute;
    bottom: 2px;
    left: 120px;
    width: 80px;
    height: 80px;
    transition: none;
    z-index: 10;
}

.player img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1); /* Flip horizontally so she faces left to right */
}

.player-fallback {
    font-size: 70px;
    display: none;
    text-align: center;
    line-height: 80px;
}

.player.jumping {
    animation: jump 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes jump {
    0% { 
        bottom: 2px; 
        transform: translateY(0);
    }
    25% { 
        bottom: 80px; 
        transform: translateY(-10px);
    }
    50% { 
        bottom: 120px; 
        transform: translateY(0);
    }
    75% { 
        bottom: 80px; 
        transform: translateY(5px);
    }
    100% { 
        bottom: 2px; 
        transform: translateY(0);
    }
}

.obstacle {
    position: absolute;
    bottom: 2px;
    right: -50px;
    width: 32px;
    height: 32px;
    animation: moveObstacle 3s linear infinite;
}

.obstacle img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.obstacle-fallback {
    width: 100%;
    height: 100%;
    background: #8B7355;
    position: relative;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* 8-bit stone design */
.obstacle-stone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        /* Top highlight */
        linear-gradient(to right, #A0906B 0%, #A0906B 25%, transparent 25%, transparent 50%, #A0906B 50%, #A0906B 75%, transparent 75%),
        /* Left highlight */
        linear-gradient(to bottom, #A0906B 0%, #A0906B 25%, transparent 25%, transparent 50%, #A0906B 50%, #A0906B 75%, transparent 75%),
        /* Main stone color */
        linear-gradient(to right, #8B7355 0%, #8B7355 100%);
    background-size: 8px 8px, 8px 8px, 100% 100%;
}

.obstacle-stone::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: 
        /* Bottom shadow */
        linear-gradient(to left, #6B5D42 0%, #6B5D42 25%, transparent 25%, transparent 50%, #6B5D42 50%, #6B5D42 75%, transparent 75%),
        /* Right shadow */
        linear-gradient(to top, #6B5D42 0%, #6B5D42 25%, transparent 25%, transparent 50%, #6B5D42 50%, #6B5D42 75%, transparent 75%);
    background-size: 8px 8px, 8px 8px;
}

/* 8-bit cactus design */
.obstacle-cactus {
    width: 24px !important;
    height: 40px !important;
    background: #2D5016;
    position: relative;
    image-rendering: pixelated;
}

.obstacle-cactus::before {
    content: '';
    position: absolute;
    top: 8px;
    left: -8px;
    width: 12px;
    height: 16px;
    background: #2D5016;
    border: 2px solid #1A3009;
}

.obstacle-cactus::after {
    content: '';
    position: absolute;
    top: 4px;
    right: -8px;
    width: 12px;
    height: 20px;
    background: #2D5016;
    border: 2px solid #1A3009;
}

/* 8-bit fire hydrant */
.obstacle-hydrant {
    width: 28px !important;
    height: 36px !important;
    background: #C41E3A;
    position: relative;
    image-rendering: pixelated;
}

.obstacle-hydrant::before {
    content: '';
    position: absolute;
    top: 8px;
    left: -4px;
    width: 8px;
    height: 12px;
    background: #8B0000;
    border-radius: 2px;
}

.obstacle-hydrant::after {
    content: '';
    position: absolute;
    top: 8px;
    right: -4px;
    width: 8px;
    height: 12px;
    background: #8B0000;
    border-radius: 2px;
}

/* 8-bit trash bin */
.obstacle-trash {
    width: 30px !important;
    height: 38px !important;
    background: #2C2C2C;
    position: relative;
    image-rendering: pixelated;
    border-radius: 2px;
}

.obstacle-trash::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 6px;
    background: #1A1A1A;
    border-radius: 3px;
}

.obstacle-trash::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #444;
    box-shadow: 0 6px 0 #444, 0 12px 0 #444;
}

/* 8-bit construction cone */
.obstacle-cone {
    width: 26px !important;
    height: 34px !important;
    background: linear-gradient(to bottom, 
        #FF6600 0%, #FF6600 25%,
        #FFF 25%, #FFF 35%,
        #FF6600 35%, #FF6600 60%,
        #FFF 60%, #FFF 70%,
        #FF6600 70%, #FF6600 100%
    );
    position: relative;
    image-rendering: pixelated;
    clip-path: polygon(40% 0%, 60% 0%, 100% 100%, 0% 100%);
}

/* 8-bit bench */
.obstacle-bench {
    width: 40px !important;
    height: 24px !important;
    background: #8B4513;
    position: relative;
    image-rendering: pixelated;
}

.obstacle-bench::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 4px;
    width: 4px;
    height: 8px;
    background: #654321;
    box-shadow: 28px 0 0 #654321;
}

.obstacle-bench::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: #A0522D;
    border: 1px solid #654321;
}

@keyframes moveObstacle {
    from { right: -50px; }
    to { right: 850px; }
}

.cloud {
    position: absolute;
    background: #d3d3d3;
    border-radius: 50px;
    opacity: 0.3;
    animation: moveClouds 12s linear infinite;
    width: 60px;
    height: 20px;
    top: 50px;
}

.cloud::before {
    content: '';
    position: absolute;
    background: #d3d3d3;
    border-radius: 50px;
    width: 25px;
    height: 25px;
    top: -10px;
    left: 10px;
}

.cloud::after {
    content: '';
    position: absolute;
    background: #d3d3d3;
    border-radius: 50px;
    width: 30px;
    height: 15px;
    top: -5px;
    right: 10px;
}

@keyframes moveClouds {
    from { right: -100px; }
    to { right: 850px; }
}

.hearts {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.heart {
    font-size: 24px;
    color: #ff4757;
    transition: all 0.3s ease;
}

.heart.lost {
    opacity: 0.2;
    transform: scale(0.8);
}

.score {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 20px;
    font-weight: bold;
    color: #535353;
    font-family: monospace;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(247, 247, 247, 0.95);
    padding: 30px;
    border: 2px solid #535353;
    text-align: center;
    display: none;
    z-index: 100;
}

.game-over h2 {
    color: #535353;
    margin-bottom: 15px;
    font-size: 24px;
    font-family: monospace;
}

.game-over p {
    margin-bottom: 20px;
    font-size: 16px;
    color: #535353;
    font-family: monospace;
}

.game-over button {
    background: #535353;
    color: #f7f7f7;
    border: none;
    padding: 12px 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-family: monospace;
}

.game-over button:hover {
    background: #333;
}

.instructions {
    position: absolute;
    top: 70px;
    left: 20px;
    background: rgba(247, 247, 247, 0.9);
    border: 1px solid #535353;
    padding: 15px;
    font-size: 14px;
    color: #535353;
    max-width: 250px;
    font-family: monospace;
}

.instructions p {
    margin-bottom: 5px;
}

.instructions p:last-child {
    margin-bottom: 0;
    font-style: italic;
    color: #777;
}

/* Mobile responsiveness */
@media (max-width: 850px) {
    body {
        height: 100vh;
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
    
    .game-container {
        padding: 10px;
    }
    
    .game-area {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        max-height: 500px;
        min-height: 350px;
    }
    
    .score {
        font-size: 16px;
        padding: 8px 12px;
        top: 10px;
        right: 10px;
    }
    
    .instructions {
        font-size: 12px;
        padding: 8px;
        top: 10px;
        left: 10px;
        max-width: 200px;
    }
    
    .player {
        width: 50px;
        height: 50px;
        left: 40px;
    }
    
    .obstacle {
        width: 25px;
        height: 50px;
    }
    
    .game-over {
        padding: 20px;
        max-width: 280px;
    }
    
    .game-over h2 {
        font-size: 24px;
    }
    
    .game-over p {
        font-size: 16px;
    }
}

/* Portrait mobile devices */
@media (max-width: 480px) and (orientation: portrait) {
    .game-area {
        height: 60vh;
        min-height: 300px;
    }
    
    .instructions {
        font-size: 11px;
        padding: 6px;
        max-width: 180px;
    }
}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
    .game-area {
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    .instructions p:first-child {
        display: none;
    }
    
    .instructions p:nth-child(2)::before {
        content: "Tap to jump! ";
    }
    
    /* Prevent zoom on touch */
    .game-container {
        touch-action: manipulation;
    }
}
