/* 10-Foot TV & Big Screen Safe Area & Arcade Styles */
:root {
  --tv-safe-top: 44px;
  --tv-safe-bottom: 44px;
  --tv-safe-left: 56px;
  --tv-safe-right: 56px;

  --p1-cyan: #00f0ff;
  --p1-dark: #0284c7;
  --p2-pink: #ff007f;
  --p2-dark: #be185d;
  --gold-accent: #facc15;
  --drab-gray: #64748b;

  --bg-dark: #080b14;
  --bg-card: rgba(15, 23, 42, 0.88);
  --focus-glow: 0 0 0 4px #00f0ff, 0 0 28px rgba(0, 240, 255, 0.7);
  --focus-glow-pink: 0 0 0 4px #ff007f, 0 0 28px rgba(255, 0, 127, 0.7);
  --focus-glow-gold: 0 0 0 4px #facc15, 0 0 28px rgba(250, 204, 21, 0.7);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: #f8fafc;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Master 16:9 Aspect Ratio Container */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #111827 0%, #030712 100%);
}

#canvas-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Split screen divider line */
#split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: linear-gradient(180deg, #00f0ff 0%, #ffffff 50%, #ff007f 100%);
  transform: translateX(-50%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  z-index: 5;
  pointer-events: none;
  display: none;
}

#split-divider.active {
  display: block;
}

/* HUD Overlay - 10-Foot Safe Margins */
.hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: var(--tv-safe-top) var(--tv-safe-right) var(--tv-safe-bottom) var(--tv-safe-left);
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Top Bar: Territory Tracker, Timer, Score */
.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.hud-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Player Score Badges */
.player-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-badge.p1 {
  border-left: 4px solid var(--p1-cyan);
}
.player-badge.p2 {
  border-right: 4px solid var(--p2-pink);
}

.player-avatar-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #fff;
}
.player-avatar-icon.p1 {
  background: linear-gradient(135deg, var(--p1-cyan), var(--p1-dark));
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.6);
}
.player-avatar-icon.p2 {
  background: linear-gradient(135deg, var(--p2-pink), var(--p2-dark));
  box-shadow: 0 0 14px rgba(255, 0, 127, 0.6);
}

.badge-info {
  display: flex;
  flex-direction: column;
}

.badge-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #94a3b8;
}

.badge-score {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.1;
}
.p1 .badge-score { color: var(--p1-cyan); text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }
.p2 .badge-score { color: var(--p2-pink); text-shadow: 0 0 10px rgba(255, 0, 127, 0.5); }

/* Center Territory Gauge & Timer */
.hud-center-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.timer-box {
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid var(--gold-accent);
  border-radius: 24px;
  padding: 6px 24px;
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.4);
}
.timer-box.hurry {
  border-color: #ef4444;
  color: #ef4444;
  animation: pulse-hurry 0.6s infinite alternate;
}

