/* HT World — world.css
   OVERLAY UI STYLES ONLY. The world itself is rendered by three.js into #gl
   (WebGL) + #css3d (CSS3DRenderer video iframes); none of the 2D world/cursor/
   station styling from Cursor Carnival lives here. This file styles the DOM
   chrome that floats over the 3D canvas: HUD, action bar, chat, panels (wear /
   help / NPC dialog), gate overlay, toast, now-playing pill and minimap.
   Visual identity carried over: indigo night, warm gold + violet accents. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  margin: 0;
  /* clip in BOTH axes so no overlay/host can paint a right-edge band, but allow
     vertical scroll-free layout. overflow:clip can't be scrolled to reveal a
     band the way hidden's scroll origin can. */
  overflow: clip;
  background: #0b1026;
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  /* iOS safe areas — the world fills the notch but UI insets respect it */
  -webkit-text-size-adjust: 100%;
}
/* the 3D world owns the pointer — normal cursor everywhere */
body { cursor: auto; }
button { font-family: inherit; cursor: pointer; }

/* ================= 3D RENDER STACK ================= */
/* CSS3D video layer behind, GL canvas on top (it raycasts ground + meshes and
   carries pointer events; the video planes hole-punch through it).

   RIGHT-EDGE BLACK BAND FIX (audit): the band came from the CSS3D / screens
   host being able to extend past the viewport (its child wraps are absolutely
   positioned at projected rects that can run off-screen, and an empty host with
   a default opaque background or sub-pixel rounding leaves a sliver). Defenses:
   (1) clip these hosts to the viewport so no child sliver shows past the right
       edge; (2) force transparent background — they must NEVER paint a fill;
   (3) the host carries no pointer events. The renderer-size half of the fix
   (use clientWidth, not innerWidth rounding) lives in main3d. */
#css3d, #screens2d {
  background: transparent !important;
  overflow: clip;
}
#css3d {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
}
#gl {
  position: fixed; inset: 0;
  z-index: 1;
  /* 100% of the fixed inset:0 box — avoids 100vw, which on some browsers is
     wider than the layout viewport (scrollbar/rounding) and would itself create
     a right-edge band. */
  width: 100%; height: 100%;
  display: block;
  pointer-events: auto;
  touch-action: none;
}

/* ================= HUD ================= */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  z-index: 100;
  pointer-events: none;
}
#hudLeft, #hudRight { display: flex; gap: 9px; align-items: center; }
#hud a, #hud span {
  pointer-events: auto;
  font-size: 11px; font-weight: 800; letter-spacing: 0.16em;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(12, 9, 28, 0.78);
  border: 1px solid rgba(140, 100, 255, 0.35);
  color: #e6dcff;
  text-decoration: none;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
#brand { color: #ffd98a !important; border-color: rgba(255, 200, 110, 0.45) !important; }
#exitLink:hover { border-color: #ffd98a; color: #ffd98a; }

/* now-playing pill (festival stage) */
#nowPlaying {
  position: fixed;
  left: 50%; bottom: 78px; transform: translateX(-50%);
  z-index: 99;
  max-width: min(86vw, 560px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(12, 9, 28, 0.82);
  border: 1px solid rgba(255, 200, 110, 0.45);
  color: #ffe2aa;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
#nowPlaying:empty { display: none; }

/* ================= ACTION BAR ================= */
#bar {
  position: fixed;
  left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; gap: 7px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 20px);
  padding: 8px;
  border-radius: 999px;
  background: rgba(12, 9, 28, 0.82);
  border: 1px solid rgba(140, 100, 255, 0.35);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42);
  z-index: 100;
}
#bar button {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: rgba(140, 100, 255, 0.12);
  font-size: 19px;
  color: #fff;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
  display: grid; place-items: center;
}
#bar button:hover { border-color: #ffd98a; background: rgba(255, 200, 110, 0.16); transform: translateY(-1px); }
#bar button:active { transform: translateY(0) scale(0.96); }
#bar button.on { border-color: #ffd98a; background: rgba(255, 200, 110, 0.16); color: #ffd98a; }

