* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body { background: #000; color: #fff; font-family: monospace; height: 100vh; overflow: hidden; user-select: none; }

/* Main layout: fixed full screen */
#game-wrapper { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* Game canvas container: 16:9 aspect, centered with margin */
.game-container { position: relative; max-width: min(95vw, calc(95vh * 16 / 9)); width: 100%; aspect-ratio: 16/9; }

/* Canvas styling */
canvas { display: block; width: 100%; height: 100%; background: #000; border: 2px solid #fff; box-sizing: border-box; }

/* CRT filter */
.crt-filter { position: absolute; inset: 0; pointer-events: none; z-index: 50; background: repeating-linear-gradient(0deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 1px, transparent 1px, transparent 2px); box-shadow: inset 0 0 80px rgba(0,0,0,0.3); }

/* Top-left menu button */
.menu-btn { position: absolute; left: 10px; top: 10px; width: 44px; height: 44px; background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); border-radius: 6px; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100; }
.menu-btn:active { transform: scale(0.96); }

/* Menu modal */
.menu-modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 90vw; max-width: 400px; background: rgba(15,15,25,0.98); border: 2px solid rgba(255,255,255,0.6); border-radius: 8px; padding: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.8); z-index: 1001; }
.menu-modal.hidden { display: none; }

.menu-content { }

.menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.menu-header h2 { margin: 0; font-size: 20px; }

.close-btn { background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.close-btn:active { transform: scale(0.9); }

.menu-section { margin-bottom: 20px; }
.menu-section h3 { margin: 0 0 12px 0; font-size: 14px; opacity: 0.8; }

.volume-control { margin-bottom: 15px; }
.volume-control label { display: block; font-size: 12px; margin-bottom: 6px; opacity: 0.8; }

.volume-slider-container { display: flex; gap: 10px; align-items: center; }
.volume-slider { flex: 1; -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.2); outline: none; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; cursor: pointer; }
.volume-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; cursor: pointer; border: none; }

.volume-value { font-size: 12px; min-width: 40px; text-align: right; opacity: 0.8; }

.menu-button { width: 100%; padding: 10px; background: rgba(100, 150, 191, 0.6); border: 2px solid rgba(150, 200, 255, 0.9); border-radius: 4px; color: #fff; font-size: 12px; cursor: pointer; margin-bottom: 10px; }
.menu-button:active { transform: scale(0.96); }

#menu-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; z-index: 1000; }
#menu-backdrop.hidden { display: none; }
#menu-backdrop.visible { display: block; }
/* Top-right leaderboard button (mobile only) */
.leaderboard-btn { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); border-radius: 6px; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100; }
.leaderboard-btn:active { transform: scale(0.96); }
@media (min-width:900px) { .leaderboard-btn { display: none; } }

/* Leaderboard panel (desktop) or modal (mobile) */
#leaderboard { position: absolute; right: 10px; top: 10px; width: 280px; max-height: calc(100% - 20px); overflow-y: auto; font-size: 11px; display: none; z-index: 80; text-align: left; }
@media (min-width:900px) { #leaderboard { display: block; } }
#leaderboard .entry { padding: 3px 4px; border-bottom: 1px solid rgba(255,255,255,0.1); }
#leaderboard .entry.gold { color: #c9ab4b; font-weight: bold; }
#leaderboard .entry.silver { color: #b7b7b7; font-weight: bold; }
#leaderboard .entry.bronze { color: #b07a4a; font-weight: bold; }
#leaderboard .entry.you { background: rgba(255,255,255,0.1); border-radius: 3px; }
#leaderboard .entry .rank { display: inline-block; width: 20px; text-align: right; margin-right: 6px; opacity: 0.7; }
#leaderboard .entry .name { display: inline-block; }
#leaderboard .entry .kills { float: right; }

/* Mobile modal leaderboard */
@media (max-width:899px) {
  #leaderboard { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 90vw; max-width: 400px; display: none; background: rgba(20,20,35,1); border: 2px solid rgba(255,255,255,0.6); border-radius: 8px; padding: 15px; box-shadow: 0 8px 32px rgba(0,0,0,0.8); }
  #leaderboard.modal-open { display: block; z-index: 1001; }
  #leaderboard .entry { color: #fff; }
  #leaderboard .entry.gold { color: #ffeb3b; }
  #leaderboard .entry.silver { color: #e8e8e8; }
  #leaderboard .entry.bronze { color: #ffb74d; }
}

/* Leaderboard backdrop */
#leaderboard-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; z-index: 1000; }
#leaderboard-backdrop.modal-open { display: block; }

/* Game info (bottom-left) */
#game-info { position: absolute; bottom: 10px; left: 10px; font-size: 12px; opacity: 0.6; max-width: 300px; z-index: 80; }
#game-info .room { display: block; margin-bottom: 3px; }
#game-info .player-name { display: block; margin-bottom: 3px; }
#game-info .instructions { font-size: 11px; opacity: 0.5; }

/* Mobile joystick and shoot button */
#mobile-controls { position: fixed; bottom: 20px; left: 20px; display: none; z-index: 60; gap: 20px; align-items: flex-end; }
@media (any-pointer: coarse), (max-width:900px) { #mobile-controls { display: flex; } }

#joystick-container { position: relative; width: 180px; height: 180px; }
#joystick-base { position: absolute; width: 180px; height: 180px; background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4); border-radius: 50%; top: 0; left: 0; }
#joystick-knob { position: absolute; width: 75px; height: 75px; background: rgba(255,255,255,0.5); border: 2px solid rgba(255,255,255,0.9); border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; }

#button-container { display: flex; flex-direction: column; gap: 10px; align-items: center; position: fixed; bottom: 20px; right: 20px; z-index: 60; }

.dash-btn { position: relative; width: 84px; height: 84px; background: rgba(100, 150, 191, 0.6); border: 3px solid rgba(150, 200, 255, 0.9); border-radius: 4px; color: #fff; font-weight: 700; font-size: 11px; cursor: pointer; touch-action: manipulation; }
.dash-btn:active { transform: scale(0.94); }
.dash-btn::before { content: ''; position: absolute; inset: 0; border-radius: 1px; border: 3px solid transparent; pointer-events: none; border-top-color: rgba(150, 200, 255, 0.9); border-right-color: rgba(150, 200, 255, 0.9); border-bottom-color: rgba(150, 200, 255, 0.9); border-left-color: rgba(150, 200, 255, 0.9); }

#mobile-controls .shoot-btn { width: 120px; height: 120px; background: rgba(191,111,111,0.6); border: 3px solid rgba(255,150,150,0.9); border-radius: 4px; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; touch-action: manipulation; }
#mobile-controls .shoot-btn:active { transform: scale(0.94); }

#fullscreen-warning { position: fixed; bottom: 50%; left: 50%; transform: translate(-50%, 50%); color: rgba(255,255,255,0.6); font-size: 14px; text-align: center; pointer-events: none; z-index: 50; }
#fullscreen-warning.hidden { display: none; }

/* Rotate to landscape prompt */
#rotate-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.95); opacity: 0; pointer-events: none; transition: opacity 200ms; z-index: 9999; text-align: center; }
#rotate-overlay.visible { opacity: 1; pointer-events: auto; }
#rotate-overlay .rotate-content { max-width: 400px; }
#rotate-overlay .rotate-icon { font-size: 48px; margin-bottom: 12px; }
#rotate-overlay .rotate-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
#rotate-overlay .rotate-text { font-size: 14px; color: #ddd; }
