.delivery-app {
  --page-background: #0c201b;
  --paper: #172f28;
  --ink: #faf4e4;
  --muted: #b7c9b8;
  --line: #3a574a;
  --panel: #1a362d;
  --panel-raised: #244337;
  --highlight: #d9ee92;
  --amber: #f9c882;
  --stage-width: 1032px;
  --stage-padding: 12px 24px calc(96px + env(safe-area-inset-bottom));
  --control-radius: 10px;
  color-scheme: dark;
  background: radial-gradient(ellipse at 50% 0, #203e31, var(--page-background) 700px);
  min-height: 100svh;
  color: var(--ink);
  font-size: 16px;
}

.delivery-app button {
  background: var(--highlight);
  color: #15251a;
  font-weight: 750;
}
.delivery-app button.secondary {
  background: var(--panel-raised);
  color: var(--ink);
  border-color: var(--line);
}
.delivery-app button.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.delivery-app button:focus-visible,
.delivery-app a:focus-visible,
.delivery-app summary:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}
.delivery-app [tabindex="-1"]:focus { outline: none; }

.delivery-app .app-header {
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 24px 10px;
}
.delivery-app .app-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
  white-space: nowrap;
}
.app-brand-mark {
  width: 30px;
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  background: var(--highlight);
  border-radius: 8px;
}
.app-brand-mark::before {
  content: "";
  width: 14px;
  height: 13px;
  border: 2px solid #203727;
  border-radius: 2px;
}
.app-brand-mark::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 13px;
  width: 4px;
  height: 7px;
  background: #203727;
}
.delivery-app .app-toolbar { flex-wrap: nowrap; gap: 6px; }
.delivery-app .app-toolbar button { padding-inline: 10px; font-size: 13px; }
.app-point-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  color: var(--amber);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.app-point-balance > span {
  display: grid;
  place-items: center;
  width: 20px;
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
}
.delivery-app:has(.ld-gameplay) .app-header,
.delivery-app.tutorial-playing .app-header { display: none; }
.delivery-app:has(.ld-gameplay) .app-stage {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(30px, env(safe-area-inset-bottom));
}
.delivery-app .registration {
  max-width: 450px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 25px;
  margin-top: clamp(18px, 5vh, 60px);
  background: linear-gradient(to top, var(--paper) 65%, #172f2890), url("./assets/delivery-town.png") center 24% / cover;
}
.delivery-app .registration h1 { padding-top: 68px; text-shadow: 0 1px 10px #0c201b; }
.delivery-app .field { font-size: 15px; }
.delivery-app input:not([type="checkbox"]), .delivery-app select {
  background: #10251e;
  color: var(--ink);
  border-color: var(--line);
}
.delivery-app .field-error { color: #ffbaa7; }
.delivery-app .field-error:empty { display: none; }
.delivery-app .form-error { background: #512e28; color: #ffcab9; }
.delivery-app .dialog {
  border-radius: 18px;
  box-shadow: 0 22px 60px #050e0ba8;
}
.delivery-app .dialog::backdrop { background: #08140fd1; }
.delivery-app .dialog-close { background: transparent; color: var(--ink); }
.delivery-app .toast {
  z-index: 110;
  bottom: calc(85px + env(safe-area-inset-bottom));
  color: #15251a;
  background: var(--highlight);
}
.delivery-app:has(.ld-gameplay) .toast { bottom: max(18px, env(safe-area-inset-bottom)); }

.ld-kicker {
  color: var(--highlight);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  overflow-wrap: anywhere;
}
.ld-hero {
  display: grid;
  align-items: end;
  min-height: clamp(350px, 48vw, 490px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid #82917a;
  background: #294135 url("./assets/delivery-town.png") center 45% / cover no-repeat;
}
.ld-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(80deg, #0b1f18f5 4%, #0b1f18cc 31%, #0b1f1840 62%, transparent 84%),
    linear-gradient(0deg, #0b1f18c4, transparent 52%);
}
.ld-hero-content { padding: clamp(24px, 5vw, 56px); }
.ld-hero h1 {
  font-size: clamp(35px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: .03em;
  line-height: 1.2;
  margin-block: 8px 14px;
}
.ld-hero h1 + p { color: #f0ebd8; font-size: clamp(14px, 2.2vw, 17px); }
.ld-launch {
  margin-top: 25px;
  width: min(100%, 318px);
  min-height: 56px;
  justify-content: space-between;
  padding-inline: 18px;
}
.ld-arrow { font-size: 25px; line-height: .8; font-weight: 500; }
.ld-home-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.ld-home-record, .ld-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.ld-home-record h2, .ld-panel-heading h2 { font-size: 16px; }
.ld-home-stats, .ld-hud, .ld-result-stats {
  display: grid;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.ld-home-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
  gap: 8px;
}
.ld-home-stats div + div { border-left: 1px solid var(--line); padding-left: 10px; }
.ld-home-stats dt, .ld-hud dt, .ld-result-stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.ld-home-stats dd, .ld-hud dd, .ld-result-stats dd {
  margin: 1px 0 0;
  color: var(--highlight);
  font-size: clamp(22px, 3.6vw, 34px);
  line-height: 1.15;
  font-weight: 850;
}
.ld-home-stats dd small, .ld-hud dd small, .ld-result-stats dd small {
  margin-left: 2px;
  color: var(--muted);
  font-size: 12px;
}
.ld-home-stats div:first-child dd { color: var(--amber); }
.ld-home-actions { display: grid; gap: 8px; }
.ld-home-actions .ld-tile {
  display: grid;
  grid-template-columns: 21px 1fr auto;
  align-items: center;
  gap: 5px 13px;
  padding: 9px 14px;
  text-align: left;
}
.ld-tile strong { display: block; font-size: 15px; }
.ld-tile small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.ld-tile .ld-arrow { color: var(--highlight); }

.ld-nav {
  position: fixed;
  z-index: 10;
  inset: auto 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  background: #10251ff5;
  border-top: 1px solid var(--line);
}
.ld-nav-inner {
  max-width: 600px;
  margin: auto;
  padding: 5px 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.ld-nav button {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 3px 2px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.ld-nav button[aria-current="page"] {
  background: #2b4936;
  border-color: #46644a;
  color: var(--highlight);
}
.ld-nav-icon { position: relative; display: block; width: 20px; height: 20px; color: currentColor; }
.ld-nav-icon::before, .ld-nav-icon::after { content: ""; position: absolute; }
.ld-nav-icon-home::before {
  inset: 3px 4px auto;
  height: 12px;
  transform: rotate(45deg);
  border: 2px solid currentColor;
  border-right: 0;
  border-bottom: 0;
  border-radius: 2px;
}
.ld-nav-icon-home::after {
  inset: 8px 4px 1px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 2px 2px;
}
.ld-nav-icon-delivery::before {
  inset: 4px 1px 5px;
  border: 2px solid currentColor;
  border-radius: 3px 8px 2px 2px;
}
.ld-nav-icon-delivery::after {
  left: 4px;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 8px 0 currentColor;
}
.ld-nav-icon-office::before {
  inset: 3px 1px 1px;
  border: 2px solid currentColor;
  border-radius: 4px 4px 2px 2px;
}
.ld-nav-icon-office::after {
  inset: 9px 5px 2px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
}
.ld-nav-icon-shop::before { inset: 6px 2px 1px; border: 2px solid currentColor; border-radius: 3px; }
.ld-nav-icon-shop::after { inset: 1px 6px auto; height: 8px; border: 2px solid currentColor; border-bottom: 0; border-radius: 8px 8px 0 0; }
.ld-nav-icon-guide { display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; line-height: 1; }

.ld-play-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ld-play-heading h1 { grid-column: 2; font-size: clamp(19px, 3vw, 27px); white-space: nowrap; }
.ld-play-heading button { padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.ld-back { justify-self: start; }
.ld-office-shortcut { justify-self: end; }
.ld-hud {
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  margin-bottom: 10px;
}
.ld-hud > div { padding: 6px 12px 8px; }
.ld-hud > div + div { border-left: 1px solid var(--line); }
.ld-hud > div:first-child { background: #2b4936; }
.ld-hud > div:first-child dt { color: var(--highlight); }
.ld-hud dd { font-size: clamp(21px, 3vw, 29px); }
.ld-play-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}
.ld-board {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  min-width: 0;
}
.ld-town { position: relative; isolation: isolate; aspect-ratio: 1.12; background: #344b38; border-radius: 10px; }
.ld-town > svg { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; }
.delivery-app .ld-house {
  position: absolute;
  left: clamp(65px, var(--x), calc(100% - 65px));
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0;
  min-height: 44px;
  padding: 3px 6px;
  white-space: nowrap;
  border: 1px solid #eee7cf;
  border-radius: 7px;
  color: var(--ink);
  background: #122823f5;
  font-size: 14px;
  line-height: 1.23;
  box-shadow: 0 2px 4px #05140f90;
}
.delivery-app .ld-house[data-node="depot"] { left: max(39px, var(--x)); }
.ld-house small { color: #d4dfcf; font-size: 15px; font-weight: 500; }
.ld-house.is-delivered small { color: #d9ee92; }
.ld-stop-tag { font-size: 11px; color: var(--highlight); }
.delivery-app .ld-house.is-current { border-color: var(--highlight); box-shadow: 0 0 0 2px #142a23; }
.delivery-app .ld-house.is-selected { z-index: 2; border-color: #ffd5be; background: #612e21; }
.ld-house.is-selected small { color: #ffe8dc; }
.ld-house.is-selected .ld-stop-tag { color: #ffe8dc; }
.delivery-app .is-overdue { color: #ffc0a8; }
.ld-map-key {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 8px;
  padding: 5px 5px 6px;
  color: var(--muted);
  font-size: 12px;
}
.ld-map-key span:first-child::before {
  content: "";
  display: inline-block;
  width: 13px;
  margin-right: 6px;
  border-top: 2px solid var(--ink);
  vertical-align: middle;
}
.ld-route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 45px;
  border-radius: 10px;
  background: var(--panel-raised);
  padding: 8px 10px;
}
.ld-route-copy strong { display: block; font-size: 15px; }
.ld-route-copy small { display: block; color: var(--muted); font-size: 13px; }
.ld-route button { padding-inline: 12px; font-size: 14px; }
.ld-auto-delivery { grid-column: 1 / -1; color: var(--amber); font-size: 13px; }
.ld-dispatch { display: grid; gap: 10px; }
.ld-dispatch .ld-panel { padding: 10px 12px; }
.ld-panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.ld-panel-heading > span { white-space: nowrap; color: var(--amber); font-size: 13px; font-weight: 750; }
.ld-manifest-list { margin-top: 4px; }
.ld-manifest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-block: 5px;
}
.ld-manifest-row + .ld-manifest-row { border-top: 1px solid var(--line); }
.ld-manifest-row strong, .ld-parcel strong { display: block; font-size: 14px; }
.ld-manifest-row small, .ld-parcel small { display: block; color: var(--muted); font-size: 14px; }
.ld-manifest-row button { flex: 0 0 auto; padding: 5px 10px; min-width: 48px; font-size: 14px; }
.ld-cargo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 7px; }
.ld-parcel, .ld-cargo-empty { border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.ld-cargo-empty { display: grid; place-items: center; border-style: dashed; color: var(--muted); min-height: 44px; font-size: 13px; }
.ld-parcel { background: #152d25; }
.ld-parcel-actions { display: grid; gap: 4px; margin-top: 5px; }
.ld-parcel-actions button { padding: 4px; font-size: 13px; }
.ld-event, .ld-howto { color: var(--muted); font-size: 14px; padding-inline: 3px; }
.ld-howto summary { display: list-item; align-content: center; min-height: 44px; cursor: pointer; }
.ld-howto p { padding-bottom: 10px; }

.ld-screen-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 14px;
}
.ld-screen-heading h1 { font-size: clamp(27px, 4vw, 37px); }
.ld-count {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--amber);
  font-size: 13px;
  white-space: nowrap;
}
.ld-office-grid, .ld-shop-grid { display: grid; align-items: start; gap: 12px; }
.ld-office-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.ld-shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ld-shop-grid .shop-item { border: 1px solid var(--line); }
.ld-shop-grid .shop-item p, .ld-plan-board > p { font-size: 14px; }
.ld-van-display {
  margin-top: 10px;
  padding: 16px 8px;
  background: radial-gradient(ellipse, #4a6c52, #112921 76%);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.ld-van-display svg { width: min(100%, 255px); display: block; margin: auto; }
.ld-van-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.ld-van-options button { display: grid; justify-items: center; gap: 2px; padding: 5px; }
.ld-van-options button[aria-pressed="true"] { border-color: var(--highlight); color: var(--highlight); }
.ld-van-options svg { width: 77px; }
.ld-van-options small { font-size: 12px; }
.ld-plan {
  display: grid;
  grid-template-columns: 68px 1fr;
  align-items: start;
  gap: 10px;
  padding: 12px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.ld-plan > svg { width: 68px; border-radius: 6px; background: var(--paper); }
.ld-plan h3 { font-size: 16px; overflow-wrap: anywhere; }
.ld-plan p, .ld-plan-empty { margin: 4px 0; color: var(--muted); font-size: 13px; }
.ld-plan-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ld-plan-actions button { font-size: 13px; padding-inline: 9px; }
.ld-product-van { display: flex; gap: 5px; }
.ld-product-van svg { width: calc(50% - 3px); }

.ld-result { max-width: 660px; margin: auto; }
.ld-result-banner {
  padding: clamp(22px, 7vw, 65px) 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  background: linear-gradient(#0c201b9c, #0c201bf5), url("./assets/delivery-town.png") center 32% / cover;
}
.ld-result-banner h1 { margin-block: 5px; font-size: clamp(36px, 7vw, 60px); }
.ld-result-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  text-align: center;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--panel);
}
.ld-result-stats div { padding: 12px 2px; }
.ld-result-stats div + div { border-left: 1px solid var(--line); }
.ld-result-stats div:nth-child(3) dd { color: var(--amber); }
.ld-result-actions {
  display: grid;
  gap: 9px;
  padding: 14px;
  text-align: center;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 20px 20px;
  background: var(--paper);
}
.ld-result-actions p { color: var(--muted); font-size: 14px; }
.ld-result-actions p strong { color: var(--amber); }

@media (hover: hover) {
  .delivery-app button:not(:disabled):hover { filter: brightness(1.13); }
  .delivery-app .ld-house:not(:disabled):hover { border-color: var(--amber); }
}
@media (max-width: 740px) {
  .delivery-app { --stage-padding: 8px 12px calc(82px + env(safe-area-inset-bottom)); }
  .delivery-app .app-header { padding-inline: 12px; }
  .ld-play-grid, .ld-office-grid, .ld-shop-grid { grid-template-columns: 1fr; }
  .ld-dispatch .ld-panel { padding-block: 8px; }
  .ld-manifest-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
  .ld-manifest-row { gap: 4px; }
  .ld-manifest-row small { font-size: 13px; white-space: nowrap; }
  .ld-manifest-row button { min-width: 44px; padding-inline: 4px; }
  .ld-manifest-row + .ld-manifest-row { border: 0; }
  .ld-manifest-row:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ld-town { aspect-ratio: 1.13; }
}
@media (max-width: 520px) {
  .delivery-app .app-header { min-height: 60px; padding-block: max(6px, env(safe-area-inset-top)) 6px; }
  .delivery-app .app-brand { font-size: 14px; gap: 6px; }
  .app-brand-mark { width: 26px; }
  .app-brand-mark::after { top: 6px; left: 11px; }
  .delivery-app .app-toolbar { gap: 2px; }
  .delivery-app .app-toolbar button { padding-inline: 6px; }
  .app-point-balance { padding-inline: 4px; font-size: 14px; }
  .ld-hero { min-height: clamp(335px, 94vw, 405px); border-radius: 18px; }
  .ld-hero::before { background: linear-gradient(0deg, #0b1f18 1%, #0b1f18d9 31%, #0b1f1833 72%, transparent); }
  .ld-hero-content { padding: 20px; }
  .ld-launch { width: 100%; min-height: 50px; margin-top: 16px; }
  .ld-home-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .ld-home-record { padding: 9px 12px 12px; }
  .ld-home-stats { margin-top: 6px; }
  .ld-home-actions { grid-template-columns: 1fr 1fr; gap: 6px; }
  .ld-home-actions .ld-tile { grid-template-columns: 20px 1fr; gap: 6px; padding: 8px; }
  .ld-tile .ld-arrow { display: none; }
  .ld-tile small { font-size: 11px; }
  .ld-play-grid { gap: 8px; }
  .ld-town { aspect-ratio: 1.2; }
  .ld-hud > div { padding: 5px 9px 6px; }
  .ld-van-display { padding: 8px; }
}
@media (max-width: 420px) {
  .ld-house[data-node="h1"] { margin-top: 22px; }
  .ld-house[data-node="h2"] { margin-top: -9px; }
  .ld-house[data-node="h3"] { margin-top: 16px; }
  .ld-house[data-node="h4"] { margin-top: -26px; }
  .ld-house[data-node="h5"] { margin-top: 8px; }
}
@media (max-width: 360px) {
  .ld-manifest-list { grid-template-columns: 1fr; }
  .ld-manifest-row:nth-child(n+2) { border-top: 1px solid var(--line); }
  .ld-play-heading { gap: 4px; }
  .ld-play-heading button { padding-inline: 6px; }
}
