@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/grotesk-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #040d10;
  --ink-2: #07181c;
  --glass: rgba(6, 20, 24, 0.72);
  --line: rgba(151, 222, 213, 0.2);
  --line-hot: rgba(151, 222, 213, 0.55);
  --ivory: #e9f2ee;
  --muted: #8ba8a6;
  --teal: #6fe3d0;
  --teal-deep: #1e8f88;
  --amber: #e8b56a;
  --amber-deep: #a76f2e;
  --danger: #e2775f;
  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --pad: clamp(14px, 3.4vw, 34px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

button { font-family: inherit; color: inherit; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #0a2a30 0%, #051216 45%, #030a0c 100%);
}

#view { position: absolute; inset: 0; }
#view canvas { display: block; width: 100% !important; height: 100% !important; }

.screen {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }

.kicker {
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 500;
}

.tiny {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- character select ---------------- */

#select {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(180deg, rgba(3, 10, 12, 0.82) 0%, rgba(3, 10, 12, 0.05) 26%, rgba(3, 10, 12, 0.02) 55%, rgba(3, 10, 12, 0.88) 88%, rgba(3, 10, 12, 0.97) 100%);
  transition: opacity 0.8s ease;
}
#select.gone { opacity: 0; pointer-events: none; }

.select-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(var(--safe-t) + 18px) var(--pad) 0;
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line-hot);
  border-radius: 50%;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--teal);
  box-shadow: 0 0 24px rgba(111, 227, 208, 0.12), inset 0 0 15px rgba(111, 227, 208, 0.08);
}
.brand-word {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ivory);
  white-space: nowrap;
}
.designation {
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}

.select-copy {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: calc(var(--safe-t) + 84px);
  margin-top: 0;
  pointer-events: none;
  max-width: 92%;
}
.select-copy h1 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(31px, 6.1vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 12px 0 14px;
  max-width: 12ch;
  text-wrap: balance;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.55);
}
.sel-role {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.select-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 22px var(--pad) calc(var(--safe-b) + 20px);
  background: linear-gradient(180deg, rgba(4, 13, 16, 0) 0%, rgba(4, 13, 16, 0.75) 30%, rgba(4, 13, 16, 0.94) 100%);
  border-top: 1px solid rgba(151, 222, 213, 0.08);
}

.char-info { min-height: 74px; }
.char-index {
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--teal);
  margin-bottom: 5px;
}
.char-info h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(21px, 3.1vw, 33px);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.char-info p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 46ch;
}

.char-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 11px 12px 12px;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(160deg, rgba(13, 35, 39, 0.9), rgba(6, 19, 22, 0.72));
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}
.char-card::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent, var(--teal));
  opacity: 0;
  transition: opacity 0.2s ease;
}
.char-card:hover { border-color: var(--line-hot); }
.char-card.on {
  border-color: rgba(232, 181, 106, 0.65);
  background: linear-gradient(160deg, rgba(31, 44, 41, 0.95), rgba(8, 24, 27, 0.9));
  transform: translateY(-2px);
}
.char-card.on::after { opacity: 1; }
.char-card .num {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.char-card .who {
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--ivory);
  font-weight: 500;
}
.char-card .role {
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent, var(--teal));
  line-height: 1.35;
}
.char-card.featured .num::after {
  content: " · featured";
  color: var(--amber);
}

.enter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 15px 20px;
  border: 1px solid rgba(232, 181, 106, 0.65);
  border-radius: 5px;
  background: linear-gradient(100deg, rgba(232, 181, 106, 0.16), rgba(232, 181, 106, 0.04));
  color: var(--ivory);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.enter-btn svg { width: 20px; height: 20px; color: var(--amber); transition: transform 0.25s ease; }
.enter-btn:hover { background: linear-gradient(100deg, rgba(232, 181, 106, 0.28), rgba(232, 181, 106, 0.08)); box-shadow: 0 0 40px rgba(232, 181, 106, 0.14); }
.enter-btn:hover svg { transform: translateX(4px); }
.enter-btn:disabled { opacity: 0.45; cursor: default; }

/* ---------------- hud ---------------- */

