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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Press Start 2P', 'Courier New', monospace !important;
}

html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

/* Arcade scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #0d0d0d;
  border-left: 1px solid #1a1a1a;
  border-right: 1px solid #1a1a1a;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3a3a1a 0%, #2a2a10 50%, #3a3a1a 100%);
  border: 2px solid #f0c040;
  border-radius: 6px;
  box-shadow: inset 0 0 4px rgba(240, 192, 64, 0.3);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4a4a2a 0%, #3a3a1a 50%, #4a4a2a 100%);
  border-color: #ffd966;
  box-shadow: inset 0 0 6px rgba(240, 192, 64, 0.5);
}

::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #5a5a2a 0%, #4a4a1a 50%, #5a5a2a 100%);
  border-color: #ffe080;
}

::-webkit-scrollbar-corner {
  background: #0d0d0d;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #3a3a1a #0d0d0d;
}

body {
  overflow: hidden;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  background: #cdcdcd;
}

/* Canvas */
#gameCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
}

/* Overlay screens */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

/* Menu */
.menu-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 40px 60px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Death Screen - Arcade Style */
.death-content {
  background: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);
  padding: 40px 50px;
  border-radius: 16px;
  text-align: center;
  border: 3px solid #ff4444;
  box-shadow: 
    0 0 30px rgba(255, 68, 68, 0.3),
    0 10px 40px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  min-width: 320px;
}

.death-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 14px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
  pointer-events: none;
}

.title {
  font-size: 48px;
  color: #00b2e1;
  text-shadow: 3px 3px 0 #0085a8;
  margin-bottom: 30px;
  letter-spacing: 2px;
}

#nameInput {
  width: 300px;
  padding: 15px 20px;
  font-size: 18px;
  border: 3px solid #00b2e1;
  border-radius: 5px;
  outline: none;
  margin-bottom: 20px;
  text-align: center;
}

#nameInput:focus {
  border-color: #0085a8;
}

.play-button {
  width: 300px;
  padding: 15px 40px;
  font-size: 24px;
  background: #00b2e1;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: bold;
}

.play-button:hover {
  background: #0085a8;
}

.mode-label {
  margin-top: 20px;
  color: #666;
  font-size: 14px;
}

/* Death screen - Arcade styled text */
.death-content h2 {
  color: #888;
  margin-bottom: 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.killer-name {
  font-size: 18px;
  color: #ff4444;
  margin-bottom: 20px;
  text-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
  font-family: 'Press Start 2P', monospace;
  letter-spacing: 1px;
}

.killer-preview {
  background: linear-gradient(180deg, #3a1a1a 0%, #2a0d0d 100%);
  padding: 20px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
  border: 2px solid #ff4444;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.killer-preview canvas {
  margin-bottom: 8px;
}

.killer-preview span {
  color: #ff8888;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#deathStats {
  margin: 20px 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-align: left;
  color: #fff;
}

#deathStats p {
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border-left: 3px solid #00ffff;
  line-height: 1.6;
}

#deathStats span {
  color: #00ffff;
}

.respawn-bonus-button,
#returnToDashboardBtn {
  width: 100%;
  padding: 14px 24px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #00d4ff 0%, #00b2e1 50%, #0099cc 100%);
  color: #000;
  border: 3px solid #007799;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: 
    0 4px 0 #007799,
    0 6px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.15s;
}

.respawn-bonus-button:hover,
#returnToDashboardBtn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 0 #007799,
    0 8px 25px rgba(0, 180, 225, 0.4);
}

.respawn-bonus-button:active,
#returnToDashboardBtn:active {
  transform: translateY(2px);
  box-shadow: 
    0 2px 0 #007799,
    0 4px 15px rgba(0, 0, 0, 0.3);
}

/* HUD */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#hud.hidden {
  display: none;
}

#hud > * {
  pointer-events: auto;
}

/* Player Info */
#playerInfo {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#cashoutHint {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4), 0 0 20px rgba(255, 215, 0, 0.15);
  letter-spacing: 2px;
  white-space: nowrap;
  opacity: 0.7;
  pointer-events: none;
  animation: cashout-blink 3s ease-in-out infinite;
}

@keyframes cashout-blink {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

#nameDisplay {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: #333;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
  margin-bottom: 8px;
}

#scoreBar {
  width: 350px;
  height: 22px;
  background: #444;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  margin-bottom: 3px;
  border: 2px solid #333;
}

