/* ══════════════════════════════════════════════════════════
   CRUCIBLE — industrial survey ledger
   amber ink on charcoal slate, hairline rules, stamped headers
   ══════════════════════════════════════════════════════════ */

:root {
  --ground:   #0d0c0a;
  --slate:    #131210;
  --panel:    #17151110;
  --panel-2:  #1b1814;
  --ink:      #e8dcc4;
  --ink-dim:  #9b937f;
  --ink-mute: #6b6558;

  --amber:    #e0a144;
  --amber-hi: #f5c274;
  --copper:   #b8703c;
  --verdigris:#5f9e88;
  --rust:     #c4523f;
  --violet:   #8f7cf0;

  --line:     rgba(232, 220, 196, .12);
  --line-2:   rgba(232, 220, 196, .06);
  --glow:     rgba(224, 161, 68, .22);

  --rail-w:   clamp(210px, 19vw, 300px);
  --rail-r:   clamp(268px, 24vw, 380px);
  --top-h:    44px;
  --tick-h:   30px;

  --f-display: 'Antonio', 'Oswald', 'Haettenschweiler', 'Arial Narrow', sans-serif;
  --f-body:    'IBM Plex Sans Condensed', 'Roboto Condensed', system-ui, sans-serif;
  --f-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

/* A class like `.modal { display: grid }` outranks the UA rule for [hidden],
   so every hideable element needs this to actually stay hidden. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  /* film grain over everything — keeps the flat palette from feeling sterile */
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

::selection { background: var(--amber); color: var(--ground); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(232,220,196,.18) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-thumb { background: rgba(232,220,196,.16); border-radius: 0; }
*::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════ gate */

.gate {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #1c1813 0%, var(--ground) 62%),
    var(--ground);
  overflow: auto;
  padding: 32px 20px;
}

.gate-grain {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, transparent 0 63px, rgba(232,220,196,.035) 63px 64px),
    repeating-linear-gradient(0deg,  transparent 0 63px, rgba(232,220,196,.035) 63px 64px);
  mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 78%);
}

.gate-inner {
  position: relative;
  width: min(620px, 100%);
  text-align: center;
  animation: rise .9s cubic-bezier(.16,1,.3,1) both;
}

.gate-mark { color: var(--amber); opacity: 0; animation: rise .8s .05s cubic-bezier(.16,1,.3,1) both; }

.gate-title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(58px, 13vw, 118px);
  line-height: .84;
  letter-spacing: .06em;
  margin: 10px 0 0;
  color: var(--ink);
  text-shadow: 0 0 46px rgba(224,161,68,.16);
  animation: rise .8s .1s cubic-bezier(.16,1,.3,1) both;
}

.gate-sub {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 26px 0 0;
  animation: rise .8s .18s cubic-bezier(.16,1,.3,1) both;
}
.gate-dot { color: var(--copper); }

.gate-rule {
  height: 1px; margin: 26px auto;
  width: min(360px, 80%);
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  animation: rise .8s .24s cubic-bezier(.16,1,.3,1) both;
}

.gate-copy {
  max-width: 46ch; margin: 0 auto;
  color: var(--ink-dim); line-height: 1.62; font-size: 14.5px;
  animation: rise .8s .3s cubic-bezier(.16,1,.3,1) both;
}

.gate-form {
  display: flex; gap: 10px; justify-content: center;
  margin: 30px auto 0; max-width: 430px;
  animation: rise .8s .38s cubic-bezier(.16,1,.3,1) both;
}

.field { flex: 1; text-align: left; }
.field-label {
  display: block;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 6px;
}

input[type=text], input[type=number] {
  width: 100%;
  background: #0a0908;
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--f-mono); font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(224,161,68,.12);
}
input::placeholder { color: #4a463d; }

.gate-error {
  color: var(--rust); font-family: var(--f-mono); font-size: 12px;
  min-height: 18px; margin: 12px 0 0;
}

.gate-returning { min-height: 26px; }
.linkish {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-dim); font-family: var(--f-mono); font-size: 12px;
  text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: var(--line);
}
.linkish:hover { color: var(--amber); }
.linkish b { color: var(--amber); }

.gate-steps {
  list-style: none; counter-reset: s;
  margin: 34px auto 0; padding: 0;
  max-width: 470px; text-align: left;
  animation: rise .8s .46s cubic-bezier(.16,1,.3,1) both;
}
.gate-steps li {
  counter-increment: s;
  position: relative;
  padding: 11px 0 11px 40px;
  border-top: 1px solid var(--line-2);
  color: var(--ink-mute); font-size: 13px;
}
.gate-steps li::before {
  content: '0' counter(s);
  position: absolute; left: 0; top: 11px;
  font-family: var(--f-mono); font-size: 11px;
  color: var(--copper); letter-spacing: .08em;
}
.gate-steps b { color: var(--ink); font-weight: 600; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════ buttons */

.btn {
  font-family: var(--f-mono);
  font-size: 11.5px; letter-spacing: .13em; text-transform: uppercase;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, transform .1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--amber); color: var(--amber-hi); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .34; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); color: var(--ink); }