#hud {
  transition: opacity 0.6s ease;
}
#hud.gone { opacity: 0; pointer-events: none; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 14px) var(--pad) 26px;
  background: linear-gradient(180deg, rgba(3, 10, 12, 0.68), rgba(3, 10, 12, 0));
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }

.loc { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 12px rgba(2,8,10,0.85), 0 1px 3px rgba(2,8,10,0.9); padding: 6px 12px 7px 10px; border-left: 1px solid rgba(232,181,106,0.35); background: linear-gradient(90deg, rgba(3,10,12,0.62), rgba(3,10,12,0)); }
.clockbox { text-shadow: 0 1px 10px rgba(2,8,10,0.8); }
.loc strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(17px, 2.2vw, 23px);
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.loc .tiny { margin-top: 3px; font-size: 9px; color: rgba(210, 232, 226, 0.74); }

.compass {
  position: relative;
  width: min(34vw, 300px);
  height: 34px;
  margin-top: 3px;
  pointer-events: none;
}
.compass-window {
  position: absolute;
  inset: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.compass-track {
  position: absolute;
  top: 14px; left: 0;
  height: 1px;
  width: 4000px;
  background:
    repeating-linear-gradient(90deg, rgba(233, 242, 238, 0.55) 0 1px, transparent 1px 14px),
    linear-gradient(90deg, transparent, rgba(151, 222, 213, 0.25), transparent);
  will-change: transform;
}
.compass-track span {
  position: absolute;
  top: -13px;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(233, 242, 238, 0.82);
}
.compass-track span.card { color: var(--amber); font-size: 10px; }
.compass-pin {
  position: absolute;
  left: 50%; top: 8px;
  width: 1px; height: 13px;
  background: var(--teal);
  box-shadow: 0 0 8px var(--teal);
  transform: translateX(-50%);
}
.compass-mark {
  position: absolute;
  top: 9px;
  width: 7px; height: 7px;
  margin-left: -3.5px;
  border: 1px solid var(--amber);
  transform: rotate(45deg) scale(0.8);
  box-shadow: 0 0 10px rgba(232, 181, 106, 0.5);
  transition: left 0.3s linear;
}

.clockbox {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}
.clockbox > div { display: flex; flex-direction: column; }
#clock {
  font-size: 15px;
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
  color: var(--ivory);
}
#phase { font-size: 8.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(8, 24, 27, 0.5);
  color: var(--ivory);
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  flex: none;
}
.icon-btn:hover { border-color: var(--line-hot); background: rgba(17, 44, 47, 0.7); }
#pauseBtn { gap: 3px; display: flex; flex-direction: row; align-items: center; justify-content: center; }
#pauseBtn i { display: block; width: 2px; height: 12px; background: var(--ivory); }

.hud-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 40px var(--pad) calc(var(--safe-b) + 18px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  background: linear-gradient(0deg, rgba(3, 10, 12, 0.76), rgba(3, 10, 12, 0));
  pointer-events: none;
}
.hud-bottom > * { pointer-events: auto; }

.objective {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  max-width: 420px;
  padding: 12px 16px 13px;
  border-left: 1px solid rgba(232, 181, 106, 0.55);
  background: linear-gradient(90deg, rgba(6, 20, 24, 0.72), rgba(6, 20, 24, 0));
}
.obj-dot {
  width: 7px; height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber);
  animation: pulse 2.6s ease-in-out infinite;
  flex: none;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.72); } }
.objective strong { display: block; font-size: 13px; font-weight: 500; letter-spacing: 0.03em; margin: 3px 0 2px; }
.objective p { margin: 0; font-size: 10.5px; line-height: 1.45; color: var(--muted); }

.controls-hint {
  grid-column: 1 / -1;
  justify-self: center;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(139, 168, 166, 0.75);
  padding-bottom: 2px;
}

.touch-ui { display: contents; }

