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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Mobile-specific body styles */
@media (max-width: 768px) {
    body {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Prevent overflow only when game is active */
    body.game-active {
        overflow: hidden;
        touch-action: none;
    }
}

.game-container {
    max-width: 1000px;
    width: 100%;
}

.game-header {
    background: #1a1a2e;
    padding: 20px;
    border-radius: 10px 10px 0 0;
    border: 4px solid #0f3460;
    border-bottom: none;
}

.game-header h1 {
    text-align: center;
    color: #ffeb3b;
    font-size: 2.5rem;
    text-shadow: 3px 3px 0px #0f3460;
    margin-bottom: 15px;
    letter-spacing: 3px;
}

.game-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stat {
    background: #0f3460;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    border: 2px solid #00d9ff;
}

.stat-label {
    display: block;
    color: #00d9ff;
    font-size: 0.8rem;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
}

.game-screen {
    position: relative;
    background: #0a0a0a;
    border: 4px solid #0f3460;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 600px;
    background: #87ceeb;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Canvas touch settings only for mobile and only when playing */
@media (max-width: 768px) {
    body.game-active #game-canvas {
        touch-action: none;
    }
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background: #1a1a2e;
    border-radius: 15px;
    border: 4px solid #00d9ff;
    box-shadow: 0 0 40px rgba(0, 217, 255, 0.5);
    max-width: 500px;
    margin: auto;
}

.overlay-content h2 {
    color: #ffeb3b;
    font-size: 3rem;
    margin-bottom: 20px;
    text-shadow: 3px 3px 0px #0f3460;
    letter-spacing: 3px;
}

.game-info {
    margin: 20px 0;
    text-align: left;
}

.game-info h3 {
    color: #00d9ff;
    font-size: 1.5rem;
    margin-bottom: 15px;
    text-align: center;
}

.game-info h4 {
    color: #ff6b6b;
    font-size: 1.2rem;
    margin: 15px 0 10px 0;
}

.controls, .objectives {
    background: #0f3460;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.controls p, .objectives p {
    color: #fff;
    margin: 8px 0;
    font-size: 1.1rem;
}

.final-score, .level-score, .bonus {
    color: #fff;
    font-size: 1.5rem;
    margin: 15px 0;
}

.final-score span, .level-score span, .bonus span {
    color: #ffeb3b;
    font-weight: bold;
}

/* Buttons */
.btn-start, .btn-restart, .btn-resume, .btn-next {
    padding: 15px 40px;
    font-size: 1.5rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-transform: uppercase;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
}

.btn-start {
    background: linear-gradient(45deg, #4ecdc4, #44a08d);
    color: #fff;
    box-shadow: 0 5px 20px rgba(78, 205, 196, 0.4);
}

.btn-start:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(78, 205, 196, 0.6);
}

.btn-restart {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: #fff;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

.btn-restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.6);
}

.btn-resume {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: #fff;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-resume:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

.btn-next {
    background: linear-gradient(45deg, #ffd700, #ffa500);
    color: #000;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.4);
}

.btn-next:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
}

/* Controls Info */
.controls-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.control-hint {
    color: #fff;
    font-size: 1rem;
}

.key {
    display: inline-block;
    background: #1a1a2e;
    padding: 5px 12px;
    border-radius: 5px;
    border: 2px solid #00d9ff;
    margin-right: 8px;
    font-weight: bold;
    color: #00d9ff;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

/* Virtual Joystick */
.joystick-container {
    position: relative;
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.joystick-base {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(26, 26, 46, 0.8);
    border: 3px solid #00d9ff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
}

.joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #00d9ff, #0099cc);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
    transition: all 0.1s;
    cursor: pointer;
    touch-action: none;
}

.joystick-stick:active {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    box-shadow: 0 0 25px rgba(0, 217, 255, 1);
}

/* Jump Button */
.mobile-btn {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
    background: #1a1a2e;
    border: 3px solid #00d9ff;
    border-radius: 50%;
    color: #00d9ff;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    outline: none;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.3);
}

.mobile-btn:active {
    background: #00d9ff;
    color: #1a1a2e;
    transform: scale(0.9);
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.9);
}

/* Desktop - ensure mobile controls are completely hidden */
@media (min-width: 769px) {
    .mobile-controls {
        display: none !important;
        pointer-events: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-header h1 {
        font-size: 1.8rem;
    }

    .game-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    #game-canvas {
        height: 400px;
    }

    .overlay {
        align-items: flex-start;
        padding: 20px 0;
    }

    .overlay-content {
        padding: 30px 20px;
        margin: 20px;
        max-width: 90%;
    }

    .overlay-content h2 {
        font-size: 2rem;
    }

    .controls-info {
        display: none;
    }

    .mobile-controls {
        display: flex;
    }

    .btn-start, .btn-restart, .btn-resume, .btn-next {
        font-size: 1.2rem;
        padding: 12px 30px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .game-header {
        padding: 10px;
    }

    .game-header h1 {
        font-size: 1.4rem;
        letter-spacing: 1px;
    }

    #game-canvas {
        height: 300px;
    }

    .overlay {
        padding: 10px 0;
    }

    .overlay-content {
        padding: 20px 15px;
        margin: 10px;
        max-width: 95%;
    }

    .overlay-content h2 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .game-info h3 {
        font-size: 1.2rem;
    }

    .controls p, .objectives p {
        font-size: 0.9rem;
    }

    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-stick {
        width: 40px;
        height: 40px;
    }

    .mobile-btn {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .mobile-controls {
        padding: 15px;
        gap: 15px;
    }
}

/* Animations */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.stat-value.blink {
    animation: blink 0.5s ease-in-out 3;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.game-screen.shake {
    animation: shake 0.3s ease-in-out;
}
