/* Atomica — naV Studios. Dark lab theme. Touch-first: 44px targets, no
   pull-to-refresh, no double-tap zoom, safe-area aware. */

:root {
  --bg: #070a16;
  --bg2: #0d1226;
  --panel: #121936;
  --panel2: #1a2348;
  --ink: #eef2ff;
  --ink-dim: #8fa3d9;
  --gold: #ffd24a;
  --red: #ff5d5d;
  --blue: #39b6ff;
  --green: #4ade80;
  /* category palette (echoes the naV vertex colors) */
  --cat-alkali: #ff5d5d;
  --cat-alkaline: #ffa14f;
  --cat-transition: #ffd24a;
  --cat-post: #7f9cf5;
  --cat-metalloid: #35d0ba;
  --cat-nonmetal: #4ade80;
  --cat-noble: #b197fc;
  --cat-lanthanide: #4dc3ff;
  --cat-actinide: #ff7ab6;
  --cat-unknown: #8b93a8;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Segoe UI', 'Avenir Next', system-ui, sans-serif;
  height: 100%;
  overscroll-behavior: none;               /* kill pull-to-refresh */
  -webkit-text-size-adjust: 100%;
}
button {
  font: inherit; color: inherit;
  touch-action: manipulation;              /* kill double-tap zoom */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.atom-canvas, .touch-surface { touch-action: none; }   /* raw pointer control */

.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  min-height: 44px; min-width: 44px;
  padding: 10px 18px;
  border: 1px solid #2c3a6e;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  color: var(--ink);
  font-size: 15px;
  transition: transform 0.06s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.on, .btn.primary { border-color: var(--gold); color: var(--gold); }
.btn-big { font-size: 20px; padding: 16px 38px; border-radius: 16px; }

/* ---------- splash ---------- */
#screen-splash {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1000px 800px at 50% 35%, #10173a 0%, var(--bg) 75%);
  text-align: center;
}
#screen-splash:not(.active) { display: none; }
.splash-presents { color: var(--ink-dim); letter-spacing: 5px; font-size: 14px; text-transform: uppercase; }
.splash-title {
  font-size: clamp(52px, 12vw, 110px);
  letter-spacing: 12px;
  margin: 8px 0 4px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--blue));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 24px rgba(255, 210, 74, 0.25));
}
.splash-sub { color: var(--ink-dim); font-size: 17px; line-height: 1.6; margin-bottom: 34px; }
.splash-sub em { color: var(--gold); font-style: normal; }

