:root {
  --plum: #2A1B3D;
  --yellow: #FFD23F;
  --pink: #FF5C8A;
  --cyan: #29C7E0;
  --green: #6BD05A;
  --orange: #FF7A3D;
  --cream: #F6F1E4;
  --ink-shadow: 5px 5px 0 var(--plum);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--plum);
  color: var(--plum);
  font-family: "Fredoka", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

body { cursor: default; }
button { font: inherit; color: inherit; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--cyan);
}

#stage, #stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 7px var(--plum);
  z-index: 2;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: var(--pink);
  opacity: 0;
}
.flash.go { animation: flashOut 0.45s ease-out; }
@keyframes flashOut {
  0% { opacity: 0.7; }
  100% { opacity: 0; }
}

.shake-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.burst {
  position: relative;
  width: 290px;
  height: 290px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.3) rotate(-12deg);
  pointer-events: none;
}
.burst::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--plum);
  clip-path: polygon(50% 0%, 59% 14%, 72% 7%, 76% 22%, 91% 20%, 89% 36%, 100% 45%, 92% 58%, 100% 72%, 84% 76%, 84% 92%, 68% 87%, 58% 100%, 47% 87%, 33% 96%, 24% 82%, 9% 86%, 11% 70%, 0% 60%, 9% 47%, 0% 34%, 14% 30%, 12% 14%, 28% 18%, 38% 3%);
  transform: scale(1.06);
}
.burst::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--pink);
  clip-path: polygon(50% 0%, 59% 14%, 72% 7%, 76% 22%, 91% 20%, 89% 36%, 100% 45%, 92% 58%, 100% 72%, 84% 76%, 84% 92%, 68% 87%, 58% 100%, 47% 87%, 33% 96%, 24% 82%, 9% 86%, 11% 70%, 0% 60%, 9% 47%, 0% 34%, 14% 30%, 12% 14%, 28% 18%, 38% 3%);
}
.burst span {
  position: relative;
  z-index: 2;
  font-family: "Lilita One", fantasy;
  font-size: 47px;
  line-height: 0.9;
  color: var(--cream);
  text-align: center;
  text-shadow: 4px 4px 0 var(--plum);
  transform: rotate(-6deg);
  padding: 0 10px;
}
.burst.show { animation: burstPop 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
@keyframes burstPop {
  0% { opacity: 0; transform: scale(0.3) rotate(-18deg); }
  18% { opacity: 1; transform: scale(1.08) rotate(3deg); }
  30% { transform: scale(0.96) rotate(-2deg); }
  72% { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.05) rotate(2deg); }
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.sticker {
  background: var(--cream);
  border: 4px solid var(--plum);
  border-radius: 16px;
  box-shadow: var(--ink-shadow);
}

img { -webkit-user-drag: none; }

/* mission card */
.mission-card {
  position: absolute;
  top: 1.8vh;
  left: 1.4vw;
  width: clamp(268px, 24vw, 356px);
  aspect-ratio: 1024 / 639;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: rotate(-1.6deg);
  filter: drop-shadow(5px 6px 0 rgba(42, 27, 61, 0.95));
}
.mission-card .panel-bg {
  position: absolute;
  inset: -7% -6% -8% -7%;
  width: 113%;
  height: 115%;
  object-fit: fill;
  pointer-events: none;
}
.mission-inner {
  position: absolute;
  inset: 10% 12% 12% 8%;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.package-portrait {
  position: relative;
  flex: 0 0 31%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.package-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(-3deg);
  filter: drop-shadow(2px 3px 0 rgba(42, 27, 61, 0.35));
}
.fragile-tape {
  position: absolute;
  top: 4%;
  left: -4%;
  font-family: "Fredoka", sans-serif;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 1px;
  background: var(--yellow);
  border: 2px solid var(--plum);
  padding: 1px 5px;
  transform: rotate(-7deg);
  border-radius: 3px;
}
.mission-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding-right: 2px;
}
.mission-kicker {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--plum);
  opacity: 0.72;
}
.mission-kicker b { font-weight: 600; }
.mission-name {
  font-family: "Lilita One", fantasy;
  font-size: clamp(17px, 1.6vw, 24px);
  line-height: 0.94;
  color: var(--plum);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.mission-dest {
  font-size: clamp(9px, 0.8vw, 12px);
  font-weight: 500;
  line-height: 1.05;
  color: var(--plum);
  opacity: 0.78;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}
.clock {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: var(--plum);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.timer {
  font-family: "Chakra Petch", monospace;
  font-weight: 700;
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1;
  letter-spacing: 0.5px;
  background: var(--plum);
  color: var(--cream);
  border: 2.5px solid var(--plum);
  border-radius: 8px;
  padding: 1px 8px 0;
  min-width: 108px;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}
.timer.warn {
  background: var(--orange);
  color: var(--cream);
}
.timer.danger {
  background: var(--pink);
  color: var(--cream);
  animation: timerShake 0.14s infinite linear;
}
@keyframes timerShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-1px, 1px) rotate(-1.4deg); }
  50% { transform: translate(1px, -1px) rotate(1deg); }
  75% { transform: translate(-1px, -1px) rotate(-0.6deg); }
  100% { transform: translate(1px, 1px) rotate(0.8deg); }
}
.mission-dist {
  position: absolute;
  right: -3%;
  bottom: 1%;
  font-family: "Chakra Petch", monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--plum);
  opacity: 0.8;
  transform: rotate(2deg);
}

