* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #f0f0f0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Times New Roman', 'Georgia', serif;
  overflow: hidden;
}

#game-wrapper {
  position: relative;
  width: min(1000px, calc(100vw - 4px));
  aspect-ratio: 10 / 7;
  max-height: calc(100vh - 4px);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: none;
  outline: 2px solid #333;
  cursor: crosshair;
}
#gameCanvas.colorblind-protanopia { filter: url('#cb-protanopia'); }
#gameCanvas.colorblind-deuteranopia { filter: url('#cb-deuteranopia'); }
#gameCanvas.colorblind-tritanopia { filter: url('#cb-tritanopia'); }

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  pointer-events: none;
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  will-change: transform;
  contain: layout style;
}

#hud.hidden {
  display: none !important;
}

/* 2026-08-07 (game-improvement): the Text Size setting (state.textScale,
   0.8-2.0, canvas-only before) now also scales the DOM HUD text via a CSS
   custom property — set live from ui.js on setting change. */
#hud {
  --hud-scale: 1;
}
#player-hp, #player-value {
  font-size: calc(11px * var(--hud-scale, 1));
}

.hud-panel {
  background: rgba(250, 249, 246, 0.94);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid #333333;
  border-radius: 0;
  padding: 8px 12px;
  color: #111111;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.08);
}

#hud-top-left {
  grid-column: 1;
  grid-row: 1;
}

#hp-bar-wrapper, #value-bar-wrapper {
  position: relative;
  margin-bottom: 4px;
}

#hp-bar-container {
  position: relative;
  width: 100%;
  height: 6px;
  background: #e5e2db;
  border: 1px solid #777777;
  overflow: hidden;
}

@keyframes hp-low-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 8px rgba(139, 38, 62, 0.5); }
}

#hp-bar-container.low-hp {
  animation: hp-low-pulse 1s ease-in-out infinite;
}

#hp-bar {
  height: 100%;
  width: 100%;
  background: #8b263e;
}

#shield-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 0%;
  background: #4a6fa5;
  opacity: 0.85;
}

#player-hp {
  font-family: 'Times New Roman', serif;
  font-size: 11px;
  font-style: italic;
  color: #444444;
  display: block;
  margin-top: 1px;
  text-align: right;
}

#value-bar-container {
  width: 100%;
  height: 5px;
  background: #e5e2db;
  border: 1px solid #777777;
  overflow: hidden;
}

#value-bar {
  height: 100%;
  width: 0%;
  background: #8c733e;
}

#player-value {
  font-family: 'Times New Roman', serif;
  font-size: 11px;
  font-style: italic;
  color: #444444;
  display: block;
  margin-top: 1px;
  text-align: right;
}

.hidden { display: none !important; }

@keyframes title-fade-in {
  from { opacity: 0; transform: translateY(-30px); letter-spacing: 25px; }
  to { opacity: 1; transform: translateY(0); letter-spacing: 12px; }
}

@keyframes subtitle-reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tagline-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes btn-border-pulse {
  0%, 100% { border-color: #333; box-shadow: none; }
  50% { border-color: #111; box-shadow: 0 0 12px rgba(0,0,0,0.08); }
}

#start-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(250, 249, 246, 0.96);
  pointer-events: all;
  box-sizing: border-box;
  padding: 20px 40px;
}

#start-screen h1 {
  font-size: 72px;
  font-family: 'Times New Roman', serif;
  color: #111;
  letter-spacing: 12px;
  margin: 0;
  animation: title-fade-in 1.5s ease-out both;
}

#start-screen .subtitle {
  font-size: 20px;
  font-style: italic;
  color: #555;
  margin-top: 5px;
  margin-bottom: 2px;
  animation: subtitle-reveal 1s ease-out 0.8s both;
}

#start-screen .tagline {
  font-size: 13px;
  color: #666;
  margin-bottom: 0;
  font-style: italic;
  animation: tagline-reveal 1.5s ease-out 1.2s both;
}

