/* Space Grotesk (variable wght 300–700, OFL — license alongside the file) is both
   the display and UI face; the stack below it is the no-font fallback. */
@font-face {
  font-family: 'Space Grotesk';
  src: url('/assets/fonts/space-grotesk-vf.woff2') format('woff2-variations');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Design tokens — modern glass + glow over the dark + molten-amber identity.
     DOM chrome only; the in-game world (canvas) reads its palette from config.js. */

  /* surfaces */
  --bg-0: #0b0c10; /* page bg behind canvas / first paint */
  --bg-1: #12141a;
  --glass-1: rgba(16, 18, 24, 0.55);
  --glass-2: rgba(18, 20, 27, 0.72);
  --glass-3: rgba(21, 23, 31, 0.88);
  --stroke-1: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.16);
  --stroke-accent: rgba(255, 138, 31, 0.45);
  --glass-hilite: inset 0 1px 0 rgba(255, 255, 255, 0.07);

  /* ink */
  --ink: #f2f5f8;
  --ink-dim: #a8b2c2;
  --ink-faint: #6b7484;

  /* brand */
  --accent: #ff8a1f;
  --accent-hi: #ffb347;
  --accent-deep: #b85600;
  --accent-08: rgba(255, 138, 31, 0.08);
  --accent-16: rgba(255, 138, 31, 0.16);
  --accent-32: rgba(255, 138, 31, 0.32);
  --glow-accent: 0 0 18px rgba(255, 138, 31, 0.35);
  --glow-accent-lg: 0 0 42px rgba(255, 138, 31, 0.45);

  /* functional */
  --info: #5b9cff;
  --info-hi: #9bd1ff;
  --gold: #ffd23f;
  --danger: #ff5b5b;
  --danger-hi: #ff8a5b;
  --success: #5fe06a;
  --success-soft: #b6f4c2;
  --danger-glow: 0 0 16px rgba(255, 91, 91, 0.4);
  --success-glow: 0 0 16px rgba(95, 224, 106, 0.35);
  --discord: #5865f2;
  --discord-hi: #7984f5;
  --discord-deep: #3b45c4;

  /* chat channel tints */
  --chan-global: #8fe3ff;
  --chan-local: #cfd8e3;
  --chan-party: #7fffb0;
  --chan-guild: #ff9f6b;
  --chan-whisper: #c79bff;
  --chan-system: #ffd23f;

  /* elevation */
  --elev-1: 0 4px 14px rgba(0, 0, 0, 0.35);
  --elev-2: 0 12px 32px rgba(0, 0, 0, 0.4);
  --elev-3: 0 24px 60px rgba(0, 0, 0, 0.5);
  --blur-1: 6px;
  --blur-2: 12px;
  --blur-3: 20px;

  /* radius */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  /* spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* type */
  --font-display: 'Space Grotesk', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --font-ui: 'Space Grotesk', ui-rounded, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 24px;
  --fs-hero: clamp(48px, 9vw, 100px);

  /* motion */
  --t-fast: 120ms;
  --t-med: 200ms;
  --t-slow: 320ms;
  --t-enter: 260ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);

  /* hero backdrop (start / dev / death overlays) */
  --bg-hero: radial-gradient(120% 120% at 50% 30%, #1d2230, #14161c 55%, #0d0e12);

  /* canvas world (read by render.js via getCss — not chrome styling) */
  --grid: rgba(255, 138, 31, 0.08); /* pre-map fallback field grid lines */
  --border: #3a3f4a; /* world boundary stroke */

  --btn-ink: #2a1500; /* dark text on bright amber buttons */
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
canvas {
  display: block;
  position: fixed;
  inset: 0;
}

/* Keyboard focus is always visible; pointer focus stays quiet. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
button,
a,
input,
select {
  outline: none;
}

/* ---- dev-build disclaimer (sits above the start overlay) ---- */
#devModal {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hero);
}
/* Discord link in the dev gate — secondary button, blurple so it reads as
   a distinct link rather than the primary "I understand" CTA. */
#devDiscord {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  text-align: center;
  text-decoration: none;
  padding: 12px;
  border-radius: var(--r-md);
  color: var(--ink);
  background: linear-gradient(180deg, var(--discord-hi), var(--discord));
  box-shadow: var(--elev-1), var(--glass-hilite);
  transition:
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}
#devDiscord:hover {
  transform: translateY(-1px);
  box-shadow:
    var(--elev-1),
    0 0 18px rgba(88, 101, 242, 0.45);
}
#devDiscord:active {
  transform: scale(0.97);
}
/* Dev-age caption + roadmap. The Roadmap button is a NEUTRAL glass secondary — it
   overrides the accent `.card button` gradient so it doesn't compete with the primary
   "I understand" CTA. The panel reuses the .devWarn glass look. */
.devAge {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
}
#devRoadmapBtn {
  font-size: 17px;
  color: var(--ink);
  background: var(--glass-2);
  border: 1px solid var(--stroke-2);
  box-shadow: var(--elev-1), var(--glass-hilite);
}
#devRoadmapBtn:hover {
  box-shadow: var(--elev-1), var(--glass-hilite);
}
#devRoadmap {
  border: 1px solid var(--stroke-2);
  background: var(--glass-2);
  border-radius: var(--r-md);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.devRoadmapDay {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
}
.devRoadmapList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.devRoadmapList li[data-status='done'] {
  color: var(--ink-faint);
}
.devRoadmapList li[data-status='ongoing'] {
  color: var(--gold);
  font-weight: 700;
}

/* ---- start overlay ---- */
#start {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg-hero);
}
#start::before {
  /* Ambient accent glow behind the logo — pure decoration. */
  content: '';
  position: absolute;
  top: 12%;
  left: 50%;
  width: min(720px, 90vw);
  height: 340px;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, var(--accent-16), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
#start h1 {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -3px;
  color: var(--ink);
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
}
#start h1 span {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 22px var(--accent-32));
}
#start p {
  margin: 0;
  color: var(--ink-dim);
  opacity: 0.9;
  font-weight: 600;
}
.card {
  position: relative;
  background: var(--glass-3);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-xl);
  padding: var(--sp-4) var(--sp-4) 20px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: min(360px, 90vw);
  backdrop-filter: blur(var(--blur-2)) saturate(1.3);
  box-shadow: var(--elev-3), var(--glass-hilite);
}
.card input {
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--stroke-1);
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease-out);
}
.card input::placeholder {
  color: var(--ink-faint);
}
.card input:focus {
  border-color: var(--accent);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.25),
    0 0 0 3px var(--accent-16);
}
.card button {
  font: inherit;
  font-weight: 700;
  font-size: 19px;
  padding: 13px;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--btn-ink);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: var(--elev-1), var(--glass-hilite);
  transition:
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}
.card button:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-1), var(--glow-accent);
}
.card button:active {
  transform: scale(0.97);
  box-shadow: var(--elev-1);
}
.hint {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.5;
}
#googleBtn {
  display: flex;
  justify-content: center;
}
.orSep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.orSep::before,
.orSep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--stroke-1);
}
.hint b {
  color: var(--ink);
}

