:root {
  --slate: #0a0f12;
  --patina-950: #0b1617;
  --patina-900: #0e1c1c;
  --patina-800: #132828;
  --patina-700: #183433;
  --verdigris: #4e9a88;
  --verdigris-dim: rgba(78, 154, 136, 0.28);
  --brass: #d6a84f;
  --brass-dim: rgba(214, 168, 79, 0.35);
  --bone: #ece5d3;
  --bone-dim: #a9a593;
  --bone-faint: #6f7468;
  --ember: #ff7a3d;
  --frost: #8fd4ff;

  --f-display: 'IM Fell English SC', 'Iowan Old Style', Georgia, serif;
  --f-ui: 'Barlow Semi Condensed', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

  --panel-w: 332px;
  --r: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--slate);
  color: var(--bone);
  font: 500 15px/1.35 var(--f-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--f-mono); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ───────────── stage ───────────── */
#stage { position: relative; flex: 1; min-width: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#view.panning { cursor: grabbing; }

#readout {
  position: absolute; left: 14px; top: 12px;
  font: 500 12px/1.2 var(--f-mono); letter-spacing: 0.02em;
  color: var(--bone-dim); pointer-events: none;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}
#readout b { color: var(--bone); font-weight: 500; }
#readout .hot { color: var(--ember); }
#readout .cold { color: var(--frost); }

#toolbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  padding: 5px;
  background: rgba(11, 22, 23, 0.86);
  border: 1px solid var(--verdigris-dim);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  width: max-content;
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 2px;
}
.tb {
  flex: none;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  padding: 6px 11px; min-width: 36px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em; color: var(--bone-dim);
  white-space: nowrap;
}
.tb:hover { color: var(--bone); background: var(--patina-800); }
.tb[aria-pressed="true"] { color: var(--brass); border-color: var(--brass-dim); background: rgba(214, 168, 79, 0.08); }
.tb .ico { font-family: var(--f-mono); font-size: 13px; letter-spacing: -0.05em; }
.tb:disabled { opacity: 0.32; cursor: default; background: transparent; }
.tb.zoom { min-width: 52px; }
.tb .dim { color: var(--bone-faint); font-size: 12px; margin-left: 2px; }
@media (max-width: 1250px) { .tb .dim { display: none; } }
.sep { width: 1px; height: 20px; background: var(--verdigris-dim); margin: 0 4px; flex: none; }

.menu {
  position: absolute; bottom: calc(var(--tb-h, 46px) + 22px); left: 50%; transform: translateX(-50%);
  max-height: calc(100% - var(--tb-h, 46px) - 40px); overflow-y: auto;
  display: grid; gap: 2px; padding: 6px; min-width: 280px;
  background: var(--patina-900); border: 1px solid var(--verdigris-dim); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.menu[hidden] { display: none; }
.menu.wide { min-width: 360px; padding: 10px 12px 12px; }
.menu-title { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); padding: 6px 12px 6px; }
.menu.wide .menu-title { padding: 2px 2px 8px; }
.menu-sep { height: 1px; background: var(--verdigris-dim); margin: 4px 6px; }
.menu button[aria-pressed="true"] { color: var(--brass); background: rgba(214, 168, 79, 0.1); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 10px; }
.menu .presets button { text-align: center; padding: 7px 4px; font-size: 13.5px; border: 1px solid rgba(78, 154, 136, 0.2); }
.presets.sky { grid-template-columns: repeat(4, 1fr); margin: 0 6px 6px; }
.slider { display: grid; grid-template-columns: 112px 1fr 70px; align-items: center; gap: 10px; font-size: 13px; color: var(--bone-dim); padding: 4px 2px; }
.slider output { text-align: right; color: var(--bone); font-size: 12px; }
.slider input { accent-color: var(--brass); }
.menu-note { margin: 8px 2px 0; font-size: 12.5px; line-height: 1.4; color: var(--bone-faint); }
.menu button {
  text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px 12px;
  font-weight: 600; font-size: 15px;
}
.menu button small { display: block; font-weight: 400; color: var(--bone-faint); font-size: 13px; }
.menu button.locked { color: var(--bone-faint); }
.menu button .needs:not(:empty) { display: block; font-size: 12px; font-weight: 500; color: rgba(214, 168, 79, 0.8); }
.menu button:hover { background: var(--patina-700); }

/* ───────────── toasts ───────────── */
#toasts {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: min(440px, calc(100% - 28px));
}
.toast {
  position: relative; display: flex; gap: 14px; align-items: center; width: 100%;
  padding: 10px 34px 10px 10px;
  background: linear-gradient(180deg, rgba(24, 52, 51, 0.96), rgba(14, 28, 28, 0.96));
  border: 1px solid var(--brass-dim);
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(236, 229, 211, 0.06);
  animation: toast-in 420ms cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.out { animation: toast-out 380ms ease-in both; }
.toast canvas { width: 44px; height: 44px; border-radius: 5px; image-rendering: pixelated; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.toast .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }
.toast .name { font: 26px/1.05 var(--f-display); color: var(--bone); margin: 3px 0 2px; }
.toast .how { font-size: 13.5px; color: var(--bone-dim); }
.toast.note .name { font: 600 16px/1.2 var(--f-ui); }
.toast > div { flex: 1; min-width: 0; }
.toast .t-icon {
  flex: none; width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(5, 10, 12, 0.45); box-shadow: inset 0 0 0 1px rgba(236, 229, 211, 0.12);
}
/* the × on every toast: the only part of it that takes a click, so the rest never blocks the map */
.toast .t-close {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--bone-dim); font: 600 18px/1 var(--f-ui); cursor: pointer; pointer-events: auto;
}
.toast .t-close:hover { color: var(--bone); background: rgba(236, 229, 211, 0.08); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ───────────── the divider: drag it to give the panel (or the map) more room ───────────── */
#splitter {
  flex: none; position: relative; z-index: 6;
  width: 10px; margin: 0 -5px; /* takes no room: it straddles the panel's edge */
  cursor: col-resize; touch-action: none;
}
#splitter::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px;
  background: transparent; transition: background 0.15s;
}
#splitter:hover::after, #splitter:focus-visible::after, #splitter.dragging::after { background: var(--brass); }
#splitter:focus-visible { outline: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; }
body.resizing.rows, body.resizing.rows * { cursor: row-resize !important; }

/* ───────────── panel ───────────── */
#panel {
  width: var(--panel-user, var(--panel-w)); flex: none;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--patina-900), var(--patina-950));
  border-left: 1px solid var(--verdigris-dim);
  min-height: 0;
}
.brand { position: relative; padding: 16px 18px 12px; border-bottom: 1px solid rgba(78, 154, 136, 0.16); }
.brand-min {
  position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center; border-radius: 5px;
  background: transparent; border: 1px solid rgba(78, 154, 136, 0.25); color: var(--bone-faint);
  font: 600 15px/1 var(--f-ui);
}
.brand-min:hover { color: var(--bone); border-color: var(--verdigris); }
/* minimized: one slim line, the name and the count */
.brand.min { display: flex; align-items: center; gap: 12px; padding: 7px 46px 7px 16px; }
.brand.min h1 { font-size: 19px; text-shadow: none; }
.brand.min .progress { margin: 0; flex: 1; min-width: 0; }
.brand.min .progress-text { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand.min .bar { display: none; }
.brand.min .brand-min { top: 50%; margin-top: -12px; }
.brand:not(.min) h1 { padding-right: 30px; }

/* grips between the panel's parts: drag one to give the tools or the description more room or less */
.grip { flex: none; position: relative; z-index: 2; height: 10px; margin: -5px 0; cursor: row-resize; touch-action: none; }
.grip::after {
  content: ''; position: absolute; top: 3px; left: 50%; width: 44px; height: 4px; margin-left: -22px;
  border-radius: 2px; background: rgba(169, 165, 147, 0.22); transition: background 0.15s;
}
.grip:hover::after, .grip:focus-visible::after, .grip.dragging::after { background: var(--brass); }
.grip:focus-visible { outline: none; }
.tools.sized, #inspect.sized { flex: none; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
.tools.sized, #inspect.sized { align-content: start; }
.brand h1 {
  margin: 0; font: 34px/1 var(--f-display); letter-spacing: 0.01em; color: var(--brass);
  text-shadow: 0 0 18px rgba(214, 168, 79, 0.25);
}
/* the logo stands in for the name, as wide as the name was at each size, with the same soft glow */
.brand h1 .logo { display: block; height: 0.83em; width: auto; filter: drop-shadow(0 0 12px rgba(214, 168, 79, 0.22)); }
.brand.min h1 .logo { filter: none; }
.progress { margin-top: 10px; }
.progress-text { font-size: 13px; color: var(--bone-dim); }
.progress-text span { font-family: var(--f-mono); color: var(--bone); }
.bar { height: 4px; margin-top: 6px; background: rgba(78, 154, 136, 0.18); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--verdigris), var(--brass)); transition: width 600ms ease; }

