/* HEAT SIGNATURE co-op — crimson-space lobby + game chrome
   Evidence: pod-flight-approach.png (deep crimson space, constellation
   lines), infiltration-normal.png (white hull, teal doors), alarm red. */

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

:root {
  --teal: #35d0c6;
  --gold: #e8c44d;
  --red: #e8434a;
  --crimson: #8e1236;
  --bg-deep: #14060c;
  --bg-panel: rgba(20, 8, 14, 0.94);
  --line: #3a1626;
  --line-hi: #5c2438;
  --dim: #9a7c88;
  --p1: #4aa3ff;
  --p2: #ff9f43;
  --p3: #5cd65c;
  --p4: #e056fd;
}

html, body {
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, #2a0a18 0%, var(--bg-deep) 75%);
  color: #e8dde2;
  font-family: "Courier New", monospace;
  overflow: hidden;
}

#app { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

/* ── Lobby ─────────────────────────────────────────────────────────────── */
#lobby-screen {
  width: min(560px, 94vw);
  max-height: 96vh;
  overflow-y: auto;
  padding: 0 30px 26px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(53, 208, 198, 0.10), inset 0 0 60px rgba(0,0,0,0.5);
}

/* crimson nebula hero strip with a white hull silhouette (docking evidence) */
#lobby-hero {
  height: 64px;
  margin: 0 -30px 14px;
  background:
    radial-gradient(ellipse 70px 24px at 74% 58%, #dfe3d6 0%, #dfe3d6 55%, transparent 56%),
    radial-gradient(ellipse 200px 50px at 30% 40%, rgba(232, 135, 156, 0.5) 0%, transparent 70%),
    radial-gradient(ellipse 260px 60px at 60% 70%, rgba(200, 106, 156, 0.35) 0%, transparent 70%),
    linear-gradient(180deg, #5c0f24 0%, var(--crimson) 60%, #6e1030 100%);
  border-bottom: 2px solid #000;
  position: relative;
}
#lobby-hero::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  background-image:
    radial-gradient(1px 1px at 12% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 26% 66%, #ffd 50%, transparent 51%),
    radial-gradient(2px 2px at 48% 24%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 44%, #fee 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 36%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 93% 70%, #ffd 50%, transparent 51%);
}

#lobby-title {
  font-size: 46px;
  font-weight: bold;
  letter-spacing: 6px;
  color: var(--teal);
  text-shadow: 3px 3px 0 #000, 0 0 22px rgba(53, 208, 198, 0.35);
}
#lobby-title span { color: #9fe8e2; }

#lobby-subtitle { margin: 6px 0 16px; font-size: 12px; color: var(--dim); letter-spacing: 1px; }

#connection-status { font-size: 12px; margin-bottom: 12px; }
#connection-status.connected { color: var(--teal); }
#connection-status.disconnected { color: var(--red); }

.lobby-section { margin-bottom: 16px; }
.lobby-section-title {
  font-size: 11px; letter-spacing: 3px; color: var(--teal);
  text-transform: uppercase; margin-bottom: 7px;
}

.btn-row { display: flex; gap: 8px; }

input#room-code-input {
  flex: 0 0 110px;
  background: #180a10; border: 1px solid var(--line-hi); color: var(--gold);
  font-family: inherit; font-size: 18px; font-weight: bold; letter-spacing: 3px;
  padding: 8px 10px; text-transform: uppercase; text-align: center;
}

