:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --text: #22201c;
  --muted: #77716a;
  --border: #ddd7ce;
  --accent: #b08a3a;
  --stage-bg: #111216;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --panel: #212228;
    --text: #ecebe8;
    --muted: #9b978f;
    --border: #36373f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Noto Sans KR", "Malgun Gothic", sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}

/* 무대 틀은 캔버스 크기에 딱 맞춘다. 틀이 캔버스보다 크면 위아래(또는 양옆)에 검은 띠가 생긴다.
   스크롤해도 무대가 보이게 위에 붙여 둔다. */
.stage-wrap {
  align-self: start;
  position: sticky;
  top: 16px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
}

#stage {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 32px);
  object-fit: contain;
  display: block;
}

.stage-wrap:fullscreen { border-radius: 0; cursor: pointer; background: #000; }
.stage-wrap:fullscreen #stage { max-height: 100vh; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 32px);
}

.panel h2 { font-size: 15px; margin: 20px 0 8px; }
.panel h3.sub { font-size: 13px; margin: 14px 0 4px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.buttons button { flex: 1; }

button {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
#play { background: var(--accent); border-color: var(--accent); color: #fff; }

.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.status { margin: 8px 0 0; font-weight: 600; }
.warn { margin: 6px 0 0; color: #c0392b; font-size: 12px; font-weight: 600; }
.panel select { max-width: 100%; }
button:disabled { opacity: 0.5; cursor: default; }

/* sticky도 녹화 중 표시(absolute)의 기준이 된다 */
.recording {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.line { border: 1px solid var(--border); border-radius: 6px; margin: 0 0 10px; padding: 8px 10px; }
.line textarea { width: 100%; resize: vertical; font: inherit; }
.line select { flex: 1; }

input[type="number"] { width: 58px; }
.seal-text { width: 44px; text-align: center; }
#sealRow[hidden] { display: none; }
input[type="color"] { width: 36px; height: 28px; padding: 0; border: none; background: none; }

/* ?t= 캡처 모드에서는 무대만 보이게 한다 */
body.capture .layout { display: block; padding: 0; }
body.capture .panel { display: none; }
body.capture .stage-wrap { border-radius: 0; }
body.capture #stage { max-height: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .panel { max-height: none; }
}

/* 연출 시간 슬라이더: 이름 · 슬라이더 · 지금 값 한 줄 */
.slider { display: grid; grid-template-columns: 112px 1fr 44px; align-items: center; gap: 8px; margin: 6px 0; }
.slider input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { gap: 4px; }
.seg-label { width: 112px; color: var(--text); }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span:not(.seg-label) { color: var(--text); display: block; text-align: center; padding: 6px 0; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* 설명은 툴팁(title)으로만 둔다. 제목 옆 「?」는 마우스를 올리면 설명이 뜬다는 표시 */
[title] { cursor: help; }
button[title], select[title], input[title] { cursor: pointer; }
.tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 600; margin-left: 4px; vertical-align: 1px; }
.muted { color: var(--muted); font-size: 12px; }
.note { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

/* 배경 투명을 켜면 무대 밑에 바둑판 무늬를 깔아 투명한 자리를 보여 준다 */
.stage-wrap.transparent #stage {
  background-color: #ffffff;
  background-image: linear-gradient(45deg, #d9d9d9 25%, transparent 25%), linear-gradient(-45deg, #d9d9d9 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9d9d9 75%), linear-gradient(-45deg, transparent 75%, #d9d9d9 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.stage-wrap.transparent:fullscreen #stage { background: none; }

/* hidden 속성이 display 규칙에 밀리지 않게 */
[hidden] { display: none !important; }

/* 수상자 목록 */
.roster { width: 100%; resize: vertical; font: inherit; }
.roster-nav { justify-content: space-between; }
.roster-nav button { width: 44px; }
.winner-now { flex: 1; text-align: center; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.three button { flex: 1; padding-left: 4px; padding-right: 4px; }
.roster.dragover { outline: 2px dashed var(--accent); outline-offset: 2px; }