/* ---- in-game HUD ---- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.panel {
  position: absolute;
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-lg);
  padding: 10px 13px;
  backdrop-filter: blur(var(--blur-2)) saturate(1.3);
  box-shadow: var(--elev-1), var(--glass-hilite);
}
/* Top-left cluster: the player frame + the End Run button beside it. The
   wrapper is anchored where #stats used to be and lays them out in a row, so
   the button hugs the panel's real width instead of a magic pixel offset. */
#hudTopLeft {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
#stats {
  position: static;
  min-width: 220px;
}
#stats .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
#stats .name {
  font-weight: 800;
  font-size: 16px;
}
#stats .lvl {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--r-full);
  background: rgba(255, 210, 63, 0.12);
  border: 1px solid rgba(255, 210, 63, 0.25);
}
/* "End Run" button — a flex sibling of #stats inside #hudTopLeft, so it sits
   beside the panel's actual right edge (no magic offset that overlaps when the
   panel grows). The HUD is pointer-events:none, so the button opts back in. A
   two-click confirm flips data-confirming (wired in main.js). */
#endRun {
  flex: none;
  pointer-events: auto;
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-md);
  padding: 9px 14px;
  color: var(--ink-dim);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(var(--blur-1));
  transition:
    color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}
#endRun:hover {
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: var(--danger-glow);
}
#endRun[data-confirming='1'] {
  background: rgba(255, 91, 91, 0.85);
  border-color: var(--danger);
  color: var(--ink);
  box-shadow: var(--danger-glow);
}
/* Mid-session sign-in: the HUD is pointer-events:none, so the block (and the
   Google button inside it) must opt back in to be clickable. */
#hudSignin {
  margin-top: 9px;
  pointer-events: auto;
}
#hudSignin .hint {
  font-size: 11px;
  margin-bottom: 6px;
}
#hudGoogleBtn {
  display: flex;
}
/* Logout button: the HUD is pointer-events:none, so it must opt back in. Shown
   only for signed-in players (toggled in net.js). */
#logoutBtn {
  margin-top: 9px;
  pointer-events: auto;
  font: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--stroke-2);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink-dim);
  cursor: pointer;
  transition:
    color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out);
}
#logoutBtn:hover {
  background: rgba(0, 0, 0, 0.55);
  color: var(--ink);
}
#logoutBtn.hidden {
  display: none;
}
.bar {
  height: 12px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  margin-top: 7px;
  position: relative;
}
.bar > i {
  border-radius: var(--r-full);
  position: relative;
  overflow: hidden;
}
/* Damage-lag trail: the ghost sits behind the fill with the same width but a
   slower, delayed transition — on damage the fill snaps down and the pale
   ghost lingers, then drains. On heal it hides under the fill entirely. */
#hpGhost {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: rgba(255, 138, 91, 0.45);
  transition: width 0.55s var(--ease-out) 0.28s !important;
}
#hpFill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
}
/* Red rim flash on the stats panel while HP is dropping (hud.js toggles it). */
#stats.hurt {
  border-color: var(--danger);
  box-shadow: var(--danger-glow), var(--glass-hilite);
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.12s linear;
}
.bar .label {
  position: absolute;
  inset: 0;
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}
#hpFill {
  background: linear-gradient(90deg, var(--danger-hi), var(--danger));
}
#xpFill {
  background: linear-gradient(90deg, var(--gold), var(--accent));
}

/* Diamonds readout in the top HUD (#stats). A soft currency, not an item. */
.diamonds {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 13px;
  font-weight: 800;
  color: #d9f4ff;
}
.diamonds .diaIcon {
  color: #6fd3ff;
  text-shadow: 0 0 8px rgba(111, 211, 255, 0.6);
  font-size: 14px;
}

/* Quests panel rows (menus.js renderQuests). */
.quest {
  padding: 9px 11px;
  margin: 8px 0;
  border-radius: var(--r-md, 10px);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
}
.quest.ready {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-16) inset;
}
.quest.claimed {
  opacity: 0.55;
}
.questHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.questLabel {
  font-weight: 700;
  font-size: 13px;
}
.questBar {
  height: 8px;
  margin-top: 8px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.questBar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, #6fd3ff, var(--accent));
  transition: width 0.2s linear;
}
.questProg {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted, #9aa0a6);
  text-align: right;
}
.questReward,
.questDone {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.questReward {
  color: #6fd3ff;
}
.questDone {
  color: var(--muted, #9aa0a6);
}

/* Diamond Shop — a stock grid of gear rows; reuses the .chip.icon + .btn tokens. */
.shopGrid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.shopItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--r-md, 10px);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));
}
.shopItem.poor {
  opacity: 0.6;
}
.shopMeta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.shopName {
  font-weight: 700;
  font-size: 13px;
}
.shopSale {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #06210f;
  background: #4ade80;
  vertical-align: middle;
}
.shopWas {
  opacity: 0.6;
  font-weight: 500;
  margin-right: 3px;
}

#players {
  right: 14px;
  top: 14px;
  min-width: 150px;
  font-size: 13px;
}
#players h4 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
#players .pl {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}
#players .pl b {
  color: var(--gold);
}

/* Top-center active-perks strip — one small icon per equipped trinket (grouped
   by type + quality), filled by hud.js renderActiveBuffs from
   state.character.buffs. The .buff tile + .buffRow container are shared with the
   Character menu panel. The strip itself ignores the mouse so it never blocks the
   canvas, but each tile re-enables pointer events so its hover tooltip works. */
#buffStrip {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 56vw;
  pointer-events: none;
}
.buffRow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.buff {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 2px solid var(--stroke-2);
  background: var(--glass-2);
  backdrop-filter: blur(var(--blur-1));
  box-shadow: var(--elev-1), var(--glass-hilite);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  transition: transform var(--t-fast) var(--ease-out);
}
.buff:hover {
  transform: translateY(-2px);
}
.buff img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
.buff .amt {
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 15px;
  padding: 0 3px;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  color: #fff;
  background: rgba(20, 20, 24, 0.92);
  border-radius: 8px;
}

/* Persistent party panel on the LEFT (below the #stats panel). Display-only,
   driven by you.party; shows one row per member with level + a healthbar. */
