/* ===================================================================
   Bombecin - Modern Tactical Arcade Theme (Up to 8 Players)
   =================================================================== */

:root {
  --bg-dark: #090d16;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --border-color: #334155;
  --border-glow: #38bdf8;

  /* 8 Player Color Themes */
  --p1-color: #3b82f6; /* Blue */
  --p2-color: #ef4444; /* Red */
  --p3-color: #22c55e; /* Green */
  --p4-color: #f59e0b; /* Yellow */
  --p5-color: #a855f7; /* Purple */
  --p6-color: #06b6d4; /* Cyan */
  --p7-color: #f97316; /* Orange */
  --p8-color: #ec4899; /* Pink */

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1640px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 6px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #38bdf8, #818cf8, #f43f5e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.logo-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Match HUD: 8-Player Scoreboard & Central Wind Gauge */
.hud-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 12px;
}

.players-scoreboard-left,
.players-scoreboard-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.players-scoreboard-right {
  justify-content: flex-end;
}

/* Player Mini Badge & Card in HUD */
.hud-player-badge {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 105px;
  max-width: 130px;
  transition: all 0.25s;
}

.hud-player-badge.active-turn {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
  transform: scale(1.04);
}

.hud-player-badge.dead {
  opacity: 0.35;
  filter: grayscale(80%);
}

.hud-player-badge.disconnected {
  border-color: #ef4444;
  border-style: dashed;
}

.badge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.badge-num {
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
  color: #fff;
}

.badge-name {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-hp-container {
  width: 100%;
  height: 6px;
  background: #0f172a;
  border-radius: 3px;
  overflow: hidden;
}

.mini-hp-fill {
  height: 100%;
  transition: width 0.3s ease;
}

/* Center Wind Gauge */
.wind-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  padding: 4px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  min-width: 160px;
}

.wind-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.wind-visual {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 1px 0;
}

.wind-compass {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0f172a;
  border: 1px solid #475569;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wind-needle {
  width: 2.5px;
  height: 16px;
  background: linear-gradient(to top, #38bdf8 50%, #f43f5e 50%);
  border-radius: 2px;
  transition: transform 0.4s ease;
  transform-origin: center;
}

.wind-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #38bdf8;
  font-family: monospace;
}

.wind-dir-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

/* Turn Banner & Disconnect Alert */
.turn-banner {
  text-align: center;
  padding: 5px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid #38bdf8;
  color: #bae6fd;
  transition: background 0.3s;
}

.disconnect-timer-badge {
  background: #ef4444;
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  margin-left: 8px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

/* Arena Canvas Container (1600x700 Aspect Ratio) */
.canvas-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  aspect-ratio: 1600 / 700;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Damage Popups */
.damage-indicator {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.3rem;
  font-weight: 900;
  pointer-events: none;
  animation: floatFade 1.2s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
  z-index: 10;
}

@keyframes floatFade {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  30% { transform: translate(-50%, -25px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -55px) scale(1); }
}

/* Floating Toast Notification */
.toast-container {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 50;
  pointer-events: none;
}

.toast-badge {
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border: 1.5px solid #f59e0b;
  color: #fef08a;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  animation: toastPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, toastFadeOut 0.4s ease-in 2.4s forwards;
}

.toast-badge.error {
  border-color: #ef4444;
  color: #fca5a5;
}

.toast-badge.info {
  border-color: #38bdf8;
  color: #bae6fd;
}

@keyframes toastPop {
  0% { opacity: 0; transform: translateY(-16px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastFadeOut {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-12px) scale(0.95); }
}

/* Chat Drawer Panel */
.chat-drawer {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 320px;
  max-height: 240px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 30;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.chat-drawer.minimized {
  transform: translateY(calc(100% - 34px));
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.8);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.chat-feed {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
}

.chat-msg-row {
  font-size: 0.75rem;
  line-height: 1.3;
  word-break: break-word;
}

.chat-sender-tag {
  font-weight: 800;
  margin-right: 4px;
}

.chat-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.chat-input-bar {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  border-top: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  outline: none;
}

.chat-input:focus {
  border-color: #38bdf8;
}

.btn-chat-send {
  background: #2563eb;
  border: none;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.chat-quick-emotes {
  display: flex;
  gap: 4px;
  padding: 2px 6px;
  background: rgba(15, 23, 42, 0.7);
}

.btn-chat-emote {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s;
}

.btn-chat-emote:hover {
  transform: scale(1.3);
}

/* Tactical Controls Deck */
.control-deck {
  display: grid;
  grid-template-columns: 1.2fr 2fr 0.8fr;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 12px;
  align-items: center;
}

.weapon-arsenal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  height: 100%;
}

.deck-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.weapons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: center;
}

.weapon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--bg-card);
  border: 2px solid #334155;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  color: var(--text-main);
}

