@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
    background-color: #2040b0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    color: #fff;
}

#game-canvas {
    border: 4px solid #ffcc00;
    background: #000;
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    image-rendering: pixelated;
    border-radius: 4px;
}

#hud {
    width: 800px;
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    font-size: 12px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#hud-level {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

#hud-level:hover {
    color: #ffcc00;
}

#level-select-menu {
    position: fixed;
    background: #222;
    border: 2px solid #ffcc00;
    border-radius: 6px;
    padding: 4px 0;
    z-index: 9999;
    min-width: 130px;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6);
}

#level-select-menu .lvl-option {
    display: block;
    width: 100%;
    padding: 6px 14px;
    color: #fff;
    background: none;
    border: none;
    text-align: left;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
}

#level-select-menu .lvl-option:hover {
    background: #ffcc00;
    color: #222;
}

#message {
    font-size: 12px;
    color: #ffcc00;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
    text-shadow: 2px 2px 0 #000;
    min-height: 20px;
    text-align: center;
}

#difficulty-selector {
    width: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 10px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#difficulty-selector label {
    font-size: 10px;
}

#difficulty {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    background: #1a3080;
    color: #ffcc00;
    border: 2px solid #ffcc00;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
    border-radius: 4px;
}

#difficulty:focus {
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

#difficulty option {
    background: #1a3080;
    color: #ffcc00;
}

#leaderboard-panel {
    width: 800px;
    margin-top: 10px;
    border: 2px solid #ffcc00;
    background: rgba(20, 40, 100, 0.9);
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 6px;
}

#leaderboard-panel h3 {
    font-size: 10px;
    color: #ffcc00;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 2px 2px 0 #000;
}

#leaderboard-list {
    font-size: 9px;
    color: #fff;
    line-height: 1.8;
}

#desktop-leaderboard-list {
    font-size: 9px;
    color: #fff;
    line-height: 1.8;
}

.lb-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 4px;
}

.lb-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.08);
}

.lb-rank {
    color: #ffcc00;
    width: 30px;
}

.lb-name {
    flex: 1;
    color: #fff;
}

.lb-score {
    color: #fff;
    width: 80px;
    text-align: right;
}

.lb-you {
    color: #ff6644 !important;
}

#leaderboard-status,
#desktop-leaderboard-status {
    font-size: 8px;
    color: #aac;
    text-align: center;
    margin-top: 6px;
}

/* ---- MOBILE MENU (hidden on desktop) ---- */
#mobile-menu-btn,
#mobile-menu-overlay,
#mobile-menu {
    display: none;
}

#mobile-menu-btn {
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 200;
    font-size: 24px;
    color: #ffcc00;
    background: rgba(20, 40, 100, 0.9);
    border: 2px solid #ffcc00;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Press Start 2P', monospace;
    line-height: 1;
}

#mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
}

#mobile-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 270px;
    height: 100%;
    background: #1a3080;
    border-left: 3px solid #ffcc00;
    z-index: 400;
    padding: 16px;
    overflow-y: auto;
    transition: right 0.25s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

#mobile-menu.open {
    right: 0;
}

#mobile-menu-close {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 24px;
    color: #ffcc00;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    -webkit-tap-highlight-color: transparent;
}

#menu-hud {
    margin-top: 40px;
    font-size: 11px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    line-height: 2.2;
}

#menu-difficulty {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 10px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#menu-difficulty select {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    background: #1a3080;
    color: #ffcc00;
    border: 2px solid #ffcc00;
    padding: 6px 8px;
    cursor: pointer;
    outline: none;
    border-radius: 4px;
}

#menu-difficulty select option {
    background: #1a3080;
    color: #ffcc00;
}

#menu-leaderboard {
    margin-top: 20px;
    border: 2px solid #ffcc00;
    background: rgba(20, 40, 100, 0.8);
    padding: 10px;
    max-height: 240px;
    overflow-y: auto;
    border-radius: 6px;
}

#menu-leaderboard h3 {
    font-size: 10px;
    color: #ffcc00;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 2px 2px 0 #000;
}

/* ---- MOBILE CONTROLS ---- */
#mobile-controls {
    display: none;
    width: 100%;
    max-width: 800px;
    padding: 10px 16px;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(20, 40, 100, 0.92);
    border-top: 3px solid #ffcc00;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

#ctrl-left {
    display: flex;
    gap: 10px;
}

#ctrl-right {
    display: flex;
}

.ctrl-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: #fff;
    background: rgba(40, 70, 160, 0.9);
    border: 3px solid #ffcc00;
    border-radius: 12px;
    width: 64px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    box-shadow: 0 3px 0 #b08800, 0 4px 8px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ctrl-btn:active,
.ctrl-btn.active {
    background: rgba(255, 204, 0, 0.4);
    box-shadow: 0 1px 0 #b08800;
    transform: translateY(2px);
}

.ctrl-jump {
    width: 90px;
    font-size: 12px;
}

@media (pointer: coarse),
(max-width: 850px) {
    #mobile-controls {
        display: flex;
    }

    #mobile-menu-btn {
        display: block;
    }

    /* Hide desktop-only elements */
    #hud,
    #difficulty-selector,
    #message,
    #leaderboard-panel {
        display: none !important;
    }

    body {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        justify-content: center;
        padding: 0;
    }

    #game-canvas {
        width: 100vw;
        height: calc(100dvh - 84px);
        max-width: none;
        border: none;
        box-shadow: none;
        display: block;
        margin: 0 auto;
    }

    #mobile-controls {
        max-width: none;
        height: 84px;
    }
}

#name-prompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a3080;
    border: 3px solid #ffcc00;
    padding: 20px 30px;
    text-align: center;
    z-index: 10000;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

#name-prompt p {
    font-size: 10px;
    color: #fff;
    margin-bottom: 12px;
}

#player-name-input {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    background: #0f2060;
    color: #ffcc00;
    border: 2px solid #ffcc00;
    padding: 8px 12px;
    text-align: center;
    text-transform: uppercase;
    width: 180px;
    outline: none;
    border-radius: 4px;
}

#player-name-input:focus {
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

#name-submit-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: #cc3300;
    color: #fff;
    border: 2px solid #ffcc00;
    padding: 8px 16px;
    margin-left: 8px;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 3px 0 #882200;
}

#name-submit-btn:hover {
    background: #ff4400;
    color: #fff;
}