.btn-primary {
  background: var(--amber); color: #17130b; border-color: var(--amber);
  font-weight: 600;
}
.btn-primary:hover { background: var(--amber-hi); border-color: var(--amber-hi); color: #17130b; }

.btn-ghost { padding: 5px 10px; color: var(--ink-mute); }

/* ═══════════════════════════════════════ shell */

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h);
  flex: none;
  display: flex; align-items: center; gap: 20px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1a1713, #131210);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-display); font-size: 20px;
  letter-spacing: .14em; color: var(--amber);
}

.topbar-stats { display: flex; gap: 20px; flex: 1; overflow: hidden; }
.stat { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.stat i {
  font-style: normal; font-family: var(--f-mono);
  font-size: 9px; letter-spacing: .2em; color: var(--ink-mute);
}
.stat b { font-family: var(--f-mono); font-size: 12.5px; font-weight: 500; color: var(--ink); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.conn {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .2em;
  padding: 3px 8px; border: 1px solid;
}
.conn[data-state=live] { color: var(--verdigris); border-color: rgba(95,158,136,.35); }
.conn[data-state=live]::before { content: '● '; animation: blip 2.4s infinite; }
.conn[data-state=lost] { color: var(--rust); border-color: rgba(196,82,63,.4); }
@keyframes blip { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

.stage {
  flex: 1; min-height: 0; min-width: 0;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--rail-r);
}

.rail {
  min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden;
  background: var(--slate);
  display: flex; flex-direction: column;
}
.rail-left  { border-right: 1px solid var(--line); }
.rail-right { border-left: 1px solid var(--line); }

/* ═══════════════════════════════════════ panels */

.panel { border-bottom: 1px solid var(--line); }
.panel-tab { border-bottom: 0; flex: 1; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(232,220,196,.035), transparent);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--f-display); font-weight: 600;
  font-size: 15px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink);
}
.panel-head .idx {
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .14em; color: var(--ink-mute);
}

.panel-sub {
  font-family: var(--f-mono); font-size: 9px;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-mute);
  padding: 12px 12px 6px;
  border-top: 1px solid var(--line-2);
}

.panel-note {
  margin: 0; padding: 10px 12px;
  font-size: 12px; line-height: 1.55; color: var(--ink-mute);
  border-bottom: 1px solid var(--line-2);
}

/* ═══════════════════════════════════════ operator */

.you { padding: 12px; }
.you-name {
  font-family: var(--f-display); font-size: 24px;
  letter-spacing: .06em; color: var(--ink); line-height: 1;
}
.you-credits {
  display: flex; align-items: baseline; gap: 5px;
  margin: 6px 0 14px;
  font-family: var(--f-mono); font-size: 27px; font-weight: 500;
  color: var(--amber);
}
.you-credits i { font-style: normal; font-size: 11px; color: var(--ink-mute); letter-spacing: .16em; }

.meter { margin-bottom: 14px; }
.meter-bar {
  height: 5px; background: #0a0908;
  border: 1px solid var(--line-2); overflow: hidden;
}
.meter-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--copper), var(--amber));
  transition: width .5s cubic-bezier(.16,1,.3,1);
}
.meter-label {
  margin-top: 5px;
  font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-dim);
}
.meter-label i { font-style: normal; color: var(--ink-mute); letter-spacing: .12em; }
.meter-label em { font-style: normal; color: var(--verdigris); float: right; }

.you-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line-2);
  border: 1px solid var(--line-2);
}
.you-grid > div { background: var(--slate); padding: 7px 9px; }
.you-grid i {
  display: block; font-style: normal;
  font-family: var(--f-mono); font-size: 8.5px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-mute);
}
.you-grid b { font-family: var(--f-mono); font-size: 13px; font-weight: 500; color: var(--ink); }

/* ═══════════════════════════════════════ inventory */

