

:root {
  --ink: #14183a;
  --card: rgba(20, 24, 58, 0.72);
  --card-text: #ffffff;
  --muted: #b9c3ff;
  --teal: #2fe0d0;
  --gold: #ffd34d;
  --gutter: 16px;
  --gap: 12px;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #5ec8ff;
  color: var(--ink);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hud {
  position: fixed;
  top: max(var(--gutter), env(safe-area-inset-top));
  left: max(var(--gutter), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: min(340px, calc(100vw - 2 * var(--gutter)));
  pointer-events: none;
}
.hud[hidden] {
  display: none;
}
.hud-card {
  background: var(--card);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 12px 16px;
  backdrop-filter: blur(6px);
}
.hud-title strong {
  white-space: nowrap;
}
.hud-title {
  display: flex;
  gap: var(--gap);
  align-items: baseline;
}
.hud-title span,
.hud-k {
  color: var(--muted);
  font-size: 13px;
}
.hud-challenge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}
.hud-challenge strong {
  font-size: 17px;
}
.hud-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px var(--gap);
  font-size: 14px;
}
.hud-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hud-v {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.hud-flash {
  align-self: flex-start;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  opacity: 0;
  transform: translateY(-6px);
}

.hud-stamps {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--gap);
  padding-left: 2px; 
}
.hud-stamps:empty {
  display: none;
}
.hud-stamp {
  padding: 6px 14px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: var(--card);
  color: var(--gold);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  animation: stamp 1s ease-out forwards;
}
@keyframes stamp {
  0% {
    opacity: 0;
    transform: scale(1.35) rotate(-2deg);
  }
  12% {
    opacity: 1;
    transform: scale(1) rotate(-1deg);
  }
  80% {
    opacity: 1;
    transform: scale(1) rotate(-1deg);
  }
  100% {
    opacity: 0;
    transform: scale(1) rotate(-1deg);
  }
}
.hud-flash.is-on {
  animation: flash 1.2s ease-out forwards;
}
@keyframes flash {
  0% {
    opacity: 0;
    transform: translateY(-6px);
  }
  12% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.help {
  position: fixed;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px var(--gap);
  font-size: 13px;
  max-width: calc(100vw - 2 * var(--gutter));
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  text-align: center;
  font: inherit;
}
.touch {
  display: none;
}
@media (pointer: coarse) {
  .help {
    display: none;
  }
  .touch {
    display: block;
  }
  .hud {
    max-width: min(300px, calc(50vw - var(--gutter)));
  }
  .hud-stats {
    grid-template-columns: repeat(3, 1fr);
    font-size: 12px;
  }
  .hud-challenge span:last-child {
    display: none;
  }
}
.touch-stick {
  position: fixed;
  left: max(var(--gutter), env(safe-area-inset-left));
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: rgba(20, 24, 58, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: grid;
  place-items: center;
}
.touch-knob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.touch-jump {
  position: fixed;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: max(var(--gutter), env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: none;
  background: var(--teal);
  color: var(--ink);
  font:
    700 18px system-ui,
    sans-serif;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}
.touch-jump.is-down {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}




.hud[data-mode="shift"] .hud-challenge,
.hud[data-mode="shift"] .hud-stats {
  display: none;
}
@media (max-height: 520px), (max-width: 600px) {
  .hud .hud-stats,
  .hud-challenge span:last-child {
    display: none;
  }
  .hud-card {
    padding: 8px 12px;
  }
  .hud-title {
    font-size: 14px;
    

    flex-wrap: wrap;
    row-gap: 2px;
  }
  .hud-title span:not(.hud-hearts) {
    order: 3;
    flex-basis: 100%;
    font-size: 12px;
  }
  .hud {
    
    max-width: calc(100vw - 2 * var(--gutter) - 56px);
  }
  .hud-challenge strong {
    font-size: 15px;
  }
  .hud-stamp {
    padding: 4px 12px;
    font-size: 13px;
  }
  .help {
    display: none;
  }
}
.hud.is-expanded .hud-stats {
  display: grid;
}
.hud-hearts {
  color: #ff6b5a; 
  letter-spacing: 1px;
}
.touch-dash {
  
  position: fixed;
  
  right: calc(max(var(--gutter), env(safe-area-inset-right)) + 14px);
  bottom: calc(max(var(--gutter), env(safe-area-inset-bottom)) + 124px);
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}



.touch-tether {
  position: fixed;
  right: calc(max(var(--gutter), env(safe-area-inset-right)) + 14px);
  bottom: calc(max(var(--gutter), env(safe-area-inset-bottom)) + 220px);
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}
@media (max-height: 520px) {
  .touch-tether {
    right: calc(max(var(--gutter), env(safe-area-inset-right)) + 110px);
    bottom: calc(max(var(--gutter), env(safe-area-inset-bottom)) + 124px);
  }
}
.touch-tether.is-down {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.touch-tether[hidden],
.help-tether[hidden],
.touch-dash[hidden],
.help-dash[hidden] {
  display: none;
}
.touch-dash.is-down {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}



.hud-train {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px var(--gap);
  font-size: 14px;
}
.hud-train[hidden] {
  display: none;
}
.hud-train-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hud-train-item svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.hud-pips {
  display: inline-flex;
  gap: 4px;
}
.hud-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--muted);
}
.hud-pip.is-on {
  background: var(--teal);
  border-color: var(--teal);
}
.hud-train-item.is-spark {
  color: #fff06a;
}
.is-train .touch-jump,
.is-train .touch-dash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
}
.is-train .touch-jump svg {
  width: 40px;
  height: 40px;
}
.is-train .touch-dash svg {
  width: 30px;
  height: 30px;
}
.is-train .touch-dash[hidden] {
  display: none;
}
.touch-label {
  font-size: 13px;
  line-height: 1;
}


.rescue {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--gold);
  color: var(--ink);
  text-align: center;
  font-size: 1.05rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
  pointer-events: none;
}
.rescue[hidden] {
  display: none;
}
.rescue-bar {
  display: block;
  width: 220px;
  max-width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgb(0 0 0 / 15%);
  overflow: hidden;
}
.rescue-bar i {
  display: block;
  height: 100%;
  background: var(--ink);
}
@media (max-width: 480px) {
  .rescue {
    font-size: 0.95rem;
    padding: 16px;
  }
}


.is-rescue .touch-dash[hidden] {
  display: inline-block;
}