@keyframes pulse-hurry {
  from { transform: scale(1); box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
  to { transform: scale(1.1); box-shadow: 0 0 25px rgba(239, 68, 68, 0.8); }
}

/* Tug of War City Coverage Bar */
.city-coverage-bar-container {
  width: 380px;
  height: 20px;
  background: #334155;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  display: flex;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.coverage-fill-p1 {
  height: 100%;
  background: linear-gradient(90deg, #0284c7, var(--p1-cyan));
  width: 0%;
  transition: width 0.25s ease-out;
}
.coverage-fill-p2 {
  height: 100%;
  background: linear-gradient(90deg, var(--p2-pink), #be185d);
  width: 0%;
  margin-left: auto;
  transition: width 0.25s ease-out;
}
.coverage-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 900;
  text-shadow: 0 1px 3px #000;
  color: #fff;
}

/* Bottom Bar: Weapon Status, Bomb Cooldown, Controls Hints */
.hud-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.weapon-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weapon-icon-box {
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  border: 2px solid var(--p1-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.p2 .weapon-icon-box {
  border-color: var(--p2-pink);
}

.special-bomb-meter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}
.meter-track {
  width: 120px;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--gold-accent);
  width: 100%;
  transition: width 0.1s linear;
}
.meter-fill.ready {
  background: linear-gradient(90deg, #facc15, #f59e0b);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.8);
  animation: pulse-meter 1s infinite alternate;
}

@keyframes pulse-meter {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

/* Splat Combo Popup in Viewport */
.combo-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.95), rgba(245, 158, 11, 0.95));
  color: #0f172a;
  padding: 12px 36px;
  border-radius: 20px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 2px;
  box-shadow: 0 10px 40px rgba(250, 204, 21, 0.6);
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  z-index: 15;
}
.combo-banner.active {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Building Complete Splash Announcement */
.building-splash {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  color: #fff;
  padding: 14px 44px;
  border-radius: 24px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  box-shadow: 0 10px 45px rgba(16, 185, 129, 0.7);
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 16;
}
.building-splash.active {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Control Pills at Bottom Center */
.control-pills-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(15, 23, 42, 0.8);
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.control-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

/* Xbox Badges */
.xbox-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.xbox-badge.btn-a { background: #107c10; }
.xbox-badge.btn-b { background: #e81123; }
.xbox-badge.btn-x { background: #0078d7; }
.xbox-badge.btn-y { background: #f59e0b; color: #111; }
.xbox-badge.btn-menu { background: #475569; font-size: 10px; width: auto; padding: 2px 8px; border-radius: 12px; }

/* Menus & Modals (10-Foot UI) */
.menu-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 11, 20, 0.88);
  backdrop-filter: blur(16px);
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--tv-safe-top) var(--tv-safe-right) var(--tv-safe-bottom) var(--tv-safe-left);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
}
.menu-screen.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 60 !important;
}

/* Main Menu Title */
.menu-logo-title {
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #00f0ff 0%, #facc15 50%, #ff007f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 25px rgba(0, 240, 255, 0.6));
  margin-bottom: 4px;
  text-align: center;
}
.menu-logo-subtitle {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 8px;
  color: #f8fafc;
  margin-bottom: 32px;
  text-align: center;
}

/* Menu Button List */
.menu-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 440px;
}

/* 10-Foot TV Focusable Buttons */
.tv-button {
  background: rgba(30, 41, 59, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  color: #f8fafc;
  padding: 16px 24px;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.15s ease, background 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.tv-button * {
  pointer-events: none;
}

.tv-button:hover,
.tv-button:focus,
.tv-button.tv-focused {
  background: linear-gradient(90deg, rgba(30, 58, 138, 0.95), rgba(15, 23, 42, 0.95));
  border-color: var(--p1-cyan);
  transform: scale(1.06);
  box-shadow: var(--focus-glow);
  z-index: 10;
}

.tv-button.danger:hover,
.tv-button.danger:focus,
.tv-button.danger.tv-focused {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px #ef4444, 0 0 28px rgba(239, 68, 68, 0.7);
}

.btn-icon {
  font-size: 24px;
}

/* Game Over Card */
.results-card {
  background: rgba(15, 23, 42, 0.96);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 32px 48px;
  max-width: 680px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.results-winner {
  font-size: 42px;
  font-weight: 900;
  margin-bottom: 20px;
  text-align: center;
}
.winner-p1 { color: var(--p1-cyan); text-shadow: 0 0 20px rgba(0, 240, 255, 0.6); }
.winner-p2 { color: var(--p2-pink); text-shadow: 0 0 20px rgba(255, 0, 127, 0.6); }
.winner-coop { color: var(--gold-accent); text-shadow: 0 0 20px rgba(250, 204, 21, 0.6); }

.results-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  margin-bottom: 28px;
}
.stat-box {
  background: rgba(30, 41, 59, 0.6);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
}
.stat-title {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
}
.stat-value {
  font-size: 26px;
  font-weight: 900;
  color: #f8fafc;
}

/* How to play modal */
.instructions-panel {
  max-width: 720px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 30px 40px;
  line-height: 1.6;
}
.instructions-panel h2 {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 16px;
  color: var(--p1-cyan);
}
.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.instruction-item {
  background: rgba(30, 41, 59, 0.7);
  padding: 16px;
  border-radius: 12px;
}
.instruction-item h3 {
  font-size: 18px;
  color: var(--gold-accent);
  margin-bottom: 6px;
}

/* Mobile On-Screen Touch Controls */
.mobile-touch-cluster {
  position: absolute;
  bottom: 20px;
  width: 100%;
  padding: 0 30px;
  display: none;
  justify-content: space-between;
  pointer-events: auto;
  z-index: 20;
}
@media (pointer: coarse) {
  .mobile-touch-cluster {
    display: flex;
  }
}
.virtual-stick {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
  position: relative;
  touch-action: none;
}
.virtual-stick-knob {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--p1-cyan);
  position: absolute;
  top: 35px;
  left: 35px;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.8);
}
.touch-action-buttons {
  display: flex;
  gap: 16px;
  align-items: center;
}
.touch-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--p1-cyan);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.touch-btn.bomb {
  border-color: var(--gold-accent);
  color: var(--gold-accent);
}

/* Device assignment tag in HUD */
.device-tag {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.7);
  padding: 3px 8px;
  border-radius: 6px;
  margin-top: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.p2 .device-tag {
  color: #f472b6;
}

/* Device Setup Banner on Main Menu */
.same-window-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(0, 240, 255, 0.4);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 20px;
}
