/* STRATA — dark cave, warm lantern light, chunky mining-stock type. */

:root {
  --bg: #14100c;
  --bg2: #1c1610;
  --panel: #221b14;
  --panel2: #2b221a;
  --line: #3a2f24;
  --ink: #ece1d2;
  --ink-dim: #a8987f;
  --lantern: #ffb347;
  --lantern-hot: #ffd76b;
  --good: #7dd97b;
  --bad: #e06c5a;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 179, 71, 0.07), transparent 60%),
    var(--bg);
}

button {
  font-family: inherit;
  color: inherit;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.06s ease,
    filter 0.12s ease,
    background 0.12s ease;
}
button:hover {
  filter: brightness(1.15);
}
button:active {
  transform: translateY(1px) scale(0.99);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
}

.hidden {
  display: none !important;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 14px 28px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 2px 10px;
}
#logo {
  font-family: 'Alfa Slab One', serif;
  font-size: 30px;
  letter-spacing: 4px;
  color: var(--lantern);
  text-shadow:
    0 2px 0 #00000088,
    0 0 26px rgba(255, 179, 71, 0.35);
  user-select: none;
}
#depth-wrap {
  margin-left: auto;
  text-align: right;
  line-height: 1.1;
}
#depth-num {
  font-family: 'Alfa Slab One', serif;
  font-size: 22px;
  color: var(--lantern-hot);
}
#stratum-name {
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}
#top-actions {
  display: flex;
  gap: 8px;
}
#top-actions button {
  width: 38px;
  height: 38px;
  font-size: 17px;
  border-radius: 50%;
}
#top-actions button.off {
  opacity: 0.4;
}

/* ---------- layout ---------- */
#layout {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
  flex: 1;
}

/* ---------- depth rail ---------- */
#depthrail {
  position: sticky;
  top: 10px;
}
#depth-col {
  position: relative;
  height: min(76vh, 640px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.band {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0.95;
}
.band.future {
  filter: brightness(0.35) saturate(0.5);
}
.band-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
  transform-origin: center;
  white-space: nowrap;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#depth-marker {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--lantern-hot);
  box-shadow: 0 0 10px var(--lantern);
  transition: top 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#depth-marker::after {
  content: '⛏';
  position: absolute;
  right: -4px;
  top: -9px;
  font-size: 11px;
  filter: drop-shadow(0 1px 2px #000);
}

/* ---------- board ---------- */
#boardwrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
#digrow {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
#digbar {
  position: relative;
  flex: 1;
  height: 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
#digbar-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #7a5a3a, var(--lantern));
  transition: width 0.35s ease;
  box-shadow: inset 0 -6px 14px rgba(0, 0, 0, 0.35);
}
#digbar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 1px 3px #000;
}
#btn-breakthrough {
  font-family: 'Alfa Slab One', serif;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 0 22px;
  color: #2a1c08;
  background: linear-gradient(180deg, var(--lantern-hot), var(--lantern));
  border: none;
  border-radius: 12px;
  box-shadow:
    0 4px 0 #8a5a18,
    0 8px 22px rgba(255, 179, 71, 0.35);
  animation: throb 1.6s ease-in-out infinite;
}
#btn-breakthrough:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8a5a18;
}
#btn-breakthrough:disabled {
  animation: none;
  filter: saturate(0.4) brightness(0.8);
}
#btn-breakthrough small {
  display: block;
  font-family: Inter, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
}
@keyframes throb {
  0%,
  100% {
    box-shadow:
      0 4px 0 #8a5a18,
      0 8px 18px rgba(255, 179, 71, 0.25);
  }
  50% {
    box-shadow:
      0 4px 0 #8a5a18,
      0 8px 34px rgba(255, 215, 107, 0.55);
  }
}

#boardbox {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--bg2);
}
#board {
  display: block;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
#boardhint {
  min-height: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
}

/* ---------- right panel ---------- */
#panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 10px;
}

#wallet {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.coin {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 7px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.12s ease;
}
.coin.bump {
  transform: scale(1.12);
}
.coin canvas {
  width: 20px;
  height: 20px;
}
.coin .amt {
  min-width: 34px;
  text-align: right;
}
.coin.retired {
  opacity: 0.55;
}

#tabs {
  display: flex;
  gap: 4px;
}
.tab {
  flex: 1;
  padding: 9px 2px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
}
.tab.on {
  color: var(--lantern);
  border-bottom-color: var(--lantern);
}
#quest-dot {
  color: var(--good);
  margin-left: 3px;
}

#pages {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  max-height: min(62vh, 560px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.page {
  display: none;
}
.page.on {
  display: block;
}

