/* Alexander & Emily — paper theatre in two acts.
   Tokens first; scene colours live in js/scenes.js and arrive as CSS variables on .stage. */

:root {
  --lacquer: #7d1616;
  --lacquer-deep: #4c0b0b;
  --gold: #d9ae52;
  --gold-soft: #f0d58e;
  --paper: #f6efe2;
  --paper-2: #efe4d0;
  --ink: #2c2520;
  --ink-soft: #5d5148;
  --red: #b3201d;
  --jade: #6fb49c;
  --blue: #3f7fb5;

  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Jost', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --zh: 'Noto Serif TC', 'Songti TC', 'PMingLiU', 'Noto Serif CJK TC', serif;

  --dock-h: 74px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--lacquer-deep);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.55;
  overflow-x: hidden;
}
img { max-width: 100%; }
button { font: inherit; color: inherit; }
.zh, [lang='zh-Hant'] { font-family: var(--zh); font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--paper); padding: 10px 14px; border-radius: 6px; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ------------------------------------------------------------ theatre */

.theatre {
  position: relative;
  height: 100svh;
  min-height: 540px;
  display: flex;
  flex-direction: column;
  padding: clamp(8px, 1.4vw, 18px) clamp(8px, 1.4vw, 18px) 4px;
  background:
    radial-gradient(120% 80% at 50% 0%, #9a1f1c 0%, var(--lacquer) 45%, var(--lacquer-deep) 100%);
}

.frame {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: clamp(6px, 1vw, 12px);
  border-radius: 8px;
  background: linear-gradient(180deg, #8f1d1a, #621010);
  box-shadow: inset 0 0 0 1px rgba(240, 213, 142, 0.5), 0 20px 40px -18px rgba(0, 0, 0, 0.7);
}
.corner { position: absolute; width: clamp(26px, 4vw, 50px); height: clamp(26px, 4vw, 50px); border: 2px solid var(--gold); z-index: 3; pointer-events: none; }
.corner::after { content: ''; position: absolute; inset: 5px; border: 1.5px solid var(--gold); }
.corner.tl { top: 3px; left: 3px; border-right: 0; border-bottom: 0; }
.corner.tl::after { border-right: 0; border-bottom: 0; }
.corner.tr { top: 3px; right: 3px; border-left: 0; border-bottom: 0; }
.corner.tr::after { border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 3px; left: 3px; border-right: 0; border-top: 0; }
.corner.bl::after { border-right: 0; border-top: 0; }
.corner.br { bottom: 3px; right: 3px; border-left: 0; border-top: 0; }
.corner.br::after { border-left: 0; border-top: 0; }

.stage {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--sky3, #f3ead8);
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(217, 174, 82, 0.9), inset 0 0 60px rgba(40, 10, 5, 0.35);
  z-index: 9;
}
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.front { pointer-events: none; z-index: 3; }
.fx { pointer-events: none; z-index: 4; }
.cards { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.grain {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 180px;
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* Sheets: each casts a soft shadow on the one behind it. */
.sheet { will-change: transform; }
.sheet:not([data-slot='sky']):not([data-slot='hang']) {
  filter: drop-shadow(0 3px 4px var(--shadow, rgba(0, 0, 0, 0.3)));
}
.sheet[data-slot='hang'] { filter: drop-shadow(0 4px 5px var(--shadow, rgba(0, 0, 0, 0.3))); }
.sheet path, .sheet rect, .sheet circle, .sheet text {
  transition: fill 1.6s ease calc(var(--i, 0) * 110ms), opacity 1.2s ease;
}
.sky1 { stop-color: var(--sky1); }
.sky2 { stop-color: var(--sky2); }
.sky3 { stop-color: var(--sky3); }
#skyGrad stop, stop { transition: stop-color 1.8s ease; }

/* Scene change: old sheets drop away front-to-back, new ones rise into the box. */
.cut { transition: transform 1.25s cubic-bezier(0.25, 1.25, 0.4, 1) calc(0.45s + var(--i, 0) * 80ms), opacity 0.6s; }
.cut.entering { transform: translateY(var(--H, 800px)); transition: none; }
.cut.leaving {
  transform: translateY(var(--H, 800px));
  transition: transform 0.7s cubic-bezier(0.6, 0, 0.9, 0.5) calc((7 - var(--i, 0)) * 45ms);
}

.stars { opacity: var(--stars, 0); transition: opacity 2.2s ease; }
.stars circle { fill: #fff6d8; animation: twinkle 3.4s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes twinkle { 50% { opacity: 0.25; } }

.glyph { font-family: var(--zh); font-weight: 700; }
.script { font-family: var(--serif); font-style: italic; font-weight: 600; }

/* Hanging things: sun, moon, clouds, lanterns on threads. */
.thread { stroke: rgba(60, 40, 28, 0.5); stroke-width: 1; fill: none; }
.hang-item { transition: transform 1.9s cubic-bezier(0.34, 1.28, 0.5, 1); }
.hang-item:not(.shown) { transition-timing-function: cubic-bezier(0.5, -0.2, 0.7, 0.6); transition-duration: 1.2s; }
.swing { animation: sway 7s ease-in-out infinite; transform-origin: 0 calc(var(--H, 800px) * -0.35); }
.hang-item:nth-child(2n) .swing { animation-duration: 8.5s; animation-direction: reverse; }
@keyframes sway { 0%, 100% { transform: rotate(-1.1deg); } 50% { transform: rotate(1.1deg); } }
.sun-rays { fill: #eeb14a; }
.sun-disc { fill: #f6c75b; }
.sun-core { fill: #fbe08a; }
.stage[data-chapter='banquet'] .sun-rays { fill: #ec8a45; }
.stage[data-chapter='banquet'] .sun-disc { fill: #f39a52; }
.stage[data-chapter='banquet'] .sun-core { fill: #f8c177; }
.moon-disc { fill: #f5edd6; }
.moon-crater { fill: #e3d6b4; }
.cloud { fill: #fffaf0; }
.lantern-body { fill: #c8281f; }
.lantern-rib { fill: #a81f18; }
.lantern-cap, .lantern-tassel { fill: var(--gold); }
.lantern-xi { fill: #f3d58a; }
.stage[data-chapter='cake'] .lantern-body, .stage[data-set='tea'] .lantern-body { filter: drop-shadow(0 0 10px rgba(255, 190, 90, 0.75)); }

/* Scene details that move. */
.car { transition: transform 3.2s cubic-bezier(0.2, 0.75, 0.25, 1) 0.9s; }
.cut.entering .car { transform: translateX(calc(var(--W, 1000px) * -0.55)); }
.jet { transform-box: fill-box; transform-origin: 50% 100%; animation: jet 1.8s ease-in-out infinite; animation-delay: var(--d, 0s); opacity: 0.9; }
@keyframes jet { 50% { transform: scaleY(0.82); opacity: 0.7; } }
.beams { animation: beams 6s ease-in-out infinite; }
@keyframes beams { 50% { opacity: 0.55; } }
.spark { transform-box: fill-box; transform-origin: center; animation: spark 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes spark { 0%, 100% { transform: scale(0.3); opacity: 0.2; } 50% { transform: scale(1); opacity: 1; } }
.rings-hang { animation: sway 5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 0; }
.firework { animation: firework 3.2s ease-out infinite; animation-delay: var(--d, 0s); }
@keyframes firework { 0% { transform: scale(0.1); opacity: 0; } 12% { opacity: 1; } 60% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(1.1); opacity: 0; } }
.bulb { animation: twinkle 2.4s ease-in-out infinite; animation-delay: var(--d, 0s); filter: drop-shadow(0 0 4px #ffd87a); }
.glint { animation: beams 3.4s ease-in-out infinite; }
.city-lights { transition: opacity 2s ease; }

/* Shadow puppets. */
.puppets { pointer-events: auto; cursor: pointer; transition: transform 2.4s cubic-bezier(0.45, 0, 0.3, 1); outline: none; }
.puppets.instant { transition: none; }
.puppets.rising .pup-bob { animation: pup-rise 1.5s cubic-bezier(0.3, 1.3, 0.4, 1) 0.5s both; }
@keyframes pup-rise { from { transform: translateY(160px); } }
.pup-pair { animation: pup-idle 3.2s ease-in-out infinite; transform-origin: 0 0; }
.puppets.walking .pup-pair { animation: pup-walk 0.6s ease-in-out 4; }
.puppets.hop .pup-bob { animation: pup-hop 0.7s cubic-bezier(0.3, 0.6, 0.4, 1); }
.pup-g, .pup-b { transition: transform 1.2s ease; }
.puppets .pup { transform-box: fill-box; transform-origin: 50% 100%; transition: transform 1.2s ease; }
.puppets[data-pose='kiss'] .groom { transform: rotate(4deg); }
.puppets[data-pose='kiss'] .bride { transform: rotate(-4deg); }
.puppets:focus-visible .pup { filter: drop-shadow(0 0 3px var(--gold)); }
.stage { --pup-suit: #1d2130; --pup-suit-lace: #39405a; --pup-skin: #f2d2b8; --pup-skin2: #e8c4a2; --pup-hair: #9b7248; }
.puppets { filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.35)); }
/* Backlit at night, like a lamp behind a shadow-puppet screen. */
.stage[data-chapter='cake'] .puppets { filter: drop-shadow(0 0 2px rgba(255, 226, 160, 0.95)) drop-shadow(0 0 10px rgba(255, 200, 110, 0.5)); }
.pup-rod { stroke: #4b3322; stroke-width: 0.9; }
.pup-rivet { fill: var(--gold); }
.pup-glasses { fill: none; stroke: #2a2a2e; stroke-width: 0.7; }
@keyframes pup-idle { 50% { transform: translateY(-1.2px) rotate(0.6deg); } }
@keyframes pup-walk { 50% { transform: translateY(-5px) rotate(-1.5deg); } }
@keyframes pup-hop { 35% { transform: translateY(-38px) scaleY(1.04); } 70% { transform: translateY(0) scaleY(0.95); } }

/* ------------------------------------------------------------ photo prints */

.card {
  position: absolute;
  left: calc(var(--l) + var(--px, 0px) * 0.35);
  top: var(--t);
  width: var(--cw);
  height: var(--ch);
  margin: 0;
  pointer-events: auto;
  transform-origin: 50% calc(var(--t) * -1);
  transition: transform 1.15s cubic-bezier(0.3, 1.32, 0.45, 1), opacity 0.4s;
  touch-action: pan-y;
}
.card.entering { transform: translateY(var(--lift)) rotate(-2.5deg); }
.card.swinging { animation: settle 3.4s ease-out 1.05s; }
.card.leaving { transform: translateY(var(--lift)) rotate(2deg); transition: transform 0.95s cubic-bezier(0.6, 0, 0.85, 0.35); }
@keyframes settle {
  0% { transform: rotate(0); } 18% { transform: rotate(0.9deg); } 42% { transform: rotate(-0.55deg); }
  66% { transform: rotate(0.25deg); } 100% { transform: rotate(0); }
}
.card .thread {
  position: absolute;
  top: calc(var(--t) * -1);
  height: var(--t);
  width: 1px;
  background: rgba(55, 35, 25, 0.55);
}
.card .thread.l { left: 16%; }
.card .thread.r { right: 16%; }
.card .thread::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: -3.5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.mat {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  padding: var(--pad) var(--pad) calc(var(--pad) * 2.6);
  border: 0;
  border-radius: 2px;
  background: #fbf6ec;
  box-shadow: 0 22px 32px -14px rgba(20, 8, 4, 0.55), 0 2px 5px rgba(20, 8, 4, 0.25), inset 0 0 0 1px rgba(160, 120, 60, 0.18);
  cursor: zoom-in;
}
.mat img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 1px; background: #e9dfcc; }
.card figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--pad) * 0.55);
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(13px, 1.25vw, 17px);
  color: var(--ink-soft);
  pointer-events: none;
}
body[data-act='2'] .mat { background: #a61d1a; box-shadow: 0 22px 32px -14px rgba(20, 8, 4, 0.6), 0 2px 5px rgba(20, 8, 4, 0.3), inset 0 0 0 3px #a61d1a, inset 0 0 0 4px var(--gold); }
body[data-act='2'] .card figcaption { color: var(--gold-soft); }
body[data-act='0'] .mat { background: #f4ecdb; }
.mat.placeholder { cursor: default; display: grid; place-items: center; }
.ph-inner { text-align: center; color: var(--ink-soft); }
.ph-xi { display: block; font-family: var(--zh); font-weight: 700; font-size: clamp(48px, 9vw, 120px); line-height: 1; color: var(--red); opacity: 0.85; }
body[data-act='2'] .ph-inner { color: var(--gold-soft); }
body[data-act='2'] .ph-xi { color: var(--gold); }
.ph-inner p { margin: 10px 0 0; font-style: italic; }

/* ------------------------------------------------------------ title tag + HUD */

.tag {
  position: absolute;
  z-index: 6;
  top: clamp(18px, 4%, 40px);
  left: clamp(14px, 3%, 40px);
  width: clamp(158px, 18vw, 250px);
  padding: 22px 16px 16px;
  background: linear-gradient(180deg, #fbf5e8, #f1e6cf);
  clip-path: polygon(14% 0, 86% 0, 100% 9%, 100% 100%, 0 100%, 0 9%);
  filter: drop-shadow(0 6px 8px rgba(40, 20, 10, 0.3));
  transform-origin: 50% -30px;
  animation: tag-swing 9s ease-in-out infinite;
  text-align: center;
}
.tag::before { content: ''; position: absolute; left: 50%; top: -60px; height: 70px; width: 1px; background: rgba(60, 40, 28, 0.55); }
.tag-hole { position: absolute; top: 8px; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: #7d5a3a; box-shadow: inset 0 0 0 2px #e8d9bb; }
.tag-kicker { margin: 0 0 6px; font-family: var(--sans); font-size: 9.5px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); }
.tag h1 { margin: 0; font-weight: 600; font-size: clamp(22px, 2.5vw, 36px); line-height: 1.02; color: var(--ink); }
.tag h1 span { display: block; }
.tag h1 em { display: block; font-weight: 500; color: var(--red); font-size: 0.8em; line-height: 1.1; }
.tag-date { margin: 8px 0 0; padding-top: 7px; border-top: 1px solid rgba(120, 90, 60, 0.3); font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em; color: var(--ink-soft); }
.tag-seal {
  position: absolute; right: 9px; bottom: 9px; width: 22px; height: 22px; display: grid; place-items: center;
  background: var(--red); color: #f6dfa4; font-size: 14px; border-radius: 3px; transform: rotate(-6deg);
}
@keyframes tag-swing { 0%, 100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.4deg); } }

.hud-wrap {
  position: absolute;
  z-index: 6;
  top: clamp(18px, 4%, 40px);
  right: clamp(14px, 3%, 40px);
  width: min(25%, 300px);
  padding: 16px 18px 14px;
  text-align: right;
  color: var(--ink);
  pointer-events: none;
  background: rgba(251, 246, 236, 0.9);
  border-radius: 3px;
  box-shadow: 0 8px 18px -10px rgba(20, 8, 4, 0.45), inset 0 0 0 1px rgba(160, 120, 60, 0.2);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.hud-wrap::before, .hud-wrap::after { content: ''; position: absolute; top: -60px; height: 60px; width: 1px; background: rgba(60, 40, 28, 0.5); }
.hud-wrap::before { left: 22%; }
.hud-wrap::after { right: 22%; }
.clock { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(28px, 3.4vw, 46px); line-height: 1.05; }
.hud-date, .hud-place { margin: 6px 0 0; font-family: var(--sans); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.85; }
.hud-place { margin-top: 2px; opacity: 0.65; }
.caption { margin-top: 14px; }
.hud-title { margin: 0; font-size: clamp(20px, 2.1vw, 30px); font-weight: 600; line-height: 1.15; }
.hud-title .zh { display: block; font-size: 0.62em; letter-spacing: 0.3em; color: var(--red); margin-top: 3px; }
.hud-line { margin: 6px 0 0; font-size: clamp(14px, 1.2vw, 17px); font-style: italic; line-height: 1.4; }
.count { margin: 6px 0 0; font-family: var(--sans); font-size: 11px; letter-spacing: 0.16em; opacity: 0.6; }

/* Finale card. */
.finale {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(92%, 520px);
  padding: clamp(22px, 4vw, 40px);
  text-align: center;
  background: #fbf5e8;
  border-radius: 4px;
  box-shadow: 0 30px 50px -20px rgba(30, 10, 5, 0.6), inset 0 0 0 1px rgba(160, 120, 60, 0.3);
  animation: finale-in 1s cubic-bezier(0.3, 1.3, 0.4, 1);
}
.finale[hidden] { display: none; }
.finale-zh { margin: 0; font-size: 44px; color: var(--red); letter-spacing: 0.2em; }
.finale h2 { margin: 6px 0 4px; font-size: clamp(24px, 3vw, 34px); font-weight: 600; line-height: 1.15; }
.finale p { margin: 0; font-style: italic; color: var(--ink-soft); }
.finale-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
@keyframes finale-in { from { transform: translate(-50%, -120%); opacity: 0; } }

/* ------------------------------------------------------------ dock */

.dock {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: auto auto 1fr auto auto auto;
  align-items: center;
  gap: clamp(4px, 1vw, 12px);
  width: min(100%, 1180px);
  margin: 8px auto 2px;
  padding: 8px clamp(8px, 1.5vw, 16px);
  min-height: var(--dock-h);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(251, 245, 232, 0.97), rgba(239, 228, 208, 0.97));
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(160, 120, 60, 0.25);
}
.ctl {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.ctl:hover { background: rgba(179, 32, 29, 0.08); }
.ctl:active { transform: scale(0.94); }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#play { background: var(--red); }
#play svg { fill: #fbf1dc; stroke: none; }
#play:hover { background: #c42a24; }
.i-pause, .playing .i-play { display: none; }
.playing .i-pause { display: block; }
.i-on, #sound[aria-pressed='true'] .i-off { display: none; }
#sound[aria-pressed='true'] .i-on { display: block; }
/* Music button carries a word so people know it's music, not sound effects. */
#sound { width: auto; padding: 0 14px 0 10px; border-radius: 999px; grid-auto-flow: column; gap: 6px; border: 1.5px solid rgba(110, 80, 50, 0.35); }
#sound[aria-pressed='true'] { background: rgba(179, 32, 29, 0.1); border-color: var(--red); }
.speed { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; font-family: var(--sans); font-size: 13px; color: var(--ink); cursor: pointer; }
.speed-label { letter-spacing: 0.06em; }
.speed output { min-width: 3.2ch; font-variant-numeric: tabular-nums; color: var(--red); font-weight: 500; }
.speed input { width: 92px; height: 44px; margin: 0; background: transparent; accent-color: var(--red); cursor: pointer; -webkit-appearance: none; appearance: none; }
.speed input::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, #e8c77b, var(--red)); }
.speed input::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, #e8c77b, var(--red)); }
.speed input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fbf6ec; border: 2px solid var(--red); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.speed input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fbf6ec; border: 2px solid var(--red); }
.speed input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.music-hint {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 10px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fbf1dc;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none; /* never blocks: the tap goes straight through */
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.music-hint::after { content: ''; position: absolute; right: 38px; top: 100%; border: 6px solid transparent; border-top-color: var(--ink); }
.music-hint.show { opacity: 1; transform: none; }
.music-hint span { color: var(--gold-soft); margin-right: 4px; }
#sound.waiting { animation: music-pulse 1.6s ease-in-out infinite; }
@keyframes music-pulse { 50% { box-shadow: 0 0 0 6px rgba(179, 32, 29, 0.18); } }
.ctl-label { font-family: var(--sans); font-size: 13px; letter-spacing: 0.06em; }

.track-wrap { position: relative; padding: 18px 16px 4px; min-width: 0; }
.days { position: relative; height: 0; }
.day {
  position: absolute;
  top: -17px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.day.gap { font-family: var(--serif); font-style: italic; letter-spacing: 0.02em; text-transform: none; font-size: 12px; opacity: 0.8; }
.track { position: relative; height: 34px; cursor: pointer; touch-action: none; outline-offset: 6px; }
.track-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 8px;
  margin-top: -4px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(60, 40, 20, 0.15);
}
.track-fill::after {
  /* the four-day gap between the two acts */
  content: '';
  position: absolute;
  left: 61%;
  width: 8%;
  top: -1px;
  bottom: -1px;
  background: repeating-linear-gradient(90deg, #f3ead7 0 4px, transparent 4px 8px);
}
.ticks { position: absolute; inset: 0; }
.tick {
  position: absolute;
  top: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1.5px solid rgba(110, 80, 50, 0.45);
  border-radius: 50%;
  background: #fbf6ec;
  cursor: pointer;
  transition: transform 0.2s, background 0.3s, border-color 0.3s;
}
.tick svg { width: 17px; height: 17px; fill: none; stroke: var(--ink-soft); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tick:hover { transform: scale(1.1); }
.tick.past { border-color: rgba(179, 32, 29, 0.55); }
.tick.active { background: var(--red); border-color: var(--gold); transform: scale(1.15); }
.tick.active svg { stroke: #f7e2ab; }
.tick::before { content: ''; position: absolute; inset: -6px; } /* bigger touch target */
.tick-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, 4px);
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: #fbf1dc;
  font-family: var(--sans);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
@media (hover: hover) {
  .tick:hover .tick-tip, .tick:focus-visible .tick-tip { opacity: 1; transform: translate(-50%, 0); }
}
.knot {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--gold);
  border: 2px solid var(--red);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: -1;
  transition: left 0.25s linear;
}
.scroll-cue {
  display: block;
  margin: 2px auto 4px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gold-soft);
  padding: 8px 12px;
}
.scroll-cue span { display: inline-block; animation: cue 2s ease-in-out infinite; }
@keyframes cue { 50% { transform: translateY(3px); } }

/* ------------------------------------------------------------ below the stage */

.paper-page {
  position: relative;
  background: var(--paper);
  background-image: var(--grain);
  background-size: 180px;
  padding: clamp(40px, 7vw, 90px) 16px 40px;
}
.paper-page > section, .paper-page > footer { width: min(100%, 1080px); margin: 0 auto clamp(56px, 8vw, 96px); }
.paper-page h2 { font-size: clamp(30px, 4.2vw, 48px); font-weight: 500; line-height: 1.1; margin: 0 0 18px; text-align: center; }
.eyebrow { margin: 0 0 8px; font-family: var(--sans); font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--red); text-align: center; }
.sub { text-align: center; margin: -8px 0 28px; color: var(--ink-soft); font-style: italic; }

.intro { max-width: 720px !important; text-align: center; }
.intro p { color: var(--ink-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 20px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fbf1dc; }
.btn.primary:hover { background: #c42a24; }
.btn.soon { opacity: 0.75; cursor: default; }
.btn.soon:hover { transform: none; }
.soon-note:not(:empty) { font-size: 12px; opacity: 0.8; }
.soon-note:not(:empty)::before { content: '· '; }
.link-btn { border: 0; background: none; padding: 8px 4px; font-family: var(--sans); font-size: 13px; letter-spacing: 0.06em; color: var(--red); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.drive {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(20px, 4vw, 44px);
  align-items: center;
  max-width: 820px !important;
  padding: clamp(22px, 4vw, 40px);
  border-radius: 6px;
  background: #fbf6ec;
  box-shadow: 0 20px 40px -26px rgba(60, 20, 10, 0.5), inset 0 0 0 1px rgba(160, 120, 60, 0.25);
}
.drive h2 { text-align: left; margin-bottom: 8px; }
.drive p { margin: 0 0 18px; color: var(--ink-soft); }
.envelope {
  position: relative;
  width: clamp(90px, 14vw, 130px);
  aspect-ratio: 3 / 4.4;
  border-radius: 6px;
  background: linear-gradient(180deg, #c8281f, #a01a16);
  box-shadow: 0 14px 24px -12px rgba(100, 10, 5, 0.7);
  transform: rotate(-4deg);
}
.envelope::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 38%; background: #b3201d; clip-path: polygon(0 0, 100% 0, 100% 40%, 50% 100%, 0 40%); filter: brightness(0.92); }
.envelope span { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); width: 44%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #a01a16; font-size: clamp(18px, 3vw, 28px); font-weight: 700; }

.venues { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 22px; }
.venue { padding: 26px 26px 20px; border-radius: 6px; background: #fbf6ec; box-shadow: inset 0 0 0 1px rgba(160, 120, 60, 0.25); border-top: 5px solid var(--blue); }
.venue:nth-child(2) { border-top-color: var(--red); }
.venue .eyebrow { text-align: left; }
.venue h3 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.15; }
.venue h3 .zh { display: block; font-size: 16px; color: var(--ink-soft); letter-spacing: 0.2em; margin-top: 4px; }
.venue .when { margin: 8px 0 12px; font-family: var(--sans); font-size: 14px; color: var(--ink-soft); }
.venue ul { margin: 0; padding-left: 20px; }
.venue li { margin: 0 0 8px; }
.venue li::marker { color: var(--gold); }

.banquet-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 60px); align-items: start; }
.menu-card {
  position: relative;
  padding: 34px clamp(20px, 4vw, 40px) 30px;
  text-align: center;
  color: #fbeccd;
  background: linear-gradient(180deg, #a81f1b, #861512);
  border-radius: 4px;
  box-shadow: 0 30px 50px -28px rgba(80, 10, 5, 0.8), inset 0 0 0 6px #a81f1b, inset 0 0 0 7.5px var(--gold);
}
.menu-card h3 { margin: 0; font-size: 30px; font-weight: 500; color: #fbeccd; }
.menu-xi { margin: 0; font-family: var(--zh); font-size: 40px; color: var(--gold); line-height: 1; }
.menu-card .zh.big { margin: 4px 0 18px; letter-spacing: 0.4em; color: var(--gold-soft); }
.menu-card ol { list-style: none; margin: 0; padding: 0; }
.menu-card li { display: grid; gap: 1px; padding: 12px 0; border-top: 1px solid rgba(240, 213, 142, 0.25); }
.menu-card .dish { font-size: 20px; font-weight: 600; }
.menu-card li .zh { color: var(--gold-soft); letter-spacing: 0.15em; font-size: 15px; }
.menu-card .note { font-style: italic; font-size: 15px; opacity: 0.85; }
.menu-note { margin: -8px 0 16px; font-style: italic; font-size: 15px; opacity: 0.8; }
.draft-ribbon { margin: -12px auto 16px; display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--gold); color: #6a1210; font-family: var(--sans); font-size: 12px; letter-spacing: 0.08em; }
.tea h3 { margin: 10px 0 12px; font-size: 32px; font-weight: 500; line-height: 1.1; }
.tea h3 .zh { display: block; font-size: 18px; color: var(--red); letter-spacing: 0.3em; margin-top: 6px; }
.tea p { color: var(--ink-soft); }

.g-chapter { margin-bottom: 44px; }
.g-chapter header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid rgba(120, 90, 60, 0.25); }
.g-chapter h3 { margin: 0; font-size: 26px; font-weight: 600; flex: 1; min-width: 200px; }
.g-chapter h3 .zh { font-size: 15px; color: var(--red); letter-spacing: 0.2em; margin-left: 8px; }
.g-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--red); }
.g-icon svg { width: 20px; height: 20px; fill: none; stroke: #f7e2ab; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.g-grid { columns: 4 200px; column-gap: 10px; }
.g-item { display: block; width: 100%; margin: 0 0 10px; padding: 0; border: 0; border-radius: 3px; overflow: hidden; background: #e9dfcc; cursor: zoom-in; break-inside: avoid; box-shadow: 0 6px 14px -8px rgba(40, 20, 10, 0.5); }
.g-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.g-item:hover img { transform: scale(1.03); }

.foot { text-align: center; color: var(--ink-soft); margin-bottom: 20px !important; }
.foot p { margin: 4px 0; }
.foot-xi { font-size: 44px; color: var(--red); margin: 0 0 8px !important; }
.foot .small { font-family: var(--sans); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }

/* Lightbox. */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(20, 10, 8, 0.94); color: #fbf1dc; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.6); }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto auto; place-items: center; }
.lightbox img { max-width: 94vw; max-height: calc(100dvh - 140px); object-fit: contain; margin-top: 20px; touch-action: pan-y; }
.lb-caption { margin: 10px 0 0; font-style: italic; }
.lb-bar { display: flex; gap: 14px; align-items: center; padding: 12px 0 20px; }
.lb-bar .btn { color: #fbf1dc; border-color: rgba(251, 241, 220, 0.6); }
.lb-prev, .lb-next, .lb-close { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(251, 241, 220, 0.4); background: transparent; color: #fbf1dc; font-size: 28px; line-height: 1; cursor: pointer; }
.lb-close { position: absolute; top: 14px; right: 14px; }

/* ------------------------------------------------------------ portrait / phones */

@media (max-aspect-ratio: 10 / 11) {
  .tag { width: auto; max-width: 52%; padding: 16px 30px 9px 14px; top: 20px; left: 12px; text-align: left; }
  .tag-hole { left: 22px; }
  .tag::before { left: 26px; }
  .tag h1 { font-size: clamp(18px, 5vw, 26px); white-space: nowrap; }
  .tag h1 span, .tag h1 em { display: inline; }
  .tag-kicker { display: none; }
  .tag-date { margin-top: 4px; padding-top: 4px; font-size: 9.5px; letter-spacing: 0.1em; }
  .tag-seal { width: 18px; height: 18px; font-size: 11px; right: 7px; bottom: 7px; }
  .hud-wrap { position: static; width: auto; padding: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .hud-wrap::before, .hud-wrap::after { display: none; }
  .hud { position: absolute; z-index: 6; top: 22px; right: 12px; text-align: right; padding: 10px 12px 9px; border-radius: 3px; background: rgba(251, 246, 236, 0.9); box-shadow: 0 8px 18px -10px rgba(20, 8, 4, 0.45); }
  .caption {
    position: absolute;
    z-index: 6;
    left: 50%;
    top: 65.5%;
    transform: translateX(-50%);
    width: min(88%, 420px);
    margin: 0;
    padding: 8px 14px 9px;
    text-align: center;
    border-radius: 4px;
    background: rgba(251, 246, 236, 0.92);
    color: var(--ink);
    box-shadow: 0 8px 18px -10px rgba(20, 8, 4, 0.5);
  }
    .hud-title { font-size: 19px; }
  .hud-title .zh { display: inline; margin-left: 6px; letter-spacing: 0.15em; }
  .hud-line { font-size: 14px; margin-top: 2px; }
  .count { display: none; }
  .clock { font-size: clamp(22px, 6.4vw, 32px); }
  .hud-date { font-size: 9.5px; letter-spacing: 0.14em; }
  .hud-place { display: none; }
}

@media (max-width: 640px) {
  .theatre { padding: 6px 6px 2px; }
  .dock {
    grid-template-columns: 1fr auto auto auto auto 1fr;
    grid-template-areas: 'track track track track track track' '. play next speed sound .';
    row-gap: 0;
    gap: 0 8px;
    padding: 4px 6px 6px;
    margin-top: 6px;
    border-radius: 12px;
  }
  .track-wrap { grid-area: track; padding: 18px 16px 0; }
  #play { grid-area: play; }
  #prev { display: none; }
  .speed { grid-area: speed; gap: 5px; padding: 0 2px; }
  .speed-label { display: none; }
  .music-hint { right: 50%; transform: translate(50%, 6px); font-size: 12.5px; }
  .music-hint.show { transform: translate(50%, 0); }
  .music-hint::after { display: none; }
  .speed input { width: 76px; }
  #sound .ctl-label { display: none; }
  #sound { padding: 0 10px; }
  #next { grid-area: next; }
  #sound { grid-area: sound; }
  .ctl { width: 44px; height: 44px; }
  .tick { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
  .tick svg { width: 15px; height: 15px; }
  .day { font-size: 8.5px; letter-spacing: 0.1em; }
  .day.gap { display: none; }
  .scroll-cue { font-size: 10.5px; }
  .banquet-wrap { grid-template-columns: 1fr; }
  .drive { grid-template-columns: 1fr; text-align: center; }
  .drive h2 { text-align: center; }
  .envelope { margin: 0 auto; }
  body { font-size: 1.12rem; }
}
@media (max-width: 380px) {
  .day:not(.gap) { font-size: 7.5px; letter-spacing: 0.06em; }
  .tick { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
}
/* Narrow phones (360–389px): keep the title tag and time plaque from colliding. */
@media (max-aspect-ratio: 10 / 11) and (max-width: 389px) {
  .tag { padding: 15px 12px 8px; max-width: 50%; }
  .tag h1 { font-size: clamp(15px, 4.6vw, 18px); }
  .tag-seal { display: none; }
  .tag-date { font-size: 9px; letter-spacing: 0.06em; }
  .clock { font-size: clamp(17px, 5vw, 20px); }
  .hud { max-width: 46%; padding: 9px 10px 8px; }
  .hud-date { font-size: 8.5px; letter-spacing: 0.08em; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .tag { transform: scale(0.8); transform-origin: 0 0; animation: none; }
  .caption { display: none; }
}

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