:root {
  --stage: #1b2533;
  --panel: rgba(250, 249, 244, 0.88);
  --ink: #1b2533;
  --muted: #566274;
  --line: rgba(27, 37, 51, 0.16);
  --accent: #c93a1e;
  --accent-text: #a8301a;
  --focus: #1592b0;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --panel: rgba(24, 33, 46, 0.86);
    --ink: #f3f1ea;
    --muted: #a9b4c3;
    --line: rgba(243, 241, 234, 0.18);
    --accent: #d2432a;
    --accent-text: #ff9a80;
    --focus: #3fd4f2;
  }
}
:root[data-theme="dark"] {
  --panel: rgba(24, 33, 46, 0.86);
  --ink: #f3f1ea;
  --muted: #a9b4c3;
  --line: rgba(243, 241, 234, 0.18);
  --accent: #d2432a;
  --accent-text: #ff9a80;
  --focus: #3fd4f2;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--stage); color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
#stage { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#feed { position: fixed; bottom: 0; right: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }

.sheet {
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(8, 14, 24, 0.3);
}
#start {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: min(31rem, calc(100% - 28px));
  border-radius: 24px; padding: 20px 22px 18px;
}
h1 {
  font-family: "Gochi Hand", "Comic Sans MS", cursive;
  font-weight: 400; font-size: clamp(2.4rem, 9vw, 3.3rem); line-height: 1;
  margin: 0 0 0.4rem;
}
#start p.lede { margin: 0 0 1rem; line-height: 1.45; color: var(--muted); max-width: 60ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  font: inherit; font-weight: 700; font-size: 1rem;
  min-height: 44px; padding: 0.6rem 1.1rem; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent; color: var(--ink); cursor: pointer;
}
button:hover { border-color: var(--ink); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#status { margin: 0.8rem 0 0; font-size: 0.92rem; line-height: 1.4; color: var(--muted); min-height: 1.3em; }
#status.error { color: var(--accent-text); }

#tune {
  position: fixed; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--panel);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
#hud {
  position: fixed; left: 12px; top: calc(12px + env(safe-area-inset-top, 0px));
  padding: 6px 10px; border-radius: 10px;
  font-size: 0.78rem; line-height: 1.4; white-space: pre; font-variant-numeric: tabular-nums;
  background: rgba(15, 22, 32, 0.58); color: #f3f1ea; pointer-events: none;
}
#panel {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: min(26rem, calc(100% - 24px)); max-height: calc(100% - 90px); overflow: auto;
  border-radius: 22px; padding: 16px 18px 14px;
}
#panel h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
.toggle { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.4rem 0; cursor: pointer; line-height: 1.35; }
.toggle input { width: 1.2rem; height: 1.2rem; margin: 0.1rem 0 0; accent-color: var(--accent); flex: none; }
.hint { display: block; font-size: 0.82rem; color: var(--muted); }
.range { padding: 0.5rem 0 0.2rem; }
.range label { display: block; font-weight: 700; font-size: 0.95rem; }
.range input { width: 100%; margin: 0.35rem 0 0.1rem; accent-color: var(--accent); }
.range input:disabled { opacity: 0.4; }
.ends { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }
.panel-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 0.9rem; }
