/* ==========================================================================
   THE UNDERVAULTS — visual system
   Theme: the working ledger of a bureaucratic guild. Aged paper, iron-gall
   ink, ONE accent: sealing-wax red. Pulp ink/engraving textures, print-shop
   typography. No borrowed trade dress.
   ========================================================================== */

:root {
  --paper:        #e9dfc8;
  --paper-hi:     #f2ead6;
  --paper-dk:     #ddd0b2;
  --paper-shadow: #c8b993;
  --ink:          #262119;
  --ink-soft:     #4c4335;
  --ink-faint:    #8a7d66;
  --rule:         #b9aa88;
  --rule-blue:    #8fa89e;      /* ledger ruling */
  --wax:          #a5341f;      /* THE accent — sealing wax */
  --wax-bright:   #c04326;
  --wax-dim:      #7c2717;
  --ok:           #4c5b3f;

  --f-display: 'Alfa Slab One', 'Georgia', serif;
  --f-body:    'Spectral', 'Georgia', serif;
  --f-fell:    'IM Fell English', 'Georgia', serif;
  --f-mono:    'IBM Plex Mono', 'Courier New', monospace;
}

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

html { font-size: 16px; }

body {
  font-family: var(--f-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.17 0 0 0 0 0.12 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app { flex: 1; display: flex; flex-direction: column; }

/* ------------------------------------------------------------ boot ------ */
.boot { margin: 20vh auto 0; text-align: center; }
.boot-stamp {
  font-family: var(--f-mono); font-weight: 600; letter-spacing: .35em;
  color: var(--wax); border: 3px double var(--wax); display: inline-block;
  padding: .6rem 1.4rem; transform: rotate(-2deg); opacity: .85;
}
.boot-sub { margin-top: 1rem; font-family: var(--f-fell); font-style: italic; color: var(--ink-soft); }

/* --------------------------------------------------------- footer ------- */
#site-footer {
  padding: .55rem 1.2rem; text-align: center;
  font-family: var(--f-mono); font-size: .68rem; color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}
.footer-sep { margin: 0 .6em; }

/* --------------------------------------------------------- shared ------- */
.screen { flex: 1; }
.screen[hidden] { display: none !important; }

h1, h2, h3 { font-weight: 400; }

button {
  font-family: var(--f-body); font-size: .95rem; cursor: pointer;
  color: var(--ink); background: var(--paper-hi);
  border: 1.5px solid var(--ink);
  padding: .5rem 1.1rem;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .06s ease, box-shadow .06s ease, background .12s;
  position: relative;
}
button:hover { background: #fff6e0; }
button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
button.primary {
  background: var(--wax); color: var(--paper-hi); border-color: var(--wax-dim);
  box-shadow: 2px 2px 0 var(--wax-dim);
  font-weight: 600; letter-spacing: .04em;
}
button.primary:hover { background: var(--wax-bright); }
button.ghost { background: transparent; box-shadow: none; border: 1px dashed var(--ink-soft); }
button:disabled { opacity: .4; cursor: not-allowed; }

.stamp {
  display: inline-block; font-family: var(--f-mono); font-weight: 600;
  letter-spacing: .25em; color: var(--wax); border: 3px double var(--wax);
  padding: .3rem .9rem; transform: rotate(-3deg);
  mix-blend-mode: multiply; opacity: .9;
}
.stamp.big { font-size: 1.3rem; padding: .5rem 1.4rem; }
@keyframes stampIn {
  0%   { transform: rotate(-3deg) scale(2.4); opacity: 0; }
  60%  { transform: rotate(-3deg) scale(.95); opacity: 1; }
  100% { transform: rotate(-3deg) scale(1);  opacity: .9; }
}
.stamp.animate { animation: stampIn .38s cubic-bezier(.2,1.4,.4,1) both; }

.flavor { font-family: var(--f-fell); font-style: italic; color: var(--ink-soft); }

/* crossed-off items — the satisfying strikethrough */
.strike { position: relative; }
.strike::after {
  content: ''; position: absolute; left: -2px; right: 100%; top: 55%;
  height: 2px; background: var(--wax); transform: rotate(-1.2deg);
  animation: strikeDraw .45s ease-out forwards;
}
@keyframes strikeDraw { to { right: -4px; } }

/* ---------------------------------------------------------- title ------- */
#screen-title { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.title-card { max-width: 620px; text-align: center; }
.title-guild {
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .45em;
  color: var(--ink-soft); text-transform: uppercase;
}
.title-word {
  font-family: var(--f-display); font-size: clamp(2.7rem, 8vw, 4.8rem);
  line-height: 1; margin: .5rem 0 .2rem; color: var(--ink);
  text-shadow: 3px 3px 0 var(--paper-shadow);
  letter-spacing: .02em;
}
.title-word .vault-u { color: var(--wax); }
.title-word .title-the {
  display: block; font-size: .3em; letter-spacing: .55em;
  color: var(--ink-soft); text-shadow: none; margin-bottom: .28em;
}
.title-proto a { color: var(--wax); }
.title-sub {
  font-family: var(--f-fell); font-style: italic; font-size: 1.15rem;
  color: var(--ink-soft); margin-bottom: 1.4rem;
}
.title-rule { border: none; border-top: 1px solid var(--rule); margin: 1.1rem 15%; position: relative; }
.title-pitch { font-size: .98rem; line-height: 1.55; color: var(--ink-soft); margin-bottom: 1.6rem; }
.title-actions { display: flex; flex-direction: column; gap: .7rem; align-items: center; }
.title-actions button { min-width: 300px; font-size: 1.05rem; padding: .7rem 1.2rem; }
.title-proto { margin-top: 1.5rem; font-family: var(--f-mono); font-size: .68rem; color: var(--ink-faint); }
.title-seal {
  margin: 1.4rem auto 0; width: 86px; height: 86px; border-radius: 50%;
  border: 3px double var(--wax); color: var(--wax);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-mono); font-size: .5rem; letter-spacing: .18em;
  text-align: center; transform: rotate(6deg); opacity: .75;
}

.title-demo-stamp {
  display: inline-block; margin: 0 auto .9rem;
  font-family: var(--f-mono); font-weight: 600; font-size: .62rem; letter-spacing: .32em;
  color: var(--wax); border: 2px solid var(--wax); padding: .3rem .9rem;
  transform: rotate(-1.5deg); opacity: .85;
}

/* ------------------------------------------------- edition (backers) ---- */
.title-edition { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.edition-badge {
  font-family: var(--f-mono); font-weight: 600; font-size: .68rem; letter-spacing: .3em;
  color: var(--wax); border: 3px double var(--wax); display: inline-block;
  padding: .45rem 1.1rem; transform: rotate(-1.5deg); opacity: .9;
}
.edition-note {
  margin-top: .9rem; font-family: var(--f-fell); font-style: italic;
  font-size: .92rem; color: var(--ink-soft); max-width: 34rem;
  margin-left: auto; margin-right: auto;
}
.edition-link {
  background: none; border: none; box-shadow: none; padding: .2rem .4rem;
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .06em;
  color: var(--wax); text-decoration: underline; cursor: pointer;
}
.edition-link:hover { color: var(--ink); }
.edition-form { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; margin-top: .4rem; }
.edition-form[hidden] { display: none; }
.edition-form input {
  font-family: var(--f-mono); font-size: .95rem; letter-spacing: .12em;
  text-transform: uppercase; text-align: center;
  padding: .5rem .8rem; width: 12.5rem;
  color: var(--ink); background: var(--paper-hi);
  border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--paper-shadow);
}
.edition-form input:focus { outline: 2px solid var(--wax); outline-offset: 1px; }
.edition-msg { margin-top: .8rem; font-family: var(--f-fell); font-style: italic; font-size: .92rem; }
.edition-msg.err { color: var(--wax-dim); }
.edition-msg.ok { color: var(--ink-soft); }

/* ----------------------------------------------------------- gate ------- */
#screen-gate { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.gate-card { max-width: 520px; text-align: center; }
.gate-stamp {
  font-family: var(--f-mono); font-weight: 600; font-size: .72rem; letter-spacing: .35em;
  color: var(--wax); border: 3px double var(--wax); display: inline-block;
  padding: .5rem 1.2rem; transform: rotate(-2deg); opacity: .85; margin-bottom: 1.4rem;
}
.gate-word {
  font-family: var(--f-display); font-size: clamp(1.9rem, 6vw, 3rem);
  line-height: 1; color: var(--ink); letter-spacing: .02em;
  text-shadow: 2px 2px 0 var(--paper-shadow); margin-bottom: 1rem;
}
.gate-word .vault-u { color: var(--wax); }
.gate-word .gate-the {
  display: block; font-size: .32em; letter-spacing: .55em;
  color: var(--ink-soft); text-shadow: none; margin-bottom: .3em;
}
.gate-text { font-family: var(--f-fell); font-style: italic; color: var(--ink-soft); margin-bottom: 1.4rem; }
.gate-form { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.gate-form input {
  font-family: var(--f-mono); font-size: 1rem; letter-spacing: .12em;
  text-transform: uppercase; text-align: center;
  padding: .55rem .8rem; width: 15.5rem;
  color: var(--ink); background: var(--paper-hi);
  border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--paper-shadow);
}
.gate-form input:focus { outline: 2px solid var(--wax); outline-offset: 1px; }
.gate-error {
  margin-top: 1rem; font-family: var(--f-fell); font-style: italic;
  color: var(--wax-dim); font-size: .95rem;
}
.gate-hint { margin-top: 1.6rem; font-family: var(--f-mono); font-size: .72rem; color: var(--ink-faint); }
.gate-hint a { color: var(--wax); }

/* ----------------------------------------------------- class select ------ */
#screen-class { padding: 2.2rem 1rem 3rem; }
.class-wrap { max-width: 980px; margin: 0 auto; }
.class-heading { text-align: center; margin-bottom: .3rem; font-family: var(--f-display); font-size: 1.6rem; }
.class-sub { text-align: center; font-family: var(--f-fell); font-style: italic; color: var(--ink-soft); margin-bottom: 1.8rem; }
.class-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem; }
.class-card {
  border: 2px solid var(--ink); background: var(--paper-hi); padding: 1.2rem 1.3rem;
  cursor: pointer; position: relative; transition: transform .1s;
  box-shadow: 3px 3px 0 var(--paper-shadow);
}
.class-card:hover { transform: translateY(-3px); }
.class-card.selected { outline: 3px solid var(--wax); outline-offset: 2px; }
.class-card.selected::before {
  content: 'CERTIFIED'; position: absolute; top: 10px; right: -8px;
  font-family: var(--f-mono); font-size: .62rem; letter-spacing: .2em;
  color: var(--wax); border: 2px solid var(--wax); padding: .2rem .5rem;
  transform: rotate(6deg); background: var(--paper-hi);
}
.class-name { font-family: var(--f-display); font-size: 1.35rem; }
.class-tag { font-family: var(--f-fell); font-style: italic; color: var(--wax-dim); margin: .15rem 0 .6rem; }
.class-desc { font-size: .9rem; line-height: 1.5; color: var(--ink-soft); margin-bottom: .8rem; }
.class-stats { display: flex; gap: 1rem; font-family: var(--f-mono); font-size: .78rem; flex-wrap: wrap; }
.class-stats span b { color: var(--wax); }
.class-gear { margin-top: .6rem; font-size: .82rem; color: var(--ink-soft); }
.class-locked {
  margin-top: 1.4rem; display: flex; gap: .8rem; flex-wrap: wrap; justify-content: center;
}
.locked-chip {
  font-family: var(--f-mono); font-size: .68rem; color: var(--ink-faint);
  border: 1px dashed var(--ink-faint); padding: .35rem .7rem;
}
.class-confirm { text-align: center; margin-top: 1.8rem; }