#partyHud {
  left: 14px;
  top: 175px;
  min-width: 168px;
  font-size: 13px;
}
#partyHud h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-dim);
}
#partyHud .pm {
  padding: 5px 0;
}
#partyHud .pm + .pm {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
#partyHud .pmTop {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
#partyHud .pmName {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 116px;
}
#partyHud .pmName.me {
  color: var(--gold);
}
#partyHud .pmLvl {
  color: var(--gold);
  font-weight: 700;
  flex: none;
}
#partyHud .pmBar {
  height: 9px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  position: relative;
}
#partyHud .pmBar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--danger-hi), var(--danger));
  transition: width 0.12s linear;
}
#partyHud .pm.dead .pmName {
  color: var(--ink-dim);
}
#partyHud .pm.dead .pmBar > i {
  background: var(--ink-faint);
}

/* Bottom equipment-loadout bar: a compact DECK of the saved sets, the active one
   full-size in front and the inactive ones fanned/dimmed behind it — each peeking
   out a little further at the bottom. The rows are absolutely stacked (one place),
   positioned by their deck --depth (0=front) so a switch just re-drives --depth and
   the transform/opacity transition rotates the deck (see hud.applyLoadoutDepths). */
#loadoutBar {
  --maxd: 0; /* deepest depth (count-1), set by hud.applyLoadoutDepths */
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 21; /* above the HUD (20), below the menu overlay (28) */
  height: 150px; /* front card sits raised by maxd·peek; deeper cards fill down to here */
  pointer-events: auto;
}
/* While the Inventory panel is open the bar floats above the menu overlay so
   bag items can be dragged down onto its cells to equip. */
#loadoutBar.lifted {
  z-index: 29;
}
.loadoutRow {
  --depth: 0;
  --peek: 26px; /* how far each deeper card sinks below the one in front */
  position: absolute;
  left: 50%;
  bottom: 0;
  transform-origin: bottom center;
  /* The deck grows UP from the baseline: the deepest card (depth = --maxd) rests at
     the container bottom, the front card is raised by maxd·peek, so every card's lower
     edge peeks out below the one in front of it — and none clip off the screen bottom. */
  transform: translateX(-50%) translateY(calc((var(--depth) - var(--maxd)) * var(--peek)))
    scale(calc(1 - var(--depth) * 0.06));
  opacity: calc(1 - var(--depth) * 0.28);
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-lg);
  padding: 10px 22px;
  cursor: pointer;
  backdrop-filter: blur(var(--blur-1));
  transition:
    opacity var(--t-med) var(--ease-out),
    transform var(--t-med) var(--ease-out);
}
.loadoutRow.active {
  /* The border shows the set's average quality (inline style), so the
     active set is marked by a brighter glass + accent glow instead. */
  background: var(--glass-3);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.18),
    var(--glow-accent),
    var(--elev-1);
}
.loadoutRow.inactive:hover {
  opacity: 0.9;
}
.loadoutNum {
  font-weight: 800;
  font-size: 26px;
  color: var(--gold);
  width: 33px;
  text-align: center;
}
.loadoutRow.inactive .loadoutNum {
  color: var(--ink-dim);
}
/* Keycap hint — present on every card but shown only on the next-to-equip (depth-1)
   one, since pressing R always promotes the card sitting right behind the active.
   Pulled OUT of the flex flow and floated just outside the card's left edge (the deck
   overflow is visible, so a child at right:100% renders outside the box) — sat at the
   peeking bottom rather than centered, so on the depth-1 card it shows beside the
   peeking deck instead of hiding behind the raised front card. It still rides the row's
   depth transform/opacity, keeping it visually tied to the card it promotes. */
.loadoutKey {
  position: absolute;
  right: calc(100% + 10px); /* just OUTSIDE the card's left edge */
  bottom: 6px; /* down by the peek, not vertically centered */
  visibility: hidden;
  font-weight: 800;
  font-size: 22px;
  color: #000;
  line-height: 1;
  padding: 5px 9px;
  border: 1px solid var(--gold);
  border-radius: var(--r-xs);
  background: var(--gold);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.loadoutRow[data-depth='1'] .loadoutKey {
  visibility: visible;
}
.loadoutSlots {
  display: flex;
  gap: 10px;
}
.loadoutCell {
  position: relative;
  width: 60px;
  height: 60px;
  border: 2px solid var(--stroke-1);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.loadoutCell.empty {
  opacity: 0.4;
}
.loadoutCell[draggable='true'] {
  cursor: grab;
}
.loadoutCell.dragover {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent) inset,
    var(--glow-accent);
  opacity: 1;
}
.loadoutCell img {
  width: 48px;
  height: 48px;
}
/* gem marker on a loadout cell whose item has a card socketed */
.loadoutGem {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 10px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Items panel: armor paperdoll beside the inventory bag. Wraps (armor stacks above
   the bag) on narrow/mobile widths; the bag column shrinks/scrolls, armor stays fixed. */
.itemsLayout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
.armorCol {
  flex: 0 0 auto;
  min-width: 168px; /* fits the paperdoll + gives the stacked sockets room to wrap */
}
.bagCol {
  flex: 1 1 220px;
  min-width: 0;
}
/* Craft mode: the Known-recipes list sits in its own column to the right of the
   bench + bag, filling the remaining width and wrapping below on narrow screens
   (.itemsLayout is flex-wrap: wrap). Its inner .recipeList caps height + scrolls. */
.recipeCol {
  flex: 1 1 220px;
  min-width: 200px;
}

/* Armor paperdoll: a centred 3-column body layout. */
.armorDoll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 6px 0 10px;
}
.armorRow {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.armorCell {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid var(--stroke-1);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.armorCell.gap {
  border-color: transparent;
  background: transparent;
}
.armorCell.empty {
  opacity: 0.55;
}
.armorCell[data-act='unequipArmor'] {
  cursor: pointer;
}
.armorCell.dragover {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent) inset,
    var(--glow-accent);
  opacity: 1;
}
.armorCell img {
  width: 42px;
  height: 42px;
}
.armorLabel {
  font-size: 9px;
  line-height: 1.1;
  color: var(--ink-dim);
  pointer-events: none;
}

#mini {
  right: 14px;
  bottom: 14px;
  padding: 0;
  overflow: hidden;
  line-height: 0;
}
#mini canvas {
  position: static;
  border-radius: calc(var(--r-lg) - 1px);
}
/* Fullscreen minimap mode (M): centre the map as a dimmed pop-up overlay
   instead of the bottom-right corner. The huge spread box-shadow dims the
   whole screen behind it (robust under the element's own overflow:hidden,
   unlike a fixed-position ::before, which the .fullscreen transform would
   turn into a clipped containing block). The canvas size is driven by JS. */