.title-group {
  text-align: center;
  margin-bottom: 20px;
}

.start-main-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 30px;
  width: min(900px, 100%);
  max-height: 420px;
  box-sizing: border-box;
}

/* Responsive start screen (2026-08-07): below 1000px viewport the fixed
   900px row clipped on small screens — min(900px, 100%) lets it shrink,
   and the tighter gap/padding keep the ledger look at reduced width. */
@media (max-width: 1000px) {
  .start-main-row { gap: 16px; }
  .controls-column { padding: 10px 12px; }
}

/* OPERATORS explainer strip (2026-08-07): start-screen onboarding — the six
   stance entries from data/operators.js, ledger style (serif, ink on paper,
   thin border, gold symbols). Sits directly below the controls/settings row
   (a third flex column would squeeze the settings column and overflow the
   five mode buttons at the fixed 900px row width). */
.operators-strip {
  width: min(900px, 100%);
  box-sizing: border-box;
  margin-top: 14px;
  border: 1px solid #333;
  background: rgba(255, 255, 255, 0.4);
  padding: 10px 18px 12px;
}
.operators-strip h3 {
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 6px;
  color: #111;
}
.operators-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 18px;
  font-size: 11px;
  color: #444;
  line-height: 1.5;
  text-align: left;
}
.operators-grid p {
  margin: 2px 0;
}
.op-symbol {
  font-family: 'Times New Roman', serif;
  color: #b8953a;
  font-weight: bold;
  font-size: 13px;
}
.operators-grid strong {
  font-family: 'Times New Roman', serif;
  color: #111;
}

/* Controls hint line (2026-08-07): stance hotkeys summary on the start
   screen, styled as a muted-gold ledger footnote. */
.controls-hint {
  font-style: italic;
  color: #8c733e;
}

.controls-column {
  flex: 1;
  border: 1px solid #333;
  padding: 15px 20px;
  background: rgba(255,255,255,0.4);
  display: flex;
  flex-direction: column;
}

.controls-column h3 {
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 6px;
  color: #111;
}

.controls-info {
  font-size: 12px;
  color: #444;
  line-height: 1.7;
  text-align: left;
}

.controls-info p {
  margin: 6px 0;
  border-bottom: 1px dashed rgba(0,0,0,0.05);
  padding-bottom: 3px;
}

.controls-info strong {
  font-family: 'Times New Roman', serif;
  color: #111;
  font-size: 12px;
}

.settings-actions-column {
  flex: 1.1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid #333;
  padding: 15px 20px;
  background: rgba(255,255,255,0.4);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-group label {
  font-family: 'Times New Roman', serif;
  font-size: 12px;
  color: #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.settings-group select {
  font-family: 'Times New Roman', serif;
  font-size: 11px;
  color: #111;
  background: #faf9f6;
  border: 1px solid #777;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  min-width: 120px;
}
.settings-group select:hover {
  border-color: #111;
}

.dropdown-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.dropdown-row label {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #555;
}

.dropdown-row select {
  font-family: 'Times New Roman', serif;
  font-size: 10px;
  padding: 3px;
  border: 1px solid #aaa;
  background: #fff;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #555;
}
/* (GoUI 2026-08-11): .settings-group label forces justify-content:
   space-between on every label, so the a11y checkboxes were pushed to the
   far edge of their labels with a huge dead gap ([☐]······Reduce motion).
   Toggle labels pin the checkbox directly beside its text instead. */
.toggle-row label {
  justify-content: flex-start;
  gap: 6px;
  width: auto;
}
#show-key-bindings { white-space: nowrap; }

/* Volume slider (2026-08-11): the native range input renders with the
   browser's default blue accent, breaking the monochrome ledger palette.
   accent-color tints both track fill and thumb in ink gray. */
input[type="range"] {
  accent-color: #333;
  cursor: pointer;
}

/* OPERATORS strip (2026-08-11): six entries in a 3×2 grid read crowded at
   the inherited base size — shrink one notch, loosen the gaps, mute to the
   ledger footnote tone. */
.operators-grid {
  font-size: 11px;
  color: #444;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 5px;
}

.sub-actions {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.sub-actions button {
  flex: 1;
  font-family: 'Times New Roman', serif;
  font-size: 10px;
  padding: 6px 2px;
  border: 1px solid #444;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
  color: #222;
}

.sub-actions button:hover {
  background: #eae9e5;
}

#start-btn, #restart-btn {
  font-family: 'Times New Roman', serif;
  font-size: 20px;
  padding: 10px;
  background: #111;
  color: #fff;
  border: 1px solid #111;
  cursor: pointer;
  letter-spacing: 4px;
  pointer-events: all;
  transition: background 0.2s;
}

#start-btn {
  animation: btn-border-pulse 3s ease-in-out infinite;
  transition: all 0.3s ease;
}

