:root {
  --bg-dark: #060913;
  --bg-panel: rgba(13, 20, 38, 0.88);
  --bg-card: #0e162b;
  --border-glow: rgba(0, 229, 255, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --accent-cyan: #00e5ff;
  --accent-yellow: #ffd600;
  --accent-green: #00e676;
  --accent-pink: #ff2a85;
  --accent-red: #ff1744;
  --text-main: #f0f5ff;
  --text-muted: #93a4c8;
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ================= LOBBY SCREEN ================= */
#lobby-screen {
  background: radial-gradient(circle at 50% 0%, #152244 0%, #060913 75%);
  overflow-y: auto;
  padding: 20px 32px;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  font-size: 38px;
  background: rgba(255, 214, 0, 0.14);
  border: 2px solid var(--accent-yellow);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px rgba(255, 214, 0, 0.35);
}

.brand h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.accent-tag {
  font-size: 13px;
  background: linear-gradient(90deg, var(--accent-cyan), #2979ff);
  color: #030712;
  padding: 3px 10px;
  border-radius: 99px;
  vertical-align: middle;
  margin-left: 8px;
  font-weight: 800;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.35);
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.lobby-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: rgba(14, 22, 43, 0.9);
  border: 1px solid var(--border-glow);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.card h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 10px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.badge {
  background: rgba(0, 229, 255, 0.16);
  color: var(--accent-cyan);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

#profile-smiley-preview {
  background: radial-gradient(circle, #1c284a 0%, #090e1c 100%);
  border: 2px solid var(--border-glow);
  border-radius: 14px;
  flex-shrink: 0;
}

.profile-Controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input[type="text"],
select {
  width: 100%;
  background: #080d1a;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent-cyan);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.6);
  transition: transform 0.12s, box-shadow 0.12s;
}

.color-swatch:hover {
  transform: scale(1.14);
}

.color-swatch.selected {
  border: 3px solid #ffffff;
  box-shadow: 0 0 12px currentColor;
  transform: scale(1.16);
}

/* Available games list */
.games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.empty-games {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  background: rgba(7, 11, 22, 0.6);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  font-size: 13.5px;
}

.game-room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #080d1a;
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 10px;
  padding: 12px 14px;
  gap: 12px;
}

.game-room-info h4 {
  font-size: 15px;
  color: #ffffff;
  margin-bottom: 4px;
}

.game-room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-pill {
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Host Form */
.host-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-subtext {
  font-size: 12px;
  color: var(--accent-cyan);
  margin-top: 2px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.host-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.1s, filter 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #00e676, #00b0ff);
  color: #040814;
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-lg {
  flex: 1;
  padding: 12px 18px;
  font-size: 15px;
}

.controls-guide-box {
  margin-top: 16px;
  background: rgba(6, 10, 22, 0.75);
  border: 1px solid rgba(255, 214, 0, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
}

.controls-guide-box h3 {
  font-size: 13.5px;
  color: var(--accent-yellow);
  margin-bottom: 6px;
}

.controls-guide-box ul {
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.controls-guide-box strong {
  color: var(--text-main);
}

/* ================= IN-GAME HUD ================= */
.hud-topbar {
  height: 58px;
  background: #080d1c;
  border-bottom: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.hud-left-stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}

.smiley-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid #fff;
}

.stat-box {
  display: flex;
  flex-direction: column;
  background: rgba(15, 24, 48, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 12px;
  border-radius: 8px;
  min-width: 105px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
}

.money-text {
  color: var(--accent-green);
}

.lives-hearts {
  font-size: 16px;
  letter-spacing: 2px;
}

.hud-center-timer {
  text-align: center;
}

.match-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.timer-display {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-yellow);
  font-variant-numeric: tabular-nums;
}

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

.hud-btn {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.hud-btn-buy {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.22), rgba(0, 229, 255, 0.22));
  border-color: var(--accent-green);
  color: #ffffff;
}

.hud-btn-danger {
  border-color: rgba(255, 23, 68, 0.4);
  color: #ff8a80;
}

.affordable-pill {
  background: var(--accent-green);
  color: #030712;
  font-weight: 900;
  font-size: 11px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pulseBadge 1.1s infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

kbd {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: monospace;
}

/* Main 3D Viewport Container */
.game-viewport-container {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100vh - 58px);
  background: #040710;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Side HUD Panels */
.hud-side-left {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 245px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.hud-side-right {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 285px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.hud-panel {
  background: rgba(8, 13, 27, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 229, 255, 0.24);
  border-radius: 10px;
  padding: 10px;
  pointer-events: auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  letter-spacing: 0.4px;
}

.map-name-tag,
.sub-count {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
}

.minimap-wrapper {
  display: flex;
  justify-content: center;
  background: #050811;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  overflow: hidden;
}

.map-upgrades-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 7px;
}

.map-chip {
  font-size: 10.5px;
  background: rgba(0, 230, 118, 0.15);
  border: 1px solid rgba(0, 230, 118, 0.35);
  color: #b9f6ca;
  padding: 3px 6px;
  border-radius: 5px;
  text-align: center;
  font-weight: 600;
}

.map-chip.locked {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

/* Recent Hits / Kills by You */
.recent-targets-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 170px;
  overflow-y: auto;
}

.empty-feed {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 10px 4px;
}

.recent-target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.recent-target-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-hit {
  background: rgba(0, 229, 255, 0.2);
  color: var(--accent-cyan);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 800;
}

.tag-kill {
  background: rgba(255, 23, 68, 0.28);
  color: #ff8a80;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 800;
}

/* Leaderboard */
.leaderboard-table-header {
  display: grid;
  grid-template-columns: 18px 1fr 48px 38px 44px;
  column-gap: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 0 6px 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 5px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 315px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 18px 1fr 48px 38px 44px;
  column-gap: 6px;
  align-items: center;
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.lb-row.is-self {
  background: rgba(0, 229, 255, 0.16);
  border: 1px solid rgba(0, 229, 255, 0.45);
  font-weight: 700;
}

.lb-name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lb-timeout-badge {
  font-size: 9.5px;
  background: rgba(255, 23, 68, 0.25);
  color: #ff8a80;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 700;
}

.lb-score-cell {
  text-align: right;
  font-weight: 800;
  color: var(--accent-yellow);
}

/* Combat Feed */
.combat-feed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 125px;
  overflow-y: auto;
  font-size: 11.5px;
}

.feed-item {
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 7px;
  border-radius: 5px;
  line-height: 1.35;
}

/* Bottom Quick-Buy & Controls Bar */
.hud-bottom-bar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 15;
}

.quick-upgrades-strip {
  display: flex;
  gap: 6px;
  background: rgba(8, 13, 27, 0.88);
  border: 1px solid rgba(0, 229, 255, 0.28);
  padding: 6px 10px;
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

.quick-upg-btn {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  padding: 4px 8px;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 66px;
  transition: transform 0.1s, border-color 0.15s;
}

.quick-upg-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.quick-upg-btn.can-afford {
  border-color: var(--accent-green);
  background: rgba(0, 230, 118, 0.12);
}

.quick-upg-btn.maxed {
  border-color: var(--accent-yellow);
  background: rgba(255, 214, 0, 0.12);
}

.qu-top {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.qu-name {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.qu-cost {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--accent-green);
}

.controls-bar-hint {
  background: rgba(5, 8, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.controls-bar-hint strong {
  color: #ffffff;
}

/* Time Out Overlay */
.timeout-overlay {
  position: absolute;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -20%);
  z-index: 25;
}

.timeout-box {
  background: rgba(18, 10, 24, 0.92);
  border: 2px solid var(--accent-red);
  box-shadow: 0 0 36px rgba(255, 23, 68, 0.45);
  border-radius: 16px;
  padding: 22px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.timeout-icon {
  font-size: 38px;
}

.timeout-box h2 {
  color: #ff5252;
  font-size: 20px;
}

.respawn-countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0;
}

.respawn-timer {
  font-size: 34px;
  font-weight: 900;
  color: var(--accent-yellow);
  font-variant-numeric: tabular-nums;
}

/* Modals (Buy Menu, Waiting Room, Game Over) */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 16, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}

.modal-card {
  background: #0d152a;
  border: 1px solid var(--accent-cyan);
  border-radius: 16px;
  padding: 22px;
  max-width: 940px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.buy-wallet-box {
  display: flex;
  gap: 12px;
}

.wallet-item {
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.wallet-item span {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

.wallet-item strong {
  font-size: 20px;
}

.wallet-money {
  border: 1px solid var(--accent-green);
  background: rgba(0, 230, 118, 0.12);
  color: var(--accent-green);
}

.btn-close {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
}

.buy-upgrades-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.upgrade-card {
  background: #080d1a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.upgrade-card.affordable {
  border-color: rgba(0, 230, 118, 0.55);
}

.upgrade-card.maxed {
  border-color: rgba(255, 214, 0, 0.55);
}

.upg-info h4 {
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.upg-cat-tag {
  font-size: 10px;
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.upg-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.upg-levels {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.lvl-pip {
  width: 18px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}

.lvl-pip.filled {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.upg-buy-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* Waiting Room & Game Over Modals */
.waiting-players-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 12px 0 18px 0;
}

.waiting-player-slot {
  background: #080d1a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.waiting-rules-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.gameover-modal-card {
  text-align: center;
  max-width: 720px;
}

.gameover-badge {
  display: inline-block;
  background: rgba(255, 214, 0, 0.18);
  color: var(--accent-yellow);
  border: 1px solid var(--accent-yellow);
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.final-scoreboard-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  text-align: left;
  font-size: 13.5px;
}

.final-scoreboard-table th,
.final-scoreboard-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.final-scoreboard-table th {
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
}
