/* Parcel Sprint: the interface is a shipping label stuck over the street. Airmail border, navy ink, no cards. */
:root {
  --ink: #0f1d45;
  --paper: #f8fafb;
  --paper-dim: #dfe7ee;
  --cobalt: #1c4fb0;
  --mail-red: #d8343d;
  --gold: #ffc21f;
  --teal: #0f9d84;
  --teal-bright: #19c7a6;
  --bug: #ff2d78;
  --bug-ink: #b60f50;
  --display: "Avenir Next Condensed", "DIN Condensed", "Roboto Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "Gill Sans", "Gill Sans MT", "Trebuchet MS", "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --stripes: repeating-linear-gradient(-45deg, var(--mail-red) 0 14px, var(--paper) 14px 22px, #2356c7 22px 36px, var(--paper) 36px 44px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--ink); color: var(--ink); font: 400 16px/1.4 var(--body); overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { position: fixed; inset: 0; }
#app { position: absolute; inset: 0; overflow: hidden; }
#stage, #street { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#street { outline: none; touch-action: none; cursor: grab; }
#street:active { cursor: grabbing; }
#street:focus-visible { box-shadow: inset 0 0 0 4px var(--gold); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

button, a { font-family: var(--body); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }

.loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 10px 16px; color: var(--paper); font: italic 800 26px/1 var(--display); }

/* The label: one strip, printed cells, one stripe. */
.label {
  position: absolute; left: 0; right: 0; top: 0; z-index: 10;
  display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: stretch; gap: 0;
  padding-top: var(--safe-t);
  background: var(--paper); color: var(--ink);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 6px 18px rgba(15, 29, 69, .26);
}
.back { display: flex; align-items: center; justify-content: center; padding: 0 14px; min-width: 44px; min-height: 44px; color: var(--ink); text-decoration: none; font: 700 17px/1 var(--body); border-right: 2px solid var(--ink); }
.back:hover { background: var(--paper-dim); }
.cells { display: flex; margin: 0; min-width: 0; }
.cell { display: flex; flex-direction: column; justify-content: center; padding: 3px 16px 4px; border-right: 1px solid rgba(15, 29, 69, .28); min-width: 0; }
.cell dt { font: 600 11.5px/1.1 var(--body); color: #3c4a70; white-space: nowrap; }
.cell dd { margin: 0; font: italic 800 25px/1.05 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-money dd { font-size: 28px; color: var(--cobalt); }
.cell-debt.warn { background: #ffe1ec; }
.cell-debt.warn dd { color: var(--bug-ink); }
.pips { display: inline-flex; gap: 4px; align-items: center; height: 26px; }
.pip { width: 15px; height: 15px; display: inline-block; }
.pip-heart { background: var(--mail-red); clip-path: path("M7.5 14 1 7.6C-.8 5.7.2 1.4 3.6 1.2c1.6-.1 3 1 3.9 2.4C8.4 2.2 9.8 1.100 11.400 1.200c3.400.2 4.400 4.500 2.600 6.400Z"); }
.pip-heart.off { background: #cfd6df; }
.pip-kit { background: var(--mail-red); border-radius: 3px; position: relative; }
.pip-kit::before, .pip-kit::after { content: ""; position: absolute; background: #fff; }
.pip-kit::before { left: 6px; right: 6px; top: 3px; bottom: 3px; }
.pip-kit::after { top: 6px; bottom: 6px; left: 3px; right: 3px; }
.pip-kit.off { background: #cfd6df; }
.held { display: flex; align-items: center; gap: 8px; padding: 0 10px; font: 600 13px/1.1 var(--body); background: var(--paper-dim); }
.held:empty { display: none; }
.held-chip.streak { background: var(--teal-bright); }
.held-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 6px; border: 2px solid var(--ink); background: var(--gold); white-space: nowrap; }
.cells, .back { order: 0; }
.ribbon { order: 1; }
.held { order: 2; }
.quiet { order: 3; border: 0; border-left: 2px solid var(--ink); background: transparent; color: var(--ink); font: 700 15px/1 var(--body); padding: 0 18px; min-height: 44px; cursor: pointer; }
.quiet:hover { background: var(--paper-dim); }

.ribbon { position: relative; min-height: 44px; background: var(--paper); overflow: hidden; box-shadow: inset 0 -11px 0 var(--paper-dim); }
.ribbon-fill { position: absolute; left: 0; bottom: 0; height: 11px; width: 0; background: var(--stripes); background-size: 62px 62px; border-right: 2px solid var(--ink); }
.ribbon-stage { position: absolute; left: 12px; top: 5px; font: italic 800 22px/1 var(--display); color: var(--ink); white-space: nowrap; }
.ribbon-end { position: absolute; right: 12px; top: 8px; font: 600 13px/1 var(--body); color: #3c4a70; white-space: nowrap; }

/* Short teaching lines. They sit under the label, in the sky, and only ever show one thing. */
.coach {
  position: absolute; z-index: 9; left: 50%; top: calc(var(--safe-t) + 80px); transform: translateX(-50%);
  width: max-content; max-width: min(92vw, 560px);
  padding: 8px 14px 9px; background: var(--ink); color: var(--paper); text-align: center;
  font: italic 800 25px/1.08 var(--display);
  border-left: 8px solid var(--gold);
}
.coach small { display: block; font: 500 14.5px/1.25 var(--body); margin-top: 2px; }
.coach.perk { border-left-color: var(--gold); }
.coach.customer { border-left-color: var(--teal-bright); }
.coach.bug { border-left-color: var(--bug); }

/* Numbers that rise from the courier. */
.floaters { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; font: italic 800 32px/1 var(--display); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; white-space: nowrap; text-align: center; animation: rise 1.05s ease-out forwards; }
.floater.good { color: #ffe27a; }
.floater.meet { color: #8bffe6; }
.floater.bad { color: #ff9dbf; }
.floater small { display: block; margin-top: 3px; font: 600 15px/1.1 var(--body); color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
@keyframes rise { from { opacity: 0; transform: var(--at) translateY(8px); } 12% { opacity: 1; } 75% { opacity: 1; } to { opacity: 0; transform: var(--at) translateY(-44px); } }

/* Next up: three stamps, in the order you'll meet them. */
.next-up { position: absolute; z-index: 7; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 14px); pointer-events: none; }
.next-up ol { list-style: none; display: flex; gap: 8px; margin: 0; padding: 0; }
.stamp { display: flex; align-items: center; gap: 8px; padding: 5px 11px 5px 7px; background: rgba(248, 250, 251, .95); border: 2px solid var(--ink); font: 600 14px/1.1 var(--body); white-space: nowrap; }
.stamp svg { width: 24px; height: 24px; flex: none; }
.stamp b { font: italic 800 19px/1 var(--display); }
.stamp.in-line { background: var(--ink); color: var(--paper); }
.stamp.in-line.bug { background: var(--bug-ink); border-color: var(--ink); }
.stamp.in-line.customer { background: #0a6e5c; }
.stamp.in-line.perk { background: #7c5500; }
.stamp .side { font-weight: 500; }

/* Thumbs. */
.controls { position: absolute; z-index: 9; left: 0; right: 0; bottom: 0; padding: 0 max(14px, env(safe-area-inset-right)) calc(var(--safe-b) + 14px) max(14px, env(safe-area-inset-left)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.controls > * { pointer-events: auto; }
.steer { display: flex; gap: 10px; }
.pad { width: 74px; height: 74px; border: 2px solid var(--ink); background: rgba(248, 250, 251, .93); color: var(--ink); font: 700 44px/1 var(--body); padding: 0 0 8px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.pad:hover { background: #fff; }
.pad.down { background: var(--gold); }
.patch { touch-action: none; min-width: 158px; min-height: 74px; border: 2px solid var(--ink); background: rgba(248, 250, 251, .93); color: var(--ink); padding: 8px 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.patch-word { font: italic 800 28px/1 var(--display); white-space: nowrap; }
.patch-kits { font: 600 13.5px/1 var(--body); }
.patch.ready { background: var(--bug); color: #fff; border-color: var(--ink); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.patch.ready .patch-kits { color: #fff; }
.patch.empty { background: rgba(223, 231, 238, .92); color: #39435e; }

/* Waybill */
.sheet-wrap { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: flex-start; padding: max(16px, var(--safe-t)) clamp(16px, 5vw, 76px) max(16px, var(--safe-b)); overflow: auto; background: linear-gradient(90deg, rgba(15, 29, 69, .42), rgba(15, 29, 69, 0) 62%); }
.sheet { width: min(100%, 470px); margin: auto 0; background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--ink), 0 20px 50px rgba(15, 29, 69, .4); }
.airmail { height: 12px; background: var(--stripes); background-size: 62px 62px; }
.sheet-body { padding: 20px 24px 22px; }
.sheet h1, .sheet h2 { margin: 0; font-family: var(--display); font-style: italic; font-weight: 800; letter-spacing: -.008em; line-height: .9; }
.sheet h1 { font-size: 76px; color: var(--ink); white-space: nowrap; }
.sheet h2 { font-size: clamp(42px, 7vw, 60px); line-height: .95; }
.lede { margin: 10px 0 14px; font-size: 17.5px; line-height: 1.34; max-width: 26em; }
.lede b { font-weight: 700; }

.verbs { margin: 0 0 12px; padding: 0; list-style: none; border-top: 2px solid var(--ink); }
.verb { display: grid; grid-template-columns: 58px 1fr; gap: 0 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(15, 29, 69, .28); }
.verb .thumb { width: 58px; height: 58px; display: block; object-fit: contain; }
.verb-name { font: italic 800 25px/1 var(--display); }
.verb.perk .verb-name b { color: #8a5f00; }
.verb.customer .verb-name b { color: #067562; }
.verb.bug .verb-name b { color: var(--bug-ink); }
.verb-name b { font-weight: 800; }
.verb p { margin: 2px 0 0; font-size: 14.5px; line-height: 1.26; }

.keys { font-size: 14px; line-height: 1.32; margin: 0 0 14px; color: #2a3454; }
.keys kbd { font: 600 12.5px/1 var(--body); border: 1.5px solid var(--ink); padding: 1px 5px 2px; background: #fff; white-space: nowrap; }

.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.primary { background: var(--ink); color: #fff; border: 2px solid var(--ink); padding: 13px 22px 14px; min-height: 52px; font: italic 800 26px/1 var(--display); cursor: pointer; }
.primary:hover { background: var(--cobalt); }
.secondary { background: transparent; color: var(--ink); border: 2px solid var(--ink); padding: 8px 14px; min-height: 44px; font: 600 15px/1 var(--body); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.secondary:hover { background: var(--paper-dim); }
.secondary[aria-pressed="true"] { background: var(--ink); color: #fff; }
#sheet-content .note { margin: 0 0 12px; }
.note { margin: 12px 0 0; font-size: 13px; line-height: 1.3; color: #39435e; }

/* Result */
.rating { margin: 2px 0 8px; font: 600 16px/1.2 var(--body); color: #2a3454; }
.total { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 8px; }
.total strong { font: italic 800 clamp(58px, 11vw, 78px)/.92 var(--display); color: var(--cobalt); font-variant-numeric: tabular-nums; }
.total span { font-size: 13.5px; color: #39435e; }
.books { width: 100%; border-collapse: collapse; margin: 0 0 8px; border-top: 2px solid var(--ink); font-size: 15px; }
.books th { text-align: left; font-weight: 500; padding: 3px 0; border-bottom: 1px solid rgba(15, 29, 69, .2); }
.books td { text-align: right; padding: 3px 0 3px 12px; border-bottom: 1px solid rgba(15, 29, 69, .2); font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.books tr.minus td { color: var(--bug-ink); }
.books tr.sum th, .books tr.sum td { border-bottom: 2px solid var(--ink); border-top: 2px solid var(--ink); font-weight: 800; }
.lesson { margin: 0 0 12px; font-size: 14.5px; line-height: 1.3; }
.score-head { display: flex; justify-content: space-between; align-items: baseline; }

/* Paused dims the world so the sheet reads as the only live thing. */
.sheet-wrap.dim { background: rgba(15, 29, 69, .5); justify-content: center; }
.sheet-wrap.center { justify-content: center; background: rgba(15, 29, 69, .4); }

.fixture-flag { position: absolute; z-index: 30; right: 8px; bottom: 8px; background: #000; color: #fff; font: 600 12px/1 var(--body); padding: 4px 6px; }

/* Mouse and keyboard screens don't need the big pads taking up the view. */
@media (min-height: 860px) and (min-width: 761px) {
  .sheet h1 { font-size: 92px; white-space: normal; }
}

@media (hover: hover) and (pointer: fine) and (min-width: 760px) {
  .pad { width: 56px; height: 56px; font-size: 34px; }
  .patch { min-width: 142px; min-height: 56px; }
  .patch-word { font-size: 24px; }
}

@media (max-width: 760px) {
  .label { grid-template-columns: auto 1fr auto; }
  .ribbon { grid-column: 1 / -1; grid-row: 2; min-height: 0; height: 26px; border-top: 1px solid var(--ink); box-shadow: inset 0 -7px 0 var(--paper-dim); }
  .ribbon-fill { height: 7px; }
  .ribbon-stage { top: 2px; left: 8px; font-size: 16px; }
  .ribbon-end { top: 4px; right: 8px; font-size: 11.5px; }
  .back { padding: 0 8px; min-width: 40px; border-right-width: 1px; }
  .back-word { display: none; }
  .cell { padding: 2px 7px 3px; }
  .cell dt { font-size: 10.5px; }
  .cell dd { font-size: 20px; }
  .cell-money { margin-left: auto; }
  .cell-money dd { font-size: 22px; }
  .pips { height: 20px; gap: 2px; }
  .pip { width: 13px; height: 13px; transform-origin: left center; }
  .pip-heart { transform: scale(.86); }
  .pip-kit::before { left: 5px; right: 5px; top: 2px; bottom: 2px; }
  .pip-kit::after { top: 5px; bottom: 5px; left: 2px; right: 2px; }
  .cells { justify-content: space-between; }
  .held { position: absolute; left: 6px; right: 6px; top: calc(100% + 5px); padding: 0; flex-wrap: wrap; gap: 4px; background: none; }
  .held-chip { font-size: 12px; padding: 2px 6px 3px; }
  .quiet { padding: 0 10px; font-size: 14px; border-left-width: 1px; }
  .coach { top: calc(var(--safe-t) + 104px); font-size: 21px; max-width: calc(100vw - 20px); width: calc(100vw - 20px); }
  .coach small { font-size: 13.5px; }
  .next-up { bottom: calc(var(--safe-b) + 98px); left: 8px; right: 8px; transform: none; }
  .next-up ol { justify-content: center; gap: 5px; }
  .stamp { font-size: 12px; padding: 3px 6px 3px 4px; gap: 4px; }
  .stamp svg { width: 18px; height: 18px; }
  .stamp b { font-size: 16px; }
  .stamp:nth-child(n+3) { display: none; }
  .controls { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .steer { gap: 8px; }
  .pad { width: 70px; height: 74px; }
  .patch { flex: 0 1 148px; min-width: 128px; padding: 6px 8px; }
  .patch-word { font-size: 25px; }
  .sheet-wrap { align-items: flex-end; padding: 10px; background: linear-gradient(0deg, rgba(15, 29, 69, .52), rgba(15, 29, 69, 0) 66%); }
  .sheet { width: 100%; margin: auto 0 0; }
  .sheet-body { padding: 13px 15px 14px; }
  .sheet h1 { font-size: 56px; }
  .sheet h2 { font-size: 40px; }
  .lede { font-size: 15px; margin: 4px 0 7px; line-height: 1.25; }
  .verb { grid-template-columns: 42px 1fr; padding: 4px 0; gap: 0 8px; }
  .verb .thumb { width: 42px; height: 42px; }
  .verb-name { font-size: 20px; }
  .verb p { font-size: 13px; }
  .keys { display: none; }
  #sheet-content .note { margin-bottom: 8px; font-size: 12px; }
  .primary { flex: 1 1 100%; min-height: 48px; padding: 9px 16px 10px; }
  .sheet-actions { gap: 6px; }
  .sheet-actions .secondary { flex: 1 1 auto; justify-content: center; padding: 6px 8px; font-size: 14px; }
  .books { font-size: 14px; }
  .books th, .books td { padding-top: 2px; padding-bottom: 2px; }
  .total strong { font-size: 54px; }
  .lesson { font-size: 13.5px; }
}

@media (max-height: 480px) {
  .sheet-wrap { align-items: flex-start; justify-content: center; padding: 6px; background: rgba(15, 29, 69, .28); }
  .sheet { width: min(100%, 640px); margin: 0 auto; }
  .airmail { height: 8px; }
  .sheet-body { padding: 8px 16px 10px; }
  .sheet h1 { font-size: 44px; }
  .sheet h2 { font-size: 34px; }
  .lede { font-size: 14px; margin: 3px 0 5px; line-height: 1.2; }
  .verbs { margin-bottom: 6px; }
  .verb .thumb { width: 28px; height: 28px; }
  .verb { grid-template-columns: 28px 1fr; padding: 1px 0; gap: 0 8px; }
  .verb-name { font-size: 19px; }
  .verb p { display: none; }
  .keys { display: none; }
  .note { margin-top: 4px; font-size: 12px; }
  .primary { flex: 1 1 auto; min-height: 44px; font-size: 22px; padding: 7px 14px 8px; }
  .sheet-actions .secondary { flex: 0 1 auto; padding: 5px 8px; font-size: 13px; }
  .total { margin: 2px 0 4px; }
  .total strong { font-size: 40px; }
  .rating { margin: 0 0 2px; font-size: 14px; }
  .books { font-size: 13px; margin-bottom: 4px; }
  .books th, .books td { padding-top: 1px; padding-bottom: 1px; }
  .lesson { font-size: 12.5px; margin-bottom: 6px; }
  .pad { width: 58px; height: 58px; }
  .patch { min-height: 58px; }
  .next-up { display: none; }
  .coach { top: calc(var(--safe-t) + 54px); font-size: 19px; padding: 4px 10px 5px; }
  .coach small { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .floater { animation: settle .95s linear forwards; }
  @keyframes settle { from { opacity: 0; transform: var(--at); } 10% { opacity: 1; } 80% { opacity: 1; } to { opacity: 0; transform: var(--at); } }
}