.tools { padding: 12px 18px 10px; display: grid; gap: 10px; border-bottom: 1px solid rgba(78, 154, 136, 0.16); }
/* five tools, each an icon over its name, so they fit in one row at any width */
.tool-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.glyph svg { display: block; }
.glyph.magnet { color: #d08cff; }
.glyph.smash { color: #e0b070; }
/* the Magnet's box holds the Magnetic switch, beside its icon: on, it picks up only magnetic metals */
.tool-box { position: relative; display: grid; min-width: 0; }
.magnet-box .tool .glyph { transform: translateX(-12px); }
.mag-switch {
  position: absolute; top: 5px; left: calc(50% - 1px); padding: 3px 2px; line-height: 0;
  background: none; border: 0; border-radius: 4px; color: var(--bone-dim);
}
.mag-switch:hover .track { background: rgba(169, 165, 147, 0.38); }
.mag-switch .track { position: relative; display: block; width: 22px; height: 12px; border-radius: 6px; background: rgba(169, 165, 147, 0.22); transition: background 150ms; }
.mag-switch .knob { position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bone-faint); transition: left 150ms, background 150ms; }
.mag-switch[aria-checked="true"] .track { background: rgba(208, 140, 255, 0.45); }
.mag-switch[aria-checked="true"] .knob { left: 12px; background: #d08cff; }
.magnet-box.magnetic .tool { border-color: rgba(208, 140, 255, 0.55); }
.magnet-box.magnetic .tool.on { border-color: #d08cff; background: rgba(208, 140, 255, 0.1); }
.shape-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.shape {
  display: grid; place-items: center; padding: 6px 0; border-radius: 6px;
  background: transparent; border: 1px solid rgba(78, 154, 136, 0.2); color: var(--bone-dim);
}
.shape:hover { color: var(--bone); border-color: var(--verdigris); }
.shape[aria-pressed="true"], .shape.on { color: var(--brass); border-color: var(--brass); background: rgba(214, 168, 79, 0.1); }
/* Ground: a tool in the shape row's spare room, wider than a shape */
.shape.ground { grid-column: span 2; display: flex; align-items: center; justify-content: center; gap: 5px; font: 600 12.5px/1 var(--f-ui); }
.shape.ground .glyph { display: grid; place-items: center; color: #7fd6c8; }
.shape.shock .glyph { color: #ffd27a; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0;
  padding: 6px 2px 5px; border-radius: var(--r);
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.2);
  font-weight: 600; font-size: 13px; line-height: 1; color: var(--bone-dim); white-space: nowrap;
}
.tool .glyph { display: grid; place-items: center; height: 16px; font-size: 13px; }
.tool:hover { color: var(--bone); border-color: var(--verdigris); }
.tool.on { color: var(--bone); border-color: var(--brass); background: rgba(214, 168, 79, 0.1); }
.glyph { font-size: 12px; }
.glyph.heat { color: var(--ember); }
.glyph.cool { color: var(--frost); }
.brush { display: grid; grid-template-columns: auto 1fr 28px; align-items: center; gap: 10px; font-size: 13px; color: var(--bone-dim); }
.brush output { text-align: right; color: var(--bone); font-size: 12px; }
input[type=range] { accent-color: var(--brass); width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--bone-dim); cursor: pointer; }
.check input { accent-color: var(--brass); margin: 0; }

/* ───────────── tabs ───────────── */
.tabs { display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 4px; padding: 10px 14px 0; }
.tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 6px 4px 7px;
  font: 600 13px/1 var(--f-ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--bone-faint);
}
.tabs button:hover { color: var(--bone-dim); }
.tabs button[aria-selected="true"] { color: var(--brass); border-bottom-color: var(--brass); }
#panel.wide { --panel-w: 440px; width: max(var(--panel-user, 0px), var(--panel-w)); }

/* ───────────── the periodic table ───────────── */
#ptable { flex: 1; overflow-y: auto; padding: 12px 12px 14px; min-height: 0; }
#ptable[hidden] { display: none; }
#pgrid { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); grid-auto-rows: auto; gap: 2px; }
.pcell {
  position: relative; aspect-ratio: 1 / 1.12; min-width: 0; padding: 1px 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 3px;
  background: var(--fam, #263333); color: var(--bone);
  font: 700 clamp(8px, 0.9vw, 12px)/1 var(--f-ui);
  transition: transform 100ms ease;
}
.pcell i { font: 400 clamp(6px, 0.55vw, 8px)/1 var(--f-mono); font-style: normal; color: rgba(236, 229, 211, 0.55); margin-bottom: 1px; }
.pcell::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: 2px; height: 2px; border-radius: 1px; background: var(--swatch); opacity: 0.9; }
.pcell:hover { transform: scale(1.18); z-index: 2; border-color: var(--bone-dim); }
.pcell.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 0 12px rgba(214, 168, 79, 0.45); z-index: 1; }
.pgap { grid-column: 1 / -1; height: 6px; }
.fam-alk { --fam: #5e3027; } .fam-ae { --fam: #5e4627; } .fam-tm { --fam: #2b3a4a; } .fam-pt { --fam: #2b4a3f; }
.fam-md { --fam: #3f4a2b; } .fam-nm { --fam: #24493a; } .fam-hal { --fam: #4f4a22; } .fam-ng { --fam: #2f3358; }
.fam-ln { --fam: #4a2f4a; } .fam-an { --fam: #57303d; } .fam-sh { --fam: #3a3a3e; }
#plegend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 12px; font-size: 11.5px; color: var(--bone-dim); }
#plegend span { display: inline-flex; align-items: center; gap: 5px; }
#plegend span::before { content: ''; width: 9px; height: 9px; border-radius: 2px; background: var(--fam); }
/* locked: the symbol dimmed; ready to research in the Lab: a dashed brass border */
.pcell.locked { background: rgba(20, 32, 32, 0.92); color: rgba(169, 165, 147, 0.42); }
.pcell.locked i { color: rgba(169, 165, 147, 0.32); }
.pcell.locked::after { opacity: 0; }
.pcell.locked:hover { transform: none; border-color: rgba(169, 165, 147, 0.25); }
.pcell.ready { border: 1px dashed rgba(214, 168, 79, 0.8); background: rgba(214, 168, 79, 0.1); color: var(--brass); }
.pcell.ready i { color: rgba(214, 168, 79, 0.6); }
.pcell.ready:hover { transform: scale(1.18); border-color: var(--brass); }
/* Try it: a faint star while an element's experiment waits, a gold one once it's done */
.pcell.trying::before, .pcell.tried::before { position: absolute; top: 1px; right: 2px; font: 400 clamp(6px, 0.55vw, 8px)/1 var(--f-ui); }
.pcell.trying::before { content: '☆'; color: rgba(214, 168, 79, 0.45); }
.pcell.tried::before { content: '★'; color: var(--brass); }
.pcell.tried:not(.on) { box-shadow: inset 0 0 0 1px rgba(214, 168, 79, 0.6); }
.plab .stars { color: var(--brass); font-weight: 600; }
.plab { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; font-size: 13px; color: var(--bone-dim); }
.plab b { color: var(--bone); }
.plab .pill { flex: 0 auto; padding: 6px 12px; font-size: 13px; }
.pill.lab { color: #9fe3cf; border-color: rgba(78, 154, 136, 0.5); background: rgba(78, 154, 136, 0.12); }
.pill.lab:hover { border-color: #9fe3cf; }
.plab-btns { display: flex; gap: 6px; flex: none; }
.pill.book { position: relative; flex: 0 auto; display: grid; place-items: center; padding: 5px 9px; color: var(--brass); border-color: var(--brass-dim); background: rgba(214, 168, 79, 0.1); }
.pill.book:hover { border-color: var(--brass); }
.pill.book.locked { color: var(--bone-faint); border-color: rgba(78, 154, 136, 0.25); background: var(--patina-800); }
.book-lock { position: absolute; right: 2px; bottom: 2px; display: none; color: var(--bone-dim); }
.pill.book.locked .book-lock { display: block; }

/* ───────────── the table ───────────── */
#table { flex: 1; overflow-y: auto; padding: 6px 14px 14px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
.group-label {
  font: 600 11px/1 var(--f-ui); letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--bone-faint); margin: 14px 4px 7px;
  display: flex; align-items: center; gap: 8px;
}
.group-label::after { content: ''; flex: 1; height: 1px; background: rgba(78, 154, 136, 0.16); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; }

.tile {
  position: relative; aspect-ratio: 1 / 1.08;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 5px 6px 5px; border-radius: 5px;
  background: var(--patina-800);
  border: 1px solid rgba(78, 154, 136, 0.22);
  text-align: left; overflow: hidden;
  min-height: 64px; /* overflow:hidden drops aspect-ratio's automatic minimum; keep rows from collapsing */
  transition: transform 120ms ease, border-color 120ms ease;
}
#codex-grid .tile { min-height: 82px; }
.tile canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; opacity: 0.55;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 55%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 55%);
}
.tile .num { position: relative; font: 400 9.5px/1 var(--f-mono); color: var(--bone-faint); }
.tile .sym { position: relative; font: 700 21px/1 var(--f-ui); letter-spacing: -0.01em; color: var(--bone); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.tile .nm { position: relative; font: 600 10.5px/1.1 var(--f-ui); color: var(--bone); text-shadow: 0 1px 2px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover { border-color: var(--verdigris); transform: translateY(-1px); }
.tile.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 0 18px rgba(214, 168, 79, 0.28); }
.tile.on canvas { opacity: 0.8; }
.tile.new::after {
  content: ''; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--brass); box-shadow: 0 0 8px var(--brass);
}
/* the same dot on anything else with something new behind it: a button, a tab, a row in a menu */
.has-new { position: relative; }
.has-new::after {
  content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; pointer-events: none;
  background: #f4c542; box-shadow: 0 0 8px #f4c542, 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.tile.locked {
  background: transparent; border-style: dashed; border-color: rgba(78, 154, 136, 0.22); cursor: help;
}
.tile.locked .sym { color: var(--bone-faint); text-shadow: none; }
.tile.locked .nm { color: var(--bone-faint); text-shadow: none; }
.tile.locked.near { border-color: rgba(214, 168, 79, 0.4); }
.tile.locked.near .sym { color: rgba(214, 168, 79, 0.65); }
.tile.locked:hover { transform: none; }
.tile.strike { animation: strike 900ms ease-out; }
@keyframes strike {
  0% { box-shadow: 0 0 0 2px var(--brass), 0 0 40px rgba(214, 168, 79, 0.8); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.flyer {
  position: fixed; z-index: 50; width: 56px; height: 60px; pointer-events: none;
  border-radius: 6px; border: 1px solid var(--brass);
  background: var(--patina-700);
  box-shadow: 0 0 30px rgba(214, 168, 79, 0.55);
  display: grid; place-items: center;
  font: 700 22px/1 var(--f-ui); color: var(--bone);
}

/* ───────────── panel footer ───────────── */
.panel-foot { border-top: 1px solid rgba(78, 154, 136, 0.16); padding: 10px 14px 14px; display: grid; gap: 10px; }
#inspect { min-height: 54px; font-size: 13px; color: var(--bone-dim); display: grid; gap: 2px; }
#inspect .title { display: flex; align-items: baseline; gap: 8px; }
#inspect .title strong { font: 600 16px/1.1 var(--f-ui); color: var(--bone); }
#inspect .title .meta { font: 400 11px/1 var(--f-mono); color: var(--bone-faint); }
#inspect .story { font-size: 12px; color: var(--bone-faint); font-style: italic; }
#inspect .try { font-size: 12px; color: var(--bone-dim); }
#inspect .try.done { color: var(--brass); }
#inspect .try .progress { color: #9fe3cf; font-style: normal; font-family: var(--f-mono); font-size: 11px; }
.foot-btns { display: flex; gap: 6px; }
.foot-btns .pill { padding: 8px 6px; }
.pill {
  flex: 1; padding: 8px 12px; border-radius: 7px;
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.25);
  font-weight: 600; font-size: 14px;
}
.pill:hover { border-color: var(--verdigris); }
#btn-help, #btn-achieve { flex: 0 0 40px; }
#btn-achieve { display: grid; place-items: center; color: var(--brass); }
.pill.primary { background: var(--brass); color: #1b1408; border-color: var(--brass); }
.pill.primary:hover { filter: brightness(1.08); }
.pill.danger { flex: 0 auto; color: #f0a08a; border-color: rgba(240, 120, 90, 0.3); background: transparent; }

/* ───────────── search ───────────── */
.search { position: relative; margin: 10px 14px 0; }
.search input {
  width: 100%; padding: 8px 32px; border-radius: 7px;
  background: var(--patina-900); border: 1px solid rgba(78, 154, 136, 0.3); color: var(--bone); font: 500 14px/1.2 var(--f-ui);
}
.search input::placeholder { color: var(--bone-faint); }
.search input:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass-dim); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--bone-faint); pointer-events: none; }
.search-clear { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); background: none; border: 0; font-size: 20px; line-height: 1; color: var(--bone-dim); padding: 3px 8px; }
.search-clear:hover { color: var(--bone); }
#search-results { flex: 1; overflow-y: auto; padding: 0 14px 14px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
#search-results[hidden], #panel.searching #table, #panel.searching #ptable, #panel.searching #weapons { display: none; }
#panel.searching .tabs button[aria-selected="true"] { color: var(--bone-faint); border-bottom-color: transparent; } /* the results stand in for the tab */
.sr-count { order: 2; font: 400 11px/1 var(--f-mono); letter-spacing: 0; color: var(--bone-faint); }
.sr-list { display: grid; gap: 4px; }
.sr {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%;
  text-align: left; padding: 6px 8px; border-radius: 7px; background: var(--patina-800); border: 1px solid transparent;
}
.sr:hover { border-color: var(--verdigris); }
.sr.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass-dim); }
.sr-tile { position: relative; width: 40px; height: 40px; border-radius: 5px; display: grid; place-items: center; overflow: hidden; background: var(--fam, var(--patina-900)); color: var(--bone); }
.sr-tile i { position: absolute; top: 3px; left: 4px; font: 400 9px/1 var(--f-mono); font-style: normal; color: rgba(236, 229, 211, 0.6); }
.sr-tile b { position: relative; font: 700 16px/1 var(--f-ui); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.sr-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0.6; }
.sr-tile .glyph { font-size: 16px; }
.sr.locked .sr-tile { filter: grayscale(0.7) brightness(0.65); }
.sr.locked .sr-name { color: var(--bone-dim); }
.sr-text { min-width: 0; display: grid; gap: 2px; }
.sr-name { font: 600 14px/1.2 var(--f-ui); color: var(--bone); }
.sr-name small { font: 400 11px/1 var(--f-mono); color: var(--bone-faint); margin-left: 6px; }
.sr-snip { font-size: 12.5px; line-height: 1.35; color: var(--bone-dim); overflow-wrap: anywhere; }
.sr.big .sr-snip { font-size: 13px; }
.sr-snip mark { background: rgba(214, 168, 79, 0.25); color: var(--bone); border-radius: 2px; padding: 0 1px; }
.sr-badge { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.12em; text-transform: uppercase; color: var(--bone-faint); white-space: nowrap; }
.sr-badge.ready { color: var(--brass); }
.sr-badge.star { color: var(--brass); font-size: 14px; letter-spacing: 0; }
.sr-empty { color: var(--bone-dim); font-size: 14px; margin: 14px 2px; }
.sr-fuzzy { color: var(--bone-faint); font-size: 12.5px; margin: 10px 2px 0; }

