/* Gate Games — the blueplanet-ai look: ink on Sage paper, a teal boarding pass, flat drawn objects.
   Tokens follow the site's design system (DESIGN.md there): light first, then dark twice, once for
   the system setting (unless the player chose light) and once for an explicit dark choice. */

:root {
  --ground: #EBF0E6;
  --surface: #F4F7F0;
  --surface-2: #E0E7DA;
  --line: #CDD6C6;
  --line-strong: #B3BFAB;
  --ink: #0F1719;
  --ink-2: #344145;
  --ink-3: #4E5B5F;
  --signal: #0892A5;
  --signal-text: #066A79;
  --signal-tint: #CFE4E3;
  --on-signal: #FFFFFF;
  --opp: #C2622D;
  --opp-text: #9A4A1F;
  --opp-fill: #9A4A1F;
  --on-opp: #FFFFFF;

  /* The boarding pass */
  --pass: #0B4A54;
  --pass-ink: #F4F7F0;
  --pass-ink-2: #CFE0DF;
  --pass-ink-3: #A9C3C4;
  --pass-line: #5E8A90;
  --pass-btn: #3E6E75;
  --pass-signal: #8FE0EA;
  --pass-opp: #F0A673;

  /* The suitcase and its drawings; --shell is replaced by the equipped shell from the shop */
  --shell: #2F4A4F;
  --shell-dark: color-mix(in srgb, var(--shell) 72%, #000);
  --on-shell: #E7EDEE;
  --lining: #DCE4D6;
  --zip: #B3BFAB;
  --art-ink: #0F1719;
  --art-light: rgba(255, 255, 255, 0.55);
  --slate: #8FA3A6;
  --sea: #D3E2E0;
  --land: #F4F7F0;
  --tag: #E2D3B2;
  --pax-skin: #E2D3B2;
  --pax-prop-light: #E2D3B2;
  --pax-prop-dark: #566E73;
  --shirt-0: #566E73;
  --shirt-1: #C9D6D3;
  --shirt-2: #2F4A4F;
  --shirt-3: #B3BFAB;

  --font-ui: "Saira", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-pass: Arial, Helvetica, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0D1213;
    --surface: #151D1F;
    --surface-2: #1D2729;
    --line: #283436;
    --line-strong: #3C4B4E;
    --ink: #E7EDEE;
    --ink-2: #AFBDBF;
    --ink-3: #8C9A9D;
    --signal: #2BB3C6;
    --signal-text: #2BB3C6;
    --signal-tint: #163A3F;
    --on-signal: #0D1213;
    --opp: #DB8A4F;
    --opp-text: #DB8A4F;
    --opp-fill: #DB8A4F;
    --on-opp: #0D1213;
    --pass: #0A3D45;
    --lining: #151D1F;
    --zip: #6F8184;
    --art-ink: #0D1213;
    --art-light: rgba(255, 255, 255, 0.35);
    --slate: #5F767A;
    --sea: #122326;
    --land: #2A3739;
    --tag: #4A4232;
    --pax-skin: #B9AB8C;
    --pax-prop-light: #B9AB8C;
    --pax-prop-dark: #5F767A;
    --shirt-0: #5F767A;
    --shirt-1: #8FA3A3;
    --shirt-2: #3E5A5F;
    --shirt-3: #6F8184;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground: #0D1213;
  --surface: #151D1F;
  --surface-2: #1D2729;
  --line: #283436;
  --line-strong: #3C4B4E;
  --ink: #E7EDEE;
  --ink-2: #AFBDBF;
  --ink-3: #8C9A9D;
  --signal: #2BB3C6;
  --signal-text: #2BB3C6;
  --signal-tint: #163A3F;
  --on-signal: #0D1213;
  --opp: #DB8A4F;
  --opp-text: #DB8A4F;
  --opp-fill: #DB8A4F;
  --on-opp: #0D1213;
  --pass: #0A3D45;
  --lining: #151D1F;
  --zip: #6F8184;
  --art-ink: #0D1213;
  --art-light: rgba(255, 255, 255, 0.35);
  --slate: #5F767A;
  --sea: #122326;
  --land: #2A3739;
  --tag: #4A4232;
  --pax-skin: #B9AB8C;
  --pax-prop-light: #B9AB8C;
  --pax-prop-dark: #5F767A;
  --shirt-0: #5F767A;
  --shirt-1: #8FA3A3;
  --shirt-2: #3E5A5F;
  --shirt-3: #6F8184;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

button, input, select { font-family: inherit; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.app-container {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 24px;
  gap: 10px;
}

/* Line icons from the sprite in index.html */
.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Boarding pass ---------- */
.pass {
  position: relative;
  overflow: hidden;
  background: var(--pass);
  color: var(--pass-ink);
  border-radius: 14px;
}
.pass-main { display: flex; flex-direction: column; padding: 12px 16px 10px; }
.pass-cities, .pass-details {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.pass-cities span, .pass-details span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass-cities span:last-child, .pass-details span:last-child { text-align: right; }
.pass-cities {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--pass-ink-3);
}
.pass-route {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-pass);
  font-weight: 700;
  font-size: 44px;
  line-height: 1.08;
  letter-spacing: -0.5px;
}
/* The plane between the codes: the text " ✈ " stays for screen readers and copy, drawn as an icon */
.pass-plane {
  width: 30px;
  height: 30px;
  flex: none;
  font-size: 0;
  color: transparent;
  background: var(--pass-ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 12.5c0-.8-.7-1.5-1.5-1.5H15L10.5 3H8.6l2.2 8H6.2L4.6 9H3l1 3.5L3 16h1.6l1.6-2h4.6l-2.2 8h1.9l4.5-8h4.5c.8 0 1.5-.7 1.5-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 12.5c0-.8-.7-1.5-1.5-1.5H15L10.5 3H8.6l2.2 8H6.2L4.6 9H3l1 3.5L3 16h1.6l1.6-2h4.6l-2.2 8h1.9l4.5-8h4.5c.8 0 1.5-.7 1.5-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pass-details { font-family: var(--font-pass); font-size: 14px; color: var(--pass-ink-2); }
/* Tear line with a ticket notch cut into each edge */
.pass-tear { position: relative; height: 0; margin: 0 14px; border-top: 1.5px dashed var(--pass-line); }
.pass-tear::before, .pass-tear::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ground);
}
.pass-tear::before { left: -24px; }
.pass-tear::after { right: -24px; }
.pass-stub { display: flex; align-items: center; gap: 14px; padding: 6px 8px 6px 16px; }
.stub-field { display: flex; flex-direction: column; min-width: 0; }
.stub-label { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--pass-ink-3); }
.stub-value { font-family: var(--font-pass); font-size: 15px; font-weight: 700; white-space: nowrap; }
.stub-value.perfect::after { content: " ★"; color: var(--pass-signal); }
.miles-badge.bump .stub-value { animation: bump 0.45s ease-out; display: inline-block; }
.stub-buttons { margin-left: auto; display: flex; gap: 2px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, transform 0.1s;
}
.icon-btn:hover { border-color: var(--ink-3); }
.icon-btn:active { transform: scale(0.94); }
.pass .icon-btn { color: var(--pass-ink-2); border-color: var(--pass-btn); }
.pass .icon-btn:hover { border-color: var(--pass-ink-3); color: var(--pass-ink); }
.pass :focus-visible { outline-color: var(--pass-signal); }

/* ---------- Connected itinerary ---------- */
.itinerary-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.itinerary-bar.show { display: flex; }
.itinerary-steps { display: flex; gap: 4px; }
.itinerary-step {
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
  white-space: nowrap;
}
.itinerary-step.done { background: var(--signal-tint); border-color: var(--signal); color: var(--signal-text); }
.itinerary-step.active { border-color: var(--ink); color: var(--ink); }

/* ---------- Mode tabs ---------- */
.mode-switcher { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.mode-tab {
  height: 44px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.mode-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--signal); }

/* ---------- Level / flight strips ---------- */
.level-strip { display: flex; gap: 6px; overflow-x: auto; padding: 1px 1px 3px; scrollbar-width: none; }
.level-strip::-webkit-scrollbar { display: none; }
.level-chip {
  flex: 0 0 auto;
  min-width: 56px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.chip-code { display: flex; align-items: center; gap: 3px; font-family: var(--font-pass); font-size: 14px; font-weight: 700; }
.chip-code .ico { width: 13px; height: 13px; stroke-width: 2; }
.level-chip .chip-stars { font-size: 12px; letter-spacing: 1px; color: var(--signal-text); white-space: nowrap; }
.level-chip.active { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.level-chip.locked { border-style: dashed; color: var(--ink-3); cursor: not-allowed; }
.level-chip.locked .chip-stars { color: var(--ink-3); }
.level-chip.perfect { background: var(--signal-tint); border-color: var(--signal); }
.level-chip.solved .chip-stars { color: var(--signal-text); }

/* ---------- Status lines and banners ---------- */
.rule-banner {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.35;
  color: var(--ink-2);
}
.rule-banner.error { color: var(--opp-text); }
.rule-banner.success { color: var(--signal-text); }
.rule-banner .btn { flex: 0 0 auto; font-family: var(--font-ui); }

.curveball-banner {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1.5px dashed var(--opp);
  border-radius: 12px;
  animation: popIn 0.25s ease-out;
}
.curveball-banner.show { display: flex; }
.curveball-top { display: flex; align-items: flex-start; gap: 12px; font-family: var(--font-body); font-size: 16px; line-height: 1.35; }
.curveball-art {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #A7D3D6;
  color: #0F1719;
  display: flex;
  align-items: center;
  justify-content: center;
}
.curveball-art .art { width: 32px; height: 32px; }
.curveball-title { font-family: var(--font-ui); font-weight: 600; font-size: 15px; color: var(--opp-text); }
.curveball-actions { display: flex; gap: 8px; }

/* Win banners read as a second boarding pass */
.win-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  background: var(--pass);
  color: var(--pass-ink);
  border-radius: 14px;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.win-banner.show { display: flex; }
.win-stars { font-size: 20px; letter-spacing: 3px; color: var(--pass-signal); line-height: 1; margin-bottom: 4px; }
.win-stars .dim { color: var(--pass-btn); }
.win-title { font-family: var(--font-pass); font-weight: 700; font-size: 18px; }
.win-sub { font-family: var(--font-pass); font-size: 14px; color: var(--pass-ink-2); }
.win-criteria { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; line-height: 1.5; color: var(--pass-ink-3); }
.win-criteria li.ok { color: var(--pass-ink); }
.win-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.win-banner .btn-ghost { color: var(--pass-ink); border-color: var(--pass-line); }
.win-banner :focus-visible { outline-color: var(--pass-signal); }

/* ---------- Buttons ---------- */
.controls-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; }
.controls-bar.single { grid-template-columns: 1fr; }
.btn {
  flex: 1;
  height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
}
.btn .ico { width: 16px; height: 16px; stroke-width: 2; }
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--opp-fill); color: var(--on-opp); border-color: transparent; font-weight: 600; }
.btn-primary:hover:not(:disabled) { border-color: transparent; filter: brightness(1.08); }
.btn-accent-outline { background: transparent; color: var(--signal-text); border-color: var(--signal-text); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn-xs { flex: 0 0 auto; height: 40px; padding: 0 10px; font-size: 14px; }
.btn.skip-btn { align-self: center; color: var(--ink-3); }
.btn.skip-btn.armed { color: var(--opp-text); border-color: var(--opp-text); }

/* ---------- Suitcase ---------- */
.suitcase-wrapper { display: flex; flex-direction: column; align-items: center; }
/* Telescoping handle: grip bar on two rods */
.suitcase-handle { position: relative; width: 88px; height: 22px; }
.suitcase-handle::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 11px;
  border-radius: 6px;
  background: var(--shell-dark);
}
.suitcase-handle span { position: absolute; left: 16px; right: 16px; top: 3px; height: 5px; border-radius: 3px; background: var(--ground); }
.suitcase-handle::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 11px;
  bottom: 0;
  border-left: 6px solid var(--zip);
  border-right: 6px solid var(--zip);
}
/* Hard shell with darker corner guards and a side handle */
.suitcase-body {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 10px 14px 14px;
  border-radius: 20px;
  background:
    linear-gradient(var(--shell-dark) 0 0) left top / 24px 24px no-repeat,
    linear-gradient(var(--shell-dark) 0 0) right top / 24px 24px no-repeat,
    linear-gradient(var(--shell-dark) 0 0) left bottom / 24px 24px no-repeat,
    linear-gradient(var(--shell-dark) 0 0) right bottom / 24px 24px no-repeat,
    var(--shell);
  transition: transform 0.25s ease, box-shadow 0.4s;
}
.suitcase-body::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 42%;
  width: 7px;
  height: 56px;
  border-radius: 0 4px 4px 0;
  background: var(--shell-dark);
}
.suitcase-body.zipped { box-shadow: 0 0 0 3px var(--signal); }
.suitcase-body.shake { animation: shake 0.32s ease; }

