/* ============================================================================
   Eldritch Agency — Lovecraftian pixel-noir theme
   ========================================================================= */
@font-face {
  font-family: 'HelvetiPixel';
  src: url('/assets/UI/HelvetiPixel.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink:        #0a0b10;
  --ink-2:      #100f18;
  --panel:      #16151f;
  --panel-2:    #1e1c2b;
  --edge:       #2f2c44;
  --edge-hi:    #544f80;
  --parchment:  #cdd2ec;
  --parchment-2:#a7abcf;
  --muted:      #7a7ba0;
  --gold:       #8b6fe0;
  --gold-hi:    #b8a3ff;
  --blood:      #a5321f;
  --occult:     #7c3aed;
  --sane:       #4a86a8;
  --grit:       #dc2626;
  --awareness:  #46b4c9;
  --skuld:      #caa20a;
  --wild:       #43c46a;
  --ok:         #5b9d54;
  --bad:        #b64434;
  --font: 'HelvetiPixel', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--ink);
  color: var(--parchment);
  font-size: 28px;
  line-height: 1.5;
  image-rendering: pixelated;
  overflow: hidden;
}
img { image-rendering: pixelated; }
button { font-family: var(--font); cursor: pointer; }
h1, h2, h3 { font-weight: normal; letter-spacing: 0.5px; }

/* ---- boot ---------------------------------------------------------------- */
.boot {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at center, #15121a 0%, #0b0d0c 70%);
}
.boot-title { width: min(560px, 80vw); image-rendering: pixelated; }
.boot-sub { color: var(--muted); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }

/* ---- app shell ----------------------------------------------------------- */
#app { height: 100vh; display: flex; flex-direction: column; }
/* Shell fills the app so .content (flex:1) gets a real height for absolute pages. */
.shell { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.topbar {
  position: relative;
  display: flex; align-items: center; gap: 20px;
  height: 68px; padding: 0 18px;   /* short bar; the tall sigil is clipped to it */
  background: linear-gradient(180deg, #1a1622, #100d14);
  box-shadow: 0 3px 0 #000;
  overflow: hidden;                /* clip the overflowing logo inside the header */
  z-index: 20;
}
/* Bottom border drawn ABOVE the clipped logo (a child would otherwise paint over
   the element's own border). */
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--edge); z-index: 5; pointer-events: none; }
.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { height: 34px; }
/* Sigil logo shown at (near) its native 100px so the line-art is crisp, not a
   pixelated downscale. RGBA black line-art → invert to light on the dark bar. */