/* ---- proximity voice mic ---- */
#micBtn .micGlyph { line-height: 1; }
#micBtn .liveDot {
  position: absolute; top: 6px; right: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #ff4d5e;
  border: 1.5px solid rgba(12, 9, 28, 0.9);
  opacity: 0; transform: scale(0.4);
  transition: opacity 0.16s, transform 0.16s;
  pointer-events: none;
}
/* mic enabled (permission granted, listening) — gold ring */
#micBtn.on {
  border-color: #ffd98a;
  background: rgba(255, 200, 110, 0.16);
  color: #ffd98a;
}
/* mic actively transmitting (you are speaking) — red live dot + halo */
#micBtn.live {
  border-color: #ff6b7a;
  background: rgba(255, 77, 94, 0.18);
  color: #ffd6db;
  box-shadow: 0 0 0 2px rgba(255, 77, 94, 0.28), 0 0 18px rgba(255, 77, 94, 0.4);
}
#micBtn.live .liveDot { opacity: 1; transform: scale(1); animation: liveBlink 1.1s ease-in-out infinite; }
@keyframes liveBlink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 94, 0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(255, 77, 94, 0); }
}
/* mic blocked / denied permission */
#micBtn.denied { opacity: 0.5; }

/* ================= CHAT INPUT ================= */
#chatForm {
  position: fixed;
  left: 50%; bottom: 74px; transform: translateX(-50%);
  z-index: 101;
  display: none;
  width: min(92vw, 420px);
}
#chatForm.open { display: block; }
#chatInput {
  width: 100%;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 200, 110, 0.55);
  background: rgba(12, 9, 28, 0.92);
  color: #fff;
  font-size: 15px;
  outline: none;
}