#mini.fullscreen {
  right: auto;
  bottom: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
}

#dead {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background: radial-gradient(
    120% 120% at 50% 45%,
    rgba(28, 12, 14, 0.55),
    rgba(16, 6, 8, 0.78) 75%,
    rgba(8, 3, 4, 0.9)
  );
  backdrop-filter: blur(var(--blur-1));
}
#dead h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #ffdede;
  text-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 34px rgba(255, 91, 91, 0.35);
}
#dead p {
  margin: 0;
  color: var(--ink-dim);
}
#dead .card {
  margin-top: 6px;
}
#dead .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
#dead .respawnBtns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* death recap: a small label/value grid summarising the life that ended */
.deathStats {
  margin: 4px 0 10px;
  text-align: left;
}
.deathStats .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.deathStats .row:last-child {
  border-bottom: none;
}
.deathStats .row .k {
  color: var(--ink-dim);
}
.deathStats .row .v {
  color: var(--ink);
  font-weight: 700;
}
/* recap image grids: one quality-bordered tile per looted item / slain mob */
.deathStats .recapSection {
  margin-top: 10px;
}
.deathStats .recapSection h4 {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}
.deathStats .recapGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.deathStats .recapTile {
  position: relative;
  width: 40px;
  height: 40px;
  border: 2px solid var(--ink-faint);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.deathStats .recapTile img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.deathStats .recapTile .amt {
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 15px;
  padding: 0 3px;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  color: #fff;
  background: rgba(20, 20, 24, 0.92);
  border-radius: 8px;
}

/* shared dev-build disclaimer (start gate + death overlay) */
.devWarn {
  border: 1px solid rgba(255, 210, 63, 0.5);
  background: rgba(120, 80, 0, 0.25);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}
.devWarn b {
  color: var(--gold);
}

#stats .sp {
  font-size: 12px;
  font-weight: 800;
  color: var(--btn-ink);
  background: var(--gold);
  border-radius: var(--r-full);
  padding: 1px 8px;
  margin-right: 8px;
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.45);
}

/* ---- menu (inventory / craft / upgrade / skills) ---- */
#menu {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.55);
  backdrop-filter: blur(var(--blur-1));
}
.menuCard {
  width: min(920px, 95vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--glass-3);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-xl);
  padding: 14px 16px 18px;
  box-shadow: var(--elev-3), var(--glass-hilite);
  backdrop-filter: blur(var(--blur-3)) saturate(1.3);
}
.menuTabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.menuTabs .spacer {
  flex: 1;
}
.menuTabs button {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 7px 14px;
  cursor: pointer;
  transition:
    color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}