/* ------------------------------------------------------------ game ------ */
#screen-game {
  display: flex; flex-direction: column; min-height: 0;
  height: calc(100vh - 34px); max-height: calc(100vh - 34px); overflow: hidden;
}

.game-header {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .55rem 1.1rem; border-bottom: 2px solid var(--ink);
  background: var(--paper-dk);
}
.gh-word { font-family: var(--f-display); font-size: 1.05rem; letter-spacing: .02em; }
.gh-word span { color: var(--wax); }
.gh-delve { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .12em; color: var(--ink-soft); }
.gh-spacer { flex: 1; }
.gh-stat { font-family: var(--f-mono); font-size: .78rem; white-space: nowrap; }
.gh-stat b { color: var(--wax); font-weight: 600; }
.gh-mode { display: flex; align-items: center; gap: .4rem; font-family: var(--f-mono); font-size: .68rem; }
.gh-mode button { font-family: var(--f-mono); font-size: .66rem; padding: .25rem .55rem; box-shadow: none; }
.gh-mode button.on { background: var(--ink); color: var(--paper-hi); }

.game-main {
  flex: 1; display: grid; grid-template-columns: minmax(380px, 1.25fr) minmax(360px, 1fr);
  gap: 0; min-height: 0;
}

/* --- vault sheet (left) --- */
.sheet-col { padding: 1rem; display: flex; flex-direction: column; align-items: center; overflow: auto; }
.sheet-head {
  width: 100%; max-width: 560px; display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-mono); font-size: .7rem; letter-spacing: .14em; color: var(--ink-soft);
  margin-bottom: .35rem;
}
.sheet-frame {
  width: 100%; max-width: 560px; border: 2px solid var(--ink);
  background: var(--paper-hi); box-shadow: 4px 4px 0 var(--paper-shadow);
  position: relative;
}
#vaultsheet { display: block; width: 100%; height: auto; }
.sheet-foot { width: 100%; max-width: 560px; margin-top: .4rem; font-family: var(--f-fell); font-style: italic; font-size: .8rem; color: var(--ink-faint); text-align: center; }