/* Zipper track along the top, with its pull tab on the right */
.tsa-zone-label { position: relative; display: flex; justify-content: center; height: 20px; margin-bottom: 6px; }
.tsa-zone-label::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 24px;
  top: 8px;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--zip) 0 3px, transparent 3px 6px);
}
.tsa-zone-label::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 0;
  width: 12px;
  height: 20px;
  border-radius: 3px 3px 6px 6px;
  background: var(--zip);
}
.tsa-zone-label span {
  position: relative;
  z-index: 2; /* above the zip that runs along the track when the bag closes */
  padding: 0 8px;
  background: var(--shell);
  color: var(--on-shell);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  line-height: 20px;
  text-transform: uppercase;
  white-space: nowrap;
}
/* When the bag is zipped, a teal zip runs along the track */
.zipper { position: absolute; left: 20px; right: 38px; top: 18px; height: 4px; pointer-events: none; opacity: 0; z-index: 1; }
.suitcase-body.zipped .zipper { opacity: 1; }
.zipper-track { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--signal) 0 3px, transparent 3px 6px); }
.zipper-pull { position: absolute; top: -5px; left: 0; width: 8px; height: 14px; border-radius: 2px; background: var(--signal); }
.suitcase-body.zipped .zipper-track { animation: zipTrack 0.9s ease-out forwards; }
.suitcase-body.zipped .zipper-pull { animation: zipPull 0.9s ease-out forwards; }