.joystick {
  position: fixed;
  left: calc(var(--safe-l) + 22px);
  bottom: calc(var(--safe-b) + 74px);
  width: 104px; height: 104px;
  border: 1px solid rgba(151, 222, 213, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(111, 227, 208, 0.06), rgba(3, 12, 14, 0.12));
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.35);
  touch-action: none;
  pointer-events: auto;
}
.joystick .stick {
  position: absolute;
  left: 50%; top: 50%;
  width: 42px; height: 42px;
  margin: -21px 0 0 -21px;
  border: 1px solid rgba(151, 222, 213, 0.5);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(151, 222, 213, 0.28), rgba(6, 20, 24, 0.75));
  box-shadow: 0 0 18px rgba(111, 227, 208, 0.15);
  will-change: transform;
}

.round-btn {
  position: fixed;
  right: calc(var(--safe-r) + 24px);
  bottom: calc(var(--safe-b) + 88px);
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(232, 181, 106, 0.7);
  background: radial-gradient(circle at 40% 30%, rgba(232, 181, 106, 0.3), rgba(20, 16, 10, 0.85));
  color: var(--ivory);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  box-shadow: 0 0 30px rgba(232, 181, 106, 0.14);
  pointer-events: auto;
}
.round-btn[hidden] { display: none; }

.waypoint {
  position: absolute;
  left: 0; top: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  padding: 4px 8px;
  border: 1px solid rgba(232, 181, 106, 0.3);
  border-radius: 3px;
  background: rgba(4, 13, 16, 0.55);
  backdrop-filter: blur(3px);
  white-space: nowrap;
}
.waypoint[hidden] { display: none; }
.wp-diamond {
  width: 7px; height: 7px;
  border: 1px solid var(--amber);
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(232, 181, 106, 0.6);
}
.wp-label { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ivory); }
.wp-dist { font-size: 9px; letter-spacing: 0.1em; color: var(--amber); font-variant-numeric: tabular-nums; }

.toast {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: min(90vw, 520px);
  padding: 10px 18px;
  border: 1px solid rgba(232, 181, 106, 0.4);
  border-radius: 4px;
  background: rgba(6, 20, 24, 0.88);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ivory);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------- dialogue ---------------- */

