:root {
  --bg: #000;
  --fg: #fff;
  --muted: #6b6b6b;
  --line: #222;
  --surface: #111;
  --accent: #ccff4d;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hint {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 48px));
  margin: 0;
  text-align: center;
  font-size: 17px;
  line-height: 1.45;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.corner {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
  transition: opacity 0.2s ease;
}
.corner-left { left: calc(16px + env(safe-area-inset-left)); pointer-events: none; }
.corner-right { right: calc(12px + env(safe-area-inset-right)); }

.gear {
  padding: 8px;
  margin: -8px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: block;
}
.gear svg { display: block; }

/* While fingers are down, everything except the canvas gets out of the way. */
body.playing .hint,
body.playing .corner { opacity: 0; pointer-events: none; }

/* ---------- Settings panel ---------- */

.settings {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  animation: slide-up 0.22s ease-out;
}
.settings[hidden] { display: none; }

@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.settings-head h1 { margin: 0; font-size: 17px; font-weight: 600; }

.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  padding: 6px 0 6px 12px;
  cursor: pointer;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.settings h2 {
  margin: 26px 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface);
  border-radius: 10px;
}
.segmented button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 9px 6px;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--accent); color: #000; font-weight: 600; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}
.row.column { flex-direction: column; align-items: stretch; justify-content: center; gap: 6px; padding: 10px 0; }
.row-line { display: flex; justify-content: space-between; align-items: center; }
.row[hidden] { display: none; }

.label { flex: 1; font-size: 16px; }
.label.big { flex: 0 0 auto; min-width: 40px; font-size: 22px; font-weight: 700; }
.value { font-size: 16px; font-variant-numeric: tabular-nums; }
.dim { color: var(--muted); flex: 1; text-align: right; }

.note { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper output { min-width: 32px; text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; }

input[type="range"] {
  width: 100%;
  margin: 6px 0;
  accent-color: var(--accent);
  touch-action: pan-x;
}

.toggle { cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: #333;
  transition: background 0.2s;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(20px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--fg); outline-offset: 2px; }

.mini-toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.mini-toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.levels.off { opacity: 0.35; pointer-events: none; }

.reset-btn {
  display: block;
  width: 100%;
  margin-top: 32px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.footer { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

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