/* ══════════════════════════════════════════════════════════════
   IRON FLOW v2 — Styles
   Wuxia/Xianxia dark theme with gradual sci-fi escalation
   Layout: fixed-height 3-col grid (realms | arena | arts)
   ══════════════════════════════════════════════════════════════ */
:root {
  --bg:     #05080f;
  --bg2:    #080d18;
  --panel:  #0c1120;
  --panel2: #111929;
  --dim:    #182038;
  --dim2:   #101828;

  --fire:   #ff4400;
  --fire2:  #ff7a30;
  --ki:     #00c8ff;
  --gold:   #ffd700;
  --purple: #9d4edd;
  --jade:   #3dba7a;
  --danger: #ff2255;

  --text:  #bccce0;
  --muted: #3a4868;

  --hdr-h: 56px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  height: 100%;
}

/* ── Layout ───────────────────────────────────────────────── */

#game {
  display: grid;
  grid-template-rows: var(--hdr-h) 1fr;
  height: 100dvh;
  overflow: hidden;
}

#main {
  display: grid;
  grid-template-columns: 1fr 420px;
  overflow: hidden;
}
/* Right panel can be hidden from the header */
body.panel-hidden #main { grid-template-columns: 1fr; }
body.panel-hidden #skills-col { display: none; }

/* ── Header ───────────────────────────────────────────────── */

#hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--dim);
  gap: 12px;
  flex-shrink: 0;
}

#brand { display: flex; flex-direction: column; line-height: 1.1; }

#game-title {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 900;
  color: var(--fire2);
  text-shadow: 0 0 18px var(--fire)88;
  letter-spacing: 0.06em;
}

#game-sub {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ── Auth bar ─────────────────────────────────────────────── */

#auth-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.auth-status {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-status.signed-in { color: var(--jade); }

.auth-btn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: transparent;
  border: 1px solid var(--dim);
  color: var(--ki);
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.2s, color 0.2s;
}
.auth-btn:hover { border-color: var(--ki); color: #fff; }
.auth-btn.signout { color: var(--muted); border-color: var(--dim); }
.auth-btn.signout:hover { color: var(--danger); border-color: var(--danger); }

/* ── Login modal ──────────────────────────────────────────── */

/* ── Header view buttons ──────────────────────────────────── */

#view-bar { display: flex; gap: 6px; flex-shrink: 0; }
.hdr-btn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: transparent;
  border: 1px solid var(--dim);
  color: var(--text);
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.hdr-btn:hover { border-color: var(--gold); color: #fff; }
.stb-sp { color: var(--gold); margin-left: 4px; }
#skill-tree-btn.can-learn { border-color: var(--jade); box-shadow: 0 0 10px var(--jade)55; animation: stbPulse 1.6s ease-in-out infinite; }
@keyframes stbPulse { 0%,100% { box-shadow: 0 0 6px var(--jade)44; } 50% { box-shadow: 0 0 14px var(--jade)99; } }

/* ── Skill tree window ────────────────────────────────────── */

#skill-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 140;
}
#skill-modal.hidden { display: none; }
.sm-box {
  background: var(--bg2);
  border: 1px solid var(--dim);
  border-top: 2px solid var(--gold);
  box-shadow: 0 0 60px rgba(255,215,0,0.08);
  width: min(1600px, 98vw);
  max-height: 97dvh;
  overflow-y: auto;            /* only as a fallback on very small screens */
  display: flex;
  flex-direction: column;
}
.sm-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--dim);
}
.sm-title { font-family: 'Orbitron', monospace; font-size: 12px; font-weight: 900; letter-spacing: 0.12em; color: var(--gold); }
.sm-level { font-size: 11px; color: var(--text); flex: 1; }
.sm-close {
  background: transparent; border: 1px solid var(--dim); color: var(--muted);
  font-size: 12px; width: 26px; height: 26px; cursor: pointer; border-radius: 2px;
}
.sm-close:hover { color: var(--text); border-color: var(--text); }
/* The window shows the whole tree at once: the 8 paths share the width,
   nodes wrap their text instead of forcing a scrollbar. */
#skill-modal { padding: 1dvh 1vw; }
#skill-modal .st-paths { height: auto; max-height: none; overflow: visible; flex-shrink: 0; }
#skill-modal .st-path { flex: 1 1 0; min-width: 0; }
#skill-modal .st-path-hdr { position: static; padding: 6px 2px 5px; }
#skill-modal .skill-node { margin: 2px 3px 0; padding: 4px 5px; }
#skill-modal .st-connector { height: 5px; }
#skill-modal .sk-name { font-size: 9px; }
#skill-modal .sk-desc { font-size: 8px; line-height: 1.25; overflow-wrap: anywhere; }
@media (max-width: 900px) {   /* narrow screens: keep columns readable and scroll sideways */
  #skill-modal .st-paths { overflow-x: auto; }
  #skill-modal .st-path { min-width: 118px; }
}
.sm-foot { font-size: 9px; color: var(--muted); padding: 7px 14px; border-top: 1px solid var(--dim); letter-spacing: 0.04em; }

/* ── Active skills bar (under the arena) ──────────────────── */

#active-skills {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
#active-skills.hidden { display: none; }
.as-btn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--fire);
  color: #fff;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 2px;
  min-width: 120px;
}
.as-btn:hover:not(:disabled) { background: var(--fire2); }
.as-btn:disabled { background: var(--dim); color: var(--muted); cursor: default; }

