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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0b10;
  color: #e8e8f0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
}

#game-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  z-index: 1;
}

#game-container canvas {
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a24 0%, #0b0b10 70%);
  z-index: 20;
}

.panel {
  background: rgba(22, 22, 30, 0.92);
  border: 1px solid #2f2f3d;
  border-radius: 12px;
  padding: 32px 36px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.panel.wide {
  width: 640px;
  max-width: 94vw;
}

.panel h2 {
  font-size: 26px;
  letter-spacing: 1px;
  margin-bottom: 18px;
  color: #ffb347;
}

.title {
  font-size: 48px;
  letter-spacing: 3px;
  color: #ff8c1a;
  text-shadow: 0 3px 0 #7a3d00;
  margin-bottom: 6px;
  text-align: center;
}

.subtitle {
  color: #8a8aa0;
  text-align: center;
  margin-bottom: 26px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 12px;
}

input, select {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #101018;
  border: 1px solid #2f2f3d;
  border-radius: 8px;
  color: #e8e8f0;
  font-size: 15px;
  outline: none;
}

input:focus, select:focus {
  border-color: #ff8c1a;
}

.btn {
  padding: 12px 20px;
  margin: 4px;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  background: #24242f;
  color: #e8e8f0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:hover { background: #2e2e3c; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: #ff8c1a;
  border-color: #ff8c1a;
  color: #1a1206;
}

.btn.primary:hover { background: #ffa347; }

.btn.ghost {
  background: transparent;
}

.row { display: flex; align-items: center; justify-content: center; margin-top: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.muted { color: #8a8aa0; font-size: 13px; }
.status { color: #ffb347; font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }
.status.error { color: #ff5d5d; }

/* ---------- lobby table ---------- */

#lobby-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

#lobby-table th {
  text-align: left;
  color: #8a8aa0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px;
  border-bottom: 1px solid #2f2f3d;
}

#lobby-table td {
  padding: 10px;
  border-bottom: 1px solid #1c1c26;
  font-size: 14px;
}

#lobby-table tr:hover td {
  background: #1a1a24;
}

.join-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #3a3a4a;
  background: #24242f;
  color: #e8e8f0;
  cursor: pointer;
  font-size: 13px;
}

.join-btn:hover { background: #2e2e3c; }

.empty-row td {
  text-align: center;
  color: #55556a;
  padding: 24px 10px;
}

/* ---------- waiting room ---------- */

.waiting-players {
  margin: 16px 0;
}

.waiting-player {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #16161f;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 15px;
}

.waiting-player .owner {
  color: #ffb347;
  font-size: 12px;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 30;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud-top-left {
  position: absolute;
  top: 14px;
  left: 14px;
}

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

.hud-label {
  font-size: 12px;
  color: #8a8aa0;
  letter-spacing: 1px;
}

.hud-num {
  font-size: 13px;
  color: #e8e8f0;
  width: 34px;
}

.bar {
  width: 180px;
  height: 16px;
  background: #3a1a1a;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2f2f3d;
}

.bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #39e675, #7bf5a5);
  border-radius: 8px;
  transition: width 0.15s ease-out;
}

#hud-players {
  margin-top: 10px;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
}

.hud-player .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.hud-player.dead .dot { background: #444 !important; }
.hud-player.dead .name { color: #55556a; }

#hud-top-center {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#hud-banner {
  font-size: 34px;
  font-weight: 800;
  color: #ffd24d;
  text-shadow: 0 2px 0 #7a5d00;
}

#hud-sub-banner {
  font-size: 15px;
  color: #ffb347;
}

#hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
}

.ping {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(22, 22, 30, 0.8);
  border: 1px solid #2f2f3d;
}

.ping.good { color: #7bf5a5; }
.ping.fair { color: #ffd24d; }
.ping.poor { color: #ff5d5d; }

#hud-top-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-exit {
  pointer-events: auto;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(22, 22, 30, 0.8);
  border: 1px solid #2f2f3d;
  color: #e8e8f0;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.btn-exit:hover {
  background: rgba(255, 93, 93, 0.2);
  border-color: #ff5d5d;
  color: #ff9d9d;
}

.btn-exit:active {
  transform: scale(0.95);
}

#hud-bottom-center {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#hud-respawn {
  font-size: 18px;
  color: #ff9d9d;
}

/* ---------- touch controls ---------- */

#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.stick {
  position: absolute;
  width: 120px;
  height: 120px;
  pointer-events: auto;
  touch-action: none;
}

#stick-left { left: 18px; bottom: 22px; }
#stick-right { right: 18px; bottom: 22px; }

.stick-ring {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.stick-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 140, 26, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.4);
}

/* ---------- game over ---------- */

.stats {
  font-size: 15px;
  color: #ffd24d;
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.7;
}