/* shop rows */
.up-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.up-row .ico {
  font-size: 22px;
  text-align: center;
  filter: drop-shadow(0 2px 3px #000);
}
.up-row .nm {
  font-weight: 800;
  font-size: 13px;
}
.up-row .nm .up-lvl {
  color: var(--lantern);
}
.up-row .fx {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
}
.up-row .cost {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  justify-content: flex-end;
}
.up-row .cost canvas {
  width: 16px;
  height: 16px;
}
.up-row.can {
  border-color: #6a5530;
  box-shadow:
    0 0 0 1px #6a5530 inset,
    0 0 14px rgba(255, 179, 71, 0.12);
}
.up-row.can:hover {
  background: #352a1e;
}
.up-row.cant {
  opacity: 0.62;
  cursor: default;
}
.up-row.cant:hover {
  filter: none;
}
.up-row.locked {
  opacity: 0.45;
}
.up-row .cost .short {
  color: var(--bad);
}

/* works */
.work-row {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
}
.work-row .ico {
  font-size: 24px;
}
.work-row .nm {
  font-weight: 800;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.work-row .blurb {
  font-size: 11.5px;
  color: var(--ink-dim);
  margin-top: 3px;
  line-height: 1.45;
}
.work-row .cost {
  display: flex;
  gap: 9px;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
  align-items: center;
}
.work-row .cost canvas {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.work-row.can {
  border-color: #6a5530;
  box-shadow:
    0 0 0 1px #6a5530 inset,
    0 0 18px rgba(255, 179, 71, 0.14);
}
.work-row.done {
  opacity: 0.6;
}
.work-row.done .nm::after {
  content: ' ✓';
  color: var(--good);
}
.work-row.locked {
  opacity: 0.4;
}
.work-row .locknote {
  font-size: 10px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* contracts */
.quest {
  padding: 11px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.quest .qt {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.quest .qt .reroll {
  font-size: 10px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.qbar {
  height: 8px;
  border-radius: 5px;
  background: #171310;
  margin-top: 8px;
  overflow: hidden;
}
.qbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #5a8a4a, var(--good));
  transition: width 0.3s ease;
}
.qnum {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 4px;
}

/* museum */
#page-museum .mgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
}
.relic {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 24px;
  padding: 4px;
}
.relic .rn {
  font-size: 8.5px;
  text-align: center;
  color: var(--ink-dim);
  line-height: 1.2;
}
.relic.unknown {
  opacity: 0.35;
  filter: grayscale(1);
}
.relic.found:hover {
  border-color: var(--lantern);
}
.museum-note {
  font-size: 11px;
  color: var(--ink-dim);
  margin: 2px 0 10px;
  line-height: 1.5;
}

/* stats / milestones */
.mile {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 12px;
}
.mile.got {
  border-color: #44603a;
}
.mile.got .mn::before {
  content: '★ ';
  color: var(--good);
}
.mile .mv {
  color: var(--ink-dim);
  white-space: nowrap;
}
.statline {
  display: flex;
  justify-content: space-between;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--ink-dim);
}
.statline b {
  color: var(--ink);
}
.sec-h {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 12px 4px 8px;
}

/* furnace */
.furnace {
  padding: 10px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.furnace .fr {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
}
.furnace select,
.furnace input {
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  font-family: inherit;
  font-size: 12px;
}
.furnace input {
  width: 76px;
}
.furnace button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- toasts ---------- */
#toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  background: var(--panel2);
  border: 1px solid #6a5530;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  gap: 9px;
  align-items: center;
  animation: toast-in 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toast.gold {
  border-color: var(--lantern);
  color: var(--lantern-hot);
}
.toast.fade {
  transition:
    opacity 0.5s ease,
    transform 0.5s ease;
  opacity: 0;
  transform: translateY(8px);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
}

/* ---------- modal ---------- */
#modal-root {
  position: fixed;
  inset: 0;
  background: rgba(8, 5, 3, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
}
#modal-card {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid #5a4a32;
  border-radius: 18px;
  box-shadow: var(--shadow);
  max-width: 460px;
  width: 100%;
  padding: 26px 26px 20px;
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-height: 86vh;
  overflow-y: auto;
}
#m-body h1 {
  font-family: 'Alfa Slab One', serif;
  color: var(--lantern);
  letter-spacing: 3px;
  margin: 0 0 4px;
  font-size: 30px;
}
#m-body h2 {
  font-family: 'Alfa Slab One', serif;
  margin: 0 0 10px;
  font-size: 20px;
  color: var(--lantern-hot);
}
#m-body .tagline {
  color: var(--ink-dim);
  font-style: italic;
  margin: 0 0 14px;
}
#m-body p {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
}
#m-body .mut {
  color: var(--ink-dim);
  font-size: 12px;
}
#m-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}
#m-actions button {
  padding: 11px 20px;
  font-weight: 800;
  font-size: 13px;
}
#m-actions .primary {
  font-family: 'Alfa Slab One', serif;
  color: #2a1c08;
  letter-spacing: 1px;
  background: linear-gradient(180deg, var(--lantern-hot), var(--lantern));
  border: none;
  box-shadow: 0 3px 0 #8a5a18;
}
.vault-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.vault-row input {
  flex: 1;
  background: var(--bg2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.danger {
  color: var(--bad);
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  #layout {
    grid-template-columns: 44px minmax(0, 1fr) 320px;
    gap: 10px;
  }
}
@media (max-width: 880px) {
  #app {
    padding: 8px 8px 20px;
  }
  #layout {
    grid-template-columns: minmax(0, 1fr);
  }
  #depthrail {
    display: none;
  }
  #panel {
    position: static;
  }
  #pages {
    max-height: none;
  }
  #logo {
    font-size: 22px;
  }
  #depth-num {
    font-size: 18px;
  }
}