/* ================= PANELS (wear / help / npc) ================= */
.panel {
  position: fixed;
  left: 50%; bottom: 80px; transform: translateX(-50%);
  width: min(94vw, 420px);
  max-height: 64vh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 18px;
  background: rgba(14, 10, 32, 0.96);
  border: 1px solid rgba(140, 100, 255, 0.45);
  color: #e6dcff;
  z-index: 102;
  backdrop-filter: blur(10px);
}
.panel h3 { color: #ffd98a; font-size: 16px; letter-spacing: 0.08em; margin-bottom: 10px; }
.panel h4 {
  color: #cdb8ff; font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; margin-bottom: 8px;
}
.panel ul { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; line-height: 1.5; }
.panel li strong { color: #ffd98a; }
.panelHint { font-size: 12px; color: rgba(230, 220, 255, 0.55); margin-top: 10px; }
#helpClose {
  margin-top: 14px;
  padding: 11px 22px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #ffd98a, #e8a93d);
  color: #2a1c05; font-weight: 800; letter-spacing: 0.08em;
}

/* ---- wear / avatar customization ---- */
.wearSection { margin-bottom: 16px; }
.wearSection:last-of-type { margin-bottom: 0; }
/* body color swatch row (filled by avatar3d/main3d → #bodyRow) */
#bodyRow { display: flex; flex-wrap: wrap; gap: 9px; }
#bodyRow .swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(140, 100, 255, 0.4);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
#bodyRow .swatch:hover { transform: scale(1.08); }
#bodyRow .swatch.on {
  border-color: #ffd98a;
  box-shadow: 0 0 0 2px rgba(255, 200, 110, 0.35), 0 0 14px rgba(255, 200, 110, 0.45);
}
/* shirt flag/plain toggle */
#shirtToggle {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid rgba(140, 100, 255, 0.3);
  background: rgba(140, 100, 255, 0.1);
  color: #cdb8ff;
  font-size: 13.5px; font-weight: 700; letter-spacing: 0.04em;
  transition: all 0.15s;
}
#shirtToggle[aria-pressed='true'] {
  border-color: #ffd98a;
  background: rgba(255, 200, 110, 0.14);
  color: #ffd98a;
}
/* gear grid (filled by avatar3d/main3d → #wearGrid) */
#wearGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wearItem {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid rgba(140, 100, 255, 0.3);
  background: rgba(140, 100, 255, 0.08);
  font-size: 22px;
  color: #cdb8ff;
  cursor: pointer;
}
.wearItem small { font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; }
.wearItem.on { border-color: #ffd98a; background: rgba(255, 200, 110, 0.14); color: #ffd98a; }
.wearItem.locked { opacity: 0.38; cursor: not-allowed; }

/* ---- NPC dialog (vendors + Guru robot chat) ---- */
#npcDialog {
  width: min(94vw, 440px);
  max-height: 70vh;
  display: flex; flex-direction: column;
  padding: 0;
  overflow: hidden;
}
#npcHeader {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(140, 100, 255, 0.3);
  background: rgba(20, 12, 40, 0.6);
}
#npcAvatar {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(140, 100, 255, 0.35), rgba(20, 12, 40, 0.9));
  border: 1px solid rgba(255, 200, 110, 0.4);
}
#npcName { flex: 1 1 auto; margin: 0; font-size: 15px; }
#npcClose {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(140, 100, 255, 0.35);
  background: rgba(140, 100, 255, 0.12);
  color: #cdb8ff;
  font-size: 14px; line-height: 1;
}
#npcClose:hover { border-color: #ffd98a; color: #ffd98a; }
#npcLog {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  font-size: 13.5px; line-height: 1.45;
  min-height: 90px;
}
#npcLog .msg {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 14px;
  word-break: break-word; white-space: pre-wrap;
  animation: bubbleIn 0.18s ease;
}
#npcLog .msg.bot {
  align-self: flex-start;
  background: rgba(140, 100, 255, 0.14);
  border: 1px solid rgba(140, 100, 255, 0.3);
  color: #e6dcff;
  border-bottom-left-radius: 3px;
}
#npcLog .msg.me {
  align-self: flex-end;
  background: rgba(255, 200, 110, 0.16);
  border: 1px solid rgba(255, 200, 110, 0.4);
  color: #ffe9c4;
  border-bottom-right-radius: 3px;
}
#npcLog .msg.typing { color: rgba(205, 184, 255, 0.65); font-style: italic; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }
#npcForm {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(140, 100, 255, 0.3);
  background: rgba(20, 12, 40, 0.6);
}
/* vendor NPCs have no chat input — main3d hides the form for canned-line NPCs */
#npcForm.hidden { display: none; }
#npcInput {
  flex: 1 1 auto;
  padding: 11px 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 200, 110, 0.5);
  background: rgba(12, 9, 28, 0.92);
  color: #fff;
  font-size: 14px;
  outline: none;
}
#npcSend {
  flex: 0 0 auto;
  width: 44px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #ffd98a, #e8983d);
  color: #2a1c05;
  font-size: 16px; font-weight: 800;
}
#npcSend:hover { filter: brightness(1.08); }

/* ================= MINIMAP ================= */
#miniMap {
  position: fixed;
  right: 14px; bottom: 76px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(12, 9, 28, 0.85);
  border: 1px solid rgba(140, 100, 255, 0.4);
  z-index: 100;
}
#miniCanvas { display: block; border-radius: 7px; }

/* ================= GATE OVERLAY ================= */
#gateOverlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7, 5, 18, 0.78);
  backdrop-filter: blur(5px);
  z-index: 200;
  cursor: auto;
}
#gateCard {
  width: min(92vw, 460px);
  max-height: min(92vh, 760px);
  overflow-y: auto;
  padding: 38px 30px;
  text-align: center;
  border-radius: 26px;
  background: linear-gradient(180deg, #1d1438, #140e2a);
  border: 2px solid rgba(255, 200, 110, 0.4);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 60px rgba(122, 60, 255, 0.25);
  transition: width 0.3s ease;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 100, 255, 0.5) transparent;
}
#gateCard::-webkit-scrollbar { width: 8px; }
#gateCard::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.45); border-radius: 8px; }
/* avatar + customize steps want more room for the rail/grid */
body[data-onboarding="avatar"]    #gateCard { width: min(94vw, 560px); padding: 30px 26px; }
body[data-onboarding="customize"] #gateCard { width: min(95vw, 640px); padding: 30px 26px; }

