* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 10px;
    background-color: #050508;
    color: #fff;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    max-width: 900px;
    margin: auto;
    position: relative;
}

#game-container {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 180px);
    aspect-ratio: 16 / 9;
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.15), 0 0 100px rgba(0, 255, 204, 0.05);
    border: 2px solid rgba(0, 255, 204, 0.5);
    border-radius: 12px;
    overflow: hidden;
    background: #0d0e15;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    padding: 20px 30px;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.8);
    color: #00ffcc;
    letter-spacing: 1px;
}

.time-rate-box {
    color: #ff0055;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.8);
    font-variant-numeric: tabular-nums;
}

.high-score-box {
    color: #b500ff;
    text-shadow: 0 0 10px rgba(181, 0, 255, 0.8);
}

#game-over-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 14, 21, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
    opacity: 1;
}

#game-over-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

#game-over-modal h2 {
    font-size: 3.5rem;
    color: #ff0055;
    text-shadow: 0 0 20px rgba(255, 0, 85, 0.8), 0 0 40px rgba(255, 0, 85, 0.4);
    margin: 0 0 15px 0;
    letter-spacing: 4px;
}

#game-over-modal p {
    font-size: 1.8rem;
    color: #00ffcc;
    margin: 0 0 40px 0;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

#restart-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: 800;
    color: #0d0e15;
    background: linear-gradient(135deg, #00ffcc, #00ccaa);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    letter-spacing: 2px;
}

#restart-btn:hover {
    background: linear-gradient(135deg, #fff, #00ffcc);
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.8);
    transform: scale(1.05) translateY(-2px);
}

#restart-btn:active {
    transform: scale(0.95);
}

/* --- Mobile Virtual Controls --- */
#mobile-controls {
    display: none; /* Hidden by default on desktop */
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

body.touch-device #mobile-controls {
    display: flex;
}

.movement-controls, .action-controls {
    display: flex;
    gap: 12px;
}

/* Landscape overlay for mobile screens to maximize game viewport size */
@media (max-height: 500px) and (orientation: landscape) {
    #mobile-controls {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        padding: 0 40px;
        pointer-events: none;
        z-index: 20;
    }
    
    .movement-controls, .action-controls {
        pointer-events: auto;
    }
    
    #game-container {
        max-height: 80vh;
    }
}

.ctrl-btn {
    width: 60px;
    height: 60px;
    background: rgba(13, 14, 21, 0.65);
    border: 2px solid rgba(0, 255, 204, 0.45);
    border-radius: 50%;
    color: #00ffcc;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.6);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.2);
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

.ctrl-btn:active {
    background: rgba(0, 255, 204, 0.25);
    border-color: #00ffcc;
    box-shadow: 0 0 25px rgba(0, 255, 204, 0.7);
    transform: scale(0.92);
}

.jump-btn {
    width: 85px;
    height: 60px;
    border-radius: 30px;
    background: rgba(255, 0, 85, 0.25);
    border-color: rgba(255, 0, 85, 0.5);
    color: #ff0055;
    text-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.2);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.jump-btn:active {
    background: rgba(255, 0, 85, 0.4);
    border-color: #ff0055;
    box-shadow: 0 0 25px rgba(255, 0, 85, 0.7);
}

/* --- Instructions Hint --- */
.instructions-hint {
    text-align: center;
    color: #8892b0;
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 600px;
    padding: 0 20px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.instructions-hint strong {
    color: #00ffcc;
}

.mobile-only {
    display: none;
}

.desktop-only {
    display: inline;
}

body.touch-device .desktop-only {
    display: none;
}

body.touch-device .mobile-only {
    display: inline;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    body {
        padding: 5px;
    }
    
    .game-wrapper {
        gap: 10px;
    }
    
    .top-bar {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    #game-over-modal h2 {
        font-size: 2.2rem;
    }
    
    #game-over-modal p {
        font-size: 1.2rem;
        margin: 0 0 25px 0;
    }
    
    #restart-btn {
        padding: 10px 25px;
        font-size: 1rem;
    }
    
    .ctrl-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .jump-btn {
        width: 70px;
        height: 50px;
        font-size: 0.85rem;
    }
    
    #mobile-controls {
        padding: 10px;
    }
}
