:root {
  --ink: #eef0f6;
  --dim: #9aa0ae;
  --glass: rgba(14, 15, 22, 0.62);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ffd27a;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
}

#scene {
  display: block;
  touch-action: none;
  outline: none;
}

/* ---- boot ---- */
#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
  background: #000;
  transition: opacity 0.6s;
  z-index: 50;
}
#boot.gone {
  opacity: 0;
  pointer-events: none;
}
.boot-mark {
  justify-self: center;
  display: block;
  opacity: 0.94;
}
.boot-title {
  font-size: 26px;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.boot-status {
  color: var(--dim);
  font-size: 13px;
}

/* ---- hud ---- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-size: 13px;
}
#hud > * {
  pointer-events: auto;
}
#hud.hud-hidden > *:not(.unhide):not(.touch) {
  display: none !important;
}
#hud.agent-hud-hidden > * {
  display: none !important;
}

.btn,
select,
.play {
  font: inherit;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn:hover,
select:hover {
  border-color: rgba(255, 255, 255, 0.3);
}
.btn.on {
  border-color: var(--accent);
  color: var(--accent);
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, #aab 50%), linear-gradient(135deg, #aab 50%, transparent 50%);
  background-position: calc(100% - 12px) 52%, calc(100% - 8px) 52%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

.hud-top-left {
  position: absolute;
  top: 14px;
  left: 16px;
  display: grid;
  gap: 6px;
  pointer-events: none;
}
.place-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  width: max-content;
}
.place-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9aa;
  box-shadow: 0 0 10px currentColor;
}
.hint {
  color: var(--dim);
  font-size: 11px;
  text-shadow: 0 1px 2px #000;
}

.hud-top-right {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 60vw;
}
.rec-btn .rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4a4a;
  margin-right: 6px;
  vertical-align: 0;
}
.rec-btn.on .rec-dot {
  animation: blink 1s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.2;
  }
}

.toasts {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  pointer-events: none;
  width: min(420px, 90vw);
}
.toast {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  display: grid;
  gap: 2px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.3s, transform 0.3s;
  backdrop-filter: blur(8px);
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast span {
  color: var(--dim);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.toast a {
  pointer-events: auto;
  justify-self: start;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.shot-btn {
  pointer-events: auto;
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 12px;
  color: var(--dim);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px 4px 5px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.shot-btn[hidden] {
  display: none;
}
.shot-btn kbd {
  font: 600 11px ui-monospace, Menlo, monospace;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}
.shot-btn kbd[hidden] {
  display: none;
}
.shot-btn.on {
  color: var(--accent);
  border-color: var(--accent);
}
.shot-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 7px 16px 7px 8px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 0 24px -8px var(--accent);
}
.prompt[hidden] {
  display: none;
}
.prompt kbd {
  font: 600 12px ui-monospace, Menlo, monospace;
  background: var(--accent);
  color: #111;
  border-radius: 999px;
  padding: 3px 9px;
}

.transport {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px 12px;
  width: min(760px, calc(100vw - 32px));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.play {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 15px;
  flex: none;
  border-radius: 50%;
}
.play.on {
  border-color: var(--accent);
  color: var(--accent);
}
.track {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}
.track-pick {
  justify-self: start;
  max-width: 100%;
  padding: 3px 24px 3px 10px;
  font-weight: 600;
}
.track-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.track-row .track-pick {
  flex: none;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-status {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-status[data-state='busy'] {
  color: var(--accent);
}
.track-status[data-state='ready'] {
  color: #7dffa8;
}
.track-status[data-state='error'] {
  color: #ff8a7a;
}
.fix-btn {
  flex: none;
  padding: 2px 9px;
  font-size: 11px;
}
.fix-btn[hidden] {
  display: none;
}
.beat-fix {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(320px, calc(100vw - 32px));
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.beat-fix[hidden] {
  display: none;
}
.beat-fix .fix-note {
  color: var(--dim);
  font-size: 11px;
}
.beat-fix label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.beat-fix input {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  width: 120px;
}
.fix-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.seek-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 11px ui-monospace, Menlo, monospace;
  color: var(--dim);
}
.seek {
  flex: 1;
}
.vol {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--dim);
}
.vol input {
  width: 80px;
}
input[type='range'] {
  accent-color: var(--accent);
}

.map-panel {
  position: absolute;
  top: 56px;
  right: 14px;
  width: 290px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.map-panel[hidden] {
  display: none;
}
.map-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.radar {
  width: 100%;
  aspect-ratio: 1;
  display: block;
}
.map-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.map-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.map-list li:hover {
  background: rgba(255, 255, 255, 0.07);
}
.map-list li i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.map-list li em {
  margin-left: auto;
  color: var(--dim);
  font-style: normal;
  font-size: 11px;
}
.map-list li.missing {
  opacity: 0.55;
}

.shop-btn[hidden],
.store-return-btn[hidden] {
  display: none;
}
.store-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 500;
}
.brand-portal-icon {
  display: block;
  flex: none;
}
.catalogue-brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.catalogue-wordmark {
  display: block;
  width: auto;
  height: 20px;
}
.catalogue-store-link {
  flex: none;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.shop-card,
.catalogue-panel {
  position: absolute;
  top: 56px;
  right: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.shop-card {
  width: min(304px, calc(100vw - 28px));
  border-top: 2px solid var(--place-accent, var(--accent));
}
.catalogue-panel {
  width: min(352px, calc(100vw - 28px));
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}
.shop-card[hidden],
.catalogue-panel[hidden] {
  display: none;
}
.shop-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shop-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 10px var(--place-accent, var(--accent));
}
.shop-card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.shop-badge {
  font-size: 11px;
  color: var(--dim);
}
.shop-badge.is-new {
  color: var(--place-accent, var(--accent));
  font-weight: 600;
}
.shop-dismiss {
  padding: 2px 9px;
  line-height: 1.2;
}
.shop-summary,
.catalogue-intro,
.catalogue-summary {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.4;
}
.shop-packs {
  display: grid;
  gap: 6px;
}
.shop-pack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.shop-pack-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.shop-pack-copy strong {
  font-size: 12px;
  font-weight: 600;
}
.shop-pack-copy span {
  font-size: 11px;
  color: var(--dim);
}
.shop-pack-action {
  flex: none;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border-color: rgba(255, 255, 255, 0.18);
}
.shop-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shop-note {
  margin: 0;
  font-size: 11px;
  color: var(--dim);
}
.shop-open-catalogue {
  padding: 4px 10px;
  font-size: 11px;
}
.catalogue-progress {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}
.catalogue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.catalogue-item {
  display: grid;
  gap: 6px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.catalogue-item.found {
  border-color: color-mix(in srgb, var(--place-accent, var(--accent)) 45%, rgba(255, 255, 255, 0.12));
}
.catalogue-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.catalogue-place {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}
.catalogue-place i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.catalogue-state {
  font-size: 11px;
  color: var(--dim);
}
.catalogue-item.found .catalogue-state {
  color: var(--place-accent, var(--accent));
}
.catalogue-go {
  padding: 3px 10px;
  font-size: 11px;
  flex: none;
}

.meter {
  position: absolute;
  left: 16px;
  top: 76px;
  border-radius: 12px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.meter[hidden] {
  display: none;
}

.drop-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  font-size: 26px;
  font-weight: 600;
  border: 3px dashed var(--accent);
}
.drop-veil[hidden] {
  display: none;
}

.unhide {
  position: absolute;
  right: 10px;
  bottom: 10px;
  opacity: 0.15;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
}
.unhide:hover {
  opacity: 0.8;
}
.unhide[hidden] {
  display: none;
}

/* ---- touch ---- */
.touch {
  display: none;
}
@media (pointer: coarse) {
  .touch {
    display: block;
    position: absolute;
    inset: auto 0 96px 0;
    height: 150px;
    pointer-events: none;
  }
  .stick {
    position: absolute;
    left: 24px;
    bottom: 0;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    pointer-events: auto;
    touch-action: none;
  }
  .nub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    margin: -27px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
  }
  .touch-jump,
  .touch-act {
    position: absolute;
    bottom: 0;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--glass);
    color: var(--ink);
    font: 600 13px inherit;
    pointer-events: auto;
    touch-action: none;
  }
  .touch-jump {
    right: 24px;
  }
  .touch-ride {
    position: absolute;
    right: 20px;
    bottom: 124px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
  }
  .touch-ride[hidden] {
    display: none;
  }
  .touch-ride button {
    width: 58px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--glass);
    color: var(--ink);
    font: 600 14px inherit;
    touch-action: none;
  }
  .touch-act {
    right: 112px;
    bottom: 34px;
  }
  .hint {
    display: none;
  }
  /* No hint line on touch: the shot button sits right under the place chip. */
  .shot-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
  /* Keep the action prompt above the stick and the Use / Jump buttons. */
  .prompt {
    bottom: 300px;
  }
  .vol {
    display: none;
  }
}

@media (max-width: 640px) {
  .transport {
    gap: 8px;
  }
  .load-btn {
    display: none;
  }
  .hud-top-right {
    max-width: 70vw;
  }
  /* The top-right buttons wrap to a second row here: toasts and drawers go below it. */
  .toasts {
    top: 92px;
  }
  .map-panel,
  .shop-card,
  .catalogue-panel {
    top: 92px;
    max-height: calc(100vh - 190px);
  }
}