/* ---------- topbar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
  background: rgba(10, 14, 30, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1d2750;
}
#tb-brand { font-size: 18px; font-weight: 600; color: var(--gold); }
#tb-brand span { color: var(--ink); font-weight: 500; letter-spacing: 2px; }
#tb-nav { display: flex; gap: 6px; flex: 1; }
#tb-nav button {
  min-height: 44px; padding: 8px 20px;
  background: none; border: none; border-radius: 12px;
  color: var(--ink-dim); font-size: 16px;
}
#tb-nav button.on { color: var(--gold); background: rgba(255, 210, 74, 0.08); }
#tb-settings { min-height: 44px; min-width: 44px; background: none; border: none; font-size: 20px; color: var(--ink-dim); }

/* ---------- screens ---------- */
#main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.screen { display: none; padding: 12px calc(14px + env(safe-area-inset-right)) 12px calc(14px + env(safe-area-inset-left)); }
.screen.active { display: block; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 12px;
  padding: 10px 20px; font-size: 15px;
  animation: toast-in 0.25s ease, toast-out 0.4s ease 2.6s forwards;
  max-width: min(80vw, 520px); text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- naV ident choreography ---------- */
#nv-ident.nv-out { opacity: 0; transition: opacity 0.45s ease; }
#nv-ident .nv-e { stroke-dasharray: 700; stroke-dashoffset: 700; }
#nv-ident.nv-run .nv-e1 { animation: nv-draw 0.9s ease 0.1s forwards; }
#nv-ident.nv-run .nv-e2 { animation: nv-draw 0.9s ease 0.3s forwards; }
#nv-ident.nv-run .nv-e3 { animation: nv-draw 0.9s ease 0.5s forwards; }
#nv-ident.nv-run .nv-e4 { animation: nv-draw 1.0s ease 0.65s forwards; }
#nv-ident.nv-run .nv-e5 { animation: nv-draw 1.0s ease 0.8s forwards; }
@keyframes nv-draw { to { stroke-dashoffset: 0; } }
#nv-ident .nv-d { opacity: 0; transform-box: fill-box; transform-origin: center; }
#nv-ident .nv-d.nv-on { opacity: 1; animation: nv-bloom 0.5s ease; }
@keyframes nv-bloom { 0% { transform: scale(0.2); } 60% { transform: scale(1.9); } 100% { transform: scale(1); } }
#nv-ident .nv-word { opacity: 0; transition: opacity 0.8s ease; }
#nv-ident .nv-word.nv-on { opacity: 1; }

/* ---------- credits ---------- */
#nv-credits {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(4, 6, 14, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#nv-credits-card {
  background: linear-gradient(180deg, #141b33, #0b0f22);
  border: 1px solid #2c3a6e; border-radius: 20px;
  padding: 26px 34px; text-align: center;
  max-width: min(92vw, 480px); max-height: 90vh; overflow-y: auto;
}
#nv-credits-logo svg { width: min(60vw, 300px); }
#nv-credits h2 { margin: 6px 0 2px; letter-spacing: 3px; }
#nv-credits .nv-ver { color: var(--ink-dim); font-size: 13px; margin: 2px 0; }
#nv-credits .nv-line { color: var(--gold); font-size: 14px; margin: 10px 0 2px; }
#nv-credits .nv-story { color: var(--ink-dim); font-size: 13px; }
#nv-credits .nv-hint { color: #55628f; font-size: 12px; font-style: italic; }
#nv-credits .nv-btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
#nv-credits .nv-d.nv-tappable { opacity: 1; cursor: pointer; pointer-events: all; }
#nv-credits .nv-d.nv-ping { animation: nv-bloom 0.5s ease; }
#nv-credits-logo.nv-chordglow svg { animation: nv-glow 1.3s ease; }
@keyframes nv-glow {
  0% { filter: drop-shadow(0 0 0 rgba(255, 210, 74, 0)); }
  40% { filter: drop-shadow(0 0 26px rgba(255, 210, 74, 0.9)); }
  100% { filter: drop-shadow(0 0 0 rgba(255, 210, 74, 0)); }
}
#nv-byline {
  margin: 26px auto 6px; text-align: center;
  color: #55628f; font-size: 13px; letter-spacing: 1px;
  cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
#nv-byline:hover { color: var(--ink-dim); }

/* long-press acknowledgement pulse */
.lp-pulse { animation: lp-pulse 0.22s ease; }
@keyframes lp-pulse { 50% { transform: scale(1.06); } }

/* ---------- generic panels/cards ---------- */
.panel {
  background: var(--panel); border: 1px solid #202a56; border-radius: 16px;
  padding: 14px;
}
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.subnav button {
  min-height: 44px; padding: 8px 16px;
  background: var(--panel); border: 1px solid #202a56; border-radius: 12px;
  color: var(--ink-dim); font-size: 14px;
}
.subnav button.on { color: var(--gold); border-color: var(--gold); }
h3.exhibit-title { margin: 4px 0 10px; color: var(--gold); font-weight: 600; letter-spacing: 1px; }
.note-honest {
  font-size: 12.5px; color: var(--ink-dim); font-style: italic;
  border-left: 3px solid var(--blue); padding-left: 10px; margin: 10px 0;
}

/* ================= the periodic table ================= */
.table-toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.feature-btn { border-color: #3d4d8f; }
/* headroom on every edge: hovered cells scale/lift and must never be clipped
   by the scroll container (H/He at the top, Fr/Ra + the f-block at the bottom,
   both sides) */
#pt-holder { overflow-x: auto; padding: 9px 9px 12px 9px; }
.pt-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(30px, 1fr)) minmax(20px, 34px);
  gap: 3px;
  min-width: 700px;
}
/* the front door: cards with depth, a soft glow language per family,
   and delightful hover/press states */