.inv {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line-2); padding: 1px;
}
.slot {
  background: var(--slate);
  padding: 8px 4px 6px; text-align: center;
  position: relative; cursor: pointer;
  transition: background .15s;
}
.slot:hover { background: var(--panel-2); }
.slot.is-empty { opacity: .26; }
.slot .g { font-size: 15px; line-height: 1; color: var(--c); }
.slot .n {
  display: block; margin-top: 4px;
  font-family: var(--f-mono); font-size: 12px; font-weight: 500; color: var(--ink);
}
.slot .l {
  display: block;
  font-family: var(--f-mono); font-size: 7.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot::after {
  content: ''; position: absolute; left: 0; top: 0; width: 2px; height: 100%;
  background: var(--c); opacity: .5;
}
.slot.is-empty::after { opacity: .12; }

/* ═══════════════════════════════════════ feed */

.feed { list-style: none; margin: 0; padding: 6px 0; max-height: 210px; overflow-y: auto; }
.feed li {
  padding: 5px 12px;
  font-size: 12px; line-height: 1.4; color: var(--ink-dim);
  border-left: 2px solid transparent;
  animation: fadein .4s both;
}
.feed li[data-kind=trade]    { border-left-color: var(--amber); }
.feed li[data-kind=contract] { border-left-color: var(--verdigris); }
.feed li[data-kind=join]     { border-left-color: var(--violet); }
.feed li[data-kind=claim],
.feed li[data-kind=build]    { border-left-color: var(--copper); }
.feed time {
  display: block; font-family: var(--f-mono);
  font-size: 8.5px; color: var(--ink-mute); letter-spacing: .1em;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }

/* ═══════════════════════════════════════ map */

.mapwrap { position: relative; min-width: 0; min-height: 0; background: #0a0908; overflow: hidden; }
#world { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#world:active { cursor: grabbing; }

.map-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(96% 86% at 50% 44%, transparent 46%, rgba(0,0,0,.55) 100%);
}

.map-legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 9px 11px;
  background: rgba(13,12,10,.84);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.map-legend span {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--f-mono); font-size: 9px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim);
}
.map-legend i { width: 8px; height: 8px; background: var(--c); flex: none; }

.map-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .16em;
  color: var(--ink-mute); pointer-events: none;
  transition: opacity .6s;
}
.map-hint.is-gone { opacity: 0; }

/* tile card */
.tilecard {
  position: absolute; right: 12px; top: 12px; width: 244px;
  background: rgba(19,18,16,.95);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 48px rgba(0,0,0,.6);
  animation: cardin .22s cubic-bezier(.16,1,.3,1) both;
}
@keyframes cardin { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

.tilecard-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 11px; border-bottom: 1px solid var(--line-2);
}
.tilecard-biome {
  font-family: var(--f-display); font-size: 15px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--amber);
}
.tilecard-coord { font-family: var(--f-mono); font-size: 10px; color: var(--ink-mute); }

.tilecard-body { padding: 10px 11px; }
.tilecard-depbar { height: 4px; background: #0a0908; border: 1px solid var(--line-2); }
.tilecard-depbar span { display: block; height: 100%; background: var(--amber); transition: width .3s; }
.tilecard-deplabel { margin-top: 5px; font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-dim); }
.tilecard-deplabel i { font-style: normal; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .1em; }

.tilecard-owner, .tilecard-building {
  margin-top: 8px; font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-dim);
}
.tilecard-owner b { color: var(--amber); }

.tilecard-actions {
  display: flex; flex-wrap: wrap; gap: 1px;
  background: var(--line-2); border-top: 1px solid var(--line-2);
}
.tilecard-actions .btn {
  flex: 1 1 auto; border: 0; background: var(--slate);
  padding: 9px 8px; font-size: 10px;
}
.tilecard-actions .btn:hover { background: var(--panel-2); }

/* ═══════════════════════════════════════ tabs */

.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex: none;
}
.tab {
  padding: 10px 4px;
  background: transparent; border: 0; border-right: 1px solid var(--line-2);
  color: var(--ink-mute); cursor: pointer;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .16em; text-transform: uppercase;
  transition: color .16s, background .16s;
}
.tab:last-child { border-right: 0; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--amber); background: var(--slate); box-shadow: inset 0 -2px 0 var(--amber); }

/* ═══════════════════════════════════════ market */

.mk-picker {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--line-2); padding: 1px;
}
.mk-chip {
  background: var(--slate); border: 0; cursor: pointer;
  padding: 6px 2px; text-align: center;
  color: var(--ink-dim); font-size: 13px; line-height: 1;
  transition: background .14s;
}
.mk-chip:hover { background: var(--panel-2); }
.mk-chip.is-on { background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--c); }
.mk-chip span { display: block; font-family: var(--f-mono); font-size: 7px; letter-spacing: .04em; margin-top: 3px; color: var(--ink-mute); }

.mk-quote {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line-2);
  border-bottom: 1px solid var(--line-2);
}
.mk-quote > div { background: var(--slate); padding: 8px 9px; }
.mk-quote i {
  display: block; font-style: normal;
  font-family: var(--f-mono); font-size: 8px;
  letter-spacing: .2em; color: var(--ink-mute);
}
.mk-quote b { font-family: var(--f-mono); font-size: 14px; font-weight: 500; }
.mk-quote .up { color: var(--verdigris); }
.mk-quote .down { color: var(--rust); }