.menuTabs button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}
.menuTabs button.active {
  color: var(--btn-ink);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: var(--glow-accent);
}
#menuClose {
  color: var(--ink);
}
#menuBody h3 {
  margin: 14px 0 8px;
  font-size: 15px;
}
#menuBody h3:first-child {
  margin-top: 2px;
}
.muted {
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 600;
}
.slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.slot {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  border: 2px solid var(--stroke-1);
  background: rgba(0, 0, 0, 0.28);
  box-shadow: var(--glass-hilite);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out);
}
.slot:not(.empty):hover {
  transform: translateY(-2px);
}
.slot.empty {
  color: var(--ink-dim);
  font-size: 20px;
  cursor: default;
  opacity: 0.6;
}
.slot img.g {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.slot.dragover {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.12);
}
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 2px solid var(--stroke-1);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: var(--glass-hilite);
  font-size: 13px;
  font-weight: 700;
  transition:
    transform var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out);
}
.chip.equipable {
  cursor: grab;
}
.chip.equipable:active {
  cursor: grabbing;
}
.chip.equipable:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}
.chip .g {
  font-size: 17px;
}
.chip img.g {
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.chip .ct {
  color: var(--ink-dim);
}
.craftRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-wrap: wrap;
}
.craftIO {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* The "Known recipes" list in the Craft panel. Craftable rows (.addable) are clickable
   to auto-fill the bench; un-craftable rows (.off) are greyed (reason on hover title).
   Each row is one compact line: ingredient icons (.ri, with ×N) → output name (.ro). */
.recipeList {
  display: flex;
  flex-direction: column;
  /* Extend downward as recipes are learned, then scroll internally so the list's
     own column takes the growth instead of stretching the whole modal card. */
  max-height: 60vh;
  overflow-y: auto;
}
.recipeRow {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 7px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--r-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recipeRow .ri {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.recipeRow .ri img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}
.recipeRow .ri .ct {
  color: var(--ink-dim);
}
.recipeRow .arrow {
  color: var(--ink-dim);
  font-weight: 800;
}
.recipeRow .ro {
  font-weight: 800;
  color: var(--ink);
}
.recipeRow.addable {
  cursor: pointer;
}
.recipeRow.addable:hover {
  background: rgba(255, 255, 255, 0.08);
}
.recipeRow.addable:active {
  transform: scale(0.99);
}
.recipeRow.off {
  opacity: 0.5;
}
.partyRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.partyRow .partyName {
  font-weight: 600;
}
.partyRow .partyDo {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.partyPrefs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.partyPrefs label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
/* --- admin panel --- */
.adminRow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}
.adminRow select,
.adminRow input {
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--stroke-1);
  border-radius: 8px;
  padding: 6px 8px;
}
.adminRow input[type='number'] {
  width: 72px;
}
#adminSearch {
  flex: 1 1 160px;
  min-width: 120px;
}
/* Offline players in the admin Players roster read dimmer than online ones. */
.playerRow.offline .partyName {
  opacity: 0.72;
}
/* Admin Inventory tab: a labelled cell (armor part / station) and a loadout-set row. */
.holdingCell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
}
.holdingSet {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0;
}
/* --- dashboard panel --- */
.dashGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 6px 0 4px;
}
.dashStat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  box-shadow: var(--glass-hilite);
}
.dashLabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}
.dashValue {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}
/* --- compendium sub-tab (mob XP / drop rates / level XP) --- */
.compTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 4px 0 12px;
}
.compTable th,
.compTable td {
  text-align: left;
  vertical-align: top;
  padding: 4px 6px;
  border-bottom: 1px solid var(--stroke-1);
}
.compTable th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  position: sticky;
  top: 0;
  background: var(--glass-3);
}
.compTable td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.compTable.levels {
  display: block;
  max-height: 240px;
  overflow: auto;
}
.compTable.matrix {
  display: block;
  overflow-x: auto;
  margin: 4px 0 10px;
}
.compTable.matrix td,
.compTable.matrix th {
  white-space: nowrap;
}
.compMobBody h4 {
  margin: 10px 0 2px;
  font-size: 12px;
}
.compMobBody h4.cardDrop {
  color: var(--gold);
}
.compPicker {
  margin: 6px 0 8px;
  font-size: 12px;
  color: var(--ink-dim);
}
.compSelect {
  margin-left: 4px;
  padding: 3px 6px;
  background: var(--glass-2);
  color: var(--ink);
  border: 1px solid var(--stroke-1);
  border-radius: 6px;
  font: inherit;
}
/* Clickable recipe item chip in the admin Items sub-tab (re-selects the item). */
.compPick {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--stroke-1);
  border-radius: 6px;
  cursor: pointer;
}
.compPick:hover {
  border-color: var(--ink-dim);
}
.compPick .g {
  width: 16px;
  height: 16px;
}
.compLevelHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.compLevelHead h3 {
  margin: 0;
}
.compLevelNav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.compLevelNav button[disabled] {
  opacity: 0.4;
  cursor: default;
}
/* --- census sub-tab (items in circulation) --- */
.compTable.census {
  display: block;
  max-height: 360px;
  overflow: auto;
}
/* Economy-audit history (admin Audit tab): a scrollable, newest-first event log. */
.compTable.audit {
  display: block;
  max-height: 360px;
  overflow: auto;
}
.compTable.audit td {
  white-space: nowrap;
}
.compTable.census .censusRow {
  cursor: pointer;
}
.compTable.census th {
  cursor: pointer;
  user-select: none;
}
.compTable.census th:hover {
  color: #fff;
}
.compTable.census th .sortCaret {
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.8;
}
.compTable.census .censusRow:hover {
  background: rgba(255, 255, 255, 0.05);
}
.censusIcon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.censusOwners td {
  background: rgba(255, 255, 255, 0.03);
}
.censusOwnerList {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.censusOwner {
  font-size: 11px;
}
.censusOwner.off {
  color: var(--ink-dim);
}
.censusOwner em {
  font-style: normal;
  color: var(--ink-dim);
}
/* --- guild panel --- */
.guildBar {
  height: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin: 6px 0;
}
.guildBarFill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}
.guildPolicy {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.guildCreate {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.guildCreate input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--stroke-1);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}
.guildRole {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.guildDanger {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 80, 80, 0.25);
}
.gtGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.gtCol {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gtHead {
  font-weight: 700;
  font-size: 13px;
  opacity: 0.9;
}
.gtNode {
  border: 1px solid var(--stroke-1);
  border-radius: 8px;
  padding: 7px 8px;
  background: rgba(255, 255, 255, 0.03);
}
.gtNode.owned {
  border-color: var(--accent);
  background: var(--accent-08);
  box-shadow: 0 0 10px var(--accent-16);
}
.gtNode.locked {
  opacity: 0.5;
}
.gtName {
  font-weight: 600;
  font-size: 12px;
}
.gtDesc {
  font-size: 11px;
  margin: 2px 0 5px;
}
.craftIO .arrow {
  color: var(--ink-dim);
  font-weight: 800;
}
.craftIO .nm {
  font-weight: 800;
  font-size: 13px;
}
.craftDo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qsel {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  border: 1px solid var(--stroke-1);
}
.btn {
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  color: var(--btn-ink);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border: none;
  border-radius: var(--r-sm);
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: var(--glass-hilite);
  transition:
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out),
    filter var(--t-fast) var(--ease-out);
}
.btn.off {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink-dim);
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn:not(:disabled):hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: var(--glow-accent);
}
.btn.off:not(:disabled):hover {
  box-shadow: none;
}
.btn:not(:disabled):active {
  transform: scale(0.96);
  box-shadow: none;
}
.btn.off:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.22);
  color: var(--ink);
}
.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* icon-only inventory cell: artwork centred, count badge in the corner */
.chip.icon {
  position: relative;
  width: 48px;
  height: 48px;
  padding: 0;
  justify-content: center;
}
.chip.icon img.g {
  width: 32px;
  height: 32px;
}
.ct.badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  padding: 1px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
/* Admin inventory-viewer delete affordance: a corner × on each holdings chip. */
.chip .del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: var(--danger, #c0392b);
  cursor: pointer;
  opacity: 0.85;
}
.chip .del:hover {
  opacity: 1;
  transform: scale(1.1);
}
/* mob-card sockets: a row per equipped item that has sockets, with a cell per
   socket (drag a matching card on, click a filled one off) */
.socketSection {
  margin: 8px 0 4px;
}
.socketGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
/* One equipped item: its icon on top, its socket cells stacked directly below it. */
.socketTile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}
.socketCells {
  display: flex;
  gap: 6px;
}
.socketCell {
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
}
.socketCell.filled {
  border-style: solid;
  cursor: grab;
}
.socketCell.filled:active {
  cursor: grabbing;
}
.socketCell img {
  width: 26px;
  height: 26px;
}
.socketCell.dragover {
  border-color: var(--accent);
  background: rgba(95, 224, 106, 0.16);
}
/* An empty socket a card in hand can go into — cued the moment its drag starts. */
.socketCell.eligible {
  border-color: var(--accent);
  border-style: dashed;
  background: rgba(95, 224, 106, 0.1);
  animation: fc-socket-pulse 1.1s ease-in-out infinite;
}
@keyframes fc-socket-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(95, 224, 106, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(95, 224, 106, 0.28);
  }
}
/* The socket under the cursor + the bag cards that fit it (hover cue, both ways). */
.socketCell.sockethot {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent) inset,
    var(--glow-accent);
}
.chip.cardmatch {
  border-color: var(--accent) !important;
  box-shadow: var(--glow-accent);
}
/* --- station tool slots (beside the craft bench) ------------------------------ */
.toolCol {
  flex: 0 0 auto;
}
.toolSlots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  max-width: 132px;
}
.toolCell {
  position: relative;
  width: 46px;
  height: 46px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
}
.toolCell:not(.empty) {
  border-style: solid;
  cursor: pointer;
}
.toolCell.empty {
  color: var(--muted);
  font-size: 20px;
}
.toolCell img {
  width: 36px;
  height: 36px;
}
.toolCell.dragover {
  border-color: var(--accent);
  background: rgba(95, 224, 106, 0.16);
}
/* An empty tool slot a tool in hand can go into — cued the moment its drag starts. */
.toolCell.eligible {
  border-color: var(--accent);
  border-style: dashed;
  background: rgba(95, 224, 106, 0.1);
  animation: fc-socket-pulse 1.1s ease-in-out infinite;
}
/* The tool slot under the cursor + the bag tools that fit it (hover cue, both ways). */
.toolCell.toolhot {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent) inset,
    var(--glow-accent);
}
.chip.toolmatch {
  border-color: var(--accent) !important;
  box-shadow: var(--glow-accent);
}
/* the rolled output-quality odds under a craft result */
.craftOdds {
  margin-top: 4px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
}
/* quality section header in the grouped inventory */
.qHead {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--qc, var(--ink-dim));
  display: flex;
  align-items: center;
  gap: 8px;
}
.qHead::after {
  content: '';
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: var(--qc, var(--stroke-1));
  opacity: 0.45;
}
.invWrap:first-child .qHead,
.invWrap > .qHead:first-child {
  margin-top: 2px;
}

