/* Watch page — code entry inherits the site tokens (light/dark aware);
   the live game view is always dark, matching the apps' in-game screen. */

/* Sections toggle via the `hidden` attribute; explicit display values below
   (flex/inline-block) would otherwise override the UA's display:none. */
[hidden] {
  display: none !important;
}

.watch-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.watch-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ---------- Code entry ---------- */

.watch-entry {
  text-align: center;
  max-width: 420px;
  width: 100%;
}

#code-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}

#code-input {
  width: 9ch;
  padding: 12px 14px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}

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

#watch-btn {
  padding: 12px 22px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

#watch-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.entry-error {
  margin-top: 16px;
  color: #ff3b30;
  font-size: 15px;
}

.entry-footer {
  margin-top: 32px;
  color: var(--text-muted);
}

/* ---------- Live game ---------- */

.watch-game {
  /* Fixed dark surface — video UI, same look in light and dark. */
  --game-bg: #0b0b0b;
  --game-card: #161616;
  --game-text: #f5f5f5;
  --game-muted: #b9b9b9;
  --game-border: rgba(255, 255, 255, 0.12);

  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--game-bg);
  color: var(--game-text);
  padding: 16px;
  gap: 12px;
}

.game-header {
  text-align: center;
}

.game-header h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.phase-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.phase-pill,
.timer-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: var(--game-card);
  border: 1px solid var(--game-border);
}

/* Phase colors mirror LobbyPhase.color in the apps. */
.phase-pill[data-phase="open"]        { color: #34c759; border-color: #34c759; }
.phase-pill[data-phase="preparation"] { color: #ff9500; border-color: #ff9500; }
.phase-pill[data-phase="skating"]     { color: #32ade6; border-color: #32ade6; }
.phase-pill[data-phase="voting"]      { color: #af52de; border-color: #af52de; }
.phase-pill[data-phase="result"]      { color: #ffcc00; border-color: #ffcc00; }
.phase-pill[data-phase="final"]       { color: #ff3b30; border-color: #ff3b30; }

.context-line {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--game-muted);
  min-height: 1.2em;
}

/* Tiles must never dictate the layout height — the game view is a fixed,
   non-scrolling surface. Rows split whatever height is available
   (minmax(0,1fr)) and the video crops to fit via object-fit: cover. The
   max-width keeps tiles from getting absurdly wide on desktop. */
.video-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
}

.video-tile {
  position: relative;
  min-height: 0;
  background: var(--game-card);
  border: 1px solid var(--game-border);
  border-radius: 12px;
  overflow: hidden;
}

.video-tile.active {
  border: 2px solid var(--accent);
}

/* Player is in the game but their camera is off — same slot, skateboard
   placeholder instead of video (mirrors the apps' camera-off tile). */
.video-tile.placeholder::before {
  content: "🛹";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 42px;
  opacity: 0.45;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-tile .tile-name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 12px;
  font-weight: 600;
}

.video-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--game-muted);
  font-size: 15px;
}

/* ---------- Player strip ---------- */

.player-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  justify-content: safe center;
}

.player-chip {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--game-card);
  border: 1px solid var(--game-border);
  border-radius: 12px;
  min-width: 92px;
}

.player-chip.active {
  border-color: var(--accent);
}

.player-chip.eliminated {
  opacity: 0.45;
}

.player-chip .chip-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-letters {
  display: flex;
  gap: 3px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
}

.chip-letters span       { color: rgba(255, 255, 255, 0.22); }
.chip-letters span.lit   { color: #ff3b30; }

/* Trick setter — same yellow as the apps' star.fill. */
.chip-star { color: #ffcc00; }

/* ---------- Overlay + audio ---------- */

.unmute-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.game-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
}

.overlay-card {
  text-align: center;
  background: #161616;
  color: #f5f5f5;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 32px 40px;
  max-width: 90vw;
}

.overlay-card h2 { margin: 0 0 8px; }
.overlay-card p  { margin: 0 0 16px; color: #b9b9b9; }

.overlay-card button {
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

@media (max-width: 480px) {
  .video-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}