/* chaos badge */
.chaos-badge {
  position: absolute;
  top: 1.2vh;
  right: 1.2vw;
  width: clamp(178px, 15vw, 236px);
  aspect-ratio: 983 / 899;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: rotate(2deg);
  filter: drop-shadow(5px 6px 0 rgba(42, 27, 61, 0.9));
}
.badge-bg {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  object-fit: contain;
}
.chaos-inner {
  position: absolute;
  inset: 24% 17% 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.chaos-kicker {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: clamp(8px, 0.72vw, 11px);
  letter-spacing: 1.4px;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--plum);
}
.chaos-value {
  font-family: "Lilita One", fantasy;
  font-size: clamp(36px, 4vw, 60px);
  line-height: 0.92;
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--plum), -1.5px -1.5px 0 var(--plum), 1.5px -1.5px 0 var(--plum), -1.5px 1.5px 0 var(--plum);
}
.chaos-words {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: clamp(8px, 0.78vw, 12px);
  line-height: 1;
  color: var(--cream);
  text-shadow: 1.5px 1.5px 0 var(--plum);
  min-height: 1.1em;
  max-width: 96%;
}
.chaos-badge.punch { animation: chaosPunch 0.42s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes chaosPunch {
  0% { transform: rotate(2deg) scale(1); }
  35% { transform: rotate(-2deg) scale(1.16); }
  65% { transform: rotate(3.4deg) scale(0.97); }
  100% { transform: rotate(2deg) scale(1); }
}

/* GPS */
.gps-panel {
  position: absolute;
  bottom: 2.2vh;
  left: 1.4vw;
  width: clamp(320px, 28vw, 440px);
  display: flex;
  align-items: flex-end;
  gap: 2%;
  filter: drop-shadow(4px 5px 0 rgba(42, 27, 61, 0.75));
}
.gps-device {
  flex: 0 0 25%;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: rotate(-3deg);
  display: flex;
  align-items: flex-end;
}
.gps-device img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(2px 3px 0 rgba(42, 27, 61, 0.35));
  transition: transform 0.18s;
}
.gps-device img.flip-face { animation: faceFlip 0.3s ease-out; }
@keyframes faceFlip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(0.12) rotate(3deg); }
  100% { transform: scaleX(1); }
}
.gps-bubble {
  position: relative;
  flex: 1;
  min-height: clamp(88px, 10.5vw, 128px);
  transform: rotate(-1.2deg);
}
.gps-bubble .panel-bg {
  position: absolute;
  inset: -16% -10% -18% -12%;
  width: 122%;
  height: 134%;
  object-fit: fill;
}
.gps-inner {
  position: relative;
  z-index: 2;
  padding: 8% 10% 8% 12%;
}
.gps-kicker {
  font-family: "Chakra Petch", monospace;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--plum);
  opacity: 0.65;
}
.gps-kicker span {
  color: var(--pink);
}
.gps-text {
  margin: 2px 0 0;
  font-family: "Chakra Petch", monospace;
  font-weight: 700;
  font-size: clamp(12px, 1.15vw, 18px);
  line-height: 1.1;
  color: var(--plum);
}
.gps-bubble.flip .gps-text { animation: paperFlip 0.36s ease-out; }
@keyframes paperFlip {
  0% { opacity: 0; transform: translateY(-7px) rotateX(55deg); }
  60% { opacity: 1; transform: translateY(1px) rotateX(-8deg); }
  100% { opacity: 1; transform: translateY(0) rotateX(0); }
}