/* svg room styles */
.svg-room { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.svg-room.entrance { fill: var(--paper-dk); }
.svg-room.boss { stroke: var(--wax); stroke-width: 2.5; }
.svg-room.current { fill: #f6eecf; }
.svg-room.contested { fill: #e7d3c3; }
.svg-room.draw { stroke-dasharray: 600; stroke-dashoffset: 600; animation: roomDraw .7s ease-out forwards; }
@keyframes roomDraw { to { stroke-dashoffset: 0; } }
.svg-roomnum { font-family: 'IBM Plex Mono', monospace; font-size: 9px; fill: var(--ink-faint); }
.svg-roomglyph { font-family: 'IBM Plex Mono', monospace; font-size: 11px; fill: var(--ink-soft); }
.svg-roomglyph.wax { fill: var(--wax); }
.svg-door { fill: var(--ink); }
.svg-door.sealed { fill: var(--ink-faint); }
.svg-exit { fill: var(--wax); cursor: pointer; }
.svg-exit-halo { fill: none; stroke: var(--wax); stroke-width: 1.5; opacity: .7; cursor: pointer; }
.svg-exit-hit { fill: transparent; cursor: pointer; }
.svg-exit-group:hover .svg-exit { fill: var(--wax-bright); }
@keyframes exitPulse { 0%,100% { opacity: .25; } 50% { opacity: .85; } }
.svg-exit-halo { animation: exitPulse 1.6s ease-in-out infinite; }
.svg-grid line { stroke: var(--rule-blue); stroke-width: .5; opacity: .38; }
.svg-compass { font-family: 'IBM Plex Mono', monospace; font-size: 8px; fill: var(--ink-faint); letter-spacing: .2em; }

/* --- right panel: tabs --- */
.panel-col { border-left: 2px solid var(--ink); display: flex; flex-direction: column; min-height: 0; background: var(--paper); }
.tabs { display: flex; border-bottom: 2px solid var(--ink); }
.tab {
  flex: 1; text-align: center; padding: .5rem .3rem; cursor: pointer;
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .14em;
  color: var(--ink-soft); border-right: 1px solid var(--rule); user-select: none;
  position: relative; background: var(--paper-dk);
}
.tab:last-child { border-right: none; }
.tab.active { background: var(--paper-hi); color: var(--ink); font-weight: 600; }
.tab .badge {
  position: absolute; top: 4px; right: 8px; min-width: 15px; height: 15px;
  background: var(--wax); color: var(--paper-hi); border-radius: 50%;
  font-size: .58rem; line-height: 15px; display: none;
}
.tab .badge.show { display: block; }
.tab-panes { flex: 1; overflow-y: auto; min-height: 0; }
.pane { display: none; padding: 1rem 1.1rem 2rem; }
.pane.active { display: block; }

/* --- field desk (prompt) --- */
.desk-block { margin-bottom: 1rem; }
.desk-room-name { font-family: var(--f-display); font-size: 1.15rem; margin-bottom: .15rem; }
.desk-room-kicker { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .2em; color: var(--wax); text-transform: uppercase; }
.desk-text { font-size: .92rem; line-height: 1.55; margin: .5rem 0; }
.desk-text em { font-family: var(--f-fell); }
.desk-flavor { font-family: var(--f-fell); font-style: italic; font-size: .9rem; color: var(--ink-soft); margin: .5rem 0; }
.desk-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .8rem; }
.desk-actions button { font-size: .85rem; }
.desk-sep { border: none; border-top: 1px dashed var(--rule); margin: .9rem 0; }

/* monster card */
.mon-card {
  border: 2px solid var(--ink); background: var(--paper-hi); padding: .8rem .95rem;
  margin: .7rem 0; box-shadow: 3px 3px 0 var(--paper-shadow); position: relative;
}
.mon-card.boss-card { border-color: var(--wax); box-shadow: 3px 3px 0 #d8b8a8; }
.mon-name { font-family: var(--f-display); font-size: 1.05rem; }
.mon-roll { font-family: var(--f-mono); font-size: .64rem; color: var(--ink-faint); float: right; }
.mon-stats { display: flex; gap: .9rem; font-family: var(--f-mono); font-size: .76rem; margin: .35rem 0; flex-wrap: wrap; }
.mon-stats b { color: var(--wax); }
.mon-trait { font-size: .82rem; color: var(--ink-soft); }
.mon-flavor { font-family: var(--f-fell); font-style: italic; font-size: .84rem; color: var(--ink-soft); margin-top: .35rem; }
.mon-wounds { margin-top: .45rem; display: flex; gap: .3rem; align-items: center; font-family: var(--f-mono); font-size: .7rem; }
.wound-box {
  width: 15px; height: 15px; border: 1.5px solid var(--ink); display: inline-block; position: relative; background: var(--paper-hi);
}
.wound-box.marked::after {
  content: '✕'; position: absolute; inset: 0; color: var(--wax); font-size: 13px;
  line-height: 14px; text-align: center; font-weight: bold;
  animation: markIn .25s ease-out;
}
@keyframes markIn { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mon-dead-stamp {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%,-50%) rotate(-14deg);
  font-family: var(--f-mono); font-weight: 600; font-size: 1.15rem; letter-spacing: .3em;
  color: var(--wax); border: 3px double var(--wax); padding: .25rem .8rem;
  background: rgba(242,234,214,.7); pointer-events: none;
}

/* dice tray */
.dice-tray {
  margin: .8rem 0; padding: .8rem; border: 1.5px dashed var(--ink-soft);
  background: var(--paper-dk); text-align: center;
}
.dice-label { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .16em; color: var(--ink-soft); margin-bottom: .55rem; text-transform: uppercase; }
.dice-row { display: flex; justify-content: center; gap: .8rem; align-items: center; }
.die {
  width: 52px; height: 52px; background: var(--paper-hi); border: 2px solid var(--ink);
  border-radius: 8px; box-shadow: 2px 3px 0 var(--paper-shadow);
  display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr);
  padding: 7px;
}
.die .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); align-self: center; justify-self: center; visibility: hidden; }
.die.rolling { animation: dieShake .5s ease-in-out; }
@keyframes dieShake {
  0% { transform: translate(0,0) rotate(0); } 20% { transform: translate(-4px,-7px) rotate(-14deg); }
  40% { transform: translate(5px,-3px) rotate(10deg); } 60% { transform: translate(-5px,4px) rotate(-8deg); }
  80% { transform: translate(3px,-2px) rotate(5deg); } 100% { transform: translate(0,0) rotate(0); }
}
.die.wax { border-color: var(--wax); } .die.wax .pip { background: var(--wax); }
.dice-total { margin-top: .55rem; font-family: var(--f-mono); font-size: .95rem; }
.dice-total b { font-size: 1.2rem; color: var(--wax); }
.dice-manual { display: flex; justify-content: center; gap: .6rem; align-items: center; margin-top: .3rem; }
.dice-manual select { font-family: var(--f-mono); font-size: 1rem; padding: .3rem .4rem; background: var(--paper-hi); border: 1.5px solid var(--ink); }
.dice-manual button { font-size: .8rem; }