/* ── Market scene ─────────────────────────────────────────── */
#market-scene {
  width: 100%;
  container-type: inline-size;        /* columns follow the arena's width, not the window's */
  min-height: clamp(300px, 48vh, 540px);
  border: 1px solid var(--dim);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,120,40,0.12), transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255,60,60,0.08), transparent 45%),
    linear-gradient(180deg, #14101c, #0c0a14);
  display: flex;
  flex-direction: column;
}
#market-scene.hidden { display: none; }
.mk-title { color: #ff9a40 !important; }
#market-leave { font-family: 'Orbitron', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  background: transparent; border: 1px solid var(--dim); color: var(--text); padding: 5px 10px; cursor: pointer; }
#market-leave:hover { border-color: #ff9a40; color: #fff; }
#market-body { display: grid; grid-template-columns: 250px 1fr; gap: 12px; padding: 12px; min-height: 0; }
.mk-left { display: flex; flex-direction: column; gap: 8px; }
.mk-blurb { font-size: 10px; color: var(--text); line-height: 1.5; }
.mk-famous { font-size: 8px; color: #ff9a40; border: 1px solid #ff9a40; padding: 0 4px; letter-spacing: 0.1em; text-transform: uppercase; }
#mk-shown { background: var(--bg2); color: var(--text); border: 1px solid var(--dim); font-family: inherit; font-size: 10px; padding: 3px; }
.mk-people { display: flex; flex-direction: column; gap: 4px; }
.mk-person { background: rgba(0,0,0,0.3); border: 1px solid var(--dim2); padding: 5px 7px; font-size: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.mk-person span { color: #ff9a40; }
.mk-person small { flex-basis: 100%; font-size: 8px; color: var(--muted); }
.mk-warn { flex-basis: 100%; font-size: 9px; color: var(--danger); }
.mk-note { font-size: 9px; color: #ff9a40; font-style: italic; }
.mk-right { display: flex; flex-direction: column; gap: 4px; max-height: 470px; overflow-y: auto; min-width: 0; }
.mk-item { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--dim2); padding: 4px 6px; }
.mk-item.out { opacity: 0.4; }
.mk-info { flex: 1; min-width: 0; font-size: 10px; display: flex; flex-direction: column; gap: 2px; }
.mk-rar { font-size: 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.mk-qty { font-size: 8px; color: var(--muted); }
.mk-desc { font-size: 9px; color: var(--muted); }
.mk-buy { font-family: 'Orbitron', monospace; font-size: 9px; font-weight: 700; background: #ffaa22; color: #000; border: none;
  padding: 5px 9px; cursor: pointer; flex-shrink: 0; min-width: 62px; }
.mk-buy:disabled { background: var(--dim); color: var(--muted); cursor: default; }
.mk-rel-fill { background: linear-gradient(90deg, #ff9a40, var(--gold)); }
.mk-ask { font-family: 'Orbitron', monospace; font-size: 8px; background: transparent; color: var(--text); border: 1px solid var(--dim); padding: 2px 5px; margin: 0 1px; cursor: pointer; }
.mk-ask.on { background: #ffaa22; color: #000; border-color: #ffaa22; }
.mk-lot { border-color: #ffaa22; }
.mk-lot.grand { box-shadow: 0 0 18px rgba(255,170,34,0.5); }
.mk-auc-btns { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.mk-auc-log { font-size: 9px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; padding: 2px 4px; }
.mk-auc-log div:first-child { color: var(--text); }
#nf-market { font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  background: transparent; color: var(--text); border: 1px solid var(--dim); padding: 9px 14px; cursor: pointer; }
#nf-market:hover { border-color: #ff9a40; color: #fff; }
@container (max-width: 640px) { #market-body { grid-template-columns: 1fr; } }

/* ── Bag & quick slots ────────────────────────────────────── */
#bag-list { overflow-y: auto; flex-shrink: 0; }
.bag-item { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-bottom: 1px solid var(--dim2); }
.bag-ico { flex-shrink: 0; }
.bag-btns { display: flex; gap: 3px; flex-shrink: 0; }
.bag-slot { font-family: 'Orbitron', monospace; font-size: 8px; width: 18px; height: 20px; background: transparent; color: var(--muted);
  border: 1px solid var(--dim); cursor: pointer; padding: 0; }
.bag-slot.on { color: #000; background: var(--gold); border-color: var(--gold); }
#quick-bar { display: flex; gap: 6px; justify-content: center; width: 100%; }
.qs { position: relative; width: 46px; height: 40px; background: var(--panel); border: 1px solid var(--dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center; }
.qs:hover { border-color: var(--gold); }
.qs.empty { opacity: 0.4; }
.qs-key { position: absolute; top: 1px; left: 3px; font-family: 'Orbitron', monospace; font-size: 8px; color: var(--gold); }
.qs-n { position: absolute; bottom: 1px; right: 3px; font-size: 8px; color: var(--text); }

/* ── Secret arts ──────────────────────────────────────────── */
.art-box { width: min(620px, 94vw); max-height: 92dvh; overflow-y: auto; text-align: left; }
.art-choices { display: flex; flex-direction: column; gap: 8px; }
.art-card { background: rgba(0,0,0,0.3); border: 1px solid var(--dim); padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.art-card-head { font-size: 12px; }
.art-note { font-size: 9px; }
.art-mut { color: #ff9a40; font-size: 9px; }
.art-aspect { font-size: 8px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border: 1px solid var(--dim); padding: 0 4px; }
.cv-reforge b { font-family: inherit; font-size: inherit; }
.cv-rf-row { flex-basis: 100%; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 10px; }
.art-learn { align-self: flex-end; font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 900; letter-spacing: 0.1em;
  background: #ffaa22; color: #000; border: none; padding: 6px 12px; cursor: pointer; margin-top: 3px; }
#st-leave { font-family: 'Orbitron', monospace; font-size: 10px; background: transparent; color: var(--text); border: 1px solid var(--dim); padding: 8px; cursor: pointer; }
.art-strain { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--dim2); font-size: 10px; }
.art-strain span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: 0.1em; }
.art-strain small { flex-basis: 100%; font-size: 8px; color: var(--muted); }
.art-strain-fill { background: linear-gradient(90deg, #ffaa22, #ff2255); }
.art-xp { height: 3px; margin-top: 3px; }
.art-sever-note { font-size: 10px; color: #ff9a40; padding: 6px 10px; display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.sa-btn.sever { background: var(--danger); color: #fff; }
.sa-btn:disabled { background: var(--dim); color: var(--muted); cursor: default; }
#turbulence { position: fixed; inset: 0; background: rgba(40,0,10,0.85); display: flex; align-items: center; justify-content: center; z-index: 240; }
#turbulence.hidden { display: none; }
.turb-box { background: var(--panel); border: 2px solid var(--danger); padding: 22px 26px; width: min(420px, 92vw); text-align: center;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 80px rgba(255,34,85,0.35); animation: turbShake 0.25s ease-in-out infinite alternate; }
@keyframes turbShake { from { transform: translateX(-2px); } to { transform: translateX(2px); } }
.turb-title { font-family: 'Orbitron', monospace; font-size: 20px; font-weight: 900; color: var(--danger); letter-spacing: 0.1em; }
.turb-reason { font-size: 11px; color: var(--text); }
.turb-diff { font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 700; color: var(--gold); }
.turb-diff.hard { color: var(--danger); }
.turb-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.turb-bar { height: 10px; }
.turb-time { background: linear-gradient(90deg, var(--danger), #ffaa22); }
.turb-count { font-family: 'Orbitron', monospace; font-size: 12px; color: #fff; }
#turb-btn { font-family: 'Orbitron', monospace; font-size: 16px; font-weight: 900; letter-spacing: 0.12em; background: var(--danger); color: #fff;
  border: none; padding: 16px; cursor: pointer; user-select: none; }
#turb-btn:active { transform: scale(0.96); }

/* ── Scene bar & sect scene ───────────────────────────────── */
#scene-bar { width: 100%; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.scene-btn { font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; background: var(--panel);
  color: var(--text); border: 1px solid var(--dim); padding: 7px 14px; cursor: pointer; min-width: 110px; }
.scene-btn:hover:not(:disabled) { border-color: var(--gold); color: #fff; }
.scene-btn:disabled { opacity: 0.35; cursor: default; }
.scene-btn.on { border-color: var(--gold); color: var(--gold); }
.scene-btn.bt-ready { border-color: var(--jade); color: var(--jade); animation: stbPulse 1.6s ease-in-out infinite; }
#sect-scene { width: 100%; min-height: clamp(300px, 48vh, 540px); border: 1px solid var(--dim); container-type: inline-size;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,215,0,0.08), transparent 60%), linear-gradient(180deg, #101624, #0a0e18); display: flex; flex-direction: column; }
#sect-scene.hidden { display: none; }
.sc-title { color: var(--gold) !important; text-shadow: 0 0 12px rgba(255,215,0,0.4); }
#sect-leave { font-family: 'Orbitron', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; background: transparent;
  border: 1px solid var(--dim); color: var(--text); padding: 5px 10px; cursor: pointer; }
#sect-leave:hover { border-color: var(--fire); color: #fff; }
#sect-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
#sc-visitors { display: flex; flex-direction: column; gap: 6px; }
.sc-comp { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.35); border: 1px solid var(--dim); padding: 6px 8px; }
.sc-recruit { min-width: 110px; padding: 7px 8px; }
.sc-dismiss { font-family: 'Orbitron', monospace; font-size: 8px; background: transparent; color: var(--muted); border: 1px solid var(--dim); padding: 4px 8px; cursor: pointer; }
.sc-dismiss:hover { color: var(--danger); border-color: var(--danger); }
.sc-overview { display: flex; gap: 6px; flex-wrap: wrap; }
.sc-overview .cv-stat { flex: 1 1 110px; }
.sc-auto { flex: 2 1 220px !important; }
.sc-hall { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px; }
.sc-card { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--dim2); border-left: 3px solid; padding: 5px 7px; opacity: 0.6; }
.sc-card.can-buy { opacity: 1; }
.sc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sc-name { font-size: 11px; font-weight: 700; }
.sc-count { color: var(--text); font-family: 'Orbitron', monospace; font-size: 10px; }
.sc-realm { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.sc-stats { font-size: 9px; color: var(--text); }
.sc-btns { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.sc-buy { font-family: 'Orbitron', monospace; font-size: 8px; font-weight: 700; background: var(--jade); color: #000; border: none; padding: 4px 6px; cursor: pointer; min-width: 92px; }
.sc-buy:disabled { background: var(--dim); color: var(--muted); cursor: default; }

/* ── Spirit root ──────────────────────────────────────────── */
.root-chip { font-size: 8px; letter-spacing: 0.06em; white-space: nowrap; cursor: help; }
.sm-root { font-size: 9px; color: var(--muted); padding: 6px 14px; border-bottom: 1px solid var(--dim); line-height: 1.5; }
.sm-root span { color: var(--text); }
.sm-synergies { display: flex; flex-wrap: wrap; gap: 4px; padding: 7px 14px; border-top: 1px solid var(--dim); }
.sm-syn-head { flex-basis: 100%; font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.sm-syn { font-size: 9px; border: 1px solid var(--dim); padding: 1px 6px; color: var(--text); cursor: help; }
.sm-syn.on { border-color: var(--jade); color: var(--jade); }
.sm-syn.unknown { color: var(--muted); cursor: default; }
#root-reveal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 220; }
#root-reveal.hidden { display: none; }
.rr-box { background: var(--panel); border: 1px solid var(--dim); border-top: 2px solid #b89cff; padding: 26px 30px; width: min(460px, 92vw);
  text-align: center; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 0 80px rgba(184,156,255,0.15); }
.rr-eyebrow { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 0.24em; color: #b89cff; }
.rr-name { font-family: 'Orbitron', monospace; font-size: 22px; font-weight: 900; letter-spacing: 0.06em; text-shadow: 0 0 18px currentColor; }
.rr-grade { font-family: 'Orbitron', monospace; font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.rr-kind { font-size: 10px; color: var(--muted); }
.rr-desc { font-size: 11px; line-height: 1.6; text-align: left; background: rgba(0,0,0,0.3); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
#rr-ok { font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 900; letter-spacing: 0.12em; background: #7a5cff; color: #fff; border: none; padding: 10px; cursor: pointer; margin-top: 6px; }
#rr-ok:hover { background: #9a80ff; }

/* ── Ascension & records ─────────────────────────────────── */
#ascension-screen, #records-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 230; }
#ascension-screen.hidden, #records-modal.hidden { display: none; }
.as-box { background: var(--panel); border: 1px solid var(--dim); border-top: 2px solid var(--gold); padding: 22px 26px; width: min(620px, 94vw);
  max-height: 92dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; text-align: center; box-shadow: 0 0 90px rgba(255,215,0,0.15); }
.as-eyebrow { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 0.26em; color: var(--gold); }
.as-title { font-family: 'Orbitron', monospace; font-size: 15px; font-weight: 900; color: #fff; }
.as-run { font-size: 10px; color: var(--muted); }
.as-score { font-family: 'Orbitron', monospace; font-size: 34px; font-weight: 900; color: var(--gold); text-shadow: 0 0 24px rgba(255,215,0,0.6); }
.as-rank { font-size: 11px; color: var(--jade); }
.as-breakdown { display: flex; flex-direction: column; gap: 3px; background: rgba(0,0,0,0.3); padding: 8px 12px; font-size: 10px; text-align: left; }
.as-breakdown div { display: flex; justify-content: space-between; }
.as-breakdown span { color: var(--muted); }
.as-rec-head { font-size: 8px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.rec-table th { font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; text-align: left; padding: 3px 5px; border-bottom: 1px solid var(--dim); }
.rec-table td { padding: 3px 5px; text-align: left; border-bottom: 1px solid var(--dim2); }
.rec-table tr.me td { color: var(--gold); font-weight: 700; }
.as-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.as-btns button { font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 900; letter-spacing: 0.1em; border: none; padding: 10px 14px; cursor: pointer; }
#as-reincarnate { background: var(--gold); color: #000; }
#as-continue, #rec-close { background: transparent; color: var(--text); border: 1px solid var(--dim); }
#death-screen.ascension .ds-box { border-color: var(--gold); box-shadow: 0 0 60px rgba(255,215,0,0.2); }
#death-screen.ascension .ds-title { color: var(--gold); text-shadow: 0 0 20px rgba(255,215,0,0.5); }

#login-modal {
  position: fixed;
  inset: 0;
  background: #000a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#login-modal.hidden { display: none; }

.lm-box {
  background: var(--panel2);
  border: 1px solid var(--dim);
  border-top: 2px solid var(--ki);
  padding: 28px 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lm-title {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 900;
  color: var(--ki);
  letter-spacing: 0.1em;
  text-align: center;
}
.lm-sub { font-size: 10px; color: var(--muted); text-align: center; letter-spacing: 0.06em; }

.lm-input {
  background: var(--bg2);
  border: 1px solid var(--dim);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  border-radius: 2px;
  width: 100%;
}
.lm-input:focus { border-color: var(--ki); }

.lm-row { display: flex; gap: 8px; }
.lm-row button {
  flex: 1;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 2px;
  border: none;
}
#lm-signin { background: var(--ki); color: #000; }
#lm-signin:hover { filter: brightness(1.15); }
#lm-signup { background: transparent; color: var(--ki); border: 1px solid var(--ki); }
#lm-signup:hover { background: var(--ki)22; }

.lm-cancel {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 2px;
}
.lm-cancel:hover { color: var(--text); }

.lm-error { background: #ff22441a; border: 1px solid var(--danger); color: var(--danger); font-size: 10px; padding: 7px 10px; border-radius: 2px; }
.lm-error.hidden { display: none; }
.lm-confirm { font-size: 10px; color: var(--jade); text-align: center; padding: 4px; }
.lm-confirm.hidden { display: none; }

#res-bar { display: flex; align-items: center; gap: 8px; }

.res-block { display: flex; flex-direction: column; align-items: flex-end; }

.res-num {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.res-num.sm   { font-size: 13px; }
.res-num.fire { color: var(--fire2); text-shadow: 0 0 8px var(--fire)66; }
.res-num.ki   { color: var(--ki);    text-shadow: 0 0 8px var(--ki)66; }

.res-lbl { font-size: 8px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.res-sep { width: 1px; height: 32px; background: var(--dim); flex-shrink: 0; }

/* ── Side columns ─────────────────────────────────────────── */

#skills-col {
  background: var(--bg2);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  display: flex;
  flex-direction: column;
}
#skills-col   { border-left:  1px solid var(--dim); }

.col-head {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--muted);
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--dim);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 2;
  text-transform: uppercase;
  flex-shrink: 0;
}
.col-head.ki-head {
  color: var(--ki);
  opacity: 0.75;
  border-top: 2px solid var(--dim);
  position: static;
}

/* ── Arena ────────────────────────────────────────────────── */

#arena-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 14px 18px;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--bg);
  position: relative;
}

#arena-col::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff1 0%, transparent 100%),
    radial-gradient(1px 1px at 38%  7%, #fff1 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 28%, #fff1 0%, transparent 100%),
    radial-gradient(1px 1px at 82% 12%, #fff1 0%, transparent 100%),
    radial-gradient(2px 2px at 24% 68%, #fff1 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}
/* Arena children keep their natural height and never shrink: the column
   scrolls instead. (Shrinking scenes let their content spill out of their
   backdrop and under the active-skills bar.) */
#arena-col > * { position: relative; z-index: 1; flex-shrink: 0; }

/* ── Stage Panel ──────────────────────────────────────────── */

#stage-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--dim);
  padding: 8px 14px;
  text-align: center;
}
.stage-label {
  font-size: 7px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 3px;
}
.stage-name {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  transition: color 0.6s;
}
.stage-enemy-row { font-size: 9px; color: var(--muted); display: flex; gap: 5px; justify-content: center; align-items: baseline; }
.stage-enemy-lbl { letter-spacing: 0.08em; text-transform: uppercase; }
.stage-enemy { font-weight: 600; transition: color 0.6s; }

/* ── Enemy Zone ───────────────────────────────────────────── */

#enemy-zone {
  width: 100%;
  height: clamp(300px, 48vh, 540px);
  background: var(--panel);
  border: 1px solid var(--dim);
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  user-select: none;
  transition: background 0.08s, border-color 0.12s;
  flex-shrink: 0;
}
#enemy-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,68,0,0.07) 0%, transparent 65%);
  pointer-events: none;
}
#enemy-zone:hover { border-color: var(--dim2); }
#combo-display {
  position: absolute;
  top: 8px;
  right: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 8px var(--gold)88;
  letter-spacing: 0.06em;
  pointer-events: none;
  animation: comboPop 0.25s ease-out;
}
@keyframes comboPop {
  0%   { transform: scale(1.5); opacity: 0.6; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── Multi-Enemy Units ────────────────────────────────────── */

/* The arena is a field: enemies wander (position set from game.js), obstacles
   are drawn over them so they can hide, trinkets sit on top. */
#enemies-row, #obstacle-layer, #trinket-layer, #ally-layer {
  position: absolute;
  inset: 0 0 18px 0;
  pointer-events: none;
}
#enemies-row    { z-index: 2; }
#obstacle-layer { z-index: 3; }
#trinket-layer  { z-index: 4; }
#ally-layer     { z-index: 2; }
.ally { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: left 0.15s ease-out, top 0.15s ease-out; pointer-events: none; }
.ally-spr { transform: scaleX(1); filter: drop-shadow(0 0 4px var(--glow, #fff)); }
.ally.attacking .ally-spr { filter: drop-shadow(0 0 14px var(--glow, #fff)) brightness(1.4); transform: scale(1.12); }
.ally-label { font-size: 7px; letter-spacing: 0.06em; white-space: nowrap; text-shadow: 0 0 4px #000; }
.eu.ally-hit .eu-sprite { filter: drop-shadow(0 0 14px var(--flash, #fff)) brightness(1.6); }
.eu.frozen .eu-sprite { filter: drop-shadow(0 0 8px #bfefff) hue-rotate(160deg) saturate(0.6) brightness(1.3); }
.eu.poisoned .eu-label { color: #9adc5a; }
#enemy-zone::after {           /* ground */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 38%;
  background: linear-gradient(180deg, transparent, rgba(60,80,60,0.12));
  pointer-events: none;
}
.eu {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 110px;
  pointer-events: none;
  transition: opacity 0.3s, left 0.06s linear, top 0.06s linear;
}
.eu > .eu-sprite { pointer-events: auto; cursor: crosshair; }
.eu.dead { opacity: 0.2; filter: grayscale(1); pointer-events: none; }
.eu.dead > .eu-sprite { pointer-events: none; }
.px-sprite { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.obstacle { position: absolute; transform: translate(-50%, -62%); pointer-events: auto; cursor: not-allowed;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.5)); }
.trinket { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer;
  animation: trinketBob 1.2s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(255,215,0,0.8)); }
.trinket:hover { filter: drop-shadow(0 0 12px rgba(255,215,0,1)) brightness(1.2); }
.trinket.fading { animation: trinketBob 1.2s ease-in-out infinite, trinketFade 0.5s ease-in-out infinite alternate; }
@keyframes trinketBob { 0%,100% { margin-top: 0; } 50% { margin-top: -5px; } }
@keyframes trinketFade { from { opacity: 1; } to { opacity: 0.35; } }
.eu-sprite {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 6px rgba(255,68,0,0.25));
  transition: transform 0.08s, filter 0.08s;
  -webkit-user-drag: none;
}
.eu:not(.dead):hover .eu-sprite { filter: drop-shadow(0 0 10px rgba(255,68,0,0.7)) brightness(1.15); transform: translateY(-2px); }
.eu.hit .eu-sprite {
  transform: scale(0.86) rotate(-6deg);
  filter: drop-shadow(0 0 16px rgba(255,68,0,0.95)) brightness(1.8);
}
/* Rogue expert from a higher realm (expedition ambush) */
.eu-elite .eu-sprite { animation: eliteAura 1.2s ease-in-out infinite; }
.eu-elite .eu-label  { color: var(--danger); font-weight: 700; font-size: 8px; }
@keyframes eliteAura {
  0%, 100% { filter: drop-shadow(0 0 6px var(--aura, #ff2255)) drop-shadow(0 0 2px #fff); }
  50%      { filter: drop-shadow(0 0 18px var(--aura, #ff2255)) drop-shadow(0 0 4px #fff); }
}
#ambush-warning {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--danger);
  background: rgba(0,0,0,0.75);
  border: 1px solid var(--danger);
  padding: 4px 8px;
  white-space: nowrap;
  z-index: 5;
  pointer-events: none;
  animation: comboPop 0.25s ease-out;
}
#ambush-warning.hidden { display: none; }
/* Between fights: the player chooses when to start the next one */
#next-fight {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(5,8,15,0.55);
  z-index: 4;
}
#next-fight.hidden { display: none; }
.nf-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#nf-cave {
  font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  background: transparent; color: var(--text); border: 1px solid var(--dim); padding: 9px 14px; cursor: pointer;
}
#nf-cave:hover { border-color: var(--jade); color: #fff; }
#nf-cave.bt-ready { border-color: var(--jade); color: var(--jade); animation: stbPulse 1.6s ease-in-out infinite; }

/* ── Cultivation cave ─────────────────────────────────────── */
#cave-scene {
  width: 100%;
  container-type: inline-size;        /* columns follow the arena's width, not the window's */
  min-height: clamp(300px, 48vh, 540px);
  border: 1px solid var(--dim);
  background:
    radial-gradient(ellipse at 30% 75%, rgba(120,90,200,0.14), transparent 55%),
    radial-gradient(ellipse at 50% 0%, rgba(0,0,0,0.6), transparent 70%),
    repeating-linear-gradient(135deg, #0e1220 0 14px, #10162a 14px 28px);
  display: flex;
  flex-direction: column;
}
#cave-scene.hidden, #enemy-zone.hidden { display: none; }
.cave-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--dim); flex-wrap: wrap; }
.cave-title { font-family: 'Orbitron', monospace; font-size: 12px; font-weight: 900; letter-spacing: 0.12em; color: #b89cff; }
.cave-sub { font-size: 9px; color: var(--muted); flex: 1; }
#cave-leave { font-family: 'Orbitron', monospace; font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  background: transparent; border: 1px solid var(--dim); color: var(--text); padding: 5px 10px; cursor: pointer; }
#cave-leave:hover:not(:disabled) { border-color: var(--fire); color: #fff; }
#cave-leave:disabled { opacity: 0.4; cursor: default; }
.cave-title { text-shadow: 0 0 12px rgba(184,156,255,0.6); }
#cave-body { display: grid; grid-template-columns: 240px minmax(0,1fr) minmax(0,1.15fr); gap: 12px; padding: 12px; flex: 1; min-height: 0; }
.cv-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* meditation chamber */
.cv-chamber { align-items: center; text-align: center; position: relative; border-radius: 4px; padding: 6px 4px;
  background: radial-gradient(ellipse at 50% 30%, rgba(122,92,255,0.18), transparent 65%); transition: background 0.4s; }
.cv-chamber.meditating { background: radial-gradient(ellipse at 50% 30%, rgba(184,156,255,0.35), transparent 70%); }
.cv-chamber.bt-success { animation: btSuccess 1.2s ease-out; }
.cv-chamber.bt-fail    { animation: btFail 0.9s ease-out; }
@keyframes btSuccess { 0% { box-shadow: 0 0 0 0 rgba(255,215,0,0.9); } 100% { box-shadow: 0 0 60px 30px rgba(255,215,0,0); } }
@keyframes btFail { 0%,30% { box-shadow: inset 0 0 40px rgba(255,34,85,0.8); transform: translateX(-3px); } 15% { transform: translateX(3px); } 100% { box-shadow: none; transform: none; } }
.cv-stage { position: relative; width: 140px; height: 130px; display: flex; align-items: center; justify-content: center; }
.cv-aura { position: absolute; inset: 8px; border-radius: 50%; border: 2px solid rgba(184,156,255,0.35);
  box-shadow: 0 0 18px rgba(184,156,255,0.35), inset 0 0 18px rgba(184,156,255,0.2); animation: auraSpin 8s linear infinite; }
.cv-chamber.meditating .cv-aura { border-color: rgba(255,215,0,0.7); box-shadow: 0 0 30px rgba(255,215,0,0.6), inset 0 0 24px rgba(255,215,0,0.4); animation-duration: 1.6s; }
@keyframes auraSpin { from { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.06); } to { transform: rotate(360deg) scale(1); } }
#cv-med { position: relative; z-index: 1; }
.cv-med-spr { filter: drop-shadow(0 0 14px rgba(184,156,255,0.55)); animation: meditate 3s ease-in-out infinite; }
@keyframes meditate { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.cv-level { font-family: 'Orbitron', monospace; font-size: 12px; font-weight: 700; }
.cv-qi { width: 100%; display: flex; flex-direction: column; gap: 3px; }
.cv-qi-lbl { display: flex; justify-content: space-between; font-size: 8px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.cv-qi-fill { background: linear-gradient(90deg, var(--jade), var(--gold)); }
.cv-bt-bar { height: 8px; }
.cv-bt-hint { font-size: 8px; color: var(--muted); text-align: center; }
.cv-btn.ready { box-shadow: 0 0 12px rgba(122,92,255,0.6); animation: stbPulse 1.6s ease-in-out infinite; }
.cv-good { color: var(--jade); }
.cv-item.risky { border-color: rgba(255,34,85,0.5); }
.cv-buffs { display: flex; flex-direction: column; gap: 3px; font-size: 9px; color: var(--gold); }
.cv-root { width: 100%; text-align: left; background: rgba(0,0,0,0.3); border: 1px solid var(--dim); padding: 7px 8px; display: flex; flex-direction: column; gap: 3px; }
.cv-root-name { font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700; text-shadow: 0 0 10px currentColor; }
.cv-root-grade { font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.cv-root-line { font-size: 9px; line-height: 1.4; color: var(--text); }
.cv-root-line b { color: var(--muted); font-weight: 700; }
.cv-root-cd { color: var(--muted); }
.cv-bt { width: 100%; text-align: left; background: rgba(0,0,0,0.35); border: 1px solid var(--dim); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cv-bt-what { font-size: 11px; }
.cv-bt-chance { font-size: 9px; color: var(--muted); line-height: 1.4; }
.cv-bar { height: 6px; background: var(--dim2); overflow: hidden; border-radius: 2px; width: 100%; }
.cv-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7a5cff, #b89cff); transition: width 0.05s linear; }
.cv-imp-fill { background: linear-gradient(90deg, #7a8a3a, #c04040); }
.cv-btn { font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 900; letter-spacing: 0.1em;
  background: #7a5cff; color: #fff; border: none; padding: 8px; cursor: pointer; }
.cv-btn:disabled { background: var(--dim); color: var(--muted); cursor: default; }
.cv-stat { background: rgba(0,0,0,0.3); border: 1px solid var(--dim); padding: 6px 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 10px; }
.cv-stat > span:first-child { color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 8px; }
.cv-stat b { font-family: 'Orbitron', monospace; font-size: 12px; }
.cv-stat small { flex-basis: 100%; font-size: 8px; color: var(--muted); line-height: 1.4; }
.cv-el { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; border: 1px solid currentColor; padding: 0 4px; border-radius: 2px; }
.cv-inv-head { font-size: 8px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.cv-inv { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.cv-item { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--dim2); padding: 4px 6px; }
.cv-info { flex: 1; min-width: 0; font-size: 10px; display: flex; flex-direction: column; gap: 2px; }
.cv-pur { color: var(--jade); font-size: 9px; }
.cv-tier { color: var(--muted); font-size: 8px; }
.cv-eff { font-size: 9px; color: var(--text); }
.cv-bad { color: var(--danger) !important; }
.cv-warn { font-size: 9px; color: var(--danger); font-weight: 700; }
.cv-use { font-family: 'Orbitron', monospace; font-size: 9px; font-weight: 700; background: var(--jade); color: #000;
  border: none; padding: 5px 9px; cursor: pointer; flex-shrink: 0; }
.cv-use.armed { background: var(--danger); color: #fff; animation: hpPulse 0.6s ease-in-out infinite; }
.cv-empty { font-size: 10px; color: var(--muted); padding: 8px; }
@container (max-width: 860px) { #cave-body { grid-template-columns: 220px minmax(0,1fr); } #cave-body > .cv-col:last-child { grid-column: 1 / -1; } }
@container (max-width: 560px) { #cave-body { grid-template-columns: 1fr; } }
#nf-btn {
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--fire);
  border: none;
  padding: 9px 18px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255,68,0,0.45);
  transition: transform 0.08s, box-shadow 0.12s;
}
#nf-btn:hover  { transform: translateY(-1px); box-shadow: 0 0 22px rgba(255,68,0,0.75); }
#nf-btn:active { transform: translateY(1px); }
.nf-info { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text); }
.nf-hp   { font-size: 8px; letter-spacing: 0.1em; color: var(--muted); }
.eu-label {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.eu-bar  { width: 100%; height: 4px; background: var(--dim2); overflow: hidden; border-radius: 1px; }
.eu-fill { height: 100%; background: var(--danger); transition: width 0.1s linear; border-radius: 1px; }

#enemy-click-hint {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  text-align: center;
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 2px 0 4px;
  pointer-events: none;
  z-index: 1;
  position: relative;
  flex-shrink: 0;
}

#expedition-flee-wrap {
  padding: 4px 0 2px;
  display: flex;
  justify-content: center;
}
#exp-flee-btn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.1s;
}
#exp-flee-btn:hover { background: rgba(255,34,85,0.12); }

/* ── QTE Overlay ──────────────────────────────────────────── */

#qte-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  z-index: 10;
  cursor: pointer;
}
#qte-overlay.hidden { display: none; }
.qte-icon  { font-size: 32px; line-height: 1; }
.qte-label {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold)66;
  animation: qtePulse 0.45s ease-in-out infinite alternate;
}
@keyframes qtePulse { 0%{opacity:1; transform:scale(1)} 100%{opacity:0.65; transform:scale(0.97)} }
.qte-hint  { font-size: 9px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.qte-cd-wrap { width: 160px; height: 6px; background: var(--dim); overflow: hidden; border-radius: 2px; }
.qte-cd-fill { height: 100%; background: var(--gold); transition: width 0.05s linear, background 0.2s; border-radius: 2px; }

/* ── Expedition Modals ────────────────────────────────────── */

#expedition-offer,
#expedition-reward {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}
#expedition-offer.hidden,
#expedition-reward.hidden { display: none; }
.exp-box {
  background: var(--panel);
  border: 2px solid var(--ki);
  box-shadow: 0 0 60px rgba(0,200,255,0.12);
  padding: 20px 22px;
  max-width: 440px;
  width: 90%;
  max-height: 85dvh;
  overflow-y: auto;
}
.exp-title {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 900;
  color: var(--ki);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.exp-sub { font-size: 9px; color: var(--muted); margin-bottom: 14px; }
.exp-choice {
  background: var(--bg2);
  border: 1px solid var(--dim);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.exp-choice:hover { background: var(--panel2); border-color: var(--ki); }
.exp-choice-head  { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.exp-choice-icon  { font-size: 20px; }
.exp-choice-name  { font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700; color: var(--ki); }
.exp-choice-dang  { font-size: 11px; margin-left: auto; }
.exp-choice-desc  { font-size: 9px; color: var(--muted); margin-bottom: 4px; }
.exp-choice-info  { font-size: 9px; color: var(--text); }
#exp-ignore-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  background: transparent;
  border: 1px solid var(--dim);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
#exp-ignore-btn:hover { background: var(--dim); color: var(--text); }

/* Expedition Reward */
.exp-rew-icon { font-size: 48px; text-align: center; margin: 10px 0; display: block; }
.exp-rew-name {
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 8px;
  display: block;
}
.exp-rew-desc {
  font-size: 11px;
  color: var(--text);
  line-height: 1.6;
  text-align: center;
  margin-bottom: 16px;
  white-space: pre-line;
}
#exp-claim-btn {
  width: 100%;
  padding: 11px;
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: var(--ki);
  color: var(--bg);
  border: none;
  cursor: pointer;
  transition: opacity 0.1s;
}
#exp-claim-btn:hover { opacity: 0.85; }

.floater {
  position: absolute;
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--fire2);
  text-shadow: 0 0 6px var(--fire);
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
  top: 20%;
  left: 50%;
}
@keyframes floatUp {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(calc(-50% + var(--fx, 0px)), -72px); }
}

/* ── Stats ────────────────────────────────────────────────── */

#stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--dim);
  border: 1px solid var(--dim);
  width: 100%;
}
.stat { background: var(--panel); padding: 7px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-val {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-lbl { font-size: 8px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }

/* ── Milestone bar ────────────────────────────────────────── */

#next-ms {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--dim);
  padding: 9px 12px;
}
.ms-lbl  { font-size: 8px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-bottom: 3px; }
.ms-name { font-size: 11px; color: var(--gold); margin-bottom: 5px; }
.ms-bar-wrap { height: 3px; background: var(--dim); overflow: hidden; }
.ms-bar { height: 100%; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width 0.4s; }

/* ── Event log ────────────────────────────────────────────── */

#event-log { width: 100%; flex: 1; }
.log-ttl   { font-size: 8px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.log-entry {
  font-size: 10px;
  color: var(--ki);
  padding: 4px 8px;
  background: var(--panel);
  border-left: 2px solid var(--ki)88;
  line-height: 1.4;
  margin-bottom: 2px;
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* ── Technique cards ──────────────────────────────────────── */

.tech-card {
  padding: 7px 11px;
  border-bottom: 1px solid var(--dim2);
  transition: background 0.12s;
  position: relative;
  overflow: hidden;
}
.tech-card.can-buy        { background: var(--panel); cursor: pointer; }
.tech-card.can-buy:hover  { background: var(--panel2); }
.tech-card.cant-buy       { opacity: 0.33; cursor: default; }
.tech-card.is-locked      { opacity: 0.2; cursor: default; }
.tech-card.is-owned       { opacity: 0.45; cursor: default; background: transparent; }

.tc-row  { display: flex; justify-content: space-between; align-items: baseline; gap: 5px; margin-bottom: 2px; }
.tc-name { font-size: 11px; font-weight: 600; }
.tc-cost { font-size: 10px; white-space: nowrap; flex-shrink: 0; }
.tc-desc { font-size: 9px; color: var(--muted); line-height: 1.35; }

.tc-lock {
  font-size: 8px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
  opacity: 0.8;
}

/* ── Milestone flash overlay ──────────────────────────────── */

#mflash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s;
}
#mflash.show { opacity: 1; pointer-events: auto; }
.mf-box {
  background: var(--panel);
  border: 2px solid var(--gold);
  box-shadow: 0 0 48px var(--gold)44, 0 0 120px var(--gold)1a;
  padding: 22px 36px;
  text-align: center;
  max-width: 320px;
  cursor: pointer;
}
.mf-eyebrow { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 0.18em; color: var(--gold); margin-bottom: 4px; opacity: 0.7; }
.mf-name    { font-family: 'Orbitron', monospace; font-size: 22px; font-weight: 700; color: var(--gold); margin-bottom: 6px; }
.mf-ki      { font-size: 15px; color: var(--ki); margin-bottom: 8px; }
.mf-msg     { font-size: 10px; color: var(--muted); line-height: 1.6; }

/* ── Skill Tree ───────────────────────────────────────────── */

.skill-pts-badge {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  color: var(--gold);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.st-paths {
  display: flex;
  height: 420px;
  overflow: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}

.st-path {
  min-width: 108px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-right: 1px solid var(--dim2);
}
.st-path:last-child { border-right: none; }

.st-path-hdr {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 7px 2px 6px;
  border-bottom: 1px solid;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}

.st-connector {
  width: 1px;
  height: 10px;
  border-left: 1px dashed transparent;
  align-self: center;
}

.skill-node {
  margin: 3px 4px 0;
  padding: 5px 5px;
  border: 1px solid var(--dim);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}
.skill-node.can-buy {
  border-color: var(--jade);
  background: var(--panel);
  box-shadow: 0 0 5px var(--jade)33;
}
.skill-node.can-buy:hover { background: var(--panel2); }
.skill-node.cant-buy      { opacity: 0.33; cursor: default; }
.skill-node.is-locked     { opacity: 0.14; cursor: default; }
.skill-node.is-owned      { opacity: 0.55; cursor: default; border-color: var(--dim2); }
.skill-node.is-owned::after {
  content: '✓';
  position: absolute;
  top: 2px; right: 3px;
  font-size: 8px;
  color: var(--jade);
}

.sk-header {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.sk-name {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.sk-type {
  font-size: 7px;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 1px;
  flex-shrink: 0;
  line-height: 1.3;
}
.sk-type.passive { background: #172540; color: #6090c0; }
.sk-type.active  { background: #2a0d05; color: var(--fire2); }
.sk-cost {
  font-family: 'Orbitron', monospace;
  font-size: 7px;
  color: var(--gold);
  flex-shrink: 0;
  line-height: 1.4;
}
.sk-desc {
  font-size: 8px;
  color: var(--muted);
  line-height: 1.3;
}
.sk-active-btn {
  margin-top: 4px;
  width: 100%;
  padding: 2px 0;
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  letter-spacing: 0.1em;
  background: var(--fire);
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 1px;
}
.sk-active-btn:disabled { background: var(--dim); color: var(--muted); cursor: default; }
.sk-active-btn:not(:disabled):hover { background: var(--fire2); }

/* ── Combat Panel ─────────────────────────────────────────── */

#combat-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--dim);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cbt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
}
.cbt-label {
  font-family: 'Orbitron', monospace;
  font-size: 7px;
  letter-spacing: 0.12em;
  font-weight: 700;
  flex-shrink: 0;
}
.cbt-enemy-label  { color: var(--danger); }
.cbt-player-label { color: var(--jade); }
.cbt-name  { font-size: 10px; font-weight: 600; flex: 1; }
.cbt-wave  { font-size: 8px; color: var(--muted); flex-shrink: 0; }
.cbt-regen { font-size: 8px; color: var(--jade);  flex-shrink: 0; }

.cbt-bar-wrap {
  position: relative;
  height: 12px;
  background: var(--dim2);
  overflow: hidden;
}
.cbt-fill {
  height: 100%;
  transition: width 0.15s linear;
}
.cbt-enemy  { background: var(--danger); }
.cbt-player { background: var(--jade); }
.cbt-player.cbt-low { background: var(--fire); animation: hpPulse 0.6s ease-in-out infinite; }
@keyframes hpPulse { 0%,100%{opacity:1} 50%{opacity:0.55} }
.cbt-hp-txt {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  font-size: 7px;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.cbt-mid {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
}
.cbt-dps  { color: var(--jade); }
.cbt-atk  { color: var(--danger); }

/* ── Death Screen ─────────────────────────────────────────── */

#death-screen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#death-screen.hidden { display: none; }

.ds-box {
  background: var(--panel);
  border: 2px solid var(--danger);
  box-shadow: 0 0 60px var(--danger)33;
  padding: 24px 28px;
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}
.ds-title {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 900;
  color: var(--danger);
  text-shadow: 0 0 20px var(--danger)66;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.ds-flavour { font-size: 10px; color: var(--muted); margin-bottom: 12px; }
.ds-stats { font-size: 11px; color: var(--text); line-height: 1.8; margin-bottom: 10px; }
.ds-stats b { color: var(--fire2); }
.ds-sm-row  { font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.ds-sm-val  { font-family: 'Orbitron', monospace; color: var(--gold); font-size: 13px; }
.ds-shop-title {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--ki);
  margin-bottom: 8px;
}
#ds-shop { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.ds-group { font-family: 'Orbitron', monospace; font-size: 9px; letter-spacing: 0.16em; color: var(--gold); text-transform: uppercase; margin-top: 6px; border-bottom: 1px solid var(--dim); padding-bottom: 2px; }
.ds-upg-desc { font-size: 9px; color: var(--muted); }
#rr-reroll { font-family: 'Orbitron', monospace; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; background: transparent; color: #b89cff; border: 1px solid #b89cff; padding: 8px; cursor: pointer; }
.ds-upg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg2);
  border: 1px solid var(--dim);
}
.ds-upg-maxed { opacity: 0.4; }
.ds-upg-icon  { font-size: 16px; flex-shrink: 0; }
.ds-upg-info  { flex: 1; font-size: 10px; }
.ds-upg-name  { font-weight: 600; }
.ds-upg-lv    { color: var(--muted); font-size: 9px; }
.ds-upg-eff   { color: var(--jade);  font-size: 9px; }
.ds-upg-maxed-txt { color: var(--gold); font-size: 9px; }
.ds-upg-btn {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  padding: 4px 8px;
  background: var(--fire);
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.ds-upg-btn.ds-disabled { background: var(--dim); color: var(--muted); cursor: default; }
.ds-upg-btn:not(.ds-disabled):hover { background: var(--fire2); }
#ds-btn {
  width: 100%;
  padding: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: var(--fire);
  color: #fff;
  border: none;
  cursor: pointer;
}
#ds-btn:hover { background: var(--fire2); }

/* ── Spirit Stones resource ───────────────────────────────── */

.res-num.ss { color: #ffaa22; text-shadow: 0 0 10px #ffaa2266; }

/* ── Secret Technique Popup ───────────────────────────────── */

#st-popup {
  position: fixed;
  inset: 0;
  background: #0009;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}
#st-popup.hidden { display: none; }

.st-box {
  background: var(--panel2);
  border: 1px solid var(--dim);
  border-top: 2px solid #ffaa22;
  padding: 24px 32px;
  width: 300px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 0 60px #ffaa2233;
}

.st-eyebrow { font-family: 'Orbitron', monospace; font-size: 8px; letter-spacing: 0.2em; color: #ffaa22; opacity: 0.7; }
.st-desc    { font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ── Secret Arts ──────────────────────────────────────────── */

.sa-head  { background: #1a1428; border-top: 1px solid #ffaa2244; }
.sa-empty { font-size: 10px; color: var(--muted); padding: 8px 10px; letter-spacing: 0.06em; }

#secret-arts-list {
  padding: 4px 0;
  overflow-y: auto;
  max-height: 160px;
  flex-shrink: 0;
}

.sa-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--dim2);
}
.sa-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.sa-name { font-size: 10px; font-weight: 600; }
.sa-desc { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-btn  { font-family:'Orbitron',monospace; font-size:8px; font-weight:700; background:var(--jade); color:#000; border:none; padding:3px 7px; cursor:pointer; border-radius:2px; flex-shrink:0; }
.sa-btn:hover { filter: brightness(1.15); }

/* ── Spirit Market ────────────────────────────────────────── */

.shop-head { background: #100e1a; border-top: 1px solid #ffaa2244; }


.shop-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.shop-name { font-size: 10px; font-weight: 600; color: var(--text); }
.shop-desc { font-size: 9px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-btn  {
  font-family: 'Orbitron', monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: #ffaa22;
  color: #000;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 2px;
  flex-shrink: 0;
  white-space: nowrap;
}
.shop-btn:hover:not(:disabled) { filter: brightness(1.15); }
.shop-btn:disabled {
  background: var(--dim);
  color: var(--muted);
  cursor: not-allowed;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 800px) {
  #game   { height: auto; overflow: visible; }
  html, body { height: auto; }
  #main {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  #skills-col { overflow-y: visible; }
  #arena-col { overflow-y: visible; }
}