/* ───────────── colours for glass and fire ───────────── */
.tile .tint-badge {
  position: absolute; right: 5px; bottom: 5px; z-index: 1; width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  background: conic-gradient(#ff3a30, #ffb020, #6aff4a, #3affb0, #4a7aff, #b46aff, #ff3a30);
  box-shadow: 0 0 0 2px rgba(5, 10, 12, 0.85);
}
.tile .tint-badge.set { background: var(--c); box-shadow: 0 0 0 2px rgba(5, 10, 12, 0.85), 0 0 8px var(--c); }
.tile .tint-badge.none { background: transparent; border: 1.5px dashed rgba(236, 229, 211, 0.55); box-shadow: none; }
.tile .tint-badge:hover, .tile .tint-badge:focus-visible { transform: scale(1.2); outline: none; box-shadow: 0 0 0 2px var(--brass); }
.tint-menu {
  position: fixed; z-index: 60; width: min(360px, calc(100vw - 16px)); max-height: min(440px, calc(100dvh - 16px)); overflow: auto;
  padding: 12px; border-radius: 10px; background: var(--patina-900); border: 1px solid var(--brass-dim); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  display: grid; gap: 10px;
}
.tint-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tint-head b { font: 20px/1 var(--f-display); color: var(--brass); font-weight: 400; }
.tint-head span { font: 400 11px/1 var(--f-mono); color: var(--bone-faint); }
.tint-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.tint-opt {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px;
  background: var(--patina-800); border: 1px solid transparent; text-align: left; font-size: 13px; color: var(--bone);
}
.tint-opt:hover, .tint-opt:focus-visible { border-color: var(--verdigris); outline: none; }
.tint-opt.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass-dim); }
.tint-opt small { font: 400 10px/1 var(--f-mono); color: var(--bone-faint); }
.tint-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.tint-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c, transparent); box-shadow: 0 0 6px var(--c, transparent), inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.tint-opt:first-child .tint-dot { background: transparent; border: 1.5px solid var(--bone-faint); box-shadow: none; }
.tint-opt.locked { color: var(--bone-faint); }
.tint-opt.locked .tint-dot { background: transparent; border: 1.5px dashed rgba(236, 229, 211, 0.3); box-shadow: none; }
/* rainbow fire: every fire colour in turn */
.tint-opt.rainbow { grid-column: 1 / -1; }
.tint-opt.rainbow:not(.locked) .tint-dot, .tile .tint-badge.rainbow {
  background: conic-gradient(#ff4d4d, #ffb84d, #f4ff4d, #5dff6a, #4dd8ff, #6a5dff, #e04dff, #ff4d4d);
  box-shadow: 0 0 8px rgba(255, 200, 120, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  animation: rainbow-spin 4s linear infinite;
}
@keyframes rainbow-spin { to { filter: hue-rotate(360deg); } }
.tint-note { margin: 0; font-size: 12px; color: var(--bone-faint); }
/* any colour (Concrete, Paint): a row of chips, and the full colour picker */
.tint-grid.swatches { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tint-grid.swatches .tint-opt { grid-column: span 2; grid-template-columns: 18px minmax(0, 1fr); }
.tint-chip {
  aspect-ratio: 1; min-height: 28px; border-radius: 6px; background: var(--c); cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.tint-chip:hover, .tint-chip:focus-visible { outline: 2px solid var(--verdigris); outline-offset: 1px; }
.tint-chip.on { outline: 2px solid var(--brass); outline-offset: 1px; }
.tint-any { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--bone); cursor: pointer; }
.tint-any input { width: 40px; height: 28px; padding: 0; border: 1px solid var(--brass-dim); border-radius: 6px; background: none; cursor: pointer; }

/* ───────────── modals ───────────── */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(4, 8, 9, 0.68); backdrop-filter: blur(3px);
  animation: fade 200ms ease both;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: linear-gradient(180deg, var(--patina-800), var(--patina-900));
  border: 1px solid var(--brass-dim); border-radius: 12px;
  padding: 24px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-card.wide { width: min(980px, 100%); padding: 0; display: flex; flex-direction: column; }
.modal-card h2 { margin: 0 0 10px; font: 36px/1 var(--f-display); color: var(--brass); }
.lede { color: var(--bone-dim); font-size: 16px; line-height: 1.45; margin: 0 0 14px; }
.lede.small { font-size: 14px; }
.lede strong { color: var(--bone); }
.keys { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 7px; font-size: 14.5px; color: var(--bone-dim); }
kbd {
  font: 500 12px/1 var(--f-mono); color: var(--bone);
  padding: 3px 6px; border-radius: 4px; border: 1px solid rgba(236, 229, 211, 0.18); background: rgba(0, 0, 0, 0.25);
}
.modal-card > .pill { width: 100%; padding: 11px; font-size: 16px; }

.modal-card.wide > header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-card.wide > header h2 { margin: 0; }
.close { background: none; border: 0; font-size: 28px; line-height: 1; color: var(--bone-dim); padding: 4px 8px; }
.close:hover { color: var(--bone); }
.codex-body { display: grid; grid-template-columns: 1fr 300px; gap: 0; min-height: 0; flex: 1; overflow: hidden; }
#codex-grid { overflow: auto; padding: 4px 22px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 7px; align-content: start; }
#codex-grid .tile { cursor: pointer; }
#codex-grid .group-label { grid-column: 1 / -1; margin: 12px 0 0; }
#codex-grid .group-label:first-child { margin-top: 4px; }
#codex-grid .codex-count { margin-left: auto; font: 500 11px/1 var(--f-mono); letter-spacing: 0; text-transform: none; color: var(--brass-dim); }
#codex-detail .pill { margin-top: 2px; }
.hint-pop .hp-chip.missing { border-style: dashed; opacity: 0.7; }
.hint-pop .hp-title canvas { width: 22px; height: 22px; border-radius: 4px; image-rendering: pixelated; }
#codex-detail { border-left: 1px solid rgba(78, 154, 136, 0.18); padding: 6px 22px 22px; overflow: auto; }
#codex-detail canvas { width: 100%; height: 90px; border-radius: 8px; image-rendering: pixelated; margin-bottom: 14px; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
#codex-detail h3 { margin: 0 0 4px; font: 30px/1.05 var(--f-display); color: var(--bone); }
#codex-detail .kind { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-bottom: 12px; }
#codex-detail p { color: var(--bone-dim); margin: 0 0 12px; font-size: 15px; }
#codex-detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; }
#codex-detail dt { color: var(--bone-faint); }
#codex-detail dd { margin: 0; color: var(--bone); }
.codex-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px; border-top: 1px solid rgba(78, 154, 136, 0.18); flex-wrap: wrap; }

/* ───────────── the weapons ───────────── */
#weapons { flex: 1; overflow-y: auto; padding: 6px 14px 14px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
#weapons[hidden] { display: none; }
.weapons { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 6px; }
.weapon {
  display: grid; grid-template-columns: 24px 1fr; align-items: center; column-gap: 9px; row-gap: 2px;
  padding: 8px 9px; border-radius: var(--r); text-align: left;
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.22);
  transition: transform 120ms ease, border-color 120ms ease;
}
.weapon svg { grid-row: span 2; color: var(--wc); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--wc) 45%, transparent)); }
.weapon b { font: 600 14px/1.1 var(--f-ui); color: var(--bone); }
.weapon small { font: 400 11.5px/1.2 var(--f-ui); color: var(--bone-faint); }
.weapon:hover { border-color: var(--verdigris); transform: translateY(-1px); }
.weapon.on { border-color: var(--brass); background: rgba(214, 168, 79, 0.08); box-shadow: 0 0 0 1px var(--brass), 0 0 18px rgba(214, 168, 79, 0.22); }
.weapons-note { margin: 14px 4px 0; font-size: 12px; line-height: 1.45; color: var(--bone-faint); }
.magnitude {
  display: grid; grid-template-columns: auto 1fr 62px; align-items: center; gap: 6px 10px;
  margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--r);
  background: rgba(210, 160, 98, 0.07); border: 1px solid rgba(210, 160, 98, 0.38);
  font-size: 13px; color: var(--bone-dim);
}
.magnitude[hidden] { display: none; }
.magnitude label { font-weight: 600; color: #d2a062; }
.magnitude input[type=range] { accent-color: #d2a062; }
.magnitude input[type=number] {
  width: 100%; padding: 4px 6px; border-radius: 4px; text-align: right;
  background: var(--patina-900); color: var(--bone); border: 1px solid rgba(210, 160, 98, 0.45);
  font: 500 14px/1 var(--f-mono);
}
.mag-note { grid-column: 1 / -1; font-size: 12px; color: var(--bone-faint); }
/* how new machines are set: a piston's or a pump's facing, a sensor's sense */
.machine-set { display: grid; gap: 6px; padding: 8px 10px; border-radius: var(--r); background: rgba(78, 154, 136, 0.08); border: 1px solid rgba(78, 154, 136, 0.3); font-size: 13px; color: var(--bone-dim); }
.machine-set[hidden], .machine-set [hidden] { display: none; }
.ms-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ms-lbl { font-weight: 600; color: #9fe3cf; min-width: 52px; }
.ms-btns { display: flex; gap: 4px; }
.ms-btns button { width: 32px; height: 28px; padding: 0; border-radius: 6px; background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.25); color: var(--bone-dim); font: 700 15px/1 var(--f-ui); }
.ms-btns button:hover { border-color: var(--verdigris); color: var(--bone); }
.ms-btns button[aria-checked="true"] { border-color: var(--brass); color: var(--brass); background: rgba(214, 168, 79, 0.12); }
.machine-set select, .machine-set input { background: var(--patina-900); border: 1px solid rgba(78, 154, 136, 0.3); color: var(--bone); border-radius: 6px; padding: 4px 6px; font: 500 13px/1.2 var(--f-ui); }
.machine-set input { width: 70px; }
.ms-unit { color: var(--bone-faint); }
.ms-note { font-size: 12px; color: var(--bone-faint); }
.ms-toggle { margin-left: auto; height: 28px; padding: 0 12px; border-radius: 6px; background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.25); color: var(--bone-dim); font: 600 13px/1 var(--f-ui); }
.ms-toggle:hover { border-color: var(--verdigris); color: var(--bone); }
.ms-toggle[aria-pressed="true"] { border-color: var(--brass); color: var(--brass); background: rgba(214, 168, 79, 0.12); }
.mag-note b { color: var(--bone); text-transform: capitalize; }
.weapons-note kbd { font: 500 11px/1 var(--f-mono); color: var(--bone-dim); }

/* ───────────── the journey: story mode ───────────── */
.pill.journey { color: var(--brass); border-color: var(--brass-dim); background: rgba(214, 168, 79, 0.08); }
.pill.journey:hover { border-color: var(--brass); }
.welcome-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.welcome-btns .pill { padding: 11px; font-size: 16px; }
.welcome-note { margin: 12px 0 0; }

/* while a chapter runs, the lab's own controls step aside */
body.questing .lab-only,
body.questing .tools .tool-row,
body.questing .tools .check,
body.questing .tabs,
body.questing #table,
body.questing #ptable,
body.questing #weapons { display: none !important; }
body.questing #readout { left: auto; right: 14px; }
/* story messages stack under the goals card, clear of it on any width */
body.questing #toasts {
  left: 14px; transform: none; top: calc(var(--quest-h, 150px) + 22px);
  align-items: flex-start; width: min(400px, calc(100% - 28px));
}