/* dragging an equipped item out onto the bag unequips it */
.invWrap {
  border-radius: 11px;
  transition: background 0.08s;
  min-height: 40px;
  max-height: 46vh; /* scroll internally so the bag stays clear of the bottom loadout bar */
  overflow-y: auto;
}
.invWrap.dragover {
  background: rgba(255, 210, 63, 0.12);
  outline: 2px dashed var(--gold);
  outline-offset: 2px;
}

/* ---- Items panel mode toggle (Craft / Upgrade) ---- */
.modeToggle {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}
.modeToggle .btn {
  flex: 1;
  text-align: center;
}

/* ---- crafting bench (staging area above the inventory) ---- */
.benchRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bench {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r-md);
  border: 2px dashed var(--stroke-2);
  background: rgba(0, 0, 0, 0.2);
  transition:
    background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
  min-height: 64px;
}
.bench.dragover {
  border-color: var(--gold);
  background: rgba(255, 210, 63, 0.12);
  box-shadow: 0 0 14px rgba(255, 210, 63, 0.25);
}
/* addable inventory/bench cells behave like equippable ones (grab + hover);
   dimmed cells are inert and visibly out of play (filter feedback). */
.chip.addable {
  cursor: grab;
}
.chip.addable:active {
  cursor: grabbing;
}
.chip.addable:hover {
  background: rgba(255, 255, 255, 0.08);
}
.craftOut {
  justify-content: flex-start;
  gap: 14px;
  border-top: none;
  padding-top: 4px;
}

/* floating item tooltip (name + stats), positioned at the cursor */
#itemTip {
  position: fixed;
  z-index: 36;
  pointer-events: none;
  max-width: 220px;
  background: var(--glass-3);
  border: 1px solid var(--stroke-1);
  border-top: 2px solid var(--qc, var(--stroke-2));
  border-radius: var(--r-sm);
  padding: 8px 10px;
  backdrop-filter: blur(var(--blur-2));
  box-shadow: var(--elev-2), var(--glass-hilite);
}
#itemTip .tipName {
  font-weight: 800;
  font-size: 14px;
}
#itemTip .tipSub {
  margin-top: 1px;
}
#itemTip .tipStats {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#itemTip .tipRow {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
  font-weight: 600;
}
#itemTip .tipRow span:first-child {
  color: var(--ink-dim);
}
.slot[draggable='true'] {
  cursor: grab;
}
.slot[draggable='true']:active {
  cursor: grabbing;
}

/* ---- skill tree (canvas) ---- */
/* A self-contained <canvas> (skillcanvas.js) renders the whole tree with its
   own pan/zoom; the stage is just a fixed-size, inset viewport for it. */
.skillStage {
  position: relative;
  width: 100%;
  height: min(520px, 68vh);
  margin: 6px 0 2px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.04), transparent 70%),
    rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke-1);
  overflow: hidden;
  touch-action: none; /* pan/zoom/hold must not scroll the panel */
}
#skillCanvas {
  /* Pinned to the (position:relative, overflow:hidden) stage so the canvas
     can never push layout or render above the tabs, whatever size JS sets. */
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  z-index: 35;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--t-med) var(--ease-out),
    visibility 0s linear var(--t-med);
  padding: 10px 18px 10px 15px;
  border-radius: var(--r-full);
  border: 1px solid var(--stroke-1);
  border-left: 3px solid var(--stroke-2);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--glass-3);
  backdrop-filter: blur(var(--blur-2));
  box-shadow: var(--elev-2), var(--glass-hilite);
}
#toast.ok {
  border-left-color: var(--success);
  box-shadow: var(--elev-2), var(--success-glow);
}
#toast.err {
  border-left-color: var(--danger);
  box-shadow: var(--elev-2), var(--danger-glow);
}

/* The loud, high-stakes result toast (craft/upgrade): larger, lifted to mid-screen,
   a full colour ring instead of just a left accent. Entrance motion is per-outcome
   (see the .show.big rules below). */
#toast.big {
  bottom: 42%;
  padding: 14px 26px;
  font-size: 18px;
  border-width: 2px;
  border-left-width: 2px;
}
#toast.big.ok {
  border-color: var(--success);
  box-shadow: var(--elev-3, var(--elev-2)), var(--success-glow), var(--success-glow);
}
#toast.big.err {
  border-color: var(--danger);
  box-shadow: var(--elev-3, var(--elev-2)), var(--danger-glow), var(--danger-glow);
}

/* ---- first-login name modal (blocking) ---- */
#nameModal {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.6);
  backdrop-filter: blur(3px);
}
#nameModal h2 {
  margin: 0 0 2px;
  font-size: 22px;
  color: var(--ink);
}
#nameError {
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger);
}

/* ---- kicked overlay (signed in elsewhere — blocking, no reconnect) ---- */
#kickedModal {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(3px);
}
#kickedModal h2 {
  margin: 0 0 2px;
  font-size: 22px;
  color: var(--ink);
}

/* ---- workbench place/upgrade prompt (shown near the home station spot) ---- */
#placeModal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.55);
  backdrop-filter: blur(2px);
}
#placeModal h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--ink);
}
#placeModal .placeBtns {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.hidden {
  display: none !important;
}
#conn {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--glass-3);
  border: 1px solid var(--danger);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  display: none;
  backdrop-filter: blur(var(--blur-1));
  box-shadow: var(--danger-glow);
}

/* Admin-only client performance overlay (F3). Fixed mid-left, pointer-events
   none so it never blocks input. Hidden until an admin toggles it. */
#perfOverlay {
  position: fixed;
  left: 14px;
  top: 130px;
  z-index: 41;
  pointer-events: none;
  white-space: pre;
  background: rgba(10, 16, 12, 0.82);
  color: var(--success-soft);
  font:
    11px/1.35 ui-monospace,
    'SF Mono',
    Menlo,
    Consolas,
    monospace;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(120, 220, 150, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.mobile #perfOverlay {
  font-size: 9px;
  top: 96px;
}