/* package stack */
.package-stack {
  position: absolute;
  right: 1.3vw;
  bottom: 2.2vh;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  filter: drop-shadow(4px 4px 0 rgba(42, 27, 61, 0.7));
}
.pkg-card {
  position: relative;
  width: clamp(68px, 6.5vw, 92px);
  aspect-ratio: 0.78;
  background: var(--cream);
  border: 3px solid var(--plum);
  border-radius: 10px;
  overflow: hidden;
  transform: rotate(1.6deg);
  opacity: 0.9;
  transition: transform 0.25s, opacity 0.3s, filter 0.3s;
}
.pkg-card:nth-child(2n) { transform: rotate(-2.4deg); }
.pkg-card img {
  position: absolute;
  inset: 6% 4%;
  width: 92%;
  height: 88%;
  object-fit: contain;
}
.pkg-card .crack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  fill: none;
  stroke: var(--orange);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.95;
}
.pkg-card .pkg-tag {
  display: none;
  position: absolute;
  top: 3px;
  left: 3px;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--plum);
  background: var(--yellow);
  border: 1.5px solid var(--plum);
  border-radius: 3px;
  padding: 0 4px;
  transform: rotate(-6deg);
}
.pkg-card.active {
  opacity: 1;
  transform: rotate(-2deg) scale(1.07);
  border-color: var(--orange);
  z-index: 2;
  animation: pkgWobble 2.6s ease-in-out infinite;
}
.pkg-card.active .pkg-tag { display: block; }
.pkg-card.delivered {
  opacity: 0.28;
  filter: grayscale(1);
  transform: rotate(5deg) scale(0.9);
}
.pkg-card.shake { animation: pkgHit 0.35s linear; }
@keyframes pkgWobble {
  0%, 100% { transform: rotate(-2deg) scale(1.07); }
  50% { transform: rotate(1.4deg) scale(1.05); }
}
@keyframes pkgHit {
  0% { transform: rotate(-7deg) scale(1.12); }
  25% { transform: rotate(6deg) scale(0.96); }
  50% { transform: rotate(-5deg) scale(1.08); }
  75% { transform: rotate(4deg) scale(0.99); }
  100% { transform: rotate(-2deg) scale(1.07); }
}

/* hazard strip */
.hazard-strip {
  position: absolute;
  left: 50%;
  bottom: calc(0.6vh + clamp(96px, 10vw, 138px));
  transform: translateX(-50%) rotate(-0.7deg);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  background: var(--cream);
  border: 3px solid var(--plum);
  border-radius: 12px;
  box-shadow: 3px 3px 0 rgba(42, 27, 61, 0.9);
  opacity: 0.94;
}
.hazard {
  position: relative;
  width: clamp(22px, 2vw, 29px);
  height: clamp(22px, 2vw, 29px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hazard img { width: 100%; height: 100%; object-fit: contain; }
.hazard i {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%) scale(0.85);
  font-style: normal;
  font-size: 8px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--plum);
  color: var(--cream);
  padding: 1px 5px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.hazard:hover i { opacity: 1; }

/* motto */
.motto-wrap {
  position: absolute;
  left: 50%;
  bottom: 0.3vh;
  transform: translateX(-50%);
  width: clamp(208px, 21vw, 326px);
  pointer-events: none;
  filter: drop-shadow(4px 5px 0 rgba(42, 27, 61, 0.6));
}
.motto {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 70%;
  animation: mottoSway 4.5s ease-in-out infinite;
}
@keyframes mottoSway {
  0%, 100% { transform: rotate(-1.2deg) translateY(0); }
  50% { transform: rotate(1.4deg) translateY(-3px); }
}

/* mission toast */
.mission-toast {
  position: absolute;
  left: 50%;
  top: 106%;
  transform: translateX(-50%) rotate(-1.4deg);
  white-space: nowrap;
  background: var(--yellow);
  border: 3px solid var(--plum);
  border-radius: 9px;
  box-shadow: 3px 3px 0 var(--plum);
  padding: 3px 11px;
  font-family: "Lilita One", fantasy;
  font-size: clamp(12px, 1.1vw, 17px);
  color: var(--plum);
  animation: toastIn 2.2s ease-out forwards;
  pointer-events: none;
  z-index: 4;
}
@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(-8px) rotate(-1.4deg) scale(0.85); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0) rotate(-1.4deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-4px) rotate(-1.4deg) scale(0.98); }
}

