/* PALPEDIA design system — translated from the approved "Pal Page v2" mock. */

:root {
  --bg: #0b1622;
  --panel: #0f1e2c;
  --panel-deep: #0d1a26;
  --panel-glass: rgba(9, 20, 30, 0.55);
  --ink: #dfeaf2;
  --muted: #93b0c1;
  --soft: #9fb6c4;
  --faint: #55707f;
  --label: #6c8a9b;
  --line: #1e3a4d;
  --line-lit: #2a5670;
  --line-bright: #2f6f95;
  --accent: #4fc3ee;
  --accent-dim: rgba(79, 195, 238, 0.12);
  --night: #a99bff;
  --hot: #ff9a5c;
  --good: #62d9a6;
  --bar-hp: #62d9a6;
  --bar-atk: #ffb060;
  --bar-def: #4fc3ee;
  --map-color: var(--accent);
  --map-void: #0a1622;   /* matches the tile-fill BG baked in by pipeline/assets/tiles.py */
  --scroll-thumb: #244a60;

  --el-neutral: #b8a88f;
  --el-fire: #ff7a45;
  --el-water: #3d9ae8;
  --el-grass: #7ec941;
  --el-electric: #f2c94c;
  --el-ice: #4fc3ee;
  --el-ground: #c98a4a;
  --el-dark: #c94a6e;
  --el-dragon: #b07de0;

  --font-head: 'Chakra Petch', sans-serif;
  --font-body: 'Rubik', sans-serif;
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #8adcf9; }
input[type="range"] { accent-color: var(--accent); width: 100%; margin: 0; }
select {
  font-family: var(--font-body);
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-lit);
  background: var(--panel); color: var(--ink); font-size: 14px;
}
button { font-family: inherit; }
[hidden] { display: none !important; }

@keyframes pingPulse {
  0% { transform: scale(0.5); opacity: 0.9; }
  70% { transform: scale(2.3); opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- shell ---------- */

.topbar {
  background: #081019;
  border-bottom: 1px solid var(--line);
  padding: 10px clamp(12px, 3vw, 32px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand {
  font-family: var(--font-head); font-weight: 700; font-size: 16px;
  letter-spacing: 2px; color: var(--accent);
}
.crumb { font-size: 12.5px; color: var(--faint); }
.crumb a { color: var(--faint); }
.crumb a:hover { color: var(--accent); }
.data-chip {
  font-size: 11px; letter-spacing: 1.5px; color: var(--faint);
  font-family: var(--font-head); white-space: nowrap;
}

.site-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.site-nav a {
  font-family: var(--font-head); font-size: 11.5px; letter-spacing: 1px; font-weight: 600;
  color: var(--soft); padding: 5px 10px; border: 1px solid transparent; white-space: nowrap;
}
.site-nav a:hover, .site-nav a.active {
  color: var(--accent); border-color: var(--line-lit); background: #0f2233;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px clamp(12px, 3vw, 32px) 48px; }

.footer {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between;
  padding-top: 18px; font-size: 12px; color: var(--faint); width: 100%;
}

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
  min-width: 300px;
}
.panel-wide { flex: 999 1 560px; }
.panel-slim { flex: 1 1 280px; min-width: 260px; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  background: var(--panel-deep);
}
.panel-head .bar { width: 4px; height: 16px; background: var(--accent); flex: none; }
.panel-head h2 {
  font-family: var(--font-head); font-size: 15px; letter-spacing: 2px;
  margin: 0; font-weight: 700; flex: 1;
}
.panel-body { padding: 14px 18px; }

.section-label {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px;
  color: var(--label); display: flex; align-items: center; gap: 5px;
}

/* ---------- chips & badges ---------- */

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.chip-dex {
  font-family: var(--font-head); font-size: 12px; letter-spacing: 2.5px;
  color: var(--accent); background: var(--accent-dim);
  border: 1px solid rgba(79, 195, 238, 0.4); padding: 3px 10px;
}
.chip-outline {
  font-family: var(--font-head); font-size: 12px; letter-spacing: 2.5px;
  color: var(--soft); border: 1px solid var(--line-lit); padding: 3px 10px;
  display: inline-flex; align-items: center;
}
.chip-desc {
  display: inline-flex; align-items: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-lit);
  padding: 4px 12px; font-size: 13px; color: #b8ccd8;
}
.chip-link {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1.5px; font-weight: 600;
  color: var(--accent); border: 1px solid var(--line-bright);
  background: rgba(79, 195, 238, 0.1); padding: 4px 10px;
}
.chip-link:hover { background: rgba(79, 195, 238, 0.22); color: var(--accent); }

.el-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; font-size: 13px; font-weight: 500; cursor: pointer;
  background: #14384e; border: 1px solid var(--line-bright); color: #a8e2fb;
}
.el-chip:hover { background: #1b4a66; }
.el-chip .diamond { width: 8px; height: 8px; transform: rotate(45deg); flex: none; }
.el-chip.small { padding: 2px 8px; font-size: 11px; gap: 5px; font-family: var(--font-head); font-weight: 600; }
.el-chip.small .diamond { width: 7px; height: 7px; }

.weak-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 154, 92, 0.1); border: 1px solid rgba(255, 154, 92, 0.4);
  padding: 4px 12px; font-size: 13px; font-weight: 500; color: #ffb98c; cursor: pointer;
}
.weak-chip:hover { background: rgba(255, 154, 92, 0.2); }

.el-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-head); font-size: 10px; font-weight: 600;
}
.el-tag .diamond { width: 7px; height: 7px; transform: rotate(45deg); }

.grade-pair {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-lit);
  padding: 3px 4px 3px 12px; font-size: 13px; color: #b8ccd8;
}
.grade-pair .k {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; color: var(--label);
}
.grade-pair .v {
  font-family: var(--font-head); font-size: 12px; font-weight: 700;
  color: #08151f; background: var(--accent); padding: 3px 9px;
}
.grade-pair .v.grade-hot { background: var(--hot); }
.grade-pair .v.grade-top {
  background: #ff6b6b; color: #fff; box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}
.grade-pair .v.grade-na { background: #22384a; color: var(--soft); }

.passive-chip {
  background: #14384e; border: 1px solid var(--line-bright); color: #a8e2fb;
  padding: 3px 10px; font-size: 12px; font-weight: 500; display: inline-block;
}

/* ---------- help tooltips ---------- */

.tip { position: relative; display: inline-flex; align-items: center; vertical-align: middle; }
.tip-btn {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line-bright); color: var(--accent);
  font-size: 10px; font-weight: 700; font-family: var(--font-head);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: help; background: var(--panel-deep); flex: none; padding: 0;
}
.tip-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: min(240px, 72vw); background: #081019; border: 1px solid var(--line-bright);
  color: #cfe0ea; font-family: var(--font-body); font-weight: 400; font-size: 12px;
  line-height: 1.5; letter-spacing: normal; text-transform: none; text-align: left;
  padding: 9px 11px; z-index: 60; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  white-space: normal;
}
.tip-pop.up { top: auto; bottom: calc(100% + 8px); }
/* header tips sit at the panel's right edge; anchor their popup rightward so
   the panel clip-path can't cut it off */
.panel-head .tip-pop, .modal-head .tip-pop, .calc-box .title .tip-pop { left: auto; right: 0; }

/* ---------- hero ---------- */

