:root {
  --glass: rgba(11, 16, 32, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #c03cff;
  --accent-bg: rgba(192, 60, 255, 0.22);
  --accent-line: rgba(192, 60, 255, 0.6);
  --orb: radial-gradient(circle at 35% 30%, #f0abfc, #c03cff 50%, #4c1d95);
}
/* Themes (themes.js): the UI accent follows the desktop skin. */
body[data-theme=classic] {
  --accent: #1084d0;
  --accent-bg: rgba(16, 132, 208, 0.25);
  --accent-line: rgba(16, 132, 208, 0.8);
  --orb: conic-gradient(#ff3b30 0 25%, #34c759 0 50%, #ffd60a 0 75%, #0a84ff 0);
}
body[data-theme=classic] #hud, body[data-theme=classic] #toolbar, body[data-theme=classic] #creatures { font-family: Tahoma, Verdana, "Segoe UI", sans-serif; }
body[data-theme=aqua] {
  --accent: #2f80ed;
  --accent-bg: rgba(47, 128, 237, 0.25);
  --accent-line: rgba(96, 165, 250, 0.75);
  --orb: radial-gradient(circle at 50% 75%, #9ee7ff, #1e7be0 60%, #0a3a8a);
}
body[data-theme=terminal] {
  --accent: #22c55e;
  --accent-bg: rgba(34, 197, 94, 0.16);
  --accent-line: rgba(74, 222, 128, 0.65);
  --orb: radial-gradient(circle, #000 55%, #4ade80 58%, #000 70%);
  font-family: "Cascadia Mono", Consolas, Menlo, "Courier New", monospace;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1020;
  color: var(--text);
  font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stage { position: fixed; inset: 0; }
#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}
/* Light map (atmos.js): low-res, multiplied over the scene; hidden in full daylight. */
#stage canvas#light { pointer-events: none; mix-blend-mode: multiply; }

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 16px));
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.health { display: flex; align-items: center; gap: 10px; }
.health .label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bar {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
}
#healthFill { height: 100%; width: 100%; background: #22c55e; transition: width 0.2s linear; }
.energy { margin-top: 4px; }
.energy .bar { height: 6px; }
#energyFill { height: 100%; width: 50%; background: linear-gradient(90deg, #f59e0b, #fde047); transition: width 0.2s linear; }
#energyText { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; color: #fde047; font-size: 12px; }
#healthText { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
#stats { margin-top: 4px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

#hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 190px);
  transform: translateX(-50%);
  padding: 8px 14px;
  background: var(--glass);
  border-radius: 999px;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.6s;
  white-space: nowrap;
}
#hint.gone { opacity: 0; }

#toolbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  transform: translateX(-50%);
  width: min(560px, calc(100% - 16px));
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#toolbar .spacer { flex: 1; }
#toolbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 58px;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
#toolbar button i { font-style: normal; font-size: 20px; line-height: 1; }
#toolbar button:active { background: rgba(255, 255, 255, 0.08); }
#toolbar button.active { background: var(--accent-bg); border-color: var(--accent-line); }

#sheet {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10;
}
#sheet[hidden] { display: none; }
#sheet .panel {
  width: min(440px, 100%);
  margin: 8px;
  margin-bottom: calc(env(safe-area-inset-bottom) + 8px);
  padding: 14px;
  background: #111827;
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#sheet h2 { margin: 2px 4px 6px; font-size: 16px; }
#sheet button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#sheet button i { font-style: normal; font-size: 24px; }
#sheet button small { display: block; color: var(--muted); font-size: 12px; }
#sheet button.cancel { justify-content: center; background: transparent; }

/* Heartbeat: a red vignette that throbs on each beat (opacity set per frame). */
#pulse {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 52%, rgba(200, 20, 60, 0.38) 82%, rgba(150, 0, 40, 0.7) 100%);
}
#heart { color: #fda4af; }
#heart i { display: inline-block; font-style: normal; }

#fever {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 140, 40, 0.25) 0%, rgba(255, 60, 20, 0.6) 100%);
  mix-blend-mode: multiply;
}

#stats { display: flex; flex-wrap: wrap; gap: 4px 12px; }
#stats .fps { margin-left: auto; opacity: 0.6; }
#feverChip { color: #fb923c; font-weight: 600; }
#stormChip { color: #f87171; font-weight: 700; animation: blink 0.8s steps(2) infinite; }
#waveChip { color: #7dd3fc; font-weight: 600; }
@keyframes blink { 50% { opacity: 0.4; } }