/* control hint */
.control-hint {
  position: absolute;
  top: 1.5vh;
  left: 50%;
  transform: translateX(-50%) rotate(0.6deg);
  display: flex;
  gap: clamp(6px, 0.9vw, 13px);
  align-items: center;
  padding: 5px 12px;
  background: var(--cream);
  border: 3px solid var(--plum);
  border-radius: 11px;
  box-shadow: 3px 3px 0 rgba(42, 27, 61, 0.9);
  font-size: clamp(8px, 0.72vw, 11px);
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.3s;
}
.control-hint b {
  display: inline-block;
  font-weight: 600;
  background: var(--yellow);
  border: 1.5px solid var(--plum);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.95em;
}
body.title .control-hint, body.title .hazard-strip, body.title .end-shift { opacity: 0; pointer-events: none; }

.sound-btn {
  position: absolute;
  top: 1.4vh;
  right: calc(1.2vw + clamp(178px, 15vw, 236px) + 10px);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  z-index: 3;
}
.sound-btn svg { width: 23px; height: 23px; fill: none; stroke: var(--plum); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn .ic-off { display: none; }
.sound-btn.muted .ic-on { display: none; }
.sound-btn.muted .ic-off { display: block; }
.sound-btn:hover { transform: translateY(-2px); }

.end-shift {
  position: absolute;
  top: 5.4vh;
  left: 50%;
  transform: translateX(-50%);
  border: 2.5px solid var(--plum);
  background: var(--cream);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--plum);
  opacity: 0.85;
}
body.title .control-hint, body.title .touch-controls { display: none; }
.end-shift:hover { opacity: 1; }

/* touch */
.touch-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}
.touch-cluster {
  position: absolute;
  bottom: 27vh;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.touch-left { left: 2vw; flex-direction: column; }
.touch-right { right: 2vw; align-items: flex-end; }
.tbtn {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--plum);
  background: var(--cream);
  box-shadow: 3px 4px 0 var(--plum);
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 20px;
  color: var(--plum);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.tbtn-go { background: var(--yellow); font-size: 17px; }
.tbtn-hop { background: var(--pink); color: var(--cream); font-size: 15px; }
.tbtn:active { transform: translateY(2px); box-shadow: 1px 2px 0 var(--plum); }
body.touch:not(.title) .touch-controls { display: block; }
body.touch .control-hint { display: none; }

/* ---------- screens ---------- */
.title-screen {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}
.title-art {
  position: absolute;
  top: 0.6vh;
  left: 50%;
  width: clamp(400px, 36vw, 570px);
  height: auto;
  transform: translateX(-50%);
  filter: drop-shadow(5px 7px 0 rgba(42, 27, 61, 0.55));
  animation: titleFloat 5s ease-in-out infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateX(-50%) rotate(-0.4deg) translateY(0); }
  50% { transform: translateX(-50%) rotate(0.5deg) translateY(-5px); }
}
.title-notes { display: none; }
.title-note { display: none; }
.start-btn {
  pointer-events: auto;
  cursor: pointer;
  font-family: "Lilita One", fantasy;
  font-size: clamp(24px, 2.4vw, 36px);
  line-height: 1;
  color: var(--plum);
  background: var(--yellow);
  border: 4px solid var(--plum);
  border-radius: 14px;
  padding: 12px 30px 13px;
  box-shadow: 6px 6px 0 var(--plum);
  transform: rotate(-1.4deg);
  letter-spacing: 0;
}
.start-btn:hover { transform: rotate(1deg) translateY(-2px); }
.start-btn:active { transform: translateY(3px); box-shadow: 2px 3px 0 var(--plum); }
#startBtn {
  position: absolute;
  left: 1.8vw;
  top: calc(1.8vh + clamp(268px, 24vw, 356px) * 0.624 + 64px);
  transform: rotate(-1.4deg);
  z-index: 2;
}
.title-caption {
  position: absolute;
  left: 1.9vw;
  top: calc(1.8vh + clamp(268px, 24vw, 356px) * 0.624 + 156px);
  transform: rotate(0.7deg);
  margin: 0;
  font-size: clamp(10px, 0.9vw, 13px);
  font-weight: 600;
  color: var(--plum);
  background: var(--cream);
  border: 2.5px solid var(--plum);
  border-radius: 8px;
  padding: 3px 10px;
  box-shadow: 2px 3px 0 var(--plum);
  white-space: nowrap;
  z-index: 2;
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-card {
  text-align: center;
  padding: 20px 30px;
  transform: rotate(-1.4deg);
}
.loading-scooter {
  font-family: "Lilita One", fantasy;
  font-size: clamp(22px, 3vw, 40px);
  color: var(--plum);
  line-height: 1;
}
.loading-card p {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 500;
}
.loading-card::after {
  content: "";
  display: block;
  width: 46px;
  height: 46px;
  margin: 14px auto 0;
  border: 6px solid var(--plum);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen.done { display: none; }

.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(42, 27, 61, 0.58);
  padding: 3vh 2vw;
}
.overlay-screen.show { display: flex; }
.fail-card, .win-card {
  width: min(560px, 92vw);
  max-height: 92vh;
  overflow: auto;
  padding: 22px 26px 24px;
  text-align: center;
  transform: rotate(-1deg);
  background: var(--cream);
}
.fail-kicker, .win-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--pink);
}
.fail-card h2, .win-card h2 {
  font-family: "Lilita One", fantasy;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 0.92;
  margin: 4px 0 8px;
  color: var(--plum);
}
.fail-card p, .win-sub {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}
.fail-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.fail-actions .start-btn { font-size: 22px; padding: 10px 20px; }
.ghost-btn {
  background: var(--cream);
  border: 3px solid var(--plum);
  border-radius: 12px;
  padding: 9px 16px;
  font-family: "Lilita One", fantasy;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--plum);
}
.auto-retry { margin: 13px 0 0; font-size: 12px; opacity: 0.7; }
.win-card h2 { font-size: clamp(26px, 3vw, 42px); }
.win-sub { font-size: 12px; opacity: 0.8; }
.win-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.win-stats div {
  background: var(--cyan);
  border: 3px solid var(--plum);
  border-radius: 10px;
  padding: 7px 4px;
  box-shadow: 2px 3px 0 var(--plum);
}
.win-stats span {
  display: block;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--plum);
  opacity: 0.75;
}
.win-stats b {
  display: block;
  font-family: "Chakra Petch", monospace;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.1;
}
.win-board {
  margin: 4px 0 16px;
  text-align: left;
  border: 2.5px solid var(--plum);
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(255, 210, 63, 0.22);
}
.board-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  opacity: 0.7;
  margin-bottom: 3px;
}
#boardList { margin: 0; padding-left: 20px; font-size: 12px; font-weight: 500; }
#boardList li { line-height: 1.45; }
#boardList li.mine { font-weight: 600; color: var(--orange); }
#boardList a { color: var(--plum); }
#boardList .board-empty { list-style: none; margin-left: -20px; opacity: 0.6; }
#againBtn { margin-top: 2px; font-size: 24px; padding: 10px 24px; }

