* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(180deg, #87ceeb 0%, #e8f4fc 40%, #f5e6c8 100%);
  color: #2c3e50;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.error-panel {
  background: #ff6b6b;
  color: #fff;
  padding: 1rem;
  text-align: center;
  font-size: 1.1rem;
}

.game-header {
  background: #ffd93d;
  border-bottom: 4px solid #f4a261;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.game-header h1 {
  font-size: 1.6rem;
  color: #e76f51;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.hud-item {
  background: #fff;
  border: 3px solid #264653;
  border-radius: 12px;
  padding: 0.4rem 0.9rem;
  min-width: 90px;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #666;
  font-weight: 700;
}

.hud-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
}

.bank-display .hud-value {
  font-size: 1.4rem;
  color: #264653;
}

.bank-display .hud-value.bank-negative {
  color: #c1121f;
}

.bank-display .hud-value.bank-positive {
  color: #264653;
}

.cash-flash-green {
  animation: cashPulseIn 0.6s ease;
}

.cash-flash-red {
  animation: cashPulseOut 0.6s ease;
}

@keyframes cashPulseIn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes cashPulseOut {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); color: #c1121f; }
}

.game-main {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
}

.factory-area {
  flex: 1 1 720px;
  min-width: 0;
}

.factory-floor {
  position: relative;
  background: #c8b896;
  border: 6px solid #8b6914;
  border-radius: 16px;
  min-height: 460px;
  overflow: visible;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.12);
}

.factory-stage {
  display: grid;
  min-height: 460px;
  width: 100%;
}

.stage-area {
  position: relative;
  min-height: 460px;
}

.stage-input {
  background: rgba(69, 123, 157, 0.12);
  border-right: 3px dashed #457b9d;
  padding: 0.5rem;
  padding-top: 1.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.loading-bay-title {
  position: absolute;
  top: 0.35rem;
  left: 0;
  right: 0;
  z-index: 20;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #2f4858;
  text-align: center;
  letter-spacing: 0.04em;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.85);
}

.stage-grid {
  padding: 8px;
}

.stage-output {
  background: rgba(231, 111, 81, 0.1);
  border-left: 3px dashed #e76f51;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.5rem;
}

.area-label,
.parking-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #555;
  text-align: center;
  padding: 0.25rem;
}

.output-zone {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
}

.storage-zone {
  border-bottom: 2px dashed rgba(0, 0, 0, 0.15);
}

.customer-zone {
  min-height: 110px;
  justify-content: flex-end;
}

.customer-parking-bay {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  top: 24px;
  border: 2px dashed rgba(29, 53, 87, 0.4);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(29, 53, 87, 0.05) 1px, transparent 1px) 0 0 / 16px 16px,
    rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 0;
}

.customer-zone .parking-label {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 0.15rem 0.25rem;
}

.customer-zone .customer-vehicle-slot {
  position: relative;
  z-index: 2;
  width: calc(100% - 12px);
  max-width: 176px;
  height: calc(100% - 30px);
  min-height: 72px;
  margin-top: 22px;
  align-items: flex-end;
  justify-content: center;
}

.factory-grid {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 420px;
  gap: 6px;
}

.grid-cell {
  background: #d4c4a0;
  border: 2px dashed #a08040;
  border-radius: 8px;
  position: relative;
  min-height: 90px;
}

.cell-label {
  display: none;
}

.route-svg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

body.route-selection-active .route-svg {
  pointer-events: auto;
}

body.route-selection-active .route-graphic.route-selectable {
  cursor: pointer;
}

body.route-selection-active .route-graphic.route-selectable .route-line {
  pointer-events: stroke;
}

.route-graphic.route-selectable .route-line {
  filter: drop-shadow(0 0 2px rgba(74, 64, 56, 0.35));
}

.route-graphic.route-selected .route-line {
  filter: drop-shadow(0 0 4px rgba(69, 123, 157, 0.65));
}

