:root {
  color-scheme: dark;
  --night: #101d1f;
  --night-raised: #17292a;
  --night-soft: #203638;
  --paper: #f2e6c9;
  --paper-bright: #fff8e7;
  --paper-deep: #ddcba5;
  --kraft: #b98752;
  --kraft-light: #d4a66d;
  --kraft-deep: #805a37;
  --ink: #263332;
  --ink-soft: #53615c;
  --ink-faint: #7c8478;
  --wood: #5d402d;
  --wood-light: #88613f;
  --brass: #d6aa58;
  --brass-bright: #f3d68a;
  --rain: #7b9c9d;
  --coral: #ed6a5a;
  --mango: #e5a93c;
  --mint: #4fb997;
  --sky: #5d91d9;
  --violet: #9172c9;
  --line-dark: rgba(31, 42, 40, 0.18);
  --line-light: rgba(255, 248, 231, 0.16);
  --shadow-paper: 0 11px 24px rgba(3, 10, 11, 0.22);
  --shadow-deep: 0 22px 54px rgba(3, 10, 11, 0.38);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  font-family: "Avenir Next", Avenir, ui-rounded, "SF Pro Rounded", "PingFang SC", "Hiragino Sans GB", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--night);
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 7%, rgba(214, 170, 88, 0.13), transparent 28rem),
    radial-gradient(circle at 82% 35%, rgba(93, 145, 217, 0.09), transparent 32rem),
    linear-gradient(155deg, #193032 0%, #0c1719 72%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(105deg, transparent 0 43px, rgba(153, 187, 189, 0.035) 44px 45px, transparent 46px 88px);
  content: "";
  animation: rain-drift 10s linear infinite;
}

@keyframes rain-drift {
  to { background-position: 120px 240px; }
}

button {
  font: inherit;
}

button,
.parcel-button,
.buffer-parcel {
  -webkit-touch-callout: none;
  user-select: none;
}

button:focus-visible {
  outline: 3px solid rgba(243, 214, 138, 0.78);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: var(--safe-top) 14px var(--safe-bottom);
  isolation: isolate;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 60px 42px;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  color: var(--paper-bright);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-seal {
  position: relative;
  display: grid;
  flex: 0 0 39px;
  width: 39px;
  height: 39px;
  margin-right: 10px;
  border: 1px solid rgba(243, 214, 138, 0.58);
  border-radius: 50%;
  place-items: center;
  transform: rotate(-8deg);
}

.brand-seal::before {
  width: 23px;
  height: 23px;
  border: 2px solid var(--brass-bright);
  border-radius: 50%;
  content: "";
}

.brand-seal::after {
  position: absolute;
  right: 6px;
  bottom: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--night);
  box-shadow: -5px -1px 0 0 var(--brass-bright);
  content: "";
}

.brand-seal i {
  position: absolute;
  bottom: -4px;
  left: 3px;
  width: 34px;
  height: 6px;
  border-top: 1px solid rgba(243, 214, 138, 0.7);
  border-bottom: 1px solid rgba(243, 214, 138, 0.4);
}

.brand-copy {
  display: block;
  min-width: 0;
}