.suitcase-lining { padding: 8px; background: var(--lining); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--shell-dark); }
.grid { display: grid; gap: 5px; width: 100%; touch-action: none; }
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.12s ease, border-color 0.12s ease;
}
.cell:active { transform: scale(0.96); }
.cell:focus { outline: none; }
.cell:focus-visible { outline: 3px solid var(--signal); outline-offset: -3px; z-index: 3; }
.cell.top-row:not(.filled) { border: 1.5px dashed var(--signal); }
.cell.blocked {
  border-color: transparent;
  background: repeating-linear-gradient(45deg, var(--shell) 0 5px, var(--shell-dark) 5px 10px);
  cursor: not-allowed;
}
/* Packed items: one colour per item, cells merged across the grid gaps, the drawing on the centre cell */
.cell.filled { --fill: var(--c); background: var(--fill); border-color: transparent; }
:root[data-theme="dark"] .cell.filled, :root[data-theme="dark"] .item-figure { --fill: color-mix(in srgb, var(--c) 78%, #0D1213); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cell.filled, :root:not([data-theme="light"]) .item-figure { --fill: color-mix(in srgb, var(--c) 78%, #0D1213); }
}
.cell.join-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cell.join-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cell.join-d { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cell.join-u { border-top-left-radius: 0; border-top-right-radius: 0; }
.cell.join-r::after {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  right: -7px;
  width: 10px;
  background: inherit;
  pointer-events: none;
}
.cell.join-r.join-rd::after { bottom: -7px; }
.cell.join-d::before {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -7px;
  height: 10px;
  background: inherit;
  pointer-events: none;
}
.cell-art { position: relative; z-index: 2; width: 74%; max-width: 46px; aspect-ratio: 1; color: var(--art-ink); pointer-events: none; }
.art { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.art .f { fill: var(--art-light); }
.cell-tag { position: absolute; right: 3px; bottom: 3px; z-index: 2; width: 14px; height: 14px; color: var(--art-ink); pointer-events: none; }
.badge-art { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge-art .f { fill: var(--art-light); }
.cell.drop-in { animation: dropIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }
.cell.preview-valid { background: var(--signal-tint) !important; border: 2px solid var(--signal) !important; }
.cell.preview-invalid { background: color-mix(in srgb, var(--opp) 22%, transparent) !important; border: 2px solid var(--opp) !important; }
.cell.hint { outline: 2px dashed var(--signal-text); outline-offset: -5px; animation: hintPulse 1.2s ease-in-out infinite; }

/* Wheels under the shell */
.suitcase-wheels { display: flex; justify-content: space-between; width: 64%; max-width: 220px; }
.suitcase-wheels span { position: relative; width: 22px; height: 15px; }
.suitcase-wheels span::before { content: ""; position: absolute; left: 3px; right: 3px; top: 0; height: 5px; background: var(--shell-dark); }
.suitcase-wheels span::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 7px var(--zip);
}

/* ---------- Weight balance scale ---------- */
.balance-card { width: 100%; max-width: 340px; margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.balance-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-3);
}
.balance-status.good { color: var(--signal-text); }
.balance-status.warn, .balance-status.bad { color: var(--opp-text); }
.scale { display: block; width: 100%; height: auto; overflow: visible; }
.scale-floor { stroke: var(--line); stroke-width: 1; }
.scale-fulcrum { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.5; stroke-linejoin: round; }
.scale-beam { transform-box: view-box; transform-origin: 160px 33.5px; transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
.scale-bar { fill: var(--ink-2); }
.scale-weight { fill: var(--slate); stroke: var(--art-ink); stroke-width: 1.5; stroke-linejoin: round; }
.scale-ring { fill: none; stroke: var(--ink-2); stroke-width: 2; }
.scale-pointer { stroke: var(--signal); stroke-width: 3; stroke-linecap: round; }
.scale-beam.warn .scale-pointer, .scale-beam.bad .scale-pointer { stroke: var(--opp); }
.scale-text { font-family: var(--font-mono); font-size: 12px; fill: var(--ink-2); }
.balance-vertical { text-align: center; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.balance-vertical.good { color: var(--signal-text); }
.balance-vertical.warn { color: var(--opp-text); }

/* ---------- Items to pack ---------- */
.tray-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
}
.tray-header > span:first-child { font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap; }
.item-tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 6px; }
.item-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 116px;
  padding: 9px 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.item-card:hover { border-color: var(--ink-3); }
.item-card:focus { outline: none; }
.item-card:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.item-card.selected { border: 2px solid var(--signal); padding: 8px 5px 7px; transform: translateY(-2px); }
.item-card.packed { background: var(--surface-2); border-style: dashed; }
.item-card.bonus-card { border-style: dashed; border-color: var(--signal); }
.item-card.bonus-card.selected { border-style: solid; }
.item-figure {
  --fill: var(--c);
  position: relative;
  width: 66px;
  height: 50px;
  border-radius: 8px;
  background: var(--fill);
  color: var(--art-ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-figure .art { width: 38px; height: 38px; }
.item-card.packed .item-figure { opacity: 0.6; }
.item-card.packed .item-figure::after {
  content: "";
  position: absolute;
  left: -7px;
  top: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--signal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center / 12px no-repeat;
}
/* The item's footprint, tucked into the drawing's corner */
.mini-grid {
  position: absolute;
  right: -7px;
  top: -7px;
  display: grid;
  gap: 1px;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.mini-cell { width: 7px; height: 7px; }
.mini-cell.on { background: var(--ink-3); }
.item-card.selected .mini-cell.on { background: var(--signal); }
.item-title {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rule-pill { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; color: var(--ink-3); text-align: center; }
.item-card.selected .rule-pill { color: var(--signal-text); }
.leave-btn {
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--signal-text);
  border: 1px solid var(--signal-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Mode views ---------- */
.mode-view { display: flex; flex-direction: column; gap: 10px; flex: 1; animation: fadeIn 0.2s ease-out; }
.mode-view.hidden { display: none !important; }

/* ---------- Trivia ---------- */
.radar-card { margin: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.radar-svg { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; background: var(--sea); }
.radar-ring { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.radar-axis { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.radar-north { fill: var(--ink-2); }
.radar-label { font-family: var(--font-mono); font-size: 12px; fill: var(--ink-2); }
.radar-route { fill: none; stroke: var(--signal); stroke-width: 2.5; stroke-dasharray: 6 5; stroke-linecap: round; }
.radar-origin { fill: var(--ink); }
.radar-dest { fill: var(--surface); stroke: var(--signal); stroke-width: 2.5; }
.radar-code { font-family: var(--font-pass); font-weight: 700; font-size: 12px; fill: var(--ink); }
.radar-code.dest { fill: var(--signal-text); }
.radar-plane { fill: var(--signal-text); }
/* Route map tip: land under the route, grid hidden, and a soft landing zone instead of a pinpoint */
.map-land { display: none; fill: var(--land); stroke: var(--line-strong); stroke-width: 0.6; stroke-linejoin: round; }
.map-zone { display: none; fill: var(--signal); fill-opacity: 0.16; stroke: var(--signal); stroke-width: 1.5; stroke-dasharray: 3 3; }
.radar-svg.map-on .map-land, .radar-svg.map-on .map-zone { display: inline; }
.radar-svg.map-on .radar-grid, .radar-svg.map-on .radar-dest { display: none; }
.radar-svg.map-on .radar-code { paint-order: stroke; stroke: var(--sea); stroke-width: 3px; stroke-linejoin: round; }
.radar-telemetry {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.clues-list { display: flex; flex-direction: column; gap: 6px; }
.clue-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}
.clue-box.revealed { align-items: flex-start; padding: 8px 10px; background: var(--surface); border: 1px solid transparent; animation: popIn 0.25s ease-out; }
.clue-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--ink-3);
}
.clue-box.revealed .clue-icon { background: var(--signal-tint); color: var(--signal-text); }
.clue-body { flex: 1; min-width: 0; }
.clue-label { font-size: 12px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-3); }
.clue-box.revealed .clue-label { color: var(--signal-text); }
.clue-text { font-family: var(--font-body); font-size: 15px; font-style: italic; line-height: 1.3; color: var(--ink-3); }
.clue-box.revealed .clue-text { font-size: 16px; font-style: normal; color: var(--ink); }

/* Answers are luggage tags: a cut corner on the left and a punched hole */
.destinations-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dest-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 62px;
  padding: 8px 10px 8px 34px;
  background: var(--tag);
  color: var(--ink);
  border: 0;
  border-radius: 0 10px 10px 0;
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}
.dest-btn:hover:not(:disabled) { transform: translateY(-1px); }
.dest-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--signal); }
.dest-btn:disabled { cursor: default; }
.tag-hole {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ground);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}
.dest-iata { font-family: var(--font-pass); font-size: 24px; font-weight: 700; line-height: 1.1; }
.dest-city { font-family: var(--font-body); font-size: 14px; color: var(--ink-2); }
.dest-btn.correct { background: var(--signal-tint); animation: popIn 0.3s ease-out; }
.dest-btn.correct .dest-iata { color: var(--signal-text); }
.dest-btn.wrong { opacity: 0.5; }
.dest-btn.wrong .dest-iata { text-decoration: line-through; color: var(--opp-text); }
.dest-btn.eliminated { opacity: 0.35; }
.dest-btn.eliminated .dest-iata { text-decoration: line-through; }

/* ---------- Boarding group shuffle ---------- */
.shuffle-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; background: var(--surface-2); border-radius: 14px; }
.shuffle-board { position: relative; width: 100%; max-width: 340px; aspect-ratio: 1; }
.shuffle-board.wide { max-width: 360px; }
.jet-door {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: calc(100% / var(--n, 3) - 6px);
  height: calc(100% / var(--n, 3) - 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1.5px dashed var(--opp);
  border-radius: 10px;
  color: var(--opp-text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
}
.door-art { width: 56%; height: auto; }
.door-art .door { fill: var(--surface); stroke: var(--opp); stroke-width: 2; }
.door-art .bridge { fill: none; stroke: var(--opp); stroke-width: 1.75; stroke-linecap: round; }
.pax-tile {
  position: absolute;
  width: calc(100% / var(--n, 3) - 6px);
  height: calc(100% / var(--n, 3) - 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: left 0.18s cubic-bezier(0.22, 1, 0.36, 1), top 0.18s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s;
}
.pax-tile.in-place { background: var(--signal-tint); border: 1.5px solid var(--signal); }
.pax-group { font-family: var(--font-pass); font-size: 13px; font-weight: 700; white-space: nowrap; }
.pax-tile.in-place .pax-group { color: var(--signal-text); }
.pax-label { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.pax-art { width: 64%; height: auto; max-height: 58%; }
.pax-art .sk { fill: var(--pax-skin); }
.pax-art .sh { fill: var(--shirt); }
.pax-art .pr { fill: var(--pax-prop-light); }
.pax-art .pd { fill: var(--pax-prop-dark); }
.pax-art .sk, .pax-art .sh, .pax-art .pr, .pax-art .pd { stroke: var(--art-ink); stroke-width: 1.75; stroke-linejoin: round; }
.pax-art .ln { fill: none; stroke: var(--ink-2); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.pax-art .dot { fill: var(--ink-2); }
.pax-art.shirt-0 { --shirt: var(--shirt-0); }
.pax-art.shirt-1 { --shirt: var(--shirt-1); }
.pax-art.shirt-2 { --shirt: var(--shirt-2); }
.pax-art.shirt-3 { --shirt: var(--shirt-3); }
.shuffle-board.wide .pax-label { display: none; }
.shuffle-board.wide .pax-group { font-size: 12px; }
.shuffle-board.wide .pax-art { width: 70%; max-height: 66%; }
.shuffle-board.wide .jet-door { font-size: 0; }
.shuffle-stats {
  width: 100%;
  max-width: 340px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- Modals (shop, builder) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(13, 18, 19, 0.55);
}
.modal.show { display: flex; }
.modal-sheet {
  width: 100%;
  max-width: 430px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 24px;
  background: var(--ground);
  color: var(--ink);
  border-radius: 16px 16px 0 0;
  animation: sheetUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-family: var(--font-body); font-weight: 600; font-size: 22px; }
.modal-row { display: flex; gap: 8px; }
.modal-note { font-size: 12px; color: var(--ink-3); text-align: center; padding-top: 2px; }
.section-label {
  margin-top: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tier-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: var(--pass); color: var(--pass-ink); border-radius: 12px; }
.tier-name { font-family: var(--font-pass); font-size: 20px; font-weight: 700; }
.tier-sub { font-size: 13px; color: var(--pass-ink-2); }
.tier-track { height: 6px; border-radius: 3px; background: var(--pass-btn); overflow: hidden; }
.tier-fill { height: 100%; background: var(--pass-signal); border-radius: 3px; transition: width 0.4s; }
.skin-list { display: flex; flex-direction: column; gap: 8px; }
.skin-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.skin-row.equipped { border-color: var(--signal); }
.skin-swatch {
  flex: 0 0 auto;
  width: 40px;
  height: 30px;
  border-radius: 7px;
  background:
    linear-gradient(color-mix(in srgb, var(--shell) 72%, #000) 0 0) left top / 9px 9px no-repeat,
    linear-gradient(color-mix(in srgb, var(--shell) 72%, #000) 0 0) right bottom / 9px 9px no-repeat,
    var(--shell);
}
.skin-info { flex: 1; display: flex; flex-direction: column; font-size: 15px; font-weight: 600; }
.skin-info small { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--ink-3); }
.skin-row .btn { flex: 0 0 auto; height: 40px; }
.shop-note { padding: 10px 12px; font-family: var(--font-body); font-size: 15px; line-height: 1.45; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.form-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.form-field input, .form-field select {
  height: 40px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  user-select: text;
  -webkit-user-select: text;
}
.builder-mini-grid {
  display: grid;
  gap: 4px;
  width: 100%;
  max-width: 240px;
  margin: 4px auto;
  padding: 8px;
  background: var(--lining);
  border: 6px solid var(--shell);
  border-radius: 14px;
}
.builder-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--on-shell);
  font-size: 12px;
  cursor: pointer;
}
.builder-cell.blocked { border-color: transparent; background: repeating-linear-gradient(45deg, var(--shell) 0 5px, var(--shell-dark) 5px 10px); }
.records-tabs { margin: 0 -4px; }
.records-panel { display: flex; flex-direction: column; gap: 10px; }
.records-panel.hidden { display: none; }
.records-summary { text-align: left; }
.records-stack { display: flex; flex-direction: column; gap: 10px; }
.record-card { display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.record-title { padding: 2px 8px 4px; font-weight: 600; font-size: 14px; }
.record-empty { padding: 0 8px 4px; font-size: 13px; color: var(--ink-2); }
.daily-card { display: flex; flex-direction: column; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.daily-today { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; background: var(--signal-tint); font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.daily-today.empty { font-family: inherit; font-weight: 400; color: var(--ink-2); }
.daily-stars { font-size: 16px; letter-spacing: 1px; }
.daily-card .section-label.sub { margin: 6px 0 0; }
.day-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; font-family: var(--font-mono); font-size: 12px; }
.day-row span:last-child { color: var(--ink-2); white-space: nowrap; }
.day-row.missed span:last-child { opacity: 0.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  background: var(--ink);
  color: var(--ground);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 30px);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Animations ---------- */
@keyframes popIn { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes dropIn { 0% { transform: scale(0.6) translateY(-6px); opacity: 0.3; } 100% { transform: scale(1); opacity: 1; } }
@keyframes hintPulse { 50% { background-color: var(--signal-tint); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes zipTrack { to { width: 100%; } }
@keyframes zipPull { from { left: 0; } to { left: calc(100% - 8px); } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

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