/* Wide-screen side rails (rails.js). Hidden below 1300px, where nothing changes.
   Geometry, all overridable on :root or #app:
     --rails-col   width kept clear for the centre column (match the widest .screen)  720px
     --rails-gap   space between the column and each rail                            24px
     --rails-edge  minimum space to the depth gauge and to the screen edge            20px
     --rails-max   widest a rail gets                                                 360px
   The column is centred in .stage, which starts after the gauge, so its centre sits at
   50% + gauge/2. Each rail hugs the column and narrows to fit on smaller screens
   (216px at 1300px, 300px from 1468px, 360px from 1588px with a 720px column).
   Heights: rails are only as tall as their content and scroll inside if the screen is short. */

.rail { display: none; }

@media (min-width: 1300px) {
  .rail {
    --r-gw: var(--gauge-w, 60px);
    --r-col: var(--rails-col, 720px);
    --r-gap: var(--rails-gap, 24px);
    --r-edge: var(--rails-edge, 20px);
    --r-top: calc(env(safe-area-inset-top, 0px) + 64px);
    --r-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    position: absolute; z-index: 4;
    top: var(--r-top);
    width: clamp(200px, calc(50% - var(--r-gw) / 2 - var(--r-col) / 2 - var(--r-gap) - var(--r-edge)), var(--rails-max, 360px));
    max-height: calc(100% - var(--r-top) - var(--r-bottom));
    display: flex; flex-direction: column; gap: 14px;
    padding: 0 0 10px;                 /* room for the last panel's drop shadow */
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: rgba(255, 246, 230, 0.25) transparent;
    container-type: inline-size;
    color: var(--ink, #fff6e6);
    font: 400 1rem/1.4 var(--f-body, sans-serif);
    transition: opacity 0.3s steps(4, end);
  }
  .rail-left { right: calc(50% - var(--r-gw) / 2 + var(--r-col) / 2 + var(--r-gap)); }
  .rail-right { left: calc(50% + var(--r-gw) / 2 + var(--r-col) / 2 + var(--r-gap)); }
  #app.digging .rail { opacity: 0.25; }
}

.rail { --rl-myth: #e4ccff; --rl-dim: rgba(255, 246, 230, 0.16); }
.rail [hidden] { display: none !important; }
.rail :focus-visible { outline: 3px solid var(--gold, #ffcf4a); outline-offset: 3px; }
:where(.rail) :where(p, h2, ol, ul) { margin: 0; }

/* ---------- panel chrome (matches .screen) ---------- */
.rail-panel {
  flex: none; display: grid; gap: 12px; padding: 14px 16px 16px;
  background: var(--panel, rgba(16, 11, 9, 0.82));
  border: 3px solid var(--panel-edge, #000);
  box-shadow: inset 0 0 0 3px rgba(255, 246, 230, 0.1), 0 6px 0 #000;
}
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.rail-title { font: 600 1.6rem/1 var(--f-pixel); letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink, #fff6e6); text-shadow: 0 2px 0 #000; white-space: nowrap; }
.rail-sub { font: 700 0.7rem/1.2 var(--f-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold, #ffcf4a); text-align: right; }

/* ---------- your miner ---------- */
/* 120px avatar, bottom-aligned, with ~66px of headroom: the tallest hats rise ~65px above the head box. */
.rl-stage {
  position: relative; height: 196px; display: grid; place-items: end center; padding-bottom: 10px;
  background: radial-gradient(ellipse 58% 42% at 50% 74%, rgba(255, 207, 74, 0.14), transparent 72%);
}
.rl-stage::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 92px; height: 8px; margin-left: -46px; background: rgba(0, 0, 0, 0.55); }
.rl-av { position: relative; z-index: 1; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.6)); }
.rl-av img { image-rendering: pixelated; }
.rl-name { font: 600 1.75rem/1 var(--f-pixel); text-align: center; color: var(--ink, #fff6e6); text-shadow: 0 2px 0 #000; overflow-wrap: anywhere; }
.rl-status { margin-top: -6px; display: flex; align-items: center; justify-content: center; gap: 6px; font: 700 0.72rem/1.2 var(--f-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint, #a8937c); }
.rl-status::before { content: ""; width: 8px; height: 8px; border: 2px solid #000; background: var(--ink-faint, #a8937c); }
.rl-status.in { color: var(--ink-dim, #e6d5bd); }
.rl-status.in::before { background: #6fe39a; }
.rl-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.rl-actions .btn:disabled { cursor: not-allowed; }
.rl-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 12px; border-top: 2px dashed var(--line, rgba(255, 246, 230, 0.16)); }
.rl-stat { display: grid; gap: 3px; min-width: 0; }
.rl-stat b { font: 600 1.55rem/1 var(--f-pixel); font-variant-numeric: tabular-nums; color: var(--ink, #fff6e6); text-shadow: 0 2px 0 #000; white-space: nowrap; }
.rl-stat span { font: 700 0.68rem/1.2 var(--f-label); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint, #a8937c); }

/* ---------- ore icons ---------- */
.rl-ore { position: relative; flex: none; display: grid; place-items: center; width: 26px; height: 26px; }
.rl-ore img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.rl-ore.no-art::before {   /* stand-in gem when a tier's art is missing */
  content: ""; width: 13px; height: 13px; transform: rotate(45deg); background: var(--tc, #b08a64);
  box-shadow: 0 0 0 2px #000, inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.45);
}

/* ---------- this dig ---------- */
.rl-log { list-style: none; padding: 0; display: grid; }
.rl-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 44px; padding: 4px 0; border-bottom: 2px dashed var(--line, rgba(255, 246, 230, 0.16)); }
.rl-row .rl-ore { width: 28px; height: 28px; }
.rl-text { display: grid; min-width: 0; }
.rl-q { font: 400 0.74rem/1.3 var(--f-label); color: var(--ink-faint, #a8937c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-a { font: 700 0.95rem/1.3 var(--f-body); color: var(--ink, #fff6e6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-a.none { font-weight: 400; color: var(--ink-faint, #a8937c); }
.rl-a.dig { color: var(--gold, #ffcf4a); }
.rl-p { font: 600 1.3rem/1 var(--f-pixel); font-variant-numeric: tabular-nums; color: var(--tc, var(--gold, #ffcf4a)); text-shadow: 0 2px 0 #000; min-width: 2.2ch; text-align: right; }
.rl-row.miss .rl-p, .rl-row.now .rl-p { color: var(--ink-faint, #a8937c); }
.rl-slot { display: grid; place-items: center; width: 26px; height: 26px; margin: 1px; border: 2px dashed rgba(255, 246, 230, 0.22); font: 700 0.72rem/1 var(--f-label); color: var(--ink-faint, #a8937c); }
.rl-slot.on { border: 2px solid #000; background: var(--gold, #ffcf4a); color: #2a1600; }
.rl-row.empty { opacity: 0.6; }
.rl-row.now { background: linear-gradient(90deg, rgba(255, 207, 74, 0.12), transparent 85%); }
.rl-total { display: flex; align-items: baseline; gap: 10px; }
.rl-total > span { flex: 1; font: 700 0.7rem/1 var(--f-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint, #a8937c); }
.rl-total small { font: 700 0.8rem/1 var(--f-label); color: var(--ink-dim, #e6d5bd); font-variant-numeric: tabular-nums; }
.rl-total b { font: 600 1.75rem/1 var(--f-pixel); font-variant-numeric: tabular-nums; color: var(--gold, #ffcf4a); text-shadow: 0 2px 0 #000; white-space: nowrap; }
.rl-note { font-size: 0.88rem; color: var(--ink-faint, #a8937c); }

/* ---------- ore ladder (rarest on top) ---------- */
.rl-ladder { list-style: none; padding: 0; display: grid; }
.rl-tier { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 2px 6px; }
.rl-tier-main { display: grid; min-width: 0; }
.rl-tier-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rl-tier-name { font: 700 0.86rem/1.15 var(--f-label); color: var(--tc, var(--ink, #fff6e6)); text-shadow: 0 1px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-tier-odds { font: 400 0.72rem/1.2 var(--f-label); color: var(--ink-faint, #a8937c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-tier-pts { display: flex; align-items: baseline; gap: 3px; }
.rl-tier-pts b { font: 600 1.25rem/1 var(--f-pixel); font-variant-numeric: tabular-nums; color: var(--ink, #fff6e6); text-shadow: 0 2px 0 #000; }
.rl-tier-pts small { font: 700 0.62rem/1 var(--f-label); text-transform: uppercase; color: var(--ink-faint, #a8937c); }
.rl-hits { flex: none; padding: 0 4px; border: 2px solid #000; background: var(--tc, var(--gold, #ffcf4a)); color: #120c09; font: 700 0.66rem/1.15 var(--f-label); }
.rl-tier.mythic { background: linear-gradient(90deg, color-mix(in srgb, var(--tc, #fff) 16%, transparent), transparent 85%); }
.rl-tier.mythic .rl-tier-name { text-shadow: 0 1px 0 #000, 0 0 8px color-mix(in srgb, var(--tc, #fff) 75%, transparent); }
.rl-tier.mythic .rl-ore { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--tc, #fff) 80%, transparent)); }
.rl-tier.on { background: rgba(255, 207, 74, 0.14); box-shadow: inset 0 0 0 2px var(--gold, #ffcf4a), 0 0 12px rgba(255, 207, 74, 0.25); }
.rl-sep { height: 2px; margin: 6px 0; background: repeating-linear-gradient(90deg, var(--line, rgba(255, 246, 230, 0.16)) 0 6px, transparent 6px 10px); }
.rl-divider { display: flex; align-items: center; gap: 8px; padding: 0 0 4px; font: 700 0.68rem/1 var(--f-label); letter-spacing: 0.14em; text-transform: uppercase; color: var(--rl-myth); text-shadow: 0 0 8px color-mix(in srgb, var(--rl-myth) 60%, transparent); }
.rl-divider::before, .rl-divider::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px); opacity: 0.6; }

/* ---------- landmarks (shallowest on top) ---------- */
.rl-now { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.rl-now small { font: 700 0.66rem/1 var(--f-label); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint, #a8937c); }
.rl-now b { font: 600 1.45rem/1 var(--f-pixel); font-variant-numeric: tabular-nums; color: var(--gold, #ffcf4a); text-shadow: 0 2px 0 #000; }
.rl-zones { list-style: none; padding: 0; display: grid; }
.rl-zone { position: relative; display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 10px; padding: 4px 6px 5px 0; }
.rl-shaft { position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--rl-dim); }
.rl-zones > .rl-zone:first-child .rl-shaft { top: 11px; }
.rl-zones > .rl-zone:last-child .rl-shaft { bottom: auto; height: 11px; }
.rl-mark { position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 4px; border: 2px solid #000; background: var(--bg, #0e0a10); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--zc, #fff) 55%, transparent); }
.rl-zone-body { display: grid; gap: 2px; min-width: 0; }
.rl-zone-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rl-zone-name { flex: 1; min-width: 0; font: 700 0.88rem/1.3 var(--f-label); color: var(--ink-dim, #e6d5bd); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-zone-depth { flex: none; font: 700 0.78rem/1.3 var(--f-label); font-variant-numeric: tabular-nums; color: var(--ink-faint, #a8937c); white-space: nowrap; }
/* Facts: one line each (full text on hover), the current zone's in full; all in full on tall screens. */
.rl-zone-fact { font: 400 0.8rem/1.35 var(--f-body); color: var(--ink-faint, #a8937c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-zone.here .rl-zone-fact { white-space: normal; overflow: visible; }
.rl-here { justify-self: start; margin: 2px 0; padding: 2px 6px; border: 2px solid #000; background: var(--gold, #ffcf4a); color: #2a1600; font: 700 0.64rem/1.15 var(--f-label); letter-spacing: 0.06em; text-transform: uppercase; }

.rl-zone.passed .rl-shaft { background: var(--zc, #fff); }
.rl-zone.passed .rl-mark { background: var(--zc, #fff); box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35); }
.rl-zone.passed .rl-zone-name { color: var(--ink, #fff6e6); }
.rl-zone.passed .rl-zone-fact { color: var(--ink-dim, #e6d5bd); }
.rl-zone.here { background: linear-gradient(90deg, rgba(255, 207, 74, 0.13), transparent 85%); }
.rl-zone.here .rl-shaft { background: linear-gradient(var(--zc, #fff) 0 11px, var(--rl-dim) 11px); }
.rl-zones > .rl-zone.here:first-child .rl-shaft { background: var(--rl-dim); }
.rl-zone.here .rl-mark { background: var(--zc, #fff); box-shadow: 0 0 0 2px var(--gold, #ffcf4a), 0 0 10px var(--gold, #ffcf4a); }
.rl-zone.here .rl-zone-name { color: var(--gold, #ffcf4a); }
.rl-zone.here .rl-zone-depth, .rl-zone.here .rl-zone-fact { color: var(--ink, #fff6e6); }
.rl-zone.deep .rl-zone-body { opacity: 0.5; }
.rl-zone.mythic .rl-zone-name { text-shadow: 0 0 8px color-mix(in srgb, var(--zc, #fff) 65%, transparent); }
.rl-zdiv { position: relative; padding: 4px 0 4px 24px; }
.rl-zdiv.lit .rl-shaft { background: var(--zc, #fff); }

/* ---------- narrow rails (screens from 1300px to about 1470px wide) ---------- */
@container (max-width: 279px) {
  .rail-panel { padding: 12px 12px 14px; gap: 10px; }
  .rail-title { font-size: 1.35rem; }
  .rail-head { flex-wrap: wrap; row-gap: 2px; }
  .rl-name { font-size: 1.5rem; }
  .rl-stat b { font-size: 1.3rem; }
  .rl-stats { gap: 10px 8px; }
  .rl-row, .rl-tier { gap: 8px; }
  .rl-tier { padding-inline: 4px; }
  .rl-total b { font-size: 1.45rem; }
  .rl-now b { font-size: 1.25rem; }
}

/* ---------- short screens (e.g. 1080p ultrawides) and tall ones ---------- */
@media (min-width: 1300px) and (max-height: 1000px) {
  .rail { gap: 12px; }
  .rail-panel { gap: 10px; padding-block: 12px 14px; }
  .rl-stage { height: 180px; padding-bottom: 6px; }
  .rl-row { min-height: 36px; padding: 2px 0; }
  .rl-row .rl-q { display: none; }
  .rl-tier:not(.on) .rl-tier-odds { display: none; }   /* still on hover via the row title */
  .rl-zone { padding-block: 3px; }
  .rl-zone:not(.here) .rl-zone-fact { display: none; }
}
@media (min-width: 1300px) and (min-height: 1300px) {
  .rl-zone-fact { white-space: normal; overflow: visible; }
}

@media (prefers-reduced-motion: no-preference) {
  .rl-zone.here .rl-mark { animation: rl-beacon 1.6s steps(2, end) infinite; }
}
@keyframes rl-beacon { 50% { box-shadow: 0 0 0 2px var(--gold, #ffcf4a), 0 0 2px var(--gold, #ffcf4a); } }
@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
}
