/* Reset & Base Setup */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

/* Ensure hidden elements are ALWAYS completely hidden */
[hidden],
.hidden,
#connect-screen[hidden],
#connect-screen.hidden,
#game-screen[hidden],
#game-screen.hidden,
#death-screen[hidden],
#death-screen.hidden,
#reload-text[hidden],
#reload-text.hidden {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000000;
  font-family: 'Helvetica', 'Arial', sans-serif;
  color: #ffffff;
}

/* ==========================================================================
   SCREEN 1: Launcher / Connect Window (Exact Replica of Tkinter get_user_input)
   ========================================================================== */
#connect-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('assets/background.jpg') no-repeat center center fixed;
  background-size: cover;
  z-index: 100;
}

#launcher-frame {
  background-color: #010d25;
  border: 2px solid #002157;
  border-radius: 6px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.88);
  width: min(520px, 92vw);
  padding: 34px 44px 38px;
  text-align: center;
}

.launcher-label {
  font-size: 26px;
  font-weight: bold;
  color: lightblue;
  margin: 0 0 10px 0;
  letter-spacing: 0.3px;
}

.input-wrap {
  position: relative;
  width: 100%;
}

.input-wrap input {
  width: 100%;
  font-family: 'Arial', sans-serif;
  font-size: 19px;
  text-align: center;
  padding: 7px 12px;
  border: 1px solid #7a9cb9;
  border-radius: 4px;
  background-color: #ffffff;
  color: #000000;
  outline: none;
  font-weight: 500;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-wrap input:focus {
  border-color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.65);
}

#color-indicator {
  font-family: 'Arial', sans-serif;
  font-size: 13px;
  font-weight: bold;
  color: lightblue;
  margin-top: 6px;
  min-height: 18px;
  transition: color 0.15s;
}

#ts-hint {
  font-family: 'Arial', sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: #00e5ff;
  margin-top: 6px;
}

#bridge-options-toggle {
  margin-top: 14px;
  text-align: left;
  font-size: 12px;
  color: #8da4be;
  cursor: pointer;
}

#bridge-options-toggle summary {
  outline: none;
}

#bridge-options-toggle input {
  background: #03173d;
  color: #e0f2fe;
  border: 1px solid #335987;
  border-radius: 3px;
  text-align: left;
}

#connect-error {
  color: #ff5252;
  font-size: 13px;
  font-weight: bold;
  min-height: 20px;
  margin-top: 12px;
}

.button-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}

#btn-play {
  background-color: green;
  color: white;
  font-family: 'Arial', sans-serif;
  font-size: 20px;
  font-weight: bold;
  padding: 8px 38px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 128, 0, 0.5);
  transition: background-color 0.15s, transform 0.08s;
}

#btn-play:hover {
  background-color: #009900;
}

#btn-play:active {
  transform: scale(0.97);
}

#btn-close {
  background-color: red;
  color: white;
  font-family: 'Arial', sans-serif;
  font-size: 20px;
  font-weight: bold;
  padding: 8px 38px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(255, 0, 0, 0.4);
  transition: background-color 0.15s, transform 0.08s;
}

#btn-close:hover {
  background-color: #cc0000;
}

#btn-close:active {
  transform: scale(0.97);
}

/* ==========================================================================
   SCREEN 2: In-Game 3D Viewport & HUD (Exact Ursina Match)
   ========================================================================== */
#game-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #000000;
}

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

/* Center Crosshair (Ursina color rgba(255, 0, 0, 122)) */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  background-color: rgba(255, 0, 0, 0.52);
  pointer-events: none;
  z-index: 10;
  transition: width 0.15s ease, height 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

#crosshair.zoomed {
  width: 9px;
  height: 9px;
  background-color: rgba(255, 30, 30, 0.95);
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

/* In-Game Top Center HUD */
#hud-top {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 10;
  width: min(520px, 70vw);
}

#healthbar-container {
  width: 100%;
  height: 22px;
  background-color: rgb(255, 0, 0);
  border: 1px solid rgba(0, 0, 0, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

#healthbar-fill {
  height: 100%;
  width: 100%;
  background-color: rgb(0, 255, 0);
  transition: width 0.1s linear;
}

#health-text {
  color: #ffffff;
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 19px;
  font-weight: bold;
  margin-top: 6px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

#ammo-text {
  color: #ffffff;
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 19px;
  font-weight: bold;
  margin-top: 5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

#reload-text {
  color: #ffff00;
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 17px;
  font-weight: bold;
  margin-top: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

#hud-controls-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 5px #000000;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

#top-bar-controls {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 25;
}

#top-bar-controls button {
  background: rgba(1, 13, 37, 0.78);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  padding: 6px 12px;
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: background 0.15s, border-color 0.15s;
}

#top-bar-controls button:hover {
  background: rgba(0, 229, 255, 0.28);
  border-color: #00e5ff;
}

/* ==========================================================================
   SCREEN 3: Death Screen (Exact Ursina Match)
   ========================================================================== */
#death-screen {
  position: absolute;
  inset: 0;
  background: url('assets/background.jpg') no-repeat center center;
  background-size: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

#death-content {
  text-align: center;
  padding: 20px;
}

#death-title {
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: clamp(52px, 8.5vw, 100px);
  font-weight: 900;
  color: #ff0000;
  margin: 0 0 14px 0;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.95);
  letter-spacing: 2px;
}

#death-subtitle {
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: clamp(16px, 2.2vw, 24px);
  font-weight: bold;
  color: #ffffff;
  margin: 0 0 28px 0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
}

#respawn-button {
  background-color: #00bcd4;
  color: #ffffff;
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 22px;
  font-weight: bold;
  padding: 12px 48px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 188, 212, 0.5);
  transition: background-color 0.15s, transform 0.08s;
}

#respawn-button:hover {
  background-color: #00e5ff;
  transform: scale(1.03);
}

#respawn-button:active {
  transform: scale(0.97);
}

#timer-text {
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 18px;
  color: #d0d0d0;
  margin-top: 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}