button {
  background: #22101a; border: 1px solid var(--line-hi); color: #e8dde2;
  font-family: inherit; font-size: 13px; padding: 9px 14px; cursor: pointer;
  letter-spacing: 1px;
}
button:hover:not(:disabled) { background: #321626; border-color: var(--teal); }
button:disabled { opacity: 0.45; cursor: default; }

.player-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player-slot {
  padding: 9px 12px; background: #180a10; border: 1px solid var(--line);
  min-height: 52px;
}
.player-slot.occupied { border-color: var(--line-hi); }
.player-slot.ready { border-color: var(--teal); box-shadow: 0 0 10px rgba(53,208,198,.3); }
.slot-label { font-size: 12px; font-weight: bold; letter-spacing: 1px; }
.slot-label.p1 { color: var(--p1); }
.slot-label.p2 { color: var(--p2); }
.slot-label.p3 { color: var(--p3); }
.slot-label.p4 { color: var(--p4); }
.slot-status { font-size: 11px; color: var(--dim); margin-top: 4px; }

.btn-ready {
  width: 100%; font-size: 20px; font-weight: bold;
  letter-spacing: 5px; padding: 13px;
  background: linear-gradient(180deg, #103c38, #0a2422);
  border: 1px solid var(--teal);
  text-shadow: 0 0 8px var(--teal);
}
.btn-ready.is-ready { background: linear-gradient(180deg, #4a4416, #2a260c); border-color: var(--gold); text-shadow: 0 0 8px var(--gold); }

#lobby-status-text { font-size: 12px; color: var(--dim); min-height: 16px; }
#lobby-help { font-size: 11px; color: #7c6270; line-height: 1.7; border-top: 1px solid var(--line); padding-top: 10px; }

/* ── Game ──────────────────────────────────────────────────────────────── */
#game-wrapper { display: none; position: relative; width: 100%; height: 100%; align-items: center; justify-content: center; }
#game-wrapper.active { display: flex; }
#lobby-screen.hidden { display: none; }

canvas#game-canvas {
  max-width: 100vw; max-height: 100vh;
  aspect-ratio: 16 / 9;
  width: 100%;
  object-fit: contain;
  background: #000;
  cursor: crosshair;
}

#countdown-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; pointer-events: none;
}
#countdown-overlay.active { display: flex; }
#countdown-number {
  font-size: 120px; font-weight: bold; color: var(--teal);
  text-shadow: 5px 5px 0 #000, 0 0 40px var(--teal);
}

#disconnected-overlay {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(10, 4, 8, 0.9); z-index: 30;
}
#disconnected-overlay.active { display: flex; }
#dc-title { color: var(--red); letter-spacing: 4px; }
#dc-message { color: var(--dim); font-size: 13px; }

#mute-btn, #fullscreen-btn {
  position: absolute; bottom: 10px; z-index: 20;
  width: 40px; height: 40px; padding: 0; font-size: 18px;
  background: rgba(20, 8, 14, 0.6); border: 1px solid var(--line-hi);
}
#mute-btn { right: 10px; }
#fullscreen-btn { right: 58px; }

/* ── Rotate hint (portrait phones) ─────────────────────────────────────── */
#rotate-hint {
  display: none; position: absolute; inset: 0; z-index: 40;
  align-items: center; justify-content: center;
  background: rgba(10, 4, 8, 0.92); color: var(--gold);
  font-size: 20px; letter-spacing: 2px; text-align: center; padding: 20px;
}
@media (orientation: portrait) {
  body.touch #rotate-hint { display: flex; }
}

/* ── Touch UI ──────────────────────────────────────────────────────────── */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
#joy-left, #joy-right {
  position: absolute; bottom: 0; width: 42%; height: 55%; z-index: 15;
  touch-action: none;
}
/* self-contained virtual stick visuals (no CDN dependency) */
.joy-base {
  display: none; position: absolute; width: 110px; height: 110px;
  margin: -55px 0 0 -55px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.joy-base.active { display: block; }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
  margin: -23px 0 0 -23px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
  border: 1px solid rgba(255, 255, 255, 0.4);
}
#joy-left { left: 0; }
#joy-right { right: 0; }
#touch-buttons {
  position: absolute; right: 12px; top: 12%;
  display: flex; flex-direction: column; gap: 10px; z-index: 16;
}
.tbtn {
  width: 64px; height: 44px; font-size: 11px; font-weight: bold;
  background: rgba(20, 8, 14, 0.45); border: 1px solid rgba(53, 208, 198, 0.75);
  color: var(--teal); border-radius: 6px;
}
.tbtn:active { background: rgba(53, 208, 198, 0.35); }

/* on-canvas thumb hint zones for first-time mobile players (fade after ~9s) */
.joy-hint {
  display: none; position: absolute; bottom: 16%; width: 86px; height: 86px;
  border: 2px dashed rgba(255, 255, 255, 0.35); border-radius: 50%;
  color: rgba(255, 255, 255, 0.55); font-size: 10px; letter-spacing: 2px;
  align-items: center; justify-content: center; text-align: center;
  pointer-events: none; z-index: 14;
}
body.touch .joy-hint { display: flex; animation: hintFade 1.2s ease 9s forwards; }
#joy-hint-left { left: 10%; }
#joy-hint-right { right: 10%; }
@keyframes hintFade { to { opacity: 0; } }

body.touch #mute-btn { right: 112px; }
body.touch #fullscreen-btn { right: 160px; }
