/* Deep Dig: Loco. Soot-black iron, brass, oxblood, and lamplight. */
@font-face {
  font-family: 'Big Shoulders Stencil';
  src: url(fonts/big-shoulders-stencil.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  src: url(fonts/barlow-semi-condensed-500.woff2) format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Semi Condensed';
  src: url(fonts/barlow-semi-condensed-700.woff2) format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Share Tech Mono';
  src: url(fonts/share-tech-mono.woff2) format('woff2');
  font-display: swap;
}

:root {
  --bg: #110c09;
  --bg-2: #1a130f;
  --panel: #241a14;
  --panel-2: #2e231b;
  --panel-edge: #3e2f24;
  --text: #f3e7d3;
  --muted: #a8978a;
  --accent: #f2b850;
  --accent-deep: #b8822a;
  --good: #8fd477;
  --danger: #ef6a4c;
  --hot: #ffb070;
  --ink: #120b07;
  --display: 'Big Shoulders Stencil', 'Barlow Semi Condensed', system-ui, sans-serif;
  --body: 'Barlow Semi Condensed', system-ui, -apple-system, sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, monospace;
  --train-h: 200px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font: 500 15px/1.35 var(--body);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---- The app: the train on top, the car's panel below ------------------------ */
#app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background: radial-gradient(120% 60% at 50% 0%, #1d140f 0%, var(--bg) 60%);
}
#top { position: relative; flex: none; padding-top: env(safe-area-inset-top); background: #0d0907; touch-action: none; z-index: 2; }
#train { display: block; width: 100%; height: var(--train-h); }
#cars {
  position: relative; height: 42px; display: flex; justify-content: center;
  background: linear-gradient(#1a120d, #110c09);
  border-top: 2px solid #4a3220; box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
#cars::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: rgba(242, 184, 80, .25); }
.strip { display: flex; gap: 2px; align-items: stretch; padding: 0 6px; width: min(100%, 620px); }
.car-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0;
  border: 0; background: none; color: #7a6656; font: 800 15px/1 var(--display); letter-spacing: .05em; text-transform: uppercase;
  padding: 0 2px; position: relative; transition: color .2s;
}
.car-tab img { height: 22px; width: auto; flex: none; opacity: .62; filter: saturate(.55); transition: opacity .2s, filter .2s; }
.car-tab.on img { opacity: 1; filter: none; }
.car-tab span { overflow: hidden; text-overflow: ellipsis; }
.car-tab.on { color: var(--accent); }
@media (max-width: 400px) {
  .car-tab { gap: 3px; font-size: 14px; letter-spacing: .03em; }
  .car-tab img { height: 16px; }
}
.car-tab.on::after {
  content: ''; position: absolute; left: 18%; right: 18%; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--accent); box-shadow: 0 0 10px rgba(242, 184, 80, .7);
}
#panels { position: relative; flex: 1; min-height: 0; overflow: hidden; transition: opacity .35s; }
#app.departing #panels, #app.departing #cars { opacity: 0; pointer-events: none; }
#app.departing #cars { transition: opacity .35s; }
.panel { position: absolute; inset: 0; will-change: transform; }
.scroll { height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.col { max-width: 620px; margin: 0 auto; padding: 12px 12px calc(env(safe-area-inset-bottom) + 28px); }

/* While the train is on the move. */
.underway {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(env(safe-area-inset-top) + var(--train-h) + 42px);
  display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; pointer-events: none; animation: fade .4s ease;
}
.uw-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.uw-card b { font: 900 38px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); text-shadow: 0 0 20px rgba(242, 184, 80, .35); animation: pop .4s cubic-bezier(.2, 1.5, .4, 1); }
.uw-card small { color: var(--muted); font-size: 14px; }
.uw-haul { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.uw-haul span { display: flex; flex-direction: column; align-items: center; animation: pop .45s cubic-bezier(.2, 1.5, .4, 1) both; }
.uw-haul span:nth-child(2) { animation-delay: .08s; } .uw-haul span:nth-child(3) { animation-delay: .16s; } .uw-haul span:nth-child(4) { animation-delay: .24s; }
.uw-haul span:nth-child(5) { animation-delay: .32s; } .uw-haul span:nth-child(6) { animation-delay: .4s; } .uw-haul span:nth-child(7) { animation-delay: .48s; }
.uw-haul img { width: 46px; height: 46px; }
.uw-haul i { font: 800 20px/1 var(--display); font-style: normal; color: var(--good); }

/* ---- Headings and plates ------------------------------------------------------ */
.car-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 2px 10px; }
.car-head h1 {
  margin: 0; font: 800 30px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; color: var(--accent);
  text-shadow: 0 2px 0 #3a2208, 0 0 18px rgba(242, 184, 80, .25);
}
.car-head .sub { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.car-head.slim { margin: 0 2px 8px; min-height: 36px; }
.car-head.slim h1 { font-size: 26px; }
.round {
  flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #4a3a2c, #241a14 70%); border: 2px solid #5a4430;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, .15), 0 2px 0 #0a0705;
}
.round img { width: 28px; height: 28px; }
.pill { display: flex; align-items: center; gap: 4px; padding: 4px 12px 4px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--panel-edge); font: 800 20px/1 var(--display); }
.pill img { width: 30px; height: 30px; }

