:root {
  --ink: #fdf8f0;
  --ink-dim: rgba(253, 248, 240, .78);
  --panel: rgba(28, 24, 22, .62);
  --panel-strong: rgba(28, 24, 22, .82);
  --accent: #e8a25c;
  --accent-ink: #2a1c10;
  --line: rgba(255, 255, 255, .18);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #f1d7ba; font-family: var(--font); color: var(--ink); }
#app { position: fixed; inset: 0; }
#app canvas { display: block; touch-action: none; cursor: grab; }
#app canvas:active { cursor: grabbing; }
.hidden { display: none !important; }
button, select { font: inherit; }

/* intro + end cards */
#intro, #end {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, rgba(40, 28, 20, .25), rgba(30, 20, 14, .65));
}
.card {
  width: min(620px, 100%); box-sizing: border-box; padding: 28px 30px; border-radius: 16px;
  background: var(--panel-strong); backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.kicker { margin: 0 0 6px; font-size: 13px; letter-spacing: .12em; color: var(--accent); }
h1 { margin: 0 0 14px; font-size: clamp(30px, 6vw, 44px); letter-spacing: .06em; }
h1 span { font-size: .5em; font-weight: 500; opacity: .75; letter-spacing: .02em; }
h2 { margin: 0 0 8px; font-size: clamp(22px, 4.6vw, 32px); letter-spacing: .08em; }
.card p { margin: 0 0 10px; line-height: 1.7; font-size: 15px; }
.card p.en { color: var(--ink-dim); font-size: 13.5px; line-height: 1.6; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 18px 0 8px; }
#progress { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#status { font-size: 12.5px !important; color: var(--ink-dim); }
#start, #replay {
  margin: 8px 0 12px; padding: 12px 26px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; letter-spacing: .05em;
}
#start:disabled { opacity: .45; cursor: progress; }
.film-return, .compat a { color: var(--ink); text-underline-offset: .22em; }
#intro .film-return { display: block; margin: 4px 0; }
#hud .film-return { font-size: 13px; white-space: nowrap; }
#intro, #end { overflow-y: auto; align-items: safe center; }
.compat { position: fixed; bottom: 0; background: var(--panel-strong); padding: 10px; }
.hint { font-size: 12.5px !important; color: var(--ink-dim); }
.note { font-size: 12px !important; color: var(--ink-dim); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px !important; }
.actions { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; }
.actions a { color: var(--ink); font-size: 14px; }

/* captions */
#caption {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); width: min(760px, calc(100vw - 32px));
  text-align: center; pointer-events: none; opacity: 0; transition: opacity .6s;
}
#caption.on { opacity: 1; }
#caption p { margin: 0 auto; width: fit-content; max-width: 100%; padding: 4px 12px; background: rgba(20, 16, 14, .55); border-radius: 6px; }
#caption .zh { font-size: clamp(16px, 2.4vw, 21px); font-weight: 600; letter-spacing: .04em; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
#caption .en { margin-top: 4px; font-size: clamp(12px, 1.7vw, 14.5px); color: var(--ink-dim); }

/* minimap */
#map {
  position: fixed; right: 16px; top: 16px; width: 200px; height: 200px; border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); opacity: 0; transition: opacity .6s; pointer-events: none;
}
body.running #map { opacity: .92; }

/* control bar */
#hud {
  position: fixed; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 12px; background: var(--panel); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .4s; pointer-events: none;
}
body.running #hud { opacity: .35; pointer-events: auto; }
body.running #hud:hover, body.running.paused #hud, body.running #hud:focus-within { opacity: 1; }
#hud button, #hud select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; font-size: 13px;
}
#hud select option { color: #222; }
#hud button[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
#play { min-width: 40px; font-size: 14px !important; }
#time { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 86px; }
#seek { flex: 1; min-width: 60px; accent-color: var(--accent); }
#hud nav { display: flex; gap: 10px; font-size: 12.5px; }
#hud nav a { color: var(--ink-dim); }

@media (max-width: 700px) {
  .card { padding: 20px 18px; }
  #map { width: 120px; height: 120px; right: 16px; top: 16px; }
  #caption { bottom: 160px; }
  #hud { flex-wrap: wrap; gap: 8px; }
  #seek { order: 10; flex-basis: 100%; }
  #hud nav { display: none; }
}

.phone-handoff #start, .phone-handoff .bar, .phone-handoff .card .en, .phone-handoff .card .note, .phone-handoff .card .hint { display: none; }
#desktop-share { margin-top: 18px; }
#desktop-share label, #copy-result { display: block; font-size: .85rem; }
#desktop-share > div { display: flex; gap: 6px; margin: 5px 0; }
#desktop-url { flex: 1; min-width: 0; padding: .5rem; }
#copy-desktop { padding: .5rem; cursor: pointer; }
