:root {
  --bg: #0f1115;
  --panel: #181b22;
  --text: #e8eaf0;
  --muted: #8b91a1;
  --accent: #7c5cff;
  --live: #e5484d;
  --border: #2a2f3a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
body.center { align-items: center; justify-content: center; padding: 16px; }
a { color: var(--muted); }
a:hover { color: var(--text); }
.muted { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button {
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
}
button:hover { filter: brightness(1.1); }
.error { color: var(--live); font-size: 14px; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.spacer { flex: 1; }
.badge {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge.live { background: var(--live); color: #fff; }
.badge.offline { background: var(--border); color: var(--muted); }

main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; min-height: 0; }
.player {
  position: relative;
  width: 100%;
  max-width: 1600px;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
video { width: 100%; height: 100%; display: block; background: #000; }
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  pointer-events: none;
}
.overlay[hidden], .unmute[hidden] { display: none; }
.unmute { position: absolute; top: 12px; left: 12px; }

/* ---------- watch page: video + chat side by side ---------- */
.pill {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}
main.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: stretch;
  justify-content: stretch;
}
.stage { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.viewers { padding: 12px 14px; border-bottom: 1px solid var(--border); max-height: 30%; overflow: auto; flex: none; }
.viewers h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.viewers ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.viewers li { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; font-size: 13px; }
.viewers li.streamer { border-color: var(--accent); color: #c9bcff; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#messages { flex: 1; list-style: none; margin: 0; padding: 10px 14px; overflow-y: auto; min-height: 0; overflow-wrap: anywhere; }
#messages li { padding: 3px 0; }
#messages time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#messages b.streamer { color: #c9bcff; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--accent); color: #fff; border-radius: 4px; padding: 0 5px; vertical-align: 1px; }
.chat-form { display: flex; gap: 8px; padding: 10px 14px 6px; border-top: 1px solid var(--border); }
.chat-form[hidden], .chat-status[hidden], .chat-as[hidden] { display: none; }
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; }
.chat-form button { padding: 8px 12px; }
.chat-status { margin: 0; padding: 6px 14px 0; font-size: 13px; color: var(--muted); }
.chat-as { margin: 0; padding: 0 14px 10px; font-size: 12px; color: var(--muted); }
.linkish { background: none; color: var(--muted); padding: 0; font-weight: 400; text-decoration: underline; font-size: 12px; }
.linkish:hover { color: var(--text); filter: none; }

@media (max-width: 900px) {
  html, body.watch { height: auto; }
  main.layout { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .player { max-height: none; }
  .side { height: 60vh; min-height: 320px; }
  .chat-form input { font-size: 16px; } /* stops iPhones zooming in */
}
header strong, header a, .pill, .badge { white-space: nowrap; }
@media (max-width: 520px) {
  header { gap: 8px; padding: 10px 12px; }
  header strong { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  header .muted { display: none; }
}