/* --- assessor pane (character sheet) --- */
.as-name { font-family: var(--f-display); font-size: 1.2rem; }
.as-class { font-family: var(--f-fell); font-style: italic; color: var(--wax-dim); margin-bottom: .7rem; }
.as-row { display: flex; gap: 1.1rem; font-family: var(--f-mono); font-size: .78rem; margin-bottom: .7rem; flex-wrap: wrap; }
.as-row b { color: var(--wax); }
.as-section { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .22em; color: var(--ink-soft); text-transform: uppercase; margin: 1rem 0 .4rem; border-bottom: 1px solid var(--rule); padding-bottom: .2rem; }
.fatigue-track { display: flex; gap: .28rem; flex-wrap: wrap; }
.ftg-box { width: 19px; height: 19px; border: 1.7px solid var(--ink); background: var(--paper-hi); position: relative; }
.ftg-box.marked::after {
  content: ''; position: absolute; inset: 2px;
  background: linear-gradient(to top right, transparent 44%, var(--wax) 45%, var(--wax) 55%, transparent 56%),
              linear-gradient(to bottom right, transparent 44%, var(--wax) 45%, var(--wax) 55%, transparent 56%);
  animation: markIn .25s ease-out;
}
.ftg-box.last { border-color: var(--wax); border-style: double; border-width: 3px; }
.gear-list { list-style: none; }
.gear-list li { display: flex; align-items: center; gap: .5rem; padding: .22rem 0; font-size: .88rem; }
.gear-ticks { display: flex; gap: .22rem; }
.gear-tick { width: 13px; height: 13px; border: 1.4px solid var(--ink); display: inline-block; position: relative; background: var(--paper-hi); }
.gear-tick.used::after {
  content: '✕'; position: absolute; inset: 0; color: var(--wax); font-size: 11px; line-height: 12px; text-align: center; font-weight: 700;
}
.gear-name { min-width: 90px; }
.gear-note { font-size: .72rem; color: var(--ink-faint); font-style: italic; }
.node-list { list-style: none; }
.node-list li { padding: .32rem 0; border-bottom: 1px dotted var(--rule); font-size: .84rem; }
.node-name { font-weight: 600; }
.node-cost { font-family: var(--f-mono); font-size: .68rem; color: var(--ink-faint); float: right; }
.node-locked { opacity: .45; }
.node-unlocked .node-name { color: var(--wax-dim); }
.node-unlocked .node-cost { color: var(--ok); }
.dark-warning {
  border: 2px solid var(--wax); color: var(--wax-dim); background: #ecd9c8;
  font-family: var(--f-mono); font-size: .72rem; padding: .5rem .7rem; margin-bottom: .8rem;
}