#start-btn:hover {
  transform: translateY(-1px);
  border-color: #000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  background: #333;
}

#restart-btn:hover {
  background: #333;
}

#game-over {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255,255,255,0.93);
  pointer-events: all;
}

#game-over h1 {
  font-size: 72px;
  font-family: 'Times New Roman', serif;
  color: #111;
  letter-spacing: 8px;
  margin-bottom: 10px;
}

#game-over p {
  font-size: 20px;
  color: #555;
  margin: 5px 0;
}

#game-over .epilogue-line {
  font-size: 15px;
  color: #999;
  font-style: italic;
  margin-bottom: 20px;
  max-width: 500px;
  text-align: center;
}

#epilogue-stats {
  margin-bottom: 5px;
}

#game-over .high-score-text {
  font-size: 18px;
  color: #888;
  font-style: italic;
  margin-top: 10px;
}

#game-over button {
  margin-top: 30px;
}

.hidden { display: none !important; }

/* Ledger Fragment Codex */
.codex-btn {
  font-family: 'Times New Roman', serif;
  font-size: 14px;
  padding: 6px 24px;
  background: transparent;
  color: #888;
  border: 1px solid #ccc;
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 3px;
  pointer-events: all;
  transition: border-color 0.2s, color 0.2s;
}
.codex-btn:hover { border-color: #555; color: #333; }

#codex-viewer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.96);
  pointer-events: all;
  padding: 40px;
  overflow-y: auto;
  z-index: 20;
}
#codex-viewer.hidden { display: none !important; }
#codex-viewer:not(.hidden) { display: flex; }
#codex-viewer h1 {
  font-size: 36px;
  color: #111;
  letter-spacing: 12px;
  margin-bottom: 20px;
  font-family: 'Times New Roman', serif;
}
#codex-entries {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.codex-entry {
  padding: 8px 16px;
  border-left: 2px solid #ddd;
  font-family: 'Times New Roman', serif;
}
.codex-entry.collected .codex-title { color: #333; }
.codex-entry.collected .codex-text { color: #887755; font-style: italic; }
.codex-entry.uncollected .codex-title { color: #ccc; }
.codex-entry.uncollected .codex-text { color: #ddd; }
.codex-title { font-size: 14px; font-weight: bold; margin-bottom: 2px; }
.codex-text { font-size: 12px; }
#codex-close-btn {
  font-family: 'Times New Roman', serif;
  font-size: 16px;
  padding: 6px 32px;
  background: transparent;
  color: #555;
  border: 1px solid #999;
  cursor: pointer;
  pointer-events: all;
}
#codex-close-btn:hover { background: #f5f5f5; }

/* Character Select
   (GoCharSel 2026-08-11) Rework for the user complaint "char-select looks
   bad": the picker (13 digit cards + 10 theorem cards) outgrew the fixed
   10:7 wrapper (~700px tall on every desktop), so the old
   justify-content:center clipped the SELECT DIGIT title and the BACK button
   off-screen with NO way to scroll (body overflow:hidden). Fixes:
     - overflow-y:auto + auto-margin safe centering: the stack centers when
       it fits and scrolls from the top when it overflows (a plain centered
       flex clips the scrollable top edge — the classic flexbox overflow
       bug).
     - paper/ink ledger palette matching #start-screen (rgba(250,249,246))
       instead of flat white; compact 126px border-box cards (7 per row) so
       two rows carry all 13 digits and the stack fits the 700px wrapper.
     - typographic compaction (28px title, 13px names, 10px desc) keeps the
       whole picker on one screen; hover/selected states in ink. */
#character-select {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cfc8b8 transparent;
  background: rgba(250,249,246,0.96);
  pointer-events: all;
  z-index: 15;
  box-sizing: border-box;
  padding: 12px 20px;
}
/* Safe centering: when the stack is shorter than the wrapper the auto
   margins absorb the free space (centered); when it overflows they collapse
   to 0 so scrolling starts at the top instead of clipping it. */
#character-select > :first-child { margin-top: auto; }
#character-select > :last-child { margin-bottom: auto; }
#character-select::-webkit-scrollbar { width: 8px; }
#character-select::-webkit-scrollbar-thumb { background: #cfc8b8; }
#character-select::-webkit-scrollbar-track { background: transparent; }
#character-select.hidden { display: none !important; }
#character-select:not(.hidden) { display: flex; }
#character-select h1 {
  font-size: 27px;
  letter-spacing: 9px;
  color: #111;
  margin-bottom: 2px;
  font-family: 'Times New Roman', serif;
}
.char-select-subtitle {
  font-size: 14px;
  color: #888;
  font-style: italic;
  margin-bottom: 24px;
  font-family: 'Times New Roman', serif;
}
/* Scoped override: the shared .char-select-subtitle is also used by the
   leaderboard viewer; only tighten it on the char-select screen. */
#character-select .char-select-subtitle {
  color: #777;
  margin-bottom: 8px;
}
#character-cards {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 8px;
}
.char-card {
  width: 126px;
  padding: 9px 8px;
  border: 1px solid #cfc8b8;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  background: #fff;
  pointer-events: all;
  font-family: 'Times New Roman', serif;
}
.char-card:hover { border-color: #111; transform: translateY(-3px); }
.char-card.locked { opacity: 0.45; cursor: default; pointer-events: none; }
.char-card.selected { border-color: #111; background: #efe9dc; box-shadow: 0 0 0 1px #111; }
.char-card-symbol { font-size: 26px; color: #111; margin-bottom: 3px; }
.char-card-name { font-size: 13px; font-weight: bold; color: #111; margin-bottom: 3px; letter-spacing: 0.5px; }
.char-card-desc { font-size: 10px; color: #777; font-style: italic; line-height: 1.3; }
/* (GoCharSel 2026-08-11) stat strip added by renderCharacterSelect: shows
   the starting value + absorb multiplier each digit brings to a run. */
.char-card-stat { font-size: 9.5px; color: #555; margin-top: 5px; letter-spacing: 0.4px; }
.char-card-unlock { font-size: 9px; color: #999; margin-top: 4px; font-style: italic; }
.char-best-wave { font-size: 12px; color: #777; font-style: italic; margin-bottom: 4px; font-family: 'Times New Roman', serif; }
/* Theorem picker lives on the same screen: narrower scoped cards so 5 fit a
   row inside the 760px panel. */
#theorem-panel {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 6px;
}
#theorem-panel h3 {
  font-size: 13px;
  color: #111;
  letter-spacing: 8px;
  margin: 4px 0 3px 0;
  font-family: 'Times New Roman', serif;
}
#theorem-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
#theorem-cards .char-card {
  width: 118px;
  padding: 7px 8px;
}
#theorem-cards .char-card-name { font-size: 11px; }
#theorem-cards .char-card-desc { font-size: 9px; }
#char-back-btn { margin-top: 8px; margin-bottom: 4px; }

/* Achievements */
#achievements-viewer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.96);
  pointer-events: all;
  padding: 40px;
  overflow-y: auto;
  z-index: 20;
}
#achievements-viewer.hidden { display: none !important; }
#achievements-viewer:not(.hidden) { display: flex; }
#achievements-viewer h1 {
  font-size: 36px;
  color: #111;
  letter-spacing: 12px;
  margin-bottom: 10px;
  font-family: 'Times New Roman', serif;
}
.achievement-count {
  font-size: 14px;
  color: #888;
  font-style: italic;
  margin-bottom: 16px;
  font-family: 'Times New Roman', serif;
}
#achievement-list {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}
.achievement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-left: 2px solid #eee;
  font-family: 'Times New Roman', serif;
}
.achievement-item.unlocked { border-left-color: #b8953a; }
.achievement-item.locked { opacity: 0.4; }
.achievement-icon { font-size: 18px; width: 24px; text-align: center; }
.achievement-info { flex: 1; }
.achievement-name { font-size: 14px; font-weight: bold; color: #333; }
.achievement-desc { font-size: 11px; color: #888; font-style: italic; }
#achievements-close-btn {
  font-family: 'Times New Roman', serif;
  font-size: 16px;
  padding: 6px 32px;
  background: transparent;
  color: #555;
  border: 1px solid #999;
  cursor: pointer;
  pointer-events: all;
}
#achievements-close-btn:hover { background: #f5f5f5; }

/* Game mode select */
#mode-select { display: flex; gap: 8px; margin-bottom: 16px; }
.mode-btn {
  font-family: 'Times New Roman', serif;
  font-size: 13px;
  padding: 6px 18px;
  background: transparent;
  color: #bbb;
  border: 1px solid #ddd;
  cursor: pointer;
  pointer-events: all;
  transition: border-color 0.2s, color 0.2s;
}
.mode-btn:hover { border-color: #999; color: #666; }
.mode-btn.selected { border-color: #555; color: #333; background: #f8f8f8; }
#daily-seed-display {
  font-family: 'Times New Roman', serif;
  font-size: 11px;
  color: #aaa;
  margin-bottom: 12px;
  font-style: italic;
}

.codex-count {
  font-size: 14px;
  color: #888;
  margin-bottom: 16px;
  font-style: italic;
}

.key-binding-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
}
.key-binding-keys { display: flex; gap: 4px; }
.key-binding-btn {
  min-width: 60px;
  padding: 4px 8px;
  border: 1px solid #333;
  background: #fff;
  cursor: pointer;
  font-family: 'Times New Roman', serif;
  font-size: 13px;
}
.key-binding-btn.capturing {
  background: #ffd700;
  border-color: #000;
}
#key-bindings-panel {
  position: absolute;
  top: 8%; left: 8%;
  width: 84%; height: 84%;
  background: rgba(250, 249, 246, 0.99);
  border: 1px solid #333;
  padding: 20px;
  box-sizing: border-box;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto;
}
#key-bindings-panel h3 { margin: 0 0 8px 0; font-size: 16px; }
#reset-keys-btn { font-size: 12px; margin-left: 8px; }
#show-key-bindings {
  font-family: 'Times New Roman', serif;
  font-size: 12px;
  padding: 4px 16px;
  background: transparent;
  color: #888;
  border: 1px solid #ccc;
  cursor: pointer;
  margin: 4px auto;
  pointer-events: all;
}
#show-key-bindings:hover { border-color: #555; color: #333; }

/* Boss nameplate */
#boss-nameplate {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.85);
  border: 1px solid #bbb;
  padding: 6px 20px;
  pointer-events: none;
  z-index: 5;
}
#boss-nameplate:not(.hidden) { display: flex; }
#boss-nameplate-symbol {
  font-size: calc(28px * var(--hud-scale, 1));
  font-family: 'Times New Roman', serif;
  color: #333;
}
#boss-nameplate-name {
  font-size: calc(16px * var(--hud-scale, 1));
  font-weight: bold;
  font-family: 'Times New Roman', serif;
  color: #111;
}