.book { display: flex; flex-direction: column; }
.book-side { padding: 0; }
.book-head {
  display: flex; justify-content: space-between;
  padding: 5px 12px;
  font-family: var(--f-mono); font-size: 8px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute);
}
.book ul { list-style: none; margin: 0; padding: 0; min-height: 92px; }
.book li {
  position: relative;
  display: flex; justify-content: space-between;
  padding: 3px 12px;
  font-family: var(--f-mono); font-size: 11.5px;
  cursor: pointer;
}
.book li:hover { background: rgba(232,220,196,.05); }
.book li .bar {
  position: absolute; top: 0; bottom: 0; right: 0;
  opacity: .13; pointer-events: none;
}
.book-asks li { color: var(--rust); }
.book-asks li .bar { background: var(--rust); }
.book-asks ul { display: flex; flex-direction: column-reverse; }
.book-bids li { color: var(--verdigris); }
.book-bids li .bar { background: var(--verdigris); }
.book li em { font-style: normal; color: var(--ink-dim); }

.book-spread {
  text-align: center; padding: 5px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .16em; color: var(--ink-mute);
  border-block: 1px solid var(--line-2);
  background: var(--panel-2);
}

.order { padding: 11px 12px; border-top: 1px solid var(--line-2); }
.order-side { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); margin-bottom: 9px; }
.oside {
  background: var(--slate); border: 0; cursor: pointer;
  padding: 8px; color: var(--ink-mute);
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .18em;
  transition: background .14s, color .14s;
}
.oside[data-side=buy].is-on  { background: rgba(95,158,136,.18); color: var(--verdigris); box-shadow: inset 0 -2px 0 var(--verdigris); }
.oside[data-side=sell].is-on { background: rgba(196,82,63,.18); color: var(--rust); box-shadow: inset 0 -2px 0 var(--rust); }

.order-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order-fields label { display: block; }
.order-fields span {
  display: block; margin-bottom: 4px;
  font-family: var(--f-mono); font-size: 8.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute);
}
.order-fields input { padding: 7px 9px; font-size: 13px; }

.order-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 9px 0;
  font-family: var(--f-mono); font-size: 12px;
}
.order-total i { font-style: normal; font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute); }
.order-total b { color: var(--amber); font-weight: 500; }
.order .btn { width: 100%; }

.orders, .prints { list-style: none; margin: 0; padding: 0; }
.orders li, .prints li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px;
  font-family: var(--f-mono); font-size: 11px;
  border-bottom: 1px solid var(--line-2);
}
.orders li .side { font-size: 9px; letter-spacing: .1em; }
.orders li .side.buy  { color: var(--verdigris); }
.orders li .side.sell { color: var(--rust); }
.orders li .grow, .prints li .grow { flex: 1; color: var(--ink-dim); }
.orders li button {
  background: none; border: 1px solid var(--line); color: var(--ink-mute);
  cursor: pointer; padding: 1px 6px; font-size: 9px; font-family: var(--f-mono);
}
.orders li button:hover { border-color: var(--rust); color: var(--rust); }
.empty { padding: 12px; font-size: 11.5px; color: var(--ink-mute); font-style: italic; }

.prints li .px { color: var(--amber); }

/* ═══════════════════════════════════════ recipes */

.recipes { padding: 1px; display: flex; flex-direction: column; gap: 1px; background: var(--line-2); }
.recipe { background: var(--slate); padding: 9px 11px; }
.recipe-top { display: flex; align-items: center; gap: 8px; }
.recipe-glyph { font-size: 15px; color: var(--c); }
.recipe-name { font-family: var(--f-display); font-size: 15px; letter-spacing: .1em; text-transform: uppercase; flex: 1; }
.recipe-tier { font-family: var(--f-mono); font-size: 8px; letter-spacing: .14em; color: var(--ink-mute); }
.recipe-io {
  margin: 6px 0 8px;
  font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-dim);
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.recipe-io .ing.short { color: var(--rust); }
.recipe-io .ing.ok { color: var(--ink-dim); }
.recipe-io .arrow { color: var(--ink-mute); }
.recipe-io .energy { margin-left: auto; color: var(--copper); }
.recipe-actions { display: flex; gap: 1px; background: var(--line-2); }
.recipe-actions .btn { flex: 1; border: 0; background: var(--panel-2); padding: 6px; font-size: 9.5px; }

/* ═══════════════════════════════════════ contracts */

