:root {
  --bg: #0b0b0f;
  --fg: #e7e7ea;
  --accent: #c11f3a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(12px, env(safe-area-inset-left)) 10px max(12px, env(safe-area-inset-right));
  background: #15151c;
}

.launch {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 0;
}

.launch input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  background: #0e0e14;
  color: var(--fg);
  font-size: 16px; /* >=16px avoids iOS zoom-on-focus */
}

.launch button {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid #2a2a35;
  border-radius: 10px;
  background: #0e0e14;
  color: var(--fg);
  font-size: 18px;
}
.icon-btn.off {
  opacity: 0.4;
}

/* --- comment list (non-danmaku feed below the player) --- */
.list-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
}
.clist {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  font-size: 14px;
  line-height: 1.45;
}
.clist[hidden] {
  display: none;
}
.clist-row {
  padding: 3px 0;
  border-bottom: 1px solid #15151c;
  word-break: break-word;
}
.clist-row.paid {
  background: #2a1f0a;
  border-radius: 6px;
  padding: 4px 6px;
}
.clist-author {
  font-weight: 700;
  margin-right: 7px;
}
.clist-text {
  color: #e7e7ea;
}

.perf {
  position: fixed;
  left: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 2147483647;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #7CFC8C;
  font: 11px/1.3 ui-monospace, monospace;
  pointer-events: none;
}

/* status badge overlaid on the stage (above the danmaku canvas) */
.status {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 2147483647;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #e7e7ea;
  font-size: 11px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* 16:9 stage; the YT IFrame fills it and the danmaku canvas overlays it. */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.stage > #player,
.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- settings sheet --- */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  max-height: 80vh;
  overflow-y: auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: #15151c;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
  z-index: 20;
  -webkit-overflow-scrolling: touch;
}
.sheet[hidden] {
  display: none;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  padding-bottom: 8px;
  background: #15151c;
}
.sheet-close {
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  background: #2a2a35;
  color: var(--fg);
}
.sheet-h {
  margin: 16px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9a9aa6;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}
.ctl-col {
  flex-direction: column;
  align-items: stretch;
}
.ctl-label {
  flex: 1;
  font-size: 14px;
}
.ctl input[type="range"] {
  flex: 1.2;
}
.ctl output {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #9a9aa6;
}
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.presets button {
  padding: 8px 12px;
  border: 1px solid #2a2a35;
  border-radius: 999px;
  background: #0e0e14;
  color: var(--fg);
}
.ng {
  width: 100%;
  padding: 8px;
  border: 1px solid #2a2a35;
  border-radius: 8px;
  background: #0e0e14;
  color: var(--fg);
  font: inherit;
  resize: vertical;
}
.ng-save {
  margin-top: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
