:root {
  --ink: #f6ece2;
  --ink-dim: rgba(246, 236, 226, 0.72);
  --glass: rgba(16, 13, 20, 0.62);
  --edge: rgba(255, 255, 255, 0.18);
  --ui-tint: #47283f;
  --accent: #f2a764;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c0a10; color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }

.glass {
  background: linear-gradient(160deg, color-mix(in srgb, var(--ui-tint) 30%, transparent), var(--glass));
  border: 1px solid var(--edge);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border-radius: 18px;
}
.pill { border-radius: 999px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.title { position: fixed; top: 16px; left: 16px; padding: 10px 16px 11px; }
.title h1 { margin: 0; font-size: 17px; letter-spacing: 0.01em; }
.title p { margin: 2px 0 0; font: 500 11.5px ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink-dim); }

button, .seg span { font: inherit; color: var(--ink); }
button.pill { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--edge); padding: 7px 14px; cursor: pointer; }
button.pill:hover { background: rgba(255, 255, 255, 0.16); }
button[aria-pressed="true"]#debugBtn { background: rgba(255, 255, 255, 0.22); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel-btn { position: fixed; top: 16px; right: 16px; padding: 9px 16px; }
.panel { position: fixed; top: 66px; right: 16px; width: 292px; max-height: calc(100vh - 190px); overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 12px; display: none; }
.panel.open { display: block; }
fieldset { border: 0; margin: 0 0 12px; padding: 0; }
legend, .row { font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; padding: 0; }
.row { display: flex; justify-content: space-between; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); font-size: 12.5px; }
.legend-note { opacity: 0.7; margin-left: 4px; }
.seg small { opacity: 0.7; font-size: 10.5px; }
.seg input:checked + span { background: var(--ink); color: #141018; border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0 0 12px; }
.btns { display: flex; gap: 8px; }
.hint { margin: 10px 0 0; font-size: 11.5px; color: var(--ink-dim); }

.debug { position: fixed; left: 16px; top: 84px; margin: 0; padding: 10px 14px; font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre; border-radius: 12px; pointer-events: none; }

.timebar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(620px, calc(100% - 32px)); padding: 10px 22px 8px; }
.readout { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
#clock { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink-dim); }
.timebar input { margin: 2px 0 0; }
.marks { position: relative; height: 22px; }
.marks button { position: absolute; transform: translateX(-50%); background: none; border: 0; padding: 2px 4px; font-size: 11.5px; color: var(--ink-dim); cursor: pointer; white-space: nowrap; }
.marks button:first-child { transform: none; left: -4px !important; }
.marks button:last-child { transform: translateX(-100%); left: calc(100% + 4px) !important; }
.marks button:hover { color: var(--ink); }

.fallback { display: none; position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 18px 22px; max-width: 320px; text-align: center; }
.no-webgl .fallback { display: block; }

@media (max-width: 719px) {
  .panel { top: 64px; left: 16px; right: 16px; width: auto; max-height: calc(100vh - 210px); }
  .title { padding: 8px 12px; }
  .title h1 { font-size: 15px; }
  .debug { top: auto; bottom: 120px; }
  .marks button { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