/* the goals card over the map */
#quest {
  position: absolute; left: 14px; top: 12px; z-index: 2; width: 272px;
  padding: 12px 14px 12px;
  background: rgba(11, 22, 23, 0.88);
  border: 1px solid var(--brass-dim); border-radius: 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
#quest[hidden] { display: none; }
.q-min {
  margin-left: auto; align-self: flex-start; flex: none;
  width: 26px; height: 26px; border-radius: 6px; padding: 0;
  background: transparent; border: 1px solid rgba(78, 154, 136, 0.25);
  color: var(--bone-dim); font: 600 16px/1 var(--f-mono);
}
.q-min:hover { color: var(--bone); border-color: var(--verdigris); }
.q-mini { display: none; font: 500 12px/1.3 var(--f-mono); color: var(--brass); margin-top: 3px; }
/* minimized: the card folds into one small round button */
#quest.min { width: auto; padding: 0; border-radius: 50%; background: rgba(11, 22, 23, 0.92); }
#quest.min .q-goals, #quest.min .q-btns, #quest.min .q-num, #quest.min header > div { display: none; }
#quest.min header { margin: 0; }
#quest.min .q-min {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  color: var(--brass); font-size: 22px; margin: 0;
}
/* the title bar is the handle for dragging the card around the map */
#quest:not(.min) header { cursor: grab; user-select: none; touch-action: none; }
#quest.dragging header { cursor: grabbing; }
#quest header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.q-num { font: 34px/1 var(--f-display); color: var(--brass); min-width: 28px; text-align: center; text-shadow: 0 0 14px rgba(214, 168, 79, 0.3); }
.q-place { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); }
.q-title { font: 23px/1.05 var(--f-display); color: var(--bone); margin-top: 3px; }
.q-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.q-goals li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 2px 8px; font-size: 13.5px; color: var(--bone-dim); }
.q-goals .mark { width: 9px; height: 9px; border-radius: 50%; justify-self: center; border: 1.5px solid var(--verdigris); }
.q-goals .val { font: 500 11.5px/1 var(--f-mono); color: var(--bone); white-space: nowrap; }
.q-goals .meter { grid-column: 2 / 4; height: 4px; border-radius: 2px; background: rgba(78, 154, 136, 0.18); overflow: hidden; }
.q-goals .meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--verdigris), var(--brass)); transition: width 400ms ease; }
.q-goals li.main { color: var(--bone); font-weight: 600; }
.q-goals li.main .mark { border-color: var(--brass); }
.q-goals li.keep .mark { background: var(--verdigris); border-color: var(--verdigris); }
.q-goals li.main.met .mark { background: var(--brass); border-color: var(--brass); }
.q-goals li.keep.lost { color: var(--bone-faint); }
.q-goals li.keep.lost .text { text-decoration: line-through; text-decoration-color: rgba(255, 122, 61, 0.6); }
.q-goals li.keep.lost .mark { background: transparent; border-color: var(--ember); }
.q-goals li.keep.lost .val { color: var(--ember); }
.q-btns { display: flex; gap: 4px; margin-top: 12px; }
.q-btns button {
  flex: 1; padding: 6px 4px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--bone-dim);
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.22);
}
.q-btns button:hover { color: var(--bone); border-color: var(--verdigris); }
#q-hint { color: var(--brass); border-color: var(--brass-dim); }

/* the pouch, in place of the element table */
#pouch { flex: 1; overflow-y: auto; padding: 6px 14px 14px; min-height: 0; }
#pouch[hidden] { display: none; }
.pouch-grid { display: grid; gap: 6px; }
.ptile {
  position: relative; display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 12px;
  padding: 8px 10px 12px; border-radius: 7px; text-align: left;
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.22);
  transition: border-color 120ms ease;
}
.ptile:hover { border-color: var(--verdigris); }
.ptile.on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 0 18px rgba(214, 168, 79, 0.22); }
.ptile canvas { width: 40px; height: 40px; border-radius: 5px; image-rendering: pixelated; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.pglyph { width: 40px; height: 40px; border-radius: 5px; display: grid; place-items: center; font-size: 18px; background: var(--patina-700); color: var(--bone-dim); }
.pglyph.heat { color: var(--ember); }
.pglyph.cool { color: var(--frost); }
.pglyph.magnet { color: #d08cff; font-weight: 700; }
.pglyph.smash { color: #e0b070; }
/* a chapter's guide (Hint): the page dims but for where to act and what to use, with a note beside them */
.guide { position: fixed; inset: 0; z-index: 70; }
.guide-dim { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.guide-dim .shade { fill: rgba(3, 7, 9, 0.74); }
.guide-dim .ring { fill: none; stroke: var(--brass); stroke-width: 2; filter: drop-shadow(0 0 7px rgba(214, 168, 79, 0.75)); animation: guide-ring 1.8s ease-in-out infinite; }
@keyframes guide-ring { 50% { stroke: #f3d48c; } }
@media (prefers-reduced-motion: reduce) { .guide-dim .ring { animation: none; } }
.guide .guide-tip { position: absolute; }
.guide-recipe { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.guide-recipe .chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 6px;
  background: rgba(214, 168, 79, 0.1); border: 1px solid var(--brass-dim); font: 600 13px/1 var(--f-ui); color: var(--bone);
}
.guide-recipe .chip canvas { width: 16px; height: 16px; border-radius: 3px; }
.guide-recipe .chip .glyph { width: 16px; text-align: center; font-size: 12px; }
.guide-recipe .op { color: var(--brass); font: 700 15px/1 var(--f-ui); }
.ptile.guide-on { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 0 18px rgba(214, 168, 79, 0.45); }
/* a chapter playing its own scene: the pouch rests */
body.cutscene #pouch { opacity: 0.35; pointer-events: none; transition: opacity 600ms ease; }
.ptxt { display: grid; gap: 3px; min-width: 0; }
.pname { font: 600 16px/1.1 var(--f-ui); color: var(--bone); }
.pleft { font: 500 12px/1 var(--f-mono); color: var(--bone-dim); }
.pbar { position: absolute; left: 10px; right: 10px; bottom: 5px; height: 3px; border-radius: 2px; background: rgba(78, 154, 136, 0.16); overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--verdigris), var(--brass)); transition: width 200ms ease; }
.ptile.empty { opacity: 0.5; }
.ptile.empty .pleft { color: var(--ember); }
.pouch-note { margin: 12px 2px 0; font-size: 13px; line-height: 1.45; color: var(--bone-faint); }

/* the journey map */
.journey-card { width: min(760px, 100%); }
.journey-card > header .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); margin-bottom: 6px; }
.chapters { list-style: none; margin: 0; padding: 6px 22px 8px; display: grid; gap: 6px; overflow: auto; }
.chapter button {
  width: 100%; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px;
  padding: 12px 16px 12px 10px; border-radius: 9px; text-align: left;
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.22);
}
.chapter button:not(:disabled):hover { border-color: var(--brass); background: var(--patina-700); }
.chapter .num { font: 34px/1 var(--f-display); color: var(--brass); text-align: center; white-space: nowrap; }
.chapter .num[data-long] { font-size: 25px; letter-spacing: -0.03em; }
.chapter .txt { display: grid; gap: 2px; min-width: 0; }
.chapter .place { font: 600 10.5px/1.2 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); }
.chapter .title { font: 24px/1.1 var(--f-display); color: var(--bone); }
.chapter .blurb { font-size: 13.5px; color: var(--bone-dim); }
.chapter .state { font: 600 13px/1 var(--f-ui); letter-spacing: 0.04em; color: var(--verdigris); white-space: nowrap; }
.chapter.done .state { color: var(--brass); font-size: 18px; letter-spacing: 0.08em; }
.chapter.current button { border-color: var(--brass-dim); }
.chapter.current .state { color: var(--brass); }
.chapter.sealed button, .chapter.locked button { background: transparent; border-style: dashed; cursor: default; }
.chapter.sealed .num, .chapter.locked .num { color: var(--bone-faint); }
.chapter.sealed .title, .chapter.locked .title { color: var(--bone-dim); }
.chapter.sealed .blurb, .chapter.locked .blurb { color: var(--bone-faint); }
.chapter.sealed .state, .chapter.locked .state { color: var(--bone-faint); font-weight: 500; }
.journey-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 22px 18px; flex-wrap: wrap; }
.journey-foot .pill { flex: 0 auto; }