.contracts { padding: 1px; display: flex; flex-direction: column; gap: 1px; background: var(--line-2); }
.contract { background: var(--slate); padding: 10px 11px; position: relative; overflow: hidden; }
.contract::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--verdigris);
}
.contract-client {
  font-family: var(--f-display); font-size: 14px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink);
}
.contract-ask { margin: 5px 0; font-family: var(--f-mono); font-size: 12px; color: var(--ink-dim); }
.contract-ask b { color: var(--amber); }
.contract-meta {
  display: flex; justify-content: space-between;
  font-family: var(--f-mono); font-size: 9.5px; color: var(--ink-mute);
  margin-bottom: 8px;
}
.contract-bar { height: 3px; background: #0a0908; margin-bottom: 8px; }
.contract-bar span { display: block; height: 100%; background: var(--verdigris); }
.contract-actions { display: flex; gap: 6px; }
.contract-actions .btn { flex: 1; padding: 6px; font-size: 9.5px; }

/* ═══════════════════════════════════════ ledger */

.supply { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); }
.supply > div { background: var(--slate); padding: 9px 11px; }
.supply i {
  display: block; font-style: normal;
  font-family: var(--f-mono); font-size: 8px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute);
}
.supply b { font-family: var(--f-mono); font-size: 15px; font-weight: 500; color: var(--ink); }
.supply .mint b  { color: var(--verdigris); }
.supply .burn b  { color: var(--rust); }

#supply-chart { display: block; width: 100%; border-bottom: 1px solid var(--line-2); }

.board { list-style: none; margin: 0; padding: 0; counter-reset: b; }
.board li {
  counter-increment: b;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}
.board li::before {
  content: counter(b, decimal-leading-zero);
  font-family: var(--f-mono); font-size: 10px; color: var(--copper);
}
.board .nm { flex: 1; color: var(--ink); }
.board .nm.on::after { content: '●'; color: var(--verdigris); font-size: 8px; margin-left: 6px; vertical-align: middle; }
.board .w { font-family: var(--f-mono); font-size: 11.5px; color: var(--amber); }

/* ═══════════════════════════════════════ ticker */

.ticker {
  height: var(--tick-h); flex: none;
  border-top: 1px solid var(--line);
  background: #0a0908;
  overflow: hidden; position: relative;
  display: flex; align-items: center;
}
.ticker::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, #0a0908 0%, transparent 5%, transparent 95%, #0a0908 100%);
}
.ticker-tape {
  display: flex; gap: 34px; white-space: nowrap;
  animation: crawl 64s linear infinite;
  padding-left: 100%;
}
.ticker:hover .ticker-tape { animation-play-state: paused; }
@keyframes crawl { to { transform: translateX(-100%); } }

.tk { display: inline-flex; align-items: baseline; gap: 7px; font-family: var(--f-mono); font-size: 11.5px; }
.tk .s { color: var(--ink-dim); letter-spacing: .1em; text-transform: uppercase; font-size: 10px; }
.tk .p { color: var(--ink); }
.tk .c.up   { color: var(--verdigris); }
.tk .c.down { color: var(--rust); }
.tk .c.flat { color: var(--ink-mute); }

/* ═══════════════════════════════════════ toasts */

.toasts {
  position: fixed; left: 50%; bottom: calc(var(--tick-h) + 18px);
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 6px;
  z-index: 400; pointer-events: none;
}
.toast {
  padding: 8px 15px;
  background: rgba(19,18,16,.96);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  font-family: var(--f-mono); font-size: 11.5px; color: var(--ink);
  animation: toastin .26s cubic-bezier(.16,1,.3,1) both;
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.toast.bad  { border-left-color: var(--rust); color: #f0c0b6; }
.toast.good { border-left-color: var(--verdigris); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* ═══════════════════════════════════════ modal */

.modal {
  position: fixed; inset: 0; z-index: 600;
  display: grid; place-items: center;
  background: rgba(6,5,4,.82); backdrop-filter: blur(3px);
  padding: 24px;
}
.modal-card {
  width: min(620px, 100%); max-height: 84vh; overflow: auto;
  background: var(--slate); border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
  animation: cardin .24s cubic-bezier(.16,1,.3,1) both;
}
.modal-body { padding: 16px 20px 24px; }
.modal-body h3 {
  margin: 18px 0 6px;
  font-family: var(--f-display); font-size: 15px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--amber);
}
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin: 0; color: var(--ink-dim); line-height: 1.62; font-size: 13.5px; }
.modal-body b { color: var(--ink); font-weight: 600; }

/* ═══════════════════════════════════════ responsive */

@media (max-width: 1240px) {
  /* Reclaim the world first: the left rail is reference, the right is action. */
  .stage { grid-template-columns: minmax(0, 1fr) var(--rail-r); }
  .rail-left { display: none; }
}

@media (max-width: 820px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(180px, 1fr) minmax(0, 44vh);
  }
  .rail-right { border-left: 0; border-top: 1px solid var(--line); }
  .topbar { gap: 10px; }
  .topbar-stats { gap: 12px; overflow-x: auto; }
  .stat:nth-child(n+4) { display: none; }
  .map-hint { display: none; }
  .tilecard { right: 8px; top: 8px; width: min(212px, 60vw); }
  .map-hint { display: none; }
}

