:root {
  --ink: #2b2140;
  --paper: #f7efe0;
  --paper-2: #efe2c9;
  --asphalt: #4b4a68;
  --asphalt-2: #57567a;
  --line: #f7efe0;
  --c0: #ff6b5a;
  --c1: #1fb5a8;
  --c2: #f4b63c;
  --c3: #8e5bd6;
  --c4: #4aa3f0;
  --c5: #6cc24a;
  --c6: #f27bb7;
  --pax: 30px;
  --shadow: 3px 3px 0 var(--ink);
  color-scheme: light;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, "PingFang HK", "Noto Sans TC", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 14px calc(env(safe-area-inset-bottom) + 12px);
  background:
    radial-gradient(circle at 20% 0%, #fff8ea 0, transparent 45%),
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(43, 33, 64, 0.025) 14px 15px),
    var(--paper);
  overflow: hidden;
}

.c0 { --c: var(--c0); }
.c1 { --c: var(--c1); }
.c2 { --c: var(--c2); }
.c3 { --c: var(--c3); }
.c4 { --c: var(--c4); }
.c5 { --c: var(--c5); }
.c6 { --c: var(--c6); }

.top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.badge b {
  font-size: 20px;
  line-height: 1;
}

.meter {
  flex: 1;
  height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 99px;
  background: #fff;
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--c5) 0 8px, #82d363 8px 16px);
  border-right: 2.5px solid var(--ink);
  transition: width 0.3s ease;
}

.round {
  width: 44px;
  height: 44px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--c2);
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
}

.queue-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--paper-2);
  box-shadow: var(--shadow);
}

.stop svg {
  display: block;
  width: 30px;
  height: 30px;
}

.queue {
  position: relative;
  flex: 1;
  height: calc(var(--pax) + 14px);
  overflow: hidden;
}

.pax {
  position: absolute;
  top: 7px;
  left: 7px;
  display: grid;
  place-items: center;
  width: var(--pax);
  height: var(--pax);
  border: 2.5px solid var(--ink);
  border-radius: 50% 50% 46% 46%;
  background: var(--c);
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.pax .sym {
  width: 58%;
  height: 58%;
  fill: #fff;
  stroke: var(--ink);
  stroke-width: 1.4;
}

.pax.front {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--ink);
}

.queue-count {
  min-width: 56px;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  opacity: 0.75;
}

.bays {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  height: clamp(92px, 16vh, 128px);
}

.bays.warn .bay {
  animation: warn 0.5s ease;
}

@keyframes warn {
  30% { background: #ffd2c8; }
}

.bay {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 6px;
  border: 2.5px dashed rgba(43, 33, 64, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.35);
}

.bay-no {
  position: absolute;
  inset: auto 0 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.35;
}

.bay-car {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 64px;
  padding: 5px 5px 6px;
  border: 2.5px solid var(--ink);
  border-radius: 14px 14px 9px 9px;
  background: var(--c);
  box-shadow: var(--shadow);
}

.bay-car .glass {
  width: 78%;
  height: 9px;
  border: 2px solid var(--ink);
  border-radius: 6px 6px 3px 3px;
  background: #cfeefa;
}

.bay-car .seats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  flex: 1;
  width: 74%;
  align-content: center;
}

.bay-car .seats i {
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.65);
}

.bay-car .seats i.on {
  background: var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.25);
}

.bay-car .badge-sym {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
}

.badge-sym .sym {
  width: 13px;
  height: 13px;
  fill: var(--c);
  stroke: var(--ink);
  stroke-width: 1.6;
}

.lot-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.07) 1px, transparent 1.5px) 0 0 / 9px 9px,
    var(--asphalt);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lot {
  --cell: 40px;
  position: relative;
  background-image:
    linear-gradient(to right, rgba(247, 239, 224, 0.18) 1.5px, transparent 1.5px),
    linear-gradient(to bottom, rgba(247, 239, 224, 0.18) 1.5px, transparent 1.5px);
  background-size: var(--cell) var(--cell);
  border: 2px dashed rgba(247, 239, 224, 0.5);
  border-radius: 6px;
  box-sizing: content-box;
  overflow: visible;
}

.car {
  position: absolute;
  left: calc(var(--x) * var(--cell));
  top: calc(var(--y) * var(--cell));
  width: calc(var(--w) * var(--cell));
  height: calc(var(--h) * var(--cell));
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
}

.car .body {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: calc(var(--cell) * 0.08);
  width: calc(var(--len) * var(--cell) - 7px);
  height: calc(var(--cell) - 9px);
  padding: 0 calc(var(--cell) * 0.08);
  border: 2.5px solid var(--ink);
  border-radius: calc(var(--cell) * 0.2) calc(var(--cell) * 0.32) calc(var(--cell) * 0.32) calc(var(--cell) * 0.2);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.28), transparent 45%),
    var(--c);
  box-shadow: 2px 3px 0 rgba(20, 14, 34, 0.55);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}

.d-right { --rot: 0deg; }
.d-down { --rot: 90deg; }
.d-left { --rot: 180deg; }
.d-up { --rot: -90deg; }

.car .glass {
  flex: none;
  width: calc(var(--cell) * 0.18);
  height: 74%;
  margin-left: auto;
  border: 2px solid var(--ink);
  border-radius: 3px calc(var(--cell) * 0.16) calc(var(--cell) * 0.16) 3px;
  background: #cfeefa;
}

.car .body::before,
.car .body::after {
  content: "";
  position: absolute;
  right: -4px;
  width: calc(var(--cell) * 0.14);
  height: calc(var(--cell) * 0.14);
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: #ffe58a;
}

.car .body::before {
  top: 10%;
}

.car .body::after {
  bottom: 10%;
}

.car .badge-sym {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--cell) * 0.42);
  height: calc(var(--cell) * 0.42);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
}

.car .badge-sym .sym {
  width: 70%;
  height: 70%;
  transform: rotate(calc(var(--rot, 0deg) * -1));
}

.car .seats {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  height: 62%;
  flex: 1;
  align-content: center;
  justify-content: center;
}

.car .seats i {
  width: calc(var(--cell) * 0.17);
  height: calc(var(--cell) * 0.17);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.55);
}

.car:active .body {
  filter: brightness(1.08);
}

.car.leaving {
  pointer-events: none;
  z-index: 3;
}

.controls {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.pill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.pill:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.pill:focus-visible,
.round:focus-visible,
.car:focus-visible {
  outline: 3px solid var(--c4);
  outline-offset: 2px;
}

.pill:focus:not(:focus-visible) {
  outline: none;
}

.pill:disabled {
  opacity: 0.45;
  cursor: default;
}

.pill svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.pill b {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
}

.pill.primary {
  background: var(--c0);
  color: var(--ink);
}

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

.flyer {
  transition: none;
  z-index: 6;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--c);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  z-index: 7;
  padding: 8px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(43, 33, 64, 0.55);
}

.sheet[hidden] {
  display: none;
}

.card {
  width: min(100%, 380px);
  padding: 22px 20px 18px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
  animation: pop 0.28s cubic-bezier(.3, 1.4, .6, 1);
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
}

.card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.card p,
.card li {
  font-size: 15px;
  line-height: 1.45;
}

.steps {
  margin: 0 0 6px;
  padding-left: 22px;
}

.steps li + li {
  margin-top: 8px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

@media (max-height: 640px) {
  :root { --pax: 26px; }
  .app { gap: 8px; }
  .pill { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .pax, .meter i, .toast { transition-duration: 0.01s; }
}
