:root {
  --panel: rgba(16, 20, 30, 0.75);
  --text: #e8eaf0;
  --muted: #9aa1b0;
  --accent: #42d4f4;
  --danger: #e6194b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #14161c;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

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

#hud {
  position: fixed;
  top: 10px;
  left: 12px;
  display: flex;
  gap: 14px;
  padding: 6px 12px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}

#hud .status-on  { color: #3cb44b; }
#hud .status-off { color: var(--danger); }

#it-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 22px;
  background: rgba(230, 25, 75, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  pointer-events: none;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.06); }
}

/* --- Scoreboard --------------------------------------------------------- */

#scoreboard {
  position: fixed;
  top: 10px;
  right: 12px;
  min-width: 190px;
  padding: 8px 12px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
}

#round-timer {
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

#scores {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#scores li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

#scores li.me { color: var(--text); font-weight: 600; }
#scores li .it-time { font-variant-numeric: tabular-nums; }
#scores li.is-it .who::after {
  content: " IT";
  color: var(--danger);
  font-weight: 800;
  font-size: 11px;
}

/* --- Toast --------------------------------------------------------------- */

#toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 28px;
  background: rgba(16, 20, 30, 0.92);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  border-radius: 10px;
  pointer-events: none;
  z-index: 10;
}

/* --- Chat -------------------------------------------------------------- */

#chat {
  position: fixed;
  left: 12px;
  bottom: 12px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chat-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow: hidden;
  font-size: 13px;
}

#chat-log .msg {
  background: var(--panel);
  border-radius: 4px;
  padding: 3px 8px;
  word-break: break-word;
}

#chat-log .msg .who { font-weight: 600; }

#chat-input {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
}

#chat-input:focus { border-color: var(--accent); }

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

#join-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.75);
}

#join-overlay.hidden { display: none; }

#join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  padding: 28px;
  background: #1b1e27;
  border: 1px solid #2a2f3d;
  border-radius: 10px;
  text-align: center;
}

#join-form h1 { margin: 0; font-size: 26px; }
#join-form p  { margin: 0; color: var(--muted); font-size: 13px; }

#join-form input {
  background: #14161c;
  border: 1px solid #2a2f3d;
  border-radius: 6px;
  color: var(--text);
  padding: 10px;
  font-size: 15px;
  text-align: center;
  outline: none;
}

#join-form input:focus { border-color: var(--accent); }

#join-form button {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #10222a;
  font-size: 15px;
  font-weight: 700;
  padding: 10px;
  cursor: pointer;
}

#join-form button:hover { filter: brightness(1.1); }

.error { color: var(--danger); }
.hidden { display: none; }

/* --- Touch controls (virtual joystick) ---------------------------------- */

#join-overlay { z-index: 20; }

#touch-zone {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 55%;
  display: none;
  touch-action: none;
  z-index: 5;
}

body.touch #touch-zone { display: block; }

#joy-base, #joy-stick {
  position: fixed;
  display: none;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 6;
}

#joy-base {
  width: 124px;
  height: 124px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.08);
}

#joy-stick {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.4);
}

#rotate-hint {
  position: fixed;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 6px 14px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  pointer-events: none;
  z-index: 7;
  white-space: nowrap;
}

@media (orientation: portrait) {
  body.touch #rotate-hint { display: block; }
}

/* On touch devices the joystick owns the bottom-left; move chat right and
   keep it compact so thumbs don't hit it. */
body.touch #chat {
  left: auto;
  right: 12px;
  bottom: 12px;
  width: 240px;
}

body.touch #chat-log { max-height: 110px; }
body.touch #scoreboard { top: 46px; }