/* --- ledger pane --- */
.ledger-head { text-align: center; margin-bottom: .6rem; }
.ledger-title { font-family: var(--f-display); font-size: 1.05rem; }
.ledger-sub { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .2em; color: var(--ink-faint); }
.ledger-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.ledger-table th {
  font-family: var(--f-mono); font-size: .6rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); text-align: left; border-bottom: 2px solid var(--ink); padding: .25rem .3rem;
}
.ledger-table td { padding: .34rem .3rem; border-bottom: 1px solid var(--rule-blue); vertical-align: top; }
.ledger-table td.num { font-family: var(--f-mono); font-size: .68rem; color: var(--ink-faint); white-space: nowrap; }
.ledger-table td.amt { font-family: var(--f-mono); text-align: right; white-space: nowrap; }
.amt.pos { color: var(--ok); } .amt.neg { color: var(--wax); }
.ledger-balance {
  margin-top: .7rem; text-align: right; font-family: var(--f-mono); font-size: .9rem;
  border-top: 2px solid var(--ink); padding-top: .4rem;
}
.ledger-balance b { color: var(--wax); font-size: 1.05rem; }
.ledger-entry-flavor { font-family: var(--f-fell); font-style: italic; color: var(--ink-soft); }

/* ------------------------------------------------------ overlay --------- */
#overlay {
  position: fixed; inset: 0; background: rgba(38,33,25,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  overflow-y: auto;
}
#overlay[hidden] { display: none; }
.letter {
  background: var(--paper-hi); max-width: 640px; width: 100%; padding: 2.2rem 2.4rem;
  border: 2px solid var(--ink); box-shadow: 6px 6px 0 rgba(38,33,25,.5);
  position: relative;
  background-image:
    repeating-linear-gradient(transparent, transparent 27px, rgba(143,168,158,.25) 28px);
}
.letter-heading {
  font-family: var(--f-mono); font-weight: 600; font-size: .95rem; letter-spacing: .12em;
  border-bottom: 3px double var(--ink); padding-bottom: .5rem; margin-bottom: 1rem;
}
.letter-body { font-size: .95rem; line-height: 1.75; margin-bottom: 1.2rem; }
.letter-sign { font-family: var(--f-fell); font-style: italic; text-align: right; color: var(--ink-soft); margin-bottom: 1.4rem; }
.letter-actions { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.letter .stamp-corner { position: absolute; top: 14px; right: 18px; }

/* settlement table */
.settle-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: .8rem 0 1rem; }
.settle-table td { padding: .3rem .2rem; border-bottom: 1px solid var(--rule-blue); }
.settle-table td:last-child { font-family: var(--f-mono); text-align: right; }
.settle-total td { border-top: 2px solid var(--ink); border-bottom: none; font-weight: 700; }