.weapon-btn:hover:not(.disabled) {
  border-color: #64748b;
  transform: translateY(-2px);
}

.weapon-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.weapon-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.weapon-icon {
  font-size: 1.2rem;
}

.weapon-name {
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
}

.ammo-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #f59e0b;
  color: #000;
  font-size: 0.6rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 8px;
}

/* Aim Controls: Side-by-Side 360° Dial & Vertical Power Slider */
.aim-controls-side-by-side {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.aim-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.aim-dial-wheel {
  width: 86px;
  height: 86px;
  min-width: 86px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  border: 2.5px solid #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3), inset 0 0 8px rgba(0, 0, 0, 0.7);
  position: relative;
  cursor: grab;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s;
}

.aim-dial-wheel:hover {
  border-color: #60a5fa;
  box-shadow: 0 0 18px rgba(96, 165, 250, 0.4), inset 0 0 8px rgba(0, 0, 0, 0.7);
}

.aim-dial-wheel:active {
  cursor: grabbing;
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.9);
}

.dial-cardinal {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-muted);
  pointer-events: none;
}

.dial-cardinal.north { top: 3px; }
.dial-cardinal.east { right: 4px; }
.dial-cardinal.south { bottom: 3px; }
.dial-cardinal.west { left: 4px; }

.dial-center-cap {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #0f172a;
  border: 1.5px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.dial-angle-number {
  font-size: 1.05rem;
  font-weight: 900;
  color: #38bdf8;
  font-family: monospace;
  line-height: 1;
}

.key-hint-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 1px;
}

.key-cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  background: #1e293b;
  border: 1px solid #475569;
  border-bottom: 2px solid #334155;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.65rem;
  font-family: inherit;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.dial-pointer-needle {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  transform: rotate(-45deg);
  transition: transform 0.05s ease-out;
}

.dial-pointer-tip {
  position: absolute;
  top: 3px;
  left: calc(50% - 4px);
  width: 8px;
  height: 13px;
  background: linear-gradient(to top, #38bdf8, #f59e0b);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  filter: drop-shadow(0 0 5px #38bdf8);
}

/* Vertical Power Control */
.power-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.vertical-power-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid #1e293b;
}

.power-step-btn {
  width: 26px;
  height: 20px;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 0;
  line-height: 1;
  background: #334155;
  border: 1px solid #475569;
}

.power-step-btn:hover {
  background: #475569;
  border-color: #38bdf8;
}

.vertical-slider-input {
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: slider-vertical;
  -webkit-appearance: slider-vertical;
  width: 18px;
  height: 64px;
  accent-color: #38bdf8;
  cursor: pointer;
  margin: 2px 0;
}

/* Fire Action Button */
.fire-area {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-fire {
  width: 100%;
  height: 100%;
  min-height: 58px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.4);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn-fire span {
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.85;
}

.btn-fire:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.6);
}

.btn-fire:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

/* Generic Buttons & Modals */
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-secondary.active {
  border-color: #38bdf8;
  color: #38bdf8;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal.active {
  display: flex;
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
}

.modal-close-btn:hover {
  background: #334155;
  border-color: #38bdf8;
  color: #fff;
}

.modal-header {
  text-align: center;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 900;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.menu-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-menu-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.btn-menu-opt:hover {
  background: #334155;
  border-color: #38bdf8;
  transform: translateX(4px);
}

.btn-menu-opt .opt-icon {
  font-size: 1.4rem;
}

.btn-menu-opt .opt-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

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

.input-field {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
}

.input-field:focus {
  border-color: #38bdf8;
}

.player-name-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lobby-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0f172a;
  padding: 10px;
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
}

.lobby-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.7);
  font-size: 0.8rem;
}

/* Stats list in Game Over */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #0f172a;
  padding: 12px;
  border-radius: 10px;
}

.stat-item {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-item strong {
  color: #fff;
}

@keyframes shakeEmpty {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px) rotate(-3deg); }
  40%, 80% { transform: translateX(6px) rotate(3deg); }
}

.shake-empty {
  animation: shakeEmpty 0.4s ease-in-out;
  border-color: #ef4444 !important;
}

@media (max-width: 950px) {
  .control-deck {
    grid-template-columns: 1fr;
  }
  .hud-bar {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .chat-drawer {
    width: 260px;
  }
}