#scoreProgress {
  height: 100%;
  background: linear-gradient(90deg, #43a83e, #5fc955);
  width: 0%;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 5px rgba(95, 201, 85, 0.5);
}

#scoreText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

#levelBar {
  width: 350px;
  height: 22px;
  background: #c7a832;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

#levelProgress {
  height: 100%;
  background: #e0c040;
  width: 0%;
  transition: width 0.3s;
}

#levelText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
}

/* Game Chat */
#gameChat {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  padding: 8px;
  pointer-events: none;
}

#gameChatMessages {
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: none;
  pointer-events: none;
}

#gameChatMessages::-webkit-scrollbar {
  display: none;
}

.chat-entry {
  padding: 4px 8px;
  font-size: 10px;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  animation: chatAppear 0.2s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-entry.chat-fade {
  opacity: 0;
  transition: opacity 2s ease;
}

.chat-name {
  color: #4ade80;
  font-weight: bold;
}

.chat-msg {
  color: #e0e0e0;
}

#gameChatInputRow {
  display: flex;
  margin-top: 6px;
  pointer-events: auto;
}

#gameChatInputRow.hidden {
  display: none;
}

#gameChatInput {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: #fff;
  font-size: 10px;
  font-family: 'Press Start 2P', 'Courier New', monospace !important;
  outline: none;
  pointer-events: auto;
}

#gameChatInput:focus {
  border-color: #4ade80;
}

#gameChatHint {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.4);
  padding: 4px 8px;
  pointer-events: none;
}

@keyframes chatAppear {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stats Panel */
#statsPanel {
  position: absolute;
  left: 20px;
  bottom: 20px;
  background: rgba(0, 0, 0, 0.6);
  padding: 15px;
  border-radius: 5px;
}

.stat-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}

.stat-name {
  color: white;
  font-size: 9px;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-weight: 400;
  width: 150px;
  min-width: 150px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.stat-bar {
  width: 120px;
  height: 14px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

/* Visual segments for 10 levels */
.stat-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 11px,
    rgba(0,0,0,0.3) 11px,
    rgba(0,0,0,0.3) 12px
  );
  pointer-events: none;
}

.stat-fill {
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}

