:root {
  color-scheme: light;
  --paper: #f4f2e9;
  --ink: #182b2c;
  --muted: #566968;
  --line: #c9cfc1;
  --petrol: #175b60;
  --amber: #efc94c;
  --orange: #d8472b;
  --sans: "Barlow", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --head: "Barlow Condensed", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid #bb490c; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner, main { width: min(1160px, calc(100% - 80px)); margin-inline: auto; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 62px; }
.home-link { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font-size: 13px; font-weight: 700; }
.home-link:hover { color: var(--petrol); }
.road-mark { display: block; width: 24px; height: 19px; transform: skew(-13deg); border-left: 6px solid var(--petrol); border-right: 6px solid var(--petrol); position: relative; }
.road-mark::after { content: ""; position: absolute; height: 100%; left: 5px; width: 2px; background: repeating-linear-gradient(0deg, var(--petrol) 0 5px, transparent 5px 8px); }
#lang, .tool-buttons button { background: transparent; border: 1px solid #aab7ac; border-radius: 4px; min-height: 34px; padding: 4px 12px; font: 600 13px/1.25 var(--sans); }
#lang:hover, .tool-buttons button:not(:disabled):hover { border-color: var(--petrol); color: var(--petrol); background: #e8ede2; }
main { padding-top: clamp(23px, 3vw, 41px); padding-bottom: 42px; }
.title-line { display: flex; gap: 20px; align-items: center; justify-content: space-between; }
h1 { font: 850 clamp(32px, 4.2vw, 62px)/1.12 var(--head); letter-spacing: -.06em; text-wrap: balance; }
.intro { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.road-icon { width: 95px; height: 30px; position: relative; flex: none; overflow: hidden; }
.road-icon i { position: absolute; left: 0; right: 0; bottom: 1px; border-bottom: 3px solid var(--ink); }
.road-icon b { position: absolute; bottom: 1px; left: 23px; width: 48px; height: 22px; border-radius: 50% 50% 0 0 / 90% 90% 0 0; border: 3px solid var(--ink); border-bottom: 0; background: repeating-linear-gradient(115deg, var(--amber) 0 7px, #273e3d 7px 13px); }
#workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(298px, 1fr); gap: clamp(24px, 4vw, 53px); align-items: start; margin-top: 26px; }
.loading-bay, .packing-side { min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; min-height: 28px; }
h2 { font: 780 23px/1.15 var(--head); letter-spacing: -.04em; }
.orientation, #count { font-size: 12px; font-weight: 650; color: var(--muted); }
.vehicle-stage {
  isolation: isolate; position: relative; padding: 6px 0 0;
}
#frame {
  position: relative; width: 100%; padding: 7.5% 6.6% 8%;
  border-radius: 16% 16% 10% 10% / 13% 13% 10% 10%;
  border: 2px solid #183d42;
  background: linear-gradient(104deg,#3a8385 0%,#236b70 16%,#13575d 47%,#155259 79%,#307278 100%);
  box-shadow: inset 0 3px 0 #86a9a3, inset 0 -6px 0 #204449, 0 8px 0 -3px #cbd1c5;
}
#frame::before { content: ""; position: absolute; inset: 4% 3% 5%; pointer-events: none; border: 1px solid rgb(184 210 197 / 47%); border-radius: 13% 13% 10% 10% / 12% 12% 10% 10%; }
.rear-seat { position: absolute; top: 3%; left: 12%; right: 12%; display: flex; align-items: flex-end; justify-content: space-around; height: 6%; border-bottom: 3px solid #172a2c; }
.rear-seat i { width: 21%; height: 100%; border-radius: 7px 7px 2px 2px; background: linear-gradient(#546764,#374848); box-shadow: inset 0 2px 0 #80948b, 0 0 0 2px #223333; }
.rear-seat i:nth-child(2) { width: 15%; height: 71%; }
#board {
  position: relative; width: 100%; aspect-ratio: 6 / 4; border: 0; padding: 0; box-sizing: content-box; isolation: isolate;
  background-color: #2c4141;
  background-image: linear-gradient(to right, rgb(170 191 168 / 26%) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(170 191 168 / 26%) 1px, transparent 1px),
    repeating-linear-gradient(125deg, rgb(211 220 190 / 3%) 0 1px, transparent 1px 5px);
  background-size: calc(100% / 6) 100%, 100% 25%, auto;
  outline: 5px solid #182d2e;
  box-shadow: 0 0 0 7px #54726c, inset 0 0 15px #1e3234;
}
.tail-lamp { position: absolute; bottom: 3.8%; height: 3.3%; width: 16%; border: 2px solid #402b28; border-radius: 4px; background: repeating-linear-gradient(90deg,#f58453 0 2px,#d34c35 2px 5px); box-shadow: inset 0 1px 0 #ffc7a3; }
.lamp-left { left: 3.7%; transform: rotate(2deg); }
.lamp-right { right: 3.7%; transform: rotate(-2deg); }
.trunk-latch { position: absolute; width: 15%; height: 2.5%; bottom: 3.1%; left: 42.5%; background: #183b3d; border-radius: 6px; box-shadow: inset 0 1px 0 #092c30, 0 1px 0 #6b9997; }
.cell, .piece { position: absolute; margin: 0; border: 0; padding: 0; border-radius: 0; }
.cell { width: calc(100% / 6); height: 25%; background: transparent; }
.cell:hover { background: rgb(240 237 182 / 11%); }
.cell:focus-visible, .piece:focus-visible { outline: 3px solid var(--amber); outline-offset: -3px; }
.cell.target-ok, .cell.preview, .cell.valid, .cell.drop-target { background: rgb(156 222 171 / 28%); }
.cell.target-bad, .cell.invalid { background: rgb(224 83 54 / 30%); }
.piece { z-index: 2; display: grid; place-items: center; background: transparent; cursor: grab; touch-action: none; user-select: none; }
.piece img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 2px rgb(7 20 17 / 42%)); pointer-events: none; }
.piece.quilt, .piece[data-id="quilt"] { z-index: 1; }
.piece.eggs, .piece[data-id="eggs"] { z-index: 3; }
.piece[aria-pressed="true"] { outline: 2px dashed var(--amber); outline-offset: -2px; }
.piece span { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); padding: 1px 4px; font-size: 10px; color: white; background: #203e39e6; border-radius: 2px; white-space: nowrap; }
#bump-live, #message { margin-top: 14px; font-size: 14px; line-height: 1.5; }
#bump-live:empty, #message:empty { display: none; }
#message { padding: 10px 13px; background: #f9e8b7; color: #554015; border-left: 4px solid #d7a82b; border-radius: 2px; }
#bump-live { color: var(--petrol); font-weight: 700; }
.packing-panel { border-block: 2px solid var(--ink); padding: 12px 0 14px; }
.packing-panel .section-head { margin-bottom: 10px; }
#cargo { display: grid; grid-template-columns: repeat(3,minmax(0, 1fr)); gap: 7px; }
.cargo-item { position: relative; min-width: 0; min-height: 80px; display: grid; justify-items: center; align-content: center; gap: 4px; padding: 6px 3px; border: 1px solid #cbd0c2; border-radius: 7px; background: #fbfaf2; font-size: 13px; font-weight: 650; }
.cargo-item img { width: 100%; height: 48px; display: block; object-fit: contain; pointer-events: none; }
.cargo-item[aria-pressed="true"] { outline: 2px solid var(--petrol); outline-offset: -2px; background: #dfece1; color: #134e4c; }
.cargo-item.packed::after { content: "✓"; position: absolute; top: 4px; right: 6px; color: var(--petrol); font: 800 12px/1 var(--sans); }
.cargo-item:hover { border-color: var(--petrol); }
.selection-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
#selection { font-size: 14px; }
.tool-buttons { display: flex; gap: 6px; }
.tool-buttons button { font-size: 12px; min-height: 33px; }
.tool-buttons button:disabled { color: #71807a; border-color: #d0d4c9; }
#hint { margin: 8px 0 11px; min-height: 2.8em; font-size: 13px; line-height: 1.4; color: var(--muted); }
#go, #repack { width: 100%; min-height: 44px; border: 1px solid #94311f; border-radius: 5px; background: var(--orange); color: white; font: 720 16px/1.2 var(--sans); padding: 9px 12px; }
#go:not(:disabled):hover, #repack:hover { background: #bd3821; }
#go:disabled { color: #625e51; background: #e2dfd2; border-color: #ccc9bc; }
#result { padding: 15px; margin-top: 12px; border: 2px solid var(--ink); background: #fffbed; border-radius: 5px; }
#result h2, #result h3 { margin: 0 0 8px; font-family: var(--head); }
.result-score { color: #174e4d; font-weight: 800; font-size: clamp(19px,2.4vw,28px); line-height: 1.2; }
.outcome-list { padding-inline-start: 18px; margin: 10px 0; font-size: 14px; line-height: 1.55; }
.comparison { border-top: 1px dashed var(--line); margin: 10px 0; padding-top: 8px; color: #584827; font-size: 13px; line-height: 1.5; }
#result #repack { margin-top: 7px; }
body.has-result .packing-panel { display: none; }
.is-riding .piece { cursor: default; }
#frame.jolt { animation: bump .6s ease-in-out both; }
.piece.impact { animation: clatter .5s ease-in-out 2; }
.piece.slide { animation: slide .55s ease-out both; }
@keyframes bump { 0%,100% { transform: translateY(0); } 25% { transform: translateY(-8px) rotate(-.7deg); } 44% { transform: translateY(5px) rotate(.5deg); } 72% { transform: translateY(-2px); } }
@keyframes clatter { 25% { filter: brightness(1.45); } 50% { translate: 3% -4%; } }
@keyframes slide { 50% { translate: var(--slide-x, 5%) var(--slide-y, 0%); } }
@media (max-width: 850px) {
  .topbar-inner, main { width: calc(100% - 42px); }
  #workspace { grid-template-columns: minmax(0, 1.35fr) minmax(250px, 1fr); gap: 20px; }
}
@media (max-width: 650px) {
  .topbar-inner, main { width: calc(100% - 30px); }
  .topbar-inner { min-height: 46px; }
  #lang { min-height: 30px; }
  main { padding-block: 18px 30px; }
  h1 { font-size: clamp(25px, 6.6vw, 38px); }
  .road-icon { display: none; }
  .intro { font-size: 13px; margin-top: 6px; }
  #workspace { display: block; margin-top: 16px; }
  .section-head { margin-bottom: 6px; min-height: 22px; }
  h2 { font-size: 19px; }
  .orientation, #count { font-size: 11px; }
  .vehicle-stage { width: min(100%,460px); margin-inline: auto; }
  .packing-side { margin-top: 16px; }
  .packing-panel { padding-top: 8px; }
  #cargo { grid-template-columns: repeat(6,minmax(0, 1fr)); gap: 4px; }
  .cargo-item { min-height: 58px; gap: 2px; padding: 4px 1px; font-size: 11px; line-height: 1.1; }
  .cargo-item img { height: 34px; }
  .cargo-item.packed::after { right: 2px; top: 2px; }
  .selection-bar { margin-top: 9px; padding-top: 8px; }
  #hint { min-height: 1.4em; margin: 6px 0 9px; }
  #bump-live, #message { margin-top: 9px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
.piece img { position: absolute; left: 50%; top: 50%; }
.cargo-item { touch-action: none; user-select: none; }
.dragging { opacity: .54; }
.drag-ghost { position: fixed; width: 64px; height: 64px; object-fit: contain; pointer-events: none; z-index: 10; filter: drop-shadow(0 3px 5px #20373188); }
#result:focus:not(:focus-visible) { outline: none; }
