/* lib/styles.css — shared neon theme for all games.
   Each game links this and adds its own game-specific styles inline. */

:root {
  --bg: #0a0a0a;
  --panel: #1a1a1a;
  --border: #333;
  --accent: #0ff;
  --accent-glow: rgba(0, 255, 255, 0.3);
  --accent2: #f0f;
  --good: #4dff4d;
  --danger: #ff4d4d;
  --muted: #aaa;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Ensure [hidden] always wins over display:flex/grid etc. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: #fff;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

/* Back-to-portal link. Fixed so it survives the absolutely-positioned lobby,
   game and overlay layers; above the overlay (z-index 10) so it stays reachable
   on a game-over screen. Panels below reserve top space so it never collides. */
.portal-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(4px);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s;
}
.portal-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Buttons */
.neon-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  font-family: var(--font);
}
.neon-btn:hover:not(:disabled) {
  box-shadow: 0 0 20px var(--accent-glow);
}
.neon-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.neon-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
}
/* The same pill used as a link (e.g. "ALL GAMES" on the disconnect screen). */
a.neon-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.neon-btn--accent {
  background: var(--accent2);
  color: #fff;
}

/* Lobby */
.lobby {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
.lobby-title {
  font-size: clamp(1.8rem, 6vw, 3rem);
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  text-transform: uppercase;
  letter-spacing: 4px;
  margin: 0;
}
.lobby-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}
.lobby-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.lobby-input {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 3px;
  padding: 12px 16px;
  width: 140px;
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font);
}
.lobby-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.lobby-status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
  max-width: 34rem;
}
.lobby-status.is-error {
  color: var(--danger);
}
.lobby-status.is-good {
  color: var(--good);
}

/* The lobby scrolls: the invite step is taller than a phone screen. The top
   padding clears the fixed portal link. */
.lobby {
  overflow-y: auto;
  justify-content: flex-start;
  padding-block: 56px 32px;
}
.lobby-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 30rem;
}

/* Invite / answer share blocks */
.share {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.share-label {
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 0.95rem;
}
.share-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}
.share-code {
  width: 100%;
  background: #0d0d0d;
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  padding: 10px;
  resize: vertical;
  word-break: break-all;
}
.share-code:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
/* Live camera preview while scanning a reply code. */
.scan-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}
.scan-video {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 16px var(--accent-glow);
  background: #000;
}

/* Install offer (lib/pwa.js fills [data-install-slot] when there is one). */
.install-slot {
  display: flex;
  justify-content: center;
}
.install-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.share-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
/* White quiet zone around the modules keeps the code scannable on the dark UI. */
/* As large as the screen sensibly allows: this code is read by someone else's
   camera across a table, and every extra pixel per module is the difference
   between a scan that lands and one that does not. */
.share-qr {
  width: min(340px, 88vw);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
  border-radius: 6px;
}
.peer-list {
  min-height: 1.5em;
  font-size: 0.9rem;
}
.peer {
  color: var(--good);
}
.peer-empty {
  color: var(--muted);
}

/* Overlay (game over / modal) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.8);
  text-align: center;
  padding: 24px;
  z-index: 10;
}
.overlay h1 {
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin: 0;
}
.overlay p {
  color: var(--muted);
  margin: 0;
}

/* Mobile-friendly: prevent pull-to-refresh / scroll jank on game canvases */
canvas {
  touch-action: none;
  display: block;
}

/* ── Party screen ─────────────────────────────────────────
   The roster and the game switcher. Rows collapse to a stacked layout on a
   phone, where the team buttons need the full width to stay tappable. */
.party-member {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 8px;
}
.party-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.party-tag {
  font-size: 0.65rem;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.party-tag.is-host {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
/*
  A bot reads as a player everywhere else in the roster, so the tag is the only
  thing that says otherwise. Magenta rather than the accent cyan: the host tag
  is already cyan, and the two sit side by side on the same row.
*/
.party-tag.is-bot {
  color: #f0f;
  border-color: #f0f;
  box-shadow: 0 0 8px rgba(255, 0, 255, 0.35);
}
.party-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.party-team,
.party-mini {
  font-family: var(--font);
  font-size: 0.65rem;
  letter-spacing: 1px;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.party-team.is-on {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}
.party-team:disabled {
  cursor: default;
  opacity: 0.7;
}
.party-mini.is-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.party-game {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: #fff;
  cursor: pointer;
}
.party-game:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.party-game:disabled {
  cursor: default;
  opacity: 0.55;
}
.party-game-name {
  color: var(--accent);
  letter-spacing: 2px;
  font-size: 0.9rem;
}
.party-game-blurb {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 4px;
}
.party-game-warn {
  color: var(--accent2);
  font-size: 0.75rem;
  margin-top: 6px;
}
