:root {
  color-scheme: dark;
  --bg: #0e0d12;
  --bg-2: #17161c;
  --line: #34313b;
  --text: #c8c6ce;
  --strong: #f3f1f6;
  --muted: #8e8b96;
  --brass: #c6a36a;
  --brass-ink: #24190e;
  --danger: #f3ecee;
  --fs: 17px;
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

html[data-font="s"] { --fs: 15px; }
html[data-font="m"] { --fs: 17px; }
html[data-font="l"] { --fs: 20px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: 1.65;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

#app {
  width: min(430px, 100%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 18px 10px;
  background:
    radial-gradient(120% 40% at 50% -10%, rgba(198, 163, 106, 0.08), transparent 50%),
    var(--bg);
}

.top {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.top-mark {
  margin-right: auto;
  width: 36px;
  height: 1px;
  background: var(--brass);
  opacity: 0.7;
}

#btn-stop {
  min-height: 48px;
  min-width: 96px;
  opacity: 1;
  background: #2a262c;
  color: var(--danger);
  border: 1px solid #ddd6da;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
}

#btn-stop:disabled {
  opacity: 1;
  background: #2a262c;
  color: var(--danger);
  border-color: #ddd6da;
}

#stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#dock {
  min-height: 33vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 0 8px;
}

h1, h2, p { margin: 0; }

h1 {
  color: var(--strong);
  font-size: 1.55rem;
  font-weight: 560;
  letter-spacing: 0.08em;
  line-height: 1.35;
}

h2 {
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--strong);
}

.eyebrow {
  color: var(--brass);
  letter-spacing: 0.22em;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.tuner, .night-label, .remain {
  color: var(--muted);
}

.waiting {
  color: var(--strong);
  font-size: 1.05rem;
}

.note, .status, .error { color: var(--muted); font-size: 0.92rem; }
.error { color: #e0b4b4; }

.caption {
  min-height: 4.5em;
  color: var(--strong);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.peek { color: var(--brass); font-size: 0.92rem; }

.legal {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding-top: 8px;
}

.legal p { margin: 0; }

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

button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--strong);
  padding: 10px 14px;
  text-align: center;
}

button:disabled { color: var(--muted); }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

#dock > button { width: 100%; }

#dock > button:first-child:not(.ghost):not(.secondary),
#btn-begin,
#names-next,
#sleep-begin,
#confirm {
  background: var(--brass);
  color: var(--brass-ink);
  border-color: transparent;
  font-weight: 650;
}

#dock > #btn-begin:disabled,
#dock > #names-next:disabled,
#dock > #sleep-begin:disabled,
#dock > #confirm:disabled,
#btn-begin:disabled,
#names-next:disabled,
#sleep-begin:disabled,
#confirm:disabled {
  background: #24222a;
  color: #6f6c76;
  border-color: var(--line);
}

.ghost { background: transparent; }

.secondary { min-width: 112px; }

.stack, .choices, .cards, .transport {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choices, .transport { flex-direction: row; flex-wrap: wrap; }
.choices > button, .transport > button, .cards > button { flex: 1 1 30%; }

.card.is-lit {
  border-color: var(--brass);
  box-shadow: inset 0 0 0 1px var(--brass), 0 0 24px rgba(198, 163, 106, 0.18);
  color: var(--strong);
}

.is-signal {
  border-color: var(--brass);
  color: var(--brass);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.check input { width: 22px; height: 22px; accent-color: var(--brass); }

.row, .slider, .grow { display: flex; flex-direction: column; gap: 6px; }
.row { flex-direction: row; align-items: flex-end; }

input[type="text"], input:not([type]), #tuner, #set-tuner {
  min-height: 48px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #120f16;
  padding: 0 12px;
  color: var(--strong);
}

input[type="range"] { width: 100%; accent-color: var(--brass); }

.wave-wrap {
  height: 150px;
  color: var(--brass);
  border-bottom: 1px solid var(--line);
}

#wave, .wave-wrap svg { width: 100%; height: 150px; display: block; }

.rail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.rail span {
  text-align: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.rail span[aria-current="step"] {
  color: var(--strong);
  border-top-color: var(--brass);
}

.words { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.words li {
  min-height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px dashed var(--line);
}
.words li.is-cleared { color: var(--muted); text-decoration: line-through; }

.timebar {
  height: 3px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.timebar span {
  display: block;
  height: 100%;
  background: var(--brass);
  transform-origin: left center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

legend { color: var(--muted); font-size: 0.85rem; }

[hidden] { display: none !important; }

@media (min-width: 840px) {
  body { align-items: stretch; }
  #app { border-left: 1px solid #221f27; border-right: 1px solid #221f27; }
}

@media (prefers-reduced-motion: reduce) {
  #wave-line { display: none; }
}