/* a journal page: parchment and ink */
#journal { --ink: #2e2416; --ink-soft: #5b4a30; --ink-faint: #8a7552; --rule: rgba(90, 64, 26, 0.28); }
.page {
  width: min(600px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 34px 42px 28px; border-radius: 6px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 252, 240, 0.7), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(150, 110, 50, 0.18), transparent 55%),
    linear-gradient(180deg, #efe5cb, #e3d5b0);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(90, 64, 26, 0.25), inset 0 0 60px rgba(120, 85, 30, 0.18);
  font: 17px/1.6 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  animation: page-in 380ms cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes page-in { from { opacity: 0; transform: translateY(10px) rotate(-0.4deg); } }
.page-eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.page h2 { margin: 8px 0 14px; font: 42px/1 var(--f-display); color: var(--ink); }
.page-stars { font-size: 30px; letter-spacing: 0.12em; color: #a8761a; margin: -6px 0 10px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }
.page-stars[hidden] { display: none; }
.page-body p { margin: 0 0 12px; }
.page-body p.after, .page-body p.found { color: var(--ink-soft); font-style: italic; }
.page-body .letter {
  margin: 16px 0; padding: 4px 0 4px 20px; border-left: 2px solid rgba(140, 100, 40, 0.5);
  font-style: italic; color: #3a2d1a;
}
.page-body .letter p { margin: 0 0 8px; }
.page-body .letter .sign { text-align: right; font-style: normal; margin-top: 6px; }
.page-body .label { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.page-body .task { margin: 18px 0 12px; padding: 12px 14px; border-radius: 6px; background: rgba(120, 85, 30, 0.1); border: 1px solid var(--rule); }
.page-body .task p { margin: 0; color: var(--ink); }
.page-body .task.part { background: rgba(40, 90, 110, 0.08); }
.pouch-preview .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pouch-preview .chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px; border-radius: 99px;
  background: rgba(46, 36, 22, 0.08); border: 1px solid var(--rule); font: 600 13.5px/1 var(--f-ui); color: var(--ink);
}
.pouch-preview .chip canvas { width: 16px; height: 16px; border-radius: 50%; image-rendering: pixelated; }
.pouch-preview .chip .glyph { width: 16px; text-align: center; font-size: 11px; color: var(--ink-soft); }
.pouch-preview .chip .glyph.heat { color: #b8461e; }
.pouch-preview .chip .n { font: 500 12px/1 var(--f-mono); color: var(--ink-faint); }
.page-goals { list-style: none; margin: 4px 0 14px; padding: 0; display: grid; gap: 4px; font: 500 15px/1.3 var(--f-ui); }
.page-goals li { display: flex; gap: 10px; align-items: baseline; }
.page-goals li::before { content: '✓'; width: 14px; color: #3f7d4f; font-weight: 700; }
.page-goals li.lost { color: var(--ink-faint); }
.page-goals li.lost::before { content: '✕'; color: #a8461e; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); }
.page-actions .pill { flex: 0 auto; padding: 10px 18px; background: transparent; color: var(--ink); border-color: rgba(60, 40, 15, 0.35); }
.page-actions .pill:hover { border-color: var(--ink); background: rgba(60, 40, 15, 0.06); }
.page-actions .pill.primary { background: var(--ink); color: #f1e8d0; border-color: var(--ink); }
.page-actions .pill.primary:hover { filter: none; background: #45361f; }

/* ───────────── the Lab ───────────── */
.modal-card.lab-card { width: min(1060px, 100%); }
.lab-card > header .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--verdigris); margin-bottom: 6px; }
.lab-card .lbl { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); margin-bottom: 5px; }
.lab-card .pill:disabled { opacity: 0.4; cursor: default; border-color: rgba(78, 154, 136, 0.25); filter: none; }
.lab-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 22px 16px; }
.lab-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 22px 16px; border-top: 1px solid rgba(78, 154, 136, 0.18); flex-wrap: wrap; font-size: 13px; color: var(--bone-faint); }
.lab-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-actions .pill { flex: 0 auto; padding: 9px 16px; }

.lab-bench { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.lab-left { display: grid; gap: 10px; }
.sample-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(78, 154, 136, 0.2); }
.sample-card canvas { width: 40px; height: 40px; border-radius: 6px; image-rendering: pixelated; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); flex: none; }
.sample-card .what { flex: 1; min-width: 0; }
.sample-card .desc { font: 22px/1.05 var(--f-display); color: var(--bone); }
.tests-left { display: flex; align-items: center; gap: 5px; }
.tests-left .lbl { margin: 0 3px 0 0; }
.tests-left i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--brass-dim); }
.tests-left i.on { background: var(--brass); border-color: var(--brass); }
.tube-wrap { position: relative; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: #070a0c; box-shadow: inset 0 0 0 1px rgba(78, 154, 136, 0.22); }
.tube-wrap canvas.tube { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tube-reading { position: absolute; left: 9px; bottom: 8px; padding: 3px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.55); font: 500 12px/1 var(--f-mono); color: var(--bone); }
.tube-reading:empty { display: none; }
.tube-idle { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--bone-dim); pointer-events: none; }
.test-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.test {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border-radius: 7px;
  background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.3); font-size: 12px; font-weight: 600;
}
.test:hover:not(:disabled) { border-color: var(--brass); color: var(--brass); }
.test:disabled { cursor: default; opacity: 0.38; }
.test.done { opacity: 1; background: rgba(214, 168, 79, 0.1); border-color: var(--brass-dim); color: var(--brass); }
.test.running { box-shadow: 0 0 0 1px var(--brass), 0 0 12px rgba(214, 168, 79, 0.4); }
.lab-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.lab-log li { padding: 8px 10px; border-left: 2px solid var(--brass-dim); background: rgba(0, 0, 0, 0.14); border-radius: 0 6px 6px 0; animation: fade 300ms ease both; }
.lab-log li b { color: var(--brass); }
.lab-log .why { display: block; margin-top: 3px; font-size: 12.5px; color: var(--bone-dim); font-style: italic; }
.lab-log li.empty { border-left-color: rgba(78, 154, 136, 0.3); color: var(--bone-dim); font-size: 13px; }

