/* Field Kit: colors come from content/system.json → theme (set as CSS variables at startup). */
:root {
  --bg: #0a0b0c; --surface: #131517; --surface2: #1b1e21; --line: #2a2f33;
  --text: #eef1ee; --muted: #7d8781; --accent: #d4ff2a; --accent-text: #0a0b0c; --danger: #ff4040;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-body);
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar: 62px; --radius: 4px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 15px; }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body.modal-open, body.dragging { overflow: hidden; }
body.dragging, body.dragging * { user-select: none; -webkit-user-select: none; cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); font-family: var(--font-mono); letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }

/* ---------- Layout ---------- */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-top) + 10px) 16px 10px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; min-width: 0; }
.brand .logo { height: 22px; width: auto; display: block; }
.brand .ph.logo { height: 22px; width: 60px; }
.who-btn { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); max-width: 55%; }
.who-btn #who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: 10px; }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 12px 12px 24px; }
.tabbar { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--bg);
  padding-bottom: var(--safe-bottom); }
.tab { height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); position: relative; }
.tab.on { color: var(--text); }
.tab.on::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 2px; background: var(--accent); }
.ico { display: inline-flex; width: 22px; height: 22px; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.btn .ico { width: 16px; height: 16px; margin-right: 6px; }

/* ---------- Building blocks ---------- */
.block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.block h2 { margin: 0 0 12px; font-family: var(--font-display); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; font-weight: 700; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.block-head h2 { margin: 0; }
.label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.label .sub { letter-spacing: .04em; text-transform: none; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; justify-content: center; }
p { line-height: 1.45; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .end { justify-content: flex-end; } .wrap { flex-wrap: wrap; }
.count { color: var(--accent); font-family: var(--font-mono); margin-left: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; border: 1px solid var(--line); background: var(--surface2); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 11px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(1.1); }
.block-btn { width: 100%; margin-top: 8px; }

.input { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; font-size: 16px; /* 16px stops iOS from zooming on focus */ -webkit-appearance: none; appearance: none; }
.input:focus { outline: none; border-color: var(--accent); }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chip.accent { color: var(--accent); border-color: var(--accent); }
.badge { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 8px; border-radius: 3px; }
.badge.ok { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.warn { background: #ffb02033; color: #ffb020; } .badge.bad { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }

.step { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface2); font-size: 18px; line-height: 1; flex: none; }
.step.wide { width: auto; padding: 0 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.step:active { background: var(--line); }

/* Placeholder used when a PNG is missing */
.ph { --ph: var(--muted); display: grid; place-items: center; width: 100%; height: 100%; background:
  repeating-linear-gradient(135deg, color-mix(in srgb, var(--ph) 14%, transparent) 0 6px, transparent 6px 12px);
  border: 1px dashed color-mix(in srgb, var(--ph) 60%, transparent); color: var(--ph); font-family: var(--font-mono); font-weight: 700; letter-spacing: .1em; font-size: 11px; }

/* ---------- Sheet ---------- */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field:first-child, .field.full { grid-column: 1 / -1; }

.pool { display: flex; align-items: center; gap: 8px; }
.pool .num { font-size: 20px; color: var(--accent); min-width: 22px; text-align: center; }

.tracks { display: flex; flex-direction: column; gap: 10px; }
.track { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--bg); }
.track-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.track-name { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.track-die { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.track-die b { color: var(--accent); font-size: 15px; }
.track-values { margin-bottom: 6px; }
.tv-label { display: block; font-family: var(--font-mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.tv-row { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 5px; }
.tv { justify-self: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.tv.on { border-color: var(--accent); color: var(--accent-text); background: var(--accent); font-weight: 700; }
.tiers { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 5px; }
.tier { display: flex; flex-direction: column; align-items: stretch; border: 1px solid var(--line); border-radius: 3px; padding: 4px 4px 0; position: relative; }
.tier.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tier.unlock::after { content: ""; position: absolute; top: -4px; right: -4px; width: 7px; height: 7px; background: var(--accent); transform: rotate(45deg); }
.pips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
.pip { aspect-ratio: 1; border: 1px solid #4a5157; border-radius: 2px; background: transparent; min-height: 18px; }
.pip.on { background: var(--text); border-color: var(--text); }
.tier.current .pip.on, .tier.done .pip.on { background: var(--accent); border-color: var(--accent); }
.pip.gear.on { background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 6px); }
.tier-die { text-align: center; font-family: var(--font-mono); font-size: 11px; font-weight: 700; padding: 5px 0 4px; color: var(--muted); }
.tier.current .tier-die { color: var(--accent); }
.tier.done .tier-die { color: var(--text); }
.track-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.stats:empty { display: none; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 2px; background: var(--bg); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .fx { font-size: 10px; font-family: var(--font-mono); color: var(--accent); }
.stat-steps { display: flex; gap: 6px; margin-top: 6px; }
.derived { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 10px; }
.der { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.der.tap { cursor: pointer; }
.der .num { font-size: 22px; font-weight: 700; }
.bonuses { margin-top: 12px; }
.line { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line > span:first-child { flex: 1; }
.line .num { min-width: 34px; text-align: right; font-size: 16px; }

.resources { display: flex; flex-direction: column; gap: 16px; }
.res-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.res-val { font-family: var(--font-mono); font-size: 14px; color: var(--muted); }
.res-val b { color: var(--text); font-size: 22px; }
.res-bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.res-bar i { display: block; height: 100%; background: var(--c); transition: width .25s; }
.res-steps { display: flex; gap: 6px; margin-top: 8px; }
.boxes { display: grid; grid-template-columns: repeat(var(--per), 1fr); gap: 4px; }
.box { aspect-ratio: 1; border: 1.5px solid #4a5157; border-radius: 3px; background: var(--bg); }
.box.on { background: var(--c); border-color: var(--c); }
.box.locked { border-style: dashed; opacity: .35; }
.boxes.slanted .box { aspect-ratio: .78; transform: skewX(-10deg); }
.acts { margin-top: 12px; }
.act-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.act { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.act .pips { display: flex; gap: 2px; }
.act .pips i { width: 6px; height: 11px; background: var(--c); transform: skewX(-10deg); }
.act:active { border-color: var(--c); }

.dice-table { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.dt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 3px; font-family: var(--font-mono); font-size: 11px; }
.dt-ico { width: 30px; height: 30px; object-fit: contain; }
.dt .ph { width: 30px; height: 30px; }
.dt .pass { color: var(--accent); } .dt .fail { color: var(--danger); }
.dt-legend { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: 10px; }

.conds { display: flex; flex-wrap: wrap; gap: 6px; }
.cond { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); }
.cond.on { color: var(--text); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }
.cond-ico { width: 18px; height: 18px; } .cond .ph { width: 18px; height: 18px; font-size: 8px; }
.cond-notes p { margin: 8px 0 0; font-size: 13px; }
.ability-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.notes { min-height: 120px; }

/* ---------- Cards ---------- */
.card { --r: var(--muted); position: relative; aspect-ratio: 5 / 7; width: 100%; container-type: inline-size; overflow: hidden;
  background: linear-gradient(180deg, var(--surface2), var(--surface)); border: 1px solid color-mix(in srgb, var(--r) 55%, var(--line));
  border-radius: 6px; display: flex; flex-direction: column; color: var(--text); cursor: pointer; user-select: none; -webkit-user-select: none; }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1.8cqw; background: var(--r); z-index: 2; }
.card-frame { position: absolute; inset: 0; background-size: 100% 100%; z-index: 3; pointer-events: none; }
.card-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card.has-face::before { display: none; }
.card-top { display: flex; justify-content: space-between; padding: 5cqw 5cqw 2cqw; font-family: var(--font-mono); font-size: 3.6cqw; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); z-index: 1; }
.card-top .rar { color: var(--r); }
.card-art { margin: 0 5cqw; aspect-ratio: 5 / 3.3; background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 10cqw 10cqw, linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 10cqw 10cqw, var(--bg);
  border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; }
.card-art img { max-width: 88%; max-height: 88%; object-fit: contain; }
.card-art .ph { font-size: 9cqw; }
.card-name { padding: 3.5cqw 5cqw 1cqw; font-family: var(--font-display); font-weight: 800; font-size: 7cqw; line-height: 1.05; text-transform: uppercase; letter-spacing: .02em; }
.card-meta { display: flex; flex-wrap: wrap; gap: 1.6cqw; padding: 1.5cqw 5cqw; }
.card-meta .chip { font-size: 3.2cqw; padding: .8cqw 1.8cqw; }
.size-glyph { display: inline-grid; gap: 1px; }
.size-glyph i { width: 5px; height: 5px; background: currentColor; display: block; }
.card-body { padding: 1.5cqw 5cqw 5cqw; overflow-y: auto; flex: 1; font-size: 4.1cqw; line-height: 1.4; }
.card-stats { display: grid; grid-template-columns: auto 1fr; gap: .6cqw 4cqw; margin: 0 0 2.5cqw; font-family: var(--font-mono); font-size: 3.7cqw; }
.card-stats dt { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; } .card-stats dd { margin: 0; }
.card-desc { margin: 0 0 2cqw; } .card-flavor { margin: 0 0 2cqw; color: var(--muted); font-style: italic; }
.card-tags { display: flex; flex-wrap: wrap; gap: 2cqw; font-family: var(--font-mono); font-size: 3.3cqw; color: var(--muted); }
.card-qty { position: absolute; right: 4cqw; bottom: 4cqw; background: var(--accent); color: var(--accent-text); font-family: var(--font-mono); font-weight: 700; font-size: 6cqw; padding: .5cqw 2.5cqw; border-radius: 2px; z-index: 4; }
.card.mini .card-top { font-size: 6cqw; padding: 7cqw 6cqw 3cqw; } .card.mini .card-top span:first-child { display: none; }
.card.mini .card-art { margin: 0 6cqw; aspect-ratio: 1; }
.card.mini .card-name { font-size: 10.5cqw; padding: 5cqw 6cqw; }
.card.mini .card-qty { font-size: 10cqw; }
.card.back { cursor: default; } .card.back::before { display: none; }
.card-back-default { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 8cqw), var(--surface); }

/* Card modal */
#overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#overlay.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .2s; }
.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 420px); max-height: calc(100dvh - 40px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto; padding: 4px; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 14px; animation: pop .2s; }
.dialog h3 { margin: 0; font-size: 17px; }
.dialog p { margin: 0; }
.card-view { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card-view > .card { width: min(78vw, 340px, calc((100dvh - 240px) * 5 / 7)); cursor: default; }
.card-view .where { margin: 0; font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; font-size: 10px; }
.face-desc { margin: 0; font-size: 14px; text-align: center; max-width: 340px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.actions .btn { flex: 1 1 calc(33% - 8px); min-width: 96px; }
.qty-ctl .num { font-size: 22px; min-width: 40px; text-align: center; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* Reveal (flip) */
.revealmodal { width: min(96vw, 560px); }
.reveal { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.reveal-head { text-align: center; }
.reveal-head h3 { margin: 0 0 4px; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .14em; font-size: 15px; }
.reveal-head p { margin: 0; }
.reveal-cards { display: grid; gap: 10px; width: 100%; justify-items: center; }
.reveal-cards.n1 { grid-template-columns: min(70vw, 300px); justify-content: center; }
.reveal-cards.n2 { grid-template-columns: 1fr 1fr; }
.reveal-cards.n3, .reveal-cards.n4 { grid-template-columns: 1fr 1fr; }
.flip { width: 100%; aspect-ratio: 5 / 7; perspective: 900px; animation: deal .4s calc(var(--i) * 90ms) both cubic-bezier(.2, .8, .2, 1); cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.2, .8, .2, 1); transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-back, .flip-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-front { transform: rotateY(180deg); }
.flip.flipped .flip-front .card { box-shadow: 0 0 0 1px var(--r), 0 0 28px -6px var(--r); }
@keyframes deal { from { opacity: 0; transform: translateY(30px) rotate(-4deg); } }

/* ---------- Inventory ---------- */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.slot { --r: var(--line); aspect-ratio: 1; border: 1px dashed var(--line); border-radius: var(--radius); position: relative; display: grid; place-items: center; padding: 8px 8px 18px; background: var(--bg); touch-action: none; }
.slot.filled { border: 1px solid var(--r); background: color-mix(in srgb, var(--r) 10%, var(--bg)); }
.slot img, .slot .ph { width: 100%; height: 100%; object-fit: contain; }
.slot-empty { color: var(--muted); font-size: 22px; }
.slot-label { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-family: var(--font-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.slot.drop-hot { border-color: var(--accent); border-style: solid; box-shadow: 0 0 0 2px var(--accent); }
.slot.drop-bad { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }

.capacity { font-family: var(--font-mono); font-size: 12px; color: var(--muted); } .capacity b { color: var(--text); }
.cap-bar { height: 3px; background: var(--line); margin: -4px 0 12px; } .cap-bar i { display: block; height: 100%; background: var(--accent); }
.grid-wrap { width: 100%; }
.grid { --cs: 48px; --gap: 3px; --p: calc(var(--cs) + var(--gap)); position: relative;
  width: calc(var(--cols) * var(--p) - var(--gap)); height: calc(var(--rows) * var(--p) - var(--gap)); }
.cell, .gi, .ghost-target { position: absolute; left: calc(var(--x) * var(--p)); top: calc(var(--y) * var(--p)); }
.cell { width: var(--cs); height: var(--cs); border: 1px solid var(--line); background: var(--bg); border-radius: 2px; }
.gi { --w: 1; --h: 1; width: calc(var(--w) * var(--p) - var(--gap)); height: calc(var(--h) * var(--p) - var(--gap)); z-index: 2;
  border: 1px solid var(--r); border-radius: 3px; overflow: hidden; touch-action: none; cursor: grab;
  background: linear-gradient(180deg, color-mix(in srgb, var(--r) 22%, var(--surface2)), color-mix(in srgb, var(--r) 8%, var(--surface))); background-size: 100% 100%; }
.gi-art { position: absolute; inset: 3px; display: grid; place-items: center; pointer-events: none; }
.gi-art img, .gi-art .ph { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.gi.rot .gi-art, .gi-art.rot { inset: auto; left: 50%; top: 50%;
  width: calc(var(--iw) * (var(--cs) + var(--gap)) - var(--gap) - 6px); height: calc(var(--ih) * (var(--cs) + var(--gap)) - var(--gap) - 6px);
  transform: translate(-50%, -50%) rotate(90deg); }
.gi-name { position: absolute; left: 4px; top: 3px; right: 4px; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-shadow: 0 1px 2px #000; pointer-events: none; }
.gi-qty { position: absolute; right: 3px; bottom: 2px; font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--text); text-shadow: 0 1px 2px #000; pointer-events: none; }
.gi.lifted { opacity: .25; }
.ghost-target { width: calc(var(--w) * var(--p) - var(--gap)); height: calc(var(--h) * var(--p) - var(--gap)); z-index: 3; pointer-events: none;
  border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 3px; }
.ghost-target.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, transparent); }
.grid.placing .cell { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }

.drag-ghost { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; border: 2px solid var(--r); border-radius: 4px;
  background: color-mix(in srgb, var(--r) 22%, var(--surface2)); box-shadow: 0 12px 30px rgba(0, 0, 0, .6); opacity: .92; }
.drag-rotate { position: fixed; z-index: 90; right: 16px; top: calc(var(--safe-top) + 70px); width: 74px; height: 74px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); touch-action: none; }
.drag-rotate .ico { width: 26px; height: 26px; }

.tray { position: relative; }
.tray.drop-hot { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.hand { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.hand-card { flex: none; width: 92px; scroll-snap-align: start; touch-action: pan-x; }
.hand-card.lifted { opacity: .3; }
.held-bar { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar) + var(--safe-bottom) + 8px); z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: var(--surface2); border: 1px solid var(--accent); border-radius: 6px; padding: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); animation: pop .2s; }
.held-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.held-info img, .held-info .ph { width: 36px; height: 36px; object-fit: contain; flex: none; }
.held-info div { display: flex; flex-direction: column; }

/* ---------- Pull ---------- */
.input.code { font-family: var(--font-mono); letter-spacing: .2em; text-transform: uppercase; flex: 1; }
.shake { animation: shake .35s; border-color: var(--danger); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.results { display: flex; flex-direction: column; margin-top: 10px; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.result-ico { width: 42px; height: 42px; object-fit: contain; flex: none; border: 1px solid var(--r); border-radius: 3px; padding: 3px; background: var(--bg); }
.result .ph.result-ico { width: 42px; height: 42px; }
.result-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.claimed { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- More ---------- */
.char-list { display: flex; flex-direction: column; }
.char { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.char:last-child { border-bottom: 0; }
.char-main { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 0; text-align: left; }
.char.on .char-main b::before { content: "▸ "; color: var(--accent); }
.warns { margin: 8px 0; padding-left: 18px; font-size: 13px; line-height: 1.4; }
.warns li { margin-bottom: 6px; } .warns li.error b { color: var(--danger); } .warns li.warn b { color: #ffb020; }
.settings p { margin: 0 0 8px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-bottom) + 14px); transform: translate(-50%, 20px); z-index: 100; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 4px; font-size: 13px; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); color: #fff; }

@media (min-width: 700px) {
  #view { padding: 20px; }
  #view > * { max-width: 640px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Containers ---------- */
.pools { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.pool-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); text-align: center; }
.pool-tile .pool-art { width: 64px; height: 64px; object-fit: contain; }
.pool-tile b { font-size: 13px; }
.pool-tile:active { border-color: var(--accent); }
.pool-hero { display: grid; place-items: center; }
.pool-hero .pool-art { width: 120px; height: 120px; object-fit: contain; }
.pool-view h3 { text-align: center; text-transform: uppercase; letter-spacing: .12em; font-family: var(--font-display); }
.pool-view > p { text-align: center; }
.odds { display: flex; flex-direction: column; gap: 6px; }
.odd { display: grid; grid-template-columns: 74px 1fr 48px; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.odd span { color: var(--r); }
.odd i { display: block; height: 6px; background: var(--r); border-radius: 1px; }
.odd b { text-align: right; font-weight: 600; }
.take-mark { position: absolute; bottom: 8px; right: 8px; z-index: 5; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 14px; }
.flip.skip .flip-front .card { opacity: .3; filter: grayscale(1); }
.flip.skip .take-mark { background: var(--surface2); color: var(--muted); border: 1px solid var(--line); }
.flip.skip .take-mark::before { content: "✕"; } .flip.skip .take-mark { font-size: 0; } .flip.skip .take-mark::before { font-size: 13px; }

/* ---------- Paperdoll ---------- */
.doll-stage { position: relative; height: min(52vh, 460px); margin: -12px -12px 10px; background:
  radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 24px 24px, linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 24px 24px, var(--bg);
  border-bottom: 1px solid var(--line); display: grid; place-items: center; }
.doll-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.doll-hud { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.doll-hud > * { pointer-events: auto; }
.slot-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -2px 12px; padding: 0 2px 4px; }
.slot-tab { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 88px; text-align: left; }
.slot-tab b { font-size: 12px; font-weight: 600; white-space: nowrap; }
.slot-tab.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.part-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.part-tile { --r: var(--line); position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-size: 12px; text-align: center; }
.part-tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.part-tile .part-thumb, .part-tile .ph { width: 72px; height: 72px; object-fit: contain; image-rendering: auto; }
.part-tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--r); }
.part-tile.locked { opacity: .55; }
.part-tile .lock { position: absolute; top: 6px; right: 6px; font-style: normal; font-family: var(--font-mono); font-size: 8px; letter-spacing: .1em; padding: 2px 4px; background: var(--surface2); border: 1px solid var(--line); border-radius: 2px; }
.part-none { width: 72px; height: 72px; display: grid; place-items: center; font-size: 28px; color: var(--muted); border: 1px dashed var(--line); }
.variants { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.swatch i { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); }
.swatch.on { border-color: var(--accent); }

/* Atlas sprites: contain-fit a slice of an atlas PNG */
.sprite-box { width: 100%; height: 100%; display: grid; place-items: center; container-type: size; }
.sprite { width: min(100cqw, calc(100cqh * var(--ar))); aspect-ratio: var(--ar); background-repeat: no-repeat; }
.card-art .sprite-box { width: 92%; height: 92%; }

/* ---------- v2: field, vault, base ---------- */
.topbar { gap: 8px; }
#status { margin-left: auto; }
.who-btn { max-width: 38%; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.status-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-chip.infil { border-color: var(--accent); color: var(--accent); }
.status-chip.infil i { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
.seg button { flex: 1; min-height: 38px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.seg button.on { background: var(--surface2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.wallet-bar { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 4px 12px; }
.wallet-bar .num { font-size: 20px; color: var(--accent); }
.row.between { justify-content: space-between; }
.block.closed { border-style: dashed; color: var(--muted); }

.pattern-wrap { display: grid; place-items: center; }
.pattern { width: min(70vw, 260px); aspect-ratio: 1; touch-action: none; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.pl-dot { fill: var(--surface2); stroke: var(--muted); stroke-width: 2; transition: r .1s; }
.pl-dot.on { fill: var(--accent); stroke: var(--accent); r: 12; }
.pl-dot.bad { fill: var(--danger); stroke: var(--danger); }
.pl-line { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.pl-live { stroke: var(--accent); stroke-width: 3; opacity: .4; stroke-linecap: round; }

.bb-list, .shop, .recipes { display: flex; flex-direction: column; }
.bb-row, .shop-row, .recipe { --r: var(--line); display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bb-row:last-child, .shop-row:last-child, .recipe:last-child { border-bottom: 0; }
.shop-row .result-text, .recipe .result-text, .bb-row .result-text { flex: 1; }
.shop-art { width: 56px; height: 56px; flex: none; border: 1px solid var(--r); border-radius: 3px; background: var(--bg); padding: 4px; display: grid; place-items: center; }
.shop-art img, .shop-art .ph { width: 100%; height: 100%; object-fit: contain; }
.shop-row.locked { opacity: .5; }
.costs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cost { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; }
.cost.short { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.recipe.short { opacity: .7; }

.faction { border-left: 3px solid var(--f); }
.fac-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.fac-head h2 { margin: 0 0 2px; color: var(--f); }
.fac-img { width: 52px; height: 52px; object-fit: contain; flex: none; }
.dialog .fac-img { width: 80px; height: 80px; align-self: center; }
.tiers-line { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; margin: 10px 0; }
.tl { border: 1px solid var(--line); border-radius: 3px; padding: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.tl span { color: var(--muted); font-size: 10px; }
.tl.open { border-color: var(--f); }
.tl.done { background: color-mix(in srgb, var(--f) 18%, transparent); border-color: var(--f); }
.next-up { display: flex; flex-direction: column; gap: 8px; }
.next-up p { margin: 0; font-size: 13px; }

.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }

.mods { list-style: none; padding: 0; margin: 2cqw 0; display: flex; flex-direction: column; gap: 3px; }
.mods li { font-size: inherit; padding: 2px 6px; border-left: 2px solid var(--line); }
.mods li.calc { border-color: var(--accent); }
.mods li.table { color: var(--muted); }
.effects li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 6px 8px; }
.effects .src { color: var(--muted); font-size: 11px; white-space: nowrap; }
.card .mods li { font-size: 3.6cqw; }
.mod-row { display: flex; flex-wrap: wrap; gap: 1.5cqw; margin: 1cqw 0 2cqw; }
.mod-pip { font-family: var(--font-mono); font-size: 3.2cqw; padding: .8cqw 2cqw; border: 1px dashed var(--line); border-radius: 2px; color: var(--muted); }
.mod-pip.on { border: 1px solid var(--r); color: var(--text); }
.shell-ab { border: 1px solid var(--line); border-radius: 3px; padding: 2cqw 3cqw; margin: 2cqw 0; font-size: 3.8cqw; }
.shell-ab p { margin: 1cqw 0; }
.sa-head { display: flex; justify-content: space-between; align-items: center; }
.mod-panel { width: min(78vw, 340px); display: flex; flex-direction: column; gap: 6px; }
.mod-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mod-slot { --r: var(--line); aspect-ratio: .8; border: 1px dashed var(--line); border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px; font-size: 10px; text-align: center; background: var(--bg); }
.mod-slot.filled { border: 1px solid var(--r); }
.mod-slot .mod-ico { width: 36px; height: 36px; object-fit: contain; }
.mod-slot .label { font-size: 8px; }

.ab-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.ab { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.ab p { margin: 0; } .ab .btn { align-self: flex-start; }
.ab-top { display: flex; justify-content: space-between; gap: 8px; }
.acts > .label { display: block; margin-top: 10px; }
.overheat { margin: 8px 0 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--danger); }
.track-die .roll { color: var(--text); font-size: 13px; }

.identity .fragments { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.identity .fragments button { text-align: left; font-size: 14px; line-height: 1.4; font-style: italic; }
.identity .fragments li::marker { color: var(--accent); font-family: var(--font-mono); font-size: 11px; }
.worn { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

.pool-tile.locked { opacity: .5; }
.widemodal { width: min(96vw, 900px); }
.atlas-picker .ap-scroll { overflow: auto; max-height: 50dvh; border: 1px solid var(--line); border-radius: 4px; background: #000; }
.ap-stage { position: relative; background-repeat: no-repeat;
  background-image: none; image-rendering: auto; }
.ap-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px) 0 0 / var(--g) var(--g), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px) 0 0 / var(--g) var(--g); }
.ap-sel { position: absolute; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; z-index: 2; }
.ap-preview { width: 96px; height: 96px; flex: none; border: 1px solid var(--line); background: var(--bg); padding: 4px; }
.snippet { flex: 1; margin: 0; font-family: var(--font-mono); font-size: 11px; white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; padding: 8px; }

/* Item index */
.index-link { width: 100%; display: flex; align-items: center; justify-content: space-between; text-align: left; }
.index-link h2 { margin: 0 0 4px; }
.index-link .chev { font-size: 22px; color: var(--accent); }
.catalog { display: flex; flex-direction: column; gap: 10px; }
.catalog > .block-head { margin-bottom: 0; justify-content: flex-start; }
.catalog > .block-head h2 { margin: 0; }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.fchip { --r: var(--line); flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.fchip.on { border-color: var(--r); color: var(--text); box-shadow: inset 0 0 0 1px var(--r); }
.fchip:first-child.on { --r: var(--accent); }
.catalog-body > p { margin: 0 0 6px; }
.btn.primary:disabled { background: var(--surface2); color: var(--muted); border-color: var(--line); opacity: 1; }

/* ---------- v3: top bar actions ---------- */
.status-chip.home { border-color: var(--accent); color: var(--accent); }
.status-chip.home i { background: var(--accent); }
.status-chip.exfil { border-color: var(--accent); background: var(--accent); color: var(--accent-text); font-weight: 700; }
.status-chip.lost { border-color: var(--danger); color: var(--danger); }
.status-chip.lost i { background: var(--danger); }
.status-group { display: flex; align-items: center; gap: 6px; }
.status-group .zone { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.status-group .zone i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.4s infinite; flex: none; }

/* ---------- Loot piles ---------- */
.pile-list { display: flex; flex-direction: column; }
.pile-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); text-align: left; }
.pile-row:last-child { border-bottom: 0; }
.pile-row .result-text { flex: 1; }
.pile-row .chev, .implant-row .chev { color: var(--accent); font-size: 18px; }
.pile-stack { position: relative; width: 34px; height: 44px; flex: none; }
.pile-stack i { position: absolute; inset: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--surface2); }
.pile-stack i:nth-child(1) { transform: rotate(-8deg); } .pile-stack i:nth-child(2) { transform: rotate(5deg); }
.pile-stack i:nth-child(3) { border-color: var(--accent); background: linear-gradient(135deg, var(--surface2), var(--bg)); }
.pile-row.dropped .pile-stack i:nth-child(3) { border-color: var(--muted); }
.tray.loot { position: sticky; top: -12px; z-index: 5; border-color: var(--accent); box-shadow: 0 8px 18px rgba(0, 0, 0, .45); }
.tray.loot h2 { font-size: 11px; }
.tray-hint { margin: 6px 0 0; font-size: 11px; }
.hand-card.face-down { flex: none; width: 92px; cursor: pointer; animation: none; }
.hand-card.face-down .card { pointer-events: none; }
.hand-card.face-down:active { transform: scale(.97); }
.ghost-target.swap { border-color: #ffb020; background: color-mix(in srgb, #ffb020 18%, transparent); }

/* ---------- Cradle drawers ---------- */
.track.closed { padding: 0; }
.drawer-head { width: 100%; display: grid; grid-template-columns: 1fr auto 18px; grid-template-areas: "name die chev" "meter meter meter"; align-items: center; gap: 6px 10px; padding: 12px; text-align: left; }
.track:not(.closed) .drawer-head { padding: 0 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.drawer-head .track-name { grid-area: name; }
.drawer-die { grid-area: die; font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.drawer-die b { color: var(--accent); font-size: 15px; }
.drawer-head .chev { grid-area: chev; color: var(--muted); }
.drawer-meter { grid-area: meter; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.drawer-meter i { display: block; height: 100%; background: var(--accent); }
.track:not(.closed) .track-head { display: none; }

/* ---------- Shield ---------- */
.shield { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--bg); --sh: #3fb6ff; }
.shield-bars { display: flex; gap: 4px; height: 16px; }
.sbar { position: relative; border: 1.5px solid color-mix(in srgb, var(--sh) 60%, var(--line)); border-radius: 3px; overflow: hidden; background: color-mix(in srgb, var(--sh) 8%, transparent); }
.sbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--sh) 85%, white), var(--sh)); transition: width .25s; }
.shield-bars.single .sbar { border-width: 2px; }
.shield.cracked { --sh: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.shield.cracked .shield-bars { background: repeating-linear-gradient(115deg, transparent 0 10px, color-mix(in srgb, var(--danger) 35%, transparent) 10px 12px); }
.crack-label { color: var(--danger); letter-spacing: .14em; font-size: 14px !important; }
.shield .res-steps { flex-wrap: wrap; }
.shield p { margin: 8px 0 0; }
.res.health { margin-top: -6px; }

/* ---------- Overheat ---------- */
.overheat-wrap { position: relative; }
.overheat-wrap .boxes { filter: saturate(.6) brightness(.7); }
.overheat-banner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--danger) 30%, transparent) 0 10px, color-mix(in srgb, var(--danger) 18%, transparent) 10px 20px);
  border: 2px solid var(--danger); border-radius: 4px; color: #fff; text-shadow: 0 1px 3px #000; pointer-events: none; animation: pulse 1.2s infinite; }
.overheat-banner b { font-family: var(--font-mono); letter-spacing: .25em; font-size: 15px; }
.overheat-banner span { font-size: 11px; }
@keyframes pulse { 50% { box-shadow: 0 0 18px color-mix(in srgb, var(--danger) 60%, transparent); } }

/* ---------- Downed ---------- */
.downed { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--danger) 25%, rgba(0,0,0,.85)), rgba(0, 0, 0, .92)); animation: fade .25s; }
.downed-box { width: min(100%, 360px); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.downed-box h2 { margin: 0; font-family: var(--font-display); font-size: 26px; letter-spacing: .18em; text-transform: uppercase; color: var(--danger); }
.downed-box p { margin: 0 0 8px; }
.downed-mark { font-size: 44px; color: var(--danger); line-height: 1; }
.downed .btn { min-height: 52px; font-size: 13px; }

/* ---------- Shell tab implants ---------- */
.implant-list { display: flex; flex-direction: column; }
.implant-row { --r: var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); text-align: left; }
.implant-row:last-child { border-bottom: 0; }
.implant-row .result-text { flex: 1; }
.implant-row .result-ico { width: 46px; height: 46px; border: 1px solid var(--r); border-radius: 3px; padding: 3px; background: var(--bg); flex: none; }
.implant-row .result-ico.empty { display: grid; place-items: center; color: var(--muted); border-style: dashed; font-size: 20px; }
.crafting-modal { background: var(--bg); border-radius: 8px; }

/* v3.1: heat shown as remaining, weapon card */
.res.heat .box.on { transition: background-color .35s, border-color .35s; }
.res.heat .res-top .res-val b { color: var(--c); }
.res.heat .overheat-wrap .boxes { filter: none; }
.weapon-card { gap: 12px; }
.wc-heat { --c: #5fe0c4; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; z-index: 2; }
.wc-heat .res-val b { color: var(--c); }
.wc-heat .box { display: block; transition: background-color .35s, border-color .35s; }
.wc-heat.over { border-color: #ff3b3b; }
.box.drain { animation: drain .7s ease-out; }
@keyframes drain { 0% { background: #fff; border-color: #fff; box-shadow: 0 0 12px #fff; } 100% { box-shadow: none; } }
.wc-cardwrap { position: relative; width: 100%; display: flex; justify-content: center; }
.wc-flash { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(10, 12, 14, .88); border: 1.5px solid var(--c, #ff7a2a); border-radius: 6px; padding: 10px 18px; opacity: 0; }
.wc-flash b { font-family: var(--font-mono); letter-spacing: .2em; font-size: 20px; color: #ff9b4a; }
.wc-flash span { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.wc-flash.go { animation: wcflash 1.3s ease-out forwards; }
@keyframes wcflash { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.9); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -75%) scale(1); } }
.wc-actions { width: 100%; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 2px; z-index: 2; }
.wc-actions .btn { flex: 1; }
.wc-fire:disabled { opacity: .5; }

/* Buyback fits the screen: header and finish row pinned, list scrolls */
.modal:has(.buyback) { overflow: hidden; display: flex; flex-direction: column; }
.dialog.buyback { min-height: 0; flex: 0 1 auto; overflow: hidden; }
.dialog.buyback .bb-list { flex: 1 1 auto; min-height: 60px; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; padding: 0 6px; }
.bb-row { gap: 8px; }
.bb-row .result-ico { width: 36px; height: 36px; }
.bb-row .result-text { min-width: 0; }
.bb-row .result-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.bb-row .btn { flex: none; white-space: nowrap; }
.dialog.buyback > .btn { flex: none; }

/* v3.2: labelled pattern dots */
.pl-dot { r: 15; }
.pl-dot.on { r: 17; }
.pl-label { font-family: var(--font-mono); font-size: 15px; font-weight: 700; fill: var(--text, #e8ecef); pointer-events: none; user-select: none; }
.pl-label.on { fill: #0b0d0f; }

/* v3.2: shield color by rarity + big cracks */
.shield { --sh: #ffffff; }
.shield-bars { height: 22px; }
.shield.cracked { --sh-c: var(--sh); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.shield.cracked .shield-bars { background: none; }
.shield.cracked .sbar { border-color: color-mix(in srgb, var(--sh) 35%, var(--line)); background: color-mix(in srgb, var(--sh) 6%, #050607); }
.shield.cracked .sbar i { width: 100% !important; background: linear-gradient(180deg, color-mix(in srgb, var(--sh) 22%, transparent), color-mix(in srgb, var(--sh) 8%, transparent)); }
.crack-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.crack-art path { fill: none; stroke-linejoin: miter; stroke-linecap: square; vector-effect: non-scaling-stroke; }
.crack-art .crack-shadow { stroke: #000; stroke-width: 5; opacity: .9; }
.crack-art .crack-line { stroke: color-mix(in srgb, var(--sh) 75%, white); stroke-width: 2; }
.shield.cracked .shield-bars { height: 30px; }

/* v3.3: damage carousel */
.damage-picker { gap: 12px; }
.dp-head { display: flex; align-items: center; justify-content: center; gap: 22px; }
.dp-big { font-size: 46px; line-height: 1; min-width: 2.6ch; text-align: center; color: var(--danger); }
.dp-wrap { position: relative; margin: 0 -18px; }
.dp-strip { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 10px 0; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); }
.dp-strip::-webkit-scrollbar { display: none; }
.dp-pad { flex: 0 0 calc(50% - 26px); }
.dp-n { flex: 0 0 46px; height: 52px; scroll-snap-align: center; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--muted);
  font-family: var(--font-mono); font-size: 18px; transition: transform .15s, color .15s, border-color .15s; }
.dp-n.on { color: #fff; border-color: var(--danger); background: color-mix(in srgb, var(--danger) 22%, var(--bg)); transform: scale(1.12); font-weight: 700; }
.dp-marker { position: absolute; left: 50%; top: 0; width: 0; height: 0; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--danger); pointer-events: none; }
.dp-preview { text-align: center; min-height: 1.4em; margin: 0; }

/* v4: weapon rounds */
.wc-ammo { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.wc-rounds { display: grid; grid-template-columns: repeat(min(var(--n), 30), 1fr); gap: 2px; }
.wc-rounds i { height: 10px; border-radius: 1px; background: var(--surface2); }
.wc-rounds i.on { background: #e9c46a; }
.act .rounds { color: var(--muted); font-family: var(--font-mono); }

/* v4: per-page line patterns so each tab feels distinct */
#view { position: relative; }
#view::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .125; background-repeat: repeat; }
#view > * { position: relative; z-index: 1; }
#view[data-tab="sheet"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2248%22%20height%3D%2248%22%3E%3Cpath%20d%3D%22M0%2024h48M24%200v48%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.5%22%20opacity%3D%22.9%22/%3E%3Cpath%20d%3D%22M22%2024h4M24%2022v4%22%20stroke%3D%22%23fff%22%20stroke-width%3D%221%22/%3E%3C/svg%3E"); }
#view[data-tab="doll"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2256%22%20height%3D%2297%22%3E%3Cpath%20d%3D%22M28%200l28%2016v32L28%2064%200%2048V16zM28%2064v33%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.6%22/%3E%3C/svg%3E"); }
#view[data-tab="combat"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%3E%3Cpath%20d%3D%22M0%2040L40%200M-10%2010L10%20-10M30%2050L50%2030%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.7%22/%3E%3C/svg%3E"); }
#view[data-tab="inventory"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2264%22%20height%3D%2264%22%3E%3Cpath%20d%3D%22M0%208h20v12h14v-12h30M8%2064v-20h12v-12M44%2064v-14h12v-20h8%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.6%22/%3E%3Ccircle%20cx%3D%2220%22%20cy%3D%2220%22%20r%3D%222%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.6%22/%3E%3Ccircle%20cx%3D%2256%22%20cy%3D%2230%22%20r%3D%222%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.6%22/%3E%3C/svg%3E"); }
#view[data-tab="pull"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%228%22%20height%3D%228%22%3E%3Cpath%20d%3D%22M0%201h8%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.5%22/%3E%3C/svg%3E"); opacity: .14; }
#view[data-tab="base"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236%22%20height%3D%2236%22%3E%3Cpath%20d%3D%22M0%200h36v36H0z%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.5%22/%3E%3Cpath%20d%3D%22M0%2018h6M30%2018h6M18%200v6M18%2030v6%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.8%22/%3E%3C/svg%3E"); }
#view[data-tab="more"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2224%22%20height%3D%2224%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%221%22%20fill%3D%22%23fff%22/%3E%3C/svg%3E"); opacity: .14; }
#view[data-tab="setup"]::before { background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2260%22%20height%3D%2260%22%3E%3Cpath%20d%3D%22M0%2030h60M30%200v60%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.4%22/%3E%3Ccircle%20cx%3D%2230%22%20cy%3D%2230%22%20r%3D%2212%22%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%22.5%22/%3E%3C/svg%3E"); }
#view[data-tab="combat"]::before { opacity: .13; background-color: transparent; box-shadow: inset 0 0 120px rgba(255, 59, 59, .25); }

/* v4: bigger infil / exfil buttons */
.status-chip.big { padding: 9px 16px; font-size: 14px; letter-spacing: .14em; font-weight: 800; font-family: var(--font-mono); }
.status-chip.home.big { background: var(--accent); color: var(--accent-text); }
.status-chip.home.big i { background: var(--accent-text); }
.lockmodal .dialog { align-items: stretch; }
.lockmodal .pattern { width: min(82vw, 320px); }
.btn.big { padding: 14px; font-size: 15px; }

/* v4: loading screen (infil / exfil) */
.loading-screen { position: fixed; inset: 0; z-index: 200; background: #050607; overflow: hidden; cursor: pointer; }
.ls-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: contrast(1.1) saturate(.9); animation: lsdrift 3s ease-out forwards; }
.ls-blank { background: radial-gradient(circle at 50% 35%, #1b2a2a, #050607 70%); }
@keyframes lsdrift { from { transform: scale(1.12); } to { transform: scale(1.02); } }
.ls-dither { position: absolute; inset: 0; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='2' height='2' fill='%23000'/%3E%3Crect x='2' y='2' width='2' height='2' fill='%23000'/%3E%3C/svg%3E"); background-size: 4px 4px; image-rendering: pixelated; }
.ls-scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0,0,0,.35) 0 2px, transparent 2px 4px); pointer-events: none; }
.ls-text { position: absolute; left: 0; right: 0; bottom: calc(60px + var(--safe-bottom)); padding: 0 28px; display: flex; flex-direction: column; gap: 10px; }
.ls-kicker { font-family: var(--font-mono); letter-spacing: .4em; font-size: 12px; color: var(--accent); }
.ls-title { position: relative; font-family: var(--font-display, var(--font-body)); font-size: 40px; line-height: 1; letter-spacing: .04em; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px rgba(0,0,0,.8); }
.ls-title::before, .ls-title::after { content: attr(data-t); position: absolute; left: 0; top: 0; width: 100%; overflow: hidden; }
.ls-title::before { color: #0ff; clip-path: inset(0 0 60% 0); transform: translateX(-2px); animation: lsglitch 1.6s steps(2) infinite; opacity: .7; }
.ls-title::after { color: #f0f; clip-path: inset(55% 0 0 0); transform: translateX(2px); animation: lsglitch 1.3s steps(2) infinite reverse; opacity: .7; }
@keyframes lsglitch { 0% { transform: translateX(-3px); } 50% { transform: translateX(3px); } 100% { transform: translateX(0); } }
.ls-progress { height: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.ls-bar { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; animation: lsprog linear forwards; }
@keyframes lsprog { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ls-skip { font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em; color: rgba(255,255,255,.5); text-transform: uppercase; }
/* glitch / dither in and out: stepped slices that tear and resolve */
.loading-screen.glitch-in { animation: glitchin .6s steps(6) both; }
.loading-screen.glitch-out { animation: glitchout .6s steps(6) both; pointer-events: none; }
@keyframes glitchin {
  0% { clip-path: inset(48% 0 48% 0); filter: contrast(3) brightness(2); transform: translateX(-12px); }
  20% { clip-path: inset(20% 0 60% 0); transform: translateX(10px); }
  40% { clip-path: inset(0 0 35% 0); filter: contrast(2) hue-rotate(60deg); transform: translateX(-6px); }
  60% { clip-path: inset(30% 0 0 0); transform: translateX(4px); }
  80% { clip-path: inset(0 0 8% 0); filter: contrast(1.4); transform: none; }
  100% { clip-path: inset(0); filter: none; transform: none; }
}
@keyframes glitchout {
  0% { clip-path: inset(0); filter: none; opacity: 1; }
  25% { clip-path: inset(10% 0 30% 0); transform: translateX(8px); filter: contrast(2) hue-rotate(-60deg); }
  50% { clip-path: inset(40% 0 20% 0); transform: translateX(-10px); filter: contrast(3) brightness(1.8); }
  75% { clip-path: inset(49% 0 49% 0); transform: translateX(6px); opacity: .8; }
  100% { clip-path: inset(50% 0 50% 0); opacity: 0; }
}

/* v4: combat tab */
.combat-head .quick-btn { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 14px; }
.qb-count { min-width: 22px; height: 22px; border-radius: 11px; background: var(--accent-text); color: var(--accent); display: inline-grid; place-items: center; font-size: 12px; padding: 0 6px; }
.quick-items .qi-list { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.qi-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qi-row .result-text { flex: 1; }
.qi-row .btn { flex: none; white-space: nowrap; }
.quick-items .label { margin-top: 8px; }

/* v4: free kit */
.free-kit .kit-items { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.kit-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--line); border-radius: 6px; }
.kit-item .result-ico { width: 34px; height: 34px; }
.free-kit.claimed { opacity: .65; }
.btn.wide { width: 100%; }

/* v4: search result rows never overflow */
.result { width: 100%; min-width: 0; }
.result-text b, .result-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.result-ico { overflow: hidden; }

/* v4: Shell stage with implant cells and callouts */
.doll-stage.cells { display: grid; grid-template-columns: 92px minmax(0, 1fr) 92px; place-items: stretch; align-items: stretch; gap: 4px; height: auto; min-height: 400px; padding: 10px 6px; }
.doll-stage.cells .imid { position: relative; min-height: 380px; }
.doll-stage.cells .doll-canvas { position: absolute; inset: 0; }
.doll-stage.cells .doll-hud { left: 0; right: 0; top: 0; bottom: auto; justify-content: center; gap: 6px; }
.icol { display: flex; flex-direction: column; justify-content: space-around; gap: 8px; position: relative; z-index: 2; }
.icell { --r: var(--line); width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 3px; border: 1px solid color-mix(in srgb, var(--r) 70%, var(--line)); border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); text-align: center; min-height: 84px; }
.icell.filled { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--r) 25%, transparent); }
.icell.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.icell.needed { border-style: dashed; border-color: var(--accent); }
.icell-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.icell-ico { width: 36px; height: 36px; object-fit: contain; }
.icell-ico.empty { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 4px; color: var(--muted); font-size: 20px; }
.icell-name { font-size: 11px; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.icell-mods { display: flex; flex-direction: column; gap: 1px; }
.icell-mods i { font-style: normal; font-family: var(--font-mono); font-size: 8.5px; line-height: 1.15; letter-spacing: 0; color: var(--r); background: color-mix(in srgb, var(--r) 12%, transparent); padding: 1px 3px; border-radius: 2px; }
.icell-sub { font-size: 9px; color: var(--muted); }
.callouts { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.callouts polyline { fill: none; stroke-width: 1.2; stroke-dasharray: 3 2; opacity: .85; }
.callouts circle { opacity: .95; }
.doll-hint { margin: 0 0 8px; }
.drawer-toggle { width: 100%; }
.cur-implant { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--r); border-radius: 6px; }
.cur-implant .result-text { flex: 1; }
.look-editor { display: flex; flex-direction: column; gap: 8px; }
.color-pick { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; }
.color-pick input { width: 32px; height: 32px; border: 0; padding: 0; background: none; border-radius: 50%; }
.color-pick input::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick input::-webkit-color-swatch { border: 1px solid rgba(255,255,255,.3); border-radius: 50%; }

/* v4: new runner setup */
body.in-setup .tabbar { display: none; }
body.in-setup #status, body.in-setup .who-btn { visibility: hidden; }
.setup { display: flex; flex-direction: column; gap: 12px; }
.setup-head { display: flex; flex-direction: column; gap: 8px; }
.setup-kicker { font-family: var(--font-mono); letter-spacing: .35em; font-size: 11px; color: var(--accent); }
.setup-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sstep { display: flex; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; color: var(--muted); }
.sstep b { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface2); font-size: 11px; }
.sstep.on { border-color: var(--accent); color: var(--text); }
.sstep.on b { background: var(--accent); color: var(--accent-text); }
.sstep.done b { background: color-mix(in srgb, var(--accent) 40%, var(--surface2)); }
.setup-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; position: sticky; bottom: 0; padding: 10px 0 calc(6px + var(--safe-bottom)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 3; }
.setup .fields .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.setup .doll-stage.cells { margin: 0 -12px; }
.starter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.starter { --r: var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 6px; text-align: center; font-size: 12px; }
.starter.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.starter-ico { width: 52px; height: 52px; object-fit: contain; }
.starter .muted { font-size: 10px; }
.block-sub { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.pool-left { font-family: var(--font-mono); font-size: 14px; color: var(--accent); }
.pool-left.zero { color: var(--muted); }
.doll-stage.cells.one-side { grid-template-columns: 104px minmax(0, 1fr) 12px; }

/* v4: atlas sprites used as small icons keep the icon's size (fixes blank search / buyback rows) */
.sprite-box.result-ico { width: 42px; height: 42px; flex: none; padding: 3px; }
.bb-row .sprite-box.result-ico { width: 36px; height: 36px; }
.implant-row .sprite-box.result-ico { width: 46px; height: 46px; }
.kit-item .sprite-box.result-ico { width: 34px; height: 34px; }
.sprite-box.icell-ico { width: 36px; height: 36px; }
.sprite-box.starter-ico { width: 52px; height: 52px; }

/* v4: bottom sheet for implant swaps so the doll stays visible above it */
.modal.sheetmodal { top: auto; bottom: 0; transform: translateX(-50%); max-height: 52dvh; width: min(100vw, 520px); padding: 0; }
.modal.sheetmodal .dialog { border-radius: 14px 14px 0 0; padding-bottom: calc(18px + var(--safe-bottom)); }
#overlay[data-cls="sheetmodal"] .scrim { background: rgba(0, 0, 0, .15); backdrop-filter: none; -webkit-backdrop-filter: none; }


/* v6.2: on-model customiser */
.color-bar { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 5px; z-index: 3; position: relative; padding: 2px 2px 0; }
.cb-tabs { display: flex; justify-content: center; gap: 4px; }
.cb-tab { padding: 4px 12px; border-radius: 999px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); background: rgba(10,12,14,.8); }
.cb-tab.on { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.cb-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: rgba(10,12,14,.85); border: 1px solid var(--line); align-self: center; max-width: 100%; }
.cb-swatch { position: relative; width: 28px; height: 28px; display: grid; place-items: center; }
.cb-swatch i { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.5); box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.cb-swatch.set i { border-color: var(--accent); }
.cb-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.cb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.cb-tool { padding: 5px 9px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--text); }
.cb-tool.active { border-color: var(--accent); color: var(--accent); }
.cb-tool.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.cb-reset { width: 26px; height: 26px; border-radius: 50%; font-size: 14px; color: var(--muted); display: grid; place-items: center; }
.cb-note { font-size: 11px; color: var(--muted); }
.cb-panel { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 10px; background: rgba(10,12,14,.92); border: 1px solid var(--line); }
.cb-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.cb-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border-radius: 999px; border: 1px solid var(--line); font-size: 11px; }
.cb-chip.on { border-color: var(--accent); color: var(--accent); }
.cb-chip.pat i { width: 20px; height: 20px; border-radius: 4px; background-color: #555; background-size: 20px 20px; background-position: center; }
.cb-range { width: 90px; accent-color: var(--accent); }
.cb-mini { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; opacity: .45; }
.cb-mini.on { border-color: var(--accent); opacity: 1; }
.height-slider { position: absolute; right: -2px; top: 50%; width: 22px; height: 60%; transform: translateY(-50%); writing-mode: vertical-lr; direction: rtl; accent-color: var(--accent); z-index: 2; opacity: .8; }

/* ---- v6.4: swatch palette, tap-to-pick, poses, templates ---- */
.cb-swatch.sel i { border-color: #fff; box-shadow: 0 0 0 2px var(--accent), 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent); }
.cb-panel-head { display: flex; justify-content: space-between; align-items: center; }
.cb-x { width: 24px; height: 24px; border-radius: 50%; color: var(--muted); font-size: 16px; display: grid; place-items: center; }
.cb-hint { margin: 0; text-align: center; font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.cb-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 6px; }
.cb-sw { position: relative; aspect-ratio: 1; min-height: 30px; border-radius: 6px; border: 1.5px solid rgba(255,255,255,.18); box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }
.cb-sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.cb-sw.orig span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.cb-sw.custom { grid-column: span 2; aspect-ratio: auto; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: rgba(255,255,255,.04); cursor: pointer; }
.cb-sw.custom i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5); flex: none; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.cb-sw.custom span { font-size: 10px; font-family: var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cb-sw.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pose-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: rgba(10,12,14,.8); }
.pose-seg button { padding: 4px 10px; font-size: 11px; font-family: var(--font-mono); letter-spacing: .06em; color: var(--muted); }
.pose-seg button.on { background: var(--accent); color: var(--accent-text); }
.doll-stage.cells .doll-hud { flex-wrap: wrap; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 12px; }
.doll-hud2 { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: center; pointer-events: none; z-index: 2; }
.doll-hud2 > * { pointer-events: auto; }
.doll-hud2 { gap: 6px; }
.pose-seg.tpl span { display: block; padding: 4px 10px; font-size: 11px; font-family: var(--font-mono); letter-spacing: .06em; color: var(--text); }
.pose-seg button { padding: 4px 8px; font-size: 10px; white-space: nowrap; }
.templates-btn { width: 100%; margin-top: 8px; }

/* ---- v6.5: downed state ---- */
.downed-bar { position: sticky; top: 0; z-index: 20; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--danger); border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 22%, rgba(8,9,10,.96)), rgba(8,9,10,.96)); box-shadow: 0 0 18px color-mix(in srgb, var(--danger) 35%, transparent); animation: pulse 2.2s infinite; display: flex; flex-direction: column; gap: 8px; }
.downed-bar.home { border-color: var(--line); animation: none; box-shadow: none; background: rgba(8,9,10,.9); }
.db-top { display: flex; justify-content: space-between; align-items: baseline; }
.db-top > b { font-family: var(--font-mono); letter-spacing: .3em; color: var(--danger); font-size: 15px; }
.downed-bar.home .db-top > b { color: var(--text); letter-spacing: .1em; }
.db-hp { font-size: 12px; color: var(--muted); } .db-hp b { font-size: 18px; color: var(--danger); }
.db-boxes { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; }
.db-box { height: 16px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--danger) 70%, transparent); background: transparent; transform: skewX(-12deg); }
.db-box.on { background: var(--danger); }
.db-note { margin: 0; font-size: 11px; color: var(--muted); }
.db-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.db-acts .btn { flex: 1 1 auto; }
.db-none { padding: 0 6px; }
.downed-note { color: var(--danger) !important; }
.db-bleed { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.db-bleed > b { color: var(--danger); font-family: var(--font-mono); letter-spacing: .06em; }
.db-bleed .btn { margin-left: auto; }
.db-rounds { display: inline-flex; gap: 3px; }
.db-rounds i { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.db-rounds i.gone { background: transparent; box-shadow: none; border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); }
.cb-gearcol { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.cb-gearcol .cb-row { align-self: flex-start; }

/* ---- v6.9: brush + floating colour menu ---- */
.cb-brush { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.04); }
.cb-brush.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cb-brush-ico { width: 20px; height: 20px; display: grid; place-items: center; }
.cb-brush-ico svg { width: 18px; height: 18px; }
.cb-brush-dots { display: inline-flex; }
.cb-brush-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.6); margin-left: -4px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.cmenu { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: rgba(10,12,14,.97); box-shadow: 0 14px 40px rgba(0,0,0,.6); max-height: calc(100vh - 24px); overflow: auto; animation: fade .15s; }
.cm-head { display: flex; align-items: center; gap: 8px; }
.cm-head b { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.cm-sub { flex: 1; font-size: 11px; color: var(--muted); }
.cm-groups { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.cm-group { display: flex; flex-direction: column; gap: 3px; }
.cm-label { font-size: 9px; font-family: var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cm-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.cm-dots .cb-swatch em { position: absolute; right: -2px; bottom: -2px; font-style: normal; font-size: 8px; font-weight: 700; background: var(--accent); color: var(--accent-text); border-radius: 4px; padding: 0 2px; line-height: 11px; }

/* v6.10: advanced implants + body gear groups */
.adv-block .adv-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 8px; }
.adv-block .adv-group { display: flex; flex-direction: column; gap: 6px; }
.cb-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.test-tag { font: 600 10px/1 var(--mono, monospace); letter-spacing: .08em; text-transform: uppercase; color: #111; background: #ffb020; border-radius: 4px; padding: 3px 6px; margin-left: auto; margin-right: 8px; }

/* v6.10.5: the customiser floats over the bottom of the 3D view (no scrolling); model and cells sit above it */
.doll-stage.cells.customizing { min-height: max(520px, calc(100dvh - 190px)); }
.doll-stage.cells.customizing .color-bar { position: absolute; left: 6px; right: 6px; bottom: 6px; max-height: 42%; overflow-y: auto; overscroll-behavior: contain; padding: 4px; border-radius: 14px;
  background: linear-gradient(to top, rgba(8,10,12,.82), rgba(8,10,12,.55)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.doll-stage.cells.customizing .doll-canvas { height: calc(100% - var(--barh, 0px)); bottom: auto; }
.doll-stage.cells.customizing .icol { padding-bottom: var(--barh, 0px); }
.doll-stage.cells.customizing .doll-hud2 { bottom: calc(var(--barh, 0px) + 2px); }
.doll-stage.cells.customizing .height-slider { top: calc((100% - var(--barh, 0px)) / 2); height: calc((100% - var(--barh, 0px)) * .6); }
/* idle stance picker (shows above Idle / Run / T when Idle is on) */
.doll-hud2 { flex-direction: column; align-items: center; }
.stance-seg button { font-size: 10px; padding: 4px 8px; }

/* v7: number pad for codes (replaces the swipe pattern lock) */
.pinpad { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pp-display { display: flex; gap: 6px; justify-content: center; align-items: center; min-height: 44px; width: min(80vw, 300px); padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); flex-wrap: wrap; }
.pp-digit { font: 700 22px/1 var(--mono, monospace); color: var(--accent); min-width: 16px; text-align: center; }
.pp-digit.bad { color: var(--danger); }
.pp-placeholder { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.pp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(80vw, 300px); }
.pp-key { aspect-ratio: 1.35; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); color: var(--text);
  font: 700 26px/1 var(--mono, monospace); touch-action: manipulation; user-select: none; }
.pp-key:active { background: var(--accent); color: #111; border-color: var(--accent); }
.pp-key.pp-fn { font-size: 22px; color: var(--muted); }
.pp-key.pp-go { color: #111; background: var(--accent); border-color: var(--accent); }
.pinpad.shake { animation: shake .4s; }
.pp-grid { position: relative; }
.pp-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pp-lines .pl-line { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.pp-lines .pl-live { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; opacity: .5; }
.pinpad.swipe .pp-grid { touch-action: none; }
.pinpad.swipe .pp-key.pp-fn { opacity: .35; pointer-events: none; }
.pp-key.lit { background: color-mix(in srgb, var(--accent) 35%, var(--surface2)); border-color: var(--accent); color: var(--accent); }
.pp-mode { margin-bottom: -2px; }
/* swipe node: the square in the middle of each number key */
.pp-key { position: relative; }
.pinpad.swipe .pp-key:not(.pp-fn)::after { content: ''; position: absolute; left: 50%; top: 50%; height: 48%; aspect-ratio: 1; width: auto;
  transform: translate(-50%, -50%); border: 1.5px solid color-mix(in srgb, var(--muted) 70%, transparent); border-radius: 6px; pointer-events: none; }
.pinpad.swipe .pp-key.lit::after { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
/* ---------- infil map ---------- */
body.map-open { overflow: hidden; }
.mapview { position: fixed; inset: 0; z-index: 45; background: #000; color: #fff; font-family: var(--font-mono); user-select: none; -webkit-user-select: none; }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.map-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map-label { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 13px; letter-spacing: .04em; color: #fff; pointer-events: auto; padding: 4px 2px; text-shadow: 0 0 4px #000, 0 0 2px #000; cursor: pointer; }
.map-label.body { font-size: 17px; pointer-events: none; }
.map-label.star { color: #ffd24a; font-size: 12px; pointer-events: none; }
.map-label.loc { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.map-label .map-lock { color: #8a8a8a; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.map-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; background: linear-gradient(#000d, #0000); z-index: 2; }
.map-title { flex: 1; text-align: center; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: #ffd24a; }
.map-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #ffd24a55; background: #000a; color: #ffd24a; font-size: 24px; line-height: 1; display: grid; place-items: center; }
.map-hint { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 58px); padding: 0 18px; line-height: 1.6; text-align: center; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #ffffff70; pointer-events: none; }
.map-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.map-code { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 12px; border: 1px solid #ffd24a; background: #000c; color: #ffd24a; font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.map-code-ico { font-size: 18px; }
.map-debug { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #ffffff80; }
.map-scan { display: none; position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: #6dff3a; opacity: 0; pointer-events: none;
  box-shadow: 0 0 6px 1px #6dff3acc, 0 0 22px 4px #4dff1a66, -40px 0 60px -10px #4dff1a33; }
/* model loading */
.imid { position: relative; }
.doll-loading { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px; background: #0a0b0ccc; border: 1px solid var(--line); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted); pointer-events: none; opacity: 0; animation: dl-in .2s ease .35s forwards; }
.dl-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: dl-rot .8s linear infinite; }
@keyframes dl-rot { to { transform: rotate(360deg); } }
@keyframes dl-in { to { opacity: 1; } }
.ph.loading { position: relative; overflow: hidden; color: transparent; }
.ph.loading::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--accent) 16%, transparent) 50%, transparent 80%); animation: dl-shim 1.2s linear infinite; }
@keyframes dl-shim { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
/* ---------- factions v2 ---------- */
.fac-list { display: flex; flex-direction: column; gap: 14px; }
.fac-banner { position: relative; display: grid; place-items: center; height: 108px; width: 100%; border-radius: 16px; border: 4px solid #000;
  box-shadow: 0 0 0 1px #ffffff1f; background: var(--f) center / cover no-repeat; color: #000; font-family: var(--font-mono); font-size: 18px; letter-spacing: .1em; text-transform: uppercase; overflow: hidden; }
.fac-banner:active { transform: scale(.985); }
.fac-dot { position: absolute; right: 12px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.fac-unmet { position: relative; height: 108px; border: 3px dashed var(--muted); border-radius: 4px; display: grid; place-items: center; color: var(--muted); font-size: 14px; letter-spacing: .06em; text-align: center; opacity: .75; }
.fac-unmet .fu-x { position: absolute; inset: 0; width: 100%; height: 100%; }
.fac-unmet .fu-x line { stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 9 7; vector-effect: non-scaling-stroke; }
.fac-unmet span { position: relative; background: var(--bg); padding: 6px 14px; max-width: 9em; }
.fac-open { position: relative; min-height: 330px; border-radius: 16px; border: 4px solid #000; box-shadow: 0 0 0 1px #ffffff1f; overflow: hidden; isolation: isolate; background: #000; }
.fo-art, .fo-slice { position: absolute; inset: 0; background: center 22% / cover no-repeat; }
.fo-art { z-index: 0; }
.fo-glitch { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.fo-slice { opacity: 0; }
.fo-tint { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(180deg, #000c 0%, #0003 34%, #0000 55%, #000d 100%), color-mix(in srgb, var(--f) 18%, transparent); mix-blend-mode: normal; }
.fo-scan { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; background: repeating-linear-gradient(0deg, #0000 0 2px, #0006 2px 3px); }
.fac-open.glitching .fo-scan { opacity: 1; }
.fac-open.glitching .fo-art { filter: drop-shadow(var(--split, 3px) 0 0 #ff003c88) drop-shadow(calc(var(--split, 3px) * -1) 0 0 #00e5ff88); }
.fo-body { position: relative; z-index: 3; min-height: 322px; display: grid; grid-template-rows: auto 1fr auto; padding: 14px; gap: 10px; }
.fo-top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; cursor: pointer; }
.fo-id { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fo-logo { height: 40px; width: auto; max-width: 170px; object-fit: contain; object-position: left; filter: drop-shadow(0 1px 3px #000); }
.fo-id h2 { margin: 0; font-size: 18px; color: #fff; text-shadow: 0 1px 4px #000; }
.fo-desc { margin: 0; max-width: 52%; font-size: 11px; line-height: 1.4; color: #ffffffd0; text-align: right; text-shadow: 0 1px 3px #000; }
.fo-actions { display: flex; flex-direction: column; gap: 8px; align-self: center; max-width: 62%; }
.fo-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--f); background: #000b; color: #fff; text-align: left; backdrop-filter: blur(3px); }
.fo-btn b { font-family: var(--font-mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--f); }
.fo-btn span { font-size: 11px; color: #ffffffb0; }
.fo-btn.supply { border-style: dashed; }
.fo-btn:disabled { opacity: .55; }
.fo-rep { justify-self: end; text-align: right; display: flex; flex-direction: column; color: #fff; text-shadow: 0 1px 4px #000; }
.fo-rep span { font-size: 12px; color: #ffffffb0; }
.fo-rep b { font-size: 22px; letter-spacing: .12em; text-transform: uppercase; }
/* unlock tree */
.tree-view { position: fixed; inset: 0; z-index: 44; background: #050607; display: flex; flex-direction: column; }
.tv-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; border-bottom: 1px solid var(--line); }
.tv-title { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tv-title span { font-family: var(--font-mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.tv-logo { height: 30px; width: auto; max-width: 160px; object-fit: contain; }
.tv-stats { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--font-mono); font-size: 11px; color: var(--f); min-width: 70px; }
.tv-stats span + span { color: var(--muted); }
.tv-scroll { flex: 1; overflow: auto; padding: 18px 10px 30px; }
.tv-canvas { position: relative; margin: 0 auto; }
.tv-lines { position: absolute; inset: 0; overflow: visible; }
.tv-lines path { fill: none; stroke: #ffffff30; stroke-width: 2; }
.tv-lines path.lit { stroke: var(--f); }
.tv-node { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; border-radius: 12px; text-align: center; border: 2px dashed #ffffff30; background: #0b0d0e; color: #ffffff70; }
.tv-node b { font-size: 12px; line-height: 1.15; }
.tv-node span { font-family: var(--font-mono); font-size: 9px; letter-spacing: .06em; }
.tv-node.open { border: 2px solid var(--f); color: #fff; box-shadow: 0 0 14px color-mix(in srgb, var(--f) 35%, transparent); }
.tv-node.open span { color: var(--f); }
.tv-node.open.short span { color: var(--bad, #ff5a5a); }
.tv-node.owned { border: 2px solid var(--f); background: var(--f); color: #000; }
.tv-hint { margin: 0; padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px); font-size: 11px; color: var(--muted); text-align: center; }
.node-sheet .kicker { font-family: var(--font-mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--f); }
.ns-rewards { margin: 6px 0 10px; padding-left: 18px; font-size: 13px; }
.ns-owned { color: var(--f); font-family: var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
.new-contact { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0; padding: 12px; border: 2px solid var(--f); border-radius: 12px; text-align: center; }
.nc-logo { height: 34px; width: auto; max-width: 180px; object-fit: contain; }
.fac-banner.art { background-color: var(--bb); background-size: auto 74%; }
.fo-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.fo-bottom .fo-actions { align-self: flex-end; max-width: 60%; }
.fo-bottom .fo-rep { flex-shrink: 0; }
/* ---------- deck search ---------- */
.deck-view { position: fixed; inset: 0; z-index: 46; display: flex; flex-direction: column; background: radial-gradient(120% 80% at 50% 35%, #15191bf2, #050607fa); backdrop-filter: blur(6px);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px calc(env(safe-area-inset-bottom, 0px) + 10px); animation: dv-in .25s ease both; }
@keyframes dv-in { from { opacity: 0; } }
.dv-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dv-top b { font-size: 16px; }
.dv-count { color: var(--muted); font-size: 12px; }
.dv-table { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; perspective: 1200px; }
.dv-stack { position: absolute; left: 50%; top: 50%; width: min(48vw, 200px); aspect-ratio: 5 / 7; transform: translate(-50%, -50%); background: none; border: 0; padding: 0; }
.dv-stack:disabled { cursor: default; }
.dv-stack.empty::after { content: 'Searched'; position: absolute; inset: 0; display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.dv-back { position: absolute; inset: 0; transform: translate(calc(var(--k) * -1.5px), calc(var(--k) * -2.5px)); filter: brightness(calc(1 - var(--k) * 0.05)); }
.dv-back > .card { width: 100%; box-shadow: 0 6px 18px #0008; }
.dv-stack:not(:disabled) .dv-back:last-child { animation: dv-nudge 2.4s ease-in-out infinite; }
@keyframes dv-nudge { 0%, 70%, 100% { transform: translate(0, 0); } 80% { transform: translate(0, -6px) rotate(-1.2deg); } 90% { transform: translate(0, 0) rotate(.6deg); } }
.dv-hand { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.dv-card { width: min(70vw, 300px, calc((100dvh - 330px) * 5 / 7)); aspect-ratio: 5 / 7; pointer-events: auto; touch-action: none; transition: transform .2s ease; z-index: 2; }
.dv-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateY(180deg); }
.dv-card.from-deck .dv-inner { animation: dv-flip .62s cubic-bezier(.2, .75, .25, 1) both; }
.dv-card.from-pile .dv-inner { animation: dv-lift .35s ease both; }
@keyframes dv-flip { 0% { transform: translateY(0) scale(.68) rotateY(0deg) rotateZ(0deg); } 45% { transform: translateY(-14%) scale(.9) rotateY(95deg) rotateZ(-4deg); } 100% { transform: translateY(0) scale(1) rotateY(180deg) rotateZ(0deg); } }
@keyframes dv-lift { from { transform: translateY(60%) scale(.5) rotateY(180deg); opacity: .4; } }
.dv-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.dv-face > .card { width: 100%; height: 100%; box-shadow: 0 18px 40px #000a; }
.dv-face-front { transform: rotateY(180deg); }
.dv-card.take { animation: dv-take .38s ease-in both; }
.dv-card.pass { animation: dv-pass .38s ease-in both; }
.dv-card.nope { animation: dv-nope .35s ease both; }
@keyframes dv-take { to { transform: translateY(-75vh) scale(.5) rotate(-6deg); opacity: 0; } }
@keyframes dv-pass { to { transform: translateY(46vh) scale(.32); opacity: .2; } }
@keyframes dv-nope { 25% { transform: translateX(-10px); } 50% { transform: translateX(9px); } 75% { transform: translateX(-5px); } }
.dv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 2px; }
.dv-actions .btn[hidden] { display: none; }
.dv-actions:has(.btn[hidden]) { grid-template-columns: 1fr; }
.dv-hint { margin: 4px 0 8px; text-align: center; font-size: 12px; color: var(--muted); min-height: 1.2em; }
.dv-pile { border-top: 1px solid var(--line); padding-top: 8px; }
.dv-label { display: block; font-family: var(--font-mono); font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.dv-bottom { display: flex; gap: 0; overflow-x: auto; min-height: 92px; align-items: center; padding: 2px 2px 4px; }
.dv-up { flex: 0 0 auto; width: 62px; margin-right: -14px; background: none; border: 0; padding: 0; transition: transform .15s; }
.dv-up:not(:disabled):active { transform: translateY(-6px); }
.dv-up > .card { width: 100%; box-shadow: -3px 0 8px #0009; }
/* debug + quick random */
.debug-block.on { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.dbg-tag { margin-left: 8px; padding: 2px 6px; border-radius: 6px; font-size: 9px; letter-spacing: .14em; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); vertical-align: middle; }
.quick-random { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 12px; border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.quick-random b { font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.quick-random span { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--line); transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: #000; }