/* Boss HP bar (2026-08-07): thin ledger bar, top-center under the boss
   nameplate. #boss-hp-container is NESTED inside #boss-nameplate (which is
   itself absolute at top:60px), so this absolute offset is relative to the
   nameplate: top:52px clears the nameplate's ~46px content box (no visual
   collision), keeping the bar near the top center. The nameplate's z-index:5
   stacking context sits above #hud, so the bar renders over the transient
   wave event banner (top:14%, z-index:30 inside #hud) when both are live. */
#boss-hp-container {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 60vw);
  height: 10px;
  border: 1px solid #333;
  background: rgba(255, 255, 255, 0.4);
  margin: 0 auto;
  z-index: 20;
}
#boss-hp-bar {
  height: 100%;
  width: 100%;
  background: #8b263e;
  transition: width 0.15s linear;
}

/* Pause screen (element + hidden toggle added by a separate agent) */
#pause-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(250, 249, 246, 0.92);
  pointer-events: all;
  z-index: 50;
  font-family: 'Times New Roman', serif;
}
#pause-screen h1 {
  font-size: 48px;
  letter-spacing: 12px;
  color: #111;
  margin: 0;
}
#pause-screen p {
  font-style: italic;
  color: #888;
}
/* Pause menu buttons (2026-08-07): RESTART RUN / QUIT TO MENU share the
   RESUME ledger-button style; only their stacking margin differs. */
