:root {
  color-scheme: dark;
  --ink: #05090d;
  --panel: rgba(8, 16, 21, .94);
  --line: rgba(185, 222, 222, .24);
  --muted: #91a7ac;
  --text: #edf5f5;
  --cyan: #86dfe1;
  --gold: #e7c27a;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: transparent; }
body { color: var(--text); font-family: Arial, Helvetica, sans-serif; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
#view:focus-visible { outline: 2px solid var(--cyan); outline-offset: -5px; }

#title { position: fixed; z-index: 2; top: 22px; left: 50%; width: min(440px, calc(100% - 32px)); transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; transition: opacity .3s ease; text-shadow: 0 2px 16px #000; }
#title.show { opacity: 1; }
#title h1 { margin: 0; font-size: clamp(12px, 1.5vw, 17px); font-weight: 700; letter-spacing: .24em; }
#title p { margin: 6px 0 0; color: var(--cyan); font-size: 9px; letter-spacing: .2em; }

#hud { position: fixed; z-index: 3; top: 22px; left: clamp(104px, 7vw, 128px); width: min(300px, calc(100vw - 128px)); pointer-events: none; }
.wm-small { margin: 0 0 7px 3px; color: var(--cyan); font-size: 9px; font-weight: 700; letter-spacing: .19em; }
.panel { padding: 10px 12px; border: 1px solid var(--line); background: var(--panel); clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%); font-size: 11px; line-height: 1.65; }
.panel div { display: flex; justify-content: space-between; gap: 12px; }
.panel span { color: var(--muted); }
.panel b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

button { min-height: 44px; border: 1px solid var(--line); background: rgba(8, 16, 21, .94); cursor: pointer; transition: color .16s ease, border-color .16s ease, background-color .16s ease; }
button:hover { border-color: rgba(134, 223, 225, .75); color: var(--cyan); }
#pause { position: fixed; z-index: 4; left: 20px; bottom: 18px; width: 46px; font-size: 16px; }
#pause.active { border-color: var(--gold); color: var(--gold); }
#controls-btn { position: fixed; z-index: 4; right: 20px; bottom: 18px; min-width: 154px; padding: 0 18px; color: #071012; border-color: var(--cyan); background: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .17em; }
#controls-btn:hover, #controls-btn.active { color: #071012; background: #b1f2f1; }

#sheet { position: fixed; z-index: 5; right: 20px; bottom: 74px; width: min(370px, calc(100vw - 36px)); max-height: min(690px, calc(100dvh - 100px)); overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 14px; border: 1px solid rgba(134, 223, 225, .38); background: var(--panel); clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
#sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding-bottom: 11px; border-bottom: 1px solid var(--line); color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.sheet-head button { min-width: 44px; border-color: transparent; background: transparent; font-size: 22px; }
.row { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 11px; }
.row input[type="range"] { display: block; width: 100%; min-height: 28px; margin: 5px 0 0; accent-color: var(--cyan); }
.row b { float: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 7px; }
.modes button { min-width: 0; min-height: 50px; padding: 7px 9px; text-align: left; font-size: 11px; line-height: 1.3; }
.modes button small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.modes button.on { border-color: var(--cyan); background: rgba(134, 223, 225, .12); }
.toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; margin-top: 12px; }
.toggles label { min-width: 0; min-height: 38px; display: flex; align-items: center; gap: 8px; color: #d7e3e4; font-size: 10px; line-height: 1.3; }
.toggles input { width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--cyan); }
.note { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.5; }

@media (max-width: 767px) {
  #title { top: 15px; width: calc(100% - 88px); left: calc(50% + 30px); }
  #title h1 { font-size: 11px; letter-spacing: .15em; }
  #title p { margin-top: 4px; font-size: 8px; letter-spacing: .1em; }
  #hud { top: 68px; left: 12px; width: min(290px, calc(100vw - 24px)); }
  .wm-small { font-size: 8px; }
  .panel { padding: 8px 10px; font-size: 10px; }
  #pause { left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 44px; }
  #controls-btn { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); min-width: 136px; padding: 0 12px; font-size: 9px; }
  #sheet { right: 10px; bottom: calc(64px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 20px)); max-height: min(76dvh, 620px); padding: 13px 14px 12px; }
  .row { margin-top: 10px; }
  .modes button { min-height: 46px; }
  .toggles { gap: 0 7px; }
  .toggles label { font-size: 9px; }
}

@media (max-width: 380px) {
  #title { top: 17px; }
  #title p { display: none; }
  #hud { top: 55px; }
  .panel div { gap: 5px; }
  .panel { font-size: 9px; }
  #sheet { max-height: calc(100dvh - 92px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