.el-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--cat, #8b93a8) 52%, #1c2650);
  border-radius: 9px;
  background:
    radial-gradient(130% 95% at 50% -8%, color-mix(in srgb, var(--cat, #8b93a8) 30%, transparent) 0%, transparent 58%),
    linear-gradient(165deg, color-mix(in srgb, var(--cat, #8b93a8) 17%, #111834) 0%, color-mix(in srgb, var(--cat, #8b93a8) 7%, #0c1126) 55%, #0a0e20 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 20px -8px color-mix(in srgb, var(--cat, #8b93a8) 45%, transparent),
    0 2px 5px rgba(0, 0, 0, 0.35);
  padding: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
@media (hover: hover) {
  .el-cell:hover {
    transform: translateY(-2px) scale(1.04);
    border-color: color-mix(in srgb, var(--cat, #8b93a8) 85%, #fff);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 0 22px -6px color-mix(in srgb, var(--cat, #8b93a8) 60%, transparent),
      0 6px 16px -4px color-mix(in srgb, var(--cat, #8b93a8) 45%, rgba(0, 0, 0, 0.5));
    z-index: 3;
  }
}
.el-cell:active { transform: scale(0.93); }
.ec-num {
  position: absolute; top: 3px; left: 5px; z-index: 2;
  font-size: 9px; font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--cat, #8b93a8) 70%, #eef2ff);
  opacity: 0.85;
}
.ec-sym {
  position: absolute; inset: 0 0 12% 0; display: flex; align-items: center; justify-content: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(12px, 1.8vw, 20px); font-weight: 700; z-index: 2;
  letter-spacing: 0.3px;
  text-shadow:
    0 0 14px color-mix(in srgb, var(--cat, #8b93a8) 60%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.85);
}
.ec-mass {
  position: absolute; bottom: 3px; left: 0; right: 0; z-index: 2;
  text-align: center; font-size: 7.5px; font-variant-numeric: tabular-nums;
  color: var(--ink-dim); opacity: 0.75; letter-spacing: 0.2px;
}
.ec-badge { position: absolute; bottom: 12px; right: 3px; font-size: 8px; color: var(--ink-dim); z-index: 2; }
.ec-fill { position: absolute; inset: 0; z-index: 1; }
/* noble gases: a slow, contented shimmer */
.el-cell.cat-noble::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(177, 151, 252, 0.16) 45%, rgba(255, 255, 255, 0.10) 50%, transparent 64%) 0 0 / 260% 100%;
  animation: noble-shimmer 7s ease-in-out infinite;
}
@keyframes noble-shimmer {
  0%, 55% { background-position: 130% 0; }
  90%, 100% { background-position: -80% 0; }
}
/* the unstable ones: a soft radioactive pulse-dot */
.el-cell.is-radio::before {
  content: ''; position: absolute; bottom: 4px; right: 4px; z-index: 2;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 7px 1.5px rgba(255, 210, 74, 0.75);
  animation: radio-pulse 2.4s ease-in-out infinite;
  animation-delay: var(--radio-delay, 0s);
}
@keyframes radio-pulse { 50% { opacity: 0.2; box-shadow: 0 0 2px 0 rgba(255, 210, 74, 0.2); } }
/* data lenses flatten the finery so the data speaks */
.mode-lens .el-cell, .mode-year .el-cell {
  background: #10173a;
  box-shadow: none;
}
.mode-lens .el-cell .ec-sym, .mode-year .el-cell .ec-sym { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
.mode-lens .el-cell.cat-noble::after, .mode-year .el-cell.cat-noble::after { display: none; }
.el-gap {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #55628f; border: 1px dashed #2a3563; border-radius: 7px;
}
/* category palette */
.cat-alkali     { --cat: var(--cat-alkali); }
.cat-alkaline   { --cat: var(--cat-alkaline); }
.cat-transition { --cat: var(--cat-transition); }
.cat-post       { --cat: var(--cat-post); }
.cat-metalloid  { --cat: var(--cat-metalloid); }
.cat-nonmetal   { --cat: var(--cat-nonmetal); }
.cat-noble      { --cat: var(--cat-noble); }
.cat-lanthanide { --cat: var(--cat-lanthanide); }
.cat-actinide   { --cat: var(--cat-actinide); }
.cat-unknown    { --cat: var(--cat-unknown); }

/* data-lens heatmaps */
.mode-lens .el-cell.lens-active .ec-fill { background: var(--lens-color); opacity: 0.82; }
.mode-lens .el-cell.lens-null { opacity: 0.35; border-style: dashed; }
.mode-lens .el-cell .ec-sym { color: #fff; }
/* radius lens: the fill becomes a sized circle */
.mode-lens .el-cell[style*="--fill-scale"] .ec-fill {
  border-radius: 50%;
  inset: 8%;
  transform: scale(var(--fill-scale, 1));
}
.legend-cats { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.lg-chip {
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
  background: color-mix(in srgb, var(--cat, #8b93a8) 20%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--cat, #8b93a8) 55%, transparent);
}
.legend-grad { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 12px; color: var(--ink-dim); }
.legend-grad .lg-bar {
  width: min(300px, 40vw); height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, rgb(38,56,122), rgb(43,149,197), rgb(255,210,74), rgb(255,93,93), rgb(255,236,236));
}
.legend-grad em { font-style: normal; color: var(--ink); }

/* temperature mode: phase visuals (category color stays, state overlays) */
.temp-ctl { display: flex; align-items: center; gap: 14px; margin: 10px 0 4px; }
.temp-ctl input[type=range] { flex: 1; max-width: 560px; min-height: 44px; }
#temp-read b { color: var(--gold); font-size: 18px; }
#temp-read span { color: var(--ink-dim); }
#temp-counts { font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
#temp-counts .ph-s { color: #b9c6f2; } #temp-counts .ph-l { color: #4dc3ff; }
#temp-counts .ph-g { color: #b197fc; } #temp-counts .ph-u { color: #55628f; }
.mode-temp .el-cell[data-phase="solid"] .ec-fill {
  background: linear-gradient(180deg, rgba(255,255,255,0.10), transparent 40%);
}
.mode-temp .el-cell[data-phase="liquid"] .ec-fill {
  background: linear-gradient(110deg, transparent 20%, rgba(77,195,255,0.45) 40%, transparent 60%) 0 0 / 250% 100%,
              linear-gradient(180deg, rgba(77,195,255,0.18), rgba(77,195,255,0.32));
  animation: liq-shimmer 2.2s linear infinite;
}
@keyframes liq-shimmer { to { background-position: 250% 0, 0 0; } }
.mode-temp .el-cell[data-phase="gas"] { opacity: 0.45; border-style: dashed; }
.mode-temp .el-cell[data-phase="gas"] .ec-fill {
  background: radial-gradient(circle at 30% 60%, rgba(177,151,252,0.25), transparent 60%);
  animation: gas-drift 3.5s ease-in-out infinite alternate;
}
@keyframes gas-drift { to { transform: translateY(-14%); } }
.mode-temp .el-cell[data-phase="unknown"] { opacity: 0.3; }
.mode-temp .el-cell[data-phase="unknown"] .ec-sym::after { content: ' ?'; color: #55628f; }
.note-honest-inline { color: var(--ink-dim); font-style: italic; font-size: 12px; }
#table-note { font-size: 13px; color: var(--ink-dim); margin-top: 8px; }

/* discovery timeline */
.mode-year .el-cell { transition: opacity 0.4s ease; }
.el-cell.year-future { opacity: 0.06; }
#year-read b { color: var(--gold); font-size: 18px; }

/* ---------- Great Why mode ---------- */
#screen-table.gw-mode, #screen-table.tour-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(380px, 36vw);
  grid-template-areas: "toolbar toolbar" "controls controls" "grid panel" "note note";
  gap: 10px;
}
#screen-table.gw-mode .table-toolbar, #screen-table.tour-mode .table-toolbar { grid-area: toolbar; }
#screen-table.gw-mode #lens-controls, #screen-table.tour-mode #lens-controls { grid-area: controls; }
#screen-table.gw-mode #pt-holder, #screen-table.tour-mode #pt-holder { grid-area: grid; }
#screen-table.gw-mode #gw-panel, #screen-table.tour-mode #tour-panel { grid-area: panel; }
#screen-table.gw-mode #table-note, #screen-table.tour-mode #table-note { grid-area: note; }
@media (max-width: 900px) {
  #screen-table.gw-mode, #screen-table.tour-mode {
    grid-template-columns: 1fr;
    grid-template-areas: "toolbar" "controls" "panel" "grid" "note";
  }
}
#gw-panel, #tour-panel {
  background: var(--panel); border: 1px solid #202a56; border-radius: 16px; padding: 14px;
  align-self: start;
}
.gw-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gw-intro { font-size: 13px; color: var(--ink-dim); }
.gw-cols { display: flex; gap: 12px; flex-wrap: wrap; }
#gw-atom { background: radial-gradient(circle at 50% 45%, #0f1530, #0a0e20); border-radius: 12px; }
.gw-sym { font-size: 38px; font-weight: 700; color: var(--gold); line-height: 1; margin-top: 6px; }
.gw-name { font-size: 13px; color: var(--ink); }
.gw-cfg { font-size: 12px; color: var(--blue); margin: 3px 0; }
.gw-fill { font-size: 12px; color: var(--ink-dim); }
.gw-rebel { color: var(--gold); }
.gw-right { flex: 1; min-width: 180px; }
.gw-note {
  font-size: 12.5px; color: var(--ink); background: var(--panel2);
  border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0;
  padding: 7px 9px; margin-bottom: 6px;
}
.gw-note i { color: var(--blue); font-style: normal; }
.gw-note-z {
  display: inline-block; min-width: 22px; margin-right: 6px; text-align: center;
  background: #2a3563; border-radius: 6px; font-size: 10px; padding: 1px 3px; color: var(--ink-dim);
}
.gw-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.gw-controls input[type=range] { flex: 1; min-height: 44px; }
#gw-zread { color: var(--gold); font-size: 13px; min-width: 48px; }
.el-cell.gw-hidden { opacity: 0.05; }
.el-cell.gw-current { outline: 2px solid var(--gold); box-shadow: 0 0 14px rgba(255, 210, 74, 0.55); z-index: 3; }
.el-cell.gw-pop { animation: gw-pop 0.45s ease; }
@keyframes gw-pop { 0% { transform: scale(0.3); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.gw-chip {
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-weight: 700; font-size: clamp(11px, 1.4vw, 16px);
  border: 1px dashed rgba(255, 210, 74, 0.5); border-radius: 7px;
  animation: gw-pop 0.45s ease;
}

/* ---------- tours ---------- */
.tour-list { display: flex; flex-direction: column; gap: 8px; }
.tour-item { text-align: left; display: flex; align-items: center; gap: 10px; }
.ti-icon { font-size: 20px; }
.ti-done { margin-left: auto; color: var(--green); }
.tour-text { font-size: 14px; line-height: 1.55; }
.tour-lesson { border-left: 3px solid var(--gold); padding-left: 10px; }
.tour-count { font-size: 12px; color: var(--ink-dim); font-weight: 400; }
.el-cell.tour-dim { opacity: 0.15; }
.el-cell.tour-hot { opacity: 1; outline: 2px solid var(--gold); z-index: 3; transform: scale(1.07); }
.el-cell.drama-1 { animation: drama-shake 0.7s ease 2; }
.el-cell.drama-2 { animation: drama-shake 0.5s ease 3; }
.el-cell.drama-3 { animation: drama-shake 0.4s ease 4; box-shadow: 0 0 16px rgba(255, 160, 79, 0.7); }
.el-cell.drama-4 { animation: drama-shake 0.3s ease 5; box-shadow: 0 0 22px rgba(255, 93, 93, 0.8); }
.el-cell.drama-5 { animation: drama-shake 0.22s ease 7; box-shadow: 0 0 30px rgba(255, 93, 93, 1); }
@keyframes drama-shake {
  0%, 100% { transform: scale(1.07) translate(0, 0); }
  25% { transform: scale(1.09) translate(-2px, 1px); }
  50% { transform: scale(1.07) translate(2px, -1px); }
  75% { transform: scale(1.1) translate(-1px, -1px); }
}
.quiz-choices { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.quiz-choice { text-align: left; }
.quiz-choice.quiz-right { border-color: var(--green); color: var(--green); }
.quiz-choice.quiz-wrong { border-color: var(--red); color: var(--red); }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.set-row label { min-width: 70px; color: var(--ink-dim); }
.set-row input[type=range] { flex: 1; min-height: 44px; }
.set-row input[type=text] {
  flex: 1; min-height: 44px; padding: 6px 12px; font: inherit;
  background: var(--bg2); color: var(--ink); border: 1px solid #2c3a6e; border-radius: 10px;
  min-width: 120px;
}
.set-hr { border: none; border-top: 1px solid #202a56; margin: 16px 0; }
.set-help { font-size: 12.5px; color: var(--ink-dim); }

/* ================= element deep-dive ================= */
.el-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.el-title { display: flex; align-items: center; gap: 14px; flex: 1; }
.el-title h2 { margin: 0; font-size: 24px; }
.el-znum { font-size: 13px; color: var(--ink-dim); font-weight: 400; }
.el-big-sym {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 14px; font-size: 30px; font-weight: 700;
  background: color-mix(in srgb, var(--cat, #8b93a8) 18%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--cat, #8b93a8) 55%, transparent);
}
.el-chips { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chip-radio { border-color: var(--gold); color: var(--gold); }
.el-nav { display: flex; gap: 6px; }
.el-3d-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .el-3d-row { grid-template-columns: 1fr; } }
.el-panel3d { display: flex; flex-direction: column; }
.panel3d-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.panel3d-head .subnav { margin-bottom: 0; }
.panel3d-canvas { position: relative; height: min(46vh, 420px); border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 50% 40%, #0e1430, #070a16); }
.panel3d-canvas canvas { display: block; }
#el-config { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.cfg-chip {
  font-size: 13px; padding: 6px 10px; min-height: 44px; min-width: 44px;
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 10px; color: var(--ink);
}
.cfg-chip sup { color: var(--gold); }
.cfg-chip.on { border-color: var(--gold); box-shadow: 0 0 8px rgba(255,210,74,0.4); }
#el-shellinfo { font-size: 13px; color: var(--ink-dim); margin-top: 8px; min-height: 20px; }
#el-sample-note { margin-top: 8px; }
.el-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
.prop-row { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid #1a2348; flex-wrap: wrap; }
.pr-label { min-width: 120px; color: var(--ink-dim); font-size: 13px; }
.pr-val { font-weight: 600; }
.pr-val-wide { flex: 1; font-size: 13.5px; }
.pr-meaning { color: var(--gold); font-size: 12.5px; font-style: italic; }
.el-summary { font-size: 13.5px; color: var(--ink-dim); line-height: 1.55; margin-top: 10px; }
.el-story { font-size: 14px; line-height: 1.55; border-left: 3px solid var(--gold); padding-left: 10px; }
.el-fact { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.light-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.flame-box, .spec-box { text-align: center; }
.spec-box { flex: 1; min-width: 280px; }
.spec-box canvas { width: 100%; max-width: 460px; }
.flame-cap { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.el-decay { margin-top: 12px; }
.el-decay p { font-size: 13.5px; line-height: 1.55; }
.chain-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; }
.chain-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px; }
.chain-step {
  min-width: 74px; text-align: center; padding: 8px 6px;
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 10px;
  opacity: 0.55; transition: all 0.3s ease; flex-shrink: 0;
}
.chain-step.chain-lit { opacity: 1; border-color: var(--gold); box-shadow: 0 0 12px rgba(255,210,74,0.35); }
.chain-step.chain-hot { outline: 2px solid var(--blue); opacity: 0.9; }
.cs-sym { font-size: 20px; font-weight: 700; }
.cs-a { font-size: 11px; color: var(--ink-dim); }
.cs-hl { font-size: 10px; color: var(--blue); margin-top: 3px; }
.cs-mode { font-size: 12px; color: var(--gold); }
.cs-stable { font-size: 11px; color: var(--green); margin-top: 3px; }

/* ================= chemistry exhibits ================= */
.bond-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 12px; }
@media (max-width: 900px) { .bond-row { grid-template-columns: 1fr; } }
.bond-side { align-self: start; }
#bond-holder { height: min(52vh, 460px); padding: 0; }
#bond-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tug-label { font-size: 12px; color: var(--ink-dim); margin: 10px 0 4px; }
.tug-bar {
  position: relative; height: 26px; border-radius: 13px; overflow: hidden;
  background: linear-gradient(180deg, #232d5c, #1a2348);
  border: 1px solid #2c3a6e;
}
.tug-fill {
  position: absolute; right: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(74, 222, 128, 0.45));
  border-left: 2px solid var(--gold);
}
.tug-a, .tug-b { position: absolute; top: 3px; font-size: 12.5px; font-weight: 600; }
.tug-a { left: 8px; color: #ff9d9d; }
.tug-b { right: 8px; color: #9df2b6; }
.tug-cap { font-size: 12px; color: var(--ink-dim); margin-top: 4px; font-style: italic; }

.octet-canvas { width: 100%; max-width: 880px; background: radial-gradient(circle at 50% 40%, #0e1430, #070a16); border-radius: 12px; display: block; }
.eq-canvas { width: 100%; background: radial-gradient(circle at 50% 40%, #0e1430, #070a16); border-radius: 12px; display: block; margin: 10px 0; }
#eq-steppers { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.eq-species {
  display: flex; align-items: center; gap: 4px;
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 10px; padding: 4px 8px;
}
.eq-species button { min-width: 44px; min-height: 44px; background: none; border: none; color: var(--gold); font-size: 20px; }
.eq-coef { font-size: 20px; font-weight: 700; color: var(--gold); min-width: 20px; text-align: center; }
.eq-formula { font-size: 17px; }
.eq-plus { font-size: 18px; color: var(--ink-dim); }
#eq-list button.eq-done { border-color: var(--green); color: var(--green); }
#eq-free-row input { flex: 1; min-height: 44px; padding: 6px 12px; font: inherit; background: var(--bg2); color: var(--ink); border: 1px solid #2c3a6e; border-radius: 10px; min-width: 140px; }

.iso-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.iso-jar { grid-column: 1 / -1; }
.iso-jar canvas { display: block; width: 100%; max-width: 640px; background: rgba(5, 7, 15, 0.5); border-radius: 10px; margin-top: 8px; }
#iso-nucleus, #iso-valley { width: 100%; background: rgba(5, 7, 15, 0.5); border-radius: 10px; }
.lab-select {
  min-height: 44px; padding: 6px 12px; font: inherit;
  background: var(--bg2); color: var(--ink); border: 1px solid #2c3a6e; border-radius: 10px;
}
.iso-stable { color: var(--green); }
.iso-radio { color: var(--gold); }
.iso-note { font-size: 12.5px; color: var(--ink-dim); font-style: italic; margin-top: 4px; }
.ion-big { font-size: 40px; font-weight: 700; color: var(--gold); }
#ion-canvas { width: 100%; background: radial-gradient(circle at 50% 45%, #0e1430, #070a16); border-radius: 12px; }

/* ================= the reaction lab ================= */
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 12px; }
@media (max-width: 900px) { .lab-grid { grid-template-columns: 1fr; } }
.shelf-label { font-size: 12px; color: var(--ink-dim); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 1px; }
.shelf-row { display: flex; flex-wrap: wrap; gap: 6px; }
.shelf-chip {
  min-height: 44px; padding: 5px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 10px;
}
.shelf-chip:active { transform: scale(0.95); }
.sc-f { font-size: 15px; font-weight: 600; }
.sc-nick { font-size: 10px; color: var(--ink-dim); }
.lab-chamber { align-self: start; }
#chamber-slots { min-height: 56px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chamber-chip {
  min-height: 44px; padding: 8px 14px; font-size: 16px;
  background: rgba(255, 210, 74, 0.12); border: 1px solid var(--gold); border-radius: 12px; color: var(--gold);
}
.cond-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cond-chip {
  min-height: 44px; padding: 6px 12px; font-size: 13.5px;
  background: var(--panel2); border: 1px solid #2c3a6e; border-radius: 20px; color: var(--ink-dim);
}
.cond-chip.on { border-color: var(--red); color: var(--ink); background: rgba(255, 93, 93, 0.14); }
#lab-go { width: 100%; }
#lab-result { margin-top: 12px; }
.lab-hit { border-left: 3px solid var(--green); padding: 8px 12px; margin-top: 8px; background: rgba(74, 222, 128, 0.06); border-radius: 0 10px 10px 0; }
.lab-hit.lh-mission { border-color: var(--gold); background: rgba(255, 210, 74, 0.07); }
.lh-name { font-weight: 700; color: var(--green); }
.lh-eq { font-size: 17px; margin: 4px 0; }
.lh-why { font-size: 13.5px; }
.lh-meta { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.lh-products { font-size: 13px; color: var(--gold); margin-top: 6px; }
.lab-miss { border-left: 3px solid var(--blue); padding: 8px 12px; font-size: 14px; background: rgba(57, 182, 255, 0.06); border-radius: 0 10px 10px 0; }
.lab-none { border-left: 3px solid #55628f; padding: 8px 12px; font-size: 14px; background: rgba(85, 98, 143, 0.1); border-radius: 0 10px 10px 0; }
.lab-stage-panel { margin-top: 12px; position: relative; overflow: hidden; }
#lab-stage { width: 100%; background: radial-gradient(circle at 50% 45%, #0e1430, #070a16); border-radius: 12px; display: block; }
#blast-shield {
  position: absolute; left: 0; right: 0; top: -110%; height: 100%; z-index: 5;
  transition: top 0.55s cubic-bezier(0.7, 0, 0.9, 0.4);
  pointer-events: none;
}
#blast-shield.bs-down { top: 0; }
.bs-glass {
  position: absolute; inset: 8px;
  background: linear-gradient(180deg, rgba(120, 160, 220, 0.16), rgba(120, 160, 220, 0.05));
  border: 3px solid rgba(180, 200, 240, 0.5); border-radius: 12px;
  backdrop-filter: blur(1.5px);
}
.bs-label {
  position: absolute; top: 16px; left: 0; right: 0; text-align: center;
  font-weight: 700; letter-spacing: 4px; color: rgba(255, 210, 74, 0.85);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.mission-banner { margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-color: var(--gold); }
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission-item { display: flex; gap: 12px; align-items: center; padding: 8px; border-bottom: 1px solid #1a2348; }
.mission-item.m-done { opacity: 0.75; }
.mi-num { min-width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink-dim); }
.m-done .mi-num { background: rgba(74, 222, 128, 0.2); color: var(--green); }
.mi-body { flex: 1; }
.mi-brief { font-size: 13px; color: var(--ink-dim); }
.mi-lesson { font-size: 12.5px; color: var(--green); margin-top: 3px; }
.ach-grid, .log-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ach-item { padding: 10px; border: 1px solid #202a56; border-radius: 12px; opacity: 0.55; }
.ach-item.ach-earned { opacity: 1; border-color: var(--gold); background: rgba(255, 210, 74, 0.06); }
.ai-name { font-weight: 600; font-size: 14px; }
.ai-desc { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.log-card { padding: 10px; border: 1px solid #202a56; border-radius: 12px; }
.log-date { font-size: 11px; color: #55628f; margin-top: 5px; }
#ach-card-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(4, 6, 14, 0.8);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.ach-card { max-width: 520px; }
.ach-card p { line-height: 1.6; font-size: 14.5px; }

/* ---------- ☢ badge + info cards ---------- */
button.chip-radio { min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.rb-more {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255, 210, 74, 0.25); font-size: 11px; font-weight: 700;
}
.ic-body p { line-height: 1.6; font-size: 14.5px; text-align: left; }
.ach-card { text-align: center; }

/* ================= teaching layer ================= */
/* the universal hint ladder */
.hint-box { margin-top: 8px; }
.hint-btn { font-size: 13.5px; }
.hint-panel { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.hint-row {
  display: flex; gap: 8px; align-items: baseline;
  background: var(--panel2); border-radius: 10px; padding: 8px 10px;
  border-left: 3px solid var(--blue);
  animation: toast-in 0.25s ease;
}
.hint-row.hint-t2 { border-left-color: var(--green); }
.hint-row.hint-t3 { border-left-color: var(--gold); }
.hint-row.hint-t4 { border-left-color: var(--red); }
.hint-tier {
  flex-shrink: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--ink-dim); min-width: 58px; padding-top: 2px;
}
.hint-text { font-size: 13.5px; line-height: 1.5; }

/* equations: the live element scoreboard */
#eq-counts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; min-height: 30px; }
.eqc {
  font-size: 14px; padding: 4px 12px; border-radius: 16px;
  font-variant-numeric: tabular-nums;
  border: 1px solid; transition: all 0.2s ease;
}
.eqc-ok { color: var(--green); border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.08); }
.eqc-bad { color: var(--red); border-color: rgba(255, 93, 93, 0.5); background: rgba(255, 93, 93, 0.08); }

/* the balancing on-ramp */
#eq-intro {
  position: fixed; inset: 0; z-index: 240;
  background: rgba(4, 6, 14, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.eq-intro-card {
  max-width: min(94vw, 700px); max-height: 92vh; overflow-y: auto;
}
.eqi-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.eqi-dot { width: 8px; height: 8px; border-radius: 50%; background: #2c3a6e; }
.eqi-dot.on { background: var(--gold); }
.eqi-body p { font-size: 14.5px; line-height: 1.6; }
.eqi-canvas { width: 100%; background: radial-gradient(circle at 50% 40%, #0e1430, #070a16); border-radius: 12px; touch-action: manipulation; }

/* worked-example narration bar */
#eq-worked-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: rgba(255, 210, 74, 0.08); border: 1px solid rgba(255, 210, 74, 0.4);
  border-radius: 12px; padding: 10px 14px; margin: 8px 0;
}
.eqw-say { flex: 1; font-size: 14px; line-height: 1.5; min-width: 200px; }

/* what-just-happened cards */
.wjh-btn { font-size: 13.5px; margin-top: 6px; }
.wjh-list { text-align: left; font-size: 13.5px; line-height: 1.6; margin: 4px 0; padding-left: 20px; }
.ic-body ul { text-align: left; }
.ic-body .btn { margin: 2px 0; }

/* discovery log: puzzle book + solo/helped marks */
.log-mystery { border-style: dashed; opacity: 0.9; }
.log-cat { font-size: 11px; color: var(--ink-dim); font-weight: 400; margin-left: 6px; }
.log-solve { font-size: 10.5px; font-weight: 400; margin-left: 6px; padding: 2px 8px; border-radius: 10px; }
.ls-solo { color: var(--gold); background: rgba(255, 210, 74, 0.1); }
.ls-helped { color: var(--blue); background: rgba(57, 182, 255, 0.12); }
.mb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mi-hints { margin-top: 4px; }
#stuck-holder { margin-top: 8px; }

/* ================= round 3: molecule trays + coach ================= */
.eq-species { flex-direction: column; align-items: stretch; padding: 6px 8px; }
.eq-tray-head { display: flex; align-items: center; gap: 4px; }
.eq-coef.eq-coef-pop { animation: gw-pop 0.35s ease; display: inline-block; }
.eq-copies { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; margin-top: 4px; justify-content: center; }
.eq-mini {
  display: inline-flex; align-items: center; gap: 1.5px;
  padding: 3px 5px; border: 1px solid #2c3a6e; border-radius: 8px;
  background: rgba(12, 17, 38, 0.8); cursor: pointer;
}
.eq-mini i { display: block; width: 8px; height: 8px; border-radius: 50%; }
.eq-mini em { font-size: 9px; color: var(--ink-dim); font-style: normal; }
.eq-mini.eq-mini-pop { animation: gw-pop 0.35s ease; }
.eq-more { font-size: 12px; color: var(--gold); align-self: center; }
#eq-coach { position: fixed; inset: 0; z-index: 245; pointer-events: none; }
.coach-ring {
  position: fixed; border: 3px solid var(--gold); border-radius: 14px;
  box-shadow: 0 0 0 4000px rgba(4, 6, 14, 0.45), 0 0 18px rgba(255, 210, 74, 0.8);
  transition: all 0.25s ease;
}
.coach-bubble {
  position: fixed; max-width: 320px; font-size: 14px; line-height: 1.5;
  pointer-events: auto; border-color: var(--gold);
}
.coach-bubble .coach-skip { min-height: 32px; min-width: 32px; padding: 2px 8px; font-size: 12px; margin-left: 6px; }

/* ================= round 4: ions overhaul ================= */
#ion-canvas { width: 100%; }
.ion-big.ion-pos { color: var(--red); }
.ion-big.ion-neg { color: var(--blue); }
.ion-cfg { font-size: 14px; color: var(--blue); margin: 6px 0; }
.ion-cfg sup { color: var(--gold); }
.ion-meter-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 11.5px; color: var(--ink-dim); }
.ion-meter-row > span:first-child { min-width: 30px; }
.ion-meter { flex: 1; height: 8px; border-radius: 4px; background: #1a2348; overflow: hidden; }
.ion-meter-fill { height: 100%; border-radius: 4px; background: var(--blue); transition: width 0.3s ease; }
.ion-meter-fill.imf-outer { background: var(--gold); }
.ion-meter-n { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.ion-identity {
  margin: 10px 0; padding: 8px 10px; font-size: 13.5px; line-height: 1.5;
  border-left: 3px solid var(--green); background: rgba(74, 222, 128, 0.07); border-radius: 0 8px 8px 0;
}
#ion-size { display: block; margin-top: 10px; background: rgba(5, 7, 15, 0.5); border-radius: 10px; width: 100%; max-width: 260px; }
.eqc-flip { animation: eqc-flip 0.32s ease; }
@keyframes eqc-flip { 35% { transform: scale(1.16) rotate(-1.5deg); } 70% { transform: scale(0.96); } }

/* ================= round 5: The Bench ================= */
.bench-panel { position: relative; overflow: hidden; padding: 6px; }
#bench-canvas { display: block; width: 100%; border-radius: 12px; background: radial-gradient(circle at 50% 30%, #10173a, #070a16); }
#bench-shield {
  position: absolute; left: 0; right: 0; top: -110%; height: 100%; z-index: 5;
  transition: top 0.55s cubic-bezier(0.7, 0, 0.9, 0.4);
  pointer-events: none;
}
#bench-shield.bs-down { top: 0; }

/* the bench coach: caption card above the canvas + glow on a live DOM button */
#bench-coach {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 8px; padding: 10px 14px;
  background: linear-gradient(135deg, rgba(255, 210, 74, 0.14), rgba(255, 210, 74, 0.04));
  border: 1px solid rgba(255, 210, 74, 0.45); border-radius: 12px;
  font-size: 14px; line-height: 1.45;
}
#bench-coach .bc-text { flex: 1; }
#bench-coach .btn { min-height: 34px; padding: 4px 12px; font-size: 12px; flex-shrink: 0; }
.coach-glow { animation: coach-glow 1.1s ease-in-out infinite; }
@keyframes coach-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 74, 0.0); }
  50% { box-shadow: 0 0 14px 4px rgba(255, 210, 74, 0.55); }
}