.topbar .brand img.brand-sigil { height: 84px; width: auto; image-rendering: auto; filter: invert(1) drop-shadow(0 1px 2px #000); }
.agency-name { color: var(--gold); font-size: 28px; }
.resources { margin-left: auto; display: flex; gap: 16px; }
.res {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: #0d0b10; border: 1px solid var(--edge);
  color: var(--parchment); font-size: 23px;
}
.res b { color: var(--gold-hi); font-size: 24px; }
.res .res-label { color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: 1px; }

/* ---- tab navigation ------------------------------------------------------ */
.tabs {
  display: flex; gap: 2px; padding: 6px 14px 0;
  background: #0b0a0e; border-bottom: 2px solid var(--edge);
}
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 20px 11px; background: linear-gradient(180deg, #100d16, #0a080e);
  border: 2px solid var(--edge); border-bottom: none; border-radius: 5px 5px 0 0;
  color: var(--muted); font-size: 23px; position: relative; top: 0;
  transition: background .12s, color .12s, top .1s;
}
.tab img { width: 22px; height: 22px; opacity: .55; transition: opacity .12s; }
.tab:hover { background: linear-gradient(180deg, #191324, #0f0b15); color: var(--parchment); top: 1px; }
.tab:hover img { opacity: .85; }
.tab:disabled { opacity: .35; cursor: not-allowed; }
.tab.active {
  background: linear-gradient(180deg, #20172f, #130e1b); color: var(--gold-hi);
  border-color: var(--gold); top: 0; padding-bottom: 14px;
  margin-bottom: -2px; z-index: 2; /* cover the baseline so NO line shows under the selected tab */
  box-shadow: inset 0 3px 0 var(--gold), 0 -4px 12px rgba(139,111,224,.22);
}
.tab.active img { opacity: 1; }

/* ---- content region ------------------------------------------------------ */
.content {
  flex: 1; min-height: 0; position: relative; overflow-y: auto; overflow-x: hidden; padding: 22px;
  /* Vignette over a viewport-locked cover image (set via --page-bg). The
     `fixed` attachment keeps the backdrop still while content scrolls. */
  background:
    radial-gradient(ellipse at 50% 38%, rgba(8,7,6,.38), rgba(6,6,5,.9)),
    var(--page-bg, none) center center / cover no-repeat fixed,
    var(--ink);
}
.page { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; }
.page-head { margin-bottom: 18px; }
.page-head h2 { color: var(--gold); font-size: 39px; text-shadow: 0 2px 0 #000; }
.page-head p { color: var(--parchment-2); font-size: 24px; max-width: 760px; }

/* ---- generic panel & grid ------------------------------------------------ */
.grid { display: grid; gap: 16px; }
.grid.cols3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols2 { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 2px solid var(--edge); box-shadow: inset 0 0 0 1px #09080a, 0 4px 0 #000;
}

/* ---- investigator card --------------------------------------------------- */
.card {
  background: linear-gradient(180deg, #1a1620, #120f16);
  border: 2px solid var(--edge);
  box-shadow: inset 0 0 0 1px #09080a, 0 4px 0 #000;
  display: flex; flex-direction: column; overflow: hidden;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--edge-hi); }
.card.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold), 0 4px 0 #000; }
.card.dead { filter: grayscale(.7) brightness(.7); }
.card-top { display: flex; gap: 12px; padding: 12px; }
.portrait {
  width: 76px; height: 76px; flex: none; object-fit: cover;
  background: #09080c; border: 2px solid var(--edge);
}
.card-id { flex: 1; min-width: 0; }
.card-id .name { color: var(--gold-hi); font-size: 30px; }
.card-id .sub { color: var(--muted); font-size: 21px; }
.god-chip {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 20px; padding: 2px 8px; border: 1px solid var(--edge-hi);
  color: var(--parchment);
}
.bars { padding: 0 12px 5px; display: flex; flex-direction: column; gap: 3px; }
.bar-row { display: flex; align-items: center; gap: 7px; font-size: 15px; }
.bar-row .lbl { width: 32px; color: var(--muted); }
.bar { flex: 1; height: 7px; background: #09080a; border: 1px solid #000; position: relative; }
.bar > span { position: absolute; inset: 0; right: auto; }
.bar.health > span { background: linear-gradient(180deg, #d5493a, #7c241a); }
.bar.sanity > span { background: linear-gradient(180deg, #63a9c9, #2f5f77); }
.bar.xp > span { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); }
.bar-row .val { width: 50px; text-align: right; color: var(--parchment-2); font-size: 15px; }

/* Special (non-bone) dice on the investigator card */
.card-dice { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 4px 12px 8px; }
.card-dice-l { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 1px; margin-right: 2px; }
.card-die { width: 30px; height: 30px; image-rendering: pixelated; cursor: help; transition: transform .1s; }
.card-die:hover { transform: scale(1.14); }
.card-die-wrap { display: inline-flex; align-items: center; gap: 1px; cursor: help; }
.card-die-wrap:hover .card-die { transform: scale(1.14); }
.card-die-x { color: var(--parchment-2); font-size: 17px; margin-right: 3px; }
.card-dice.none { color: var(--muted); font-size: 16px; padding: 2px 12px 8px; }

.card-foot { margin-top: auto; padding: 8px 12px; border-top: 1px solid var(--edge);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 21px; }
.afflictions { display: flex; gap: 4px; flex-wrap: wrap; }
.affliction { font-size: 19px; color: #d98a6a; border: 1px solid #5a3325; padding: 1px 6px; text-transform: capitalize; }
.status-chip { font-size: 20px; padding: 2px 9px; border: 1px solid var(--edge); color: var(--muted); }
.status-chip.idle { color: var(--ok); border-color: #35502f; }
.status-chip.expedition { color: var(--gold); border-color: var(--edge-hi); }
.status-chip.machination { color: var(--occult); border-color: #4a2a6a; }
.status-chip.cooldown { color: var(--awareness); border-color: #2f5f77; }
.status-chip.dead { color: var(--bad); border-color: #5a2a22; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  background: linear-gradient(180deg, #20192c, #140f1c);
  border: 2px solid var(--edge-hi); color: var(--parchment);
  padding: 8px 16px; font-size: 23px; box-shadow: 0 3px 0 #000;
  transition: transform .06s, background .12s;
}
.btn:hover { background: linear-gradient(180deg, #291f3a, #191224); color: var(--gold-hi); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: 0 3px 0 #000; }
.btn.primary { border-color: var(--gold); color: var(--gold-hi); background: linear-gradient(180deg, #24153d, #160c26); }
.btn.danger { border-color: var(--blood); color: #e8917f; }
.btn.small { padding: 4px 10px; font-size: 19px; box-shadow: 0 2px 0 #000; }
.btn.ghost { background: transparent; border-color: var(--edge); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- expedition list card ------------------------------------------------ */
.exp-card {
  border: 2px solid var(--edge); box-shadow: 0 4px 0 #000; overflow: hidden;
  display: flex; flex-direction: column; min-height: 220px; position: relative;
  background: #100d14;
}
.exp-card .banner { height: 130px; background-size: cover; background-position: center;
  border-bottom: 2px solid var(--edge); position: relative; }
.exp-card .banner::after { content:''; position:absolute; inset:0;
  background: linear-gradient(180deg, transparent 40%, #100d14); }
.exp-card .tier-badge { position: absolute; top: 8px; left: 8px; z-index: 2;
  background: #09080ccc; border: 1px solid var(--gold); color: var(--gold-hi);
  font-size: 16px; padding: 2px 8px; }
.exp-card .body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.exp-card .body h3 { color: var(--gold-hi); font-size: 31px; }
.exp-card .body .desc { color: var(--parchment-2); font-size: 21px; flex: 1; }
.exp-reward { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 21px; }
.exp-reward b { color: var(--gold); }

/* ---- dice ---------------------------------------------------------------- */
.dicebox { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start;
  min-height: 84px; align-items: center; padding: 6px 12px; }
/* The die is the polyhedral shape itself; the symbol sits centered on top. */
.die { width: 78px; height: 78px; position: relative; display: flex; align-items: center; justify-content: center; }
.die .dshape { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.die .faces { position: relative; z-index: 1; display: flex; gap: 3px; align-items: center; justify-content: center; }
.die .sym { position: relative; display: flex; align-items: center; justify-content: center; }
.die .sym img { filter: drop-shadow(0 1px 2px #000) drop-shadow(0 0 3px rgba(0,0,0,.85)); }
.die .sym .cnt { position: absolute; bottom: -1px; right: -3px; font-size: 23px; color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.die.rolling { animation: roll-spin .45s ease-out; }
.die.spinning { animation: roll-spin .55s linear infinite; }
.die.rolling .faces, .die.spinning .faces { opacity: 0; }
.die.landed { animation: land .25s ease-out; }
.die.preview { opacity: .82; } /* un-rolled pool preview */
/* interactive minigame die states — the highlight glow is a drop-shadow on the
   die's shape (set in JS), so it follows any silhouette (triangle, square, …). */
.die.valid, .die.discardable { cursor: pointer; }
.die.valid:hover, .die.discardable:hover { transform: scale(1.07); }
.die.invalid { opacity: .34; filter: grayscale(.7); }
/* Used dice keep a full-size box (so the row spacing never shifts) but scale
   down visually; both hit-spent and discarded get the same faded grey. */
.die.used { filter: grayscale(1); opacity: .42; transform: scale(.55); }
.die.used.discarded { opacity: .3; }
.die.die-burst { animation: die-burst .5s ease-out forwards; }
@keyframes tumble { 0%{transform:rotate(0) scale(1)} 25%{transform:rotate(90deg) scale(1.08)} 50%{transform:rotate(180deg) scale(.94)} 75%{transform:rotate(270deg) scale(1.08)} 100%{transform:rotate(360deg) scale(1)} }
@keyframes land { 0%{transform:scale(1.35)} 60%{transform:scale(.9)} 100%{transform:scale(1)} }

/* ---- encounter / play view ----------------------------------------------- */
.play { max-width: 1200px; margin: 0 auto; height: 100%; position: relative; }

/* Full-cover dice-roll board (SCA-style): darkens the encounter while the dice
   tumble in, driven by the JS sim in play.js. */
.roll-overlay {
  position: absolute; inset: 0; z-index: 40; overflow: hidden;
  border: 3px solid var(--edge-hi); box-shadow: inset 0 0 90px rgba(0,0,0,.8);
  background: radial-gradient(ellipse at 50% 58%, rgba(18,14,30,.9), rgba(4,4,8,.97));
  opacity: 1; transition: opacity .26s ease;
}
.roll-overlay.lift { opacity: 0; }
.roll-overlay .die { position: absolute; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }

/* ---- tooltips ------------------------------------------------------------ */
.tooltip {
  position: fixed; z-index: 400; max-width: 320px; pointer-events: none;
  background: linear-gradient(180deg, #1c1a28, #12111a); border: 2px solid var(--gold);
  box-shadow: 0 6px 0 #000, 0 0 24px rgba(0,0,0,.6); padding: 9px 11px;
  opacity: 0; transform: translateY(4px); transition: opacity .1s ease, transform .1s ease;
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip::after { /* arrow */
  content: ''; position: absolute; left: 50%; bottom: -8px; width: 0; height: 0; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid var(--gold);
}
.tooltip.below::after { bottom: auto; top: -8px; border-top: none; border-bottom: 8px solid var(--gold); }
.tip-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.tip-title { color: var(--gold-hi); font-size: 23px; }
.tip-tag { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 1px; margin-left: auto; }
.tip-line { display: flex; align-items: center; gap: 6px; font-size: 19px; color: var(--parchment); margin: 2px 0; }
.tip-line img { image-rendering: pixelated; }
.tip-l { color: var(--parchment-2); }
.tip-v { margin-left: auto; color: var(--gold-hi); }
.tip-text { color: var(--parchment-2); font-size: 19px; margin-top: 5px; line-height: 1.35; white-space: pre-line; }
/* die tooltip: one cell per die SIDE, each symbol drawn (duplicates shown). */
.tip-faces { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; max-width: 560px; }
/* the big single-die tooltip: let the panel grow so the large symbols lay out in
   a clean row or two instead of cramming against the 320px default cap. */
.tooltip:has(.tip-dietip) { max-width: 760px; }
.tip-dietip .tip-faces { max-width: 720px; }
.tip-face { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; background: #100e18;
  border: 1px solid var(--edge); border-radius: 4px; }
.tip-face img { image-rendering: pixelated; }
.tip-face-sym { display: inline-flex; align-items: center; gap: 1px; }
.tip-face-x { color: var(--gold-hi); font-size: 26px; font-weight: 700; }
.tip-face.blank { color: var(--muted); min-width: 48px; justify-content: center; }
.tip-face-dash { font-size: 44px; color: var(--muted); }

/* investigator "dice pool" tooltip: one row per die group, each with a compact
   faces grid. Kept tighter than the big single-die encounter tooltip. */
.tip-dicelist { max-width: 600px; }
.tip-dice-row { display: flex; flex-direction: column; gap: 2px; padding: 5px 0; border-top: 1px solid var(--edge); }
.tip-dice-row:first-of-type { border-top: none; }
.tip-dice-key { display: flex; align-items: center; gap: 6px; }
.tip-dice-icon { width: 22px; height: 22px; image-rendering: pixelated; }
.tip-dice-label { color: var(--gold); font-size: 15px; }
.tip-dice-n { color: var(--gold-hi); font-size: 15px; font-weight: 700; }
.tip-dicelist .tip-faces { max-width: 580px; gap: 4px; margin: 2px 0 0; }
.tip-dicelist .tip-face { padding: 2px 4px; }
.tip-dicelist .tip-face-x { font-size: 22px; }
.tip-dicelist .tip-face-dash { font-size: 34px; }
.tip-dicelist .tip-face.blank { min-width: 40px; }
.tooltip:has(.tip-dicelist) { max-width: 620px; }
.stage {
  position: relative; border: 3px solid var(--edge-hi); box-shadow: 0 5px 0 #000, inset 0 0 0 1px #000;
  background-size: cover; background-position: center bottom;
  height: 100%; min-height: 420px; max-height: calc(100vh - 140px);
  display: flex; flex-direction: column; overflow: hidden; background-color: #09080c;
}
/* Environment is bottom-anchored (tall images crop at the top). The top blends
   to solid black by ~25% so the banner reads; the bottom darkens for the dock. */
.stage::before { content:''; position:absolute; inset:0;
  background: linear-gradient(180deg, #000 0%, rgba(6,6,5,.9) 10%, rgba(6,6,5,.16) 25%, rgba(6,6,5,.1) 55%, rgba(6,6,5,.66) 78%, rgba(6,6,5,.96) 100%); }

/* ornate title banner */
.stage-banner { text-align: center; padding: 14px 18px 4px; position: relative; }
.stage-banner .tier-chip { position: absolute; left: 16px; top: 16px; background: #09080ccc;
  border: 1px solid var(--gold); color: var(--gold-hi); font-size: 20px; padding: 2px 10px; }
.stage-banner .enc-title { color: var(--gold-hi); font-size: 43px; text-shadow: 0 2px 0 #000, 0 0 12px rgba(139,111,224,.25);
  border-bottom: 2px solid var(--edge-hi); display: inline-block; padding: 0 26px 6px; }
.stage-banner .enc-sub { color: var(--parchment-2); font-size: 21px; margin-top: 6px; text-transform: capitalize; letter-spacing: 1px; }
.stage > * { position: relative; z-index: 1; }
/* Dungeon node-path (SCA-style sequential encounters). */
.node-path { display: flex; align-items: center; justify-content: center; padding: 10px 18px 6px; }
.node-step { display: flex; align-items: center; flex: 0 0 auto; }
.node-link { width: 44px; height: 3px; background: var(--edge); }
.node-step.done .node-link, .node-step.current .node-link, .node-step.fail .node-link { background: var(--edge-hi); }
.node-dot { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #09080c; border: 2px solid var(--edge); color: var(--muted); font-size: 23px; flex: none; }
.node-step.done .node-dot { background: #223f1e; border-color: var(--ok); color: #cfe6c4; }
.node-step.fail .node-dot { background: #3a1a14; border-color: var(--bad); color: #e8b0a4; }
.node-step.current .node-dot { border-color: var(--gold); color: var(--gold-hi); box-shadow: 0 0 10px rgba(139,111,224,.5); }
.node-step.boss .node-dot { width: 44px; height: 44px; font-size: 26px; border-width: 3px; }

.enc-desc { color: var(--parchment-2); font-size: 23px; max-width: 780px; text-align: center; margin: 2px auto 0; font-style: italic; padding: 0 18px; }
/* Scene: the encounter creature stands (bottom-anchored, large) in the environment. */
.scene { flex: 1; position: relative; display: flex; align-items: flex-end; justify-content: flex-start; min-height: 150px; overflow: hidden; }
.scene > * { position: relative; z-index: 1; }
.scene-art { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; padding-left: 7%; }
.scene-art::before { content: ''; position: absolute; left: 50%; bottom: 2%; width: 90%; height: 70%; transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(90,50,110,.32), transparent 66%); z-index: 0; }
.scene-art img { position: relative; z-index: 1; height: 135%; max-height: 736px; width: auto; max-width: 62vw;
  object-fit: contain; object-position: bottom; image-rendering: pixelated;
  transform: scaleX(-1); /* bestiary is drawn facing left; flip to face into the scene (right) */
  filter: drop-shadow(0 14px 20px rgba(0,0,0,.8)); margin-bottom: -120px; }
.scene-art.noimg { align-items: center; }
.scene-art.noimg img { display: none; }
.scene-art-ph { display: none; color: var(--muted); font-size: 25px; text-align: center; padding: 16px; }
.scene-art.noimg .scene-art-ph { display: block; }

/* Compact objective tablets, overlaid top-right (symbol + fillable slots). */
.objective-tablets { position: absolute; top: 12px; right: 14px; max-width: 380px; display: flex; flex-direction: column; gap: 8px; z-index: 4; align-items: flex-end; }
.ot-head { color: var(--gold); font-size: 16px; text-transform: uppercase; letter-spacing: 2px; text-align: right; }
.trial-tablet { background: linear-gradient(180deg, #191521, #0f0c14); border: 2px solid var(--edge-hi); border-top-color: var(--gold);
  box-shadow: 0 3px 0 #000; padding: 7px 10px; width: fit-content; } /* only as wide as its symbols */
.trial-tablet.current { border-color: var(--gold); box-shadow: 0 0 10px rgba(139,111,224,.3), 0 3px 0 #000; }
.trial-tablet.done { border-color: var(--edge); opacity: .45; filter: grayscale(1); } /* cleared: just greyed, stays put */
.trial-tablet.future { opacity: .5; }
.trial-name { color: var(--parchment-2); font-size: 16px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.trial-objs { display: flex; flex-wrap: wrap; gap: 10px; }
.obj { display: flex; gap: 5px; }
/* Required symbol: white = incomplete, inverts to black-on-gold when fulfilled. */
.osym { position: relative; width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: background .2s; }
.osym img { width: 52px; height: 52px; filter: brightness(0) invert(1); transition: filter .2s; }
.osym.done { background: var(--gold-hi); box-shadow: 0 0 9px rgba(184,163,255,.55); }
.osym.done img { filter: brightness(0); }

.outcome-slot { min-height: 40px; text-align: center; }
.assist-note { color: var(--muted); font-size: 20px; }
.outcome-banner { text-align: center; padding: 6px; font-size: 34px; letter-spacing: 2px; }
.outcome-banner.critical_success { color: var(--gold-hi); }
.outcome-banner.success { color: var(--ok); }
.outcome-banner.partial_failure { color: #7e4ad7; }
.outcome-banner.failure { color: var(--bad); }
.outcome-banner.critical_failure { color: #ff5a3c; text-shadow: 0 0 10px #a5321f; }

/* field notes — small scroll overlaid bottom-left of the scene */
.field-notes { position: absolute; left: 16px; top: 14px; width: 250px; background: #09080cd9;
  border: 1px solid var(--edge); padding: 8px 10px; z-index: 4; }
.field-notes h4 { color: var(--gold); font-size: 20px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.fn-log { display: flex; flex-direction: column-reverse; max-height: 132px; overflow-y: auto; font-size: 19px; color: var(--parchment-2); }
.fn-log p { padding: 2px 0; border-bottom: 1px solid #16131c; }

/* short bottom dock: portrait bubbles pop up out of the frame; a large action
   banner hovers just above the dice. No stats here — they only matter on a loss. */
.bottom-dock { position: relative; display: flex; align-items: flex-end; gap: 12px; padding: 10px 26px; border-top: 2px solid var(--edge-hi); background: #09080cf2; overflow: visible; }
.roll-col { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; width: 90px; } /* fixed so the bubble never shifts x */
.button-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
/* Encounter "Field Kit" pull-out drawer (left edge). The whole drawer slides;
   the arrow tab rides its right edge so it's a visible handle when closed. */
.enc-drawer { position: absolute; left: 0; top: 96px; z-index: 20; width: 236px;
  transform: translateX(-100%); transition: transform .25s ease; }
.enc-drawer.open { transform: translateX(0); }
.enc-drawer-panel { background: rgba(10,9,16,.97); border: 1px solid var(--edge-hi); border-left: none;
  border-radius: 0 10px 10px 0; box-shadow: 6px 0 20px rgba(0,0,0,.55); overflow: hidden; }
.enc-drawer-head { padding: 8px 12px; font-size: 18px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gold-hi); background: #14121c; border-bottom: 1px solid var(--edge); }
.enc-drawer-note { padding: 5px 12px; font-size: 14px; color: var(--muted); background: #100e18; border-bottom: 1px solid var(--edge); }
.enc-drawer-list { display: flex; flex-direction: column; max-height: 46vh; overflow-y: auto; padding: 6px; gap: 5px; }
.enc-drawer-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer;
  border: 1px solid var(--edge); background: #16151f; transition: background .12s, border-color .12s; }
.enc-drawer-item:hover { background: #221f30; border-color: var(--gold); }
.enc-drawer-item .edi-name { flex: 1; color: var(--parchment); font-size: 19px; }
.enc-drawer-item .edi-qty { color: var(--muted); font-size: 17px; }
.enc-drawer-item.spent { cursor: default; opacity: .42; }
.enc-drawer-item.spent:hover { background: #16151f; border-color: var(--edge); }
.enc-drawer-tab { position: absolute; left: 100%; top: 20px; width: 30px; height: 62px; padding: 0;
  background: rgba(10,9,16,.97); border: 1px solid var(--edge-hi); border-left: none; border-radius: 0 9px 9px 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 4px 0 12px rgba(0,0,0,.45); }
.enc-drawer-tab:hover { background: #221f30; }
.enc-drawer-tab .edt-bag { display: flex; align-items: center; justify-content: center; color: var(--gold); transition: color .15s ease; }
.enc-drawer-tab:hover .edt-bag, .enc-drawer.open .enc-drawer-tab .edt-bag { color: var(--gold-hi); }
.assists { display: flex; gap: 16px; flex: none; align-items: flex-end; }
.enc-bubble { position: relative; margin-top: -46px; }
.enc-bubble.sm { margin-top: -28px; }
.enc-bubble.pickable { cursor: pointer; transition: transform .1s; }
.enc-bubble.pickable:hover { transform: translateY(-3px); }
.pportrait { position: relative; width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--edge-hi);
  overflow: hidden; background: #09080c; box-shadow: 0 4px 8px rgba(0,0,0,.7); }
.pportrait.sm { width: 56px; height: 56px; border-width: 2px; }
.enc-bubble.acting .pportrait { border-color: var(--gold); box-shadow: 0 0 16px rgba(139,111,224,.55), 0 4px 8px rgba(0,0,0,.7); }
.pportrait .pimg { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.btn-roll { min-width: 100px; height: 38px; padding: 0 18px; border-radius: 6px; border: 2px solid var(--gold);
  background: linear-gradient(180deg, #23163a, #100a1a); color: var(--gold-hi);
  display: flex; align-items: center; justify-content: center; font-size: 24px; letter-spacing: 3px;
  box-shadow: 0 4px 0 #000, 0 0 14px rgba(139,111,224,.25); transition: transform .06s, background .12s; }
.btn-roll:hover { background: radial-gradient(circle at 50% 36%, #2e1d4c, #150d24); }
.btn-roll:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn-roll:disabled { opacity: .5; cursor: not-allowed; }
.btn-roll .rb-icon { width: 30px; height: 30px; image-rendering: pixelated; filter: grayscale(1) brightness(1.3); }
.btn-roll .rb-text { font-size: 21px; letter-spacing: 3px; }

/* Fixed height so the dock never changes size when dice appear/roll/settle
   (a reflowing dock was resizing the scene and rescaling the creature). */
.dice-area { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: flex-start; height: 100px; }
.enc-banner { position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: 16px; text-align: center;
  font-size: 38px; letter-spacing: 2px; color: var(--gold-hi); text-shadow: 0 2px 0 #000, 0 0 16px rgba(0,0,0,.85); pointer-events: none; }
.enc-banner:empty { display: none; }
.enc-banner.warn { color: #854ce7; }
.enc-banner.critical_success, .enc-banner.success { color: var(--ok); }
.enc-banner.partial_failure { color: #7e4ad7; }
.enc-banner.failure, .enc-banner.critical_failure { color: #ff5a3c; text-shadow: 0 0 12px #a5321f, 0 2px 0 #000; }
.stage-retreat { position: absolute; top: 14px; right: 16px; z-index: 5; }

/* ---- encounter animations & juice ---------------------------------------- */
@keyframes roll-spin { 0% { transform: rotate(0) scale(1); } 30% { transform: rotate(150deg) scale(1.12); } 70% { transform: rotate(320deg) scale(.92); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes die-burst { 0% { transform: scale(1); opacity: .85; } 100% { transform: scale(2.3); opacity: 0; } }
.sym-flyer img { width: 42px; height: 42px; filter: brightness(0) invert(1) drop-shadow(0 0 8px var(--gold-hi)); }
.crash-ring { width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--gold-hi);
  box-shadow: 0 0 12px var(--gold-hi); animation: crash-ring .4s ease-out forwards; }
@keyframes crash-ring { 0% { width: 10px; height: 10px; opacity: 1; } 100% { width: 80px; height: 80px; opacity: 0; } }
.osym.just-done { animation: osym-pop .45s ease-out; }
@keyframes osym-pop { 0% { transform: scale(1); } 45% { transform: scale(1.6); box-shadow: 0 0 16px var(--gold-hi); } 100% { transform: scale(1); } }
.trial-tablet.exiting { animation: trial-exit .6s ease-in .32s forwards; } /* delay: let the hit land first */
@keyframes trial-exit { 0% { transform: translateX(0) rotate(0); } 14% { transform: translateX(-7px) rotate(-2deg); } 30% { transform: translateX(7px) rotate(2deg); }
  46% { transform: translateX(-3px) rotate(-1deg); } 60% { transform: translateX(0); } 100% { transform: translateX(150%) rotate(6deg); opacity: 0; } }
.scene-art.hit { animation: art-hit .38s ease-out; }
@keyframes art-hit { 0% { transform: translateX(0); } 20% { transform: translateX(-10px); filter: brightness(1.5); } 45% { transform: translateX(8px); } 70% { transform: translateX(-4px); } 100% { transform: translateX(0); } }
@keyframes tablet-fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(360px) rotate(10deg); opacity: 0; } }
/* A defeated encounter sinks off the bottom after its objectives fall away. */
.stage.enc-sink { animation: enc-sink .6s ease-in forwards; }
@keyframes enc-sink { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(80vh); opacity: 0; } }
/* ROLL button drawn ABOVE the agent; the button area keeps a fixed height so the
   bubble never shifts whether a button is shown or not. */
/* Roll column is a FIXED die-height box so it never grows the dock. Its children
   are positioned absolutely: the square Roll tile bottom-aligns with the dice row
   (like another die), and the acting bubble floats above it, poking over the dock's
   top edge. */
.roll-col { position: relative; height: 86px; overflow: visible; gap: 0; }
.roll-col .acting-wrap { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 1; }
.roll-col .enc-bubble { position: relative; z-index: 1; margin-top: 0; }
.roll-col .button-wrap { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); z-index: 5; margin: 0; }
.roll-col .roll-btn { width: 82px; height: 82px; padding: 0; font-size: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }

/* ---- modal --------------------------------------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(4,4,3,.8); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: linear-gradient(180deg, #1a1620, #100d14); border: 2px solid var(--edge-hi);
  box-shadow: 0 6px 0 #000; max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal-head { padding: 14px 18px; border-bottom: 2px solid var(--edge); display: flex; align-items: center; }
.modal-head h3 { color: var(--gold-hi); font-size: 28px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 2px solid var(--edge); display: flex; gap: 10px; justify-content: flex-end; }

/* ---- settings modal ------------------------------------------------------- */
.settings { display: flex; flex-direction: column; gap: 18px; min-width: 340px; }
.set-sec-h { color: var(--gold); font-size: 18px; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; }
.set-sec.danger .set-sec-h { color: var(--blood); }
.set-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.set-label { width: 108px; color: var(--parchment-2); font-size: 20px; }
.set-ctl { flex: 1; display: flex; align-items: center; gap: 8px; }
.set-input { flex: 1; background: #0d0b10; color: var(--parchment); border: 1px solid var(--edge-hi);
  padding: 7px 9px; font-family: var(--font); font-size: 20px; }
.set-slider { flex: 1; accent-color: var(--gold); }
.set-vol-val { width: 46px; text-align: right; color: var(--gold-hi); font-size: 18px; }
.set-danger-note { color: var(--muted); font-size: 17px; margin-bottom: 8px; line-height: 1.4; }

/* debrief (SCA victory tablet) */
.debrief { text-align: center; }
.db-title { font-size: 48px; letter-spacing: 5px; margin-bottom: 6px; text-shadow: 0 2px 0 #000; }
.db-title.win { color: var(--ok); text-shadow: 0 0 16px rgba(91,157,84,.55), 0 2px 0 #000; }
.db-title.loss { color: var(--bad); text-shadow: 0 0 16px rgba(165,50,31,.55), 0 2px 0 #000; }
.db-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0 6px; }
.db-chip { background: #0d0b10; border: 1px solid var(--edge-hi); border-top: 2px solid var(--gold); padding: 8px 14px; min-width: 76px; }
.db-chip-v { display: block; color: var(--gold-hi); font-size: 31px; }
.db-chip-l { display: block; color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: 1px; }
.db-line { margin-top: 8px; color: var(--parchment-2); font-size: 21px; }
.db-refs { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; vertical-align: middle; }
.db-line.gold { color: var(--gold-hi); }
.db-line.loss { color: #e8917f; }

/* selectable assign list */
.assign-list { display: flex; flex-direction: column; gap: 8px; }
.assign-item { display: flex; gap: 10px; align-items: center; padding: 8px; border: 2px solid var(--edge); background: #120f16; }
.assign-item.picked { border-color: var(--gold); }
.assign-item.disabled { opacity: .4; }
.assign-item img { width: 44px; height: 44px; border: 1px solid var(--edge); background: #09080c; }
.assign-item .ai-body { flex: 1; }

/* ---- inventory ----------------------------------------------------------- */
.inv-item { display: flex; gap: 10px; padding: 10px; align-items: center; }
.inv-item .qty { color: var(--gold-hi); }
.inv-use { flex: none; }
.rarity-common { color: var(--parchment-2); }
.rarity-uncommon { color: #6fb26a; }
.rarity-rare { color: #6f8fd6; }

/* ---- machinations (idle investigations) ---------------------------------- */
.mach-progress { height: 8px; margin: 0 12px 8px; background: #09080a; border: 1px solid #000; position: relative; }
.mach-progress-fill { position: absolute; inset: 0; right: auto; width: 0; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); transition: width 1s linear; }
.mach-remaining { color: var(--gold-hi); font-size: 21px; }
.mach-avail { overflow: hidden; }
.mach-banner { height: 78px; background-size: cover; background-position: center; border-bottom: 2px solid var(--edge); }
.mach-banner.cat-investigation { background: linear-gradient(180deg, #16283a, #0e1620); }
.mach-banner.cat-training { background: linear-gradient(180deg, #1c142a, #0f0a17); }
.mach-banner.has-img { background-color: #09080c; background-size: cover; background-repeat: no-repeat; background-position: center; image-rendering: pixelated; }
.mach-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.mach-head { display: flex; align-items: center; gap: 8px; }
.mach-head .name { color: var(--gold-hi); font-size: 25px; flex: 1; }
.cat-chip { font-size: 15px; text-transform: uppercase; letter-spacing: 1px; padding: 1px 8px; border: 1px solid var(--edge-hi); color: var(--parchment-2); }
.cat-chip.cat-investigation { color: var(--awareness); border-color: #2f5f77; }
.cat-chip.cat-training { color: #7e4ad7; border-color: #37235a; }
.mach-desc { color: var(--parchment-2); font-size: 20px; }
.mach-rewards { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.rw { color: var(--muted); font-size: 19px; }
.rw b { color: var(--gold-hi); }
.rw.good b { color: var(--ok); }
.rw.bad b { color: var(--bad); }
.rw.chance { color: #71638a; font-style: italic; }
.mach-cost { color: #d98a6a; font-size: 19px; }
.rw.item, .mach-cost.item { cursor: help; text-decoration: underline dotted rgba(184,163,255,.45); text-underline-offset: 3px; }
.mach-unlocks { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; margin-top: 6px; }
.mach-unlock-head { color: var(--gold); font-size: 15px; text-transform: uppercase; letter-spacing: 1.5px; margin-right: 2px; }
.mach-unlock-bit { font-size: 16px; padding: 1px 8px; border: 1px solid var(--occult); color: #c4a8ff; cursor: help; }
.mach-unlock-bit:hover { background: rgba(124,58,237,.15); }
.mach-costs { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.mach-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; } /* pinned to the card bottom */
.mach-time { color: var(--muted); font-size: 19px; }

/* ---- shared entity cards (machination / expedition / item / investigator) --- */
.entity-card { display: flex; flex-direction: column; }
.mach-card, .exp-card { display: flex; flex-direction: column; }
.mach-card .mach-body, .exp-card .mach-body { flex: 1; }       /* push the foot to the bottom */
.entity-ref { cursor: pointer; }
.exp-card .ec-banner { position: relative; height: 92px; background-size: cover; background-position: center; border-bottom: 2px solid var(--edge); }
/* item card */
.item-card { background: linear-gradient(180deg, #1c1a28, #12111a); border: 2px solid var(--edge-hi); }
.ec-head { display: flex; align-items: baseline; gap: 8px; padding: 10px 12px 2px; }
.ec-title { color: var(--gold-hi); font-size: 23px; }
.ec-tag { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 1px; margin-left: auto; }
.ec-sub { padding: 0 12px; color: var(--parchment-2); font-size: 16px; text-transform: capitalize; }
.ec-lines { padding: 6px 12px 0; display: flex; flex-direction: column; gap: 3px; }
.ec-line { display: flex; align-items: center; gap: 6px; font-size: 18px; color: var(--parchment); }
.ec-line img { image-rendering: pixelated; }
.ec-l { color: var(--parchment-2); }
.ec-v { margin-left: auto; color: var(--gold-hi); }
.ec-text { padding: 6px 12px 12px; color: var(--parchment-2); font-size: 18px; line-height: 1.35; }

/* card shown inside a tooltip: drop the tooltip chrome, fix a readable width */
.tooltip.card-tip { padding: 0; border: none; background: none; box-shadow: none; width: 300px; max-width: 92vw; }
.tooltip.card-tip::after { content: none; }
.tooltip.card-tip .entity-card { width: 100%; }
/* bare modal: the card itself is the popup, with a close in its upper-left */
.modal.bare { background: none; border: none; box-shadow: none; padding: 0; overflow: visible; position: relative; }
.modal.bare .entity-card { width: 340px; max-width: 92vw; }
.modal-x-float { position: absolute; top: 6px; left: 6px; z-index: 3; width: 26px; height: 26px; padding: 0; line-height: 1; background: rgba(11,13,12,.85); border: 1px solid var(--edge-hi); color: var(--parchment); }
.modal-x-float:hover { color: var(--gold-hi); border-color: var(--gold); }

/* ---- toast --------------------------------------------------------------- */
#toast-layer { position: fixed; bottom: 20px; left: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: flex-start; }
.toast { background: #120f16; border: 2px solid var(--edge-hi); color: var(--parchment);
  padding: 10px 18px; box-shadow: 0 4px 0 #000; animation: toastin .2s ease-out; font-size: 21px; }
.toast.error { border-color: var(--blood); color: #e8917f; }
.toast.good { border-color: var(--gold); color: var(--gold-hi); }
@keyframes toastin { from{opacity:0; transform: translateY(8px)} to{opacity:1; transform:none} }

/* ---- landing ------------------------------------------------------------- */
.landing { height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(6, 6, 10, 0.35), rgba(3, 3, 7, 0.82)),
    url('/assets/UI/Backgrounds/background-cultist.png') center center / cover no-repeat;
  image-rendering: pixelated; }
.landing .panel { padding: 30px; text-align: center; width: min(460px, 92vw); }
.landing img.title { width: 100%; margin-bottom: 18px; }
.landing input {
  width: 100%; font-family: var(--font); font-size: 23px; padding: 10px 12px; margin: 8px 0;
  background: #0a090d; border: 2px solid var(--edge); color: var(--parchment);
}
.landing input:focus { outline: none; border-color: var(--gold); }
.landing .divider { color: var(--muted); margin: 14px 0; font-size: 19px; }

.empty { text-align: center; color: var(--muted); padding: 40px; font-size: 23px; }
.loading { text-align:center; color: var(--muted); padding: 30px; }

.muted { color: var(--muted); }
.gold { color: var(--gold-hi); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #09080c; }
::-webkit-scrollbar-thumb { background: var(--edge); border: 2px solid #09080c; }

/* ---- Debug menu (dev tools, bottom-right) -------------------------------- */
.dbg-widget { position: fixed; right: 16px; bottom: 16px; z-index: 400; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.dbg-fab { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--edge-hi); background: #14121c;
  color: var(--gold-hi); font-size: 22px; cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.5); padding: 0; }
.dbg-fab:hover { background: #221f30; border-color: var(--gold); }
.dbg-panel { display: none; width: 320px; max-height: 70vh; overflow-y: auto; background: rgba(10,9,16,.98);
  border: 1px solid var(--edge-hi); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.6); padding: 10px; }
.dbg-widget.open .dbg-panel { display: block; }
.dbg-head { font-size: 20px; letter-spacing: 1px; text-transform: uppercase; color: var(--gold-hi);
  border-bottom: 1px solid var(--edge); padding-bottom: 6px; margin-bottom: 8px; }
.dbg-row { margin-bottom: 10px; }
.dbg-row-title { font-size: 16px; color: var(--muted); margin-bottom: 4px; }
.dbg-row-ctl { display: flex; gap: 6px; align-items: center; }
.dbg-select { flex: 1; min-width: 0; background: #16151f; color: var(--parchment); border: 1px solid var(--edge-hi);
  padding: 5px 6px; font-family: var(--font); font-size: 16px; }
.dbg-num { width: 64px; background: #16151f; color: var(--parchment); border: 1px solid var(--edge-hi);
  padding: 5px 6px; font-family: var(--font); font-size: 16px; }