#storm {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  box-shadow: inset 0 0 120px 30px rgba(220, 38, 38, 0.55);
}
#storm.on { opacity: 1; animation: stormPulse 1.2s ease-in-out infinite; }
@keyframes stormPulse { 50% { opacity: 0.55; } }

#toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 100px);
  transform: translateX(-50%);
  max-width: min(480px, calc(100% - 24px));
  padding: 8px 14px;
  background: #111827;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  z-index: 15;
}
#toast[hidden] { display: none; }
#toast.show { animation: toastIn 0.25s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

@media (max-width: 520px) {
  #toolbar button { min-width: 44px; }
  .health .label { display: none; }
}

/* ---- Creature list ------------------------------------------------------ */
#creatures {
  position: fixed;
  right: calc(env(safe-area-inset-right) + 8px);
  top: calc(env(safe-area-inset-top) + 88px);
  width: 214px;
  max-height: calc(100% - 180px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#creatures .tabs { display: flex; gap: 4px; flex-shrink: 0; }
#creatures .tabs button {
  flex: 1;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
#creatures .tabs button.active { background: var(--accent-bg); border-color: var(--accent-line); color: var(--text); }
.pane {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.pane[hidden] { display: none; }
/* While a hotbar tool is armed the panel's selection is only a memory. */
body.armed #creatures .tabs button.active { background: rgba(255, 255, 255, 0.05); border-color: var(--accent-line); }
body.armed .pane .creature.active { opacity: 0.6; }
.creature.locked, .creature.poor { opacity: 0.45; }
.creature.locked.active, .creature.poor.active { opacity: 0.7; }
.creature .cost { color: #fde047; min-width: 34px; }
.creature .trained {
  margin-left: 4px;
  color: #4ade80;
  font-style: normal;
  font-size: 11px;
}
#tip .chips { display: flex; flex-wrap: wrap; gap: 4px; }
#tip .chips span { padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); color: var(--text); font-size: 11px; }
#tip .strain { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: #cbd5e1; }
#tip .strain canvas { width: 44px; height: 44px; flex-shrink: 0; background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
#tip .strain b { color: #4ade80; margin-right: 4px; }
.group {
  padding: 6px 6px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.group:first-child { padding-top: 2px; }
.creature b em {
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.2);
  color: #7dd3fc;
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  vertical-align: 1px;
}
.creature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  flex-shrink: 0;
}
.creature:hover { background: rgba(255, 255, 255, 0.06); }
.creature.active { background: rgba(255, 255, 255, 0.1); border-color: var(--c); }
.creature canvas { width: 30px; height: 30px; flex-shrink: 0; }
.creature .txt { flex: 1; min-width: 0; line-height: 1.15; }
.creature .txt b { display: block; font-size: 12px; }
.creature .txt small { display: block; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.creature .count {
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

#tip {
  position: fixed;
  z-index: 20;
  width: 250px;
  padding: 10px 12px;
  background: #111827;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  pointer-events: none;
}
#tip[hidden] { display: none; }
#tip p { margin: 6px 0 0; color: #cbd5e1; }
#tip .trait b { color: var(--text); margin-right: 4px; }
.tip-head { display: flex; align-items: baseline; gap: 8px; }
.tip-head b { color: var(--c); font-size: 14px; }
.tip-head span { color: var(--muted); font-size: 11px; text-transform: capitalize; }

/* ---- Mark regions bar ---------------------------------------------------- */
#regionBar {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 88px);
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 16px));
  padding: 10px 12px;
  background: #111827;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 14px;
  z-index: 5;
}
#regionBar[hidden] { display: none; }
#regionBar .title { font-weight: 700; margin-right: 8px; }
#regionBar .help { color: var(--muted); font-size: 12px; }
#regionBar .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#regionBar button {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#regionBar button.active { border-color: #fbbf24; background: rgba(251, 191, 36, 0.18); }
#regionBar button.done { margin-left: auto; background: #fbbf24; color: #111; font-weight: 700; }