.dlg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 var(--pad) calc(var(--safe-b) + 18px);
  background: linear-gradient(0deg, rgba(3, 10, 12, 0.72), rgba(3, 10, 12, 0) 55%);
  pointer-events: auto;
}
.dlg[hidden] { display: none; }
.dlg-card {
  width: min(720px, 100%);
  padding: 18px 20px 16px;
  border: 1px solid rgba(151, 222, 213, 0.24);
  border-radius: 6px;
  background:
    linear-gradient(160deg, rgba(13, 33, 37, 0.96), rgba(5, 16, 19, 0.97));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: rise 0.35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.dlg-head { display: flex; align-items: center; gap: 11px; }
.monogram {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid rgba(232, 181, 106, 0.55);
  border-radius: 50%;
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.08em;
  background: radial-gradient(circle at 35% 30%, rgba(232, 181, 106, 0.18), rgba(8, 24, 27, 0.6));
  flex: none;
}
.dlg-head strong { display: block; font-size: 13px; letter-spacing: 0.08em; font-weight: 500; }
.dlg-head small { display: block; font-size: 8.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.live-dot {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--teal);
}
.live-dot i { width: 5px; height: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); animation: pulse 2s infinite; }
.dlg-text {
  margin: 15px 0 4px;
  font-family: var(--serif);
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 300;
  line-height: 1.45;
  letter-spacing: 0.005em;
  color: var(--ivory);
  min-height: 2.9em;
}
.dlg-choices { display: grid; gap: 7px; margin: 14px 0 6px; }
.dlg-choice {
  text-align: left;
  padding: 11px 14px;
  border: 1px solid rgba(151, 222, 213, 0.24);
  border-radius: 4px;
  background: rgba(9, 28, 31, 0.75);
  font-size: 12.5px;
  color: var(--ivory);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dlg-choice:hover { border-color: rgba(232, 181, 106, 0.6); background: rgba(20, 38, 36, 0.9); }
.dlg-next {
  margin-left: auto;
  display: block;
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid rgba(232, 181, 106, 0.5);
  border-radius: 4px;
  background: transparent;
  color: var(--amber);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
}
.dlg-next:hover { background: rgba(232, 181, 106, 0.12); }
.dlg-next[hidden] { display: none; }

/* ---------------- overlays ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 20px) var(--pad) calc(var(--safe-b) + 20px);
  background: rgba(2, 8, 10, 0.9);
  backdrop-filter: blur(7px);
  pointer-events: auto;
  animation: fade 0.25s ease both;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 26px 22px;
  border: 1px solid rgba(151, 222, 213, 0.22);
  border-radius: 8px;
  background: linear-gradient(165deg, #0b2327, #071518 60%, #061114);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}
.panel h2 {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(27px, 4vw, 38px);
  margin: 8px 0 18px;
  letter-spacing: -0.01em;
}
.panel-close { position: absolute; top: 14px; right: 14px; }
.menu-list { display: grid; gap: 7px; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(151, 222, 213, 0.16);
  border-radius: 4px;
  background: rgba(8, 26, 29, 0.55);
  text-align: left;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.menu-row:hover { border-color: rgba(232, 181, 106, 0.55); background: rgba(19, 40, 39, 0.7); }
.menu-row small { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.controls-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 18px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(151, 222, 213, 0.12);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.controls-list div { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.controls-list b { color: var(--ivory); font-weight: 400; }

.codex-panel { width: min(680px, 100%); }
.codex-list { display: grid; gap: 0; border-top: 1px solid rgba(151, 222, 213, 0.12); }
.codex-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid rgba(151, 222, 213, 0.1);
}
.codex-row .ci { font-size: 9px; letter-spacing: 0.1em; color: var(--teal); padding-top: 3px; }
.codex-row h3 { margin: 0 0 4px; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; color: var(--ivory); }
.codex-row p { margin: 0; font-size: 11px; line-height: 1.55; color: var(--muted); }
.codex-row.locked h3 { color: rgba(139, 168, 166, 0.6); }
.codex-row.locked p { color: rgba(139, 168, 166, 0.38); filter: blur(3px); user-select: none; }
.codex-foot { margin: 16px 0 0; font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(139, 168, 166, 0.55); }

/* ---------------- loading + errors ---------------- */

.loading {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(80% 60% at 50% 40%, #0a2429 0%, #041014 55%, #020809 100%);
  transition: opacity 0.9s ease;
}
.loading.gone { opacity: 0; pointer-events: none; }
.load-inner { width: min(420px, 82vw); text-align: center; }
.load-mark {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(111, 227, 208, 0.4);
  border-radius: 50%;
  color: var(--teal);
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: 0 0 50px rgba(111, 227, 208, 0.12), inset 0 0 25px rgba(111, 227, 208, 0.08);
  animation: spinPulse 6s linear infinite;
}
@keyframes spinPulse { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.load-title {
  font-family: var(--serif);
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-bottom: 26px;
}
.load-bar { height: 1px; background: rgba(151, 222, 213, 0.16); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal-deep), var(--teal), var(--amber)); transition: width 0.4s ease; box-shadow: 0 0 14px var(--teal); }
.load-status { margin-top: 14px; font-size: 9.5px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); min-height: 1.4em; }
.load-sub { margin-top: 30px; font-size: 8px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(139, 168, 166, 0.45); }

.error-box {
  position: absolute;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 90vw;
  padding: 10px 14px;
  border: 1px solid rgba(226, 119, 95, 0.5);
  border-radius: 4px;
  background: rgba(20, 8, 8, 0.9);
  color: #f3d6cf;
  font-size: 11px;
}

/* ---------------- responsive ---------------- */

@media (orientation: landscape) and (min-width: 720px) {
  .select-copy {
    position: absolute;
    left: var(--pad);
    top: 50%;
    transform: translateY(-58%);
    max-width: 46vw;
    margin-top: 0;
  }
  .select-copy { top: 50%; transform: translateY(-58%); max-width: 46vw; }
  .select-copy h1 { font-size: clamp(40px, 4.6vw, 68px); }
  .select-bottom {
    grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr) minmax(180px, 0.8fr);
    align-items: end;
    gap: 26px;
    padding-top: 18px;
  }
  .char-cards { align-self: end; }
  .enter-btn { align-self: end; height: 58px; }
  .hud-bottom { grid-template-columns: minmax(0, 420px) auto; padding-bottom: calc(var(--safe-b) + 26px); }
  .controls-hint { justify-self: end; padding-right: 4px; }
  .joystick { left: calc(var(--safe-l) + 26px); bottom: calc(var(--safe-b) + 96px); }
}

