/* Page frame: masthead, three-column board, control bar. */

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100svh;
  padding: clamp(0.9rem, 2.2vh, 1.7rem) clamp(1rem, 3.4vw, 2.6rem);
  gap: clamp(0.4rem, 1.4vh, 1rem);
  overflow-x: clip;
}

/* ---- masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.7rem, 2vw, 1.6rem);
  flex-wrap: wrap;
  padding-bottom: clamp(0.5rem, 1.4vh, 0.9rem);
  border-bottom: var(--rule);
}

.masthead .ticker { flex: 1 1 22rem; }

.mark {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.mark__name {
  font-family: var(--font-pixel);
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--hot);
  text-shadow: 2px 2px 0 var(--hot-deep);
  margin: 0;
}

.mark__seed {
  appearance: none;
  border: var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ghost-dim);
  font: inherit;
  font-size: var(--step-0);
  letter-spacing: 0.18em;
  padding: 0.22em 0.7em;
  cursor: pointer;
  transition: color 200ms, border-color 200ms, background 200ms;
}

.mark__seed:hover {
  color: var(--hot-lit);
  border-color: rgba(200, 162, 74, 0.5);
  background: rgba(200, 162, 74, 0.08);
}

.masthead__right {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 1.6rem);
}

.purse {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.purse__coin {
  width: 1.35em;
  height: 1.35em;
  flex: none;
}

.purse__value {
  font-size: var(--step-2);
  letter-spacing: 0.02em;
  color: var(--hot-lit);
}

.purse__label {
  font-size: var(--step-0);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ghost-faint);
}

.icon-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 2px solid var(--void);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--ghost-dim);
  cursor: pointer;
  box-shadow: var(--bevel);
  transition: color 200ms, background 200ms;
}

.icon-btn:hover {
  color: var(--hot-lit);
  background: var(--panel);
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
}

.icon-btn[aria-pressed='true'] .icon-on,
.icon-btn[aria-pressed='false'] .icon-off {
  display: none;
}

/* ---- board ------------------------------------------------------------- */

.board {
  display: grid;
  grid-template-columns: minmax(9rem, 12.5rem) minmax(0, 1fr) minmax(12rem, 18.5rem);
  align-items: stretch;
  gap: clamp(1rem, 3vw, 3rem);
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding-top: 0.4rem;
}

.rail--left {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(239, 231, 216, 0.18) transparent;
  padding-right: 0.3rem;
}

.rail--right {
  align-items: stretch;
}

.rail__title {
  margin: 0 0 0.9rem;
}

/* depth ladder */

.ladder {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Ten ticks in a row: the whole run at a glance, one line of vertical space. */
.ladder--bar {
  flex-direction: row;
  align-items: flex-end;
  gap: 3px;
  margin: 0.1rem 0 0.5rem;
}

.ladder--bar .ladder__rung {
  display: block;
  flex: 1;
  height: 10px;
  border-radius: 0;
  background: rgba(239, 231, 216, 0.14);
  transition: background 300ms, height 300ms var(--ease-out);
}

.ladder--bar .ladder__rung[data-state='open'] { background: var(--hot); }

.ladder--bar .ladder__rung[data-state='current'] {
  height: 18px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(255, 211, 77, 0.6);
}

.rail__next {
  margin: 0 0 1rem;
  color: var(--ghost-faint);
  letter-spacing: 0.1em;
  text-transform: none;
}

.rail__count {
  margin: 0 0 1.4rem;
}

.rail__count b {
  display: block;
  font-family: var(--font-term);
  font-size: var(--step-3);
  font-weight: 400;
  line-height: 1;
  color: var(--ghost);
}

/* ledger */

.ledger {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0 0.2rem 0 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(239, 231, 216, 0.2) transparent;
  min-height: 0;
}

.ledger:empty::after {
  content: 'nothing opened yet';
  font-size: var(--step-0);
  color: var(--ghost-faint);
  font-style: italic;
}

/* ---- controls ---------------------------------------------------------- */

.controls {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  padding-top: clamp(0.4rem, 1.4vh, 0.9rem);
  border-top: var(--rule);
  text-align: center;
}

.controls__meta {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: var(--step-0);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ghost-faint);
}

.controls__meta em {
  font-family: var(--font-flavour);
  font-style: italic;
  font-size: var(--step-1);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ghost-dim);
}

.controls__row {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.6vw, 1rem);
  flex-wrap: wrap;
  justify-content: center;
}

.controls__hint {
  margin: 0;
  font-size: var(--step-0);
  color: var(--ghost-faint);
}

.controls__hint kbd {
  font: inherit;
  border: var(--rule);
  border-radius: 0;
  padding: 0.05em 0.4em;
  color: var(--ghost-dim);
}

@media (max-width: 900px) {
  body {
    overflow-x: clip;
    overflow-y: auto;
  }

  .shell {
    height: auto;
    min-height: 100svh;
  }

  .board {
    /* minmax(0, …) or a wide child (the ticker, the prize grid) blows the track out. */
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .rail--left {
    order: 2;
    overflow: visible;
  }

  .rail--right {
    order: 3;
    max-height: none;
  }

  .masthead .ticker { flex: 1 1 100%; order: 3; }

  .panel { max-height: 22rem; }

  .stage {
    order: 1;
  }

  .rail--right {
    max-height: none;
  }

  .rail__count {
    margin: 0 0 0.8rem;
  }
}
