:root {
  color-scheme: dark;
  --ink: #e5e6ed;
  --dim: #a1aaba;
  --line: rgba(200, 215, 232, .18);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --edge: clamp(24px, 4vw, 64px);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #080e1b; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid #d1c3a5; outline-offset: 5px; }
button:disabled { cursor: not-allowed; }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
.hud { position: fixed; z-index: 10; user-select: none; transition: opacity .5s ease, visibility .5s; }
body.ui-hidden .hud { opacity: 0; visibility: hidden; pointer-events: none; }
.hud-tl { top: max(var(--edge), env(safe-area-inset-top)); left: max(var(--edge), env(safe-area-inset-left)); pointer-events: none; }
.eyebrow { display: block; font: 400 9px/1.4 var(--mono); letter-spacing: .25em; color: var(--dim); }
.hud-tl h1 { margin: 16px 0 14px; font: 400 clamp(30px, 3vw, 40px)/1.15 var(--serif); letter-spacing: .24em; color: #efede7; text-shadow: 0 2px 20px #080e1b; }
.hud-tl > p { font: 400 9px/1.4 var(--mono); letter-spacing: .22em; color: var(--dim); }
.motion-toggle { right: var(--edge); top: calc(var(--edge) - 12px); min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid #c8d7e817; border-radius: 30px; background: #09111f45; color: #b4becb; font-size: 11px; letter-spacing: .15em; }
.status-dot { width: 4px; height: 4px; border-radius: 50%; background: #bcbfae; box-shadow: 0 0 9px #bcbfae66; }
.motion-toggle[aria-pressed="true"] .status-dot { background: transparent; border: 1px solid #a1aaba; box-shadow: none; }
.shore-caption { left: var(--edge); bottom: max(32px, env(safe-area-inset-bottom)); pointer-events: none; }
.shore-caption p { font: 400 18px/1.6 var(--serif); letter-spacing: .17em; color: #d3d5d8; }
.shore-caption > span { display: block; margin-top: 9px; font: 400 8px/1.5 var(--mono); letter-spacing: .22em; color: #929eae; }

/* One quiet control rail, with visible names and generous touch targets. */
.dock { bottom: max(28px, env(safe-area-inset-bottom)); right: var(--edge); display: flex; align-items: center; padding: 3px 7px; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: rgba(7, 15, 27, .66); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.dock button { position: relative; min-width: 57px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 4px; background: transparent; color: #aeb8c8; font-size: 11px; letter-spacing: .08em; transition: background .2s, color .2s; }
.dock button:hover, .dock button[aria-expanded="true"] { background: #b8c9e510; color: #f0ede6; }
.dock button[aria-pressed="true"] { color: #e0cbaa; }
.dock button[aria-pressed="true"]::after { content: ""; position: absolute; width: 12px; height: 1px; bottom: 6px; left: calc(50% - 6px); background: #d8c49e; }
.dock button.empty { opacity: .6; }
#restore-ui { position: fixed; z-index: 12; right: var(--edge); bottom: max(28px, env(safe-area-inset-bottom)); min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 6px; color: #b4becb; background: #080e1b80; font-size: 11px; letter-spacing: .12em; opacity: .45; transition: opacity .2s; }
#restore-ui:hover, #restore-ui:focus-visible { opacity: 1; }

.panel { position: fixed; z-index: 11; right: var(--edge); bottom: calc(max(28px, env(safe-area-inset-bottom)) + 66px); width: 306px; max-height: calc(100dvh - 150px); overflow-y: auto; padding: 24px; background: rgba(9, 17, 31, .94); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: 0 16px 48px #02060c55; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin: -8px -8px 8px 0; }
.panel h2 { font: 400 20px/1.4 var(--serif); letter-spacing: .1em; }
.panel-close { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--dim); font-size: 11px; }
.panel-kicker { font: 9px/1.5 var(--mono); letter-spacing: .2em; color: #8997ac; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0 12px; }
.presets button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; border: 1px solid var(--line); border-radius: 5px; background: #ffffff03; color: #c3cad5; font-size: 11px; }
.presets button:hover { border-color: #b9c4d377; }
.presets button[aria-pressed="true"] { border-color: #a8adc1; background: #cbd0e00d; }
.swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--swatch); }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: #bec7d4; padding: 12px 0; border-bottom: 1px solid #b4c5de10; cursor: pointer; }
.panel input[type="color"] { width: 40px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer; }
.panel input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.panel input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.panel > button { margin-top: 18px; width: 100%; min-height: 44px; border: 1px solid var(--line); color: #c6ccda; background: transparent; font-size: 11px; letter-spacing: .1em; border-radius: 5px; }
.panel > button:hover { border-color: #a8adc1; }
.panel .hint { margin-top: 14px; font: 10px/1.8 -apple-system, "PingFang SC", sans-serif; color: #97a4b8; }
.panel.locked label, .panel.locked > button, .panel.locked .presets { opacity: .45; }
.panel.locked input[type="color"] { cursor: not-allowed; }
.panel.locked .hint { color: #c9b798; }
#notice { position: fixed; z-index: 20; left: 50%; bottom: 108px; transform: translateX(-50%); max-width: calc(100vw - 40px); padding: 12px 18px; background: #0b1526ed; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; color: #d0d6e0; opacity: 0; pointer-events: none; transition: opacity .25s; }
#notice.visible { opacity: 1; }

#loader { position: fixed; inset: 0; z-index: 40; background: #080e1b; display: flex; flex-direction: column; gap: 24px; align-items: center; justify-content: center; }
#loader p { font: 24px/1.4 var(--serif); letter-spacing: .3em; color: #d4d4d8; }
#loader > span { font: 9px/1.5 var(--mono); letter-spacing: .24em; color: var(--dim); }
#loader .spin { width: 30px; height: 30px; border: 1px solid #bec8dd20; border-top-color: #b4becb; border-radius: 50%; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#overlay { position: fixed; inset: 0; z-index: 50; background: #080e1bf5; display: flex; align-items: center; justify-content: center; }
.ov-box { text-align: center; max-width: 420px; padding: 34px; }
.ov-box h2 { font-size: 16px; letter-spacing: .15em; color: #ddc5a5; margin-bottom: 12px; }
.ov-box p { font-size: 13px; line-height: 1.8; color: var(--dim); margin-bottom: 20px; }
.ov-box button { background: none; border: 1px solid var(--line); color: var(--ink); font-size: 12px; padding: 14px 26px; border-radius: 5px; }
@media (max-width: 640px) {
  :root { --edge: 24px; }
  .hud-tl h1 { margin-top: 12px; font-size: 30px; }
  .eyebrow { font-size: 8px; }
  .motion-toggle { font-size: 10px; }
  .shore-caption { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 78px); }
  .shore-caption p { font-size: 16px; }
  .shore-caption > span { font-size: 7px; margin-top: 6px; }
  .dock { left: var(--edge); right: var(--edge); bottom: max(22px, env(safe-area-inset-bottom)); justify-content: space-between; }
  .dock button { flex: 1; min-width: 0; padding: 0 8px; }
  .panel { left: var(--edge); right: var(--edge); width: auto; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 66px); }
  body:has(.panel:not([hidden])) .shore-caption { opacity: 0; }
}
@media (max-height: 500px) {
  .eyebrow, .shore-caption > span { display: none; }
  .hud-tl { top: 20px; }
  .hud-tl h1 { font-size: 26px; margin: 0 0 8px; }
  .shore-caption { bottom: 26px; }
  .panel { max-height: calc(100dvh - 110px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
