:root {
  --bg: #000;
  --panel: #111;
  --panel-2: #1a1a1a;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --accent: #ff4d3d;
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff4d3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Verdana, Geneva, Tahoma, sans-serif;
}

button, select, input {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 4px 10px; font-size: 13px; }

select, input[type="text"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}

.hidden { display: none !important; }

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

body.player {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 18px;
  line-height: 1.6;
  font-size: 15px;
  color: #ddd;
  background: rgba(0, 0, 0, 0.75);
}

#start-overlay { cursor: pointer; background: #000; }

.start-button {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.start-button::after {
  content: "";
  margin-left: 6px;
  border-style: solid;
  border-width: 16px 0 16px 26px;
  border-color: transparent transparent transparent #fff;
}

#waiting { background: #000; color: var(--muted); }

#controls {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  transition: opacity 0.4s;
}
#controls.idle { opacity: 0; pointer-events: none; }

#controls button {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
#controls svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#room-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 176, 32, 0.85);
  color: #000;
}

/* ---------- Internal pages (admin / publish) ---------- */

body.internal { min-height: 100vh; }

.internal header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.internal header h1 { font-size: 18px; margin: 0; margin-right: auto; }
.internal header a { color: var(--muted); text-decoration: none; font-size: 14px; }
.internal header a.current { color: var(--text); }

.internal main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.rooms { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.card h3 { font-size: 13px; color: var(--muted); font-weight: normal; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: 0.05em; }

.metric-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 28px; margin: 4px 0; font-variant-numeric: tabular-nums; }
.metric-sub { font-size: 12px; color: var(--muted); }
.metric-value.ok { color: var(--ok); }
.metric-value.warn { color: var(--warn); }
.metric-value.bad { color: var(--bad); }

canvas.spark { width: 100%; height: 44px; display: block; margin-top: 8px; }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill.live { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

table.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
table.kv td { padding: 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 42%; }
table.kv td:last-child { font-variant-numeric: tabular-nums; word-break: break-all; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

code.secret { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.notice { font-size: 13px; color: var(--muted); line-height: 1.6; }
.notice.warn { color: var(--warn); }
.error { color: var(--bad); font-size: 13px; }

.preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: contain;
}

@media (max-width: 600px) {
  .internal main { padding: 14px; }
  .grid.rooms { grid-template-columns: 1fr; }
}