#resume-btn, #btn-restart, #btn-quit {
  margin-top: 20px;
  font-family: 'Times New Roman', serif;
  font-size: 16px;
  padding: 8px 32px;
  background: #111;
  color: #fff;
  border: none;
  cursor: pointer;
  letter-spacing: 3px;
}
#btn-restart, #btn-quit {
  margin-top: 8px;
}

/* ── Wave-start ink-stamp banner (2026-08-11) ──
   "WAVE N" stamps in at the start of each active wave. Pure CSS animation:
   stamp-in → hold → fade, ending opacity:0 forwards so no JS timer is
   needed. ui.js restarts it by toggling the .stamp-in class with a reflow.
   #hud is pointer-events:none, so the banner never blocks input. */
#wave-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-family: 'Times New Roman', serif;
  font-size: 46px;
  font-weight: bold;
  letter-spacing: 14px;
  color: #111111;
  text-align: center;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
  /* doubled ledger-stamp frame */
  border: 2px solid rgba(17, 17, 17, 0.9);
  outline: 1px solid rgba(17, 17, 17, 0.9);
  outline-offset: 4px;
  padding: 10px 26px;
}
#wave-banner.stamp-in {
  animation: wave-stamp 1.9s ease forwards;
}
@keyframes wave-stamp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.35); letter-spacing: 26px; }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1);    letter-spacing: 14px; }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Menu transitions (2026-08-11) ──
   Screens previously snapped in/out with instant classList toggles (art
   audit: "no transitions anywhere"). A shared screen-level fade keeps the
   ledger doc aesthetic without per-element animation risk. */
#start-screen, #character-select, #game-over, #pause-screen,
#achievements-viewer, #leaderboard-viewer, #exchange-viewer, #codex-viewer {
  animation: screen-fade-in 0.18s ease-out;
}
@keyframes screen-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* In-game fade for the HUD when a run ends / restarts (same audit). The
   .hidden rule forces display:none !important, so a pure opacity transition
   can never animate — the rule was dead (WireAudit 2026-08-11). */
