:root {
  --ink: #17161a;
  --ink-2: #4a4750;
  --ink-3: #8c8893;
  --paper: rgba(250, 247, 241, 0.86);
  --paper-solid: #faf7f1;
  --line: rgba(23, 22, 26, 0.09);
  --red: #d2402c;
  --gold: #f2b234;
  /* 不用宋体：标题也用无衬线，靠字重区分层级 */
  --serif: -apple-system, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  --sans: -apple-system, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dfd0; color: var(--ink); font-family: var(--sans); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ---------- 加载：一根荧光棒随进度被勾出来，完成时点亮 ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; text-align: center; gap: 18px;
  background: var(--ld-bg); color: #fff; transition: opacity 1s var(--ease), visibility 1s;
  /* 背景候选（?ld=a|b|c 对比）：都是干净的饱和暖色，白光才托得出来 */
  --ld-bg: linear-gradient(165deg, #ffd3b8 0%, #f6a383 55%, #ee8a72 100%);
}
#loading[data-ld=b] { --ld-bg: linear-gradient(180deg, #f7b98f 0%, #d9768a 52%, #7a4f93 100%); }
#loading[data-ld=c] { --ld-bg: linear-gradient(165deg, #e46a4c 0%, #c8402a 60%, #a9301f 100%); }
#loading.done { opacity: 0; visibility: hidden; }
.ld-stage { position: relative; width: 160px; height: 320px; zoom: .42; transform-origin: 24px 256px; animation: ld-wave 1.5s ease-in-out infinite alternate; }
/* 像在看台上挥荧光棒：以握柄末端为轴左右摆 */
@keyframes ld-wave { 0% { transform: rotate(-9deg); } 100% { transform: rotate(9deg); } }
.ld-stick { position: relative; width: 160px; height: 320px; overflow: visible; }
.ld-track { stroke: rgba(255, 255, 255, .28); stroke-width: 1.4; transition: opacity .6s; }
#loading.lit .ld-track { opacity: 0; }
/* 线条与发光都是白色；奶白底上靠一层很淡的暖色投影把白线托出来 */
.ld-seg { stroke: #fff; stroke-width: 2; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .9s var(--ease), stroke-width .5s; }
.ld-stick { filter: drop-shadow(0 0 6px rgba(255, 255, 255, .9)); transition: filter .6s; }
#loading.lit .ld-seg { stroke-width: 2.6; }
#loading.lit .ld-stick { animation: ld-flick .9s ease-out; filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 26px #fff) drop-shadow(0 0 60px rgba(255, 255, 255, .9)); }
@keyframes ld-flick { 0% { opacity: .4; } 12% { opacity: 1; } 22% { opacity: .5; } 34% { opacity: 1; } 44% { opacity: .75; } 100% { opacity: 1; } }
.ld-halo {
  position: absolute; left: 114px; top: 86px; width: 320px; height: 320px; margin: -160px 0 0 -160px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 252, 244, .95), rgba(255, 248, 232, .45) 45%, transparent);
  opacity: 0; transform: scale(.3); transition: opacity .8s ease-out, transform 1.2s var(--ease); pointer-events: none;
}
#loading.lit .ld-halo { opacity: 1; transform: scale(1); }
/* 卡通星星：从灯头蹦出来，带回弹，然后一直晃 */
.ld-stars { position: absolute; inset: 0; pointer-events: none; }
.ld-stars i { position: absolute; left: 114px; top: 86px; width: 0; height: 0; }
.ld-stars svg { position: absolute; left: calc(var(--s) * -1); top: calc(var(--s) * -1); width: calc(var(--s) * 2); height: calc(var(--s) * 2); overflow: visible; stroke: none; }
#loading.lit .ld-stars i { animation: star-pop .9s cubic-bezier(.34, 1.7, .5, 1) var(--d) both; }
#loading.lit .ld-stars svg { animation: star-wobble 1.1s ease-in-out calc(var(--d) + .9s) infinite alternate; }
@keyframes star-pop {
  0% { transform: translate(0, 0) scale(0) rotate(-140deg); }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(0); }
}
@keyframes star-wobble {
  0% { transform: rotate(-14deg) scale(.92); }
  100% { transform: rotate(14deg) scale(1.12); }
}
.ld-sub { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; letter-spacing: .12em; color: rgba(255, 255, 255, .78); min-height: 16px; }
.ld-sub b { font-family: var(--mono); font-weight: 500; color: #fff; letter-spacing: 0; }

/* ---------- 玻璃质感（顶栏、底栏、起身、首页铭牌共用） ---------- */
.glass {
  --g-bg: rgba(250, 250, 248, .62); --g-fg: var(--ink); --g-sub: var(--ink-2); --g-accent: #c2401f;
  --g-edge: rgba(0, 0, 0, .08); --g-shadow: rgba(30, 20, 10, .22);
  position: relative; isolation: isolate; color: var(--g-fg);
  background: var(--g-bg);
  backdrop-filter: blur(24px) saturate(1.15); -webkit-backdrop-filter: blur(24px) saturate(1.15);
  box-shadow: 0 0 0 .5px var(--g-edge) inset, 0 8px 24px -10px var(--g-shadow);
}
body.dark .glass {
  --g-bg: rgba(24, 22, 26, .56); --g-fg: #fff; --g-sub: rgba(255,255,255,.6); --g-accent: var(--gold);
  --g-edge: rgba(255, 255, 255, .1); --g-shadow: rgba(0, 0, 0, .5);
}

/* ---------- 顶部 ---------- */
#topbar {
  position: fixed; z-index: 10; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-t) + 12px) 12px 0; display: flex; justify-content: center; pointer-events: none;
}
.tb-title { pointer-events: auto; height: 36px; border-radius: 18px; display: inline-flex; align-items: center; padding: 0 4px; font-size: 13px; }
.tb-title button { height: 100%; display: inline-flex; align-items: center; gap: 2px; padding: 0 8px 0 12px; border-radius: 16px; transition: transform .25s var(--ease), opacity .2s; }
.tb-title button:active { transform: scale(.94); }
.tb-title b { font-family: var(--serif); font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.tb-title span { color: var(--g-sub); }
.tb-title svg { width: 14px; height: 14px; opacity: .45; stroke-width: 2; transition: transform .3s var(--ease); }
.tb-title button.open svg { transform: rotate(180deg); }
.tb-div { width: 1px; height: 14px; background: currentColor; opacity: .14; }
/* 顶部小弹窗：从标题下方弹出 */
.pop {
  position: fixed; z-index: 11; top: calc(var(--safe-t) + 56px); left: 50%; width: min(300px, calc(100vw - 32px)); padding: 6px; border-radius: 20px;
  --g-bg: rgba(250, 250, 248, .82);
  transform: translate(-50%, -8px) scale(.96); transform-origin: 50% 0; opacity: 0; pointer-events: none;
  transition: transform .45s cubic-bezier(.34, 1.4, .64, 1), opacity .2s;
}
body.dark .pop { --g-bg: rgba(24, 22, 26, .78); }
.pop.open { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
button.pv { width: 100%; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 14px; text-align: left; transition: background .2s; }
button.pv b { font-size: 14px; font-weight: 600; }
button.pv small { flex: 1; font-size: 11px; color: var(--g-sub); }
button.pv svg { width: 16px; height: 16px; stroke-width: 2; }
button.pv.on { background: rgba(0, 0, 0, .05); }
body.dark button.pv.on { background: rgba(255, 255, 255, .08); }
button.pv:disabled { opacity: .45; cursor: default; }

#tip {
  position: fixed; z-index: 6; pointer-events: none; padding: 6px 10px; border-radius: 10px;
  background: var(--ink); color: #fff; font-size: 12px; white-space: nowrap; opacity: 0;
  transform: translate(-50%, calc(-100% - 14px)); transition: opacity .15s;
}
#tip.on { opacity: 1; }
#tip b { font-family: var(--mono); font-weight: 500; margin-right: 6px; color: var(--gold); }

/* ---------- 底部操作区 ---------- */
#dock {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  padding: 0 12px calc(var(--safe-b) + 16px);
  display: flex; align-items: flex-end; gap: 10px; pointer-events: none;
}
#dock > * { pointer-events: auto; }
.dock-btn {
  flex: 0 0 auto; width: 64px; height: 60px; border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 500;
  transition: transform .25s var(--ease), background .25s, color .25s;
}
.dock-btn svg { width: 22px; height: 22px; }
.dock-btn:active { transform: scale(.94); }
.dock-btn.on { --g-bg: rgba(28, 26, 30, .84); --g-fg: #fff; }
body.dark .dock-btn.on { --g-bg: rgba(255, 255, 255, .88); --g-fg: var(--ink); }
.dock-mid { flex: 1; position: relative; height: 60px; display: flex; justify-content: center; align-items: center; pointer-events: none; }
.dock-mid > * { pointer-events: auto; }


/* ---------- 起身 ---------- */
#standup {
  position: fixed; z-index: 9; right: 12px; bottom: calc(var(--safe-b) + 90px);
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 52px; height: 52px; justify-content: center;
  border-radius: 50%; font-size: 11px;
  opacity: 0; transform: scale(.6); pointer-events: none; transition: all .4s var(--ease);
}
#standup svg { width: 18px; height: 18px; }
#standup.on { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- 视角胶囊：落座后只报区号和座位，深灰底 ---------- */
#capsule {
  position: absolute; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 22px; border-radius: 20px; white-space: nowrap;
  background: rgba(28, 26, 30, .82); color: #fff; backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 0 0 .5px rgba(255, 255, 255, .08) inset, 0 10px 30px -10px rgba(0, 0, 0, .45);
  transform: translateY(16px) scale(.94); opacity: 0; pointer-events: none;
  transition: transform .6s cubic-bezier(.34, 1.4, .64, 1), opacity .35s;
}
#capsule.on { transform: none; opacity: 1; pointer-events: auto; }
#capsule b { font-family: var(--serif); font-size: 18px; letter-spacing: .04em; }
#capsule span { font-family: var(--mono); font-size: 13px; color: rgba(255, 255, 255, .6); }

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed; z-index: 20; top: 0; bottom: 0; width: min(380px, 82vw);
  padding-top: var(--safe-t);
  background: var(--paper); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  display: flex; flex-direction: column;
  transition: transform .55s var(--ease), box-shadow .55s;
}
.drawer.left { left: 0; transform: translateX(-104%); border-radius: 0 22px 22px 0; }
.drawer.right { right: 0; transform: translateX(104%); border-radius: 22px 0 0 22px; }
.drawer.open { transform: none; box-shadow: 0 0 60px rgba(30, 20, 5, .22); }
.drawer.right.half { transform: translateX(0); }
.dr-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.dr-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; letter-spacing: .08em; }
.dr-close { width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.05); color: var(--ink-2); display: grid; place-items: center; }
.dr-close svg { width: 16px; height: 16px; }
.dr-grab { display: none; }
.dr-head, .dr-grab { user-select: none; -webkit-user-select: none; }
.dr-body { overflow-y: auto; padding: 4px 20px calc(var(--safe-b) + 28px); flex: 1; -webkit-overflow-scrolling: touch; }
.dr-body section { padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.dr-body section:last-of-type { border-bottom: 0; }
.dr-body h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.dr-body h3 i { font-style: normal; font-family: var(--mono); font-size: 11px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; }
.note { font-size: 11px; color: var(--ink-3); margin: 10px 0 0; }


.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.presets button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 8px; border-radius: 14px; font-size: 11px; color: var(--g-sub); transition: all .25s var(--ease); }
.presets button svg { width: 36px; height: 36px; stroke-width: 1.5; }
.presets svg .fd { fill: none; stroke: currentColor; stroke-width: 2; }
.presets svg .st { fill: currentColor; stroke: none; }
.presets button.on { background: var(--ink); color: #fff; }
body.dark .presets button.on { background: #fff; color: var(--ink); }

#minimap { margin: 0 -6px; }
#minimap svg { width: 100%; height: auto; display: block; }
#minimap path, #minimap rect.fsec { cursor: pointer; transition: fill .2s; }
.seatpick { margin-top: 10px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.6); border: 1px solid var(--line); display: none; }
.seatpick.on { display: block; }
.sp-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.sp-title b { font-family: var(--serif); font-size: 20px; }
.sp-title span { font-size: 12px; color: var(--ink-3); }
.seatpick label { display: grid; grid-template-columns: 18px 34px 1fr; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); margin: 6px 0; }
.seatpick output { font-family: var(--mono); font-size: 13px; color: var(--ink); }
input[type=range] { -webkit-appearance: none; appearance: none; height: 28px; background: transparent; width: 100%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(0,0,0,.1); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25), 0 0 0 5px var(--red) inset; }
.sp-actions { display: flex; gap: 8px; margin-top: 10px; }
.sp-actions button { flex: 1; height: 42px; border-radius: 12px; font-size: 14px; background: rgba(0,0,0,.05); }
.sp-actions .primary { background: var(--red); color: #fff; font-weight: 600; flex: 2; }
.favs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.favs button { padding: 7px 12px; border-radius: 16px; font-size: 12px; background: rgba(0,0,0,.05); font-family: var(--mono); }
.favs button.active { background: var(--gold); }

.empty { padding: 40px 0; text-align: center; color: var(--ink-3); font-size: 14px; display: none; }
.drawer.right.blank .empty { display: block; }
.drawer.right.blank section { display: none; }
.size-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: #17161a; color: #fff; }
#size-svg { width: 132px; flex: 0 0 auto; overflow: visible; }
.size-text .big { font-size: 14px; color: rgba(255,255,255,.7); }
.size-text .big b { display: block; font-family: var(--serif); font-size: 22px; color: var(--gold); margin-top: 2px; line-height: 1.2; }
.size-text .small { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 6px; line-height: 1.5; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.facts div { padding: 10px; border-radius: 12px; background: rgba(255,255,255,.6); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.facts b { font-family: var(--mono); font-size: 16px; font-weight: 500; }
.facts small { font-size: 11px; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { height: 38px; padding: 0 14px; border-radius: 19px; font-size: 13px; background: rgba(255,255,255,.6); border: 1px solid var(--line); transition: all .2s var(--ease); }
.chips button b { font-family: var(--mono); font-weight: 500; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.calib { font-size: 11px; color: var(--ink-3); margin: 18px 0 0; line-height: 1.6; }

/* ---------- 取景框（焦段模拟） ---------- */
#viewfinder { position: fixed; inset: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity .4s; }
#viewfinder.on { opacity: 1; }
#viewfinder .c { position: absolute; width: 26px; height: 26px; border: 2px solid rgba(255,255,255,.85); }
.c.tl { left: 18px; top: calc(var(--safe-t) + 70px); border-right: 0; border-bottom: 0; }
.c.tr { right: 18px; top: calc(var(--safe-t) + 70px); border-left: 0; border-bottom: 0; }
.c.bl { left: 18px; bottom: calc(var(--safe-b) + 100px); border-right: 0; border-top: 0; }
.c.br { right: 18px; bottom: calc(var(--safe-b) + 100px); border-left: 0; border-top: 0; }
.vf-label { position: absolute; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); display: flex; gap: 8px; align-items: center; font-family: var(--mono); color: #fff; font-size: 12px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.vf-label span:first-child { padding: 3px 8px; border-radius: 10px; background: var(--gold); color: #000; text-shadow: none; }

/* 手机：抽屉改成从下往上的底部面板 */
@media (max-width: 640px) {
  /* 两档吸附：先露出下半屏，上滑吸满全屏 */
  .drawer, .drawer.left, .drawer.right {
    top: 0; left: 0; right: 0; bottom: auto; width: 100%; height: 100dvh; padding-top: 0;
    border-radius: 26px 26px 0 0; transform: translateY(104%); --half: 42dvh;
    transition: transform .5s cubic-bezier(.22, 1, .36, 1), border-radius .4s, padding-top .4s;
  }
  .drawer.open, .drawer.right.half { transform: translateY(var(--half)); box-shadow: 0 -10px 50px rgba(30, 20, 5, .18); touch-action: none; }
  .drawer.open.full { transform: none; border-radius: 0; padding-top: var(--safe-t); touch-action: auto; }
  .drawer.open:not(.full) .dr-body { overflow: hidden; }
  .dr-grab { display: block; width: 36px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .16); margin: 8px auto 0; flex: 0 0 auto; }
  .dr-head { padding-top: 8px; touch-action: none; }
}
@media (max-width: 560px) {
  .size-card { flex-direction: column; align-items: stretch; text-align: left; }
  #size-svg { width: 100%; max-height: 120px; }
}

/* 首页时隐藏漫游界面 */
#topbar, #dock { transition: opacity .6s var(--ease), transform .6s var(--ease); }
body.home #topbar { opacity: 0; transform: translateY(-20px); pointer-events: none; }
body.home #dock { opacity: 0; transform: translateY(30px); }
body.home #dock > * { pointer-events: none; }

/* 分区图指北：细、小、灰，不描边 */
#minimap .mm-n { fill: rgba(28, 27, 31, .4); stroke: none; }
#minimap .mm-n text { font: 400 13px -apple-system, "PingFang SC", sans-serif; }
body.dark #minimap .mm-n { fill: rgba(255, 255, 255, .42); }
