:root {
  color-scheme: dark;
  --page: #201823;
  --panel: #30232e;
  --deep: #251c29;
  --line: #694c59;
  --ink: #fbedd6;
  --muted: #cdb1a5;
  --gold: #f2c785;
  --active: #513341;
  font-family: "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, #4a3040, var(--page) 63%);
}

button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid #fff0ba; outline-offset: 3px; }

.flow-shell {
  position: relative;
  width: min(440px, calc(100% - 24px));
  margin-inline: auto;
  padding: max(13px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
}
.flow-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.brand, .header-actions { display: flex; align-items: center; gap: 8px; }
.brand img {
  width: 34px;
  height: 46px;
  filter: drop-shadow(0 2px 2px #150c16);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .12em;
}
.flow-heading h1, .result h2 {
  margin: 0;
  font-family: "Songti TC", "Noto Serif TC", PMingLiU, Georgia, serif;
  font-size: clamp(1.54rem, 7.55vw, 2.27rem);
  font-weight: 800;
  letter-spacing: .035em;
  line-height: 1.08;
  text-shadow: 2px 2px #1b1320;
}
.icon-control {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font-size: .72rem;
  text-decoration: none;
}
.icon-control.restart { font-size: 1.32rem; line-height: 1; }
.icon-control:hover { background: var(--active); }

.projection {
  overflow: hidden;
  border: 1px solid #8a635f;
  border-radius: 13px;
  background: var(--panel);
  box-shadow: 0 12px 25px #170e1a6e;
}
.film-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}
.film-number {
  display: grid;
  width: 40px;
  height: 33px;
  place-items: center;
  border: 1px solid #a07659;
  border-inline: 4px dotted #a07659;
  border-radius: 3px;
  color: var(--gold);
  background: #43313c;
  font: 700 1.02rem Georgia, serif;
}
.film-title p, .tile-count span {
  margin: 0;
  color: var(--muted);
  font-size: .62rem;
}
.film-title h2 {
  margin: 1px 0 0;
  font-size: .94rem;
  font-weight: 750;
  line-height: 1.15;
}
.tile-count { display: flex; align-items: baseline; gap: 5px; }
.tile-count strong {
  color: var(--gold);
  font-size: 1.14rem;
  font-variant-numeric: tabular-nums;
}
.picture { background: #2b202c; }
#screen { display: block; width: 100%; aspect-ratio: 400 / 338; height: auto; }
#crew-reactions { position: absolute; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; }
#crew-reactions > svg { position: absolute; top: 0; left: 0; display: block; overflow: visible; }
.encore {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid #c59768;
  border-radius: 99px;
  background: #3e2937;
  color: #ffde97;
  font-size: .69rem;
  font-weight: 750;
  white-space: nowrap;
  pointer-events: none;
}
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .68rem;
}
.belt-label { color: var(--ink); white-space: nowrap; }
.belt-label strong { margin-left: 3px; color: var(--gold); font-variant-numeric: tabular-nums; }
.capacity { display: flex; gap: 3px; }
.capacity i { width: 9px; height: 9px; border: 1px solid #8c6968; border-radius: 2px; }
.capacity i.filled { border-color: #eac58a; background: #eac58a; }
.transport-note { margin-left: auto; text-align: right; }
.side-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border-top: 1px dashed #8c6561;
  background: linear-gradient(103deg, #3a2833, #4b302f);
}
.side-panel strong { color: #f4c992; font-size: .75rem; }
.side-panel p { margin: 2px 0 0; color: var(--muted); font-size: .64rem; }
.side-ticket {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid #d7a76d;
  border-radius: 7px;
  background: #68413c;
  color: #ffe1a5;
  font-size: .76rem;
  font-weight: 750;
}
.side-ticket b {
  min-width: 16px;
  padding: 0 3px;
  border-radius: 4px;
  background: #271d27;
  color: #ffe1a5;
  text-align: center;
}
.side-ticket[aria-pressed="true"] {
  border-color: #ffe7b5;
  background: var(--gold);
  color: #36212b;
  box-shadow: 0 0 11px #eeaa6250;
}
.side-ticket:disabled { border-color: #846357; background: #48313a; color: var(--muted); }

.loading-deck {
  padding: 10px 10px 9px;
  margin-top: 9px;
  border: 1px solid #77545b;
  border-radius: 11px;
  background: linear-gradient(#342632, #291f2b);
}
.deck-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; margin-bottom: 5px; }
.deck-heading h2 { margin: 0; font-size: .82rem; letter-spacing: .06em; white-space: nowrap; }
.deck-heading p { margin: 0; color: var(--muted); font-size: .62rem; text-align: right; }
.deck-count { margin-left: 4px; color: var(--gold); font-size: .64rem; font-variant-numeric: tabular-nums; }
.deck-count.full { color: #ff9c94; }
.waiting, .queues { display: grid; gap: 6px; }
.waiting { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.queues { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.queue-heading { margin-top: 10px; }
.crew {
  position: relative;
  display: block;
  width: 100%;
  height: 57px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--crew-color, #694d5a);
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--crew-color, #684552) 30%, #362635), #302330 90%);
  box-shadow: inset 0 -3px #1d16225e;
}
.waiting .crew { height: 48px; border-radius: 7px; }
.crew:not(:disabled):hover, .crew:not(:disabled):focus-visible { background: #523747; }
.crew:not(:disabled):active { translate: 0 1px; }
.crew:disabled:not(.empty) { opacity: .72; }
.crew.empty {
  border: 1px dashed #765563;
  background: #291e2a;
  box-shadow: none;
}
.seat-number {
  color: #ac8a87;
  font: 600 .72rem Georgia, serif;
}
.crew-art {
  position: absolute;
  bottom: 5px;
  left: 50%;
  translate: -50% 0;
  width: auto;
  height: 45px;
  max-width: 69%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px #241425ae);
}
.waiting .crew-art { height: 34px; bottom: 5px; max-width: 75%; }
.crew.is-arriving .crew-art { visibility: hidden; }
.crew-glyph {
  position: absolute;
  left: 6px;
  top: 4px;
  color: var(--crew-color);
  font-size: .74rem;
  line-height: 1;
}
.crew-ammo {
  position: absolute;
  top: 4px;
  right: 5px;
  min-width: 16px;
  padding: 1px 3px;
  border: 1px solid color-mix(in srgb, var(--crew-color) 75%, #382632);
  border-radius: 4px;
  background: #211922;
  color: var(--ink);
  font-size: .62rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-align: center;
}
.waiting .crew-glyph { left: 4px; }
.waiting .crew-ammo { right: 3px; }
.queue-preview { display: flex; gap: 3px; align-items: center; justify-content: center; min-height: 20px; padding-top: 4px; }
.next-chip {
  border-radius: 4px;
  padding: 1px 4px;
  background: #3a2a39;
  color: var(--muted);
  font-size: .59rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.next-chip b { color: var(--crew-color); margin-right: 3px; }
.flow-footer { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 8px 2px 0; }
.hint { min-height: 1.4em; margin: 0; color: #e1c3ac; font-size: .7rem; line-height: 1.5; }
.flow-links { display: flex; flex: 0 0 auto; gap: 7px; }
.flow-footer a { color: var(--gold); font-size: .7rem; text-underline-offset: 3px; white-space: nowrap; }

.result {
  width: min(350px, calc(100% - 40px));
  max-height: calc(100% - 40px);
  padding: 21px;
  border: 1px solid #9d715e;
  border-radius: 14px;
  color: var(--ink);
  text-align: center;
  background: radial-gradient(ellipse at 50% 12%, #56394a, #2b202c 70%);
  box-shadow: 0 20px 50px #100b12b0;
}
.result::backdrop { background: #160f1abb; }
.result-art { height: 81px; margin-bottom: 9px; }
.result-art img { width: auto; height: 100%; filter: drop-shadow(0 3px 2px #18101a); }
.result h2 { font-size: 2rem; }
.result-detail { margin: 10px 0 16px; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.result-actions button {
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid #8b6464;
  border-radius: 7px;
  background: #41303d;
  font-size: .82rem;
  font-weight: 700;
}
.result-actions .primary { background: var(--gold); color: #34212a; border-color: var(--gold); }

@media (max-width: 355px) {
  .brand, .header-actions { gap: 5px; }
  .brand img { width: 29px; height: 39px; }
  .flow-shell { width: calc(100% - 16px); }
  .flow-heading { margin-bottom: 9px; }
  .side-panel { padding-block: 2px; }
  .loading-deck { padding: 8px 7px 7px; }
  .waiting, .queues { gap: 4px; }
}
