/* ------------------------------------------------------------------
   RSTR Vault
   The chrome borrows from the game's own bank interface: recessed slots,
   beveled stone frames, and the bitmap numerals the game sets values in.
   Price colour is not decoration — it is the tier an item sits in, and
   the hatched slots are the ones that cannot be bought on the GE at all.
   ------------------------------------------------------------------ */

:root {
  --bg:          #16130e;
  --stone:       #3a3228;
  --stone-lit:   #56493a;
  --stone-dark:  #211c15;
  --slot:        #1d1913;
  --parchment:   #cdbfa3;
  --parchment-d: #94886f;
  --gold:        #d4a017;
  --ink:         #0e0c09;

  /* Value tiers for this list, in the game's own stack colours. */
  --tier-1:      #ffffff;  /* under 100M  */
  --tier-2:      #ffdd44;  /* 100M – 1B   */
  --tier-3:      #4cff8a;  /* over 1B     */
  --blocked:     #ff7a6b;  /* above max cash: not buyable on the GE */

  --font-bit: 'Pixelify Sans', 'Courier New', monospace;
  --font-ui:  'Barlow Semi Condensed', system-ui, sans-serif;

  --slot-size: 104px;
  --rule: 1px solid var(--stone);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  /* Ships at 1.25x so the interface reads at the size it was designed for
     without the viewer reaching for browser zoom. */
  zoom: 1.25;
  margin: 0;
  background: var(--bg);
  /* A faint woven texture, the way the game's stone panels read up close. */
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg,  rgba(0,0,0,.20)       0 1px, transparent 1px 3px);
  color: var(--parchment);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.15; margin: 0; }
p { margin: 0 0 1em; max-width: 66ch; }
a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #f0c24d; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.skip {
  position: absolute; top: 8px; left: 8px; z-index: 99;
  background: var(--gold); color: var(--ink); padding: 10px 16px; font-weight: 700;
  clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { clip-path: none; }

/* ---------- top chrome ---------- */

.chrome {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--stone), var(--stone-dark));
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--stone-lit) inset, 0 6px 18px rgba(0,0,0,.5);
}
.chrome__in {
  max-width: 1180px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}

.mark { font-family: var(--font-bit); display: flex; align-items: baseline; gap: 8px; }
.mark__r {
  font-size: 30px; font-weight: 700; color: var(--gold); letter-spacing: .02em;
  text-shadow: 2px 2px 0 var(--ink);
}
.mark__sub { font-size: 17px; color: var(--parchment-d); }

.rate { display: flex; gap: 22px; margin: 0; flex-wrap: wrap; }
.rate div { display: flex; flex-direction: column; }
.rate dt { font-size: 12px; color: var(--parchment-d); letter-spacing: .04em; }
.rate dd { margin: 0; font-family: var(--font-bit); font-size: 16px; color: var(--parchment); }

/* ---------- shared section frame ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

section { padding: 56px 0; border-bottom: var(--rule); }
section > h2 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 700; margin-bottom: .5em; }

/* ---------- bank ---------- */

.bank__bar { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 6px; }
.bank__count { margin: 0; color: var(--parchment-d); font-size: 15px; }

.controls { display: flex; gap: 16px; flex-wrap: wrap; margin: 22px 0 16px; }
.controls label { display: block; font-size: 12px; color: var(--parchment-d); letter-spacing: .05em; margin-bottom: 5px; }
.controls__search { flex: 1 1 280px; }
.controls input, .controls select {
  width: 100%; font-family: var(--font-ui); font-size: 16px; color: var(--parchment);
  background: var(--slot); border: 2px solid var(--stone); padding: 9px 12px;
  box-shadow: 1px 1px 0 rgba(0,0,0,.6) inset;
}
.controls input::placeholder { color: #6d6350; }
.controls select { cursor: pointer; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 12px; }
.tab {
  font-family: var(--font-ui); font-size: 14.5px; font-weight: 600; cursor: pointer;
  color: var(--parchment-d); background: var(--stone-dark);
  border: 2px solid var(--stone); border-bottom-color: var(--ink);
  padding: 7px 14px;
}
.tab:hover { color: var(--parchment); background: var(--stone); }
.tab[aria-selected='true'] {
  color: var(--ink); background: var(--gold); border-color: var(--gold);
}

.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tog {
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--parchment-d); background: transparent;
  border: 2px solid var(--stone); padding: 6px 13px;
}
.tog:hover { color: var(--parchment); border-color: var(--stone-lit); }
.tog[aria-pressed='true'] { color: var(--ink); background: var(--parchment); border-color: var(--parchment); }
.tog--clear { border-style: dashed; }