.lab-right .group-label { margin-top: 2px; }
.handbook-wrap { overflow-x: auto; }
.handbook { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.handbook th, .handbook td { padding: 6px 8px; text-align: left; vertical-align: middle; border-bottom: 1px solid rgba(78, 154, 136, 0.12); }
.handbook tbody th { white-space: nowrap; color: var(--bone-dim); font-weight: 600; }
.handbook tbody th svg { vertical-align: -3px; margin-right: 6px; color: var(--bone-faint); }
.handbook tr.ran th, .handbook tr.ran th svg { color: var(--brass); }
.handbook tr.splits th::after { content: ' ◆'; color: #9fe3cf; font-size: 10px; }
.handbook td.samp { background: rgba(214, 168, 79, 0.07); color: var(--brass); font: 500 12px/1.25 var(--f-mono); }
.handbook th.samp { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); vertical-align: bottom; background: rgba(214, 168, 79, 0.07); }
.handbook th.cand { padding: 0 3px 6px; vertical-align: bottom; min-width: 96px; }
.handbook th.cand button { width: 100%; display: grid; gap: 2px; text-align: left; padding: 6px 8px; border-radius: 6px; background: var(--fam); border: 1px solid transparent; }
.handbook th.cand button:hover { border-color: var(--bone-dim); }
.handbook th.cand .sym { font: 700 20px/1 var(--f-ui); }
.handbook th.cand .nm { font-size: 13px; font-weight: 600; }
.handbook th.cand .fm { font-size: 11px; color: rgba(236, 229, 211, 0.6); font-weight: 500; }
.handbook th.cand.struck button { opacity: 0.35; text-decoration: line-through; }
.handbook td.struck { opacity: 0.3; text-decoration: line-through; }
.handbook tfoot td { border-bottom: 0; padding: 10px 3px 0; }
.handbook .pill.guess { width: 100%; padding: 7px 4px; font-size: 13px; }
.hb-note { margin: 10px 0 0; font-size: 12.5px; color: var(--bone-faint); }

.lab-fact { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 6px; }
.big-tile {
  position: relative; aspect-ratio: 1 / 1.12; border-radius: 10px; background: var(--fam);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px var(--brass-dim), 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: tile-in 520ms cubic-bezier(.2, .9, .3, 1.3) both;
}
.big-tile i { font: 400 15px/1 var(--f-mono); font-style: normal; color: rgba(236, 229, 211, 0.6); }
.big-tile b { font: 700 58px/1 var(--f-ui); color: var(--bone); margin: 4px 0; }
.big-tile span { font-size: 14px; font-weight: 600; color: var(--bone); }
.big-tile::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 9px; height: 4px; border-radius: 2px; background: var(--swatch); }
@keyframes tile-in { from { opacity: 0; transform: scale(0.6) rotate(-6deg); } }
.fact-text dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: 14.5px; }
.fact-text dt { color: var(--bone-faint); }
.fact-text dd { margin: 0; color: var(--bone); }
.try-note { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: rgba(78, 154, 136, 0.1); border: 1px solid rgba(78, 154, 136, 0.4); }
.try-note .lbl { color: #9fe3cf; }
.try-note p { margin: 0; font-size: 14px; color: var(--bone); }
.try-note p.needs { margin-top: 6px; font-size: 13px; color: var(--bone-dim); }
.family-note { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: rgba(214, 168, 79, 0.08); border: 1px solid var(--brass-dim); }
.family-note .lbl { color: var(--brass); }
.family-note p { margin: 0; font-size: 14px; color: var(--bone); }
.sharp { margin: 14px 0 0; font-size: 13.5px; color: var(--bone-dim); font-style: italic; }
.lab-wrong, .lab-wait { max-width: 620px; padding: 6px 0; }
.lab-wrong p, .lab-wait p { color: var(--bone-dim); font-size: 15px; margin: 0 0 12px; }
.lab-wrong ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; font-size: 14px; color: var(--bone-dim); }
.lab-wrong li svg { vertical-align: -3px; margin-right: 6px; color: var(--bone-faint); }
.lab-wrong li b { color: var(--bone); margin-right: 6px; }
.lab-wrong li.ran svg, .lab-wrong li.ran b { color: var(--brass); }
.lab-wrong p.lab-count, .lab-wait p.lab-count { font-family: var(--f-mono); font-size: 13px; color: var(--bone); }
/* the wait for a fresh sample: a flask bubbling on the bench, and a bar filling up */
.lab-timer {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  max-width: 460px; padding: 12px 16px 12px 12px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(24, 52, 51, 0.7), rgba(14, 28, 28, 0.7));
  border: 1px solid rgba(78, 154, 136, 0.3); box-shadow: inset 0 1px 0 rgba(236, 229, 211, 0.05);
}
.lt-flask { display: block; overflow: visible; }
.lt-glass { fill: none; stroke: var(--bone-dim); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lt-liquid { fill: var(--verdigris); opacity: 0.85; transform-origin: 50% 100%; animation: lt-slosh 1.6s ease-in-out infinite; }
.lt-b { fill: #c9f0e4; opacity: 0; animation: lt-rise 1.4s ease-in infinite; }
.lt-b.b2 { animation-delay: 0.45s; }
.lt-b.b3 { animation-delay: 0.9s; }
@keyframes lt-rise { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: 0.9; } 100% { opacity: 0; transform: translateY(-26px); } }
@keyframes lt-slosh { 50% { transform: scaleY(0.92); } }
.lt-text { display: grid; gap: 4px; min-width: 0; }
.lt-label { font: 21px/1.1 var(--f-display); color: var(--bone); }
.lt-sub { font-size: 13px; color: var(--bone-faint); }
.lt-bar { height: 6px; margin-top: 4px; border-radius: 3px; background: rgba(78, 154, 136, 0.16); overflow: hidden; }
.lt-fill { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--verdigris), #9fe3cf); box-shadow: 0 0 10px rgba(159, 227, 207, 0.5); transition: width 0.25s linear; }
.lt-left {
  min-width: 52px; padding: 7px 10px; border-radius: 8px; text-align: center;
  font: 600 20px/1 var(--f-ui); color: var(--brass); background: rgba(214, 168, 79, 0.1); border: 1px solid var(--brass-dim);
  font-variant-numeric: tabular-nums;
}
.lab-timer.ready { border-color: var(--brass-dim); }
.lab-timer.ready .lt-liquid { fill: var(--brass); animation: none; }
.lab-timer.ready .lt-b { display: none; }
.lab-timer.ready .lt-fill { background: linear-gradient(90deg, var(--brass), #f3d48c); box-shadow: 0 0 10px rgba(214, 168, 79, 0.55); }
.lab-wrong .lab-timer { margin-top: 4px; }
/* the tour, the first time the Lab opens: the page dims, one part of the bench lights up, a note beside it */
.lab-head-btns { display: flex; align-items: center; gap: 6px; }
.lab-help {
  width: 30px; height: 30px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--brass-dim); color: var(--brass); font: 700 15px/1 var(--f-ui);
}
.lab-help:hover { background: rgba(214, 168, 79, 0.12); border-color: var(--brass); }
.tour-hole {
  position: fixed; z-index: 70; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(3, 7, 9, 0.72), 0 0 0 2px var(--brass), 0 0 22px 2px rgba(214, 168, 79, 0.55);
  transition: left 260ms cubic-bezier(.2, .9, .3, 1), top 260ms cubic-bezier(.2, .9, .3, 1), width 260ms cubic-bezier(.2, .9, .3, 1), height 260ms cubic-bezier(.2, .9, .3, 1), opacity 160ms;
  animation: tour-glow 1.8s ease-in-out infinite;
}
@keyframes tour-glow { 50% { box-shadow: 0 0 0 200vmax rgba(3, 7, 9, 0.72), 0 0 0 2px #f3d48c, 0 0 32px 6px rgba(214, 168, 79, 0.7); } }
.tour-tip {
  position: fixed; z-index: 71; width: min(330px, calc(100vw - 16px)); display: grid; gap: 8px; padding: 14px 16px 12px;
  background: linear-gradient(180deg, var(--patina-700), var(--patina-800)); border: 1px solid var(--brass); border-radius: 10px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6); transition: left 260ms cubic-bezier(.2, .9, .3, 1), top 260ms cubic-bezier(.2, .9, .3, 1), opacity 160ms;
}
.tour-tip .tt-head { display: grid; gap: 3px; }
.tour-tip .tt-step { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }
.tour-tip b { font: 22px/1.1 var(--f-display); font-weight: 400; color: var(--bone); }
.tour-tip p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--bone-dim); }
.tt-btns { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.tt-btns .pill { flex: 0 auto; padding: 7px 14px; }
.tt-skip { background: none; border: 0; padding: 4px 0; font-size: 13px; color: var(--bone-faint); text-decoration: underline; text-underline-offset: 3px; }
.tt-skip:hover { color: var(--bone); }
.tt-wait { font-size: 13px; font-weight: 600; color: #9fe3cf; animation: tt-pulse 1.4s ease-in-out infinite; }
@keyframes tt-pulse { 50% { opacity: 0.55; } }
@media (max-width: 640px) {
  .lab-timer { grid-template-columns: auto minmax(0, 1fr); }
  .lt-left { grid-column: 2; justify-self: start; }
}

@media (max-width: 820px) {
  .lab-bench, .lab-fact { grid-template-columns: 1fr; }
  .big-tile { width: 120px; }
  .lab-body { padding: 4px 14px 12px; }
}

/* ───────────── element groups ───────────── */
.modal-card.groups-card { width: min(1080px, 100%); position: relative; }
.to-top {
  position: absolute; right: 26px; bottom: 22px; z-index: 2; width: 42px; height: 42px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--patina-700); border: 1px solid var(--brass); color: var(--brass);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(214, 168, 79, 0.25);
  opacity: 0; transform: translateY(10px) scale(0.9); pointer-events: none; transition: opacity 180ms, transform 180ms;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--brass); color: #1b1408; }
.groups-card > header .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
/* the Info window: links to the about and legal pages */
.info-links { display: grid; gap: 6px; margin: 4px 0 14px; }
.info-links a {
  display: block; padding: 10px 12px; border-radius: 7px; background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.25);
  color: var(--bone); font: 600 15px/1.2 var(--f-ui); text-decoration: none;
}
.info-links a:hover { border-color: var(--brass); color: var(--brass); }
.welcome-btns.one { grid-template-columns: 1fr; }
/* the Info window's progress backup: download, restore (asking first), and whether the browser keeps it */
.backup { margin: 0 0 16px; padding-top: 14px; border-top: 1px solid rgba(78, 154, 136, 0.2); }
.backup h3 { margin: 0 0 6px; font: 24px/1.1 var(--f-display); color: var(--bone); }
.backup .lede { margin-bottom: 10px; }
.backup-keep { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--bone-faint); }
.backup-keep.kept { color: #9fe3cf; }
.restore-ask { margin-top: 10px; padding: 12px; border-radius: 8px; background: rgba(14, 28, 28, 0.6); border: 1px solid rgba(240, 120, 90, 0.35); display: grid; gap: 8px; }
.restore-ask[hidden] { display: none; }
.restore-ask.bad { border-color: rgba(78, 154, 136, 0.3); }
.restore-ask b { color: var(--bone); font: 600 15px/1.3 var(--f-ui); }
.restore-ask p { margin: 0; font-size: 13.5px; line-height: 1.4; color: var(--bone-dim); }
.restore-ask table { border-collapse: collapse; font-size: 13px; color: var(--bone-dim); width: 100%; }
.restore-ask th, .restore-ask td { padding: 3px 6px 3px 0; text-align: left; font-weight: 500; }
.restore-ask thead th { color: var(--bone-faint); font: 600 11px/1.2 var(--f-ui); letter-spacing: 0.1em; text-transform: uppercase; }
.restore-ask td { font-family: var(--f-mono); color: var(--bone); }
.restore-ask .slot-btns .pill.danger { background: rgba(240, 120, 90, 0.12); }
.saves-note { margin: -10px 22px 18px; font-size: 13px; color: var(--bone-faint); }
.saves-note b { color: var(--bone-dim); font-weight: 600; }

/* the new player's guide: the first step is a welcome in the middle of the screen */
.tour-tip.welcome { width: min(400px, calc(100vw - 24px)); padding: 20px 22px 16px; text-align: center; justify-items: center; }
.tour-tip.welcome b { font-size: 30px; color: var(--brass); }
.tour-tip.welcome p { font-size: 15px; }
.tour-tip.welcome .tt-btns { width: 100%; margin-top: 8px; }
.tour-tip .tt-icon { width: 72px; height: 72px; border-radius: 16px; }

/* saved worlds: five slots, each with its picture, name, description and buttons */
.modal-card.saves-card { width: min(640px, 100%); }
.saves-card > header .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.saves-list { display: grid; gap: 8px; padding: 4px 22px 22px; overflow: auto; }
.slot { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 8px; background: rgba(14, 28, 28, 0.6); border: 1px solid rgba(78, 154, 136, 0.22); }
.slot.empty { border-style: dashed; }
.slot-pic { flex: none; width: 128px; height: 80px; border-radius: 6px; overflow: hidden; display: grid; place-items: center; background: #0a1013; color: var(--bone-faint); font: 600 22px/1 var(--f-display); box-shadow: inset 0 0 0 1px rgba(236, 229, 211, 0.1); }
.slot-pic img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.slot-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.slot-title { font: 600 15px/1.2 var(--f-ui); color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.empty .slot-title { color: var(--bone-faint); font-weight: 500; }
.slot-meta { font: 500 11.5px/1.2 var(--f-mono); color: var(--bone-faint); }
.slot-desc { margin: 0; font-size: 13px; line-height: 1.4; color: var(--bone-dim); }
.slot-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.slot-btns .pill { flex: 0 0 auto; padding: 6px 12px; font-size: 13px; }
.slot-btns .pill.primary { background: var(--brass); color: #1a1408; border-color: var(--brass); }
.slot-name, .slot-desc-in {
  width: 100%; padding: 7px 9px; border-radius: 6px; border: 1px solid rgba(78, 154, 136, 0.35);
  background: var(--patina-900); color: var(--bone); font: 500 14px/1.3 var(--f-ui); resize: vertical;
}
.slot-name:focus, .slot-desc-in:focus { outline: none; border-color: var(--brass); }
@media (max-width: 520px) { .slot-pic { width: 84px; height: 52px; } }

/* achievements: a card each, earned ones in brass; secrets hide until found */
.achieve-card > header .eyebrow { font: 600 11px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); margin-bottom: 6px; }
.achieve-body { flex: 1; min-height: 0; overflow: auto; padding: 0 22px 22px; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
.achieve-body .group-label { margin: 16px 0 8px; }
.achieve-body .codex-count { margin-left: auto; font: 500 11px/1 var(--f-mono); letter-spacing: 0; text-transform: none; color: var(--brass-dim); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.ach {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px;
  background: rgba(14, 28, 28, 0.6); border: 1px solid rgba(78, 154, 136, 0.22);
}
.ach-icon { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--bone-faint); border: 1px solid rgba(78, 154, 136, 0.25); font: 700 14px/1 var(--f-ui); }
.ach-txt { display: grid; gap: 3px; min-width: 0; flex: 1; }
.ach-txt b { font: 600 14px/1.2 var(--f-ui); color: var(--bone-dim); }
.ach-txt small { font-size: 12.5px; line-height: 1.35; color: var(--bone-faint); }
.ach.got { background: rgba(214, 168, 79, 0.07); border-color: var(--brass-dim); }
.ach.got .ach-icon { color: var(--brass); border-color: var(--brass-dim); background: rgba(214, 168, 79, 0.1); }
.ach.got .ach-txt b { color: var(--bone); }
.ach.got .ach-txt small { color: var(--bone-dim); }
.ach.secret { border-style: dashed; }
.ach-bar { height: 4px; border-radius: 2px; background: rgba(78, 154, 136, 0.18); overflow: hidden; margin-top: 3px; }
.ach-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--verdigris), var(--brass)); }
.ach-prog { font: 500 11px/1.2 var(--f-mono); color: var(--bone-faint); }
.groups-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 22px 22px; display: grid; gap: 22px; scrollbar-width: thin; scrollbar-color: var(--patina-700) transparent; }
.g-nav { display: grid; gap: 8px; padding: 12px 14px; border-radius: 9px; background: rgba(0, 0, 0, 0.16); border: 1px solid rgba(78, 154, 136, 0.18); }
.g-nav-part { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; }
.g-nav-part span { width: 100%; font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); margin-bottom: 2px; }
.g-nav-part a { color: var(--bone); text-decoration: none; border-bottom: 1px solid rgba(78, 154, 136, 0.3); font-size: 14px; }
.g-nav-part a:hover, .g-nav-part a:focus-visible { color: var(--brass); border-color: var(--brass); outline: none; }
.g-part { display: grid; gap: 14px; }
.g-part > h3 { margin: 0; font: 28px/1 var(--f-display); color: var(--bone); display: flex; align-items: center; gap: 14px; }
.g-part > h3::after { content: ''; flex: 1; height: 1px; background: rgba(78, 154, 136, 0.2); }
.g-group { display: grid; gap: 11px; min-width: 0; padding: 16px 16px 18px; border-radius: 10px; background: rgba(0, 0, 0, 0.14); border: 1px solid rgba(78, 154, 136, 0.18); scroll-margin-top: 8px; }
.g-group > header { display: grid; gap: 4px; }
.g-title { margin: 0; font: 23px/1.05 var(--f-display); color: var(--brass); }
.g-group > header p { margin: 0; color: var(--bone-dim); font-size: 14px; max-width: 72ch; }
.g-group h4:not(.g-title) { margin: 6px 0 0; font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-faint); }
.g-els { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.g-el {
  position: relative; display: inline-grid; grid-template-columns: auto auto; grid-template-areas: "z sym" "nm nm" "val val";
  align-items: baseline; column-gap: 6px; min-width: 74px; padding: 6px 8px 7px; border-radius: 6px; border: 1px solid transparent;
  background: var(--fam, #263333); color: var(--bone); text-align: left; line-height: 1.15;
}
.g-el:hover, .g-el:focus-visible { border-color: var(--bone-dim); }
.g-el i { grid-area: z; font: 400 10px/1 var(--f-mono); font-style: normal; color: rgba(236, 229, 211, 0.6); }
.g-el b { grid-area: sym; justify-self: end; font: 700 18px/1 var(--f-ui); }
.g-el small { grid-area: nm; margin-top: 3px; font-size: 12px; font-weight: 600; }
.g-el em { grid-area: val; max-width: 18ch; margin-top: 2px; font: 400 11px/1.25 var(--f-mono); font-style: normal; color: rgba(236, 229, 211, 0.75); }
.g-el.has-c { padding-bottom: 10px; }
.g-el.has-c::after { content: ''; position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.g-hue { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; padding-top: 10px; border-top: 1px solid rgba(78, 154, 136, 0.14); }
.g-hue:first-of-type, .g-group h4 + .g-hue { border-top: 0; padding-top: 2px; }
.g-sw { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffffff55, transparent 55%), var(--c); box-shadow: 0 0 16px -2px var(--c), inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.g-hue-body { display: grid; gap: 6px; min-width: 0; }
.g-hue-name { font: 600 15px/1.2 var(--f-ui); text-transform: capitalize; color: var(--bone); }
.g-hue-name span { text-transform: none; color: var(--bone-faint); font-weight: 500; font-size: 13px; }
.g-row { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: 12px; align-items: start; padding-top: 10px; border-top: 1px solid rgba(78, 154, 136, 0.14); }
.g-row:first-of-type, .g-group > header + .g-row { border-top: 0; padding-top: 0; }
.g-row-label { display: grid; gap: 2px; padding-top: 4px; font-weight: 600; color: var(--bone); }
.g-row-label span { font: 400 11px/1 var(--f-mono); color: var(--bone-faint); }
.g-recipe { display: grid; gap: 6px; padding: 11px 13px; border-radius: 8px; background: var(--patina-800); border: 1px solid rgba(78, 154, 136, 0.2); }
.g-recipe-title { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: #9fe3cf; }
.g-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.g-recipe p { margin: 0; color: var(--bone-dim); font-size: 14px; }
.g-op { font: 500 16px/1 var(--f-mono); color: var(--bone-faint); }
.g-thing { padding: 5px 9px; border-radius: 6px; border: 1px dashed rgba(169, 165, 147, 0.4); color: var(--bone-dim); font-size: 13px; }
.g-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(78, 154, 136, 0.14); }
.g-group > header + .g-chain { border-top: 0; padding-top: 0; }
@media (max-width: 640px) {
  .groups-body { padding: 4px 14px 16px; }
  .g-row { grid-template-columns: 1fr; gap: 6px; }
  .g-el { min-width: 66px; }
}

/* ───────────── small screens: table becomes a bottom drawer ───────────── */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  #panel, #panel.wide { width: 100%; height: var(--panel-user-h, 42dvh); border-left: 0; }
  #splitter {
    width: auto; height: 16px; margin: 0; cursor: row-resize;
    background: var(--patina-900); border-top: 1px solid var(--verdigris-dim);
  }
  #splitter::after { top: 5px; bottom: auto; left: 50%; width: 48px; height: 4px; margin-left: -24px; border-radius: 2px; background: var(--bone-faint); }
  .brand { display: flex; align-items: center; gap: 14px; padding: 10px 46px 10px 16px; }
  .brand h1 { font-size: 24px; }
  .brand-min { top: 50%; margin-top: -12px; }
  .progress { margin: 0; flex: 1; }
  .tools { grid-template-columns: 1fr auto; padding: 8px 16px; align-items: center; }
  .tool-row, .shape-row { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
  #inspect, #grip-info { display: none; }
  #panel.wide { --panel-w: 100%; }
  .pcell { font-size: 8px; }
  #toolbar { bottom: 8px; }
  .tb { padding: 6px 8px; font-size: 13px; }
  .codex-body { grid-template-columns: 1fr; overflow: auto; }
  #quest { width: auto; max-width: calc(100% - 28px); padding: 8px 10px; }
  #quest header { margin-bottom: 6px; }
  .q-num { font-size: 24px; }
  .q-title { font-size: 18px; }
  .q-place { display: none; }
  .q-goals { gap: 4px; }
  .q-goals li { font-size: 12.5px; }
  .q-btns { margin-top: 8px; }
  .page { padding: 24px 22px 20px; font-size: 16px; }
  .page h2 { font-size: 34px; }
  .chapter button { grid-template-columns: 40px 1fr; }
  .chapter .state { grid-column: 2; }
  .welcome-btns { grid-template-columns: 1fr; }
  #codex-detail { border-left: 0; border-top: 1px solid rgba(78, 154, 136, 0.18); }
}

/* ───────────── phones and tablets: the footer's buttons fold away behind ‹ in the header ───────────── */
.brand-more, .brand-tray { display: none; }
@media (max-width: 1024px) {
  .brand-more {
    display: grid; place-items: center; position: absolute; top: 12px; right: 42px; z-index: 3;
    width: 24px; height: 24px; padding: 0 0 2px; border-radius: 5px;
    background: rgba(214, 168, 79, 0.08); border: 1px solid var(--brass-dim); color: var(--brass);
    font: 700 18px/1 var(--f-ui);
  }
  .brand-more:hover, .brand-more[aria-expanded="true"] { background: rgba(214, 168, 79, 0.16); border-color: var(--brass); }
  .brand.min .brand-more { top: 50%; margin-top: -12px; }
  .brand.min { padding-right: 76px; }
  .brand:not(.min) h1 { padding-right: 60px; }
  .brand-tray {
    display: flex; align-items: center; position: absolute; top: 0; bottom: 0; left: 0; right: 72px; z-index: 2;
    padding: 0 0 0 10px; background: var(--patina-900);
    visibility: hidden; opacity: 0; transform: translateX(28px);
    transition: opacity 160ms ease, transform 220ms cubic-bezier(.2, .9, .3, 1), visibility 0s linear 220ms;
  }
  .brand.tray-open .brand-tray { visibility: visible; opacity: 1; transform: none; transition: opacity 160ms ease, transform 220ms cubic-bezier(.2, .9, .3, 1); }
  .brand-tray .foot-btns { flex: 1; min-width: 0; gap: 5px; }
  .brand-tray .pill { min-width: 0; padding: 6px 3px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-tray #btn-help, .brand-tray #btn-achieve { flex: 0 0 32px; }
}
@media (max-width: 820px) {
  .panel-foot { display: none; }
  .brand-more { top: 50%; margin-top: -12px; }
}
/* phones and tablets: a compact toolbar, every button within reach. On a phone it is two rows:
   time, undo and zoom on top, the views, weather, scenes and map below. */
/* small screens: one long tile that scrolls sideways, with an arrow at each end to say there is more */
.tb-row { display: contents; }
.tb-arrow { display: none; }
@media (max-width: 1024px) {
  #toolbar { width: calc(100% - 12px); max-width: 720px; padding: 3px; gap: 2px; bottom: 6px; flex-wrap: nowrap; justify-content: flex-start; }
  .tb-row {
    display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; touch-action: pan-x; -webkit-overflow-scrolling: touch;
  }
  .tb-row::-webkit-scrollbar { display: none; }
  .tb-row .tb { flex: none; white-space: nowrap; }
  .tb-arrow {
    display: grid; place-items: center; flex: none; width: 28px; height: 32px; padding: 0 0 2px; border: 0; border-radius: 6px;
    background: rgba(214, 168, 79, 0.1); color: var(--brass); font: 700 20px/1 var(--f-ui);
  }
  .tb-arrow:disabled { opacity: 0.28; cursor: default; }
  #toolbar.fits { width: max-content; }
  #toolbar.fits .tb-arrow { display: none; }
}
@media (max-width: 640px) {
  .tb { padding: 6px 7px; font-size: 12.5px; min-width: 28px; }
  .tb.zoom { min-width: 44px; }
  .sep { margin: 0 2px; }
  .menu, .menu.wide { min-width: 0; width: calc(100% - 16px); max-width: 380px; }
  .tools { padding: 8px 12px; gap: 8px; }
  .tool-row { gap: 4px; }
  .tool { font-size: 12px; }
  .tabs button { font-size: 12px; letter-spacing: 0.04em; }
  .brand h1 { font-size: 21px; }
  .brand .progress-text { font-size: 12px; }
  #toasts { top: 6px; gap: 4px; width: calc(100% - 12px); }
  .toast { gap: 8px; padding: 4px 30px 4px 5px; border-radius: 8px; }
  .toast canvas, .toast .t-icon { width: 28px; height: 28px; border-radius: 4px; }
  .toast .t-icon svg { width: 18px; height: 18px; }
  .toast .eyebrow { font-size: 9px; letter-spacing: 0.12em; }
  .toast .name, .toast.note .name { font-size: 15px; line-height: 1.1; margin: 1px 0; }
  .toast .how { font-size: 11.5px; line-height: 1.25; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .toast .t-close { top: 2px; right: 2px; }
  #quest { max-width: min(58%, 210px); padding: 5px 7px; left: 6px; top: 6px; border-radius: 8px; }
  #quest header { gap: 6px; margin-bottom: 3px; }
  .q-num { font-size: 15px; }
  .q-title { font-size: 13px; line-height: 1.1; }
  .q-goals { gap: 2px; }
  .q-goals li { font-size: 10.5px; line-height: 1.2; }
  .q-btns { margin-top: 4px; gap: 3px; }
  .q-btns button { padding: 3px 5px; font-size: 10.5px; }
}
/* the Lab upright on a phone: the sample and tube on top and the tests in reach, all on one screen,
   the handbook below */
@media (max-width: 820px) and (orientation: portrait) {
  .lab-card > header { padding: 10px 14px 4px; }
  .lab-card > header h2 { font-size: 22px; }
  .lab-card > header .eyebrow { font-size: 9.5px; margin-bottom: 2px; }
  .lab-bench { gap: 8px; }
  .lab-bench > * { min-width: 0; }
  .lab-left { gap: 6px; }
  .sample-card { padding: 5px 8px; gap: 8px; }
  .sample-card canvas { width: 28px; height: 28px; }
  .sample-card .desc { font-size: 16px; }
  .sample-card .lbl { margin-bottom: 1px; font-size: 9px; }
  .tests-left .lbl { font-size: 9px; letter-spacing: 0.1em; white-space: nowrap; }
  .tests-left i { width: 8px; height: 8px; }
  .tube-wrap { aspect-ratio: auto; height: 21dvh; }
  .test-row { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .test { padding: 4px 0 3px; font-size: 9.5px; gap: 1px; min-width: 0; }
  .test svg { width: 14px; height: 14px; }
  .lab-log { font-size: 12.5px; gap: 4px; }
  .lab-log li { padding: 4px 8px; }
  .lab-log .why { font-size: 11.5px; }
  .lab-foot { padding: 6px 14px 8px; }
  .lab-foot #lab-progress { font-size: 11.5px; }
  .lab-actions .pill { padding: 6px 12px; font-size: 13px; }
  .handbook { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* full screen shows which way it goes */
#btn-full { display: inline-grid; place-items: center; }
#btn-full .full-out, #btn-full[aria-pressed="true"] .full-in { display: none; }
#btn-full[aria-pressed="true"] .full-out { display: inline; }
#btn-full[hidden] { display: none !important; }

/* the story's last chapter for now ends on a dark screen: a line, then "Coming soon…" */
.finale {
  position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; gap: 22px; padding: 24px;
  text-align: center; background: #000; opacity: 0; transition: opacity 1600ms ease; cursor: pointer;
}
.finale.show { opacity: 1; }
.finale.out { opacity: 0; pointer-events: none; }
.finale p { margin: 0 auto; max-width: 34ch; opacity: 0; transform: translateY(8px); transition: opacity 1800ms ease, transform 1800ms ease; }
.finale .finale-line { font: 400 clamp(20px, 3vw, 30px)/1.4 var(--f-display); color: var(--bone); }
.finale .finale-soon { font: 600 13px/1 var(--f-ui); letter-spacing: 0.32em; text-transform: uppercase; color: var(--brass); }
.finale.line .finale-line, .finale.soon .finale-soon { opacity: 1; transform: none; }

/* earned things (unlocks.js): out of sight until they open */
.weapon[hidden], .weapons[hidden], .group-label[hidden], .tabs [hidden], #btn-journey[hidden], #btn-begin-journey[hidden],
[data-scene][hidden], [data-sky][hidden], .scene-more[hidden], .weapons-more[hidden], .lab-help[hidden] { display: none !important; }
.weapons-more { margin: 10px 2px 0; font-size: 13px; line-height: 1.45; color: var(--brass); }
.scene-more {
  display: block; width: 100%; text-align: left; margin-top: 4px; padding: 8px 10px; border-radius: 6px;
  background: transparent; border: 1px dashed var(--brass-dim); color: var(--brass); font: 600 13px/1.3 var(--f-ui); cursor: pointer;
}
.scene-more small { display: block; font-weight: 500; color: var(--bone-faint); }
.scene-more:hover { border-color: var(--brass); }

/* Hint's answer: a small box by the button, with the recipe or the quest in it */
.hint-pop {
  position: fixed; z-index: 72; width: min(320px, calc(100vw - 16px)); display: grid; gap: 8px; padding: 12px 14px 12px;
  background: linear-gradient(180deg, var(--patina-700), var(--patina-800)); border: 1px solid var(--brass); border-radius: 10px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6); animation: hp-in 160ms ease-out;
}
@keyframes hp-in { from { opacity: 0; transform: translateY(6px); } }
.hint-pop .hp-head { display: flex; align-items: center; justify-content: space-between; }
.hint-pop .hp-eyebrow { font: 600 10.5px/1 var(--f-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }
.hint-pop .hp-close { width: 24px; height: 24px; padding: 0; border-radius: 6px; background: transparent; border: 0; color: var(--bone-dim); font: 600 18px/1 var(--f-ui); }
.hint-pop .hp-close:hover { color: var(--bone); }
.hint-pop .hp-title { display: flex; align-items: center; gap: 8px; }
.hint-pop .hp-title b { font: 21px/1.1 var(--f-display); font-weight: 400; color: var(--bone); }
.hint-pop .hp-recipe { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.hint-pop .hp-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 6px;
  background: rgba(214, 168, 79, 0.1); border: 1px solid var(--brass-dim); font: 600 14px/1 var(--f-ui); color: var(--bone);
}
.hint-pop .hp-chip canvas { width: 18px; height: 18px; border-radius: 3px; }
.hint-pop .hp-op { color: var(--brass); font: 700 16px/1 var(--f-ui); }
.hint-pop p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--bone-dim); }
.hint-pop .hp-bar { height: 5px; border-radius: 3px; background: rgba(78, 154, 136, 0.18); overflow: hidden; }
.hint-pop .hp-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--verdigris), var(--brass)); }
.hint-pop .hp-prog, .hint-pop .hp-foot { font: 500 12px/1.3 var(--f-mono); color: var(--bone-faint); }