/* Chat — a persistent bottom-LEFT panel (the loadout bar owns bottom-centre).
   Top-level element, z-index 22: above the HUD (20), below the menu overlay
   (28). Hidden until in-game (#hud reveal in net.js toggles it too). */
#chatPanel {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 22;
  width: 320px;
  max-width: 42vw;
  display: flex;
  flex-direction: column;
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-lg);
  backdrop-filter: blur(var(--blur-2)) saturate(1.3);
  box-shadow: var(--elev-1), var(--glass-hilite);
  overflow: hidden;
  pointer-events: auto;
}
#chatPanel.hidden {
  display: none;
}
#chatTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px 4px 0;
}
.chatTab {
  position: relative;
  flex: 1 1 auto;
  min-width: 42px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink-dim);
  border: 1px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition:
    color var(--t-fast) var(--ease-out),
    background var(--t-fast) var(--ease-out);
}
.chatTab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
}
/* New messages on a non-active tab: light it up so it catches the eye. */
.chatTab.unread {
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  border-top-color: var(--gold);
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.55);
}
.chatTab.active {
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
  border-color: var(--stroke-1);
}
.chatDot {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}
#chatLog {
  height: 168px;
  overflow-y: auto;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}
.chatLine {
  margin: 1px 0;
  color: var(--ink);
}
.chatSys {
  color: var(--ink-dim);
  font-style: italic;
}
.chatName {
  font-weight: 700;
  cursor: pointer;
}
.chatName:hover {
  text-decoration: underline;
}
.chatTo {
  font-weight: 700;
  color: var(--chan-whisper);
}
.chatSep {
  color: var(--ink-dim);
}
/* Per-channel name tint (the line's channel class colours its name). */
.chPublic .chatName {
  color: var(--ink);
}
.chGlobal .chatName {
  color: var(--chan-system);
}
.chNearby .chatName {
  color: var(--chan-global);
}
.chParty .chatName {
  color: var(--chan-party);
}
.chGuild .chatName {
  color: var(--chan-guild);
}
.chWhisper .chatName,
.chWhisper.chatLine {
  color: var(--chan-whisper);
}
/* Tab tints (left border accent per channel). */
.chatTab.chGlobal.active {
  border-top-color: var(--chan-system);
}
.chatTab.chNearby.active {
  border-top-color: var(--chan-global);
}
.chatTab.chParty.active {
  border-top-color: var(--chan-party);
}
.chatTab.chGuild.active {
  border-top-color: var(--chan-guild);
}
.chatTab.chWhisper.active {
  border-top-color: var(--chan-whisper);
}
#chatInputRow {
  display: flex;
  padding: 5px;
  border-top: 1px solid var(--stroke-1);
}
#chatInput {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  border: 1px solid var(--stroke-1);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}
#chatInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-16);
}
/* A roster name that starts a whisper when clicked (party/guild panels). */
.chatLink {
  cursor: pointer;
}
.chatLink:hover {
  text-decoration: underline;
}

/* ============================================================
   Mobile / touch controls + responsive layout
   The overlay (#touchControls) is built by public/touch.js and only mounted
   on touch devices; the `.mobile` body class (set in main.js) drives the
   responsive tweaks. Everything below is inert on desktop.
   ============================================================ */
#touchControls {
  position: fixed;
  inset: 0;
  z-index: 24; /* above HUD/loadout/chat (20-22), below menu overlay (28) */
  pointer-events: none; /* children opt back in */
}
#touchControls > * {
  pointer-events: auto;
}

/* Left-thumb joystick */
.tcStick {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(26px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--glass-1);
  border: 2px solid var(--stroke-2);
  backdrop-filter: blur(var(--blur-1));
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.4),
    var(--glass-hilite);
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tcKnob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--accent-hi), var(--accent));
  border: 2px solid var(--accent-deep);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.4),
    var(--glow-accent);
  will-change: transform;
}

/* Right-thumb action buttons (Attack / Defend) */
.tcActions {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(26px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.tcBtn {
  font: inherit;
  color: var(--btn-ink);
  border: none;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tcActions .tcBtn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-size: 30px;
  box-shadow: var(--elev-1), var(--glass-hilite);
}
.tcAttack {
  background: linear-gradient(180deg, var(--danger-hi), var(--danger));
  width: 92px !important;
  height: 92px !important;
  font-size: 38px !important;
}
.tcDefend {
  background: linear-gradient(180deg, var(--info-hi), var(--info));
}
.tcBtn.held {
  transform: scale(0.92);
  filter: brightness(1.15);
}
.tcAttack.held {
  box-shadow: var(--elev-1), var(--danger-glow);
}
.tcDefend.held {
  box-shadow:
    var(--elev-1),
    0 0 16px rgba(91, 156, 255, 0.5);
}

/* Top-edge menu/chat buttons */
.tcMenu {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
  border-radius: var(--r-full);
  padding: 5px 7px;
  backdrop-filter: blur(var(--blur-1));
  box-shadow: var(--elev-1), var(--glass-hilite);
}
.tcMenuBtn {
  width: 42px;
  height: 42px;
  border-radius: var(--r-full);
  font-size: 20px;
  background: rgba(0, 0, 0, 0.25);
}
.tcMenuBtn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* --- Responsive tweaks for small / touch screens --- */
@media (max-width: 760px), (pointer: coarse) {
  /* Backdrop blur is the priciest effect on mobile GPUs — drop the tiers so the
     same glass rules cost a fraction (the translucency still reads as glass). */
  :root {
    --blur-1: 3px;
    --blur-2: 5px;
    --blur-3: 8px;
  }
  /* Shrink the corner HUD panels so they don't dominate a phone screen. */
  #stats {
    min-width: 0;
    max-width: 56vw;
    font-size: 13px;
    padding: 7px 9px;
  }
  #players {
    min-width: 0;
    font-size: 11px;
    max-width: 38vw;
  }
  #partyHud {
    top: 150px;
    min-width: 0;
    max-width: 44vw;
    font-size: 11px;
  }
  /* The perks strip would collide with the corner panels on a phone — drop it
     below the stats panel, shrink the chips, and let it scroll horizontally. */
  #buffStrip {
    top: 120px;
    left: 14px;
    transform: none;
    justify-content: flex-start;
    max-width: 92vw;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .buff {
    width: 28px;
    height: 28px;
  }
  .buff img {
    width: 22px;
    height: 22px;
  }
  /* Stack End Run under the shrunk stats panel so it can't overflow beside it. */
  #hudTopLeft {
    flex-direction: column;
  }
  #endRun {
    padding: 7px 11px;
    font-size: 12px;
  }
  /* The minimap moves up so it clears the right-thumb action buttons. Its
     canvas size is now driven by JS (the M-toggle modes) via inline styles,
     so there's no fixed canvas width/height override here anymore. */
  #mini {
    right: 10px;
    bottom: auto;
    top: 110px;
  }
  /* Menus + chat go (near) full-screen with bigger tap targets. */
  .menuCard {
    width: 96vw;
    max-height: 88vh;
  }
  #chatPanel {
    width: 70vw;
    max-width: 70vw;
    left: 8px;
    bottom: 170px; /* sit above the joystick */
  }
  #chatLog {
    height: 130px;
  }
  /* Lift the loadout deck above the on-screen controls, and shrink the cells
     back down — the desktop size would run off a phone screen. */
  #loadoutBar {
    bottom: 168px;
    height: 90px; /* smaller cards + tighter peek ⇒ a shorter deck */
  }
  .loadoutRow {
    --peek: 16px; /* tighter fan on the small deck */
    gap: 8px;
    padding: 4px 9px;
  }
  .loadoutNum {
    font-size: 13px;
    width: 14px;
  }
  .loadoutSlots {
    gap: 5px;
  }
  .loadoutCell {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .loadoutCell img {
    width: 32px;
    height: 32px;
  }
  .menuTabs button {
    padding: 9px 12px;
    font-size: 15px;
  }
  .slot {
    width: 54px;
    height: 54px;
  }
}