/* progression tree in settlement */
.tree-wrap { margin: 1rem 0; }
.tree-xp { font-family: var(--f-mono); font-size: .8rem; margin-bottom: .6rem; }
.tree-xp b { color: var(--wax); }
.tree-node {
  display: flex; align-items: baseline; gap: .6rem; padding: .45rem .5rem;
  border: 1.5px solid var(--rule); margin-bottom: .35rem; background: var(--paper);
}
.tree-node.owned { border-color: var(--ok); background: #e4e0cd; }
.tree-node.can { border-color: var(--ink); }
.tree-node .nn { font-weight: 600; min-width: 130px; }
.tree-node .nt { flex: 1; font-size: .8rem; color: var(--ink-soft); }
.tree-node button { font-size: .72rem; padding: .25rem .6rem; white-space: nowrap; }
.tree-node .owned-mark { font-family: var(--f-mono); font-size: .66rem; color: var(--ok); letter-spacing: .1em; }

/* leaderboard */
.lb-table { width: 100%; border-collapse: collapse; font-size: .8rem; font-family: var(--f-mono); }
.lb-table th { text-align: left; font-size: .62rem; letter-spacing: .14em; border-bottom: 2px solid var(--ink); padding: .25rem; }
.lb-table td { padding: .3rem .25rem; border-bottom: 1px solid var(--rule-blue); }

/* log line updates */
.deskline { animation: fadeUp .3s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------- progressive text reveal -- */
.reveal {
  opacity: 0; transform: translateY(4px);
  transition: opacity .28s ease-out, transform .28s ease-out;
}
.revealed { opacity: 1 !important; transform: none !important; }

/* ------------------------------------------------------- floating text -- */
.float-text {
  position: fixed; z-index: 90; transform: translateX(-50%);
  font-family: var(--f-mono); font-weight: 600; font-size: .95rem;
  letter-spacing: .12em; color: var(--wax); pointer-events: none;
  text-shadow: 0 0 6px var(--paper-hi);
  animation: floatUp 1.05s ease-out forwards;
}
.float-text.miss { color: var(--ink-faint); font-weight: 400; }
.float-text.gain { color: var(--ok); }
.float-text.hurt { color: var(--wax-dim); }
.float-text.crit {
  font-size: 1.25rem; letter-spacing: .2em;
  animation: floatUp 1.05s ease-out forwards, critFlash .35s steps(2) 2;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -44px) scale(1); }
}
@keyframes critFlash { 50% { color: var(--ink); } }