@media (min-width: 900px) and (orientation: portrait) {
  .select-copy { max-width: 60vw; }
}

@media (max-width: 380px) {
  .designation { display: none; }
  .char-card { padding: 9px 8px 10px; }
  .char-card .role { font-size: 7.5px; }
  .compass { width: 30vw; }
  .objective p { display: none; }
}

@media (hover: none) {
  .controls-hint { display: none; }
}

.key-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 88px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px 8px 8px;
  border: 1px solid rgba(232, 181, 106, 0.45);
  border-radius: 4px;
  background: rgba(5, 18, 21, 0.82);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ivory);
  pointer-events: none;
  animation: rise 0.3s ease both;
}
.key-prompt[hidden] { display: none; }
.key-prompt b {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border: 1px solid rgba(232, 181, 106, 0.6);
  border-radius: 3px;
  color: var(--amber);
  font-weight: 500;
  font-size: 11px;
}

#app::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(130% 100% at 50% 45%, transparent 58%, rgba(2, 8, 10, 0.42) 100%),
    linear-gradient(180deg, rgba(2, 8, 10, 0.25) 0%, transparent 14%, transparent 82%, rgba(2, 8, 10, 0.3) 100%);
}

#hud { opacity: 0; pointer-events: none; }
#hud.on { opacity: 1; pointer-events: none; }
#hud.on .hud-top > *, #hud.on .hud-bottom > *, #hud.on .objective, #hud.on .touch-ui * { pointer-events: auto; }
#hud.talking .objective, #hud.talking .touch-ui, #hud.talking .waypoint, #hud.talking .toast { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }

@media (hover: none) {
  .hud-bottom { padding-bottom: calc(var(--safe-b) + 158px); }
  .objective {
    position: fixed;
    left: var(--pad);
    right: auto;
    bottom: calc(var(--safe-b) + 196px);
    top: auto;
    max-width: min(88vw, 380px);
    padding: 10px 14px 11px;
    background: linear-gradient(90deg, rgba(6,20,24,.78), rgba(6,20,24,.05));
    border-left-color: rgba(232,181,106,.55);
    border-radius: 0 4px 4px 0;
  }
  .objective p { display: block; }
  .objective strong { font-size: 12px; }
  .objective p { font-size: 10px; }
  .toast { position: fixed; bottom: calc(var(--safe-b) + 288px); left: 50%; transform: translateX(-50%) translateY(8px); max-width: 86vw; text-align: center; }
  .toast.show { transform: translateX(-50%) translateY(0); }
  .compass { display: none; }
  #soundBtn, #helpBtn { display: none; }
  .loc .tiny { display: none; }
  .clockbox { gap: 8px; }
  .hud-top { padding-top: calc(var(--safe-t) + 17px); }
  .select-top { padding-top: calc(var(--safe-t) + 14px); }
  .designation { font-size: 8.5px; letter-spacing: 0.16em; max-width: 48%; }
  .select-copy { top: calc(var(--safe-t) + 76px); }
}
@media (hover: none) and (orientation: landscape) {
  .objective { bottom: calc(var(--safe-b) + 150px); max-width: 46vw; }
  .toast { bottom: calc(var(--safe-b) + 232px); }
  .joystick { bottom: calc(var(--safe-b) + 54px); left: calc(var(--safe-l) + 18px); width: 92px; height: 92px; }
  .round-btn { bottom: calc(var(--safe-b) + 60px); width: 66px; height: 66px; }
}