.grid {
  list-style: none; margin: 0; padding: 12px;
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(var(--slot-size), 1fr));
  background: var(--ink);
  border: 2px solid var(--stone);
  box-shadow: 2px 2px 0 rgba(0,0,0,.5) inset;
}

.cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px 8px; cursor: pointer; text-align: center;
  background: var(--slot);
  border: 1px solid #2c261d;
  box-shadow: 1px 1px 0 rgba(0,0,0,.55) inset;
  font: inherit; color: inherit; width: 100%;
}
.cell:hover, .cell:focus-visible { background: #272119; border-color: var(--stone-lit); }
.cell[aria-current='true'] { border-color: var(--gold); background: #2b2318; }

.cell__rank {
  position: absolute; top: 3px; left: 5px;
  font-family: var(--font-bit); font-size: 12px; color: #6d6350;
}
.cell__img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.cell__name {
  font-size: 12.5px; line-height: 1.2; color: var(--parchment-d);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.4em;
}
.cell__gp { font-family: var(--font-bit); font-size: 15px; line-height: 1; }

.t1 { color: var(--tier-1); }
.t2 { color: var(--tier-2); }
.t3 { color: var(--tier-3); }

/* Above max cash: no GE price exists, so the slot is marked as unbuyable. */
.cell--blocked { background-image: repeating-linear-gradient(135deg, rgba(255,122,107,.09) 0 4px, transparent 4px 9px); }
.cell--blocked .cell__gp { color: var(--blocked); }

.grid__empty { padding: 34px 4px; color: var(--parchment-d); }
.more {
  display: block; margin: 18px auto 0; cursor: pointer;
  font-family: var(--font-ui); font-size: 15px; font-weight: 600; color: var(--parchment);
  background: var(--stone-dark); border: 2px solid var(--stone); padding: 10px 22px;
}
.more:hover { background: var(--stone); }

/* ---------- how it works ---------- */

.steps { list-style: none; counter-reset: s; margin: 0 0 44px; padding: 0; display: grid; gap: 2px; }
.steps li {
  counter-increment: s; position: relative;
  background: linear-gradient(var(--stone-dark), #1a160f);
  border: 2px solid var(--stone); padding: 20px 22px 20px 68px;
}
.steps li::before {
  content: counter(s); position: absolute; left: 20px; top: 18px;
  font-family: var(--font-bit); font-size: 28px; color: var(--gold);
}
.steps h3 { font-size: 19px; margin-bottom: 6px; color: var(--parchment); }
.steps p { margin: 0; color: var(--parchment-d); font-size: 16px; }
.steps strong { color: var(--parchment); }

.math h3 { font-size: 21px; margin-bottom: 6px; }
.math__note { color: var(--parchment-d); font-size: 15px; }
.math__table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 16px; }
.math__table th, .math__table td { text-align: left; padding: 10px 12px; border-bottom: var(--rule); }
.math__table th { font-size: 12px; color: var(--parchment-d); letter-spacing: .05em; font-weight: 600; }
.math__table td:nth-child(n+2) { font-family: var(--font-bit); }
.math__table .m-blocked { color: var(--blocked); }
.math__table tfoot td { border-bottom: 0; border-top: 2px solid var(--stone); color: var(--gold); }

/* ---------- foot ---------- */

.foot { max-width: 1180px; margin: 0 auto; padding: 34px 20px 64px; color: var(--parchment-d); font-size: 14.5px; }
.foot p { max-width: 80ch; }
.foot__stamp { font-family: var(--font-bit); font-size: 13px; color: #5e5544; }

/* ---------- item detail ---------- */

.detail {
  position: fixed; right: 0; bottom: 0; z-index: 30;
  width: min(380px, 100%); max-height: 86vh;
  display: flex; flex-direction: column;
  background: linear-gradient(var(--stone), var(--stone-dark));
  border: 2px solid var(--ink);
  box-shadow: -6px -6px 22px rgba(0,0,0,.55);
}
/* display:flex above outranks the hidden attribute's UA display:none, so the
   panel has to opt back out explicitly or it shows empty before anything is
   clicked and refuses to close. */
.detail[hidden] { display: none; }

@media (min-width: 900px) { .detail { top: 76px; bottom: auto; } }

/* Once dragged, the panel is placed by left/top and the anchored edges let go. */
.detail--moved { right: auto; bottom: auto; }
.detail--dragging { user-select: none; box-shadow: -8px -8px 30px rgba(0,0,0,.7); }

/* The titlebar is the drag handle. touch-action keeps a touch drag from
   scrolling the page underneath it. */
.detail__bar {
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 7px 6px 7px 11px;
  background: var(--stone-dark);
  border-bottom: 1px solid var(--ink);
  cursor: grab; touch-action: none;
}
.detail--dragging .detail__bar { cursor: grabbing; }

.detail__grip {
  flex: none; width: 13px; height: 13px;
  background-image: radial-gradient(var(--parchment-d) 1px, transparent 1px);
  background-size: 4px 4px;
  opacity: .65;
}
.detail__title {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; color: var(--parchment-d); letter-spacing: .03em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.detail__close {
  flex: none; cursor: pointer;
  background: none; border: 0; color: var(--parchment-d);
  font-size: 22px; line-height: 1; padding: 2px 9px;
}
.detail__close:hover { color: var(--parchment); }

.detail__in { padding: 18px 22px 26px; overflow-y: auto; }
.detail__in img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.detail__in h3 { font-size: 22px; margin: 8px 0 2px; color: var(--parchment); }
.detail__in .d-examine { font-size: 15px; color: var(--parchment-d); font-style: italic; margin-bottom: 16px; }
.detail__in dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0 0 18px; font-size: 15px; }
.detail__in dt { color: var(--parchment-d); }
.detail__in dd { margin: 0; font-family: var(--font-bit); text-align: right; }
.detail__in .d-warn {
  border-left: 3px solid var(--blocked); padding: 9px 12px; margin-bottom: 16px;
  background: rgba(255,122,107,.08); font-size: 14.5px; color: var(--parchment);
}

@media (max-width: 560px) {
  :root { --slot-size: 92px; }
  body { font-size: 16px; }
  .rate { gap: 16px; }
  .steps li { padding: 18px 16px 18px 58px; }
}

.bank__lede { color: var(--parchment-d); font-size: 16.5px; max-width: 62ch; margin: 6px 0 0; }


/* ---------- treasury ---------- */

.tre__lede { color: var(--parchment); font-size: 18px; max-width: 62ch; margin-bottom: 26px; }

.tre__state {
  display: flex; flex-wrap: wrap; gap: 2px;
  background: var(--ink); border: 2px solid var(--stone);
}
.tre__state > div {
  flex: 1 1 190px; padding: 15px 18px;
  background: linear-gradient(var(--stone-dark), #1a160f);
}
.tre__state dl { margin: 0; }
.tre__state dt { font-size: 12px; color: var(--parchment-d); letter-spacing: .05em; }
.tre__state dd { margin: 3px 0 0; font-family: var(--font-bit); font-size: 26px; color: var(--gold); }
.tre__sub { margin: 3px 0 0; font-size: 12.5px; color: var(--parchment-d); }

.tre__src {
  margin: 14px 0 0; max-width: 78ch; font-size: 14.5px; color: var(--parchment-d);
  border-left: 3px solid var(--stone-lit); padding-left: 13px;
}

/* ---------- progress bars ---------- */

.bar {
  position: relative; height: 10px; overflow: hidden;
  background: #100e0a;
  border: 1px solid #2c261d;
  box-shadow: 1px 1px 0 rgba(0,0,0,.6) inset;
}
.bar--lg { height: 18px; }

.bar__fill {
  height: 100%; width: 0;
  background: var(--stone-lit);
  transition: width .45s ease-out;
}
/* Fill colour tracks progress, not price: gold is filling, green is covered. */
.bar__fill--active { background: var(--gold); box-shadow: 0 0 8px rgba(212,160,23,.55); }
.bar__fill--covered { background: var(--tier-3); box-shadow: 0 0 6px rgba(76,255,138,.35); }
.bar__fill--queued, .bar__fill--uncostable { background: var(--stone-lit); box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .bar__fill { transition: none; } }

/* ---------- active item ---------- */

.active {
  display: grid; grid-template-columns: 88px 1fr; gap: 20px; align-items: center;
  background: linear-gradient(var(--stone), var(--stone-dark));
  border: 2px solid var(--gold); padding: 20px 22px; margin-bottom: 26px;
}
.active__img { width: 80px; height: 80px; object-fit: contain; image-rendering: pixelated; }
.active__body { min-width: 0; }
.active__pos { margin: 0 0 2px; font-size: 12.5px; color: var(--gold); letter-spacing: .05em; }
.active__name { font-size: clamp(21px, 2.6vw, 28px); color: var(--parchment); margin-bottom: 11px; }
.active__math { margin: 10px 0 0; font-size: 15px; color: var(--parchment-d); max-width: none; }
.active__none { margin: 0; color: var(--parchment-d); }

/* ---------- queue rows ---------- */

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.row {
  display: grid; grid-template-columns: 34px 40px 1fr auto; gap: 14px; align-items: center;
  padding: 9px 14px; cursor: pointer;
  background: var(--stone-dark); border: 1px solid #2c261d;
}
.row:hover { background: var(--stone); }
.row--covered { background: linear-gradient(90deg, rgba(76,255,138,.07), transparent 60%); }
.row--active { border-color: var(--gold); background: #2b2318; }
.row--uncostable { opacity: .55; }

.row__n { font-family: var(--font-bit); font-size: 13px; color: #6d6350; text-align: right; }
.row__img { width: 34px; height: 34px; object-fit: contain; image-rendering: pixelated; }
.row__mid { min-width: 0; display: grid; gap: 6px; }
.row__name { font-size: 15px; color: var(--parchment); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__right { text-align: right; display: grid; gap: 1px; }
.row__gp { font-family: var(--font-bit); font-size: 15px; }
.row__gp--none { color: var(--blocked); font-size: 13px; }
.row__usd { font-size: 12.5px; color: var(--parchment-d); }
.row__flag {
  grid-column: 3 / -1; font-size: 11.5px; color: var(--blocked); letter-spacing: .04em;
}

/* ---------- rate comparison ---------- */

.rates { margin-bottom: 40px; }
.rates__table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.rates__table th, .rates__table td { text-align: left; padding: 11px 12px; border-bottom: var(--rule); vertical-align: top; }
.rates__table thead th { font-size: 12px; color: var(--parchment-d); letter-spacing: .05em; font-weight: 600; }
.rates__table tbody th { font-weight: 600; color: var(--parchment); }
.rates__table td:nth-child(2), .rates__table td:nth-child(3) { font-family: var(--font-bit); }
.rates__status { font-size: 14px; color: var(--parchment-d); }
.rates__grey td:nth-child(2) { color: var(--tier-3); }
.rates__bond td:nth-child(2) { color: var(--blocked); }
.rates__gap { margin: 14px 0 0; font-size: 15px; color: var(--parchment); max-width: 74ch; }

/* ---------- covered cells ---------- */

.cell--covered { background: #1b2419; border-color: #34492f; }
.cell__tick { position: absolute; top: 3px; right: 5px; font-size: 12px; color: var(--tier-3); }

@media (max-width: 560px) {
  .active { grid-template-columns: 56px 1fr; gap: 14px; padding: 16px; }
  .active__img { width: 52px; height: 52px; }
  .row { grid-template-columns: 26px 30px 1fr auto; gap: 10px; padding: 8px 10px; }
  .row__img { width: 28px; height: 28px; }
  .rates__table { font-size: 14px; }
  .rates__table th, .rates__table td { padding: 9px 7px; }
}

/* ---------- live region + bought pool ---------- */

.live {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 40; margin: 0; max-width: min(520px, calc(100vw - 32px));
  background: var(--stone); border: 2px solid var(--gold); color: var(--parchment);
  padding: 10px 18px; font-size: 15px; text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.6);
}
.live:empty { display: none; }

.bought .cell { cursor: pointer; }

/* A covered item announces itself once as it lands, then settles. */
@keyframes landed {
  0%   { border-color: var(--tier-3); box-shadow: 0 0 0 2px rgba(76,255,138,.55); }
  100% { border-color: #34492f;       box-shadow: 1px 1px 0 rgba(0,0,0,.55) inset; }
}
.cell--new { animation: landed 1.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .cell--new { animation: none; } }

/* ---------- contract address ---------- */

/* Sits inline in the navbar, so it stays quieter than the wordmark beside it. */
.ca {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  /* Capped so it stays secondary to the wordmark rather than filling the bar. */
  flex: 0 1 auto; max-width: 420px;
}

.ca__label {
  font-family: var(--font-bit); font-size: 11px; color: var(--gold);
  letter-spacing: .06em; flex: none;
}

.ca__addr {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-bit); font-size: 11.5px; line-height: 1.4; color: var(--parchment);
  background: var(--slot); border: 1px solid var(--stone);
  box-shadow: 1px 1px 0 rgba(0,0,0,.6) inset;
  padding: 4px 8px; user-select: all;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ca__copy {
  flex: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 600;
  color: var(--ink); background: var(--gold); border: 1px solid var(--gold);
  padding: 4px 10px;
}
.ca__copy:hover { background: #f0c24d; border-color: #f0c24d; }
.ca__copy:active { transform: translateY(1px); }
.ca__copy[data-done='true'] { background: var(--tier-3); border-color: var(--tier-3); }

.ca__state { font-size: 11px; color: var(--tier-3); flex: none; }
.ca__state:empty { display: none; }

@media (max-width: 860px) {
  .ca { flex-basis: 100%; order: 3; }
  .ca__addr { white-space: normal; word-break: break-all; }
}

/* ---------- X link ---------- */

.xlink {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; color: var(--parchment-d);
  border: 1px solid var(--stone); background: var(--slot);
  box-shadow: 1px 1px 0 rgba(0,0,0,.6) inset;
}
.xlink:hover { color: var(--ink); background: var(--gold); border-color: var(--gold); }
.xlink svg { width: 14px; height: 14px; display: block; }