.routes-layer .route-line {
  stroke: #4a4038;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.route-connector-line {
  stroke: #4a4038;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.factory-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.factory-unit,
.external-unit,
.storage-unit,
.route-runtime,
.transporter,
.flying-product {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.unit-loader-wrap {
  width: 108px;
  max-width: 100%;
  z-index: 12;
  margin: 0 auto;
}

.unit-loader-wrap.supplier-delivery-active .loader-hidden-during-delivery {
  visibility: hidden;
}

.unit-loader-wrap .supplier-delivery-van {
  pointer-events: none;
}

/* Shared factory truck (delivery + customer) — SVG identity with functional overlays */
.factory-truck {
  position: relative;
  margin: 0 auto;
  text-align: center;
}

.factory-truck .truck-art {
  position: absolute;
  inset: 0;
}

.factory-truck .truck-art svg {
  display: block;
  width: 100%;
  height: 100%;
}

.factory-truck .truck-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Delivery truck — smaller, blue cab, open cargo-door treatment.
   viewBox 0 0 195 118 → aspect-ratio 195/118. */
.delivery-truck {
  width: 102px;
  max-width: 100%;
  aspect-ratio: 195 / 118;
}

.delivery-truck .truck-overlay .loader-product-emerge {
  position: absolute;
  left: 69.74%;
  top: 30.51%;
  width: 21.54%;
  height: 47.46%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delivery-truck .loader-emerging-product {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  animation: loaderProductEmerge 0.55s ease-in-out infinite alternate;
}

@keyframes loaderProductEmerge {
  from { transform: translateX(-2px); opacity: 0.75; }
  to { transform: translateX(5px); opacity: 1; }
}

.delivery-truck .loader-release-point {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translate(50%, -50%);
  width: 12px;
  height: 12px;
  border: 2px dashed transparent;
  border-radius: 50%;
  pointer-events: none;
}

.loader-release-point {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translate(50%, -50%);
  width: 12px;
  height: 12px;
  border: 2px dashed transparent;
  border-radius: 50%;
  pointer-events: none;
}

.loader-body {
  background: #457b9d;
  border: 3px solid #1d3557;
  border-radius: 10px;
  padding: 6px;
  text-align: center;
}

.loader-chute {
  width: 22px;
  height: 18px;
  background: #333;
  margin: 4px auto 0;
  border-radius: 0 0 6px 6px;
}

.storage-sublabel {
  font-size: 0.62rem;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  margin-bottom: 4px;
  text-shadow: none;
}

.unit-machine {
  width: auto;
  max-width: 118px;
  z-index: 10;
  isolation: isolate;
}

.machine-wip-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.machine-core {
  position: relative;
  width: 92px;
}

.machine-wip-input,
.machine-wip-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.wip-label {
  font-size: 0.52rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #495057;
  line-height: 1;
}

.machine-mask {
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  background-color: #8b9198;
  z-index: 0;
  pointer-events: none;
}

.machine-body {
  background-color: #6c757d;
  border: 2px solid #343a40;
  border-radius: 10px;
  padding: 0;
  text-align: center;
  position: relative;
  z-index: 1;
  min-height: 114px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.machine-artwork-layer {
  position: relative;
  flex: 1 1 auto;
  min-height: 80px;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
  background: #eef1f4;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.machine-info-panel {
  position: relative;
  z-index: 2;
  padding: 5px 6px 4px;
  background: rgba(52, 58, 64, 0.92);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.machine-name,
.unit-name {
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 1px 1px 0 #000, 0 0 4px rgba(0, 0, 0, 0.45);
}

.machine-condition-label {
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ffe8a3;
  text-shadow: 1px 1px 0 #000;
  margin-top: 1px;
}

.storage-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: #264653;
  text-shadow: none;
  margin-bottom: 4px;
}

.machine-speed {
  font-size: 0.62rem;
  font-weight: 700;
  color: #f8f9fa;
  text-shadow: 1px 1px 0 #000;
  margin: 0;
  padding: 3px 6px 5px;
  background: rgba(52, 58, 64, 0.92);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.machine-indicator {
  font-size: 0.58rem;
  margin-top: 2px;
  color: #dee2e6;
  text-shadow: 1px 1px 0 #000;
}

.machine-warning-light {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #555;
  opacity: 0;
  z-index: 3;
}

.machine-working-parts {
  display: none;
}

.unit-machine.machine-condition-old .machine-artwork-layer {
  background: #8a7f6e;
}

.unit-machine.machine-condition-upgraded .machine-artwork-layer {
  background: #aebac0;
}

.unit-machine.machine-condition-new .machine-artwork-layer {
  background: #e2a530;
}

.art-cue-crack,
.art-cue-tape,
.art-cue-sparkle {
  display: none;
}

.machine-condition-old .art-cue-crack { display: inline; }
.machine-condition-upgraded .art-cue-tape { display: inline; }
.machine-condition-new .art-cue-sparkle { display: inline; }

.machine-artwork-layer svg {
  display: block;
  width: 100%;
  height: 100%;
}

.unit-machine.machine-state-working .machine-artwork-layer svg {
  animation: artBuzz 0.15s steps(1) infinite;
}

@keyframes artBuzz {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(0.5px, -0.5px); }
  50% { transform: translate(-0.5px, 0.5px); }
  75% { transform: translate(0.5px, 0.5px); }
}

.unit-machine.machine-state-working .machine-artwork-cutter .cutter-blade {
  transform-origin: 28px 14px;
  animation: cutterStroke 0.35s ease-in-out infinite alternate;
}

@keyframes cutterStroke { from { transform: rotate(0deg); } to { transform: rotate(-9deg); } }

.unit-machine.machine-state-working .machine-artwork-driller .driller-head {
  animation: drillerPress 0.45s ease-in-out infinite alternate;
}

@keyframes drillerPress { from { transform: translateY(0); } to { transform: translateY(5px); } }

.unit-machine.machine-state-working .machine-artwork-sander .sander-stripes {
  animation: sanderScroll 0.4s linear infinite alternate;
}

@keyframes sanderScroll { from { transform: translateX(0); } to { transform: translateX(-6px); } }

.unit-machine.machine-state-working .machine-artwork-packer .packer-flap-left {
  transform-origin: 24px 28px;
  animation: flapLeft 0.5s ease-in-out infinite alternate;
}

.unit-machine.machine-state-working .machine-artwork-packer .packer-flap-right {
  transform-origin: 64px 28px;
  animation: flapRight 0.5s ease-in-out infinite alternate;
}

@keyframes flapLeft { from { transform: rotate(0deg); } to { transform: rotate(-16deg); } }
@keyframes flapRight { from { transform: rotate(0deg); } to { transform: rotate(16deg); } }

.unit-machine.machine-state-working .machine-artwork-painter .painter-gun {
  transform-origin: 38px 54px;
  animation: gunSweep 0.6s ease-in-out infinite alternate;
}

.unit-machine.machine-state-working .machine-artwork-painter .painter-spray {
  transform-origin: 60px 33px;
  animation: paintSpray 0.6s ease-in-out infinite alternate;
}

@keyframes gunSweep { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes paintSpray {
  from { opacity: 0.5; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.unit-machine.machine-state-working .machine-artwork-washer .washer-drum {
  transform-origin: 46px 62px;
  animation: spin 1.4s linear infinite;
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.unit-machine.machine-state-working .machine-artwork-press .press-ram {
  animation: pressDown 0.5s ease-in-out infinite alternate;
}

@keyframes pressDown { from { transform: translateY(0); } to { transform: translateY(6px); } }

.unit-machine.machine-state-working .machine-artwork-moulder .mould-left {
  animation: mouldOpenL 0.6s ease-in-out infinite alternate;
}

.unit-machine.machine-state-working .machine-artwork-moulder .mould-right {
  animation: mouldOpenR 0.6s ease-in-out infinite alternate;
}

@keyframes mouldOpenL { from { transform: translateX(0); } to { transform: translateX(-4px); } }
@keyframes mouldOpenR { from { transform: translateX(0); } to { transform: translateX(4px); } }

.unit-machine.machine-state-working .machine-artwork-stamper .stamp-ram {
  animation: stampDown 0.4s ease-in-out infinite alternate;
}

.unit-machine.machine-state-working .machine-artwork-stamper .stamp-impact {
  animation: impactFlash 0.4s steps(1) infinite alternate;
}

@keyframes stampDown { from { transform: translateY(0); } to { transform: translateY(8px); } }
@keyframes impactFlash { from { opacity: 0.25; } to { opacity: 1; } }

.unit-machine.machine-state-working .machine-artwork-lathe .lathe-chuck {
  transform-origin: 46px 54px;
  animation: spin 1s linear infinite;
}

.unit-machine.machine-state-working .machine-artwork-grinder .grinder-wheel {
  transform-origin: 44px 56px;
  animation: spinFast 0.6s linear infinite;
}

.unit-machine.machine-state-working .machine-artwork-grinder .grinder-spark {
  animation: sparkFlicker 0.25s steps(1) infinite alternate;
}

@keyframes spinFast { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sparkFlicker { from { opacity: 0.3; } to { opacity: 1; } }

.unit-machine.machine-state-working .machine-artwork-welder .welder-arc {
  animation: arcFlicker 0.2s steps(2) infinite;
}

@keyframes arcFlicker { 0% { opacity: 0.3; } 50% { opacity: 1; } 100% { opacity: 0.3; } }

.unit-machine.machine-state-working .machine-artwork-assembler .assembler-arm {
  animation: armPress 0.5s ease-in-out infinite alternate;
}

@keyframes armPress { from { transform: translateY(0); } to { transform: translateY(6px); } }

.unit-machine.machine-state-working .machine-artwork-oven .oven-heat {
  transform-box: fill-box;
  transform-origin: center;
  animation: heatPulse 0.6s ease-in-out infinite alternate;
}

@keyframes heatPulse {
  from { opacity: 0.55; transform: scaleY(0.75); }
  to { opacity: 1; transform: scaleY(1.2); }
}

.unit-machine.machine-state-working .machine-artwork-sprayer .sprayer-mist {
  transform-origin: 64px 58px;
  animation: mistPulse 0.5s ease-in-out infinite alternate;
}

@keyframes mistPulse {
  from { opacity: 0.5; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.unit-machine.machine-state-working .machine-artwork-polisher .polisher-shine {
  animation: shineSweep 0.4s ease-in-out infinite alternate;
}

@keyframes shineSweep {
  from { transform: translate(0, 0); opacity: 0.6; }
  to { transform: translate(4px, -4px); opacity: 1; }
}

.unit-machine.machine-state-working .machine-artwork-filler .filler-drip {
  animation: dripFall 0.8s ease-in infinite;
}

@keyframes dripFall {
  0% { transform: translateY(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(10px); opacity: 0; }
}

.unit-machine.machine-state-working .machine-artwork-sealer .sealer-top {
  animation: sealTop 0.5s ease-in-out infinite alternate;
}

.unit-machine.machine-state-working .machine-artwork-sealer .sealer-bottom {
  animation: sealBottom 0.5s ease-in-out infinite alternate;
}

@keyframes sealTop { from { transform: translateY(0); } to { transform: translateY(4px); } }
@keyframes sealBottom { from { transform: translateY(0); } to { transform: translateY(-4px); } }

.unit-machine.machine-state-working .machine-artwork-labeler .labeler-roll {
  transform-origin: 30px 40px;
  animation: spin 1s linear infinite;
}

.unit-machine.machine-state-working .machine-artwork-wrapper .wrapper-roll {
  transform-origin: 24px 34px;
  animation: spin 1s linear infinite;
}

.unit-machine.machine-state-working .machine-artwork-wrapper .wrapper-lines {
  animation: wrapShift 0.4s ease-in-out infinite alternate;
}

@keyframes wrapShift {
  from { transform: translateX(-2px); opacity: 0.7; }
  to { transform: translateX(2px); opacity: 1; }
}

.art-generic {
  position: absolute;
  inset: 0;
}

.art-generic-panel {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 10px;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

.machine-product-slot {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 16px;
}

.machine-state-waiting .machine-mask,
.machine-state-waiting .machine-body {
  background-color: #8b9198;
  border-color: #495057;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.machine-state-working .machine-mask,
.machine-state-working .machine-body {
  background-color: #5c636a;
  border-color: #2d6a4f;
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.95), 0 0 12px rgba(64, 145, 108, 0.45);
}

.machine-state-working .machine-mask {
  background-color: #40916c;
}

.machine-state-working .machine-working-parts {
  display: none;
}

.machine-state-blocked .machine-mask,
.machine-state-blocked .machine-body {
  background-color: #7d848a;
  border-color: #e63946;
  box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.35);
}

.machine-state-blocked .machine-warning-light {
  opacity: 1;
  background: #e63946;
  animation: warningBlink 0.6s ease-in-out infinite;
}

@keyframes machinePulse {
  from { transform: translateX(-50%) scaleX(0.8); }
  to { transform: translateX(-50%) scaleX(1.2); }
}

@keyframes warningBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.machine-product-slot {
  display: none;
}

.machine-input-queue,
.machine-processing-slot,
.route-dispatch-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 4px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(0, 0, 0, 0.22);
  border-radius: 6px;
  position: static;
  transform: none;
  width: auto;
  max-width: 112px;
  margin-top: 0;
}

.queue-count {
  font-size: 0.6rem;
  font-weight: 800;
  background: #264653;
  color: #fff;
  border-radius: 8px;
  padding: 0 5px;
}

.product-chip,
.wooden-product,
.toy-product,
.generic-product {
  width: 18px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid #5c4033;
  flex-shrink: 0;
}

.toy-product {
  background: linear-gradient(135deg, #ffd166 0%, #f4a261 100%);
  border-color: #e76f51;
}

.wooden-product {
  background: linear-gradient(180deg, #deb887 0%, #8b6914 100%);
}

.generic-product {
  background: linear-gradient(180deg, #90be6d 0%, #577590 100%);
}

.floating-product {
  position: absolute;
  z-index: 12;
}

.floating-product.inside-machine {
  position: relative;
  transform: none;
}

.floating-product.waiting-dispatch {
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
}

.flying-product {
  z-index: 20;
  transition: left 0.45s linear, top 0.45s linear;
}

.cash-wad {
  position: absolute;
  width: 22px;
  height: 16px;
  transform: translate(-50%, -50%);
  z-index: 25;
  pointer-events: none;
}

.cash-note {
  position: absolute;
  border: 2px solid #1b4332;
  border-radius: 2px;
  background: linear-gradient(180deg, #52b788 0%, #2d6a4f 100%);
}

.cash-note.note-back {
  width: 20px;
  height: 14px;
  top: 2px;
  left: 2px;
  opacity: 0.7;
  transform: rotate(-4deg);
}

.cash-note.note-mid {
  width: 20px;
  height: 14px;
  top: 1px;
  left: 1px;
  opacity: 0.85;
  transform: rotate(2deg);
}

.cash-note.note-front {
  width: 20px;
  height: 14px;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cash-euro {
  font-size: 0.65rem;
  font-weight: 900;
  color: #1b4332;
}

.cash-band {
  position: absolute;
  top: 6px;
  left: -1px;
  width: 22px;
  height: 4px;
  background: #ffd166;
  border: 1px solid #1b4332;
  border-radius: 1px;
  opacity: 0.9;
}

.route-runtime {
  z-index: 6;
}

.route-wait-point {
  width: 10px;
  height: 10px;
  border: 2px solid #8b7355;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
}

.route-dispatch-queue {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 7;
}

.transporter {
  width: 40px;
  height: 44px;
  z-index: 15;
  opacity: 0.45;
}

.transporter.active {
  opacity: 1;
}

.transporter.active .transporter-symbol {
  animation: transporterBob 0.45s ease-in-out infinite alternate;
}

.transporter.blocked {
  opacity: 0.7;
  filter: grayscale(0.3);
}

.transporter-icon {
  position: relative;
  text-align: center;
}

.transporter-symbol {
  font-size: 1.4rem;
  line-height: 1;
  display: block;
}

.transporter-carry {
  position: absolute;
  top: 2px;
  right: -6px;
}

@keyframes transporterBob {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.conveyor-belt {
  display: block;
  width: 28px;
  height: 8px;
  margin: 6px auto 0;
  border-radius: 2px;
  background: repeating-linear-gradient(
    90deg,
    #6c757d 0,
    #6c757d 4px,
    #adb5bd 4px,
    #adb5bd 8px
  );
  border: 1px solid #495057;
}

.transporter-conveyor.active .conveyor-belt {
  animation: conveyorScroll 0.6s linear infinite;
}

@keyframes conveyorScroll {
  from { background-position: 0 0; }
  to { background-position: 16px 0; }
}

.robot-body {
  display: block;
  width: 22px;
  height: 18px;
  margin: 4px auto 0;
  border-radius: 4px;
  background: #457b9d;
  border: 2px solid #1d3557;
  position: relative;
}

.robot-body::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #a8dadc;
  border: 1px solid #1d3557;
}

.transporter-robot.active .robot-body {
  animation: robotGlide 0.5s ease-in-out infinite alternate;
}

@keyframes robotGlide {
  from { transform: translateX(-2px); }
  to { transform: translateX(2px); }
}

.btn-transport {
  background: #6d6875;
  color: #fff;
}

.transport-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.transport-option-btn {
  flex: 1 1 auto;
  min-width: 7rem;
  padding: 0.45rem 0.6rem;
  border: 2px solid #adb5bd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.transport-option-btn.transport-option-selected {
  border-color: #457b9d;
  background: #e8f4f8;
}

.transport-option-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.transport-unaffordable {
  display: block;
  font-size: 0.75rem;
  color: #c1121f;
}

.transport-select-prompt {
  color: #6c757d;
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

.storage-unit {
  width: 100%;
  max-width: 150px;
  position: relative;
  transform: none;
  text-align: center;
}

.storage-unit.storage-full {
  outline: 3px solid #e63946;
  border-radius: 8px;
  padding: 4px;
}

.storage-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.storage-slot {
  width: 22px;
  height: 18px;
  border: 2px dashed #666;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.storage-slot.filled {
  border-style: solid;
  background: rgba(255, 255, 255, 0.75);
}

.customer-van-slot,
.customer-vehicle-slot {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.customer-van,
.customer-truck {
  position: relative;
  text-align: center;
  transition: transform 0.7s ease, opacity 0.4s ease;
}

.customer-van.phase-hidden,
.customer-truck.phase-hidden {
  opacity: 0;
  transform: translateX(110%);
}

.customer-van.phase-enter,
.customer-truck.phase-enter {
  opacity: 1;
  transform: translateX(42%);
}

.customer-van.phase-park,
.customer-van.phase-collect,
.customer-truck.phase-park,
.customer-truck.phase-collect {
  opacity: 1;
  transform: translateX(0);
}

.customer-van.phase-depart,
.customer-truck.phase-depart {
  opacity: 1;
  transform: translateX(115%);
  transition: transform 0.9s ease;
}

.customer-truck {
  width: 168px;
  max-width: 100%;
  aspect-ratio: 270 / 118;
  position: relative;
  transition: transform 0.7s ease, opacity 0.4s ease;
}

.customer-truck .truck-overlay .truck-trailer-slots {
  position: absolute;
  left: 24.44%;
  top: 32.20%;
  width: 48.15%;
  height: 40.68%;
  display: grid;
  grid-auto-rows: 1fr;
  gap: 2px;
  align-content: stretch;
  justify-content: center;
  pointer-events: none;
}

.truck-slot {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1.5px solid rgba(32, 28, 20, 0.55);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.truck-slot.filled {
  border-style: solid;
  border-color: #201c14;
  background: rgba(255, 255, 255, 0.88);
}

.truck-slot .product-chip {
  width: 78%;
  height: 68%;
}

.van-body {
  width: 64px;
  height: 36px;
  margin: 0 auto;
  background: #e63946;
  border: 3px solid #1d3557;
  border-radius: 8px 14px 6px 6px;
  position: relative;
}

.van-body::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  width: 18px;
  height: 14px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 3px;
}

.van-body::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 10px;
  width: 12px;
  height: 12px;
  background: #333;
  border-radius: 50%;
  box-shadow: 32px 0 0 #333;
}

.van-cargo {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  margin-top: 4px;
  min-height: 16px;
}

.van-cash-burst {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 800;
  color: #06d6a0;
  opacity: 0;
  pointer-events: none;
}

.van-cash-burst.visible {
  opacity: 1;
  animation: cashBurst 0.5s ease;
}

@keyframes cashBurst {
  0% { transform: translateX(-50%) translateY(8px); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-14px); opacity: 0; }
}

.control-panel {
  flex: 0 1 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.intermission-panel {
  background: #fff;
  border: 3px solid #264653;
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-panel {
  background: #fff;
  border: 3px solid #2a9d8f;
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.order-panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #264653;
}

.order-panel-note {
  margin: 0;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.35;
}

.order-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.order-option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.order-option-btn:not([disabled]):hover {
  border-color: #2a9d8f;
}

.order-option-btn.order-option-selected {
  border-color: #2a9d8f;
  background: #e9f7f4;
}

.order-option-btn[disabled] {
  opacity: 0.72;
  cursor: not-allowed;
}

.order-option-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #264653;
}

.order-option-detail {
  font-size: 0.76rem;
  color: #555;
}

.order-unavailable {
  font-size: 0.74rem;
  color: #c1121f;
  font-weight: 600;
}

.order-confirmation-panel .confirmation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.supplier-delivery-van {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 132px;
  transform: translateX(-50%);
  z-index: 14;
  transition: transform 0.65s ease, opacity 0.35s ease;
}

.supplier-delivery-van.phase-hidden {
  opacity: 0;
  transform: translate(-50%, 110%);
}

.supplier-delivery-van.phase-enter {
  opacity: 1;
  transform: translate(-50%, 18%);
}

.supplier-delivery-van.phase-unload {
  opacity: 1;
  transform: translate(-50%, 0);
}

.supplier-delivery-van.phase-depart {
  opacity: 1;
  transform: translate(-50%, -115%);
  transition: transform 0.85s ease;
}

.supplier-delivery-van .delivery-truck {
  width: 100%;
}

.intermission-message {
  font-size: 0.85rem;
  font-weight: 700;
  color: #264653;
  line-height: 1.35;
}

.upgrade-panel {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 0.65rem;
}

.bottleneck-label {
  display: none;
}

.intermission-message {
  display: none;
}

.decision-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.decision-option {
  background: #f8f9fa;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.decision-option-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #457b9d;
  text-transform: uppercase;
  margin: 0;
}

.decision-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  padding: 0.1rem 0;
  color: #555;
}

.decision-row strong {
  color: #264653;
}

.decision-unavailable {
  font-size: 0.75rem;
  color: #c1121f;
  font-weight: 600;
  margin: 0;
}

.forecast-block {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}

.forecast-note {
  font-size: 0.72rem;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  margin: 0 0 0.25rem;
}

.forecast-row {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.74rem;
  margin: 0.12rem 0;
  color: #555;
}

.forecast-row strong {
  text-align: right;
}

.forecast-row .delta-positive {
  color: #2a9d8f;
}

.forecast-row .delta-negative {
  color: #c1121f;
}

.forecast-unavailable {
  font-size: 0.74rem;
  color: #6c757d;
  margin: 0;
}

.forecast-details {
  margin-top: 0.35rem;
  font-size: 0.72rem;
}

.forecast-details summary {
  cursor: pointer;
  color: #457b9d;
  font-weight: 600;
}

.upgrade-panel-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #457b9d;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.upgrade-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  padding: 0.15rem 0;
  color: #555;
}

.upgrade-row strong {
  color: #264653;
}

.intermission-actions,
.decision-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.machine-selection-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.confirmation-panel,
.pass-confirmation-panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.confirmation-content {
  background: #fff;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 0.65rem;
}

.confirmation-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #264653;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}

.confirmation-emphasis {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.2rem 0;
  color: #264653;
}

.confirmation-speed {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.55rem 0.45rem;
  margin: 0.35rem 0;
  color: #264653;
  background: #eef4f8;
  border: 2px solid #457b9d;
  border-radius: 8px;
}

.confirmation-speed strong {
  color: #2a9d8f;
  letter-spacing: 0.01em;
}

.confirmation-cost {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 0.35rem 0;
  color: #264653;
}

.confirmation-cost strong {
  color: #e76f51;
}

.confirmation-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  padding: 0.12rem 0;
  color: #555;
}

.confirmation-forecast {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid #e9ecef;
}

.confirmation-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.pass-confirm-message {
  font-size: 0.9rem;
  font-weight: 700;
  color: #264653;
  margin: 0;
  text-align: center;
}

.btn-small {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.machine-ineligible-reason {
  font-size: 0.55rem;
  font-weight: 700;
  color: #c1121f;
  text-align: center;
  max-width: 118px;
  line-height: 1.2;
  margin-top: 2px;
}

.machine-select-prompt {
  font-size: 0.82rem;
  font-weight: 700;
  color: #457b9d;
  text-align: center;
  margin: 0;
  padding: 0.35rem 0.5rem;
  background: #eef4f8;
  border: 2px solid #457b9d;
  border-radius: 8px;
}

.van-cash-burst {
  position: absolute;
  top: 10%;
  right: 18%;
  width: 28px;
  height: 28px;
  pointer-events: none;
  opacity: 0;
}

.van-cash-burst.visible {
  opacity: 1;
}

.customer-truck .van-cash-burst.visible::after {
  content: '+€';
  font-size: 0.65rem;
  font-weight: 800;
  color: #2a9d8f;
  animation: cashPop 0.45s ease;
}

.btn-upgrade.action-pending,
.btn-buy.action-pending {
  box-shadow: 0 0 0 3px rgba(247, 127, 0, 0.45);
}

.btn-upgrade {
  background: #2a9d8f;
  color: #fff;
  border: 3px solid #1d3557;
  font-size: 0.9rem;
  padding: 0.65rem;
  box-shadow: 0 3px 0 #1d3557;
}

.btn-buy {
  background: #457b9d;
  color: #fff;
  border: 3px solid #1d3557;
  font-size: 0.9rem;
  padding: 0.65rem;
  box-shadow: 0 3px 0 #1d3557;
}

.btn-buy:disabled,
.btn-upgrade:disabled,
.btn-move:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-move {
  background: #6d597a;
  color: #fff;
  border: 3px solid #1d3557;
  font-size: 0.9rem;
  padding: 0.65rem;
  box-shadow: 0 3px 0 #1d3557;
}

.grid-cell.move-destination-selectable {
  background: rgba(109, 89, 122, 0.18);
  border-color: #6d597a;
  box-shadow: inset 0 0 0 2px rgba(109, 89, 122, 0.35);
  cursor: pointer;
}

.grid-cell.move-current-location {
  box-shadow: inset 0 0 0 3px rgba(247, 127, 0, 0.75);
}

.grid-cell.move-selected-destination {
  background: rgba(42, 157, 143, 0.22);
  box-shadow: inset 0 0 0 3px rgba(42, 157, 143, 0.85);
}

.move-location-preview {
  margin: 0.45rem 0 0.65rem;
}

.move-preview-grid {
  display: grid;
  gap: 3px;
  max-width: 160px;
  margin: 0 auto 0.35rem;
}

.move-preview-cell {
  aspect-ratio: 1;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
}

.move-preview-cell.move-preview-current {
  background: rgba(247, 127, 0, 0.35);
  border-color: #f77f00;
}

.move-preview-cell.move-preview-proposed {
  background: rgba(42, 157, 143, 0.35);
  border-color: #2a9d8f;
}

.move-preview-legend {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: #555;
}

.move-preview-key::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.move-preview-key.move-preview-current::before {
  background: rgba(247, 127, 0, 0.75);
}

.move-preview-key.move-preview-proposed::before {
  background: rgba(42, 157, 143, 0.75);
}

.cash-chart-section {
  margin: 0.85rem 0 1rem;
  padding: 0.65rem 0.5rem 0.35rem;
  background: #fff;
  border: 2px solid #dee2e6;
  border-radius: 10px;
}

.cash-chart-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #264653;
  text-transform: uppercase;
  margin: 0 0 0.45rem;
  text-align: center;
}

.cash-chart-wrap {
  position: relative;
}

.cash-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.cash-chart-zero-line {
  stroke: #c1121f;
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.cash-chart-zero-label {
  fill: #c1121f;
  font-size: 10px;
  font-weight: 700;
}

.cash-chart-axis-label {
  fill: #6c757d;
  font-size: 10px;
}

.cash-chart-actual-line {
  fill: none;
  stroke: #264653;
  stroke-width: 2.5;
}

.cash-chart-projected-line {
  fill: none;
  stroke: #868e96;
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.cash-chart-point {
  fill: #264653;
  stroke: #fff;
  stroke-width: 1;
}

.cash-chart-projected-point {
  fill: #868e96;
}

.cash-chart-point-negative {
  fill: #c1121f;
}

.cash-chart-legend {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: #555;
}

.cash-chart-key::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 2px solid #264653;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.cash-chart-key-projected::before {
  border-top-style: dashed;
  border-top-color: #868e96;
}

.cash-chart-tooltip {
  position: absolute;
  background: #264653;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.destination-selection-active .factory-grid {
  cursor: crosshair;
}

.btn-pass {
  background: #e9ecef;
  color: #264653;
  border: 3px solid #adb5bd;
  font-size: 0.9rem;
  padding: 0.65rem;
}

.machine-speed {
  font-size: 0.58rem;
  font-weight: 700;
  color: #dee2e6;
  margin-top: 1px;
}

.machine-upgraded-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffd166;
  color: #1d3557;
  font-size: 0.52rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  border: 2px solid #1d3557;
  white-space: nowrap;
  z-index: 2;
}

.machine-upgraded .machine-body {
  border-color: #2a9d8f;
  box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.35);
}

.machine-upgraded .machine-mask {
  background-color: #6faaa1;
}

.intermission-active .unit-machine.selectable-machine {
  pointer-events: auto;
  cursor: pointer;
}

.intermission-active .unit-machine.machine-ineligible {
  opacity: 0.72;
  pointer-events: none;
}

.intermission-active .unit-machine.selectable-machine .machine-body {
  outline: 2px dashed rgba(69, 123, 157, 0.55);
}

.intermission-active .unit-machine.machine-selected .machine-body {
  outline: 3px solid #f77f00;
  box-shadow: 0 0 0 3px rgba(247, 127, 0, 0.35);
}

.intermission-active .unit-machine.machine-not-affordable .machine-body {
  opacity: 0.72;
}

.results-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.results-modal-actions .btn {
  font-size: 0.85rem;
  padding: 0.55rem 0.85rem;
}

.campaign-final-title {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  margin: 0 0 0.65rem;
}

.campaign-final-message {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #444;
  text-align: center;
  margin: 0 0 1rem;
}

.campaign-final .results-campaign-final {
  margin-bottom: 0;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .campaign-final .results-campaign-final {
    grid-template-columns: repeat(4, 1fr);
  }
}

.machine-purchased-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  background: #457b9d;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.machine-upgrade-flash .machine-body {
  animation: machineUpgradeFlash 0.8s ease;
}

.results-campaign-final {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.results-divider {
  border: none;
  border-top: 2px solid #dee2e6;
  margin: 0.75rem 0;
}

.campaign-outcome {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.machine-upgrade-flash .machine-body {
  animation: machineUpgradeFlash 0.8s ease;
}

@keyframes machineUpgradeFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42, 157, 143, 0); }
  50% { box-shadow: 0 0 18px 6px rgba(42, 157, 143, 0.85); }
}

.btn {
  font-size: 1.15rem;
  font-weight: 800;
  padding: 1rem 1.25rem;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #06d6a0;
  color: #1d3557;
  border: 4px solid #1d3557;
  box-shadow: 0 4px 0 #1d3557;
}

.btn-primary:not(:disabled):hover {
  background: #05c090;
}

.btn-secondary {
  background: #ffd166;
  color: #1d3557;
  border: 4px solid #e76f51;
  box-shadow: 0 4px 0 #e76f51;
}

.btn-secondary:not(:disabled):hover {
  background: #ffc145;
}

.btn-close {
  background: #457b9d;
  color: #fff;
  border: 3px solid #1d3557;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  text-transform: none;
  box-shadow: none;
}

.results-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.results-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.results-modal-panel {
  position: relative;
  background: #fff;
  border: 4px solid #264653;
  border-radius: 16px;
  width: min(920px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

.results-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 3px solid #eee;
  background: #ffd93d;
  flex-shrink: 0;
}

.results-modal-header h2 {
  color: #e76f51;
  font-size: 1.35rem;
}

.results-modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.results-primary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.results-metric-card {
  background: #f8f9fa;
  border: 3px solid #264653;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #666;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 900;
  color: #264653;
  line-height: 1.1;
}

.results-outcome {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
}

.results-outcome.positive {
  color: #2a9d8f;
}

.results-outcome.negative {
  color: #e63946;
}

.results-details-wrap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.results-details {
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 0;
  background: #fff;
  overflow: visible;
}

.results-details summary {
  font-size: 0.85rem;
  font-weight: 800;
  color: #457b9d;
  cursor: pointer;
  padding: 0.6rem 0.75rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  user-select: none;
}

.results-details summary::-webkit-details-marker {
  display: none;
}

.results-details summary::after {
  content: '▸';
  font-size: 0.9rem;
  color: #457b9d;
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.results-details[open] summary::after {
  transform: rotate(90deg);
}

.results-details .details-content {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid #eee;
}

.results-details ul {
  list-style: none;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.results-details li {
  padding: 0.25rem 0;
  color: #2c3e50;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.results-section h3 {
  font-size: 1rem;
  color: #457b9d;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid #eee;
  padding-bottom: 0.25rem;
}

.results-section ul {
  list-style: none;
  font-size: 0.95rem;
}

.results-section li {
  padding: 0.35rem 0;
}

.positive {
  color: #2a9d8f;
}

.negative {
  color: #e63946;
}

@media (max-width: 900px) {
  .game-shell,
  .game-header,
  .game-main,
  .control-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .game-main {
    flex-direction: column;
    align-items: stretch;
  }

  .factory-area {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .factory-floor {
    min-width: var(--factory-stage-min-width, 676px);
  }

  .factory-stage {
    min-width: var(--factory-stage-min-width, 676px);
  }

  .control-panel {
    flex: 1 1 auto;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .control-panel .btn {
    flex: 1;
  }
}

@media (max-width: 700px) {
  .results-primary {
    grid-template-columns: 1fr;
  }

  .results-details-wrap {
    grid-template-columns: 1fr;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }
}

/*
 * Header wrappers dissolve on desktop so title, actions and HUD keep the
 * existing single flex row. Mobile overrides below must come after these.
 */
.header-primary,
.header-actions {
  display: contents;
}

.header-btn-icon {
  display: none;
}

.header-icon-btn:focus-visible {
  outline: 3px solid #e76f51;
  outline-offset: 2px;
}

.level-select-open {
  margin-left: auto;
}

/* Compact Header/HUD — presentation only; activates through tablet widths.
 * Chosen at max-width: 900px because measured desktop wrapping still produces
 * ~257–302px headers from 601–768px, while 1024/1440 stay on the desktop path. */
@media (max-width: 900px) {
  .game-header {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.25rem;
    padding: 0.3rem 0.5rem;
  }

  .header-primary {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    width: 100%;
  }

  .header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
    flex: 0 0 auto;
  }

  .game-header h1 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.15;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .header-icon-btn {
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    font-size: 0;
    letter-spacing: 0;
    line-height: 0;
    border-width: 3px;
    border-radius: 10px;
    box-shadow: 0 2px 0 #e76f51;
  }

  .header-icon-btn.level-select-open {
    margin-left: 0;
  }

  .header-btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .header-btn-icon {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .hud {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    gap: 0;
    padding: 0;
    background: rgba(255, 255, 255, 0.72);
    border: 2px solid #264653;
    border-radius: 8px;
  }

  .hud-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.05rem;
    background: transparent;
    border: none;
    border-radius: 0;
    border-right: 1px solid rgba(38, 70, 83, 0.28);
    padding: 0.2rem 0.3rem;
    text-align: left;
  }

  .hud-item:last-child {
    border-right: none;
  }

  .hud-label {
    display: block;
    font-size: 0.55rem;
    letter-spacing: 0.02em;
    line-height: 1.05;
    margin-bottom: 0;
  }

  .hud-value {
    display: block;
    font-size: 0.72rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .bank-display .hud-value {
    font-size: 0.82rem;
  }

  /* Customer strings are longest; denser type keeps the strip to one compact row. */
  .hud-item:last-child {
    flex: 1.35 1 0;
  }

  .hud-item:last-child .hud-value {
    font-size: 0.64rem;
    line-height: 1.12;
  }
}

.settings-modal-panel {
  max-width: min(420px, calc(100vw - 24px));
  width: 100%;
}

.playback-speed-fieldset {
  border: 2px solid #264653;
  border-radius: 8px;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 1rem;
  text-align: left;
}

.playback-speed-fieldset legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

.settings-help {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  line-height: 1.35;
}

.playback-speed-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.playback-speed-btn.is-selected,
.playback-speed-btn[aria-checked="true"] {
  background: #264653;
  color: #fff;
}

.playback-speed-btn:focus-visible {
  outline: 3px solid #e76f51;
  outline-offset: 2px;
}

.level-select-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-select-modal.hidden {
  display: none;
}

.level-select-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.level-select-panel {
  position: relative;
  z-index: 1;
  background: #fff;
  border: 3px solid #264653;
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 280px;
  max-width: min(420px, calc(100vw - 24px));
  width: 100%;
}

.level-select-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.level-select-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.level-select-group-title {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  text-align: left;
}

.level-select-btn {
  width: 100%;
  text-align: left;
}

.level-select-meta {
  display: block;
  font-size: 0.85em;
  opacity: 0.8;
}

.strategic-targets-panel {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 2px solid #264653;
  border-radius: 8px;
  background: #fff;
}

.strategic-targets-heading {
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.target-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.6rem;
}

.target-stars,
.target-line {
  letter-spacing: 0.04em;
}

.customer-reaction {
  margin: 0.45rem 0 0;
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: left;
}

.customer-reaction-text {
  font-weight: 600;
}

.targets-modal-content {
  margin: 1rem 0;
}

.results-stars {
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
}

.decision-audit {
  text-align: left;
  margin: 1rem 0;
}

.decision-audit ol {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* Welcome and tutorial presentation layer */
body:not([data-app-view="game"]) {
  background: #f7f4ec;
  color: #292823;
  overflow-x: hidden;
}

.game-shell {
  min-height: 100vh;
}

.app-screen {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding: clamp(0px, 3vw, 32px);
  display: grid;
  place-items: center;
  background: #f7f4ec;
}

.experience-card {
  --experience-charcoal: #292823;
  --experience-amber: #df9d22;
  --experience-muted: #8f8c84;
  --experience-line: #c9c4b8;
  width: min(100%, 492px);
  min-height: min(100dvh, 920px);
  border: 1px solid #d9d5cc;
  border-radius: 36px;
  background: #faf8f2;
  color: var(--experience-charcoal);
  box-shadow: 0 16px 48px rgba(41, 40, 35, 0.07);
  padding: clamp(28px, 7vw, 40px) clamp(28px, 7vw, 40px);
}

.welcome-card {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.welcome-wordmark {
  border: 3px dashed var(--experience-line);
  border-radius: 28px;
  padding: 24px 18px 18px;
}

.welcome-wordmark h1 {
  font-size: clamp(2.25rem, 9vw, 3rem);
  line-height: 1;
  letter-spacing: 0.01em;
  font-weight: 850;
}

.welcome-wordmark p {
  margin-top: 8px;
  color: #6f6b63;
  font-size: 0.94rem;
  letter-spacing: 0.02em;
}

.welcome-tagline {
  max-width: 350px;
  margin: 20px auto 0;
  color: #69655e;
  font-size: clamp(1.05rem, 4.2vw, 1.26rem);
  line-height: 1.35;
}

.welcome-illustration {
  width: min(70%, 270px);
  aspect-ratio: 1.3;
  margin: 36px auto 24px;
  border: 3px dashed var(--experience-line);
  border-radius: 26px;
  display: grid;
  place-items: center;
}

.welcome-illustration svg {
  width: 82%;
  height: 82%;
}

.welcome-actions {
  display: grid;
  gap: 14px;
  margin-top: auto;
}

.experience-btn {
  width: 100%;
  min-height: 64px;
  border: 3px solid var(--experience-charcoal);
  border-radius: 21px;
  padding: 12px 20px;
  font: inherit;
  font-size: clamp(1.06rem, 4.4vw, 1.28rem);
  line-height: 1.15;
  font-weight: 800;
  color: var(--experience-charcoal);
  background: transparent;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.experience-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(41, 40, 35, 0.12);
}

.experience-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.experience-btn:focus-visible,
.text-back-btn:focus-visible,
.tutorial-library-item:focus-visible {
  outline: 4px solid #2d6fb4;
  outline-offset: 4px;
}

.experience-btn-primary {
  border-color: var(--experience-amber);
  background: var(--experience-amber);
}

.experience-btn-secondary {
  background: #faf8f2;
}

.experience-btn-disabled {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  color: #949087;
  background: #ebe7dc;
  border-color: #d4cfc1;
  cursor: not-allowed;
}

.coming-soon {
  min-width: 126px;
  padding: 8px 12px;
  border: 1px solid #d4cfc1;
  border-radius: 999px;
  background: #faf8f2;
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: 0.08em;
}

.prototype-label {
  margin-top: 20px;
  color: #c5c0b5;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.tutorial-card {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.tutorial-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tutorial-piece-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 16px;
  border: 1px solid #c8c3b6;
  border-radius: 999px;
  background: #e9e5da;
  font-weight: 850;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tutorial-progress {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.tutorial-progress-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.tutorial-progress-dot.is-complete {
  background: #c7c1b4;
}

.tutorial-progress-dot.is-current {
  width: 29px;
  background: var(--experience-amber);
}

.tutorial-progress-dot.is-upcoming {
  border: 3px solid #c7c1b4;
  background: transparent;
}

.tutorial-kicker,
.eyebrow {
  margin-top: 38px;
  color: var(--experience-amber);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: 0.24em;
}

.tutorial-illustration {
  width: min(74vw, 288px);
  aspect-ratio: 1;
  margin: 22px auto 24px;
  border: 3px dashed var(--experience-line);
  border-radius: 28px;
  display: grid;
  place-items: center;
}

.tutorial-illustration svg {
  width: 86%;
  height: 86%;
}

.tutorial-copy h1 {
  font-size: clamp(2.35rem, 10vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0.01em;
  font-weight: 850;
}

.tutorial-copy p {
  max-width: 370px;
  margin: 18px auto 0;
  color: #6d6961;
  font-size: clamp(1.04rem, 4.3vw, 1.22rem);
  line-height: 1.45;
}

.tutorial-card-cta {
  margin-top: auto;
  color: #faf8f2;
  background: var(--experience-charcoal);
}

.tutorial-card-screen[data-piece="5"] .tutorial-card-cta {
  color: var(--experience-charcoal);
  border-color: var(--experience-amber);
  background: var(--experience-amber);
}

.tutorial-library-card {
  min-height: min(100dvh, 820px);
}

.tutorial-library-header {
  text-align: center;
}

.tutorial-library-header .eyebrow {
  margin-top: 28px;
}

.tutorial-library-header h1 {
  margin-top: 8px;
  font-size: clamp(2.2rem, 9vw, 3rem);
}

.tutorial-library-header > p:last-child {
  margin-top: 8px;
  color: #6d6961;
  font-size: 1.08rem;
}

.text-back-btn {
  display: block;
  border: 0;
  padding: 8px 0;
  color: var(--experience-charcoal);
  background: transparent;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.tutorial-library-list {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

.tutorial-library-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 12px;
  width: 100%;
  min-height: 84px;
  border: 2px solid #c8c3b6;
  border-radius: 20px;
  padding: 14px 18px;
  text-align: left;
  color: var(--experience-charcoal);
  background: #f5f1e8;
  font: inherit;
  cursor: pointer;
}

.tutorial-library-item:hover {
  border-color: var(--experience-amber);
}

.tutorial-library-piece {
  grid-column: 1;
  color: var(--experience-amber);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.tutorial-library-item strong {
  grid-column: 1;
  font-size: 1.24rem;
}

.tutorial-library-arrow {
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 1.5rem;
}

.icon-charcoal,
.icon-amber,
.icon-muted,
.icon-amber-dash,
.icon-muted-dash {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.icon-charcoal {
  stroke: #292823;
}

.icon-amber {
  stroke: #df9d22;
}

.icon-muted {
  stroke: #97958f;
}

.icon-amber-dash {
  stroke: #df9d22;
  stroke-dasharray: 9 9;
}

.icon-muted-dash {
  stroke: #97958f;
  stroke-dasharray: 8 8;
}

.icon-arrow {
  stroke-width: 4;
}

.icon-charcoal-fill {
  fill: #292823;
}

.icon-amber-fill {
  fill: #df9d22;
}

.icon-muted-fill {
  fill: #97958f;
}

.icon-soft-fill {
  fill: #e3ded2;
  stroke: #292823;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

@media (max-width: 520px) {
  .app-screen {
    padding: 0;
  }

  .experience-card {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 32px;
    box-shadow: none;
  }

  .tutorial-illustration {
    width: min(72vw, 288px);
  }
}

@media (max-width: 400px) {
  .experience-card {
    padding: 28px;
  }

  .tutorial-piece-badge {
    padding-inline: 13px;
    font-size: 0.9rem;
  }

  .tutorial-progress {
    gap: 7px;
  }

  .tutorial-progress-dot {
    width: 10px;
    height: 10px;
  }

  .tutorial-progress-dot.is-current {
    width: 25px;
  }

  .tutorial-kicker {
    margin-top: 32px;
    font-size: 0.88rem;
  }

  .tutorial-illustration {
    margin-top: 18px;
  }

  .experience-btn-disabled {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .coming-soon {
    min-width: 108px;
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .experience-btn {
    transition: none;
  }

  .unit-machine.machine-state-working .machine-artwork-layer svg,
  .unit-machine.machine-state-working .machine-artwork-layer svg * {
    animation: none !important;
  }

  .delivery-truck .loader-emerging-product {
    animation: none;
  }
}


.test-level-import {
  border-top: 2px solid #d8d4c8;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.test-level-import-heading {
  color: #264653;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.test-level-import-note {
  color: #66635c;
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 0 0 0.8rem;
  max-width: 34rem;
}

.test-level-import-status {
  color: #287f70;
  font-size: 0.85rem;
  margin: 0.65rem 0 0;
  min-height: 1.2em;
}

.test-level-import-status.import-status-error {
  color: #b42318;
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

