/* ═══════════════════════════════════════════════════════════════
   NEXUS — in-world HUD & loading
   ═══════════════════════════════════════════════════════════════ */

.nexus-root { position: fixed; inset: 0; overflow: hidden; background: #000; }
.nexus-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------------- loading ---------------- */
.nexus-loading {
  position: absolute; inset: 0; z-index: 30;
  background: radial-gradient(90% 70% at 50% 30%, #171226, #08070c 75%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  transition: opacity 0.55s;
}
.nexus-loading.done { opacity: 0; pointer-events: none; }
.nl-mark { animation: nlfloat 3s ease-in-out infinite; filter: drop-shadow(0 0 34px rgba(143,123,216,0.45)); }
@keyframes nlfloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.nexus-loading h2 { font-size: 30px; letter-spacing: 0.34em; margin-left: 0.34em; }
.nl-status { color: var(--text-dim); font-size: 13.5px; }
.nl-bar { width: min(300px, 70vw); height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; }
.nl-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.4s; }
.nl-tip { color: var(--text-faint); font-size: 12.5px; margin-top: 16px; font-style: italic; }

/* ---------------- HUD frame ---------------- */
.hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; font-size: calc(14px * var(--ui-scale)); }
.hud > * { pointer-events: auto; }
.hud-markers, .hud-hints, .hud-captions { pointer-events: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(rgba(5,4,9,0.55), transparent);
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-brand { display: flex; gap: 10px; align-items: center; }
.hud-brand b { font-family: var(--font-display); letter-spacing: 0.22em; font-size: 15px; display: block; }
.hud-server { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.04em; }
.hud-top-right { display: flex; gap: 8px; position: relative; }
.hud-chip {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: rgba(12,10,18,0.72); backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text-dim);
  position: relative; transition: color 0.15s, border-color 0.15s;
}
.hud-chip:hover { color: var(--text); border-color: var(--lav-deep); }
.hud-chip svg { width: 19px; height: 19px; }
.hud-chip .pop {
  position: absolute; top: -6px; right: -6px; background: var(--lav-deep); color: #fff;
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--font-display); padding: 0 4px;
}
.help-tip {
  position: absolute; top: 48px; right: 0; white-space: nowrap;
  background: var(--grad); color: #16121e; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 10px;
  animation: tipin 0.4s;
}
.help-tip::before { content: ''; position: absolute; top: -5px; right: 18px; border: 5px solid transparent; border-bottom-color: #ecdfc0; border-top: none; }
@keyframes tipin { from { opacity: 0; transform: translateY(6px); } }

/* ---------------- event tracker ---------------- */
.hud-event {
  background: rgba(12,10,18,0.78); backdrop-filter: blur(10px);
  border: 1px solid rgba(143,123,216,0.4); border-radius: 14px;
  padding: 10px 16px; min-width: 260px; max-width: 340px;
}
.hud-event.ev-warn { border-color: rgba(230,207,143,0.5); animation: evpulse 2s ease-in-out infinite; }
@keyframes evpulse { 0%,100% { box-shadow: 0 0 0 rgba(230,207,143,0); } 50% { box-shadow: 0 0 22px rgba(230,207,143,0.25); } }
.hud-event-head { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; background: #b98fe8; box-shadow: 0 0 8px #b98fe8; animation: evdot 1.6s infinite; }
@keyframes evdot { 50% { opacity: 0.4; } }
.ev-label { font-family: var(--font-display); }
.ev-timer { margin-left: auto; color: var(--gold); font-variant-numeric: tabular-nums; font-family: var(--font-display); }
.ev-progress { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.09); margin-top: 8px; overflow: hidden; }
.ev-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7a3fd8, #b98fe8, #e6cf8f); transition: width 0.4s; }
.ev-tip { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }

/* world markers */
.wmarker {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-family: var(--font-display); font-size: 12px; color: #d8ccf4;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  transition: opacity 0.2s; will-change: transform;
}
.wmarker span { background: rgba(12,10,18,0.6); border-radius: 8px; padding: 2px 8px; backdrop-filter: blur(4px); }
.wmarker i { font-style: normal; font-size: 10.5px; color: var(--text-dim); }
.wmarker.m-cell { color: #f2dfa8; }
.wmarker.m-node { color: #c9b8f2; }
.wmarker.offscreen { opacity: 0.75; }

/* captions */
.hud-captions { position: absolute; bottom: 190px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; align-items: center; }
.caption { background: rgba(8,7,12,0.85); border-radius: 8px; padding: 4px 12px; font-size: 12.5px; color: var(--text-dim); }

/* ---------------- interaction prompt & hints ---------------- */
.hud-prompt {
  position: absolute; bottom: 148px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  background: rgba(12,10,18,0.8); backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 14px;
  animation: promptin 0.25s;
}
@keyframes promptin { from { opacity: 0; transform: translate(-50%, 6px); } }
.hud-prompt .pk, .kbd {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px;
  background: var(--grad); color: #16121e; border-radius: 7px;
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px; font-style: normal;
}
.hud-prompt .pt { font-size: 13.5px; }
.hud-hints { position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 5px; align-items: center; }
.hint { background: rgba(8,7,12,0.65); border-radius: 9px; padding: 4px 12px; font-size: 12px; color: var(--text-dim); transition: opacity 0.6s; }
.hint.fade { opacity: 0; }

/* ---------------- chat ---------------- */
.hud-chat {
  position: absolute; left: 14px; bottom: 14px; width: min(340px, calc(100vw - 120px));
  background: rgba(10,9,15,0.72); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  font-size: calc(13px * var(--chat-scale));
  transition: transform 0.25s, opacity 0.25s;
}
.hud-chat.collapsed .chat-log, .hud-chat.collapsed .chat-form { display: none; }
.hud-chat.collapsed { width: auto; background: transparent; border-color: transparent; backdrop-filter: none; }
.hud-chat.collapsed .chat-head { border-bottom: none; }
.hud-chat.collapsed .chat-tab { display: none; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.chat-tab { padding: 4px 12px; border-radius: 8px; color: var(--text-faint); font-family: var(--font-display); font-size: 12px; }
.chat-tab.active { background: rgba(143,123,216,0.2); color: var(--text); }
.chat-collapse { margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; color: var(--text-dim); border-radius: 8px; }
.chat-collapse:hover { background: var(--bg3); }
.chat-collapse svg { width: 16px; height: 16px; }
.hud-chat.collapsed .chat-collapse { background: rgba(12,10,18,0.72); border: 1px solid var(--line-strong); width: 40px; height: 40px; border-radius: 12px; }
.chat-unread { background: var(--danger); color: #fff; font-size: 10px; border-radius: 8px; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; }
.chat-log { max-height: 190px; min-height: 60px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.cmsg { line-height: 1.4; word-break: break-word; }
.cmsg .cname { color: #c4b4ee; font-weight: 600; font-family: var(--font-display); font-size: 0.95em; }
.cmsg .cname:hover { text-decoration: underline; }
.cmsg.self .cname { color: var(--gold); }
.cmsg.sys { color: var(--text-faint); font-size: 0.9em; font-style: italic; }
.bot-tag, .you-tag, .friend-tag {
  font-style: normal; font-size: 9px; letter-spacing: 0.08em; vertical-align: 2px;
  background: rgba(143,123,216,0.25); color: #c9b8f2; border-radius: 4px; padding: 1px 4px; margin-left: 4px;
  font-family: var(--font-display);
}
.you-tag { background: rgba(230,207,143,0.2); color: var(--gold); }
.friend-tag { background: rgba(127,216,160,0.16); color: var(--ok); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-input { flex: 1; background: rgba(255,255,255,0.06); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); padding: 7px 11px; font: inherit; min-width: 0; }
.chat-input:focus { outline: 2px solid var(--lav-deep); outline-offset: -1px; }

/* ---------------- right dock: voice + emotes ---------------- */
.hud-right-dock { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.voice-dock { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.voice-dock[data-state="on"] .voice-btn { color: var(--ok); border-color: rgba(127,216,160,0.5); }
.voice-dock.tx .voice-btn { box-shadow: 0 0 14px rgba(127,216,160,0.5); }
.voice-dock[data-state="denied"] .voice-btn { color: var(--danger); }
.voice-meter { width: 40px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.voice-meter i { display: block; height: 100%; width: 0; background: var(--ok); transition: width 0.08s; }
.emote-btn { width: 48px; height: 48px; border-radius: 14px; }

/* party chip */
.party-chip {
  position: absolute; top: 70px; left: 16px;
  display: flex; gap: 8px; align-items: center;
  background: rgba(12,10,18,0.72); border: 1px solid rgba(230,207,143,0.4);
  border-radius: 11px; padding: 6px 12px; font-size: 12.5px; font-family: var(--font-display);
}
.party-chip svg { width: 15px; height: 15px; color: var(--gold); }

/* ---------------- emote wheel ---------------- */
.emote-wheel {
  position: absolute; bottom: 90px; right: 76px;
  width: 210px; height: 210px;
}
.emote-slot {
  position: absolute; width: 92px; height: 44px;
  left: calc(50% + cos((var(--i) * 90deg) + 45deg) * 74px - 46px);
  top: calc(50% - sin((var(--i) * 90deg) + 45deg) * 74px - 22px);
  background: rgba(14,12,20,0.9); backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong); border-radius: 12px;
  font-family: var(--font-display); font-size: 12.5px;
  transition: border-color 0.15s, transform 0.15s;
}
.emote-slot:hover { border-color: var(--lav); transform: scale(1.06); }
.emote-slot.empty { opacity: 0.45; }
.ew-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 110px; text-align: center; font-size: 10.5px; color: var(--text-faint);
}

/* ---------------- player list ---------------- */
.playerlist {
  position: absolute; top: 66px; right: 14px; width: 270px; max-height: 60vh;
  background: rgba(10,9,15,0.85); backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
}
.playerlist header { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-family: var(--font-display); }
.pl-count { color: var(--text-faint); font-size: 12px; }
.pl-x { margin-left: auto; width: 28px; height: 28px; }
.pl-rows { overflow-y: auto; padding: 6px; }
.pl-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 9px; }
.pl-row:hover { background: rgba(255,255,255,0.05); }
.pl-name { font-size: 13.5px; }
.pl-row.me .pl-name { color: var(--gold); }
.pl-menu { width: 28px; height: 28px; font-size: 16px; }
.pl-note { padding: 8px 14px; color: var(--text-faint); font-size: 10.5px; border-top: 1px solid var(--line); }

/* player context menu */
.player-menu {
  position: fixed; z-index: 380; min-width: 200px;
  background: rgba(14,12,20,0.96); backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  animation: promptin 0.15s;
}
.player-menu header { padding: 11px 14px; border-bottom: 1px solid var(--line); font-family: var(--font-display); font-size: 13.5px; }
.player-menu button {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 9px 14px; font-size: 13px; color: var(--text-dim);
}
.player-menu button:hover { background: rgba(143,123,216,0.14); color: var(--text); }
.player-menu button.danger:hover { background: rgba(232,106,122,0.14); color: var(--danger); }
.player-menu button svg { width: 16px; height: 16px; }

/* ---------------- esc menu / overlays ---------------- */
.esc-menu { display: flex; flex-direction: column; gap: 10px; min-width: 240px; }
.esc-menu .btn { width: 100%; justify-content: center; padding: 12px; }
.ingame-settings { max-height: 60vh; overflow-y: auto; }
.ingame-overlay-body { min-height: 200px; }
.help-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; }
.help-panel h4 { font-size: 13px; color: var(--gold); margin: 12px 0 4px; letter-spacing: 0.06em; }
.help-panel p { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; }
.board-panel h4 { margin-bottom: 10px; }
.board-panel ul { margin-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--text-dim); font-size: 14px; }
.board-panel em { color: var(--gold); font-style: normal; }
.mini-profile p { color: var(--text-dim); font-size: 14px; }

/* perf */
.hud-perf {
  position: absolute; top: 66px; left: 16px;
  background: rgba(8,7,12,0.7); border-radius: 8px; padding: 4px 10px;
  font-size: 11px; color: var(--ok); font-variant-numeric: tabular-nums; font-family: var(--font-display);
}

/* ---------------- mobile controls ---------------- */
.mobile-controls { position: absolute; inset: 0; pointer-events: none; }
.joystick {
  position: absolute; left: 20px; bottom: 90px;
  width: calc(120px * var(--touch-scale, 1)); height: calc(120px * var(--touch-scale, 1));
  border-radius: 50%; border: 1.5px solid var(--line-strong);
  background: rgba(255,255,255,0.04); pointer-events: auto; touch-action: none;
}
.stick {
  position: absolute; left: 50%; top: 50%; margin: -26px 0 0 -26px;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(200,180,228,0.35); border: 1.5px solid var(--lav);
}
.mbtns { position: absolute; right: 18px; bottom: 100px; display: flex; flex-direction: column; gap: 12px; pointer-events: auto; }
.mbtn {
  width: calc(60px * var(--touch-scale, 1)); height: calc(60px * var(--touch-scale, 1));
  border-radius: 50%; background: rgba(12,10,18,0.72); border: 1.5px solid var(--line-strong);
  font-size: 22px; color: var(--text);
}
.mbtn:active { background: rgba(143,123,216,0.3); }
.look-area { position: absolute; right: 0; top: 15%; bottom: 30%; width: 55%; pointer-events: auto; touch-action: none; }
.is-mobile .hud-chat { bottom: 210px; max-width: 260px; }
.is-mobile .hud-right-dock { bottom: 230px; }

@media (max-width: 720px) {
  .hud-event { min-width: 0; max-width: 240px; font-size: 12px; }
  .playerlist { width: min(270px, 84vw); }
}
