:root {
  --panel: rgba(18, 26, 36, 0.72);
  --panel-border: rgba(255, 255, 255, 0.16);
  --accent: #f0b429;
  --font: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: #f5f7fa;
  background: #1a2430;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
}

#viewport.is-dragging {
  cursor: grabbing;
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hud-top,
.hud-left,
.hud-right,
.hud-bottom,
.toast,
.station-labels {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  top: 0.75rem;
  left: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.hud-top > * {
  pointer-events: auto;
}

.level-badge {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  background: radial-gradient(circle at 35% 30%, #6a7a8a, #2c3644 72%);
  border: 3px solid #d0d8e0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.quest-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem 0.4rem 0.4rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.quest-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #d44545, #8a2020);
  font-size: 0.85rem;
}

.quest-icon.route {
  background: linear-gradient(160deg, #3a9a6a, #1f6a48);
}

.route-chip {
  max-width: 14rem;
}

.switch-label.named {
  width: auto;
  min-width: 2.4rem;
  height: 2.2rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  gap: 0.15rem;
}

.resources {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.res {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem 0.35rem 0.35rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.res b {
  font-variant-numeric: tabular-nums;
}

.ico {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.ico.people {
  background: linear-gradient(160deg, #5a9fd4, #2a6088);
}
.ico.people::after {
  content: "";
  position: absolute;
  inset: 28% 32% 42%;
  background: #e8f4ff;
  border-radius: 50%;
}
.ico.people::before {
  content: "";
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: 18%;
  height: 28%;
  background: #e8f4ff;
  border-radius: 40% 40% 20% 20%;
}

.ico.coin {
  background: radial-gradient(circle at 35% 30%, #ffe08a, #d4a020 65%, #a87810);
  box-shadow: inset 0 0 0 2px rgba(255, 220, 120, 0.45);
}

.ico.gem {
  background: linear-gradient(160deg, #6ee0a8, #1f8a5a);
  clip-path: polygon(50% 8%, 88% 38%, 70% 92%, 30% 92%, 12% 38%);
  border-radius: 0;
}

.hud-left,
.hud-right {
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.hud-left {
  left: 0.75rem;
}
.hud-right {
  right: 0.75rem;
}

.round-btn {
  pointer-events: auto;
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, #4e5e70, #2a3644);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.round-btn:hover {
  filter: brightness(1.08);
}
.round-btn:active,
.round-btn[aria-pressed="true"] {
  transform: scale(0.96);
  border-color: var(--accent);
}

.hud-bottom {
  left: 0;
  right: 0;
  bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.speed-panel {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  border-radius: 1.1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

.speed-panel button {
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #3e4e5e, #243038);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.speed-panel button:active {
  background: linear-gradient(180deg, #8a5a28, #5a3818);
  border-color: var(--accent);
}

.speed-readout {
  min-width: 4.6rem;
  text-align: center;
  line-height: 1.05;
}

.speed-readout span {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
}

.speed-readout small {
  opacity: 0.65;
  font-size: 0.68rem;
  font-weight: 700;
}

.hint {
  margin: 0;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.55;
  max-width: 40rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.toast {
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(28, 38, 48, 0.92), rgba(55, 42, 28, 0.92));
  border: 1px solid rgba(240, 180, 80, 0.45);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  animation: toast-in 0.35s ease;
  white-space: nowrap;
}

.toast[hidden] {
  display: none;
}

.station-labels {
  inset: 0;
  overflow: hidden;
}

.station-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(18, 26, 36, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 800;
  font-size: 0.72rem;
  white-space: nowrap;
  line-height: 1.2;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  will-change: left, top;
}

.station-label.landmark {
  border-color: rgba(120, 200, 255, 0.55);
  color: #dff4ff;
  background: rgba(20, 40, 55, 0.88);
}

.switch-label {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  cursor: pointer;
}

.timer-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: rgba(24, 32, 42, 0.88);
  border: 3px solid #e0a820;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.62rem;
  line-height: 1.1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@media (max-width: 700px) {
  .hint {
    display: none;
  }
  .resources .res:first-child {
    display: none;
  }
  .round-btn {
    width: 2.7rem;
    height: 2.7rem;
  }
  .hud-left,
  .hud-right {
    top: auto;
    bottom: 5.5rem;
    transform: none;
  }
}