/* Rainbow color scheme for stats (matching diep.io) */
.stat-row[data-stat="0"] .stat-fill { background: #00b2e1; } /* Health Regen - Cyan */
.stat-row[data-stat="1"] .stat-fill { background: #00e16c; } /* Max Health - Green */
.stat-row[data-stat="2"] .stat-fill { background: #8aab00; } /* Body Damage - Olive */
.stat-row[data-stat="3"] .stat-fill { background: #e6c500; } /* Bullet Speed - Yellow */
.stat-row[data-stat="4"] .stat-fill { background: #f57d25; } /* Bullet Penetration - Orange */
.stat-row[data-stat="5"] .stat-fill { background: #e85050; } /* Bullet Damage - Red */
.stat-row[data-stat="6"] .stat-fill { background: #c050a0; } /* Reload - Pink */
.stat-row[data-stat="7"] .stat-fill { background: #7850c0; } /* Movement Speed - Purple */

.stat-btn {
  width: 26px;
  height: 26px;
  background: linear-gradient(180deg, #66ff66 0%, #4CAF50 50%, #388E3C 100%);
  color: #000;
  border: 2px solid #2E7D32;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 400;
  font-size: 12px;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  opacity: 0.3;
  pointer-events: none;
  transition: all 0.15s ease;
  box-shadow: 
    0 3px 0 #1B5E20,
    0 0 6px rgba(76, 175, 80, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.stat-btn.active {
  opacity: 1;
  pointer-events: auto;
}

.stat-btn.active:hover {
  background: linear-gradient(180deg, #88ff88 0%, #66ff66 50%, #4CAF50 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 5px 0 #1B5E20,
    0 0 12px rgba(76, 175, 80, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.stat-btn.active:active {
  transform: translateY(2px);
  box-shadow: 
    0 1px 0 #1B5E20,
    0 0 4px rgba(76, 175, 80, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#skillPoints {
  color: #4CAF50;
  font-size: 9px;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-weight: 400;
  margin-top: 12px;
  text-align: center;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

#skillPoints.has-points {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
  animation: skillBlink 0.8s ease-in-out infinite;
}

@keyframes skillBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Skill Point +1 notification in center of screen */
#skillPointNotif {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 18px;
  color: #ffd700;
  text-shadow: 
    0 0 10px rgba(255, 215, 0, 0.8),
    0 0 20px rgba(255, 215, 0, 0.4);
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: none;
}

#skillPointNotif.show {
  opacity: 1;
  animation: skillNotifBlink 0.5s ease-in-out 4;
}

@keyframes skillNotifBlink {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.3; transform: translate(-50%, -50%) scale(1.1); }
}

/* Upgrade Panel */
#upgradePanel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  z-index: 60;
}

#upgradePanel.hidden {
  display: none;
}

.upgrade-options {
  display: flex;
  gap: 20px;
}

.upgrade-option {
  width: 100px;
  height: 100px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  border: 3px solid rgba(0, 0, 0, 0.3);
  pointer-events: auto !important;
  z-index: 100;
}

/* Tank upgrade background colors (matching diep.io) */
.upgrade-option:nth-child(1) { background: #85d2f0; } /* Cyan - Twin */
.upgrade-option:nth-child(2) { background: #85e085; } /* Green - Sniper */
.upgrade-option:nth-child(3) { background: #f08585; } /* Pink - Machine Gun */
.upgrade-option:nth-child(4) { background: #f0e085; } /* Yellow - Flank Guard */
.upgrade-option:nth-child(5) { background: #8585f0; } /* Blue - 5th option */

.upgrade-option:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}

.upgrade-option canvas {
  width: 60px;
  height: 60px;
  pointer-events: none;
}

.upgrade-option span {
  color: white;
  font-size: 11px;
  margin-top: 5px;
  pointer-events: none;
}

/* Leaderboard - Retro Arcade Style (Gold Theme) */
#leaderboard {
  position: absolute;
  right: 20px;
  top: 20px;
  background: linear-gradient(180deg, #0a0a0a 0%, #050505 100%);
  padding: 16px 14px;
  border-radius: 4px;
  width: 240px;
  box-sizing: border-box;
  border: 2px solid #ffd700;
  border-bottom: 3px solid #a08000;
  border-right: 3px solid #a08000;
  box-shadow: 
    0 0 15px rgba(255, 215, 0, 0.2),
    0 0 40px rgba(255, 215, 0, 0.05),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  image-rendering: pixelated;
}

#leaderboard h3 {
  color: #ffd700;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  font-weight: 400;
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.2);
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

#leaderboardList {
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  overflow: visible;
  gap: 6px;
  box-sizing: border-box;
  width: 100%;
  border-radius: 2px;
}

.leaderboard-entry:first-child {
  border-left-color: #ffd700;
  background: rgba(255, 215, 0, 0.06);
}

.leaderboard-entry:nth-child(2) {
  border-left-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.04);
}

.leaderboard-entry:nth-child(3) {
  border-left-color: #cd7f32;
  background: rgba(205, 127, 50, 0.04);
}

.leaderboard-entry.self {
  border-left-color: #ffd700;
  border-left-width: 4px;
  background: rgba(255, 215, 0, 0.08);
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: #ddd;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.15);
}

.leaderboard-score {
  font-weight: 400;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  flex-shrink: 0;
  text-align: right;
  min-width: 40px;
  color: #4ade80;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.leaderboard-score.wager-free {
  color: #666;
  text-shadow: none;
}

.leaderboard-score.wager-low {
  color: #4ade80;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

.leaderboard-score.wager-medium {
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.leaderboard-score.wager-high {
  color: #f97316;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 10px rgba(249, 115, 22, 0.6); }
  50% { text-shadow: 0 0 18px rgba(249, 115, 22, 1); }
}

/* Minimap */
#minimap {
  position: absolute;
  right: 20px;
  bottom: 20px;
  background: rgba(200, 200, 200, 0.8);
  border: 2px solid #666;
  border-radius: 5px;
  overflow: hidden;
}

#minimapCanvas {
  display: block;
}

/* Exit Game Button */
.exit-game-btn {
  position: fixed !important;
  top: 20px !important;
  left: 20px !important;
  background: linear-gradient(180deg, #ff6666 0%, #ef4444 50%, #dc2626 100%);
  border: 3px solid #991b1b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 
    0 4px 0 #991b1b,
    0 6px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.15s;
  z-index: 99999 !important;
  pointer-events: auto !important;
}

.exit-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 6px 0 #991b1b,
    0 8px 25px rgba(0, 0, 0, 0.4);
}

.exit-game-btn:active {
  transform: translateY(2px);
  box-shadow: 
    0 2px 0 #991b1b,
    0 4px 15px rgba(0, 0, 0, 0.3);
}

.exit-game-btn.hidden {
  display: none !important;
}

/* Game notifications */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

.game-notification {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* ===== LOBBY INVITE TOAST ===== */
.lobby-invite-toast .invite-toast-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-invite-toast .invite-toast-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 10px;
}

.lobby-invite-toast .invite-toast-text strong {
  color: #4ade80;
}

.lobby-invite-toast .invite-toast-details {
  font-size: 12px;
  color: #aaa;
}

.lobby-invite-toast .invite-toast-actions {
  display: flex;
  gap: 8px;
}

.lobby-invite-toast .invite-accept-btn {
  flex: 1;
  padding: 8px 16px;
  background: #4ade80;
  border: none;
  border-radius: 6px;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.lobby-invite-toast .invite-accept-btn:hover {
  background: #22c55e;
}

.lobby-invite-toast .invite-decline-btn {
  padding: 8px 12px;
  background: #333;
  border: none;
  border-radius: 6px;
  color: #888;
  font-size: 14px;
  cursor: pointer;
}

.lobby-invite-toast .invite-decline-btn:hover {
  background: #444;
  color: #fff;
}

/* ===== MOBILE RESPONSIVE STYLES FOR GAME UI ===== */

@media (max-width: 768px) {
  /* In-game leaderboard */
  #leaderboard {
    width: 180px;
    min-width: 180px;
    padding: 12px;
    top: 10px;
    right: 10px;
  }
  
  #leaderboard h3 {
    font-size: 12px;
    margin-bottom: 10px;
  }
  
  #leaderboardList {
    font-size: 11px;
  }
  
  .leaderboard-entry {
    padding: 6px 8px;
    margin-bottom: 4px;
  }
  
  /* Stats panel */
  #statsPanel {
    left: 10px;
    bottom: 10px;
    padding: 10px;
    width: auto;
    min-width: 160px;
  }
  
  .stat-row {
    font-size: 10px;
    margin-bottom: 6px;
  }
  
  .stat-name {
    font-size: 7px;
  }
  
  /* Minimap */
  #minimap {
    right: 10px;
    bottom: 10px;
  }
  
  #minimapCanvas {
    width: 100px;
    height: 100px;
  }
  
  /* Player info */
  #playerInfo {
    font-size: 12px;
  }
  
  #scoreBar, #xpBar {
    height: 16px;
  }
  
  /* Death screen */
  .death-content {
    padding: 20px;
    width: 90%;
    max-width: 350px;
  }
  
  .death-content h2 {
    font-size: 14px;
  }
  
  .killer-name {
    font-size: 24px;
  }
  
  #deathStats {
    font-size: 13px;
  }
  
  #returnToDashboardBtn {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  /* Exit button */
  .exit-game-btn {
    padding: 10px 16px;
    font-size: 12px;
    top: 10px !important;
    left: 10px !important;
  }
  
  /* Upgrade panel */
  #upgradePanel {
    width: 90%;
    max-width: 300px;
  }
  
  .upgrade-options {
    gap: 6px;
  }
  
  .upgrade-btn {
    padding: 8px 10px;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  #leaderboard {
    width: 150px;
    min-width: 150px;
    padding: 10px;
  }
  
  #leaderboard h3 {
    font-size: 10px;
  }
  
  #leaderboardList {
    font-size: 10px;
  }
  
  .leaderboard-entry {
    padding: 5px 6px;
  }
  
  #statsPanel {
    min-width: 140px;
    padding: 8px;
  }
  
  #minimapCanvas {
    width: 80px;
    height: 80px;
  }
  
  .death-content {
    padding: 16px;
  }
  
  .killer-name {
    font-size: 20px;
  }
}