/* Phones: keep only position, and let the self strip carry the rest. Showing a
   partial stat leaves a bare orphaned number in the bar. */
@media (max-width: 560px) {
  .stat:nth-child(n+3) { display: none; }
  .brand span { display: none; }
  .ms-name { max-width: 40%; }
}

/* Short windows: the ticker is the first thing worth sacrificing. */
@media (max-height: 620px) {
  :root { --tick-h: 0px; }
  .ticker { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .ticker-tape { animation: none; padding-left: 0; }
}

/* ══════════════════════════════════════════════════════════
   RPG layer — classes, vitals, gear, movement, combat
   ══════════════════════════════════════════════════════════ */

/* ── class picker ── */

.classes {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 26px auto 0; max-width: 560px;
  animation: rise .8s .34s cubic-bezier(.16,1,.3,1) both;
}
.classcard {
  position: relative;
  padding: 14px 12px 13px;
  background: #100f0d;
  border: 1px solid var(--line);
  cursor: pointer; text-align: left;
  transition: border-color .18s, background .18s, transform .18s;
}
.classcard:hover { border-color: var(--c); transform: translateY(-2px); }
.classcard.is-on { border-color: var(--c); background: #16130f; }
.classcard.is-on::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--c);
}
.classcard .cg { font-size: 20px; color: var(--c); line-height: 1; }
.classcard .cn {
  display: block; margin: 7px 0 5px;
  font-family: var(--f-display); font-size: 17px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink);
}
.classcard .cb { font-size: 11.5px; line-height: 1.45; color: var(--ink-mute); }
.classcard .cs {
  display: flex; gap: 7px; margin-top: 8px;
  font-family: var(--f-mono); font-size: 9px; color: var(--ink-dim);
}
.classcard .cs b { color: var(--c); font-weight: 500; }

/* ── vitals ── */

.you-name { display: flex; align-items: baseline; gap: 8px; }
.you-name em {
  font-style: normal; font-family: var(--f-mono); font-size: 11px;
  letter-spacing: .12em; color: var(--amber);
}

.vitals { margin: 12px 0 10px; display: flex; flex-direction: column; gap: 7px; }
.vital-bar {
  height: 6px; background: #0a0908;
  border: 1px solid var(--line-2); overflow: hidden;
}
.vital-bar span { display: block; height: 100%; width: 0%; transition: width .45s cubic-bezier(.16,1,.3,1); }
.vital-hp .vital-bar span { background: linear-gradient(90deg, #7a2b22, #c4523f); }
.vital-st .vital-bar span { background: linear-gradient(90deg, var(--copper), var(--amber)); }
.vital-xp .vital-bar span { background: linear-gradient(90deg, #35604f, var(--verdigris)); }
.vital-label {
  display: flex; justify-content: space-between; margin-top: 3px;
  font-family: var(--f-mono); font-size: 9.5px; color: var(--ink-dim);
}
.vital-label i { font-style: normal; color: var(--ink-mute); letter-spacing: .18em; }

/* ── stats ── */

.statgrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line-2); border: 1px solid var(--line-2); margin-bottom: 8px;
}
.statrow {
  background: var(--slate); padding: 6px 8px;
  display: flex; align-items: center; gap: 6px;
}
.statrow i {
  font-style: normal; font-family: var(--f-mono); font-size: 8.5px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute); flex: 1;
}
.statrow b { font-family: var(--f-mono); font-size: 13px; color: var(--ink); }
.statrow button {
  background: none; border: 1px solid var(--amber); color: var(--amber);
  cursor: pointer; width: 17px; height: 17px; line-height: 1;
  font-family: var(--f-mono); font-size: 11px; padding: 0;
}
.statrow button:hover { background: var(--amber); color: #17130b; }

.derived {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px;
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-mute);
}
.derived span b { color: var(--ink-dim); font-weight: 500; }

.points-flag {
  display: block; margin: 6px 0; padding: 5px 8px;
  background: rgba(224,161,68,.12); border-left: 2px solid var(--amber);
  font-family: var(--f-mono); font-size: 10px; color: var(--amber-hi);
}

/* ── equipment ── */

.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line-2); padding: 1px; }
.gslot {
  background: var(--slate); padding: 9px 6px; text-align: center;
  cursor: pointer; transition: background .15s; border: 0; color: inherit;
}
.gslot:hover { background: var(--panel-2); }
.gslot .sl {
  display: block; font-family: var(--f-mono); font-size: 7.5px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-mute);
}
.gslot .sg { display: block; font-size: 17px; margin: 4px 0 2px; color: var(--c, var(--ink-mute)); }
.gslot .sn { display: block; font-size: 10px; color: var(--ink-dim); line-height: 1.2; }
.gslot.is-empty .sg { opacity: .25; }