.delivery-popup {
  position: absolute;
  left: 50%;
  top: 18vh;
  transform: translateX(-50%) scale(0.85);
  z-index: 10;
  width: min(440px, 82vw);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.delivery-popup.show { opacity: 1; transform: translateX(-50%) scale(1); }
.speech {
  position: relative;
  padding: 12px 18px 14px;
  transform: rotate(-1.2deg);
  background: var(--cream);
}
.speech::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: -17px;
  width: 26px;
  height: 20px;
  background: var(--cream);
  border-right: 4px solid var(--plum);
  border-bottom: 4px solid var(--plum);
  transform: skewX(-18deg) rotate(24deg);
}
.speech-who {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--pink);
  margin-bottom: 2px;
}
.speech p {
  margin: 0;
  font-family: "Lilita One", fantasy;
  font-size: clamp(16px, 1.7vw, 24px);
  line-height: 1.05;
  color: var(--plum);
}

.rotate-note {
  position: absolute;
  left: 50%;
  bottom: 1vh;
  transform: translateX(-50%);
  display: none;
  z-index: 12;
  font-size: 10px;
  font-weight: 500;
  color: var(--cream);
  background: var(--plum);
  border-radius: 6px;
  padding: 3px 8px;
  opacity: 0.85;
  pointer-events: none;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .mission-card { width: clamp(210px, 37vw, 300px); top: 1.2vh; left: 1vw; }
  .mission-name { font-size: 15px; }
  .timer { font-size: 20px; min-width: 90px; }
  .chaos-badge { width: clamp(132px, 22vw, 185px); right: 1vw; }
  .chaos-value { font-size: clamp(30px, 4.8vw, 46px); }
  .gps-panel { width: clamp(230px, 40vw, 340px); bottom: 1.4vh; left: 1vw; }
  .gps-text { font-size: clamp(11px, 1.7vw, 15px); }
  .pkg-card { width: clamp(54px, 8.4vw, 74px); }
  .motto-wrap { width: clamp(180px, 27vw, 260px); }
  .hazard-strip { bottom: calc(0.6vh + clamp(84px, 12vw, 112px)); }
  .hazard { width: 21px; height: 21px; }
  .sound-btn { top: 1.2vh; right: calc(1vw + clamp(132px, 22vw, 185px) + 8px); width: 36px; height: 36px; }
  .sound-btn svg { width: 20px; height: 20px; }
  .title-art { width: min(68vw, 470px); }
  .title-caption { left: 2vw; top: calc(1.2vh + clamp(210px, 37vw, 300px) * 0.624 + 82px); font-size: 9px; }
}