.hero {
  background: linear-gradient(120deg, #0d1e2e 0%, #113a54 70%, #15516f 100%);
  border-bottom: 1px solid var(--line); position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(-55deg, transparent 0 26px, rgba(79, 195, 238, 0.045) 26px 28px),
    radial-gradient(500px 260px at 90% 0%, rgba(79, 195, 238, 0.14), transparent 70%);
}
.hero-inner {
  max-width: 1180px; margin: 0 auto;
  padding: clamp(16px, 2.5vw, 28px) clamp(12px, 3vw, 32px);
  position: relative; display: flex; flex-wrap: wrap;
  gap: clamp(16px, 2.5vw, 28px); align-items: stretch;
}
.hero-art { flex: 0 0 auto; width: min(190px, 42vw); display: flex; flex-direction: column; gap: 8px; position: relative; }
.alpha-badge {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}
.alpha-badge img { width: 100%; height: 100%; display: block; }
.hero-art .alpha-badge { top: 10px; right: 10px; width: 30px; height: 30px; }
.frame {
  width: 100%; aspect-ratio: 1;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  background: rgba(9, 20, 30, 0.6); border: 1px solid var(--line-lit);
  padding: 6px; box-sizing: border-box; display: flex;
}
.frame img { width: 100%; height: 100%; object-fit: contain; }
.frame .placeholder {
  width: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-family: var(--font-head); font-size: 11px; letter-spacing: 1px;
}
.partner-card {
  background: var(--panel-glass); border: 1px solid #21455c;
  border-left: 3px solid var(--accent); padding: 9px 11px;
}
.partner-card .name { font-weight: 600; font-size: 14px; margin-top: 2px; }
.partner-card .desc { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; text-wrap: pretty; }

.hero-main {
  flex: 1 1 300px; min-width: 260px;
  display: flex; flex-direction: column; justify-content: center; gap: 10px;
}
.hero-main h1 {
  font-family: var(--font-head); font-size: clamp(30px, 4.5vw, 44px);
  font-weight: 700; margin: 0; line-height: 1;
}
.hero-main .flavor {
  margin: 2px 0 0; max-width: 58ch; color: var(--muted);
  font-size: 13.5px; line-height: 1.5; text-wrap: pretty;
}

.hero-side {
  flex: 1 1 240px; min-width: 220px;
  display: flex; flex-direction: column; gap: 7px; justify-content: center;
  background: var(--panel-glass); border: 1px solid #21455c; padding: 12px 14px;
}
.hero-side .rule { height: 1px; background: var(--line); margin: 2px 0; }

.work-row { display: flex; align-items: center; gap: 8px; }
.work-row .label { flex: 1; font-size: 13px; font-weight: 500; }
.work-pips { display: flex; gap: 3px; }
.work-pips span { width: 10px; height: 10px; background: #12293a; }
.work-pips span.on { background: var(--accent); }
.work-row .lv {
  font-family: var(--font-head); font-weight: 600; font-size: 12px;
  width: 26px; text-align: right; color: var(--accent);
}
.kv-row { display: flex; align-items: center; justify-content: space-between; }
.kv-row .k { font-size: 13px; font-weight: 600; }
.kv-row .v { font-size: 12px; color: var(--label); }

/* ---------- sticky section nav ---------- */

.section-nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(8, 16, 25, 0.93); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.section-nav .inner {
  max-width: 1180px; margin: 0 auto; display: flex; gap: 4px;
  overflow-x: auto; padding: 8px clamp(12px, 3vw, 32px);
}
.section-nav a {
  white-space: nowrap; font-family: var(--font-head); font-size: 12.5px;
  letter-spacing: 1px; font-weight: 600; color: var(--soft);
  padding: 6px 13px; border: 1px solid transparent;
}
.section-nav a:hover, .section-nav a.active {
  color: var(--accent); border-color: var(--line-lit); background: #0f2233;
}

.page-main { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.page-main > section { scroll-margin-top: 56px; }

/* ---------- stats panel ---------- */

.stats-grid { display: flex; flex-wrap: wrap; gap: 20px; padding: 16px 18px; }
.stats-col { flex: 1 1 230px; min-width: 220px; }
.stats-col.readout { display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.slider-head label {
  font-family: var(--font-head); font-size: 12px; letter-spacing: 1.5px; color: var(--label);
}
.slider-head .big { font-family: var(--font-head); font-weight: 700; font-size: 24px; color: var(--accent); }
.iv-sliders { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.iv-row .head { display: flex; justify-content: space-between; margin-bottom: 2px; }
.iv-row label { font-size: 12.5px; color: var(--muted); }
.iv-row .val { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.iv-buttons { display: flex; gap: 6px; margin-top: 14px; }
.btn-ghost, .btn-solid {
  flex: 1; font-family: var(--font-head); font-size: 12px; letter-spacing: 1px;
  font-weight: 600; padding: 8px 0; cursor: pointer;
}
.btn-ghost { border: 1px solid var(--line-lit); background: transparent; color: var(--soft); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-solid { border: 1px solid var(--accent); background: var(--accent); color: #08151f; }

.stat-readout .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.stat-readout .k {
  font-size: 11px; letter-spacing: 1.5px; font-family: var(--font-head); color: var(--label);
}
.stat-readout .v { font-family: var(--font-head); font-weight: 700; font-size: 24px; }
.stat-readout .track { height: 8px; background: #12293a; overflow: hidden; }
.stat-readout .fill { height: 100%; width: 0%; }
.stat-readout.hp .v { color: var(--bar-hp); }
.stat-readout.hp .fill { background: linear-gradient(90deg, #2fa87c, var(--bar-hp)); }
.stat-readout.atk .v { color: var(--bar-atk); }
.stat-readout.atk .fill { background: linear-gradient(90deg, #dd7f38, var(--bar-atk)); }
.stat-readout.def .v { color: var(--bar-def); }
.stat-readout.def .fill { background: linear-gradient(90deg, #2e9dc8, var(--bar-def)); }
.stats-note { font-size: 11.5px; color: var(--faint); }

/* ---------- location panel ---------- */

.loc-legend {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1px;
}
.loc-legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--soft); }
.loc-legend .dot { width: 8px; height: 8px; border-radius: 50%; }
.loc-body { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 18px; }

.map-view {
  flex: 1.4 1 320px; min-width: 280px; max-width: 460px; position: relative;
  aspect-ratio: 1; align-self: flex-start;
  border: 1px solid #21455c; overflow: hidden; background: #0a1622;
}
/* the world map is square; a square container keeps %-markers exact */
.map-view img.map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.map-tag {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px; color: #cfe0ea;
  background: rgba(8, 16, 25, 0.82); border: 1px solid var(--line-lit); padding: 3px 8px;
}
.map-zone-tag {
  font-family: var(--font-head); font-size: 11px; font-weight: 600; color: var(--map-color);
  background: rgba(8, 16, 25, 0.82); border: 1px solid var(--line-lit); padding: 3px 8px;
}
.map-labels { position: absolute; top: 8px; left: 8px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.map-expand {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(8, 16, 25, 0.82); border: 1px solid var(--line-lit);
  color: #cfe0ea; cursor: pointer; font-size: 15px;
}
.map-marker { position: absolute; width: 16px; height: 16px; pointer-events: none; transform: translate(-50%, -50%); }
.map-marker .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--map-color); animation: pingPulse 1.9s ease-out infinite;
}
.map-marker .core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--map-color); box-shadow: 0 0 8px var(--map-color);
}
.map-coords {
  position: absolute; bottom: 8px; left: 8px; display: flex; flex-wrap: wrap; gap: 4px;
  max-width: 30%; pointer-events: none;
}
.coord-chip {
  font-family: var(--font-head); font-size: 11px; font-weight: 600; color: var(--map-color);
  background: rgba(8, 16, 25, 0.85); border: 1px solid var(--line-lit); padding: 2px 7px;
}
.map-pager {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: rgba(8, 16, 25, 0.82); border: 1px solid var(--line-lit); padding: 3px 6px;
}
.map-pager button {
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: #cfe0ea; cursor: pointer; font-size: 16px;
}
.map-pager .idx {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1px; color: var(--soft);
  min-width: 34px; text-align: center;
}

.loc-cards { flex: 1 1 230px; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.loc-card {
  background: var(--panel-deep); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); padding: 9px 12px;
}
.loc-card.warn { border-left-color: var(--hot); }
.loc-card .t { font-weight: 600; font-size: 13.5px; }
.loc-card .d { font-size: 12px; color: var(--label); }
.loc-card.sphere {
  background: rgba(79, 195, 238, 0.07); border: 1px solid var(--line-bright);
  display: flex; align-items: center; gap: 10px;
}
.loc-card.sphere .dot { width: 9px; height: 9px; background: var(--accent); border-radius: 50%; flex: none; }
.loc-card.sphere .t { color: #a8e2fb; }

/* ---------- breeding panel ---------- */

.breed-body { display: flex; flex-wrap: wrap; gap: 16px; padding: 14px 18px; }
.breed-col { flex: 1 1 240px; min-width: 230px; }
.combo-list { display: flex; flex-direction: column; gap: 6px; }
.combo-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-deep); border: 1px solid var(--line);
  padding: 8px 12px; font-size: 13px;
}
.combo-row .p { font-weight: 600; flex: 1; }
.combo-row .p.r { text-align: center; }
.combo-row .plus { color: var(--faint); }
.combo-row .ok { color: var(--good); font-family: var(--font-head); font-weight: 700; }
.combo-row .gender { font-size: 10px; color: var(--night); font-family: var(--font-head); }
.breed-note { font-size: 12px; color: var(--faint); margin-top: 8px; text-wrap: pretty; }

.calc-box { background: var(--panel-deep); border: 1px solid #21455c; padding: 14px 16px; }
.calc-box .title {
  font-size: 11px; letter-spacing: 1.5px; color: var(--accent);
  font-family: var(--font-head); margin-bottom: 10px;
  display: flex; align-items: center; gap: 5px;
}
.calc-field label { font-size: 11.5px; color: var(--label); display: block; margin-bottom: 3px; }
.calc-fields { display: flex; flex-direction: column; gap: 8px; }
.egg-result {
  margin-top: 12px; border: 1px solid var(--line-bright);
  background: rgba(79, 195, 238, 0.07); padding: 12px 14px; text-align: center;
}
.egg-result .k {
  font-size: 10px; letter-spacing: 2px; color: var(--accent);
  font-family: var(--font-head); margin-bottom: 4px;
}
.egg-result .child { font-family: var(--font-head); font-weight: 700; font-size: 20px; }
.egg-result .note { font-size: 12px; color: var(--label); margin-top: 2px; }

/* breeding explorer (unified Parent + Parent = Child picker) */
.bx-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.bx-body .breed-note { margin-top: 0; }
.bx-slots { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.bx-op {
  font-family: var(--font-head); font-size: 22px; font-weight: 700;
  color: var(--faint); padding-bottom: 12px; flex: none;
}
.bx-op.eq { color: var(--accent); }
.bx-slot { position: relative; flex: 1 1 200px; min-width: 170px; }
.bx-slot-label {
  font-family: var(--font-head); font-size: 10.5px; letter-spacing: 1.5px;
  color: var(--label); margin-bottom: 4px;
}
.bx-face {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 9px;
  background: var(--panel-deep); border: 1px solid var(--line-lit);
  color: var(--ink); font: inherit; cursor: pointer; text-align: left;
}
.bx-face:hover, .bx-face.open { border-color: var(--accent); }
.bx-face-icon {
  width: 34px; height: 34px; border-radius: 50%; flex: none; overflow: hidden;
  background: #0a2233; border: 1px solid var(--line-lit);
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-family: var(--font-head); font-weight: 700;
}
.bx-face-icon img { width: 100%; height: 100%; object-fit: cover; }
.bx-face-name { flex: 1; font-weight: 600; font-size: 13.5px; min-width: 0; }
.bx-face-name.any { color: var(--faint); font-weight: 400; }
.bx-pop {
  /* portaled to <body> and placed by JS — the panel's clip-path would clip it */
  position: fixed; z-index: 90;
  background: var(--panel); border: 1px solid var(--accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.bx-search {
  width: 100%; padding: 8px 10px; background: var(--panel-deep);
  border: 0; border-bottom: 1px solid var(--line-lit);
  color: var(--ink); font-family: var(--font-body); font-size: 13px;
}
.bx-search:focus { outline: none; }
.bx-opts { max-height: 290px; overflow-y: auto; }
.bx-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 10px;
  background: none; border: 0; color: var(--ink); font: inherit; font-size: 13px;
  cursor: pointer; text-align: left;
}
.bx-opt:hover { background: var(--accent-dim); }
.bx-opt img { width: 26px; height: 26px; border-radius: 50%; flex: none; background: #0a2233; }
.bx-opt .n { flex: 1; min-width: 0; }
.bx-opt .d { color: var(--faint); font-size: 10.5px; font-family: var(--font-head); flex: none; }
.bx-opt-any { color: var(--faint); padding: 7px 10px; }
.bx-btn {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1.5px; font-weight: 600;
  color: var(--accent); border: 1px solid var(--line-bright); background: transparent;
  padding: 6px 14px; cursor: pointer;
}
.bx-btn:hover { background: rgba(79, 195, 238, 0.22); }
.bx-mode { margin-left: auto; }
.bx-mode, .bx-mode-alt, #bx-reset { margin-bottom: 7px; flex: none; }
.bx-statusrow { display: flex; align-items: center; gap: 10px; }
.bx-status {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1.5px;
  color: var(--label); min-height: 14px; flex: 1; min-width: 0;
}
.bx-view { padding: 4px 11px; font-size: 10px; flex: none; }
.bx-more { align-self: center; }
.bx-results {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 980px) { .bx-results { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .bx-results { grid-template-columns: 1fr; } }
.bx-hint {
  grid-column: 1 / -1; text-align: center; padding: 34px 16px;
  color: var(--faint); border: 1px dashed var(--line-lit); font-size: 13px;
}
.bx-row {
  align-items: flex-start; padding: 14px 8px 12px; gap: 4px;
  position: relative; border-color: var(--line-lit); border-radius: 3px;
  background: linear-gradient(180deg, #10202f 0%, var(--panel-deep) 100%);
}
.bx-row:hover { border-color: var(--line-bright); }
.bx-row .bx-pal {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1; color: var(--ink); font-weight: 600; min-width: 0;
  font-size: 12px; text-align: center; line-height: 1.25;
}
.bx-row .bx-pal:hover .n { color: var(--accent); }
.bx-row .bx-pal img {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: #0a2233; border: 1px solid var(--line-lit);
}
.bx-row .plus { margin-top: 14px; flex: none; }
.bx-row .eq { color: var(--accent); font-weight: 700; }
@media (max-width: 640px) {
  .bx-slot { max-width: none; }
  .bx-op { padding-bottom: 14px; }
}

/* chain modes (shortest path / passive breeder) */
.bx-slots.path-on .bx-slot[data-slot="a"],
.bx-slots.path-on .bx-slot[data-slot="b"],
.bx-slots.path-on .bx-op { display: none; }
/* the passive source slot only exists in passive mode */
.bx-slot[data-slot="p"], .bx-op.arrow { display: none; }
.bx-slots.passive-on .bx-slot[data-slot="p"],
.bx-slots.passive-on .bx-op.arrow { display: block; }
.bx-slots.passive-on .bx-slot[data-slot="a"],
.bx-slots.passive-on .bx-slot[data-slot="b"],
.bx-slots.passive-on .bx-op:not(.arrow) { display: none; }
.bx-op.arrow { color: var(--night); }
.bx-mode.on, .bx-mode-alt.on { background: rgba(79, 195, 238, 0.22); border-color: var(--accent); }
.step-card { padding-top: 24px; }
.step-badge {
  position: absolute; top: 0; left: 0; padding: 2px 8px 3px;
  font-family: var(--font-head); font-size: 10.5px; font-weight: 700;
  letter-spacing: 1px; color: #0b1622; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.step-lock {
  position: absolute; top: 3px; right: 6px;
  font-family: var(--font-head); font-size: 8.5px; letter-spacing: 1px;
  color: var(--night);
}
.own-tag {
  font-family: var(--font-head); font-size: 8.5px; letter-spacing: 1px;
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 2px;
  color: var(--label);
}
.own-tag.owned { color: var(--good); border-color: rgba(98, 217, 166, 0.4); }
.own-tag.step { color: var(--accent); border-color: rgba(79, 195, 238, 0.4); }
.own-tag.target { color: #0b1622; background: var(--good); border-color: var(--good); font-weight: 700; }
.own-tag.passive { color: var(--night); border-color: rgba(169, 155, 255, 0.45); }
/* a step whose child has to inherit the passive — reroll it until it does */
.step-card.carries { border-color: rgba(169, 155, 255, 0.4); }
.step-card.carries .step-badge { background: var(--night); }

/* lineage view */
.bx-tree { grid-column: 1 / -1; padding: 4px 2px; overflow-x: auto; }
.bx-tree ul { list-style: none; margin: 0; padding: 0; }
.bx-tree ul ul { padding-left: 34px; }
.bx-tree li { position: relative; padding: 4px 0; }
/* elbow into each nested node, plus the run-on down to the next sibling */
.bx-tree ul ul > li::before {
  content: ''; position: absolute; left: -20px; top: 0; width: 16px; height: 21px;
  border-left: 1px solid var(--line-lit); border-bottom: 1px solid var(--line-lit);
}
.bx-tree ul ul > li:not(:last-child)::after {
  content: ''; position: absolute; left: -20px; top: 21px; bottom: 0;
  border-left: 1px solid var(--line-lit);
}
.tree-node {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  background: var(--panel-deep); border: 1px solid var(--line-lit); border-radius: 3px;
  color: var(--ink); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.tree-node:hover { border-color: var(--accent); }
.tree-node img { width: 28px; height: 28px; border-radius: 50%; flex: none; background: #0a2233; }
.tree-node .gender { color: var(--faint); font-weight: 400; }
.tree-node.is-carrier { border-color: rgba(169, 155, 255, 0.45); }
.tree-node.is-target { border-color: var(--good); }

.own-bar {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--panel-deep); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.own-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.own-label {
  font-family: var(--font-head); font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; color: var(--accent);
}
.own-hint { font-size: 11.5px; color: var(--faint); flex: 1; min-width: 160px; }
.own-clear { padding: 3px 10px; font-size: 10px; }
.own-search {
  width: min(320px, 100%); padding: 7px 10px; background: var(--bg);
  border: 1px solid var(--line-lit); color: var(--ink);
  font-family: var(--font-body); font-size: 13px;
}
.own-search:focus { outline: none; border-color: var(--accent); }
.own-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.own-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px;
  background: rgba(9, 20, 30, 0.5); border: 1px solid var(--line-lit);
  color: var(--ink); font: inherit; font-size: 12px; cursor: pointer; border-radius: 2px;
}
.own-chip:hover { border-color: var(--hot); }
.own-chip:hover .x { color: var(--hot); }
.own-chip img { width: 22px; height: 22px; border-radius: 50%; background: #0a2233; }
.own-chip .x { color: var(--faint); font-size: 11px; }
.own-empty { font-size: 12px; color: var(--faint); }
.own-pop { max-height: 300px; overflow-y: auto; }

/* ---------- skills panel ---------- */

.skills-list { padding: 8px 10px; display: flex; flex-direction: column; }
.skill-grid-head, .skill-row {
  display: grid; grid-template-columns: 38px 1fr 40px 40px;
  gap: 8px; align-items: center;
}
.skill-grid-head {
  padding: 3px 8px 5px; font-family: var(--font-head); font-size: 9px;
  letter-spacing: 1px; color: var(--faint); border-bottom: 1px solid var(--line);
}
.skill-legend { padding: 4px 8px 6px; font-size: 10px; color: var(--faint); }
.skill-row { padding: 7px 8px; font-size: 13px; }
.skill-row:hover { background: #12293a; }
.skill-row .lv { font-size: 11px; color: var(--faint); font-weight: 600; }
.skill-row .name-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-row .name-cell a { font-weight: 600; color: var(--ink); }
.skill-row .name-cell a:hover { color: var(--accent); text-decoration: underline; }
.skill-row .el { font-size: 10px; margin-left: 4px; }
.skill-row .pwr { text-align: right; font-weight: 600; color: var(--bar-atk); }
.skill-row .ct { text-align: right; font-size: 11px; color: var(--faint); }
.skills-rule { height: 1px; background: var(--line); margin: 6px 8px; }
.best-passives { padding: 6px 8px 8px; }

/* ---------- modals ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(4, 10, 16, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 32px);
}
.modal-dialog {
  position: relative; border: 1px solid var(--line-bright); background: #0a1622;
  width: min(880px, 94vw); max-height: 88vh; overflow: auto;
}
.modal-dialog.map-modal {
  width: min(680px, 94vw, 88vh); aspect-ratio: 1; height: auto; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel-deep);
  position: sticky; top: 0; z-index: 2;
}
.modal-head .bar { width: 4px; height: 16px; background: var(--accent); }
.modal-head h2 {
  font-family: var(--font-head); font-size: 14px; letter-spacing: 2px;
  margin: 0; font-weight: 700; flex: 1;
}
.modal-close {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line-lit); color: #cfe0ea;
  cursor: pointer; font-size: 15px; flex: none;
}
.map-modal .map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.map-modal .overlay-labels { position: absolute; top: 10px; left: 10px; display: flex; gap: 8px; pointer-events: none; }
.map-modal .modal-close { position: absolute; top: 10px; right: 10px; background: rgba(8, 16, 25, 0.85); border-color: var(--line-lit); z-index: 3; }
.map-modal .arrow-toggle {
  position: absolute; top: 52px; right: 10px; z-index: 3;
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; padding: 6px 10px;
  background: rgba(8, 16, 25, 0.85); border: 1px solid var(--line-lit);
  color: var(--soft); cursor: pointer;
}
.map-modal svg.arrow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-modal .center-dot {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid #cfe0ea; background: rgba(8, 16, 25, 0.6); pointer-events: none;
}
.map-modal .center-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -170%);
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; color: var(--soft);
  pointer-events: none; white-space: nowrap;
}
.map-modal .map-pager { bottom: 12px; padding: 6px 10px; }
.map-modal .map-marker { width: 18px; height: 18px; }
.map-modal .map-marker .core { width: 10px; height: 10px; }

.typechart-body { padding: 16px; display: flex; flex-wrap: wrap; gap: 16px; }
.typechart-img {
  flex: 1.5 1 340px; min-width: 280px; min-height: 300px;
  border: 1px solid #21455c; background: #081019;
  display: flex; align-items: center; justify-content: center;
}
.typechart-img img { max-width: 100%; max-height: 100%; }
.typechart-side { flex: 1 1 220px; min-width: 210px; display: flex; flex-direction: column; gap: 14px; }
.match-label { font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px; margin-bottom: 6px; }
.match-label.good { color: var(--good); }
.match-label.bad { color: var(--hot); }
.typechart-note { font-size: 12px; color: var(--label); line-height: 1.5; text-wrap: pretty; }

.ref-modal-body { padding: 16px; font-size: 13px; }
.ref-modal-body .desc { color: var(--muted); line-height: 1.5; margin: 8px 0 12px; }
.ref-modal-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ref-modal-body th {
  text-align: left; font-family: var(--font-head); font-size: 10px; letter-spacing: 1px;
  color: var(--label); padding: 4px 8px; border-bottom: 1px solid var(--line);
}
.ref-modal-body td { padding: 5px 8px; border-bottom: 1px solid rgba(30, 58, 77, 0.5); }

/* ---------- index page ---------- */

.filter-panel { margin-bottom: 14px; }
.filter-body { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search-input {
  flex: 1 1 200px; min-width: 180px; padding: 8px 12px;
  border: 1px solid var(--line-lit); background: var(--panel-deep);
  color: var(--ink); font-size: 14px; font-family: var(--font-body);
}
.search-input:focus { outline: none; border-color: var(--accent); }
.el-filter {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  background: transparent; border: 1px solid var(--line-lit); color: var(--soft);
}
.el-filter .diamond { width: 7px; height: 7px; transform: rotate(45deg); }
.el-filter.on { background: #14384e; border-color: var(--line-bright); color: #a8e2fb; }
.filter-label {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px;
  color: var(--label); align-self: center; margin-right: 2px;
}
.cat-filter .tab-n { color: inherit; opacity: 0.7; }
.cat-clear { color: var(--muted); border-style: dashed; }
.cat-clear:hover { color: var(--hot); border-color: rgba(255, 154, 92, 0.45); }
.filter-count {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1.5px; color: var(--label);
  margin-left: auto; white-space: nowrap;
}
.filter-select { width: auto; min-width: 140px; padding: 6px 10px; font-size: 12.5px; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; width: 100%;
}
.pal-card {
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  color: var(--ink);
}
.pal-card:hover { border-color: var(--line-bright); background: #12283a; color: var(--ink); }
.pal-card .art { aspect-ratio: 1; background: rgba(9, 20, 30, 0.6); display: flex; align-items: center; justify-content: center; position: relative; }
.pal-card .art img { width: 100%; height: 100%; object-fit: contain; }
.pal-card .no { font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px; color: var(--faint); }
.pal-card .nm { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.pal-card .meta-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 16px; }
.pal-card .variant-chip {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; font-weight: 600;
  color: var(--night); border: 1px solid rgba(169, 155, 255, 0.4); padding: 1px 6px;
}
.pal-card .work-mini { font-size: 10px; color: var(--label); }

/* ---------- reference pages (skills / items / technology / breeding) ---------- */

.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ref-table th {
  text-align: left; font-family: var(--font-head); font-size: 10px; letter-spacing: 1.2px;
  color: var(--label); padding: 8px 10px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.ref-table td { padding: 7px 10px; border-bottom: 1px solid rgba(30, 58, 77, 0.45); vertical-align: top; }
.ref-table tr:hover td { background: #12293a; }
.ref-table .num { text-align: right; font-weight: 600; }
.ref-table .learners { font-size: 12px; color: var(--muted); }
/* search-term hit inside a skill effect/description */
mark.skill-hl {
  background: rgba(242, 201, 76, 0.28);
  color: var(--ink);
  border-radius: 3px;
  padding: 0 1px;
}
.tab-row { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  font-family: var(--font-head); font-size: 12.5px; letter-spacing: 1px; font-weight: 600;
  color: var(--soft); padding: 6px 13px; border: 1px solid transparent;
  background: transparent; cursor: pointer;
}
.tab-btn.active, .tab-btn:hover { color: var(--accent); border-color: var(--line-lit); background: #0f2233; }

.tier-badge {
  font-family: var(--font-head); font-size: 10px; font-weight: 700;
  padding: 2px 7px; color: #08151f; background: var(--accent);
}
.tier-badge[data-tier^="-"] { background: var(--el-dark); color: #fff; }
.tier-badge[data-tier="5"] { background: var(--el-dragon); color: #08151f; }

.chip-mini.mutation {
  color: #d9b8f7; border-color: rgba(176, 125, 224, 0.5);
  background: rgba(176, 125, 224, 0.1);
}

.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort::after { content: '▾'; margin-left: 5px; color: var(--accent); }
.th-sort[data-dir="asc"]::after { content: '▴'; }

/* ---------- technology tree (mimics the in-game Technology screen) ---------- */

:root {
  --tech-line: rgba(103, 205, 232, 0.32);
  --tech-frame: #7fb6d4;
  --tech-ancient: #b07de0;
  --tech-ancient-bg: rgba(80, 35, 110, 0.35);
  --tech-ancient-line: rgba(176, 125, 224, 0.4);
}

/* header row: teal TECHNOLOGY bar + purple ANCIENT TECHNOLOGY bar (game layout) */
.tech-head-row { display: flex; align-items: stretch; }
.tech-head-main { flex: 1; min-width: 0; }
.tech-head-ancient {
  width: 248px; flex: none; box-sizing: border-box; padding-left: 14px; padding-right: 14px;
  background: linear-gradient(180deg, #3b2358 0%, #2a1a42 100%);
  border-left: 1px solid var(--tech-ancient-line);
}
.tech-head-ancient .bar { background: var(--tech-ancient); }
.tech-head-ancient h2 {
  font-size: 12px; letter-spacing: 1.3px; color: #e3c8ff; white-space: nowrap;
  text-shadow: 0 0 8px rgba(176, 125, 224, 0.55);
}

.tech-tree {
  background:
    repeating-linear-gradient(-55deg, transparent 0 26px, rgba(79, 195, 238, 0.03) 26px 28px),
    linear-gradient(180deg, #12374d 0%, #0d2536 26%, #0b1c2a 100%);
  padding: 4px 0 10px;
}
.tech-row {
  display: grid; grid-template-columns: 64px 1fr 248px; align-items: stretch;
  border-bottom: 1px solid var(--tech-line);
  box-shadow: 0 1px 0 rgba(103, 205, 232, 0.07);
}
.tech-row:last-child { border-bottom: none; box-shadow: none; }
.tech-rail { position: relative; display: flex; align-items: center; justify-content: center; }
.tech-rail::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px; background: var(--tech-line);
}
.lv-diamond {
  position: relative; z-index: 1; width: 30px; height: 30px; transform: rotate(45deg);
  background: #0b2434; border: 1px solid rgba(103, 205, 232, 0.85); flex: none;
  box-shadow: 0 0 12px rgba(79, 195, 238, 0.35), inset 0 0 9px rgba(79, 195, 238, 0.28);
  display: flex; align-items: center; justify-content: center;
}
.lv-diamond span {
  transform: rotate(-45deg);
  font-family: var(--font-head); font-weight: 700; font-size: 13px; color: #eaf6fc;
  text-shadow: 0 0 6px rgba(79, 195, 238, 0.8);
}
.tech-cards {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch;
  padding: 13px 16px 13px 4px;
}
/* continuous purple strip; also renders (empty) on levels with no ancient tech */
.tech-row-ancient {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch; align-content: flex-start;
  padding: 13px 12px; box-sizing: border-box;
  background: var(--tech-ancient-bg);
  border-left: 1px solid var(--tech-ancient-line);
  box-shadow: inset 0 0 22px rgba(30, 8, 50, 0.45);
}

.tech-card {
  width: 104px; padding: 0; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(180deg, #1a4560 0%, #123349 55%, #0e2739 100%);
  border: 1px solid var(--tech-frame); border-radius: 3px;
  box-shadow: 0 0 7px rgba(127, 182, 212, 0.28), inset 0 0 0 1px rgba(8, 21, 31, 0.55);
  font-family: var(--font-body); color: var(--ink); text-align: center;
}
.tech-card:hover {
  border-color: #b8e2f5; transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(127, 182, 212, 0.5), inset 0 0 0 1px rgba(8, 21, 31, 0.55);
}
.tech-card .cat {
  margin-top: 4px; padding: 1px 8px; border-radius: 2px;
  font-family: var(--font-head); font-size: 8.5px; font-weight: 600; letter-spacing: 0.6px;
  color: #ffbe63; background: #4b2519; border: 1px solid #7c4526;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); white-space: nowrap;
}
.tech-card .art {
  position: relative; width: 100%;
  height: 54px; display: flex; align-items: center; justify-content: center; padding: 2px 0;
}
.tech-card .art img {
  max-width: 48px; max-height: 48px; width: auto; height: auto;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
}
/* glowing point cost over the icon, like the game's tech cards */
.tech-card .pts {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-family: var(--font-head); font-weight: 700; font-size: 26px; color: var(--accent);
  text-shadow: 0 0 8px rgba(79, 195, 238, 0.9), 0 0 18px rgba(79, 195, 238, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.85);
}
.tech-card.ancient .pts {
  color: #e879f9;
  text-shadow: 0 0 8px rgba(232, 121, 249, 0.9), 0 0 18px rgba(232, 121, 249, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.85);
}
.tech-card .nm {
  width: 100%; box-sizing: border-box; flex: 1; min-height: 32px; margin-top: auto;
  display: flex; align-items: center; justify-content: center; padding: 3px 5px 4px;
  background: rgba(4, 13, 20, 0.62); border-top: 1px solid rgba(127, 182, 212, 0.25);
  border-radius: 0 0 2px 2px;
  font-size: 10.5px; font-weight: 500; line-height: 1.18; color: #ecf5fa;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); text-wrap: balance;
}

.tech-card.ancient {
  border-color: var(--tech-ancient);
  background: linear-gradient(180deg, #3a2b56 0%, #2a2044 55%, #1e1833 100%);
  box-shadow: 0 0 8px rgba(176, 125, 224, 0.35), inset 0 0 0 1px rgba(12, 8, 24, 0.55);
}
.tech-card.ancient:hover {
  border-color: #d4b3f2;
  box-shadow: 0 0 13px rgba(176, 125, 224, 0.55), inset 0 0 0 1px rgba(12, 8, 24, 0.55);
}
.tech-card.ancient .cat { color: #e3c8ff; background: #3b2261; border-color: #6a44a5; }
.tech-card.ancient .nm { border-top-color: rgba(176, 125, 224, 0.3); }

.tech-card.unlocked {
  border-color: #67e0ff;
  background: linear-gradient(180deg, #1f5d82 0%, #164963 55%, #103850 100%);
  box-shadow: 0 0 13px rgba(79, 195, 238, 0.55), inset 0 0 10px rgba(79, 195, 238, 0.2);
}
.tech-card.ancient.unlocked {
  border-color: #d4b3f2;
  background: linear-gradient(180deg, #55407c 0%, #3e2f62 55%, #2b2148 100%);
  box-shadow: 0 0 13px rgba(176, 125, 224, 0.6), inset 0 0 10px rgba(176, 125, 224, 0.22);
}

/* top-left select circle: blank ring, fills when the tech is marked unlocked */
.tech-card .sel-dot {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  width: 13px; height: 13px; border-radius: 50%; box-sizing: border-box;
  border: 1.5px solid rgba(200, 230, 245, 0.75); background: rgba(8, 18, 26, 0.55);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.tech-card .sel-dot:hover {
  border-color: #fff; transform: scale(1.2);
  box-shadow: 0 0 7px rgba(79, 195, 238, 0.85);
}
.tech-card.unlocked .sel-dot {
  background: var(--accent); border-color: #d9f4ff;
  box-shadow: 0 0 8px rgba(79, 195, 238, 0.95);
}
.tech-card.ancient.unlocked .sel-dot {
  background: #e879f9; border-color: #f3d9ff;
  box-shadow: 0 0 8px rgba(232, 121, 249, 0.95);
}

/* header readout: points the current selection costs + share */
.tech-head-need {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--accent);
  border: 1px solid var(--line-bright); background: rgba(79, 195, 238, 0.08);
  padding: 3px 10px;
}
.tech-head-need .dia {
  width: 8px; height: 8px; transform: rotate(45deg); flex: none;
  background: var(--accent); box-shadow: 0 0 6px rgba(79, 195, 238, 0.8);
}
.tech-head-need.ancient {
  color: #e3c8ff; border-color: #6a44a5; background: rgba(176, 125, 224, 0.1);
}
.tech-head-need.ancient .dia {
  background: var(--tech-ancient); box-shadow: 0 0 6px rgba(176, 125, 224, 0.8);
}

.tech-filter-ancient.on {
  background: #2f2149; border-color: #8a5fc4; color: #d9c2f5;
}

/* deep links: /technology#slug flashes the card (JS adds .hash-hit) */
.tech-card { scroll-margin: 110px; }
.tech-card:target, .tech-card.hash-hit {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(79, 195, 238, 0.85);
}
.tech-card.ancient:target, .tech-card.ancient.hash-hit {
  box-shadow: 0 0 0 2px var(--tech-ancient), 0 0 20px rgba(176, 125, 224, 0.85);
}

/* sticky footer bar: point meters + search/filters (mimics the game footer) */
.tech-footbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  justify-content: space-between; padding: 10px 18px;
  background: var(--panel-deep); border-top: 1px solid var(--tech-line);
  box-shadow: 0 -8px 16px rgba(4, 10, 16, 0.55);
}
.tech-meters { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.tech-meter {
  display: inline-flex; align-items: baseline; gap: 10px; padding: 6px 14px;
  background: linear-gradient(90deg, rgba(79, 195, 238, 0.16), rgba(79, 195, 238, 0.04));
  border: 1px solid var(--line-lit); border-left: 3px solid var(--accent);
}
.tech-meter .lbl {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.4px; color: var(--label);
  white-space: nowrap;
}
.tech-meter .val {
  font-family: var(--font-head); font-size: 15px; font-weight: 700; color: var(--accent);
  text-shadow: 0 0 7px rgba(79, 195, 238, 0.6); white-space: nowrap;
}
.tech-meter.ancient {
  background: linear-gradient(90deg, rgba(176, 125, 224, 0.18), rgba(176, 125, 224, 0.04));
  border-color: #533a78; border-left-color: var(--tech-ancient);
}
.tech-meter.ancient .val { color: #d9b8f7; text-shadow: 0 0 7px rgba(176, 125, 224, 0.6); }
.tech-foot-filters { flex: 1 1 340px; justify-content: flex-end; }

/* tech detail modal (game unlock popup) */
.chip-mini.ancient { color: #e3c8ff; border-color: rgba(176, 125, 224, 0.45); }
.tech-unlock { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.tech-unlock-name {
  font-family: var(--font-head); font-size: 13px; letter-spacing: 1px; font-weight: 700;
  color: var(--accent); margin: 0;
}
.tech-unlock-top { display: flex; gap: 14px; align-items: center; margin: 10px 0 4px; }
.tech-unlock-ico {
  width: 64px; height: 64px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 13, 20, 0.6); border: 1px solid var(--line-lit);
}
.tech-unlock-ico img { max-width: 56px; max-height: 56px; }
.tech-stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 0; flex: 1; }
.tech-stats div { display: contents; }
.tech-stats dt {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.2px; color: var(--label);
  align-self: center;
}
.tech-stats dd { margin: 0; font-weight: 600; font-size: 13px; }
.tech-mats-label {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.5px; color: var(--label);
  margin: 12px 0 6px;
}
.tech-mats { display: flex; flex-direction: column; gap: 4px; }
.tech-mat {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  background: rgba(4, 13, 20, 0.5); border: 1px solid rgba(30, 58, 77, 0.7); color: var(--ink);
}
.tech-mat:hover { border-color: var(--line-bright); color: var(--accent); }
.tech-mat .ico {
  width: 24px; height: 24px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.tech-mat .ico img { max-width: 24px; max-height: 24px; }
.tech-mat .nm { flex: 1; font-size: 12.5px; }
.tech-mat .qty { font-family: var(--font-head); font-weight: 700; font-size: 12.5px; color: var(--accent); }
.tech-station, .tech-yield { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.tech-req {
  margin-top: 14px; padding: 9px 12px; font-size: 12.5px; line-height: 1.45; color: #ffb98c;
  background: rgba(201, 74, 74, 0.12); border: 1px solid rgba(224, 82, 82, 0.55);
}
.tech-cost {
  margin: 14px 0 0; font-family: var(--font-head); font-size: 13px; font-weight: 700;
  letter-spacing: 1px; color: var(--accent); text-shadow: 0 0 7px rgba(79, 195, 238, 0.55);
}
.tech-cost.ancient { color: #d9b8f7; text-shadow: 0 0 7px rgba(176, 125, 224, 0.6); }
.tech-modal-foot {
  position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-deep);
}
.tech-foot-btn {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1.5px; font-weight: 600;
  color: var(--accent); border: 1px solid var(--line-bright);
  background: rgba(79, 195, 238, 0.1); padding: 7px 14px; cursor: pointer;
}
.tech-foot-btn:hover { background: rgba(79, 195, 238, 0.22); color: var(--accent); }

/* ---------- research page: Pal Labor Research Lab (in-game look) ---------- */

.lab {
  --lab-gold: #d9c66f;
  --lab-gold-bright: #f2df8e;
  --lab-gold-line: rgba(217, 198, 111, 0.35);
  --lab-panel: #14130d;
}
.lab-head .bar { background: var(--lab-gold); }
.lab-head h2 { color: #f3efdc; text-shadow: 0 0 8px rgba(240, 220, 130, 0.35); }
.lab-chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--lab-gold);
  border: 1px solid var(--lab-gold-line); background: rgba(217, 198, 111, 0.08);
  padding: 3px 10px;
}
.lab-chip .dia {
  width: 8px; height: 8px; transform: rotate(45deg); flex: none;
  background: var(--lab-gold); box-shadow: 0 0 6px rgba(240, 220, 130, 0.8);
}
.lab-share { color: var(--lab-gold); border-color: var(--lab-gold-line); }
.lab-share:hover { color: var(--lab-gold-bright); border-color: var(--lab-gold); }
.lab-count { color: var(--lab-gold); }

.lab-layout { display: flex; align-items: stretch; background: #100f0a; }

/* left: "Choose Research Subject" list, selected entry in game blue */
.lab-subjects {
  width: 250px; flex: none; box-sizing: border-box; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 7px; align-content: flex-start;
  background: linear-gradient(180deg, #191813 0%, #121109 100%);
  border-right: 1px solid var(--lab-gold-line);
}
.lab-subjects-title {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1px; color: #cfc9b0;
  margin: 0 2px 6px;
}
.lab-subject {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; cursor: pointer; text-align: left;
  font-family: var(--font-body); font-weight: 600; font-size: 13px; color: #e9e9e2;
  background: rgba(31, 33, 31, 0.92); border: 1px solid #3d403c;
}
.lab-subject img { width: 20px; height: 20px; flex: none; filter: drop-shadow(0 1px 1px #000); }
.lab-subject .nm { flex: 1; min-width: 0; }
.lab-subject .cnt {
  font-family: var(--font-head); font-weight: 700; font-size: 13px; color: #efd049;
  white-space: nowrap;
}
.lab-subject .cnt .tot { color: #b7ad86; font-size: 11px; }
.lab-subject:hover { border-color: #8b8b78; }
.lab-subject.on {
  color: #fff; background: linear-gradient(180deg, #3f9be4 0%, #2273bd 100%);
  border-color: #7cc4f4; box-shadow: 0 0 12px rgba(63, 155, 228, 0.35);
}
.lab-subject.on .cnt, .lab-subject.on .cnt .tot { color: #fff; }
/* white corner brackets around the selected subject, like the game */
.lab-subject.on::before {
  content: ""; position: absolute; inset: -4px; pointer-events: none;
  background:
    linear-gradient(#fff, #fff) top left / 10px 2px,
    linear-gradient(#fff, #fff) top left / 2px 10px,
    linear-gradient(#fff, #fff) top right / 10px 2px,
    linear-gradient(#fff, #fff) top right / 2px 10px,
    linear-gradient(#fff, #fff) bottom left / 10px 2px,
    linear-gradient(#fff, #fff) bottom left / 2px 10px,
    linear-gradient(#fff, #fff) bottom right / 10px 2px,
    linear-gradient(#fff, #fff) bottom right / 2px 10px;
  background-repeat: no-repeat;
}

/* middle: the research tree */
.lab-main { flex: 1; min-width: 0; padding: 12px 14px; }
.lab-cat-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  background: rgba(58, 54, 30, 0.55);
  border: 1px solid var(--lab-gold-line); border-bottom: none;
}
.lab-cat-head img { filter: drop-shadow(0 1px 1px #000); }
.lab-cat-head .nm {
  font-family: var(--font-head); font-weight: 700; font-size: 14px; letter-spacing: 1px;
  color: #f2ecd4;
}
.lab-cat-head .lvl {
  margin-left: auto; font-family: var(--font-head); font-size: 12px; color: #b7ad86;
}
.lab-cat-head .lvl .done, .lab-cat-head .lvl b {
  color: #efd049; font-size: 17px; font-weight: 700;
  text-shadow: 0 0 8px rgba(240, 220, 130, 0.5);
}
.lab-tree {
  position: relative; padding: 10px 12px 26px;
  border: 1px solid var(--lab-gold-line);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Cpath d='M15 11v8M11 15h8' stroke='%23fffbe0' stroke-opacity='.09' stroke-width='1.5'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #454020 0%, #393516 45%, #2c2a13 100%);
}
.lab-lines {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.lab-lines line { stroke: rgba(255, 255, 255, 0.85); stroke-width: 2; }

.lab-root {
  position: relative; z-index: 1; display: flex; justify-content: center;
  padding: 14px 0 30px; margin-left: 64px;
}
.lab-diamond {
  width: 44px; height: 44px; box-sizing: border-box; flex: none;
  transform: rotate(45deg);
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #37341d, #232112);
  border: 2px solid #6d6845;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6);
}
.lab-diamond img {
  width: 24px; height: 24px; transform: rotate(-45deg);
  opacity: 0.4; filter: grayscale(0.6) drop-shadow(0 1px 2px #000);
}
.lab-diamond.root {
  width: 60px; height: 60px; border-color: var(--lab-gold-bright);
  background: radial-gradient(circle at 35% 30%, #8a7a35, #57511f 60%, #3c381a);
  box-shadow: 0 0 18px rgba(240, 220, 130, 0.5), inset 0 0 10px rgba(255, 240, 170, 0.35);
}
.lab-diamond.root img { width: 30px; height: 30px; opacity: 1; filter: drop-shadow(0 1px 2px #000); }

.lab-band {
  position: relative; z-index: 1; display: flex; align-items: stretch;
  border-top: 1px solid rgba(255, 251, 224, 0.16); padding: 18px 0;
}
.lab-rail {
  width: 64px; flex: none; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding-top: 6px;
}
.lab-rail img { opacity: 0.9; filter: drop-shadow(0 1px 1px #000); }
.lab-rail span {
  font-family: var(--font-head); font-weight: 700; font-size: 12px;
  color: var(--lab-gold); text-shadow: 0 1px 2px #000; white-space: nowrap;
}
.lab-cells {
  flex: 1; min-width: 0; display: grid;
  grid-template-columns: repeat(var(--cols), minmax(56px, 1fr));
}
.lab-cell {
  display: flex; flex-direction: column; align-items: center;
  gap: 26px; min-height: 54px; padding: 4px 0;
}
.lab-node { background: none; border: none; padding: 5px; cursor: pointer; position: relative; z-index: 1; }
.lab-node:hover .lab-diamond {
  border-color: #cfc389;
  box-shadow: 0 0 10px rgba(240, 220, 130, 0.35), inset 0 0 8px rgba(0, 0, 0, 0.6);
}
.lab-node.done .lab-diamond {
  border-color: #f4e08a;
  background: linear-gradient(135deg, #7c6d2f, #57511f);
  box-shadow: 0 0 14px rgba(240, 220, 130, 0.55), inset 0 0 9px rgba(255, 240, 170, 0.3);
}
.lab-node.done .lab-diamond img { opacity: 1; filter: drop-shadow(0 1px 2px #000); }
.lab-node.dim { opacity: 0.22; }
.lab-node.hash-hit .lab-diamond {
  border-color: #fff;
  box-shadow: 0 0 0 2px #fff, 0 0 18px rgba(255, 255, 255, 0.7);
}

/* right: aggregated "Research Effects" for the selected subject */
.lab-effects {
  width: 272px; flex: none; box-sizing: border-box;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #191813 0%, #121109 100%);
  border-left: 1px solid var(--lab-gold-line);
}
.lab-effects-head {
  margin: 12px; padding: 7px 10px; text-align: center;
  font-family: var(--font-head); font-weight: 700; font-size: 12.5px; letter-spacing: 1px;
  color: #262214; background: linear-gradient(180deg, #d6c68b, #bfae74);
}
.lab-effects-body {
  padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
}
.lab-effect {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 12.5px; color: #efe9d2; line-height: 1.35;
}
.lab-effect img { width: 18px; height: 18px; flex: none; margin-top: 1px; filter: drop-shadow(0 1px 1px #000); }
.lab-effect a { color: var(--lab-gold-bright); }
.lab-effects-empty { font-size: 12px; color: #8f8a72; line-height: 1.5; }

/* bottom: workload meter + search */
.lab-footbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center;
  justify-content: space-between; padding: 10px 14px;
  background: var(--lab-panel); border-top: 1px solid var(--lab-gold-line);
  box-shadow: 0 -8px 16px rgba(4, 4, 2, 0.55);
}
.lab-meter {
  display: inline-flex; align-items: baseline; gap: 10px; padding: 6px 14px;
  background: linear-gradient(90deg, rgba(217, 198, 111, 0.16), rgba(217, 198, 111, 0.03));
  border: 1px solid var(--lab-gold-line); border-left: 3px solid var(--lab-gold);
}
.lab-meter .lbl {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1.4px; color: #b7ad86;
  white-space: nowrap;
}
.lab-meter .val {
  font-family: var(--font-head); font-size: 15px; font-weight: 700; color: var(--lab-gold);
  text-shadow: 0 0 7px rgba(240, 220, 130, 0.5); white-space: nowrap;
}

/* research detail modal: effect icon + text row */
.research-effect { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.research-effect .desc { flex: 1; margin: 0; }
.research-effect a { color: var(--accent); }
.lab-pop-head { background: linear-gradient(180deg, #454020, #2c2a13); }
.lab-pop-head .lv { color: var(--lab-gold); }

@media (max-width: 980px) {
  .lab-layout { flex-direction: column; }
  .lab-subjects {
    width: auto; flex-direction: row; flex-wrap: wrap;
    border-right: none; border-bottom: 1px solid var(--lab-gold-line);
  }
  .lab-subjects-title { width: 100%; }
  .lab-subject { flex: 1 1 44%; }
  .lab-effects { width: auto; border-left: none; border-top: 1px solid var(--lab-gold-line); }
}

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

@media (max-width: 640px) {
  .hero-art { width: min(150px, 60vw); }
  .map-coords { max-width: 45%; }
  .topbar { flex-wrap: wrap; }
  .site-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .data-chip { display: none; }
  .tech-row { grid-template-columns: 44px 1fr 160px; }
  .lv-diamond { width: 25px; height: 25px; }
  .lv-diamond span { font-size: 11px; }
  .tech-cards { gap: 7px; padding-right: 10px; }
  .tech-card { width: 90px; }
  .tech-card .art { height: 46px; }
  .tech-card .art img { max-width: 42px; max-height: 42px; }
  .tech-card .pts { font-size: 21px; }
  .tech-head-main { flex-wrap: wrap; row-gap: 6px; }
  .tech-head-ancient { width: 160px; padding-left: 10px; padding-right: 10px; }
  .tech-head-ancient h2 { font-size: 9.5px; letter-spacing: 1px; }
  .tech-row-ancient { padding: 10px 8px; gap: 7px; }
  .tech-footbar { padding: 8px 10px; gap: 8px 12px; }
  .tech-meter { padding: 5px 10px; gap: 7px; }
  .tech-meter .val { font-size: 13px; }
  .lab-rail { width: 40px; }
  .lab-root { margin-left: 40px; }
  .lab-diamond { width: 36px; height: 36px; }
  .lab-diamond img { width: 20px; height: 20px; }
  .lab-diamond.root { width: 48px; height: 48px; }
}

/* ---------- reference pages: items grid, chips, missions ---------- */

.tab-n {
  font-size: 10px; color: var(--faint); margin-left: 4px;
  font-family: var(--font-head); letter-spacing: 0.5px;
}
.section-hint { font-size: 12px; color: var(--muted); margin: 2px 0 12px; }

.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 8px;
}
.item-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--panel-deep); color: var(--ink); text-decoration: none;
  transition: border-color 0.12s, background 0.12s;
}
.item-row:hover { border-color: var(--line-bright); background: #12283a; }
.item-ico {
  flex: none; width: 42px; height: 42px; border-radius: 3px;
  border: 1px solid var(--line-lit); background: var(--panel-glass);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.item-ico img { width: 36px; height: 36px; object-fit: contain; }
.item-ico[data-rarity="Uncommon"]  { border-color: #4f8f2f; box-shadow: inset 0 0 8px rgba(126, 201, 65, 0.18); }
.item-ico[data-rarity="Rare"]      { border-color: #2e6fae; box-shadow: inset 0 0 8px rgba(61, 154, 232, 0.22); }
.item-ico[data-rarity="Epic"]      { border-color: #7d55a8; box-shadow: inset 0 0 8px rgba(176, 125, 224, 0.25); }
.item-ico[data-rarity="Legendary"] { border-color: #b07a35; box-shadow: inset 0 0 8px rgba(255, 176, 96, 0.28); }
.item-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.rarity-tag {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px;
  margin-left: 6px; vertical-align: 1px;
}
.rarity-tag[data-rarity="Uncommon"]  { color: var(--el-grass); }
.rarity-tag[data-rarity="Rare"]      { color: var(--el-water); }
.rarity-tag[data-rarity="Epic"]      { color: var(--el-dragon); }
.rarity-tag[data-rarity="Legendary"] { color: var(--bar-atk); }
.item-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.item-desc {
  font-size: 11.5px; color: var(--muted); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.chip-mini {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-head); font-size: 9.5px; letter-spacing: 0.8px;
  padding: 2px 6px; border: 1px solid var(--line); border-radius: 2px;
  color: var(--label); background: rgba(9, 20, 30, 0.4);
  text-decoration: none; white-space: nowrap;
}
.chip-mini.cat   { color: #a8e2fb; border-color: var(--line-lit); }
.chip-mini.craft { color: var(--good); border-color: rgba(98, 217, 166, 0.35); }
.chip-mini.drop  { color: var(--hot); border-color: rgba(255, 154, 92, 0.35); }
.chip-mini.gold  { color: var(--el-electric); border-color: rgba(242, 201, 76, 0.3); }
.chip-mini.exp   { color: var(--accent); border-color: rgba(79, 195, 238, 0.35); }
.chip-mini.coord { color: var(--muted); }
.chip-mini.reward { color: var(--ink); }
.chip-mini.reward img { width: 16px; height: 16px; object-fit: contain; }
a.chip-mini:hover { border-color: var(--line-bright); color: var(--accent); }

/* missions */
.mission-card {
  display: flex; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--panel-deep);
}
.mission-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.mission-title { font-weight: 600; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mission-objectives { display: flex; flex-direction: column; gap: 2px; }
.obj-line { font-size: 12px; color: var(--soft); }
.obj-line a { color: var(--accent); text-decoration: none; }
.obj-line a:hover { text-decoration: underline; }
.obj-coord { color: var(--muted); }
.mission-rewards { display: flex; flex-wrap: wrap; gap: 4px; }
.briefing summary {
  cursor: pointer; font-family: var(--font-head); font-size: 9.5px;
  letter-spacing: 1.2px; color: var(--faint); user-select: none;
}
.briefing summary:hover { color: var(--accent); }
.briefing p { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* mission arc filter pills */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.pill {
  font-family: var(--font-head); font-size: 11px; letter-spacing: 1px; font-weight: 600;
  color: var(--soft); background: transparent; border: 1px solid var(--line-lit);
  padding: 5px 12px; cursor: pointer;
}
.pill:hover { color: var(--accent); border-color: var(--line-bright); }
.pill.on { background: #14384e; border-color: var(--line-bright); color: #a8e2fb; }
.pill .n { color: var(--faint); font-size: 9.5px; margin-left: 3px; }

/* story chapters (collapsible arcs) */
.chapter {
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--panel-deep); margin-bottom: 10px;
}
.chapter.open { border-color: var(--line-lit); }
.chapter-head {
  display: flex; align-items: center; gap: 14px; width: 100%; box-sizing: border-box;
  padding: 10px 14px; background: none; border: 0; cursor: pointer;
  text-align: left; color: var(--ink);
}
.chapter-head:hover { background: #12293a; }
.ch-no {
  width: 28px; height: 28px; transform: rotate(45deg); flex: none; margin: 4px 6px;
  background: #0b2434; border: 1px solid var(--line-bright);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px rgba(79, 195, 238, 0.25), inset 0 0 8px rgba(79, 195, 238, 0.2);
}
.ch-no span {
  transform: rotate(-45deg); font-family: var(--font-head); font-weight: 700;
  font-size: 12px; color: #eaf6fc; text-shadow: 0 0 6px rgba(79, 195, 238, 0.8);
}
.ch-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ch-title {
  font-family: var(--font-head); font-weight: 700; font-size: 13.5px;
  letter-spacing: 1.5px; color: var(--accent);
}
.ch-tagline { font-size: 11.5px; color: var(--muted); }
.ch-meta {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1px;
  color: var(--faint); white-space: nowrap;
}
.caret { font-size: 12px; color: var(--faint); transition: transform 0.15s; flex: none; }
.chapter.open .caret, .giver-card.open .caret { transform: rotate(90deg); }
.chapter-body { padding: 4px 14px 12px; border-top: 1px solid var(--line); }

/* timeline rail (main story steps + giver quest lines) */
.timeline { list-style: none; margin: 0; padding: 10px 0 0; display: flex; flex-direction: column; }
.t-row { display: grid; grid-template-columns: 44px 1fr; }
.t-rail { position: relative; }
.t-rail::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 1px; margin-left: -0.5px; background: var(--line-lit);
}
.t-row:first-child .t-rail::before { top: 23px; }
.t-row:last-child .t-rail::before { bottom: auto; height: 23px; }
.t-row:only-child .t-rail::before { display: none; }
.t-node {
  position: absolute; left: 50%; top: 12px; transform: translate(-50%, 0) rotate(45deg);
  width: 22px; height: 22px; background: #0b2434; border: 1px solid var(--line-bright);
  display: flex; align-items: center; justify-content: center;
}
.t-node span {
  transform: rotate(-45deg); font-family: var(--font-head); font-weight: 700;
  font-size: 10px; color: #bfe8fa;
}
.timeline .mission-card { margin-bottom: 8px; }
.t-row:last-child .mission-card { margin-bottom: 0; }

/* sub-mission giver cards (collapsible) */
.list-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.list-controls .section-hint { flex: 1; margin: 0; }
.btn-ghost.mini { flex: none; font-size: 10px; padding: 5px 10px; letter-spacing: 1px; }
.giver-card {
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--panel-deep); margin-bottom: 8px;
}
.giver-card:hover, .giver-card.open { border-color: var(--line-lit); }
.giver-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; }
.giver-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  padding: 4px; background: none; border: 0; cursor: pointer;
  text-align: left; color: var(--ink);
}
.giver-avatar {
  width: 44px; height: 44px; flex: none; overflow: hidden;
  background: #0a2233; border: 1px solid var(--line-lit);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 14px;
  letter-spacing: 1px; color: var(--accent);
}
.giver-avatar img { width: 100%; height: 100%; object-fit: cover; }
.giver-avatar.lg {
  width: 84px; height: 84px; font-size: 24px;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
}
.giver-avatar.sm {
  width: 28px; height: 28px; font-size: 10px;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%);
}
.giver-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.giver-name {
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
  letter-spacing: 1.5px; color: var(--accent);
}
.giver-sub {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.giver-profile { flex: none; white-space: nowrap; }
.giver-missions {
  padding: 10px 14px 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.giver-missions .mission-card { background: var(--panel); }

/* giver profile page */
.giver-hero { display: flex; align-items: center; gap: 18px; padding: 18px; flex-wrap: wrap; }
.giver-hero-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.giver-hero-main h1 {
  font-family: var(--font-head); font-size: clamp(22px, 3.5vw, 32px);
  letter-spacing: 2px; margin: 0; line-height: 1;
}
.exp-chip { color: var(--accent); border-color: rgba(79, 195, 238, 0.4); }
.giver-map { min-width: 0; max-width: none; width: 100%; }
.giver-others { display: flex; flex-wrap: wrap; gap: 8px; }
.giver-mini {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--line-lit); background: var(--panel-deep); color: var(--ink);
}
.giver-mini:hover { border-color: var(--accent); color: var(--ink); }
.giver-mini .nm { font-family: var(--font-head); font-size: 10.5px; font-weight: 600; letter-spacing: 1px; }
.giver-mini .n { font-family: var(--font-head); font-size: 9.5px; color: var(--faint); }

@media (max-width: 640px) {
  .item-grid { grid-template-columns: 1fr; }
  .mission-card { gap: 8px; }
  .ch-meta { display: none; }
  .t-row { grid-template-columns: 36px 1fr; }
  .list-controls { flex-wrap: wrap; }
  .list-controls .section-hint { flex-basis: 100%; }
}

/* ---------- interactive map page ---------- */

.map-shell {
  display: flex;
  height: calc(100vh - 53px);
  min-height: 420px;
  overflow: hidden;
}
.map-side {
  width: 300px; flex: 0 0 300px;
  background: var(--panel-deep);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  padding: 12px;
  transition: margin-left 0.2s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.map-side::-webkit-scrollbar { width: 10px; }
.map-side::-webkit-scrollbar-track { background: transparent; }
.map-side::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 8px;
  border: 2px solid var(--panel-deep); background-clip: padding-box;
}
.map-side::-webkit-scrollbar-thumb:hover { background: var(--line-bright); }
.map-side.collapsed { margin-left: -325px; }
.map-canvas-wrap { position: relative; flex: 1; min-width: 0; }
/* #pm-map IS the .leaflet-container element; leaflet.css loads after this file
   and its `.leaflet-container { background:#ddd }` would win at equal specificity,
   so target the id to keep the void matching the tile-fill baked into the tiles. */
.pm-map, #pm-map.leaflet-container { position: absolute; inset: 0; background: var(--map-void); }
.map-side-toggle {
  position: absolute; top: 12px; left: 0; z-index: 800;
  width: 26px; height: 40px;
  background: var(--panel); color: var(--soft);
  border: 1px solid var(--line-lit); border-left: none;
  border-radius: 0 6px 6px 0; cursor: pointer; font-size: 16px;
}
.map-side-toggle:hover { color: var(--accent); }

.map-side-head { position: relative; display: flex; flex-direction: column; gap: 8px; }
#pm-search {
  font-family: var(--font-body);
  padding: 8px 10px; font-size: 13.5px;
  border: 1px solid var(--line-lit);
  background: var(--panel); color: var(--ink);
}
.pm-search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 900;
  background: var(--panel); border: 1px solid var(--line-bright);
  max-height: 300px; overflow-y: auto;
}
.pm-search-results button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--ink); font-size: 12.5px; cursor: pointer;
}
.pm-search-results button:hover { background: var(--accent-dim); }
.pm-search-results button img { width: 18px; height: 18px; object-fit: contain; }
.pm-search-results button i { margin-left: auto; color: var(--good); font-style: normal; }
.pm-search-results p { margin: 0; padding: 8px 10px; color: var(--faint); font-size: 12.5px; }

.pm-progress { margin: 12px 0 8px; }
#pm-progress-label {
  font-family: var(--font-head); font-size: 12px; letter-spacing: 1px; color: var(--soft);
}
.pm-progress-bar {
  height: 4px; margin-top: 5px; background: var(--line); border-radius: 2px; overflow: hidden;
}
#pm-progress-fill { height: 100%; width: 0; background: var(--good); transition: width 0.25s; }

.pm-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pm-controls > button {
  font-family: var(--font-head); font-size: 10.5px; letter-spacing: 1px;
  padding: 5px 10px; cursor: pointer;
  background: var(--panel); color: var(--soft);
  border: 1px solid var(--line-lit); border-radius: 20px;
}
.pm-controls > button:hover { color: var(--accent); border-color: var(--line-bright); }
.pm-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}

.pm-group h4 {
  margin: 14px 0 4px;
  font-family: var(--font-head); font-size: 11px; letter-spacing: 2px;
  color: var(--label); text-transform: uppercase;
}
.pm-cat {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px; margin: 1px 0;
  background: none; border: 1px solid transparent; border-radius: 5px;
  color: var(--faint); font-family: var(--font-body); font-size: 13px;
  cursor: pointer; text-align: left;
}
.pm-cat img { width: 20px; height: 20px; object-fit: contain; opacity: 0.4; }
.pm-cat em { margin-left: auto; font-style: normal; font-size: 11.5px; color: var(--faint); }
.pm-cat.on { color: var(--ink); background: var(--accent-dim); }
.pm-cat.on img { opacity: 1; }
.pm-cat.on em { color: var(--accent); }
.pm-cat:hover { border-color: var(--line-lit); }

/* effigy sub-types: a collapsible list of per-pal toggles under "Pal Effigy" */
.pm-caret {
  margin-left: 4px; padding: 0 4px; color: var(--label);
  font-size: 22px; line-height: 1; flex: none;
}
.pm-cat:hover .pm-caret,
.pm-cat.on .pm-caret { color: var(--accent); }
.pm-subcats {
  margin: 1px 0 4px 15px; padding-left: 8px;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1px;
}
.pm-subcat {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 3px 7px;
  background: none; border: 1px solid transparent; border-radius: 5px;
  color: var(--faint); font-family: var(--font-body); font-size: 12px;
  cursor: pointer; text-align: left;
}
.pm-subcat img { width: 16px; height: 16px; object-fit: contain; opacity: 0.35; border-radius: 3px; }
.pm-subcat em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--faint); }
.pm-subcat.on { color: var(--ink); }
.pm-subcat.on img { opacity: 1; }
.pm-subcat.on em { color: var(--accent); }
.pm-subcat:hover { border-color: var(--line-lit); }

.pm-panel {
  margin-top: 16px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.pm-panel h3 {
  margin: 0 0 8px;
  font-family: var(--font-head); font-size: 11px; letter-spacing: 2px; color: var(--label);
}
.pm-loc-row, .pm-route-row { display: flex; gap: 6px; }
.pm-loc-row input {
  width: 40%; min-width: 0; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--line-lit); background: var(--panel-deep); color: var(--ink);
}
.pm-loc-row button, .pm-route-row button {
  font-family: var(--font-head); font-size: 10.5px; letter-spacing: 1px;
  padding: 6px 10px; cursor: pointer;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--line-bright); border-radius: 4px; white-space: nowrap;
}
#pm-route-draw { flex: 1; }
.pm-route-cats { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.pm-route-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px 4px 6px; line-height: 1;
  background: var(--panel-deep); color: var(--faint);
  border: 1px solid var(--line-lit); border-radius: 20px;
  font-family: var(--font-body); font-size: 12px; cursor: pointer;
}
.pm-route-chip img { width: 16px; height: 16px; object-fit: contain; opacity: 0.45; }
.pm-route-chip:hover { color: var(--soft); border-color: var(--line-bright); }
.pm-route-chip.on { color: var(--accent); background: var(--accent-dim); border-color: var(--line-bright); }
.pm-route-chip.on img { opacity: 1; }
.pm-panel .pm-toggle { margin-top: 8px; }

/* numbered route stops */
.pm-route-num {
  min-width: 17px; height: 17px; padding: 0 3px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  background: #ffb060; color: #14100a;
  font-family: var(--font-head); font-weight: 700; font-size: 10.5px;
  border: 1.5px solid #14100a; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.pm-hint { margin: 8px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--faint); }
.pm-linkbtn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-size: 11.5px; text-decoration: underline;
}
.pm-credit { margin: 16px 0 4px; font-size: 10.5px; color: var(--faint); }

/* pins */
.pm-pin { position: relative; width: 100%; height: 100%; cursor: pointer; }
.pm-pin img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}
.pm-pin .pm-check {
  display: none; position: absolute; right: -4px; top: -4px;
  width: 13px; height: 13px; line-height: 13px;
  background: var(--good); color: #06281a; border-radius: 50%;
  font-size: 9px; font-weight: 700; text-align: center;
}
.pm-pin.pm-found { opacity: 0.45; }
.pm-pin.pm-found .pm-check { display: block; }
.pm-pin:hover { transform: scale(1.15); }

/* named-area labels: text anchored at the area centroid (0-size divIcon).
   three tiers, revealed by zoom — biome (big) / region (mid) / landmark (small) */
.pm-area-label {
  position: absolute; transform: translate(-50%, -50%);
  white-space: nowrap; pointer-events: none;
  font-family: var(--font-head); text-shadow: 0 1px 3px #000, 0 0 6px rgba(0, 0, 0, 0.9);
}
.pm-area-landmark {
  font-size: 10.5px; letter-spacing: 0.3px; color: var(--soft);
}
.pm-area-region {
  pointer-events: auto; cursor: pointer;
  font-size: 12px; letter-spacing: 1px; color: #cfe3ef;
  text-shadow: 0 1px 4px #000, 0 0 9px rgba(0, 0, 0, 0.92);
}
.pm-area-biome {
  pointer-events: auto; cursor: pointer;
  font-size: 13.5px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
  color: #eaf4fb; text-shadow: 0 1px 4px #000, 0 0 12px rgba(0, 0, 0, 0.95);
}
.pm-area-biome::after {
  content: ""; display: block; height: 2px; margin: 2px auto 0; width: 60%;
  background: var(--ac); border-radius: 2px; opacity: 0.85;
}
.pm-area-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ac); flex: none;
}
.pm-res-tag { margin-left: auto; font-style: normal; font-size: 10px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--label); }

/* player marker */
.pm-player { position: relative; width: 34px; height: 34px; }
.pm-player-dot {
  position: absolute; left: 12px; top: 12px; width: 10px; height: 10px;
  background: var(--good); border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 6px rgba(98, 217, 166, 0.9);
}
.pm-player-ring {
  position: absolute; inset: 0; border: 2px solid var(--good); border-radius: 50%;
  animation: pingPulse 1.6s ease-out infinite;
}

/* popups */
.pm-map .leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-bright); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
}
.pm-map .leaflet-popup-tip { background: var(--panel); border: 1px solid var(--line-bright); }
.pm-map .leaflet-popup-content { margin: 10px 12px; font-family: var(--font-body); }
.pm-pop { display: flex; flex-direction: column; gap: 7px; min-width: 180px; }
.pm-pop-head { display: flex; align-items: center; gap: 8px; }
.pm-pop-head img { width: 26px; height: 26px; object-fit: contain; }
.pm-pop-head strong { display: block; font-size: 13.5px; line-height: 1.25; }
.pm-pop-cat { font-size: 11px; color: var(--label); }
.pm-pop-photo { max-width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.pm-pop-pal {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px;
}
.pm-pop-pal img { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-deep); }
.pm-pop-lv { font-size: 12px; color: var(--muted); }
.pm-pop .coord-chip { align-self: flex-start; }
.pm-pop-ft {
  background: none; border: 1px dashed var(--line-lit); border-radius: 4px;
  padding: 5px 8px; color: var(--accent); font-size: 11.5px; cursor: pointer; text-align: left;
}
.pm-pop-ft:hover { border-color: var(--accent); }
.pm-pop-mark {
  font-family: var(--font-head); font-size: 10.5px; letter-spacing: 1px;
  padding: 7px 10px; cursor: pointer; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--line-bright);
}
.pm-pop-mark:hover { background: rgba(79, 195, 238, 0.22); }

/* right-click context popup */
.pm-ctx { display: flex; flex-direction: column; gap: 7px; }
.pm-ctx button {
  font-family: var(--font-head); font-size: 10px; letter-spacing: 1px;
  padding: 6px 9px; cursor: pointer; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--line-bright);
}
.pm-ctx-pop .leaflet-popup-content-wrapper {
  background: var(--panel); border: 1px solid var(--line-bright); border-radius: 8px;
}
.pm-ctx-pop .leaflet-popup-tip { background: var(--panel); }

@media (max-width: 760px) {
  .map-shell { flex-direction: column; height: auto; }
  .map-side { width: auto; flex: none; max-height: 45vh; border-right: none;
              border-bottom: 1px solid var(--line); }
  .map-side.collapsed { margin-left: 0; display: none; }
  .map-canvas-wrap { height: 55vh; }
}

/* ---------- resource calculator ---------- */

.calc-body { padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.calc-note { font-size: 12px; color: var(--faint); text-wrap: pretty; }
.calc-add { max-width: 460px; }
.calc-add .search-input { width: 100%; box-sizing: border-box; }
.calc-drop {
  /* portaled to <body> and placed by JS — the panel's clip-path would clip it */
  position: fixed; z-index: 90; max-height: 340px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--accent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.calc-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px;
  background: none; border: 0; color: var(--ink); font: inherit; font-size: 13px;
  cursor: pointer; text-align: left;
}
.calc-opt:hover, .calc-opt.active { background: var(--accent-dim); }
.calc-opt .nm { flex: 1; min-width: 0; }
.calc-opt .cat {
  flex: none; font-family: var(--font-head); font-size: 9.5px;
  letter-spacing: 0.8px; color: var(--faint);
}
.calc-opt-none { padding: 8px 10px; color: var(--faint); font-size: 12.5px; }

.cc-ico {
  flex: none; width: 28px; height: 28px; display: inline-flex;
  align-items: center; justify-content: center;
  border: 1px solid var(--line-lit); background: var(--panel-glass);
}
.cc-ico img { width: 24px; height: 24px; object-fit: contain; }

.calc-targets { display: flex; flex-direction: column; gap: 6px; }
.calc-target {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border: 1px solid var(--line); background: var(--panel-deep);
}
.cc-target-name { font-size: 13.5px; font-weight: 600; min-width: 0; }
.cc-cat {
  font-family: var(--font-head); font-size: 9px; font-weight: 600;
  letter-spacing: 0.8px; color: var(--faint); margin-left: 4px;
}
.cc-step { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.cc-step button {
  width: 26px; height: 26px; border: 1px solid var(--line-lit); background: var(--panel);
  color: var(--soft); font-size: 14px; line-height: 1; cursor: pointer;
}
.cc-step button:hover { color: var(--accent); border-color: var(--accent); }
.cc-step .cc-qty-in {
  width: 62px; padding: 4px 4px; text-align: center;
  border: 1px solid var(--line-lit); background: var(--panel);
  color: var(--ink); font-family: var(--font-body); font-size: 13px;
}
.cc-step .cc-qty-in:focus { outline: none; border-color: var(--accent); }
.cc-remove {
  flex: none; width: 26px; height: 26px; border: 1px solid transparent; background: none;
  color: var(--faint); font-size: 12px; cursor: pointer;
}
.cc-remove:hover { color: var(--hot); border-color: var(--line-lit); }

.calc-empty { width: 100%; box-sizing: border-box; }

.calc-results { width: 100%; }
.calc-results .panel { min-width: 0; width: auto; }

/* crafting plan tree */
.cc-tree { display: flex; flex-direction: column; font-size: 13px; }
.cc-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 6px 4px calc(6px + var(--depth) * 18px);
}
.cc-row:hover { background: rgba(79, 195, 238, 0.05); }
.cc-caret {
  flex: none; width: 18px; height: 18px; padding: 0; border: 0; background: none;
  color: var(--faint); font-size: 11px; line-height: 1; cursor: pointer;
}
.cc-caret:hover { color: var(--accent); }
.cc-caret.spacer { visibility: hidden; cursor: default; }
.cc-name { font-weight: 500; min-width: 0; }
a.cc-name { color: var(--ink); }
a.cc-name:hover { color: var(--accent); }
.cc-need { font-family: var(--font-head); font-weight: 700; color: var(--accent); white-space: nowrap; }
.cc-crafts { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cc-cycle { color: var(--hot); cursor: help; }
.cc-toggle { display: inline-flex; margin-left: auto; border: 1px solid var(--line-lit); }
.cc-toggle .cc-mode {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 0.8px;
  padding: 3px 8px; border: 0; background: none; color: var(--faint); cursor: pointer;
}
.cc-toggle .cc-mode.on { background: #14384e; color: #a8e2fb; }
.cc-toggle .cc-mode.on.gather { background: rgba(98, 217, 166, 0.16); color: var(--good); }
.cc-toggle .cc-mode:not(.on):hover { color: var(--soft); }

/* source-group boxes (DROPS/RANCH/ALPHA/VENDOR) — reused inside the node popover */
.cc-srcs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin-top: 9px;
}
.cc-srcs:empty { display: none; }
.cc-src {
  display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center;
  padding: 5px 8px; border: 1px solid rgba(30, 58, 77, 0.55);
  border-left: 2px solid var(--line-lit); background: rgba(4, 11, 17, 0.45);
}
.cc-src.drop   { border-left-color: var(--hot); }
.cc-src.ranch  { border-left-color: var(--good); }
.cc-src.alpha  { border-left-color: var(--tech-ancient); }
.cc-src.vendor { border-left-color: var(--el-electric); }
.cc-src-label {
  align-self: center;
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; color: var(--label);
}
.cc-src-label.drop { color: var(--hot); }
.cc-src-label.ranch { color: var(--good); }
.cc-src-label.alpha { color: var(--tech-ancient); }
.cc-src-label.vendor { color: var(--el-electric); }
.cc-pal {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 1px 7px; border: 1px solid var(--line-lit);
  border-radius: 2px; color: var(--accent); background: rgba(9, 20, 30, 0.4);
}
.cc-pal:hover { border-color: var(--line-bright); }
.cc-pal .d { font-size: 10px; color: var(--muted); }
.cc-pal.ranch { color: var(--good); border-color: rgba(98, 217, 166, 0.35); }
.cc-pal.alpha { color: var(--tech-ancient); border-color: var(--tech-ancient-line); }
.cc-vendor { font-size: 11.5px; color: var(--soft); }
.cc-more {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 0.8px;
  padding: 2px 7px; border: 1px solid var(--line-lit); border-radius: 2px;
  background: none; color: var(--label); cursor: pointer; white-space: nowrap;
}
.cc-more:hover { color: var(--accent); border-color: var(--line-bright); }
.cc-more.alpha { color: var(--tech-ancient); border-color: var(--tech-ancient-line); }
.cc-more.less { color: var(--faint); border-style: dashed; }
.cc-more.less:hover { color: var(--soft); }
/* ===== MASTER PLAN as a node/edge DAG graph ===== */
/* scroll box: grows tall, scrolls vertically (and horizontally for wide graphs) */
.cc-graph {
  position: relative; overflow: auto; max-height: min(72vh, 900px);
  border: 1px solid var(--line); background: var(--panel-deep);
  cursor: grab; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent;
}
.cc-graph::-webkit-scrollbar { width: 10px; height: 10px; }
.cc-graph::-webkit-scrollbar-track { background: transparent; }
.cc-graph::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 8px;
  border: 2px solid var(--panel-deep); background-clip: padding-box;
}
.cc-graph::-webkit-scrollbar-thumb:hover { background: var(--line-bright); }
.cc-graph::-webkit-scrollbar-corner { background: transparent; }
/* drag-to-pan feedback (JS toggles .panning) */
.cc-graph.panning { cursor: grabbing; user-select: none; }
.cc-graph.panning * { cursor: grabbing !important; }

/* done toolbar: show/hide + reset checked-off nodes (sits above the graph) */
.cc-donebar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 10px; margin-bottom: 8px;
  border: 1px solid var(--line); background: var(--panel-deep);
}
.cc-donebar-count { font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; color: var(--good); }
.cc-donebar-acts { display: inline-flex; gap: 6px; margin-left: auto; }
.cc-donebar-btn {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 0.8px; padding: 4px 9px;
  cursor: pointer; color: var(--soft); border: 1px solid var(--line-lit); background: none;
}
.cc-donebar-btn:hover { color: var(--ink); border-color: var(--line-bright); }
.cc-donebar-btn.on { background: #14384e; color: #a8e2fb; border-color: var(--line-bright); }
.cc-donebar-btn.danger:hover { color: var(--el-dark); border-color: var(--el-dark); }

/* mark-done button inside the node popover foot */
.cc-donebtn {
  margin-left: auto; font-family: var(--font-head); font-size: 9px; letter-spacing: 0.8px;
  padding: 4px 10px; cursor: pointer; color: var(--soft);
  border: 1px solid var(--line-lit); background: none;
}
.cc-donebtn:hover { color: var(--ink); border-color: var(--line-bright); }
.cc-donebtn.on { color: var(--good); border-color: var(--good); background: rgba(98, 217, 166, 0.14); }

/* a checked-off node, shown only while SHOW DONE is on */
.cc-node.is-done { opacity: 0.5; }
.cc-node.is-done .cc-node-name { text-decoration: line-through; }
.cc-node-done {
  position: absolute; top: -8px; left: 6px; width: 16px; height: 16px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #06231a;
  background: var(--good); border: 1px solid var(--panel-deep);
}
/* coordinate space + scroll extent — W/H set inline by JS in px.
   NEVER add transform/filter/will-change here (breaks the mobile as-sheet). */
.cc-canvas { position: relative; }

/* edge layer: one svg sized to the canvas, painted behind the node cards */
.cc-edges { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: visible; }
.cc-edge { fill: none; stroke: var(--line-lit); stroke-width: 1.5; stroke-linecap: round; }
.cc-edge-layer { transition: opacity .13s ease; }
.cc-edge-layer.dim { opacity: .16; }               /* one composited fade of every base edge */
.cc-edge.lit { stroke: var(--accent); stroke-width: 2.25; }
.cc-edge.sel { stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 0 3px var(--accent)); }
@media (prefers-reduced-motion: reduce) { .cc-edge-layer { transition: none; } }

/* node card: icon + name + amount, absolutely positioned at (x,y) */
.cc-node {
  position: absolute; box-sizing: border-box; width: 184px; height: 64px;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-align: left;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: rgba(9, 20, 30, 0.92); color: var(--ink); cursor: pointer; font: inherit;
  z-index: 1; transition: border-color .12s, box-shadow .12s;
}
.cc-node:hover { border-color: var(--line-bright); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); }
.cc-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-node.is-base { border-left-color: var(--good); }
.cc-node.is-craft { border-left-color: var(--accent); }
.cc-node.is-target { border-left-color: var(--el-electric); background: rgba(79, 195, 238, 0.10); }
.cc-node[aria-expanded="true"] {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim), 0 6px 18px rgba(0, 0, 0, 0.5); z-index: 3;
}
.cc-node-ico {
  flex: none; width: 34px; height: 34px; display: inline-flex; align-items: center;
  justify-content: center; border: 1px solid var(--line-lit); background: var(--panel-glass);
}
.cc-node-ico img { width: 28px; height: 28px; object-fit: contain; }
.cc-node-ico.lg { width: 44px; height: 44px; }
.cc-node-ico.lg img { width: 38px; height: 38px; }
.cc-node-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-node-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cc-node-amt { font-family: var(--font-head); font-weight: 700; font-size: 12px; color: var(--accent); }
.cc-node.is-base .cc-node-amt { color: var(--good); }
.cc-node.is-target .cc-node-amt { color: var(--el-electric); }
.cc-node-tag {
  position: absolute; top: -8px; right: 6px; font-family: var(--font-head); font-size: 8.5px;
  letter-spacing: 1px; padding: 1px 5px; color: var(--el-electric);
  background: var(--panel-deep); border: 1px solid rgba(242, 201, 76, 0.45);
}
.cc-node-tag.base { color: var(--good); border-color: rgba(98, 217, 166, 0.4); }

/* detail popover (in-canvas, anchored to the clicked node) */
.cc-pop {
  position: absolute; z-index: 20; width: 300px; max-height: min(70vh, 560px);
  display: flex; flex-direction: column; background: rgba(13, 19, 26, 0.98);
  border: 1px solid var(--line-bright);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(8, 14, 20, 0.8); --arrow-y: 24px;
}
.cc-pop-head {
  display: flex; align-items: flex-start; gap: 9px; padding: 10px 10px 9px;
  background: linear-gradient(90deg, #16323f, #0e222e); border-bottom: 1px solid var(--line-bright);
}
.cc-pop-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cc-pop-name { font-family: var(--font-head); font-weight: 700; font-size: 14.5px; color: #f2f8fb; }
a.cc-pop-name:hover { color: var(--accent); }
.cc-pop-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cc-pop-cat { font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; color: var(--label); }
.cc-pop-qty { font-family: var(--font-head); font-size: 10px; color: var(--accent); }
.cc-pop-x {
  flex: none; width: 24px; height: 24px; border: 1px solid var(--line-lit);
  background: none; color: var(--faint); font-size: 12px; cursor: pointer;
}
.cc-pop-x:hover { color: var(--hot); }
.cc-pop-body { padding: 10px 11px 12px; overflow-y: auto; font-size: 13px; }
.cc-pop-sec + .cc-pop-sec { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.cc-pop-sec-head { display: flex; align-items: center; gap: 8px; }
.cc-recipe.pop, .cc-srcs.pop { margin-top: 7px; padding-left: 0; }
.cc-pop-buy { margin-top: 7px; }
.cc-recipe-label.alt { color: var(--hot); }
.cc-pop-foot { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; }
.cc-pop-foot .cc-toggle { margin-left: 0; }
.cc-pop-none { color: var(--faint); font-size: 12.5px; padding: 4px 0; }
.cc-pop::before, .cc-pop::after {
  content: ''; position: absolute; top: var(--arrow-y); width: 0; height: 0; border: 7px solid transparent;
}
.cc-pop.on-right::before { left: -14px; border-right-color: var(--line-bright); }
.cc-pop.on-left::after { right: -14px; border-left-color: var(--line-bright); }
@media (max-width: 640px) {
  /* the panel's cut-corner clip-path would clip the position:fixed bottom sheet
     (same hazard the search dropdown avoids by portaling) — drop it on mobile */
  .calc-master-panel { clip-path: none; }
  .cc-pop.as-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-height: 76vh;
    border-left: none; border-right: none; box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.7);
  }
  .cc-pop.as-sheet::before, .cc-pop.as-sheet::after { display: none; }
}

.cc-recipe {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 9px; padding-left: 38px;
}
.cc-recipe-label {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; color: var(--label);
}
.cc-ing {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px;
  border: 1px solid var(--line-lit); border-radius: 2px; background: rgba(9, 20, 30, 0.5);
  color: var(--ink); font-family: var(--font-body); font-size: 11.5px; cursor: pointer;
}
.cc-ing:hover { border-color: var(--accent); color: var(--accent); }
.cc-ing.static { cursor: default; }                 /* gathered item: recipe is reference-only */
.cc-ing.static:hover { border-color: var(--line-lit); color: var(--ink); }
.cc-ing-ico { flex: none; width: 18px; height: 18px; display: inline-flex; }
.cc-ing-ico img { width: 18px; height: 18px; object-fit: contain; }
.cc-ing-amt { font-family: var(--font-head); font-weight: 700; color: var(--accent); }

.cc-flash { animation: cc-flash 1.2s ease-out; }
@keyframes cc-flash {
  0% { box-shadow: 0 0 0 2px var(--accent) inset; }
  100% { box-shadow: 0 0 0 0 transparent inset; }
}
.cc-hint { padding: 14px 4px; color: var(--faint); font-size: 12.5px; }

@media (max-width: 640px) {
  .cc-recipe { padding-left: 0; }
}

/* ---------- tech hover popup (in-game style detail card) ---------- */

.tech-pop {
  position: absolute; z-index: 90; width: 312px; pointer-events: none;
  background: rgba(13, 19, 26, 0.97); border: 1px solid #46586a;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(8, 14, 20, 0.8);
}
.tech-pop-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 9px 12px; background: linear-gradient(90deg, #16323f, #0e222e);
  border-bottom: 1px solid var(--line-bright);
}
.tech-pop-head .nm {
  font-family: var(--font-head); font-weight: 700; font-size: 15px; color: #f2f8fb;
}
.tech-pop-head .lv {
  font-family: var(--font-head); font-weight: 600; font-size: 10.5px;
  letter-spacing: 1px; color: var(--accent); white-space: nowrap;
}
.tech-pop-head.ancient {
  background: linear-gradient(90deg, #2d1f47, #1c142e);
  border-bottom-color: var(--tech-ancient);
}
.tech-pop-head.ancient .lv { color: #d9b8f7; }
.tech-pop-body { padding: 10px 12px 12px; font-size: 13px; max-height: 62vh; overflow: hidden; }
.tech-pop-body .tech-unlock { border-top: none; margin-top: 6px; padding-top: 0; }
.tech-pop-body .tech-unlock + .tech-unlock {
  border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px;
}
.tech-pop-body .tech-unlock-ico { width: 52px; height: 52px; }
.tech-pop-body .desc { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 6px 0; }
.tech-pop-body .tech-mat { padding: 3px 6px; background: rgba(20, 34, 46, 0.85); }