/* ===== EA-style step machine: show exactly one .gateStep =====
   body[data-onboarding] selects the active step; if the attribute is missing
   (older main3d that only knows the hero gate) the hero step shows by default. */
.gateStep { animation: gateStepIn 0.32s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
.gateStep[hidden] { display: none !important; }
@keyframes gateStepIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#gateArt {
  width: 148px; height: 148px;
  border-radius: 50%;
  object-fit: cover;
  transform: scale(1.0);
  margin: 0 auto 14px;
  display: block;
  box-shadow: 0 0 50px rgba(255, 200, 110, 0.45), 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 3px solid rgba(255, 200, 110, 0.55);
}
#gateTitle {
  font-family: Georgia, serif;
  font-size: 44px; letter-spacing: 0.06em;
  color: #ffd98a;
  text-shadow: 0 0 30px rgba(255, 200, 110, 0.5);
}
#gateSub { color: #cdb8ff; font-size: 14.5px; margin: 8px 0 22px; }
#gateEnter {
  padding: 15px 38px;
  font-size: 16px; font-weight: 800; letter-spacing: 0.1em;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, #ffd98a, #e8983d);
  color: #2a1c05;
  box-shadow: 0 8px 30px rgba(255, 180, 80, 0.35);
  cursor: pointer;
}
#gateEnter:hover { filter: brightness(1.08); }
#gateNote { margin-top: 14px; font-size: 12px; color: rgba(205, 184, 255, 0.65); min-height: 16px; }
#gateLinks { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
#gateLinks a {
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(140, 100, 255, 0.45);
  color: #cdb8ff;
  text-decoration: none;
}
#gateLinks a:hover { border-color: #ffd98a; color: #ffd98a; }
/* on the avatar/customize steps the bottom links are quieter (nav has Back) */
body[data-onboarding="avatar"] #gateLinks,
body[data-onboarding="customize"] #gateLinks { margin-top: 12px; opacity: 0.62; }