/* Touch controls hint for mobile */
@media (pointer: coarse) {
  /* Make buttons more touch-friendly */
  .upgrade-btn,
  #returnToDashboardBtn,
  .exit-game-btn {
    min-height: 44px;
  }
  
  .stat-upgrade-btn {
    min-width: 32px;
    min-height: 32px;
  }
}

/* Landscape mobile - optimize for gameplay */
@media (max-height: 500px) and (orientation: landscape) {
  #statsPanel {
    transform: scale(0.8);
    transform-origin: bottom left;
  }
  
  #leaderboard {
    transform: scale(0.85);
    transform-origin: top right;
  }
  
  #minimap {
    transform: scale(0.8);
    transform-origin: bottom right;
  }
  
  #playerInfo {
    transform: scale(0.9);
    transform-origin: bottom center;
  }
}

/* ===== MOBILE TOUCH CONTROLS ===== */
#mobileControls {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}

#mobileControls.hidden {
  display: none;
}

/* Fullscreen button for mobile */
.mobile-fullscreen-btn {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 11px;
  padding: 14px 28px;
  background: linear-gradient(180deg, #ffdd66 0%, #f0c040 50%, #d4a800 100%);
  border: 3px solid #a08000;
  border-radius: 10px;
  color: #000;
  cursor: pointer;
  box-shadow: 
    0 4px 0 #806000,
    0 0 15px rgba(240, 192, 64, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  letter-spacing: 1px;
}

.mobile-fullscreen-btn:active {
  transform: translateX(-50%) translateY(3px);
  box-shadow: 
    0 1px 0 #806000,
    0 0 8px rgba(240, 192, 64, 0.3);
}

.mobile-fullscreen-btn.hidden {
  display: none;
}

/* Hide fullscreen button on desktop */
@media (pointer: fine) {
  .mobile-fullscreen-btn {
    display: none !important;
  }
}

#joystickArea, #aimJoystickArea {
  position: fixed;
  width: 100px;
  height: 100px;
  pointer-events: none;
  z-index: 9999;
}

#joystickArea {
  bottom: 30px;
  left: 20px;
}

