:root {
  --bg: #0e1116;
  --panel: #171b22;
  --line: #2a313c;
  --fg: #e6eaf0;
  --dim: #98a2b3;
  --accent: #4ade80;
  --warn: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  /* iPad でのタップ操作用。長押しメニューやダブルタップ拡大が誤爆すると配信が乱れる */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.bar h1 { margin: 0; font-size: 17px; font-weight: 650; }
.hint { font-weight: 400; font-size: 13px; color: var(--dim); }

.stats { display: flex; gap: 14px; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--dim); }

main { max-width: 1100px; margin: 0 auto; padding: 18px; }

.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
  touch-action: manipulation;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(14, 17, 22, .82);
  padding: 20px;
  text-align: center;
}
.overlay[hidden] { display: none; }

.panel { max-width: 440px; }
.lead { margin: 0 0 6px; font-size: 16px; }
.sub { margin: 0 0 18px; font-size: 13px; color: var(--dim); }

button {
  font: inherit;
  color: var(--fg);
  background: #232a34;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #2b333f; }
button:disabled { opacity: .45; cursor: default; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06240f;
  font-weight: 650;
  padding: 11px 26px;
}
button.primary:hover:not(:disabled) { background: #6ee79a; }

.msg { margin: 14px 0 0; font-size: 13px; color: var(--warn); white-space: pre-wrap; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 14px 2px 0;
}
.ctl { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--dim); }
.ctl-range input { width: 130px; }
#blocks-val { font-variant-numeric: tabular-nums; width: 2ch; }

.note { color: var(--dim); font-size: 13px; border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }


/* ---- 配信モード：映像だけを画面いっぱいに出す ---------------------------
   iPad の画面共有では画面に映っているものがそのまま相手に見えるので、
   ヘッダも操作パネルも隠して canvas だけを残す。 */

.exit {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 3;
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(20, 24, 31, .55);
  border-color: rgba(255, 255, 255, .18);
  font-size: 16px;
  line-height: 1;
}
.exit[hidden] { display: none; }

body.present { background: #000; }
body.present .bar,
body.present .controls,
body.present .note { display: none; }
body.present main { max-width: none; margin: 0; padding: 0; }
body.present .stage {
  border: 0;
  border-radius: 0;
  aspect-ratio: auto !important;   /* JS が付ける inline の aspect-ratio を打ち消す */
  height: 100vh;
  height: 100dvh;
}

/* ---- 登録まわり ---- */

.enroll-bar { border-top: 1px solid var(--line); margin-top: 12px; }
.enroll-status { font-size: 13px; color: var(--dim); min-height: 1.6em; }

#enroll.armed {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #04212e;
  font-weight: 650;
}

.roster { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 2px 0; font-size: 13px; color: var(--dim); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border: 1px solid #38bdf8;
  border-radius: 999px;
  color: var(--fg);
}
.chip button {
  padding: 0;
  width: 20px; height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  line-height: 1;
}
.chip button:hover { background: rgba(255,255,255,.1); color: var(--fg); }

.note ol { margin: 6px 0 0; padding-left: 1.3em; }
.note li { margin: 3px 0; }
body.present .roster, body.present .enroll-bar { display: none; }