.plate {
  position: relative; margin: 0 0 12px; padding: 12px 12px 12px;
  border-radius: 14px; border: 1px solid #3a2b20; border-top-color: #54402f;
  background:
    radial-gradient(circle at 9px 9px, #7a6048 1.4px, #120b07 2.2px, transparent 2.8px),
    radial-gradient(circle at calc(100% - 9px) 9px, #7a6048 1.4px, #120b07 2.2px, transparent 2.8px),
    radial-gradient(circle at 9px calc(100% - 9px), #7a6048 1.4px, #120b07 2.2px, transparent 2.8px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), #7a6048 1.4px, #120b07 2.2px, transparent 2.8px),
    linear-gradient(rgba(40, 30, 23, .5), rgba(24, 17, 13, .72)),
    url(art/ui/iron.webp) 0 0 / 256px 256px,
    #221913;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, .05), 0 3px 0 #0a0705, 0 6px 16px rgba(0, 0, 0, .25);
}
.plate h2 {
  margin: 0 0 10px; padding: 0 10px; font: 800 19px/1.1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: #e8c890;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px;
}
.plate h2 small { font: 500 13px/1.2 var(--body); letter-spacing: 0; text-transform: none; color: var(--muted); }
h2.group { margin: 18px 4px 10px; font: 800 22px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 10px; }
h2.group::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, rgba(242, 184, 80, .5), transparent); }
h3.mini { margin: 12px 4px 8px; font: 800 16px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: #e8c890; }
.foot { font-size: 13px; margin: 4px 6px 0; }
.ico { width: 32px; height: 32px; }
.ico.tiny { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; margin-right: 3px; }

/* ---- Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  font: 800 16px/1 var(--display); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text); background: linear-gradient(#3e3029, #2a201a); border: 2px solid #120b07; border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, .16), 0 3px 0 #0a0705; transition: transform .06s, filter .15s;
}
.btn img { width: 22px; height: 22px; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 230, 190, .16), 0 1px 0 #0a0705; }
.btn.brass { color: #2a1604; background: linear-gradient(#ffe7a2, #e2b04a 45%, #b37a24); box-shadow: inset 0 1px 0 #fff6d0, 0 3px 0 #5a3a0c; text-shadow: 0 1px 0 rgba(255, 245, 210, .6); }
.btn.danger { color: #fff; background: linear-gradient(#e86a4a, #a8321c); box-shadow: inset 0 1px 0 #ffb8a0, 0 3px 0 #4a1408; }
.btn:disabled { filter: grayscale(.85) brightness(.6); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn.wide { width: 100%; margin-top: 8px; justify-content: flex-start; text-transform: none; font: 700 15px/1.2 var(--body); letter-spacing: 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Fire up the drill. */
.go-btn {
  width: 100%; display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding: 10px 14px 10px 10px; text-align: left;
  color: #2a1604; border: 2px solid #120b07; border-radius: 16px;
  background:
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, .06) 0 10px, transparent 10px 20px),
    linear-gradient(#ffe7a2, #e8b04a 40%, #b87a22);
  box-shadow: inset 0 2px 0 #fff6d0, inset 0 -3px 0 rgba(90, 50, 8, .4), 0 4px 0 #4a2c06, 0 10px 24px rgba(242, 160, 50, .18);
  transition: transform .06s;
}
.go-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 #fff6d0, 0 1px 0 #4a2c06; }
.go-ico { flex: none; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #4a3a2c, #160f0b); border: 2px solid #120b07; box-shadow: inset 0 0 0 3px #a87a26; }
.go-ico img { width: 44px; height: 44px; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(-2px); } 50% { transform: translateX(3px); } }
.go-txt { display: flex; flex-direction: column; min-width: 0; }
.go-txt b { font: 900 27px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; }
.go-txt small { margin-top: 4px; font: 700 14px/1.25 var(--body); color: #5a3a12; }

/* ---- Tiles, slots, and chips --------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.grid.ores { grid-template-columns: repeat(5, 1fr); }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px;
  background: linear-gradient(#33271f, #251c16); border: 1px solid #120b07; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 170, .08), 0 2px 0 #0a0705; min-width: 0;
}
.tile img { width: 46px; height: 46px; }
.tile .nm { font-size: 12.5px; line-height: 1.1; text-align: center; color: #d8c8b2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .n { position: absolute; top: 4px; right: 5px; font: 800 15px/1 var(--display); color: var(--accent); text-shadow: 0 1px 0 #000, 0 0 4px #000; }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(242, 184, 80, .3); background: linear-gradient(#4a3824, #2e2116); }
.tile.dim { opacity: .45; }
.tile.dim.sel { opacity: .8; }
.grid.stock .tile .n { font-size: 17px; }

.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  position: relative; min-height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px;
  border-radius: 12px; border: 2px dashed #5a4636; background: rgba(0, 0, 0, .25); color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.1;
}
.slot img { width: 46px; height: 46px; }
.slot.empty img { width: 28px; height: 28px; opacity: .8; }
.slot.full { border: 1px solid #120b07; background: linear-gradient(#5a3f22, #3a2814); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 220, 170, .15), 0 2px 0 #0a0705; }
.slot.locked { border-style: solid; border-color: #2a201a; opacity: .55; }
.slot.locked img { width: 24px; height: 24px; }
.slot .x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; opacity: .7; }
.slot .x img { width: 18px; height: 18px; }
.slot .tgt { position: absolute; top: 4px; left: 4px; }
.slot .tgt img { width: 22px; height: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 3px; border-radius: 999px;
  background: #1a130f; border: 1px solid #3e2f24; font-size: 13px; color: var(--text);
}
.chip img { width: 22px; height: 22px; }
.chip span { display: flex; align-items: baseline; gap: 3px; }
.chip b { font-weight: 700; }
.chip i { font-style: normal; color: var(--muted); font-size: 12px; }
.chip i::before { content: '/ '; }
.chip.short { border-color: #7a2a1a; background: #2a120c; }
.chip.short b { color: var(--danger); }
.chips.compact .chip { padding-right: 7px; }

/* ---- Upgrade and recipe cards --------------------------------------------------- */
.up-sec h3 { margin: 0 0 6px; padding: 0 8px; display: flex; align-items: center; gap: 8px; font: 800 19px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: #e8c890; }
.up-sec h3 img { width: 30px; height: 30px; }
.up { display: grid; grid-template-columns: 52px 1fr auto; gap: 4px 10px; align-items: start; padding: 10px 6px; border-top: 1px solid rgba(255, 220, 170, .07); }
.up:first-of-type { border-top: 0; }
.plate > .up:first-child, .up-sec h3 + .up { border-top: 0; }
.up-ico { width: 52px; height: 52px; padding: 2px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid #3e2f24; }
.up-ico img { width: 46px; height: 46px; }
.up-main { min-width: 0; }
.up h4 { margin: 2px 0 0; font: 700 16.5px/1.15 var(--body); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.up h4 small { font-weight: 500; font-size: 13px; color: var(--muted); }
.up .eff { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.up.installed .eff { color: var(--good); }
.up.idle .eff { color: var(--muted); }
.up-act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 4px; }
.up .done { display: inline-flex; align-items: center; gap: 4px; font: 800 15px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--good); }
.up .done img { width: 20px; height: 20px; }
.up .need { max-width: 110px; font-size: 12.5px; color: var(--danger); text-align: right; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: #3e2f24; }
.pips i.on { background: var(--good); box-shadow: 0 0 6px rgba(143, 212, 119, .6); }
.up.make.flash { animation: flash 1.4s ease; border-radius: 10px; }
@keyframes flash { 0%, 40% { background: rgba(242, 184, 80, .18); } }
@media (max-width: 380px) {
  .up { grid-template-columns: 44px 1fr; }
  .up-ico { width: 44px; height: 44px; }
  .up-ico img { width: 38px; height: 38px; }
  .up-act { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; padding-top: 2px; }
}

.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.toggle {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 12px; text-align: left;
  border: 1px solid #120b07; background: #1a130f; color: var(--muted); font-size: 13.5px; line-height: 1.1;
}
.toggle img { width: 30px; height: 30px; opacity: .5; }
.toggle span { flex: 1; }
.toggle i { flex: none; width: 34px; height: 18px; border-radius: 9px; background: #3e2f24; position: relative; transition: background .2s; }
.toggle i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #a8978a; transition: transform .2s, background .2s; }
.toggle.on { color: var(--text); background: #22301e; }
.toggle.on img { opacity: 1; }
.toggle.on i { background: #3f7a32; }
.toggle.on i::after { transform: translateX(16px); background: #e8ffd8; }
.toggle.mini { padding: 6px 10px; gap: 8px; }
.toggle.mini span { font: 800 15px/1 var(--display); text-transform: uppercase; letter-spacing: .05em; }

/* ---- The recipe bar over the smelter's and mill's games ----------------------------- */
.recipe-bar { padding: 8px 10px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.recipe-bar .flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.recipe-bar .flow .chips { margin: 0; }
.recipe-bar .to img { width: 22px; height: 22px; }
.recipe-bar .out { width: 44px; height: 44px; }
.recipe-bar .qty { font: 800 22px/1 var(--display); color: var(--accent); }
.recipe-bar .meta { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button {
  min-width: 36px; height: 36px; border-radius: 9px; border: 2px solid #120b07; background: linear-gradient(#3e3029, #2a201a);
  font: 800 20px/1 var(--display); box-shadow: inset 0 1px 0 rgba(255, 230, 190, .16), 0 2px 0 #0a0705;
}
.stepper button.max { padding: 0 8px; font-size: 14px; letter-spacing: .05em; }
.stepper b { min-width: 40px; text-align: center; font: 800 22px/1 var(--display); }
@media (max-width: 400px) {
  .stepper button { min-width: 32px; height: 34px; }
  .stepper b { min-width: 34px; font-size: 20px; }
  .recipe-bar .out { width: 38px; height: 38px; }
}

/* ---- The games' boxes ------------------------------------------------------------------ */
.game {
  position: relative; margin: 0 0 12px; border-radius: 16px; overflow: hidden; touch-action: none;
  border: 2px solid #120b07; box-shadow: inset 0 0 0 2px #4a3524, 0 3px 0 #0a0705, 0 8px 24px rgba(0, 0, 0, .35);
}
.result {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; text-align: center; background: rgba(14, 9, 6, .9); animation: fade .25s ease;
}
.result h3 { margin: 0; font: 900 34px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--accent); text-shadow: 0 0 18px rgba(242, 184, 80, .4); animation: pop .35s cubic-bezier(.2, 1.5, .4, 1); }
.result small { color: var(--muted); font-size: 13px; animation: blink 1.6s ease-in-out infinite; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes blink { 50% { opacity: .45; } }
.fx { display: flex; align-items: center; justify-content: center; gap: 10px; }
.fx-side { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 160px; }
.fx-item { display: flex; flex-direction: column; align-items: center; font: 800 18px/1 var(--display); }
.fx-item img { width: 44px; height: 44px; }
.fx-side.out .fx-item img { width: 60px; height: 60px; }
.fx-side.out .fx-item b { font-size: 24px; color: var(--accent); }
.fx-side.bad { opacity: .8; }
.fx-arrow { width: 34px; height: 34px; }
.fx-badge { position: absolute; top: -22px; right: -30px; width: 48px; height: 48px; display: grid; place-items: center; animation: pop .4s .2s both cubic-bezier(.2, 1.6, .4, 1); }
.fx-badge img { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx-badge span { position: relative; font: 900 18px/1 var(--display); color: #3a1c04; }

/* The furnace: touch and hold anywhere. */
.furnace {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 12px; min-height: 236px; cursor: pointer;
  background:
    radial-gradient(120% 90% at 50% 120%, rgba(255, 110, 30, calc(.08 + var(--heat, 0) * .4)), transparent 70%),
    linear-gradient(#2a1c14, #160e0a);
}
.furnace.blocked { cursor: not-allowed; }
.gauge {
  position: relative; border-radius: 28px; border: 3px solid #120b07; overflow: hidden;
  background: linear-gradient(to top, #2a3a5a 0%, #4a3a5a 18%, #8a2a1a 40%, #e2561c 65%, #ffb02a 85%, #fff2b8 100%);
  box-shadow: inset 0 0 0 2px #6a4a2a, inset 6px 0 10px rgba(255, 255, 255, .15), inset -8px 0 12px rgba(0, 0, 0, .45);
}
.gauge .band { position: absolute; left: 0; right: 0; background: rgba(255, 255, 255, .28); border-top: 2px solid #fff6d0; border-bottom: 2px solid #fff6d0; box-shadow: 0 0 14px rgba(255, 240, 180, .8); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { background: rgba(255, 255, 255, .42); } }
.gauge .line { position: absolute; left: 0; right: 0; height: 0; border-top: 3px dashed #ff3a1a; filter: drop-shadow(0 0 3px #000); }
.gauge .needle {
  position: absolute; left: -2px; right: -2px; height: 6px; margin-bottom: -3px; border-radius: 3px;
  background: #fff; box-shadow: 0 0 0 2px #120b07, 0 0 10px #fff; transition: background .2s;
}
.gauge .needle.good { background: #d8ffb8; box-shadow: 0 0 0 2px #120b07, 0 0 14px #8fd477; }
.gauge .needle.hot { background: #ffd0a0; }
.gauge .needle.cold { background: #b8c8e8; }
.readout { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.big { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.big span { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.big b { font: 400 34px/1 var(--mono); color: #ffe2a0; text-shadow: 0 0 10px rgba(255, 180, 80, .5); }
.big.paused b { color: var(--danger); animation: blink .8s steps(2, start) infinite; }
.bar { height: 12px; border-radius: 6px; background: #120b07; border: 1px solid #4a3524; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c8601c, #ffd27a); box-shadow: 0 0 10px rgba(255, 180, 80, .6); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid #3e2f24; }
.stat > img { width: 38px; height: 38px; flex: none; }
.stat div { display: flex; flex-direction: column; min-width: 0; }
.stat b { font: 800 24px/1 var(--display); }
.stat span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ring {
  --p: 0; --fill: #f08a2c; position: relative; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: conic-gradient(var(--fill) calc(var(--p) * 1turn), #120b07 0);
}
.ring::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: #241a14; }
.ring img { position: absolute; inset: 7px; width: 26px; height: 26px; opacity: .6; filter: grayscale(.5); }
.ring.rush { --fill: #ffe27a; box-shadow: 0 0 14px rgba(255, 226, 122, .8); animation: dance .3s ease-in-out infinite alternate; }
.ring.rush img, .ring.max img { opacity: 1; filter: none; }
.ring.max { --fill: var(--good); }
@keyframes dance { to { transform: rotate(8deg) scale(1.06); } }
.made-n { transform-origin: left center; }
.status { margin: 0; min-height: 19px; font-weight: 700; font-size: 14.5px; color: var(--muted); }
.status.good { color: var(--good); }
.status.hot { color: var(--hot); }
.status.bad { color: var(--danger); }
.hint {
  position: absolute; left: 80px; right: 12px; bottom: 44px; display: flex; flex-direction: column; align-items: center; pointer-events: none;
  padding: 10px; border-radius: 14px; background: rgba(18, 11, 7, .72); border: 2px dashed rgba(242, 184, 80, .55);
  animation: breathe 1.6s ease-in-out infinite; transition: opacity .3s;
}
.hint b { font: 900 26px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.hint small { margin-top: 3px; color: var(--muted); }
.hint.gone, .furnace.blocked .hint { opacity: 0; }
@keyframes breathe { 50% { transform: scale(1.03); } }
.furnace.held { --heat: 1; }
.furnace.held .gauge { box-shadow: inset 0 0 0 2px #ffb02a, inset 6px 0 10px rgba(255, 255, 255, .15), 0 0 14px rgba(255, 140, 40, .6); }
.lump { position: fixed; width: 22px; height: 22px; z-index: 40; pointer-events: none; }

/* The mill's bed: tap anywhere. */
.mill { display: flex; justify-content: center; padding: 3px; background: #0f0a07; cursor: pointer; }
.mill canvas { display: block; border-radius: 10px; }

/* The fabricator's cover. */
.wip {
  touch-action: pan-y; padding: 0; color: #2a1604;
  background: repeating-linear-gradient(-45deg, #2a2420 0 18px, #221c18 18px 36px);
}
.wip-tape { height: 22px; background: repeating-linear-gradient(-45deg, #f2b62e 0 16px, #1a1410 16px 32px); border-bottom: 2px solid #120b07; }
.wip-tape.low { border-bottom: 0; border-top: 2px solid #120b07; }
.wip-body { display: flex; align-items: center; gap: 12px; margin: 14px; padding: 12px 14px; border-radius: 12px; background: #f2b62e; border: 3px solid #120b07; box-shadow: 0 3px 0 #0a0705; transform: rotate(-1deg); }
.wip-body h3 { margin: 0; font: 900 24px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; }
.wip-body p { margin: 4px 0 0; font-weight: 700; font-size: 14px; line-height: 1.3; }
.wip-cog { width: 56px; height: 56px; flex: none; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Bottom sheet ----------------------------------------------------------------------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 35; display: flex; align-items: flex-end; justify-content: center; background: rgba(6, 4, 2, .6); animation: fade .2s ease; }
.sheet {
  width: min(100%, 620px); max-height: 82vh; margin: 0; padding: 12px 12px calc(env(safe-area-inset-bottom) + 14px);
  border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: rise .25s cubic-bezier(.2, .9, .3, 1);
}
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sheet h2 { margin: 0; padding-left: 6px; }
.sheet .x { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid #3e2f24; background: #1a130f; display: grid; place-items: center; }
.sheet .x img { width: 20px; height: 20px; }
.sheet-body { overflow-y: auto; padding: 2px 4px 4px; -webkit-overflow-scrolling: touch; }
.sheet-body p { margin: 4px 2px 10px; }
.sheet-body .grid { margin-bottom: 10px; }
.about { margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(255, 220, 170, .08); }
.about p { display: block; min-height: 28px; padding-left: 34px; position: relative; font-size: 13.5px; color: var(--muted); }
.about p img { position: absolute; left: 0; top: -2px; width: 26px; height: 26px; }
.about b { color: var(--text); }
.detail { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.detail .huge { width: 84px; height: 84px; }
.detail .big-n { display: block; font: 900 40px/1 var(--display); color: var(--accent); }
.empty { margin: 0 10px; }

/* ---- Toast ------------------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + var(--train-h) + 52px); z-index: 60;
  transform: translate(-50%, -10px); opacity: 0; pointer-events: none; max-width: calc(100% - 32px);
  padding: 9px 16px; border-radius: 999px; background: #1a130f; border: 2px solid var(--accent); color: var(--text);
  font: 800 17px/1.1 var(--display); letter-spacing: .04em; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--danger); }

/* ---- The mine ------------------------------------------------------------------------------ */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: radial-gradient(100% 70% at 50% 40%, #241911, #0d0907 80%); }
.mine-hud { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; max-width: 620px; width: 100%; margin: 0 auto; }
.fuel {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 62px; height: 56px; border-radius: 12px;
  background: radial-gradient(circle at 50% 30%, #3a2c22, #1a130f); border: 2px solid #120b07; box-shadow: inset 0 0 0 2px #6a4a2a;
}
.fuel .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.fuel b { font: 900 30px/1 var(--display); color: #ffe2a0; }
.fuel.low b { color: var(--danger); animation: blink .8s steps(2, start) infinite; }
.tally { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.tally-item { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.tally-item img { width: 30px; height: 30px; }
.tally-item .total { font: 800 14px/1 var(--display); }
.tally-item .gain { position: absolute; top: -6px; right: -2px; font: 800 13px/1 var(--display); color: var(--good); text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.tally-item .gain.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.manual-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2px solid #5a4430; background: radial-gradient(circle at 35% 30%, #4a3a2c, #241a14 70%); display: grid; place-items: center; padding: 0; }
.manual-btn img { width: 26px; height: 26px; }
#chain-info { flex: none; min-height: 22px; padding: 2px 12px; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--muted); }
#chain-info.ok { color: var(--accent); }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 8px; }
#board {
  display: block; touch-action: none; border-radius: 10px; border: 5px solid #120b07;
  box-shadow: 0 0 0 3px #6a4a2a, 0 0 0 5px #120b07, 0 10px 30px rgba(0, 0, 0, .6);
}
.toolbar { flex: none; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 6px 10px 10px; max-width: 620px; width: 100%; margin: 0 auto; }
.tool-btn {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 12px;
  border: 2px solid #120b07; background: linear-gradient(#3e3029, #2a201a); box-shadow: inset 0 1px 0 rgba(255, 230, 190, .16), 0 2px 0 #0a0705;
}
.tool-btn img { width: 34px; height: 34px; }
.tool-btn .tname { font-weight: 700; font-size: 13.5px; }
.tool-btn .tcount { font: 800 15px/1 var(--display); color: var(--accent); }
.tool-btn.aiming { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(242, 184, 80, .5); }
.haul { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 5, 3, .78); animation: fade .25s ease; }
.haul-card { width: min(100%, 420px); padding: 16px 16px 18px; text-align: center; }
.haul-card h1 { margin: 0 0 8px; font: 900 40px/1 var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.haul-card ul { list-style: none; margin: 0 0 8px; padding: 0; text-align: left; }
.haul-card li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-bottom: 1px solid rgba(255, 220, 170, .06); }
.haul-card li.none { opacity: .45; }
.haul-card li img { width: 32px; height: 32px; }
.haul-card li .name { flex: 1; }
.haul-card li .gain { font: 800 18px/1 var(--display); color: var(--good); }
.haul-card li .qty { min-width: 44px; text-align: right; font: 800 18px/1 var(--display); }
.haul-card .muted { font-size: 13px; }
.btn.big { width: 100%; min-height: 54px; font-size: 22px; margin-top: 6px; }

/* ---- The manual --------------------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; background: rgba(10, 6, 4, .88); animation: fade .2s ease; }
.mpanel { width: 100%; max-width: 620px; height: 100%; display: flex; flex-direction: column; background: var(--bg); padding: calc(env(safe-area-inset-top) + 10px) 10px calc(env(safe-area-inset-bottom) + 6px); }
.mhead { display: flex; align-items: center; justify-content: space-between; }
.mhead h2 { margin: 0; display: flex; align-items: center; gap: 8px; font: 900 28px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.mhead h2 .ico { width: 32px; height: 32px; }
.mclose { width: 44px; height: 44px; font-size: 20px; border-radius: 50%; background: var(--panel); border: 1px solid var(--panel-edge); }
.mtabs { display: flex; gap: 4px; overflow-x: auto; padding: 10px 0 6px; flex: none; }
.mtabs button { flex: none; padding: 7px 12px; font: 800 15px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; color: var(--muted); }
.mtabs button.on { color: var(--accent); border-color: var(--accent); }
.msearch { flex: none; margin-bottom: 6px; padding: 10px 12px; font-size: 16px; color: var(--text); background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; -webkit-user-select: text; user-select: text; }
.mbody { flex: 1; overflow-y: auto; padding: 0 2px 30px; -webkit-user-select: text; user-select: text; }
.mbody p, .mbody li { font-size: 15px; line-height: 1.5; }
.mguide h3, .mgroup { margin: 18px 0 6px; font: 800 21px/1.1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.mguide ul, .mguide ol { padding-left: 20px; margin: 0; }
.mguide li { margin-bottom: 4px; }
.mentry { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; scroll-margin-top: 4px; }
.mentry.flash { animation: mflash 1.2s ease; }
@keyframes mflash { 0%, 40% { border-color: var(--accent); box-shadow: 0 0 16px rgba(242, 184, 80, .5); } }
.mentry header { display: flex; align-items: center; gap: 10px; }
.mentry header .ico.big { width: 46px; height: 46px; }
.mentry h4 { margin: 0; font-size: 17px; }
.mentry header small { color: var(--muted); }
.mentry > p { margin: 8px 0 0; }
.mrow { margin: 6px 0 0; padding-left: 66px; text-indent: -66px; }
.mlabel { display: inline-block; width: 66px; text-indent: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.mrow .mlink { text-indent: 0; }
.mlink { display: inline-flex; align-items: center; gap: 3px; margin: 1px 2px; padding: 1px 7px 1px 3px; background: var(--panel-2); border-radius: 999px; color: var(--text); text-decoration: none; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.mlink .ico { width: 20px; height: 20px; }
.mbody .ico { display: inline-block; width: 22px; height: 22px; vertical-align: -5px; }
.mtier { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 14px; }
.mtier div { margin-top: 4px; }
.mtable { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: 14px; }
.mtable th, .mtable td { text-align: left; padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.mtable.recipes td:nth-child(2) { color: var(--muted); width: 16px; }

/* ---- The ideas tab (ideas.js) ------------------------------------------------------------- */
.idea-tab {
  position: fixed; left: 0; z-index: 45; width: 32px; height: 50px; padding: 0 0 0 2px;
  display: grid; place-items: center; cursor: grab; touch-action: none;
  background: var(--panel-2); border: 2px solid var(--accent); border-left: 0; border-radius: 0 14px 14px 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35); opacity: .75; transition: opacity .15s, transform .15s;
}
.idea-tab.right { left: auto; right: 0; padding: 0 2px 0 0; border-left: 2px solid var(--accent); border-right: 0; border-radius: 14px 0 0 14px; }
.idea-tab img { width: 24px; height: 24px; pointer-events: none; }
.idea-tab:hover, .idea-tab:focus-visible, .idea-tab.dragging { opacity: 1; }
.idea-tab.dragging { cursor: grabbing; transform: scale(1.08); }
.idea-sheet { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: calc(env(safe-area-inset-top) + 14px) 12px 12px; background: rgba(0, 0, 0, .55); animation: fade .15s ease; }
.idea-card { width: min(100%, 460px); display: grid; gap: 10px; padding: 16px; background: var(--panel); color: var(--text); border: 2px solid var(--accent); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.idea-card h2 { margin: 0; font: 900 26px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.idea-card textarea { width: 100%; min-height: 120px; resize: vertical; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--panel-edge); background: var(--panel-2); color: var(--text); font: inherit; font-size: 16px; -webkit-user-select: text; user-select: text; }
.idea-card textarea:focus { outline: none; border-color: var(--accent); }
.idea-where { margin: 0; color: var(--muted); font-size: 13px; }
.idea-actions { display: flex; justify-content: flex-end; gap: 10px; }
.idea-actions button { min-height: 44px; padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 15px; border: 1px solid var(--panel-edge); background: var(--panel-2); color: var(--text); }
.idea-actions .idea-save { background: var(--accent); border-color: var(--accent); color: #2a1604; }
