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

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #000000;
    color: #ecf0f1;
    font-family: 'VT323', monospace, 'Courier New', sans-serif;
    touch-action: none;
}

#root {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #000000;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: relative;
    background: #000000;
}

/* --- VIEWPORT & CANVAS (BORDERLESS FULLSCREEN) --- */
.game-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #000000;
}

#game-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #000000;
}

#game-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: none;
}

/* --- MOBILE HUD & ON-SCREEN CONTROLS OVERLAY --- */
.mobile-hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    padding: max(10px, env(safe-area-inset-top, 10px)) max(12px, env(safe-area-inset-right, 12px)) max(14px, env(safe-area-inset-bottom, 14px)) max(12px, env(safe-area-inset-left, 12px));
}

/* Top Subtle Floating Utilities */
.top-hud-bar {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none;
}

.hud-icon-btn {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #ecf0f1;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    touch-action: manipulation;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.hud-icon-btn:hover {
    background: rgba(0, 255, 255, 0.25);
    border-color: rgba(0, 255, 255, 0.6);
}

.hud-icon-btn:active {
    background: rgba(0, 255, 255, 0.4);
    transform: scale(0.92);
}

/* Bottom Controls Section */
.bottom-hud-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    pointer-events: none;
}

/* --- SEMI-TRANSPARENT VIRTUAL JOYSTICK --- */
.joystick-base {
    position: relative;
    width: 124px;
    height: 124px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, rgba(0, 255, 255, 0.04) 65%, rgba(0, 255, 255, 0.18) 100%);
    border: 2px solid rgba(0, 255, 255, 0.35);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.15), inset 0 0 15px rgba(0, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.joystick-base.active {
    border-color: rgba(0, 255, 255, 0.7);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.35), inset 0 0 20px rgba(0, 255, 255, 0.2);
}

.joy-dir {
    position: absolute;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    font-family: monospace;
    pointer-events: none;
}
.dir-up { top: 6px; }
.dir-down { bottom: 6px; }
.dir-left { left: 8px; }
.dir-right { right: 8px; }

.joystick-knob {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.65) 0%, rgba(0, 180, 220, 0.4) 70%, rgba(0, 100, 150, 0.3) 100%);
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 14px rgba(0, 255, 255, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    will-change: transform;
}

/* --- SEMI-TRANSPARENT ACTION BUTTONS --- */
.action-buttons-group {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    pointer-events: none;
}

.hud-action-btn {
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.08s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bomb-hud-btn {
    width: 52px;
    height: 52px;
    background: radial-gradient(circle, rgba(243, 156, 18, 0.5) 0%, rgba(211, 84, 0, 0.3) 80%, rgba(160, 60, 0, 0.2) 100%);
    border: 2px solid rgba(255, 200, 80, 0.7);
    box-shadow: 0 0 12px rgba(243, 156, 18, 0.4);
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    margin-bottom: 6px;
}

.bomb-hud-btn .btn-icon {
    font-size: 14px;
    margin-bottom: 1px;
}

.bomb-hud-btn .btn-text {
    font-size: 7px;
    font-weight: bold;
}

.bomb-hud-btn:active {
    transform: scale(0.92);
    background: radial-gradient(circle, rgba(255, 180, 30, 0.8) 0%, rgba(243, 156, 18, 0.6) 80%);
}

.fire-hud-btn {
    width: 72px;
    height: 72px;
    background: radial-gradient(circle, rgba(231, 76, 60, 0.55) 0%, rgba(192, 57, 43, 0.35) 80%, rgba(150, 30, 20, 0.2) 100%);
    border: 2px solid rgba(255, 120, 120, 0.75);
    box-shadow: 0 0 16px rgba(231, 76, 60, 0.45);
    color: #fff;
    font-family: 'Press Start 2P', monospace;
}

.fire-hud-btn .btn-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.fire-hud-btn .btn-text {
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.fire-hud-btn.pressed, .fire-hud-btn:active {
    transform: scale(0.92);
    background: radial-gradient(circle, rgba(255, 80, 60, 0.8) 0%, rgba(231, 76, 60, 0.6) 80%);
    box-shadow: 0 0 24px rgba(255, 80, 60, 0.8);
}

/* --- MODALS --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 12px;
}

.modal-card {
    background: #1a1e2d;
    border: 2px solid #00ffff;
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 16px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #2c3e50;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: #f1c40f;
}

.close-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}

.modal-body {
    font-size: 15px;
    line-height: 1.4;
    color: #cbd5e0;
}

.lore-text {
    background: #0f131f;
    border-left: 3px solid #f1c40f;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 13px;
}

.modal-body h3 {
    color: #00ffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    margin: 10px 0 6px 0;
}

.modal-body ul {
    margin-left: 18px;
    margin-bottom: 10px;
}

.controls-table, .leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.controls-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #2d3748;
}

.leaderboard-table th {
    background: #2d3748;
    color: #f1c40f;
    padding: 6px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-align: left;
}

.leaderboard-table td {
    padding: 6px;
    border-bottom: 1px solid #2d3748;
    font-size: 13px;
}

.leaderboard-table tr.gold { color: #f1c40f; }
.leaderboard-table tr.silver { color: #bdc3c7; }
.leaderboard-table tr.bronze { color: #e67e22; }

.score-val {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #00ffff;
}

.mode-tag {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    background: #334155;
}
.mode-tag.classic { background: #1e3a8a; }
.mode-tag.enhanced { background: #7c2d12; }
.mode-tag.night { background: #14532d; }

.modal-footer {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.primary-btn {
    background: #27ae60;
    color: #fff;
    border: 2px solid #2ecc71;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}