@media (orientation: portrait) {
  .mission-card { width: 49vw; top: 1vh; left: 1.5vw; }
  body.title .mission-card, body.title .chaos-badge,
  body.title .gps-panel, body.title .package-stack { opacity: 0; pointer-events: none; }
  body.title #soundBtn { top: auto; bottom: 11vh; right: 3vw; opacity: 1; pointer-events: auto; }
  body.title .touch-controls { display: none; }
  .end-shift { display: none; }
  .title-art { width: 92vw; top: 1vh; }
  .mission-name { font-size: 15px; }
  .mission-dest { font-size: 9px; }
  .timer { font-size: 18px; min-width: 82px; }
  .chaos-badge { width: 33vw; top: 1vh; right: 1.5vw; }
  .chaos-value { font-size: clamp(32px, 7.5vw, 52px); }
  .gps-panel { width: 55vw; left: 2vw; bottom: 22vh; }
  .gps-device { flex-basis: 22%; }
  .gps-text { font-size: 11px; }
  .package-stack { flex-direction: row; right: 2vw; bottom: 10vh; gap: 4px; }
  .pkg-card { width: 12.5vw; }
  .motto-wrap { display: none; }
  body.title .motto-wrap { display: block; width: 42vw; bottom: 1.2vh; }
  .hazard-strip { display: none; }
  .control-hint { display: none; }
  .sound-btn { top: 1vh; right: calc(1.5vw + 33vw + 8px); }
  .title-caption { left: 2vw; top: calc(1vh + 92vw * 0.667 + 80px); font-size: 9px; white-space: normal; text-align: left; max-width: 70vw; }
  #startBtn { left: 2vw; top: calc(1vh + 92vw * 0.667 + 12px); }
  .touch-cluster { bottom: 2vh; }
  .win-stats { grid-template-columns: repeat(2, 1fr); }
  .rotate-note { display: block; animation: noteFade 7s forwards; }
  @keyframes noteFade { 0%, 70% { opacity: 0.85; } 100% { opacity: 0; } }
}

@media (orientation: landscape) and (max-height: 850px) {
  body.touch .package-stack { flex-direction: row; right: 2vw; bottom: 13vh; gap: 4px; }
  body.touch .pkg-card { width: clamp(56px, 7vw, 78px); }
  body.touch .gps-panel { bottom: 13vh; left: 2vw; width: clamp(300px, 30vw, 410px); }
  body.touch .touch-cluster { bottom: 2vh; }
  body.touch .touch-left { flex-direction: row; }
  body.touch .touch-right { flex-direction: row; align-items: center; }
  body.touch .hazard-strip { display: none; }
  body.touch .motto-wrap { width: clamp(190px, 20vw, 290px); bottom: 0.3vh; }
  body.touch .tbtn { width: 54px; height: 54px; font-size: 18px; }
  body.touch .tbtn-go { font-size: 15px; }
  body.touch .tbtn-hop { font-size: 14px; }
}

@media (max-height: 560px) {
  .mission-card { width: 210px; }
  .mission-name { font-size: 14px; }
  .timer { font-size: 18px; min-width: 85px; }
  .chaos-badge { width: 120px; }
  .gps-panel { width: 250px; }
  .pkg-card { width: 52px; }
  .motto-wrap { width: 170px; }
  .hazard-strip { display: none; }
  .control-hint { display: none; }
  .sound-btn { top: 8px; right: 136px; }
}

@media (prefers-reduced-motion: reduce) {
  .title-art, .motto, .pkg-card.active { animation: none; }
}
