/* DEAD CELLS co-op — lobby + game chrome.
   Evidence: title-screen.png (cyan DEAD CELLS wordmark over warm orange sunset
   island), pq frames (dark desaturated blue-teal stone, teal torch accents). */

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

:root {
  --teal: #37e0c8;
  --gold: #ffd27f;
  --red: #ff5a5a;
  --bg-deep: #070b12;
  --bg-panel: rgba(11, 16, 26, 0.94);
  --line: #22314a;
  --line-hi: #3a5578;
  --dim: #7c8aa4;
  --p1: #4aa3ff;
  --p2: #ff9f43;
  --p3: #5cd65c;
  --p4: #e056fd;
}

html, body {
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, #0d1420 0%, var(--bg-deep) 75%);
  color: #d8e0ec;
  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(55, 224, 200, 0.10), inset 0 0 60px rgba(0,0,0,0.5);
}

/* sunset-island hero strip (title evidence: warm orange sky, dark island) */
#lobby-hero {
  height: 64px;
  margin: 0 -30px 14px;
  background:
    linear-gradient(180deg, rgba(0,0,0,0) 55%, #0b101a 100%),
    radial-gradient(ellipse at 62% 90%, rgba(20,16,26,0.95) 0%, rgba(20,16,26,0.9) 26%, transparent 27%),
    linear-gradient(180deg, #e8894a 0%, #f0a85c 45%, #f8d488 80%, #f8e8b0 100%);
  border-bottom: 2px solid #000;
  position: relative;
}
#lobby-hero::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 20px;
  background: linear-gradient(180deg, transparent 0%, rgba(232,150,80,0.5) 100%);
}

#lobby-title {
  font-size: 46px;
  font-weight: bold;
  letter-spacing: 6px;
  color: #e8f4f8;
  text-shadow: 3px 3px 0 #000, 0 0 22px rgba(55, 224, 200, 0.45);
}
#lobby-title span { color: var(--teal); }

#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: #0c1220; 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: #131c30; border: 1px solid var(--line-hi); color: #d8e0ec;
  font-family: inherit; font-size: 13px; padding: 9px 14px; cursor: pointer;
  letter-spacing: 1px;
}
button:hover:not(:disabled) { background: #1c2a44; 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: #0c1220; 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(55,224,200,.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, #143430, #0c1e20);
  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: #5c6a84; 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;
}

#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(3, 6, 12, 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(11, 16, 26, 0.6); border: 1px solid var(--line-hi);
}
#mute-btn { right: 10px; }
#fullscreen-btn { right: 58px; }

/* ── Rotate overlay (portrait phones) ──────────────────────────────────── */
#rotate-overlay {
  display: none; position: absolute; inset: 0; z-index: 40;
  align-items: center; justify-content: center;
  background: rgba(3, 6, 12, 0.94); color: var(--gold);
  font-size: 20px; letter-spacing: 2px; text-align: center; padding: 20px;
}
#rotate-overlay.active { display: none; }
body.touch #rotate-overlay.active { display: flex; }

/* ── Touch UI (self-drawn) ─────────────────────────────────────────────── */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }

#joy-zone {
  position: absolute; left: 0; bottom: 0; width: 44%; height: 60%; z-index: 15;
}
#joy-knob {
  position: absolute; left: 24%; bottom: 24%;
  width: 76px; height: 76px; border-radius: 50%;
  border: 2px solid rgba(55, 224, 200, 0.55);
  background: rgba(55, 224, 200, 0.12);
  pointer-events: none;
}
#joy-zone.live #joy-knob { background: rgba(55, 224, 200, 0.28); }
.joy-hint {
  display: none; position: absolute; left: 10%; bottom: 16%;
  color: rgba(255, 255, 255, 0.5); font-size: 10px; letter-spacing: 2px;
  pointer-events: none; z-index: 14;
}
body.touch .joy-hint { display: block; animation: hintFade 1.2s ease 9s forwards; }
@keyframes hintFade { to { opacity: 0; } }

#touch-buttons {
  position: absolute; right: 10px; bottom: 8%;
  display: grid; grid-template-columns: 68px 68px; gap: 10px; z-index: 16;
}
.tbtn {
  width: 68px; height: 52px; font-size: 12px; font-weight: bold;
  background: rgba(11, 16, 26, 0.45); border: 1px solid rgba(55, 224, 200, 0.7);
  color: var(--teal); border-radius: 8px;
}
.tbtn.big { height: 62px; font-size: 14px; }
.tbtn:active { background: rgba(55, 224, 200, 0.35); }

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