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

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

body {
    background-color: #1a3520;
    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: 11px;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#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;
}

/* ---- BOTTOM NAVIGATION ---- */
#bottom-nav {
    width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-top: 4px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #ffcc00;
    border-radius: 6px;
}

#gem-display {
    display: flex;
    gap: 8px;
    align-items: center;
}

.gem-slot {
    width: 28px;
    height: 28px;
    background: #333;
    border: 2px solid #666;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    color: #fff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    transition: background 0.3s, box-shadow 0.3s;
}

#restart-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #fff;
    background: #882222;
    border: 2px solid #ffcc00;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #000;
    transition: background 0.2s;
}

#restart-btn:hover {
    background: #cc3333;
}

#fullscreen-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #fff;
    background: #225588;
    border: 2px solid #ffcc00;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #000;
    transition: background 0.2s;
}

#fullscreen-btn:hover {
    background: #3377aa;
}

/* Fullscreen mode */
body.fullscreen-mode #hud,
body.fullscreen-mode #message,
body.fullscreen-mode #bottom-nav {
    display: none !important;
}

body.fullscreen-mode #game-canvas {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

#minimap-container {
    position: fixed;
    top: 10px;
    right: 10px;
    border: 3px solid #ffcc00;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
}

#minimap {
    display: block;
    image-rendering: pixelated;
}

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

#ctrl-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ctrl-mid-row {
    display: flex;
    gap: 4px;
}

#ctrl-action {
    display: flex;
    align-items: center;
}

.ctrl-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #fff;
    background: rgba(40, 80, 50, 0.9);
    border: 3px solid #ffcc00;
    border-radius: 12px;
    width: 56px;
    height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    box-shadow: 0 3px 0 #886600, 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 #886600;
    transform: translateY(2px);
}

.ctrl-action-btn {
    width: 80px;
    font-size: 10px;
}

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

    #hud,
    #message {
        display: none !important;
    }

    #bottom-nav {
        display: none !important;
    }

    #minimap-container {
        top: 4px;
        right: 4px;
    }

    #minimap {
        width: 100px;
        height: 100px;
    }

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

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

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