#aimJoystickArea {
  bottom: 30px;
  right: 20px;
}

#joystickBase {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.4;
}

#joystickThumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.7);
  position: absolute;
  pointer-events: none;
}

#aimJoystickBase {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 50, 50, 0.1);
  border: 3px solid rgba(255, 80, 80, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.4;
}

#aimJoystickThumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 80, 80, 0.6);
  border: 2px solid rgba(255, 100, 100, 0.8);
  position: absolute;
  pointer-events: none;
}

#aimLabel {
  display: none;
}

/* Hide mobile controls on desktop */
@media (pointer: fine) {
  #mobileControls {
    display: none !important;
  }
}

/* Mobile game adjustments */
@media (pointer: coarse) {
  #playerInfo {
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 300px;
  }

  #playerInfo #scoreBar,
  #playerInfo #levelBar {
    width: 100%;
  }

  #statsPanel {
    bottom: auto;
    top: 60px;
    left: 10px;
    transform: scale(0.75);
    transform-origin: top left;
  }

  #minimap {
    bottom: auto;
    top: 60px;
    right: 10px;
    transform: scale(0.7);
    transform-origin: top right;
  }

  #leaderboard {
    top: 50px;
    right: 50%;
    transform: translateX(50%) scale(0.75);
    transform-origin: top center;
  }
}

/* Mobile game active: hide dashboard, fill screen with game */
body.mobile-game-active #dashboard {
  display: none !important;
}

body.mobile-game-active #gameCanvas {
  width: 100vw !important;
  height: 100vh !important;
}

/* Forced landscape mode for in-app browsers (Phantom/Solflare) - only in portrait */
@media (orientation: portrait) {
  body.mobile-landscape-forced {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vh;
    height: 100vw;
    transform: rotate(90deg);
    transform-origin: top left;
    margin-left: 100vw;
    overflow: hidden;
  }

  body.mobile-landscape-forced #gameCanvas {
    width: 100vh !important;
    height: 100vw !important;
  }

  body.mobile-landscape-forced #mobileControls {
    width: 100vh;
    height: 100vw;
  }

  body.mobile-landscape-forced #playerInfo {
    bottom: 100px;
    width: 50%;
    max-width: 280px;
  }

  body.mobile-landscape-forced #statsPanel {
    top: 10px;
    left: 10px;
    transform: scale(0.7);
    transform-origin: top left;
  }

  body.mobile-landscape-forced #minimap {
    top: 10px;
    right: 10px;
    bottom: auto;
    transform: scale(0.6);
    transform-origin: top right;
  }

  body.mobile-landscape-forced #leaderboard {
    top: 10px;
    transform: translateX(50%) scale(0.65);
  }

  body.mobile-landscape-forced .mobile-fullscreen-btn {
    display: none !important;
  }
}

/* If already in landscape, forced class does nothing extra */
@media (orientation: landscape) {
  body.mobile-landscape-forced {
    width: 100vw;
    height: 100vh;
  }

  body.mobile-landscape-forced #gameCanvas {
    width: 100vw !important;
    height: 100vh !important;
  }

  body.mobile-landscape-forced .mobile-fullscreen-btn {
    display: none !important;
  }
}