/* ── compact self strip (narrow screens) ── */

.miniself {
  flex: none;
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--f-mono); font-size: 10.5px;
}
.ms-name { display: flex; align-items: baseline; gap: 5px; flex: none; max-width: 33%; }
.ms-name b {
  font-family: var(--f-display); font-size: 14px; letter-spacing: .06em; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ms-name i { font-style: normal; color: var(--amber); font-size: 9px; }
.ms-name i::before { content: 'lv'; color: var(--ink-mute); margin-right: 2px; }

.ms-bar {
  position: relative; flex: 1; min-width: 0; height: 14px;
  background: #0a0908; border: 1px solid var(--line-2);
  display: flex; align-items: center;
}
.ms-bar > span { position: absolute; inset: 0 auto 0 0; width: 0%; transition: width .3s; }
.ms-hp > span { background: linear-gradient(90deg, #7a2b22, #c4523f); }
.ms-st > span { background: linear-gradient(90deg, var(--copper), var(--amber)); }
.ms-bar em {
  position: relative; font-style: normal; font-size: 9px;
  color: var(--ink); padding-left: 5px; text-shadow: 0 1px 2px #000;
}
.ms-cr { flex: none; color: var(--ink-mute); }
.ms-cr b { color: var(--amber); }
.ms-more {
  flex: none; background: none; border: 1px solid var(--line);
  color: var(--ink-dim); cursor: pointer; padding: 2px 8px; font-size: 12px;
}
.ms-more.is-on { border-color: var(--amber); color: var(--amber); }

/* On narrow screens the left rail becomes a slide-over opened by ☰. */
@media (max-width: 1240px) {
  .miniself[hidden] { display: flex !important; }
  .rail-left.is-open {
    display: flex !important;
    position: fixed; z-index: 60;
    left: 0; right: 0; top: calc(var(--top-h) + 26px); bottom: var(--tick-h);
    border-right: 0; border-top: 1px solid var(--line);
    box-shadow: 0 18px 60px rgba(0,0,0,.7);
  }
}

/* ── movement rose ── */

.rose {
  position: absolute; left: 18px; bottom: 74px;
  width: 104px; height: 104px;
  border-radius: 50%;
  background: rgba(13,12,10,.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.rose button {
  position: absolute; left: 50%; top: 50%;
  width: 26px; height: 30px; margin: -15px 0 0 -13px;
  background: none; border: 0; cursor: pointer;
  color: var(--ink-mute); font-size: 13px; line-height: 1;
  transform: rotate(calc(var(--a) * 1deg)) translateY(-34px);
  transform-origin: 50% 50%;
  transition: color .15s;
}
.rose button:hover { color: var(--amber); }
.rose button:disabled { opacity: .2; cursor: not-allowed; }
.rose-mid {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: var(--amber); font-size: 11px;
}

.worldbar {
  position: absolute; left: 138px; bottom: 74px;
  display: flex; gap: 1px; background: var(--line-2);
}
.worldbar .btn {
  background: rgba(13,12,10,.82); border: 1px solid var(--line);
  padding: 8px 12px; font-size: 10px; backdrop-filter: blur(6px);
}

.objective {
  position: absolute; left: 18px; bottom: 24px;
  max-width: min(520px, calc(100% - 36px));
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 13px;
  background: rgba(13,12,10,.88);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  backdrop-filter: blur(6px);
  font-size: 12.5px; color: var(--ink-dim);
  animation: fadein .4s both;
}
.objective i { font-style: normal; color: var(--amber); font-size: 10px; }
.objective[data-tone=warn] { border-left-color: var(--rust); color: #f0c0b6; }
.objective[data-tone=warn] i { color: var(--rust); }
.objective[data-tone=good] { border-left-color: var(--verdigris); }
.objective[data-tone=good] i { color: var(--verdigris); }

.loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  display: flex; align-items: center; gap: 9px;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .16em;
  color: var(--ink-mute); pointer-events: none;
}
.loading span {
  width: 9px; height: 9px; border: 1px solid var(--amber);
  animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tilecard-threat {
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line-2);
  font-family: var(--f-mono); font-size: 10.5px; color: var(--rust);
}
.tilecard-threat b { color: var(--amber); }

/* ── combat ── */

.combat {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(60% 60% at 50% 50%, rgba(40,10,6,.32), rgba(6,5,4,.86));
  backdrop-filter: blur(2px);
  z-index: 30;
  animation: fadein .2s both;
}
.combat-card {
  width: min(430px, 92%);
  background: rgba(19,18,16,.97);
  border: 1px solid var(--line);
  border-top: 2px solid var(--rust);
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  animation: cardin .26s cubic-bezier(.16,1,.3,1) both;
}
.combat-foe { display: flex; align-items: center; gap: 11px; padding: 12px 14px 8px; }
.combat-glyph { font-size: 27px; line-height: 1; }
.combat-id { flex: 1; }
.combat-name {
  font-family: var(--f-display); font-size: 19px;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink);
}
.combat-lvl { font-family: var(--f-mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .1em; }
.combat-round { font-family: var(--f-mono); font-size: 9.5px; color: var(--ink-mute); letter-spacing: .14em; }

.combat-hp { height: 7px; margin: 0 14px; background: #0a0908; border: 1px solid var(--line-2); }
.combat-hp span { display: block; height: 100%; background: linear-gradient(90deg, #7a2b22, #c4523f); transition: width .3s; }
.combat-hpnum {
  padding: 4px 14px 10px;
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-dim); text-align: right;
}

.combat-you {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line-2);
  display: flex; flex-direction: column; gap: 5px;
}
.combat-you-row { display: flex; align-items: center; gap: 8px; }
.cy-label {
  font-family: var(--f-mono); font-size: 8px; letter-spacing: .18em;
  color: var(--ink-mute); width: 34px; flex: none;
}
.cy-bar { flex: 1; height: 6px; background: #0a0908; border: 1px solid var(--line-2); }
.cy-bar span { display: block; height: 100%; width: 0%; transition: width .3s; }
.cy-hp span { background: linear-gradient(90deg, #7a2b22, #d0604a); }
.cy-st span { background: linear-gradient(90deg, var(--copper), var(--amber)); }
.cy-num {
  font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-dim);
  width: 62px; text-align: right; flex: none;
}
.combat-you.is-critical .cy-hp span { animation: pulse-hp 1s ease-in-out infinite; }
@keyframes pulse-hp { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

.combat-log {
  list-style: none; margin: 0; padding: 8px 14px;
  max-height: 190px; overflow-y: auto;
  border-top: 1px solid var(--line-2);
  font-family: var(--f-mono); font-size: 11.5px; line-height: 1.5;
}
.combat-log li { color: var(--ink-dim); padding: 2px 0; animation: fadein .3s both; }
.combat-log li.hit  { color: var(--amber-hi); }
.combat-log li.hurt { color: #f0a396; }
.combat-log li.good { color: var(--verdigris); }

.combat-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-2); }
.combat-actions .btn { border: 0; background: var(--panel-2); padding: 12px 4px; font-size: 10px; }
.combat-actions .btn:hover { background: #241f18; }

/* ── recipe filter ── */

.recipe-filter { display: flex; gap: 1px; background: var(--line-2); }
.recipe-filter button {
  flex: 1; background: var(--slate); border: 0; cursor: pointer;
  padding: 7px 3px; color: var(--ink-mute);
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
}
.recipe-filter button.is-on { color: var(--amber); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--amber); }

.recipe-req { font-family: var(--f-mono); font-size: 9px; color: var(--violet); }
.recipe-stats { font-family: var(--f-mono); font-size: 9.5px; color: var(--verdigris); margin-top: 3px; }

.board .lv { font-family: var(--f-mono); font-size: 10px; color: var(--violet); }

/* ── contracts: hunt variant ── */
.contract.hunt::before { background: var(--rust); }
.contract-kind {
  font-family: var(--f-mono); font-size: 8px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-mute);
}

/* Keep this breakpoint aligned with the layout one above, or the world buttons
   restack while the left rail is still present and crowd the movement rose. */
@media (max-width: 820px) {
  .rose { left: 10px; bottom: 58px; width: 86px; height: 86px; }
  .rose button { transform: rotate(calc(var(--a) * 1deg)) translateY(-27px); }
  .worldbar { left: 104px; bottom: 58px; }
  .objective { left: 10px; bottom: 8px; font-size: 11.5px; padding: 6px 10px; }
  .worldbar .btn { padding: 7px 9px; font-size: 9px; }
}

@media (max-width: 660px) {
  .classes { grid-template-columns: 1fr; }
  .gate-form { flex-direction: column; }
}
