:root {
  --ink: #f1e9d6; --dim: rgba(241, 233, 214, .62); --faint: rgba(241, 233, 214, .32);
  --gold: #d9b56a; --line: rgba(217, 181, 106, .28); --glass: rgba(8, 11, 22, .62); --glass2: rgba(8, 11, 22, .82);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Noto Serif", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --cjk: "Hiragino Mincho ProN", "Songti TC", "Noto Serif CJK TC", "Source Han Serif TC", "Yu Mincho", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #04060d; color: var(--ink); font-family: var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#stage:active { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }

/* ---------- title ---------- */
#title { position: fixed; left: 28px; top: 22px; pointer-events: none; transition: opacity 1.2s; text-shadow: 0 1px 14px rgba(0, 0, 0, .7); }
#title h1 { margin: 0; font: 400 21px/1.2 var(--serif); letter-spacing: .04em; }
#title h1 span { color: var(--dim); }
#title p { margin: 5px 0 0; font: 400 12px/1.3 var(--cjk); letter-spacing: .14em; color: var(--dim); }
#title p i { color: var(--gold); font-style: normal; margin: 0 .3em; }

/* ---------- tools ---------- */
#tools { position: fixed; right: 22px; top: 18px; display: flex; gap: 8px; }
.tool { height: 36px; min-width: 36px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: grid; place-items: center; transition: background .2s, border-color .2s; }
.tool.wide { padding: 0 15px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
.tool:hover { background: rgba(24, 30, 52, .8); border-color: rgba(217, 181, 106, .6); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#btn-sound .wave { display: none; } #btn-sound.on .wave { display: inline; } #btn-sound.on .mute { display: none; }
#btn-sound.on { border-color: var(--gold); }
#viewmenu { position: fixed; right: 22px; top: 62px; width: 232px; background: var(--glass2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index: 30; max-height: calc(100vh - 150px); overflow: auto; }
#viewmenu h3 { margin: 8px 10px 4px; font: 400 10px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
#viewmenu button { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
#viewmenu button:hover { background: rgba(217, 181, 106, .14); }
#viewmenu button span { font-family: var(--cjk); color: var(--dim); font-size: 12px; }

/* ---------- modes ---------- */
#modes { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 20; max-width: calc(100vw - 20px); }
#modes button { padding: 8px 15px; border-radius: 18px; font-size: 12.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); white-space: nowrap; transition: background .25s, color .25s; }
#modes button:hover { color: var(--ink); }
#modes button.on { background: rgba(217, 181, 106, .2); color: #fff3d6; }
#modes button.tour { margin-left: 6px; border-left: 1px solid var(--line); border-radius: 0 18px 18px 0; padding-left: 17px; }
#modes button.tour.on { border-radius: 18px; border-left-color: transparent; }
#hint { position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%); margin: 0; font-size: 12.5px; letter-spacing: .06em; color: var(--dim); text-shadow: 0 1px 8px #000; pointer-events: none; transition: opacity 1.4s; white-space: nowrap; }
#hint.gone { opacity: 0; }

/* ---------- labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; opacity: 0; transition: opacity .35s; will-change: transform; text-shadow: 0 1px 6px rgba(0, 0, 0, .95), 0 0 16px rgba(0, 0, 0, .7); padding: 3px 6px; }
.label.show { opacity: 1; }
.label:not(.show) { pointer-events: none; }
.label .t { font: 400 13px/1.15 var(--serif); letter-spacing: .03em; white-space: nowrap; }
.label .s { font: 400 10.5px/1.25 var(--cjk); color: var(--dim); letter-spacing: .1em; white-space: nowrap; }
.label::after { content: ""; width: 1px; height: 14px; margin-top: 3px; background: linear-gradient(var(--gold), transparent); }
.label.major .t { font-size: 15px; }
.label.minor .t { font-size: 11.5px; color: var(--dim); }
.label.cap::after { display: none; }
.label.cap { align-items: flex-start; }
.label.cap::before { content: ""; position: absolute; left: -4px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.label:hover .t { color: #ffe9b0; }
.label b { font-weight: 400; color: var(--gold); margin-right: .35em; font-size: .85em; }

/* ---------- info panel ---------- */
#panel { position: fixed; right: 22px; top: 76px; width: 326px; max-height: calc(100vh - 180px); overflow: auto; background: var(--glass2); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px 18px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); z-index: 25; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
#panel .close, #about .close { position: absolute; right: 10px; top: 8px; width: 30px; height: 30px; font-size: 22px; line-height: 1; color: var(--dim); border-radius: 50%; }
#panel .close:hover, #about .close:hover { color: var(--ink); background: rgba(255, 255, 255, .08); }
#panel .kicker { margin: 0 0 6px; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
#panel h2 { margin: 0 26px 12px 0; font: 400 21px/1.2 var(--serif); letter-spacing: .01em; }
#panel dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 13px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#panel dt { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); align-self: center; }
#panel dd { margin: 0; font: italic 400 14.5px/1.3 var(--serif); }
#panel dd.zh { font: 400 15px/1.3 var(--cjk); letter-spacing: .08em; }
#panel .text { margin: 0 0 12px; font: 400 14.5px/1.55 var(--serif); color: #ece4d0; }
#panel .basis { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--dim); padding-left: 10px; border-left: 2px solid var(--line); }

/* ---------- tour ---------- */
#tour { position: fixed; left: 50%; bottom: calc(78px + var(--safe-b)); transform: translateX(-50%); width: min(600px, calc(100vw - 28px)); background: var(--glass2); border: 1px solid var(--line); border-radius: 14px; padding: 16px 22px 12px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); z-index: 26; overflow: hidden; }
#tour .bar { position: absolute; left: 0; top: 0; right: 0; height: 2px; background: rgba(255, 255, 255, .06); }
#tour .bar i { display: block; height: 100%; width: 0; background: var(--gold); }
#tour .step { margin: 0 0 4px; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
#tour h2 { margin: 0 0 6px; font: 400 20px/1.2 var(--serif); }
#tour .text { margin: 0 0 10px; font: 400 14.5px/1.55 var(--serif); color: #ece4d0; min-height: 4.4em; }
#tour .nav { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; }
#tour .nav button { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding: 6px 8px; border-radius: 6px; }
#tour .nav button:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
#tour .nav button:disabled { opacity: .3; pointer-events: none; }
body.touring #hint { opacity: 0; }
@media (min-width: 1000px) { #tour { left: 28px; bottom: 26px; transform: none; width: 410px; } }

/* ---------- about ---------- */
#about { position: fixed; inset: 0; background: rgba(2, 3, 8, .66); display: grid; place-items: center; z-index: 50; padding: 18px; animation: fade .3s; }
#about[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
#about .sheet { position: relative; width: min(680px, 100%); max-height: min(82vh, 760px); overflow: auto; background: #0a0e1b; border: 1px solid var(--line); border-radius: 16px; padding: 30px 34px 26px; }
#about h2 { margin: 0 0 18px; font: 400 25px/1.2 var(--serif); }
#about h3 { margin: 20px 0 6px; font: 400 10.5px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
#about p { margin: 0; font: 400 14.5px/1.6 var(--serif); color: #e6dec9; }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 60%, #0c1226 0%, #04060d 70%); display: grid; place-items: center; z-index: 100; transition: opacity 1.6s ease .2s, visibility 0s 1.9s; }
body:not(.loading) #loader { opacity: 0; visibility: hidden; }
#loader .inner { text-align: center; }
#loader .zh { margin: 0 0 10px; font: 400 15px/1 var(--cjk); letter-spacing: .5em; text-indent: .5em; color: var(--gold); }
#loader h1 { margin: 0; font: 400 40px/1.1 var(--serif); letter-spacing: .06em; }
#loader .sub { margin: 8px 0 30px; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--dim); }
#loader .track { width: 220px; height: 1px; background: rgba(255, 255, 255, .12); margin: 0 auto 14px; }
#loader .track i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
#loader .msg { margin: 0; font-size: 12px; color: var(--faint); letter-spacing: .08em; }
body.loading #title, body.loading #tools, body.loading #modes, body.loading #hint { opacity: 0; }
#tools, #modes { transition: opacity 1.2s; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  #title { left: 14px; top: 12px; max-width: calc(100vw - 170px); }
  #title h1 { font-size: 16px; } #title h1 span { display: block; font-size: 12px; margin-top: 2px; }
  #title p { display: none; }
  #tools { right: 10px; top: 10px; gap: 5px; }
  .tool { height: 34px; min-width: 34px; } .tool.wide { padding: 0 11px; font-size: 11px; }
  #viewmenu { right: 10px; top: 52px; }
  #modes { bottom: calc(10px + var(--safe-b)); overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  #modes::-webkit-scrollbar { display: none; }
  #modes button { padding: 9px 9px; font-size: 10.5px; letter-spacing: .05em; }
  #modes button.tour { margin-left: 3px; padding-left: 11px; }
  .wide-only { display: none; }
  #hint { bottom: calc(62px + var(--safe-b)); font-size: 11px; white-space: normal; text-align: center; width: calc(100vw - 30px); }
  #panel { left: 8px; right: 8px; top: auto; bottom: calc(62px + var(--safe-b)); width: auto; max-height: 42vh; padding: 16px 18px 14px; }
  #panel h2 { font-size: 18px; } #panel .text { font-size: 13.5px; }
  #tour { bottom: calc(62px + var(--safe-b)); padding: 14px 16px 10px; }
  #tour h2 { font-size: 17px; } #tour .text { font-size: 13.5px; min-height: 0; }
  #about .sheet { padding: 24px 20px 20px; }
  .label .t { font-size: 11.5px; } .label.major .t { font-size: 13px; } .label .s { font-size: 9.5px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