.brand-copy small,
.brand-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  margin-bottom: 2px;
  color: rgba(242, 230, 201, 0.56);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.brand-copy strong {
  font-size: clamp(15px, 4.5vw, 19px);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.level-chip,
.language-button,
.icon-button {
  min-height: 42px;
  border: 1px solid rgba(242, 230, 201, 0.18);
  color: var(--paper-bright);
  background: rgba(242, 230, 201, 0.07);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.level-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.level-chip strong {
  color: var(--brass-bright);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.language-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  padding: 3px;
  border-radius: 21px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.language-option {
  display: grid;
  min-width: 22px;
  height: 28px;
  border-radius: 14px;
  color: rgba(242, 230, 201, 0.48);
  place-items: center;
  transition: color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.language-divider {
  width: 7px;
  color: rgba(242, 230, 201, 0.24);
  font-size: 8px;
}

.language-button[data-language="zh"] .language-option-zh,
.language-button[data-language="en"] .language-option-en {
  color: var(--night);
  background: var(--brass-bright);
  box-shadow: 0 2px 8px rgba(3, 10, 11, 0.24);
}

.icon-button {
  display: grid;
  width: 42px;
  padding: 0;
  border-radius: 50%;
  place-items: center;
}

.icon-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sound-off {
  display: none;
}

.is-muted .sound-on {
  display: none;
}

.is-muted .sound-off {
  display: block;
}

.shift-note {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 54px;
  margin-top: 8px;
  padding: 9px 12px 9px 18px;
  overflow: hidden;
  border-radius: 3px 8px 8px 3px;
  background: var(--paper-deep);
  box-shadow: 0 7px 18px rgba(3, 10, 11, 0.2);
  transform: rotate(-0.35deg);
}

.shift-note::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 14px, rgba(65, 64, 51, 0.045) 14px 15px);
  content: "";
}

.shift-pin {
  position: absolute;
  top: 8px;
  left: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b3c31;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.shift-note > div {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-right: 8px;
}

.shift-note p,
.shift-note strong {
  display: block;
  margin: 0;
}

.shift-note p {
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shift-note strong {
  margin-top: 2px;
  overflow: hidden;
  font-family: "Kaiti SC", "STKaiti", "Songti SC", serif;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-stamp {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 5px 7px 4px;
  border: 1px solid rgba(126, 59, 50, 0.52);
  border-radius: 2px;
  color: rgba(126, 59, 50, 0.72);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: rotate(4deg);
}

.order-card {
  position: relative;
  margin-top: 9px;
  padding: 15px 15px 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 231, 0.46);
  border-radius: var(--radius-lg);
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, rgba(77, 72, 55, 0.032) 21px 22px),
    var(--paper-bright);
  box-shadow: var(--shadow-paper);
}

.paper-tape {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 82px;
  height: 18px;
  background: rgba(205, 180, 128, 0.44);
  transform: translateX(-50%) rotate(-1deg);
}

.section-heading,
.buffer-heading,
.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.order-count,
.buffer-note {
  margin: 3px 0 0;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 650;
}

.order-count strong {
  color: var(--ink);
  font-size: 13px;
}

.combo-badge {
  position: relative;
  display: grid;
  min-width: 41px;
  height: 27px;
  padding: 0 8px;
  border: 1px solid rgba(126, 59, 50, 0.34);
  border-radius: 3px;
  color: rgba(126, 59, 50, 0.68);
  background: transparent;
  font-size: 11px;
  font-weight: 950;
  opacity: 0.56;
  place-items: center;
  transform: rotate(3deg) scale(0.94);
  transition: 180ms ease;
}

.combo-badge.is-active {
  color: #7e3b32;
  border-color: #7e3b32;
  opacity: 1;
  transform: rotate(-2deg) scale(1.06);
}

.manifest-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed rgba(38, 51, 50, 0.16);
  color: var(--ink-faint);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.order-track-wrap {
  margin: 7px -3px -2px;
  padding: 3px 3px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-color: rgba(38, 51, 50, 0.2) transparent;
  scrollbar-width: thin;
  touch-action: pan-x;
}

.order-track {
  display: flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  min-width: 100%;
  min-height: 47px;
}

.order-token {
  position: relative;
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--route-color);
  border-radius: 6px;
  color: var(--route-color);
  background: #fffaf0;
  box-shadow: 0 3px 7px rgba(38, 51, 50, 0.13);
  font-size: 13px;
  font-weight: 950;
  opacity: 0.56;
  place-items: center;
  transition: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.order-token::after {
  position: absolute;
  right: -7px;
  width: 5px;
  height: 1px;
  background: rgba(38, 51, 50, 0.25);
  content: "";
}

.order-token:last-child::after {
  display: none;
}

.order-token > span {
  display: grid;
  place-items: center;
}

.order-token > small {
  position: absolute;
  bottom: -12px;
  color: var(--ink-faint);
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.order-token.is-current {
  z-index: 2;
  flex-basis: 45px;
  width: 45px;
  height: 45px;
  border-width: 3px;
  border-radius: 9px;
  background: var(--route-color);
  color: var(--route-ink, #fff);
  opacity: 1;
  transform: translateY(-1px);
  animation: current-order 1.5s ease-in-out infinite;
}

.order-token.is-shipped {
  flex-basis: 25px;
  width: 25px;
  height: 25px;
  border-color: rgba(38, 51, 50, 0.25);
  color: rgba(38, 51, 50, 0.34);
  box-shadow: none;
  opacity: 0.38;
  transform: none;
}

.order-token.is-shipped::before {
  position: absolute;
  width: 24px;
  height: 1px;
  background: rgba(38, 51, 50, 0.42);
  content: "";
  transform: rotate(-32deg);
}

@keyframes current-order {
  50% { box-shadow: 0 4px 10px rgba(38, 51, 50, 0.18), 0 0 0 5px color-mix(in srgb, var(--route-color) 20%, transparent); }
}

.playfield {
  position: relative;
  display: flex;
  min-height: clamp(278px, 39svh, 368px);
  margin-top: 9px;
  padding: 46px 11px 67px;
  overflow: hidden;
  border: 1px solid rgba(242, 230, 201, 0.13);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(86, 116, 116, 0.1), transparent 28%),
    var(--night-raised);
  box-shadow: var(--shadow-deep), inset 0 1px rgba(255, 255, 255, 0.04);
  isolation: isolate;
}

.playfield::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    repeating-linear-gradient(110deg, transparent 0 48px, rgba(145, 179, 179, 0.045) 49px 50px, transparent 51px 82px),
    radial-gradient(circle at 82% 8%, rgba(243, 214, 138, 0.11), transparent 120px);
  content: "";
  animation: rain-field 7s linear infinite;
}

.playfield::after {
  position: absolute;
  right: 11px;
  bottom: 48px;
  left: 11px;
  height: 9px;
  z-index: -1;
  border-top: 2px solid rgba(214, 170, 88, 0.28);
  border-bottom: 1px solid rgba(0, 0, 0, 0.32);
  background: var(--wood);
  content: "";
}

@keyframes rain-field {
  to { background-position: 100px 210px, 0 0; }
}

.rain-window {
  position: absolute;
  top: 7px;
  right: 11px;
  width: 70px;
  height: 31px;
  overflow: hidden;
  border: 2px solid rgba(242, 230, 201, 0.16);
  border-radius: 5px;
  background: linear-gradient(160deg, #263f43, #122326);
  opacity: 0.76;
}

.rain-window::before {
  position: absolute;
  inset: -20px 0;
  background: repeating-linear-gradient(108deg, transparent 0 12px, rgba(180, 211, 211, 0.25) 13px 14px, transparent 15px 26px);
  content: "";
}

.window-moon {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brass-bright);
  box-shadow: 0 0 11px rgba(243, 214, 138, 0.42);
}

.window-moon::after {
  position: absolute;
  top: -2px;
  left: 5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #1b3235;
  content: "";
}

.window-frame::before,
.window-frame::after {
  position: absolute;
  background: rgba(242, 230, 201, 0.16);
  content: "";
}

.window-frame::before { top: 0; bottom: 0; left: 50%; width: 2px; }
.window-frame::after { top: 50%; right: 0; left: 0; height: 2px; }

.factory-header {
  position: absolute;
  top: 15px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(242, 230, 201, 0.58);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.factory-light {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(79, 185, 151, 0.85);
}

.lanes {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(var(--lane-count, 3), minmax(0, 1fr));
  gap: clamp(7px, 2vw, 11px);
  width: 100%;
}

.lane {
  position: relative;
  display: flex;
  min-width: 0;
  padding: 18px 6px 12px;
  overflow: hidden;
  border: 1px solid rgba(242, 230, 201, 0.09);
  border-radius: 15px 15px 9px 9px;
  background: rgba(4, 12, 13, 0.3);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.lane::before {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 17px, rgba(242, 230, 201, 0.085) 17px 23px, transparent 23px 40px);
  content: "";
  opacity: 0.54;
  animation: belt-scroll 1.65s linear infinite;
}

.lane::after {
  display: none;
  position: absolute;
  top: 5px;
  left: 50%;
  color: rgba(242, 230, 201, 0.33);
  font-size: 6px;
  font-weight: 900;
  content: "IN " attr(data-lane-label);
  letter-spacing: 0.12em;
  transform: translateX(-50%);
}

.lane.is-paused::before {
  animation-play-state: paused;
}

@keyframes belt-scroll {
  to { background-position-y: 40px; }
}

.lane-track {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  gap: clamp(5px, 0.8svh, 8px);
  min-height: 100%;
}

.lane-label {
  position: absolute;
  top: 5px;
  left: 50%;
  z-index: 2;
  color: rgba(242, 230, 201, 0.42);
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.parcel-button,
.buffer-parcel,
.flying-parcel {
  position: relative;
  display: grid;
  aspect-ratio: 1.2;
  width: 100%;
  min-height: 42px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(74, 48, 28, 0.44);
  border-radius: 7px;
  color: var(--route-color);
  background:
    linear-gradient(100deg, transparent 0 43%, rgba(106, 70, 39, 0.16) 43% 44%, transparent 44% 100%),
    linear-gradient(152deg, var(--kraft-light), var(--kraft));
  box-shadow: 0 7px 10px rgba(2, 7, 8, 0.28), inset 0 1px rgba(255, 244, 210, 0.3);
  font-size: clamp(13px, 4vw, 19px);
  font-weight: 950;
  place-items: center;
  transition: opacity 160ms ease, transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 160ms ease;
}

.parcel-button::before,
.buffer-parcel::before,
.flying-parcel::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 43%;
  width: 16%;
  border-right: 1px solid rgba(112, 73, 40, 0.16);
  border-left: 1px solid rgba(255, 243, 207, 0.16);
  background: rgba(220, 186, 126, 0.56);
  content: "";
}

.parcel-button::after,
.buffer-parcel::after,
.flying-parcel::after {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 5px;
  border-top: 1px solid rgba(82, 45, 30, 0.26);
  border-bottom: 1px solid rgba(82, 45, 30, 0.2);
  content: "";
  transform: rotate(7deg);
}

.parcel-seam {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.parcel-seam::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 43%;
  width: 16%;
  background: rgba(220, 186, 126, 0.56);
  content: "";
}

.parcel-mark,
.route-tag {
  position: relative;
  z-index: 1;
  display: grid;
  width: 56%;
  min-width: 30px;
  aspect-ratio: 1.3;
  border: 3px solid var(--route-color);
  border-radius: 5px;
  color: var(--route-color);
  background: var(--paper-bright);
  box-shadow: 0 2px 4px rgba(60, 38, 22, 0.2);
  place-items: center;
  text-shadow: none;
}

.route-tag > span {
  display: grid;
  place-items: center;
}

.route-tag > b {
  font-size: clamp(10px, 3.1vw, 15px);
  font-weight: 950;
  letter-spacing: 0.02em;
}

.route-tag > small {
  display: block;
  color: var(--ink-faint);
  font-size: 5px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.parcel-button:not(.is-front) {
  pointer-events: none;
  filter: saturate(0.74) brightness(0.72);
  opacity: 0.68;
  transform: scale(0.92);
}

/* Two-lane boards must not turn every parcel into a tall card and push the
   holding shelf below the phone viewport. Depth, not lane width, owns height. */
.parcel-button {
  aspect-ratio: auto;
}

.lanes[data-depth="1"] .parcel-button { height: 72px; }
.lanes[data-depth="2"] .parcel-button { height: 68px; }
.lanes[data-depth="3"] .parcel-button { height: 58px; }
.lanes[data-depth="4"] .parcel-button { height: 49px; }
.lanes[data-depth="5"] .parcel-button { height: 44px; }

.parcel-button.is-front {
  cursor: pointer;
}

.parcel-button.is-front:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.parcel-button.is-front:active,
.buffer-parcel:active {
  transform: scale(0.94);
}

.parcel-button.is-match,
.buffer-parcel.is-match {
  animation: match-ready 1.25s ease-in-out infinite;
}

@keyframes match-ready {
  50% { box-shadow: 0 7px 10px rgba(2, 7, 8, 0.28), inset 0 1px rgba(255, 244, 210, 0.3), 0 0 0 4px color-mix(in srgb, var(--route-color) 54%, transparent); }
}

[data-color="coral"] { --route-color: var(--coral); --route-ink: #fff; }
[data-color="mango"] { --route-color: var(--mango); --route-ink: #2e291d; }
[data-color="mint"] { --route-color: var(--mint); --route-ink: #102723; }
[data-color="sky"] { --route-color: var(--sky); --route-ink: #fff; }
[data-color="violet"] { --route-color: var(--violet); --route-ink: #fff; }

.dispatch-gate {
  position: absolute;
  bottom: 8px;
  left: 50%;
  display: grid;
  grid-template-columns: 25px 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  width: 112px;
  height: 42px;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(242, 230, 201, 0.24);
  border-radius: 7px 7px 12px 12px;
  color: rgba(242, 230, 201, 0.8);
  background: linear-gradient(180deg, #3b5a58, #294443);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28), inset 0 -4px rgba(0, 0, 0, 0.11);
  transform: translateX(-50%);
  transition: 180ms ease;
}

.dispatch-gate::before {
  position: absolute;
  top: -7px;
  right: 10px;
  left: 10px;
  height: 7px;
  border: 1px solid rgba(242, 230, 201, 0.2);
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  content: "";
}

.gate-ring {
  position: relative;
  display: block;
  width: 22px;
  height: 26px;
  border: 2px solid rgba(243, 214, 138, 0.72);
  border-radius: 3px 3px 7px 7px;
}

.gate-ring::before,
.gate-ring::after {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1px;
  background: rgba(243, 214, 138, 0.28);
  content: "";
}

.gate-ring::before { left: 6px; }
.gate-ring::after { right: 6px; }

.gate-arrow {
  position: absolute;
  left: 15px;
  color: var(--brass-bright);
  font-size: 11px;
  transform: translateY(-1px);
}

.gate-label {
  justify-self: center;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.dispatch-gate.is-shipping {
  color: #fff;
  border-color: rgba(79, 185, 151, 0.75);
  background: #32645a;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28), 0 0 0 5px rgba(79, 185, 151, 0.14);
  transform: translateX(-50%) scale(1.07);
}

.hint-bubble {
  position: absolute;
  top: 57px;
  left: 50%;
  z-index: 8;
  max-width: calc(100% - 38px);
  padding: 8px 11px;
  border: 1px solid rgba(38, 51, 50, 0.13);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper-bright);
  box-shadow: 0 8px 18px rgba(2, 7, 8, 0.3);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px) scale(0.97);
  transition: 180ms ease;
}

.hint-bubble.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.hint-tail {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.buffer-section {
  position: relative;
  margin-top: 9px;
  padding: 12px 14px 14px;
  border: 2px solid rgba(70, 43, 26, 0.38);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 30%),
    linear-gradient(180deg, var(--wood-light), var(--wood));
  box-shadow: 0 8px 18px rgba(3, 10, 11, 0.28), inset 0 1px rgba(255, 240, 207, 0.16);
}

.buffer-section .eyebrow,
.buffer-note {
  color: rgba(255, 244, 218, 0.8);
}

.buffer-note {
  color: rgba(255, 244, 218, 0.54);
}

.shelf-screw {
  position: absolute;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bca475;
  box-shadow: inset 0 0 0 1px rgba(46, 30, 18, 0.36);
}

.shelf-screw::after {
  position: absolute;
  top: 2px;
  left: 1px;
  width: 4px;
  height: 1px;
  background: rgba(46, 30, 18, 0.45);
  content: "";
  transform: rotate(-35deg);
}

.shelf-screw-left { left: 6px; }
.shelf-screw-right { right: 6px; }

.capacity {
  padding: 4px 8px;
  border: 1px solid rgba(255, 244, 218, 0.18);
  border-radius: 4px;
  color: rgba(255, 244, 218, 0.78);
  background: rgba(20, 14, 9, 0.2);
  font-size: 10px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition: 180ms ease;
}

.capacity.is-warning {
  color: #2e291d;
  border-color: transparent;
  background: var(--brass-bright);
  animation: capacity-pulse 1.15s ease-in-out infinite;
}

@keyframes capacity-pulse { 50% { transform: scale(1.06); } }

.buffer-slots {
  display: grid;
  grid-template-columns: repeat(var(--buffer-count, 3), minmax(68px, 94px));
  gap: 8px;
  justify-content: center;
  margin-top: 9px;
}

.buffer-slot {
  position: relative;
  display: grid;
  aspect-ratio: 1.35;
  min-width: 0;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(25, 14, 8, 0.36);
  border-radius: 5px;
  background: rgba(18, 11, 7, 0.22);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.2);
  place-items: center;
  transition: 180ms ease;
}

.buffer-slot::before {
  position: absolute;
  bottom: 3px;
  left: 50%;
  color: rgba(255, 244, 218, 0.25);
  font-size: 6px;
  font-weight: 900;
  content: "格 " attr(data-index);
  transform: translateX(-50%);
}

html[lang="en"] .buffer-slot::before {
  content: "SLOT " attr(data-index);
}

.buffer-slot.is-filled {
  background: rgba(18, 11, 7, 0.3);
}

.buffer-slot.is-last-open {
  border-color: rgba(243, 214, 138, 0.72);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(243, 214, 138, 0.12);
}

.buffer-parcel {
  width: 100%;
  cursor: pointer;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 3px 0;
  color: rgba(242, 230, 201, 0.72);
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}

.control-button:hover {
  background: rgba(242, 230, 201, 0.07);
}

.control-button:disabled {
  cursor: default;
  opacity: 0.27;
}

.control-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.move-counter {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: rgba(242, 230, 201, 0.45);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.move-counter strong {
  color: var(--paper-bright);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.flying-parcel {
  position: fixed;
  z-index: 200;
  min-height: 0;
  margin: 0;
  pointer-events: none;
}

.is-shaking {
  animation: shake 280ms ease-out;
}

@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  padding: 18px;
  background: rgba(4, 11, 12, 0.75);
  backdrop-filter: blur(9px);
  place-items: center;
}

.result-card,
.level-card {
  width: min(100%, 430px);
  max-height: min(88svh, 740px);
  overflow: auto;
  border: 1px solid rgba(255, 248, 231, 0.52);
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(77, 72, 55, 0.032) 22px 23px),
    var(--paper-bright);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: modal-in 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.result-card {
  position: relative;
  padding: 20px 22px 18px;
  border-radius: 8px;
  text-align: center;
}

.result-card::before,
.result-card::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 7px;
  background: radial-gradient(circle at 7px 0, transparent 5px, var(--paper-bright) 5.5px) 0 0 / 14px 7px repeat-x;
  content: "";
}

.result-card::before { top: -1px; transform: rotate(180deg); }
.result-card::after { bottom: -1px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
}

.receipt-topline {
  display: flex;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(38, 51, 50, 0.2);
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.result-orbit {
  position: relative;
  width: 86px;
  height: 86px;
  margin: 17px auto 13px;
  border: 2px solid rgba(126, 59, 50, 0.55);
  border-radius: 50%;
  color: rgba(126, 59, 50, 0.7);
  transform: rotate(-7deg);
}

.result-orbit::before,
.result-orbit::after {
  position: absolute;
  right: 10px;
  left: 10px;
  height: 1px;
  background: rgba(126, 59, 50, 0.42);
  content: "";
}

.result-orbit::before { top: 23px; }
.result-orbit::after { bottom: 23px; }

.postmark-moon {
  position: absolute;
  inset: 25px;
  border: 5px solid rgba(126, 59, 50, 0.65);
  border-radius: 50%;
}

.postmark-moon::after {
  position: absolute;
  top: -7px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--paper-bright);
  content: "";
}

.result-orbit i {
  position: absolute;
  display: grid;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  color: var(--route-ink, #fff);
  background: var(--route-color);
  font-size: 7px;
  font-style: normal;
  place-items: center;
}

.result-orbit i:nth-of-type(1) { top: -4px; left: 33px; }
.result-orbit i:nth-of-type(2) { right: -3px; bottom: 17px; }
.result-orbit i:nth-of-type(3) { bottom: 4px; left: 3px; }

.result-card h1,
.level-card h2 {
  margin: 5px 0 0;
  font-family: "Songti SC", "STSong", Georgia, serif;
  font-size: clamp(27px, 8vw, 37px);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.result-card > p:not(.eyebrow):not(.receipt-footer) {
  max-width: 300px;
  margin: 8px auto 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.result-card > .result-story {
  padding: 7px 9px;
  border-top: 1px dashed rgba(38, 51, 50, 0.15);
  border-bottom: 1px dashed rgba(38, 51, 50, 0.15);
  font-family: "Kaiti SC", "STKaiti", serif;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 18px 0 14px;
}

.result-stats div {
  padding: 10px 6px;
  border: 1px solid rgba(38, 51, 50, 0.09);
  border-radius: 6px;
  background: rgba(38, 51, 50, 0.035);
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.result-stats strong {
  margin-top: 3px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 51px;
  padding: 0 18px;
  border: 0;
  border-radius: 7px;
  color: var(--paper-bright);
  background: var(--night-raised);
  box-shadow: 0 9px 17px rgba(38, 51, 50, 0.22);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.text-button {
  min-height: 42px;
  margin-top: 5px;
  padding: 0 12px;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.receipt-footer {
  margin: 2px 0 0;
  color: rgba(38, 51, 50, 0.35);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.level-card {
  padding: 20px;
  border-radius: 13px;
}

.level-card h2 {
  font-size: 27px;
}

.close-button {
  flex: 0 0 42px;
  color: var(--ink);
  border-color: rgba(38, 51, 50, 0.13);
  background: rgba(38, 51, 50, 0.04);
  font-size: 23px;
  line-height: 1;
}

.chapter-ribbon {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  margin-top: 16px;
  padding: 10px 12px;
  border-left: 3px solid #7e3b32;
  background: rgba(126, 59, 50, 0.06);
}

.chapter-ribbon span {
  grid-row: 1 / 3;
  align-self: center;
  color: #7e3b32;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.chapter-ribbon strong {
  font-size: 12px;
}

.chapter-ribbon small {
  color: var(--ink-faint);
  font-size: 8px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 17px;
}

.level-grid-button {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(38, 51, 50, 0.14);
  border-radius: 7px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.28);
  font-size: 13px;
  font-weight: 900;
  place-items: center;
  cursor: pointer;
}

.level-grid-button.is-current {
  color: var(--paper-bright);
  border-color: var(--night-raised);
  background: var(--night-raised);
  box-shadow: 0 5px 10px rgba(38, 51, 50, 0.2);
}

.level-grid-button.is-complete::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  color: #fff;
  background: #7e3b32;
  font-size: 7px;
  content: "✓";
  place-items: center;
}

.level-grid-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.level-map-note {
  margin: 15px 3px 1px;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 500;
  max-width: calc(100% - 34px);
  padding: 9px 13px;
  border: 1px solid rgba(243, 214, 138, 0.3);
  border-radius: 6px;
  color: var(--paper-bright);
  background: var(--night-raised);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 450;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -18px;
  width: 8px;
  height: 11px;
  border-radius: 2px;
  background: var(--route-color);
  animation: confetti-fall var(--fall-time) cubic-bezier(0.2, 0.65, 0.4, 1) forwards;
}

@keyframes confetti-fall {
  to { transform: translate3d(var(--drift), 110svh, 0) rotate(var(--spin)); }
}

@media (min-width: 620px) and (min-height: 760px) {
  body {
    display: grid;
    padding: 22px;
    place-items: center;
  }

  .game-shell {
    min-height: min(930px, calc(100svh - 44px));
    border: 1px solid rgba(242, 230, 201, 0.11);
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(29, 49, 50, 0.92), rgba(13, 25, 27, 0.95));
    box-shadow: 0 38px 90px rgba(0, 0, 0, 0.42);
  }

  .parcel-button {
    align-self: center;
    max-width: 106px;
  }
}

@media (max-height: 740px) {
  .game-shell { padding-top: 7px; padding-bottom: 7px; }
  .topbar { min-height: 46px; }
  .brand-seal { width: 34px; height: 34px; flex-basis: 34px; }
  .shift-note { min-height: 44px; margin-top: 5px; padding-top: 6px; padding-bottom: 6px; }
  .order-card { margin-top: 6px; padding-top: 11px; padding-bottom: 8px; }
  .manifest-meta { margin-top: 5px; padding-top: 5px; }
  .order-track-wrap { margin-top: 4px; }
  .order-track { min-height: 40px; }
  .order-token { width: 30px; height: 30px; flex-basis: 30px; }
  .order-token.is-current { width: 39px; height: 39px; flex-basis: 39px; }
  .playfield { min-height: 246px; margin-top: 6px; padding-top: 40px; padding-bottom: 58px; }
  .buffer-section { margin-top: 6px; padding-top: 8px; padding-bottom: 8px; }
  .buffer-slots { margin-top: 6px; }
  .controls { padding-top: 3px; }
}

@media (max-width: 380px) {
  .game-shell { padding-left: 9px; padding-right: 9px; }
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto 54px 38px;
    gap: 4px;
  }
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 15px; }
  .brand-seal { margin-right: 7px; }
  .level-chip { padding: 0 9px; }
  .language-button { width: 54px; }
  .topbar > .icon-button { width: 38px; }
  .shift-note strong { font-size: 11px; }
  .story-stamp { font-size: 6px; padding-right: 5px; padding-left: 5px; }
  .playfield { padding-right: 7px; padding-left: 7px; }
  .lanes { gap: 5px; }
  .lane { padding-right: 4px; padding-left: 4px; }
  .level-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 340px) {
  .brand-seal {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    margin-right: 5px;
  }

  .brand-copy strong { font-size: 14px; }
  .level-chip { min-width: 38px; padding: 0 7px; justify-content: center; }
  .level-chip > span { display: none; }
}

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