.shake { animation: cardShake .34s ease-in-out; }
@keyframes cardShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-.4deg); }
  40% { transform: translateX(4px) rotate(.3deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.mon-wcount { font-family: var(--f-mono); font-size: .7rem; color: var(--wax); margin-right: .2rem; }

/* ---------------------------------------------------- assessor strip ---- */
.assessor-strip {
  width: 100%; max-width: 560px; margin-top: .55rem;
  border: 2px solid var(--ink); background: var(--paper-hi);
  box-shadow: 3px 3px 0 var(--paper-shadow);
  padding: .45rem .7rem; display: flex; flex-direction: column; gap: .3rem;
}
.strip-row { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.strip-stats { font-family: var(--f-mono); font-size: .72rem; white-space: nowrap; }
.strip-stats b { color: var(--wax); }
.strip-sep { flex: 0 0 1px; align-self: stretch; background: var(--rule); }
.strip-label {
  font-family: var(--f-mono); font-size: .6rem; letter-spacing: .14em;
  color: var(--ink-soft); text-transform: uppercase; margin-right: .15rem;
}
.strip-fatigue { display: flex; gap: .2rem; flex-wrap: wrap; }
.ftg-box.sm { width: 14px; height: 14px; border-width: 1.4px; }
.ftg-box.sm.last { border-width: 2.5px; }
.strip-dark {
  font-family: var(--f-mono); font-size: .62rem; letter-spacing: .12em;
  color: var(--paper-hi); background: var(--wax); padding: .12rem .45rem;
  animation: exitPulse 1.6s ease-in-out infinite;
}
.strip-kit { display: inline-flex; align-items: center; gap: .22rem; margin-right: .7rem; }

/* -------------------------------------------------- orientation memo ---- */
.letter.orientation { max-width: 560px; }
.letter.orientation .letter-heading { padding-right: 10.5rem; }
.letter.orientation .stamp-corner { font-size: .78rem; }
.orient-intro { font-size: .86rem; margin-bottom: 1rem; }
.orient-step { min-height: 150px; }
.orient-title {
  font-family: var(--f-mono); font-weight: 600; font-size: .8rem;
  letter-spacing: .2em; color: var(--wax); margin-bottom: .5rem;
}
.orient-body { font-size: .93rem; line-height: 1.7; }
.orient-dots { display: flex; gap: .45rem; justify-content: center; margin: .9rem 0; }
.orient-dot {
  width: 9px; height: 9px; border: 1.5px solid var(--ink-soft); border-radius: 50%;
  display: inline-block; background: transparent;
}
.orient-dot.on { background: var(--wax); border-color: var(--wax); }
.orient-dismiss {
  display: flex; align-items: center; gap: .45rem; justify-content: center;
  font-family: var(--f-mono); font-size: .68rem; color: var(--ink-soft);
  margin-bottom: 1rem; cursor: pointer;
}
.orient-dismiss input { accent-color: var(--wax); }

#help-btn { font-family: var(--f-display); min-width: 30px; }
#text-speed { min-width: 96px; }

/* --------------------------------------------------- boss meter --------- */
.mon-meter {
  margin-top: .5rem; padding-top: .45rem; border-top: 1.5px dashed var(--wax);
  font-family: var(--f-mono); font-size: .72rem; letter-spacing: .08em; color: var(--wax-dim);
}
.mon-meter b { color: var(--wax); font-size: .95rem; }

/* ------------------------------------------------- XP progression forks - */
.fork {
  border: 1.5px solid var(--rule); background: var(--paper-hi); padding: .55rem .7rem;
  margin: .55rem 0; box-shadow: 2px 2px 0 var(--paper-shadow);
}
.fork.can { border-color: var(--ink); }
.fork.resolved { border-color: var(--ok); background: #e4e0cd; }
.fork.locked { opacity: .72; }
.fork-head { display: flex; justify-content: space-between; align-items: baseline; }
.fork-name { font-family: var(--f-display); font-size: .92rem; }
.fork-cost { font-family: var(--f-mono); font-size: .68rem; letter-spacing: .12em; color: var(--wax); }
.fork.resolved .fork-cost { color: var(--ok); }
.fork-prompt { font-family: var(--f-fell); font-style: italic; font-size: .82rem; color: var(--ink-soft); margin: .2rem 0 .45rem; }
.fork-opts { display: flex; flex-direction: column; gap: .35rem; }
.fork-opt {
  display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem;
  border: 1px dashed var(--rule); background: var(--paper);
}
.fork-opt.chosen { border: 1.5px solid var(--ok); background: #dfe3cd; }
.fork-opt.discarded { opacity: .45; text-decoration: line-through; }
.fork-opt-tag {
  font-family: var(--f-display); font-size: .85rem; color: var(--wax);
  border: 1.5px solid var(--wax); border-radius: 50%; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.fork-opt.chosen .fork-opt-tag { color: var(--ok); border-color: var(--ok); }
.fork-opt-body { flex: 1; font-size: .8rem; line-height: 1.4; }
.fork-opt-mark { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .12em; color: var(--ok); }
.fork-opt-mark.discard { color: var(--ink-faint); }
.fork-opt button { font-size: .68rem; padding: .28rem .55rem; white-space: nowrap; }

/* ------------------------------------------------- guild commissary ----- */
.commissary { margin: 1.1rem 0 .4rem; }
.comm-gold { font-family: var(--f-mono); font-size: .82rem; margin: .35rem 0 .6rem; }
.comm-gold b { color: var(--wax); }
.comm-section {
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid var(--rule); padding-bottom: .2rem; margin: .7rem 0 .4rem;
}
.comm-item {
  display: grid; grid-template-columns: minmax(120px,auto) 1fr auto auto; gap: .6rem;
  align-items: center; padding: .32rem .1rem; border-bottom: 1px dotted var(--rule); font-size: .82rem;
}
.comm-name { font-weight: 600; }
.comm-note-inline { font-size: .74rem; color: var(--ink-soft); font-family: var(--f-fell); font-style: italic; }
.comm-have { font-family: var(--f-mono); font-size: .66rem; color: var(--ok); white-space: nowrap; }
.comm-item button { font-size: .7rem; padding: .25rem .55rem; white-space: nowrap; }
.comm-note { font-family: var(--f-fell); font-style: italic; font-size: .78rem; color: var(--ink-faint); margin-top: .55rem; }
.office-sheets { font-family: var(--f-mono); font-size: .74rem; margin-top: .5rem; }
.office-sheets a { color: var(--wax); font-weight: 600; }

/* ------------------------------------------------- guild registration --- */
.letter.register { max-width: 560px; }
.register-free {
  font-family: var(--f-mono); font-size: .74rem; color: var(--ink-soft);
  border-left: 3px solid var(--wax); padding-left: .6rem; margin-top: .5rem;
}
.register-form { margin-top: .4rem; }
.register-label {
  display: block; font-family: var(--f-mono); font-size: .68rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: .8rem;
}
.register-form input[type=text], .register-form input[type=email] {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .6rem;
  font-family: var(--f-body); font-size: .95rem; background: var(--paper-hi);
  border: 1.5px solid var(--ink-soft); color: var(--ink);
}
.register-form input:focus { outline: 2px solid var(--wax); border-color: var(--wax); }
.register-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.register-consent { font-size: .72rem; color: var(--ink-faint); margin: .2rem 0 .6rem; line-height: 1.5; }
.register-msg { font-family: var(--f-mono); font-size: .78rem; margin: .4rem 0; }
.register-msg.err { color: var(--wax); }
.register-success { text-align: center; }
.register-ok { font-size: .95rem; line-height: 1.6; margin-bottom: 1rem; }
.register-download {
  display: inline-block; font-family: var(--f-mono); font-weight: 600; font-size: .85rem;
  color: var(--paper-hi); background: var(--wax); padding: .55rem 1rem; text-decoration: none;
  border: 2px solid var(--wax-dim); box-shadow: 3px 3px 0 var(--paper-shadow);
}
.register-download:hover { background: var(--wax-bright); }
.register-dl-note { margin-top: .6rem; }

/* ------------------------------------------------------ responsive ------ */
@media (max-width: 980px) {
  .game-main { grid-template-columns: 1fr; }
  .panel-col { border-left: none; border-top: 2px solid var(--ink); }
  .sheet-col { padding: .7rem; }
  #screen-game { height: auto; max-height: none; overflow: visible; }
  .tab-panes { overflow-y: visible; }
}
@media (max-width: 560px) {
  .title-actions button { min-width: 240px; }
  .letter { padding: 1.4rem 1.2rem; }
  .gh-stat { font-size: .68rem; }
}