/* ================= ONBOARDING — shared step chrome ================= */
.gateHead {
  font-family: Georgia, serif;
  font-size: 27px; letter-spacing: 0.03em;
  color: #ffd98a;
  text-shadow: 0 0 22px rgba(255, 200, 110, 0.4);
  margin-bottom: 4px;
}
.gateHeadSub { color: #cdb8ff; font-size: 13.5px; margin: 0 0 16px; line-height: 1.45; }
.gateMeta { margin-top: 14px; font-size: 12px; color: rgba(205, 184, 255, 0.6); line-height: 1.5; }
.gatePrimary {
  padding: 14px 32px;
  font-size: 15px; font-weight: 800; letter-spacing: 0.08em;
  border: none; border-radius: 999px;
  background: linear-gradient(135deg, #ffd98a, #e8983d);
  color: #2a1c05;
  box-shadow: 0 8px 26px rgba(255, 180, 80, 0.32);
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s;
}
.gatePrimary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.gatePrimary:active { transform: translateY(0) scale(0.98); }
.gatePrimary[disabled] { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.gateBig { padding: 16px 44px; font-size: 16px; letter-spacing: 0.1em; }
.gateGhost {
  padding: 13px 24px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  border-radius: 999px;
  border: 1px solid rgba(140, 100, 255, 0.45);
  background: rgba(140, 100, 255, 0.08);
  color: #cdb8ff;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.gateGhost:hover { border-color: #ffd98a; color: #ffd98a; background: rgba(255, 200, 110, 0.1); }
.gateNav { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 20px; }
.gateNavStack { flex-direction: column; }
.gateNavStack .gatePrimary, .gateNavStack .gateGhost { width: 100%; }
.gateArtSm {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 10px; display: block;
  border: 2px solid rgba(255, 200, 110, 0.5);
  box-shadow: 0 0 30px rgba(255, 200, 110, 0.35);
}
.authNote { margin-top: 12px; font-size: 12px; color: rgba(160, 220, 170, 0.8); min-height: 0; }
.authNote:empty { display: none; }
.gateNote { margin-top: 12px; font-size: 12px; color: rgba(205, 184, 255, 0.65); min-height: 0; }
.gateNote:empty { margin-top: 0; }

/* ---- avatar live-preview stage ---- */
.avatarStage {
  position: relative;
  width: 100%;
  display: grid; place-items: center;
  margin: 0 auto 14px;
}
.avatarStage canvas {
  display: block;
  width: min(82vw, 320px); height: auto;
  max-height: 46vh;
  border-radius: 20px;
  background:
    radial-gradient(120% 90% at 50% 18%, rgba(140, 100, 255, 0.22), transparent 62%),
    linear-gradient(180deg, #160f30, #0d0922);
  border: 1px solid rgba(140, 100, 255, 0.32);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}
.avatarStageSm canvas { width: min(60vw, 220px); max-height: 38vh; border-radius: 16px; }
.previewGlow {
  position: absolute; inset: auto 0 8px 0; height: 26px; margin: 0 auto;
  width: 60%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 200, 110, 0.35), transparent 70%);
  filter: blur(4px); pointer-events: none;
}

/* ---- gender filter chips ---- */
.genderChips { display: flex; gap: 8px; justify-content: center; margin: 0 0 14px; flex-wrap: wrap; }
.genderChip {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(140, 100, 255, 0.4);
  background: rgba(140, 100, 255, 0.08);
  color: #cdb8ff;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.genderChip:hover { border-color: rgba(255, 200, 110, 0.6); color: #ffe9c4; }
.genderChip.is-on, .genderChip[aria-selected="true"] {
  border-color: #ffd98a; color: #2a1c05;
  background: linear-gradient(135deg, #ffd98a, #e8b85a);
}

/* ---- character card rail ---- */
.charRail {
  display: flex; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  padding: 6px 2px 10px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 100, 255, 0.5) transparent;
}
.charRail::-webkit-scrollbar { height: 6px; }
.charRail::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.4); border-radius: 6px; }
.charCard {
  position: relative;
  flex: 0 0 auto;
  width: 92px; min-height: 116px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px 10px;
  border-radius: 16px;
  border: 1.5px solid rgba(140, 100, 255, 0.3);
  background: rgba(140, 100, 255, 0.07);
  color: #cdb8ff;
  cursor: pointer;
  scroll-snap-align: center;
  transition: transform 0.14s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.charCard:hover { transform: translateY(-2px); border-color: rgba(255, 200, 110, 0.55); }
.charCard .charThumb {
  width: 60px; height: 60px; border-radius: 12px;
  object-fit: cover; display: block;
  background: radial-gradient(circle at 50% 35%, rgba(140, 100, 255, 0.3), rgba(13, 9, 34, 0.9));
  border: 1px solid rgba(140, 100, 255, 0.3);
  font-size: 30px; line-height: 60px; text-align: center;
}
.charCard .charName { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }
.charCard[hidden] { display: none !important; }
/* animated selection ring */
.charCard.is-selected {
  border-color: transparent;
  background: rgba(255, 200, 110, 0.12);
  color: #ffe9c4;
  box-shadow: 0 6px 22px rgba(255, 180, 80, 0.28);
}
.charCard.is-selected::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 18px;
  padding: 2px;
  background: conic-gradient(from 0deg, #ffd98a, #b07bff, #ffd98a, #e8983d, #ffd98a);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: ringSpin 4s linear infinite;
  pointer-events: none;
}
@keyframes ringSpin { to { transform: rotate(360deg); } }
.charCard.is-selected .charName { color: #ffd98a; }

/* ---- customize step ---- */
.customizePanel { display: flex; gap: 18px; align-items: flex-start; text-align: left; }
.custCol { display: flex; flex-direction: column; gap: 14px; }
.custColPreview { flex: 0 0 auto; align-items: center; }
.custColControls { flex: 1 1 auto; min-width: 0; }
.custGroup { display: flex; flex-direction: column; gap: 8px; }
.custGroup h4 {
  color: #cdb8ff; font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; margin: 0;
}
.swatchRow { display: flex; flex-wrap: wrap; gap: 9px; }
.swatchRow .swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(140, 100, 255, 0.4);
  cursor: pointer; padding: 0;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.swatchRow .swatch:hover { transform: scale(1.08); }
.swatchRow .swatch.on, .swatchRow .swatch[aria-checked="true"] {
  border-color: #ffd98a;
  box-shadow: 0 0 0 2px rgba(255, 200, 110, 0.35), 0 0 14px rgba(255, 200, 110, 0.45);
}
.gearRail { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gearRail .gearItem {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px;
  border-radius: 12px;
  border: 1px solid rgba(140, 100, 255, 0.3);
  background: rgba(140, 100, 255, 0.08);
  font-size: 20px; color: #cdb8ff; cursor: pointer;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.gearRail .gearItem small { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; }
.gearRail .gearItem:hover { border-color: rgba(255, 200, 110, 0.5); }
.gearRail .gearItem.on { border-color: #ffd98a; background: rgba(255, 200, 110, 0.14); color: #ffd98a; }

/* ---- returning-user continue card ---- */
.continueCard {
  display: flex; align-items: center; gap: 14px;
  text-align: left;
  padding: 12px 14px; margin: 6px auto 4px;
  border-radius: 18px;
  border: 1px solid rgba(140, 100, 255, 0.35);
  background: rgba(140, 100, 255, 0.08);
  width: fit-content; max-width: 100%;
}
.continueCard canvas {
  flex: 0 0 auto;
  width: 96px; height: 120px; border-radius: 12px;
  background: linear-gradient(180deg, #160f30, #0d0922);
  border: 1px solid rgba(140, 100, 255, 0.3);
}
.continueMeta { display: flex; flex-direction: column; gap: 3px; }
.continueLabel { color: #ffd98a; font-size: 16px; font-weight: 800; letter-spacing: 0.03em; }
.continueHint { color: rgba(205, 184, 255, 0.7); font-size: 12px; }

/* ================= CONTROLS HINT (bottom-left, fades) ================= */
#controlsHint {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left, 0px));
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  z-index: 99;
  display: flex; flex-wrap: wrap; gap: 6px; max-width: min(48vw, 340px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
}
#controlsHint.fade { opacity: 0; }
#controlsHint[hidden] { display: none; }
.ctlChip {
  font-size: 10.5px; letter-spacing: 0.04em;
  color: #cdb8ff;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(12, 9, 28, 0.7);
  border: 1px solid rgba(140, 100, 255, 0.28);
  backdrop-filter: blur(5px);
  white-space: nowrap;
}
.ctlChip b { color: #ffd98a; font-weight: 800; }

/* ================= MOBILE JUMP BUTTON ================= */
#jumpBtn {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 101;
  width: 72px; height: 72px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 50%;
  border: 1px solid rgba(255, 200, 110, 0.45);
  background: rgba(20, 12, 40, 0.78);
  color: #ffd98a;
  font-size: 26px; line-height: 1;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.15s;
}
#jumpBtn small { font-size: 9px; font-weight: 800; letter-spacing: 0.1em; }
#jumpBtn:active { transform: scale(0.92); background: rgba(255, 200, 110, 0.2); }
#jumpBtn[hidden] { display: none !important; }

/* ================= BIG MAP PANEL ================= */
.bigPanel {
  width: min(96vw, 760px) !important;
  max-width: 96vw;
  max-height: min(86vh, 720px);
  padding: 16px !important;
  left: 50%; top: 50%; bottom: auto;
  transform: translate(-50%, -50%) !important;
}
.bigMapHead {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.bigMapHead h3 { margin: 0; }
.bigMapTools { display: flex; gap: 8px; align-items: center; }
#recenterBtn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(140, 100, 255, 0.45);
  background: rgba(140, 100, 255, 0.1);
  color: #cdb8ff;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
#recenterBtn:hover { border-color: #ffd98a; color: #ffd98a; background: rgba(255, 200, 110, 0.12); }
#bigMapClose, #settingsClose {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(140, 100, 255, 0.35);
  background: rgba(140, 100, 255, 0.12);
  color: #cdb8ff;
  font-size: 14px; line-height: 1; cursor: pointer;
}
#bigMapClose:hover, #settingsClose:hover { border-color: #ffd98a; color: #ffd98a; }
#bigMapStage {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(140, 100, 255, 0.3);
  background: linear-gradient(180deg, #11193a, #0c1230);
  touch-action: none;   /* the map handles its own pan/zoom */
}
#bigMapCanvas {
  display: block;
  width: 100%; height: auto;
  cursor: grab;
}
#bigMapCanvas:active { cursor: grabbing; }

/* ================= SETTINGS PANEL ================= */
#settingsPanel { width: min(94vw, 420px); }
.setRow {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 2px;
  border-bottom: 1px solid rgba(140, 100, 255, 0.16);
}
.setRow:last-of-type { border-bottom: none; }
.setLabel { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.setName { color: #e6dcff; font-size: 14px; font-weight: 700; }
.setSub { color: rgba(205, 184, 255, 0.55); font-size: 11.5px; }
.setToggle {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(140, 100, 255, 0.4);
  background: rgba(140, 100, 255, 0.1);
  color: #cdb8ff;
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.setToggle:hover { border-color: rgba(255, 200, 110, 0.55); color: #ffe9c4; }
.setToggle[aria-pressed="true"] {
  border-color: #ffd98a;
  background: rgba(255, 200, 110, 0.16);
  color: #ffd98a;
}
/* quality toggle reads its current mode from data-quality for clarity */
#qualityToggle[data-quality="low"] { color: #cdb8ff; background: rgba(140, 100, 255, 0.1); border-color: rgba(140, 100, 255, 0.4); }

/* ================= TOAST ================= */
#toast {
  position: fixed;
  left: 50%; top: 64px; transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(12, 9, 28, 0.94);
  border: 1px solid rgba(255, 200, 110, 0.55);
  color: #ffd98a;
  font-size: 13px; font-weight: 700;
  z-index: 210;
  white-space: nowrap;
}

/* ================= MOBILE ================= */
@media (max-width: 760px) {
  #bar { gap: 5px; padding: 6px; }
  #bar button { width: 42px; height: 42px; font-size: 17px; }
  #hud a, #hud span { font-size: 9.5px; padding: 7px 10px; }
  #nowPlaying { max-width: 60vw; bottom: 74px; }
  #gateTitle { font-size: 34px; }
  .gateHead { font-size: 23px; }
  #miniMap { bottom: 72px; }
  /* mini-map hugs the right so it doesn't sit under the jump button */
  #miniMap { right: calc(96px + env(safe-area-inset-right, 0px)); }
  #controlsHint { max-width: 64vw; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
  /* stack the customize columns on phones */
  .customizePanel { flex-direction: column; align-items: stretch; }
  .custColPreview { align-self: center; }
  .gearRail { grid-template-columns: repeat(5, 1fr); }
  .bigPanel { width: 96vw !important; padding: 12px !important; }
}
/* very short / landscape phones: shrink the avatar stage so the rail stays visible */
@media (max-height: 560px) {
  .avatarStage canvas { max-height: 38vh; }
  #gateArt { width: 96px; height: 96px; }
  #gateTitle { font-size: 30px; }
}

/* ================= ACCESSIBILITY ================= */
/* keyboard focus ring — visible only for keyboard users, gold to match theme */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.charCard:focus-visible,
.genderChip:focus-visible,
.swatchRow .swatch:focus-visible,
.gearRail .gearItem:focus-visible,
.emoteBtn:focus-visible {
  outline: 2px solid #ffd98a;
  outline-offset: 2px;
  border-radius: 8px;
}
#bigMapCanvas:focus-visible, #avatarPreview:focus-visible { outline: 2px solid #ffd98a; outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .charCard.is-selected::after { animation: none; }
  #micBtn.live .liveDot { animation: none; }
  #controlsHint { transition: opacity 0.001ms !important; }
}

/* hidden attr must always win over .panel display (covers new V2 panels too) */
.panel[hidden],
#miniMap[hidden],
#npcDialog[hidden],
#bigMap[hidden],
#settingsPanel[hidden],
#jumpBtn[hidden] { display: none !important; }