.fade { position: fixed; inset: 0; background: #010204; opacity: 0; transition: opacity 0.7s ease; pointer-events: none; z-index: 60; }
.fade.on { opacity: 1; }
.fade[hidden] { display: none; }
.menu-row[hidden] { display: none; }
.boost-btn { border-color: rgba(255, 231, 176, 0.75); }
.boost-btn.held { background: radial-gradient(circle at 40% 30%, rgba(255, 231, 176, 0.6), rgba(60, 40, 14, 0.9)); box-shadow: 0 0 40px rgba(255, 220, 160, 0.35); }

#hud.flying .toast { position: fixed; top: calc(var(--safe-t) + 84px); bottom: auto; left: 50%; transform: translateX(-50%) translateY(-6px); max-width: min(86vw, 520px); text-align: center; }
#hud.flying .toast.show { transform: translateX(-50%) translateY(0); }
.touch-ui[hidden] { display: none; }

.screen[hidden], .overlay[hidden], .dlg[hidden] { display: none !important; }
button, a, .joystick { -webkit-tap-highlight-color: transparent; }

.wallet { margin-top: 4px; font-size: 10px; letter-spacing: 0.14em; color: rgba(255, 231, 176, 0.92); font-variant-numeric: tabular-nums; }
.wallet b { font-weight: 500; color: var(--ivory); }
.wallet i { font-style: normal; opacity: 0.45; padding: 0 2px; }
.wallet.pulse { animation: walletPulse 0.8s ease; }
@keyframes walletPulse { 0% { color: #fff6d8; text-shadow: 0 0 14px rgba(255,220,160,0.9); } 100% { } }
.pilots { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(151, 222, 213, 0.8); }
.shop-btn { font-size: 10px; letter-spacing: 0.08em; color: rgba(255, 231, 176, 0.95); border-color: rgba(232, 181, 106, 0.55); }
#hud.on .loc .wallet, #hud.on .loc .pilots { pointer-events: none; }
.tags { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); padding: 2px 7px; font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ivory); background: rgba(4, 13, 16, 0.6); border: 1px solid rgba(151, 222, 213, 0.35); border-radius: 2px; white-space: nowrap; }
.tag small { display: block; font-size: 8px; letter-spacing: 0.12em; color: rgba(151, 222, 213, 0.8); }
.shop-panel { max-height: 86vh; overflow-y: auto; }
.shop-wallet { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 12px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 231, 176, 0.9); }
.shop-wallet b { font-size: 15px; color: var(--ivory); font-weight: 500; margin-right: 4px; }
.ops { display: grid; gap: 6px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid rgba(151, 222, 213, 0.18); background: rgba(6, 20, 24, 0.5); }
.ops div { display: flex; justify-content: space-between; gap: 10px; font-size: 10px; letter-spacing: 0.08em; color: rgba(210, 232, 226, 0.82); }
.ops div b { font-weight: 500; color: var(--teal); white-space: nowrap; }
.ops .ops-head { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(232, 181, 106, 0.85); }
.shop-list { display: grid; gap: 8px; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; border: 1px solid rgba(232, 181, 106, 0.22); background: rgba(10, 18, 20, 0.6); }
.shop-item h3 { margin: 0; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; color: var(--ivory); }
.shop-item p { grid-column: 1 / 2; margin: 0; font-size: 10.5px; line-height: 1.5; color: var(--muted); }
.shop-item .tier { font-size: 9px; letter-spacing: 0.14em; color: rgba(151, 222, 213, 0.8); text-transform: uppercase; }
.shop-item button { grid-row: 1 / 3; grid-column: 2; min-width: 92px; padding: 9px 10px; border: 1px solid rgba(232, 181, 106, 0.7); background: rgba(40, 28, 12, 0.7); color: var(--ivory); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; border-radius: 2px; }
.shop-item button:disabled { opacity: 0.4; border-color: rgba(151, 168, 166, 0.4); background: transparent; }
.shop-item.omega { border-color: rgba(255, 231, 176, 0.5); background: linear-gradient(90deg, rgba(48, 34, 12, 0.55), rgba(10, 18, 20, 0.6)); }
@media (hover: none) { .wallet { font-size: 9.5px; } }