/* Phones: the creature list becomes a strip above the toolbar. */
@media (max-width: 760px) {
  #creatures {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: calc(env(safe-area-inset-bottom) + 76px);
    width: auto;
    max-height: none;
    flex-direction: row;
  }
  #creatures .tabs { flex-direction: column; width: 64px; }
  #creatures .tabs button { font-size: 10px; padding: 4px 2px; }
  .pane { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: 1; }
  #toast { top: calc(env(safe-area-inset-top) + 92px); }
  .creature { flex-direction: column; gap: 2px; padding: 4px 6px; position: relative; }
  .creature .txt small { display: none; }
  .creature .txt b { font-size: 10px; }
  .creature b em { display: none; }
  .group { writing-mode: vertical-rl; transform: rotate(180deg); padding: 4px 2px; align-self: center; }
  .creature .count { position: absolute; top: 0; right: 0; min-width: 0; padding: 0 4px; font-size: 9px; }
  #hint { bottom: calc(env(safe-area-inset-bottom) + 256px); }
  #hotbar { bottom: calc(env(safe-area-inset-bottom) + 150px); }
}

/* ---- The OS plays along (os.js) ------------------------------------------- */
#btnStart { display: none !important; }
@media (max-width: 660px) { #btnStart { display: flex !important; } }

#fx.oscursor { cursor: none; }
#cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
  z-index: 100;
  will-change: transform;
}
#cursor[hidden] { display: none; }

#popups { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.popup {
  position: absolute;
  width: 290px;
  pointer-events: auto;
  background: #1e2235;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: popIn 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.popup.out { animation: popOut 0.2s ease-in forwards; }