/* ---- motion system ---------------------------------------------------------
   Entrance/feedback keyframes. Elements hidden via display:none restart their
   animation when revealed, so the entrances below need no JS. Everything is
   disabled under prefers-reduced-motion. */
@keyframes fc-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fc-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fc-scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fc-toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes fc-slide-left {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fc-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.85;
  }
}
@keyframes fc-glow-pulse {
  0%,
  100% {
    box-shadow: var(--glow-accent);
  }
  50% {
    box-shadow: 0 0 26px rgba(255, 138, 31, 0.55);
  }
}
@keyframes fc-glow-pulse-danger {
  0%,
  100% {
    box-shadow: var(--danger-glow);
  }
  50% {
    box-shadow: 0 0 26px rgba(255, 91, 91, 0.6);
  }
}
@keyframes fc-bar-sheen {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(350%);
  }
}
@keyframes fc-shake {
  0%,
  100% {
    transform: none;
  }
  20%,
  60% {
    transform: translateX(-2px);
  }
  40%,
  80% {
    transform: translateX(2px);
  }
}

/* entrances */
.menuCard {
  animation: fc-fade-up var(--t-enter) var(--ease-out);
}
#menu:not(.hidden) {
  animation: fc-fade-in var(--t-med) var(--ease-out);
}
#start .card,
#dead .card {
  animation: fc-fade-up var(--t-enter) var(--ease-out);
}
#nameModal .card,
#kickedModal .card,
#placeModal .card {
  animation: fc-scale-in var(--t-enter) var(--ease-spring);
}
#chatPanel {
  animation: fc-slide-left var(--t-enter) var(--ease-out);
}
#partyHud,
#players {
  animation: fc-fade-in var(--t-enter) var(--ease-out);
}
#itemTip {
  animation: fc-scale-in var(--t-fast) var(--ease-out);
}
/* Death recap rows stagger in (fill backwards so late rows start invisible). */
.deathStats .row {
  animation: fc-fade-up var(--t-slow) var(--ease-out) backwards;
}
.deathStats .row:nth-child(2) {
  animation-delay: 60ms;
}
.deathStats .row:nth-child(3) {
  animation-delay: 120ms;
}
.deathStats .row:nth-child(4) {
  animation-delay: 180ms;
}
.deathStats .row:nth-child(5) {
  animation-delay: 240ms;
}
.deathStats .recapSection {
  animation: fc-fade-up var(--t-slow) var(--ease-out) 300ms backwards;
}

/* toast in/out */
#toast.show {
  opacity: 1;
  visibility: visible;
  transition: none;
  animation: fc-toast-in var(--t-enter) var(--ease-spring);
}
/* The big result toast lands with an outcome-matched motion (both preserve the
   translateX(-50%) centering): success pops, failure shakes. */
#toast.show.big.ok {
  animation: fc-toast-pop 420ms var(--ease-spring);
}
#toast.show.big.err {
  animation: fc-toast-shake 420ms var(--ease-out);
}
@keyframes fc-toast-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.7);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.12);
  }
  100% {
    transform: translate(-50%, 0) scale(1);
  }
}
@keyframes fc-toast-shake {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  15%,
  45%,
  75% {
    transform: translate(calc(-50% - 8px), 0);
  }
  30%,
  60%,
  90% {
    transform: translate(calc(-50% + 8px), 0);
  }
}

/* Full-screen success/failure burst: a colour vignette (edges tinted, centre clear
   so menus stay readable) that flashes in and fades out. Non-interactive. */
#screenFlash {
  position: fixed;
  inset: 0;
  z-index: 34;
  pointer-events: none;
  opacity: 0;
}
#screenFlash.flash-ok {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(95, 224, 106, 0.28) 100%);
  animation: fc-flash 500ms var(--ease-out);
}
#screenFlash.flash-err {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 91, 91, 0.38) 100%);
  animation: fc-flash 500ms var(--ease-out);
}
@keyframes fc-flash {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* attention pulses */
#stats .sp {
  animation: fc-pulse 1.6s var(--ease-inout) infinite;
}
#dead .btn:not([disabled]) {
  animation: fc-pulse 1.6s var(--ease-inout) infinite;
}
.loadoutKey {
  animation: fc-glow-pulse 2.2s var(--ease-inout) infinite;
}
.menuTabs button.active {
  animation: fc-glow-pulse 2.2s var(--ease-inout) infinite;
}
#conn {
  animation: fc-glow-pulse-danger 2.2s var(--ease-inout) infinite;
}
#nameError:not(.hidden) {
  animation: fc-shake 240ms var(--ease-out);
}

/* bar sheen: a soft highlight sweeps the HP/XP fills */
.bar > i::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  animation: fc-bar-sheen 3s var(--ease-inout) infinite;
}
#hpGhost::after {
  content: none;
}

/* One switch turns it all off. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --t-fast: 0ms;
    --t-med: 0ms;
    --t-slow: 0ms;
    --t-enter: 0ms;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  #toast {
    transition: none;
  }
  #toast.show {
    opacity: 1;
    visibility: visible;
  }
}

/* Stronger hairlines + dimmed-text lift for users who ask for more contrast. */
@media (prefers-contrast: more) {
  :root {
    --stroke-1: rgba(255, 255, 255, 0.22);
    --stroke-2: rgba(255, 255, 255, 0.38);
    --ink-dim: #c7d0dd;
    --ink-faint: #97a1b1;
  }
}