.weapon-hud { position: fixed; right: calc(var(--safe-r) + 14px); top: calc(var(--safe-t) + 74px); width: 168px; padding: 8px 10px; border: 1px solid rgba(151, 222, 213, 0.3); border-left: 1px solid rgba(232, 181, 106, 0.6); background: rgba(4, 12, 15, 0.62); pointer-events: none; }
.weapon-hud[hidden], .boss-bar[hidden], .mode-btn[hidden] { display: none; }
.w-top { display: flex; justify-content: space-between; gap: 6px; font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ivory); }
.w-top b { font-weight: 500; color: #bfe8ff; }
.w-bar { height: 4px; margin-top: 6px; background: rgba(151, 222, 213, 0.12); }
.w-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #6fd8ff, #e8f7ff); box-shadow: 0 0 8px rgba(160, 220, 255, 0.6); }
.w-charge i { background: linear-gradient(90deg, #e8b56a, #fff2c8); width: 0; }
.w-charge.heat i { background: linear-gradient(90deg, #e8b56a, #ff6a3a); }
.w-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(151, 222, 213, 0.8); }
.boss-bar { position: fixed; left: 50%; top: calc(var(--safe-t) + 128px); transform: translateX(-50%); width: min(80vw, 360px); text-align: center; pointer-events: none; font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: #ffb4a0; }
.b-bar { height: 5px; margin: 5px 0 4px; background: rgba(255, 90, 60, 0.15); border: 1px solid rgba(255, 110, 80, 0.4); }
.b-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5a3a, #ffb070); }
.boss-bar small { color: rgba(255, 220, 200, 0.8); }
.fire-btn { right: calc(var(--safe-r) + 24px); bottom: calc(var(--safe-b) + 176px); border-color: rgba(160, 220, 255, 0.8); background: radial-gradient(circle at 40% 30%, rgba(160, 220, 255, 0.35), rgba(8, 18, 26, 0.85)); }
.fire-btn.held { box-shadow: 0 0 36px rgba(160, 220, 255, 0.5); }
.mode-btn { position: fixed; right: calc(var(--safe-r) + 108px); bottom: calc(var(--safe-b) + 196px); padding: 8px 10px; border-radius: 3px; border: 1px solid rgba(160, 220, 255, 0.5); background: rgba(6, 14, 20, 0.8); color: var(--ivory); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; pointer-events: auto; }
@media (hover: none) and (orientation: landscape) { .fire-btn { bottom: calc(var(--safe-b) + 140px); } .mode-btn { bottom: calc(var(--safe-b) + 150px); } }
.puzzle-panel { text-align: center; }
.puzzle-help { font-size: 11px; line-height: 1.55; color: var(--muted); margin: 0 0 14px; }
.dials { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.dial { width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(160, 220, 255, 0.55); background: radial-gradient(circle, rgba(160, 220, 255, 0.12), rgba(6, 12, 16, 0.9)); position: relative; transition: transform 0.25s ease, box-shadow 0.25s; pointer-events: auto; }
.dial::after { content: ''; position: absolute; left: 50%; top: 4px; width: 4px; height: 22px; margin-left: -2px; border-radius: 2px; background: #e8f7ff; box-shadow: 0 0 10px rgba(160, 220, 255, 0.9); }
.dial.ok { border-color: rgba(255, 226, 170, 0.85); }
.dial.hint { box-shadow: 0 0 0 3px rgba(255, 226, 170, 0.6); }
.tag.op { border-color: rgba(232, 181, 106, 0.5); }

/* an open panel owns the screen: the HUD and floating tags step back */
body:has(.overlay:not([hidden])) #hud,
body:has(.overlay:not([hidden])) .tags { visibility: hidden; }

/* phone held upright: the objective sits under the district name, clear of the player and the weapon buttons */
@media (hover: none) and (orientation: portrait) {
  #hud:not(.flying) .objective { top: calc(var(--safe-t) + 104px); bottom: auto; max-width: calc(100vw - 206px); padding: 8px 10px 9px; }
  #hud:not(.flying) .objective p { font-size: 9.5px; }
  .mode-btn { bottom: calc(var(--safe-b) + 176px); right: calc(var(--safe-r) + 112px); }
}

.objective p { transition: opacity 0.4s ease, max-height 0.4s ease; max-height: 6em; overflow: hidden; }
.objective.brief p { opacity: 0; max-height: 0; }
.objective.brief { background: linear-gradient(90deg, rgba(6,20,24,.5), rgba(6,20,24,0)); }