@keyframes popIn { from { opacity: 0; transform: scale(0.8); } }
@keyframes popOut { to { opacity: 0; transform: scale(0.9); } }
.popup .bar { display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 10px; background: rgba(255, 255, 255, 0.07); font-size: 12px; }
.popup .bar b { flex: 1; text-align: center; margin-right: 46px; color: #cbd5e1; font-weight: 600; }
.popup .dots { display: flex; gap: 6px; }
.popup .dots i { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; cursor: pointer; }
.popup .dots i:nth-child(2) { background: #f59e0b; pointer-events: none; }
.popup .dots i:nth-child(3) { background: #22c55e; pointer-events: none; }
.popup .body { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 4px; }
.popup .ic { font-size: 30px; line-height: 1; }
.popup p { margin: 2px 0 0; font-size: 13px; color: #e2e8f0; }
.popup .btns { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 12px 12px; }
.popup button {
  padding: 5px 14px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.popup button.pri { background: #3b82f6; border-color: #3b82f6; font-weight: 600; }
.popup.warn { border-color: rgba(251, 191, 36, 0.6); }
.popup.warn button.pri { background: #f59e0b; border-color: #f59e0b; color: #111; }
.popup.ad { background: linear-gradient(135deg, #fde047, #f472b6 55%, #a855f7); border: 3px dashed #fff; }
.popup.ad .bar { background: rgba(0, 0, 0, 0.25); }
.popup.ad .bar b, .popup.ad p { color: #1e1b4b; }
.popup.ad p { font-weight: 600; }
.popup.ad .ic { animation: blink 0.5s steps(2) infinite; }
.popup.ad button.pri { background: #16a34a; border-color: #fff; animation: wiggle 0.6s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(-4deg) scale(1.06); } }

#notes {
  position: fixed;
  left: calc(env(safe-area-inset-left) + 8px);
  top: calc(env(safe-area-inset-top) + 88px);
  width: 270px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 14;
  pointer-events: none;
}
.note {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  cursor: pointer;
  animation: noteIn 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.note.out { animation: noteOut 0.3s ease-in forwards; }
@keyframes noteIn { from { opacity: 0; transform: translateX(-30px); } }
@keyframes noteOut { to { opacity: 0; transform: translateX(-30px); } }
.note .ic { font-size: 20px; }
.note .tx { flex: 1; min-width: 0; }
.note b { display: block; font-size: 12px; }
.note small { display: block; font-size: 11px; color: var(--muted); }
.note .when { align-self: flex-start; font-size: 10px; color: var(--muted); }

#startMenu {
  position: fixed;
  left: calc(env(safe-area-inset-left) + 8px);
  bottom: calc(env(safe-area-inset-bottom) + 60px);
  width: 290px;
  padding: 8px;
  background: rgba(17, 19, 40, 0.96);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
  max-height: calc(100% - 140px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
  animation: menuIn 0.2s ease-out;
}
#startMenu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(12px); } }
#startMenu .head { display: flex; gap: 10px; align-items: center; padding: 4px 6px 10px; border-bottom: 1px solid var(--glass-border); margin-bottom: 4px; }
#startMenu .head .orb { width: 26px; height: 26px; border-radius: 50%; background: var(--orb); }
#startMenu .head b { display: block; }
#startMenu .head small, #startMenu button small { display: block; color: var(--muted); font-size: 11px; }
#startMenu > button {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
#startMenu > button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); }
#startMenu > button:disabled { opacity: 0.45; cursor: default; }
#startMenu > button i { font-style: normal; font-size: 18px; width: 24px; text-align: center; }
#startMenu .sect { padding: 8px 8px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
#startMenu .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 8px; }
#startMenu .chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#startMenu .chip.on { border-color: #facc15; background: rgba(250, 204, 21, 0.18); }

#startMenu .tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 8px 8px; }
#startMenu .tiles button {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  column-gap: 6px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
#startMenu .tiles button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }
#startMenu .tiles button:disabled { opacity: 0.45; cursor: default; }
#startMenu .tiles i { grid-row: span 2; font-style: normal; font-size: 18px; text-align: center; }
#startMenu .tiles small { font-size: 10px; }

/* Saved image row in the screen picker. */
#sheet .saved { display: flex; gap: 8px; }
#sheet .saved[hidden] { display: none; }
#sheet .saved button:first-child { flex: 1; }
#sheet .saved .forget { flex: none; justify-content: center; color: var(--muted); font-size: 12px; }

/* Outbreak report (aftermath.js): a card above the toolbar. */
#report {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 76px);
  transform: translateX(-50%);
  width: min(420px, calc(100% - 16px));
  padding: 12px;
  background: rgba(15, 18, 38, 0.95);
  border: 1px solid var(--accent-line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 18;
  animation: reportIn 0.45s cubic-bezier(0.2, 1.3, 0.4, 1);
}
#report[hidden] { display: none; }
@keyframes reportIn { from { opacity: 0; transform: translate(-50%, 30px) scale(0.96); } }
#report .head { display: flex; gap: 10px; align-items: center; }
#report .head .ic { font-size: 30px; }
#report .head .tt { flex: 1; min-width: 0; }
#report .head b { display: block; font-size: 16px; }
#report .head small { color: var(--muted); font-size: 12px; }
#report .x, .overlay .x {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  flex: none;
}
#report .spark { display: block; width: 100%; height: 46px; margin: 10px 0 2px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
#report .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
#report .tiles div { padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); }
#report .tiles b { display: block; font-size: 17px; }
#report .tiles small { color: var(--muted); font-size: 10px; }
#report .strains { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
#report .strains span { font-size: 11px; padding: 2px 8px 2px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
#report .strains span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--c); }
#report .btns { display: flex; gap: 6px; margin-top: 10px; }
#report .btns button {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid var(--accent-line);
  background: var(--accent-bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* Full-screen overlays (aftermath.js, replay.js): replay, before/after, photo mode. */
.overlay { position: fixed; inset: 0; z-index: 40; background: #000; touch-action: none; }
.overlay .view { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.overlay.photo .view { cursor: grab; }
.overlay.compare .view { cursor: ew-resize; }
.overlay .ovtop, .overlay .ovbot {
  position: absolute;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: rgba(10, 12, 28, 0.78);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.25s, transform 0.25s;
}
.overlay .ovtop { top: calc(env(safe-area-inset-top) + 8px); }
.overlay .ovbot { bottom: calc(env(safe-area-inset-bottom) + 8px); }
.overlay .ovtop b { white-space: nowrap; }
.overlay .ovtop .info { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay.bare .ovtop { opacity: 0; transform: translateY(-20px); pointer-events: none; }
.overlay.bare .ovbot { opacity: 0; transform: translateY(20px); pointer-events: none; }
.overlay .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.overlay .chip, .overlay .ovbot > button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.overlay .chip.on { border-color: var(--accent-line); background: var(--accent-bg); }
.overlay .ovbot > button.pri { margin-left: auto; border-color: var(--accent-line); background: var(--accent); color: #fff; font-weight: 700; }
.overlay .ovbot .hint { flex: 1; color: var(--muted); font-size: 12px; }
.overlay .play { width: 38px; height: 38px; padding: 0 !important; font-size: 16px !important; }
.overlay .scrub { position: relative; flex: 1; min-width: 140px; height: 38px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); cursor: pointer; }
.overlay .scrub canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.overlay .scrub .head { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 8px rgba(255, 255, 255, 0.8); }
.overlay .time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 40px; }
.overlay.flash::after { content: ""; position: absolute; inset: 0; background: #fff; pointer-events: none; animation: shutter 0.45s ease-out forwards; }
@keyframes shutter { from { opacity: 0.85; } to { opacity: 0; } }
body.covered #hud, body.covered #toolbar, body.covered #hotbar, body.covered #creatures, body.covered #hint, body.covered #notes, body.covered #cursor { visibility: hidden; }

/* Screensaver: the UI dims away while the white cells drift. */
#hud, #toolbar, #hotbar, #creatures, #hint, #notes { transition: opacity 1s; }
body.saver #hud, body.saver #toolbar, body.saver #hotbar, body.saver #creatures, body.saver #hint, body.saver #notes { opacity: 0.06; }

@media (max-width: 760px) {
  #notes { left: 8px; right: 8px; width: auto; top: calc(env(safe-area-inset-top) + 92px); }
  #startMenu { bottom: calc(env(safe-area-inset-bottom) + 76px); }
  #report { bottom: calc(env(safe-area-inset-bottom) + 84px); }
  .overlay .ovbot { gap: 6px; }
  .overlay .scrub { flex-basis: 100%; order: 5; }
}

/* ---- Hotbar (hotbar.js): every tool, one page per category ------------------------- */
#hotbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 82px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 5px 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  width: min(600px, calc(100% - 16px));
  box-sizing: border-box;
}
#hotbar .hchips { display: flex; justify-content: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#hotbar .hchips::-webkit-scrollbar { display: none; }
#hotbar .hchip {
  flex: 0 0 auto; min-height: 26px; padding: 2px 10px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
#hotbar .hchip i { font-style: normal; opacity: 0.55; font-size: 9px; margin-right: 4px; }
#hotbar .hchip.on { color: var(--text); background: var(--accent-bg); border-color: var(--accent-line); }
#hotbar .hrow { display: flex; align-items: center; gap: 3px; }
#hotbar .hnav {
  flex: 0 0 22px; height: 52px; padding: 0; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
}
#hotbar .hnav:disabled { opacity: 0.2; cursor: default; }
#hotbar .hpages {
  flex: 1 1 auto; min-width: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
#hotbar .hpages::-webkit-scrollbar { display: none; }
#hotbar .hpage {
  flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 4px;
}
#hotbar .slot {
  position: relative;
  width: 54px;
  height: 56px;
  flex-shrink: 0;
  padding: 2px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  touch-action: pan-x;
  -webkit-touch-callout: none;
  user-select: none;
}
#hotbar .slot canvas { width: 36px; height: 36px; pointer-events: none; }
#hotbar .slot .nm { font-size: 8.5px; line-height: 1; color: var(--muted); white-space: nowrap; max-width: 52px; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#hotbar .slot:hover { background: rgba(255, 255, 255, 0.09); }
#hotbar .slot.on { background: var(--accent-bg); border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line) inset; }
#hotbar .slot.on .nm { color: var(--text); }
#hotbar .slot.dry canvas { opacity: 0.45; }
#hotbar .slot .cost { position: absolute; right: 3px; top: 1px; font-size: 9px; color: #fde047; opacity: 0.85; }
#hotbar .slot .sbar { position: absolute; left: 5px; right: 5px; bottom: 2px; height: 3px; background: rgba(0, 0, 0, 0.5); border-radius: 2px; overflow: hidden; }
#hotbar .slot .sbar i { display: block; height: 100%; width: 100%; background: #5fd38a; }
#hotbar .slot .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.5); pointer-events: none; }

#hbTip { font-size: 12px; line-height: 1.35; }
#hbTip {
  position: fixed;
  width: 260px;
  padding: 8px 10px;
  background: rgba(11, 16, 32, 0.94);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  pointer-events: none;
  z-index: 16;
}
#hbTip[hidden] { display: none; }
#hbTip p p { margin: 4px 0 0; }
#hbTip em em { opacity: 0.6; font-style: normal; font-size: 11px; }
#hbTip .good { color: #7fe0a0; }
#hbTip .bad { color: #ffa08a; }
#hbTip .dim { color: var(--muted); font-size: 11px; }

@media (max-width: 520px) {
  #hotbar { padding: 4px; }
  #hotbar .slot { width: 46px; height: 50px; }
  #hotbar .slot canvas { width: 32px; height: 32px; }
  #hotbar .slot .nm { font-size: 8px; max-width: 44px; }
  #hotbar .hnav { flex-basis: 18px; }
}
