/* Cyber Fox — UI styles.
   The #ui layer is laid out in virtual pixels (1280×720) and scaled to fit the
   screen, so every size here is in game units, not CSS pixels on the device.
   On a typical phone in landscape, 1 virtual px ≈ 0.55 CSS px. */

:root {
  --font: ui-rounded, "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  /* Palette tokens. Chapter palettes overwrite these at runtime (src/render/palette.js). */
  --letterbox: #2a211b;
  --bg: #f7efe5;
  --panel: rgba(255, 250, 244, 0.95);
  --panel-solid: #fffaf4;
  --panel-edge: #e3d2c2;
  --text: #4a3b33;
  --muted: #8c7a6e;
  --accent: #f2a65a;
  --accent-edge: #d98a3d;
  --accent-text: #ffffff;
  --btn: #ffffff;
  --btn-edge: #dccabb;
  --danger: #e2626b;
  --warn: #f2b84b;
  --good: #6cbf8b;
  --shadow: 0 8px 22px rgba(90, 60, 40, 0.22);
  --scrim: rgba(52, 36, 26, 0.5);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--letterbox);
  color: var(--text);
  font-family: var(--font);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stage {
  position: absolute;
  overflow: hidden;
  background: var(--bg);
}

#game {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
}

#ui {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
  pointer-events: none;
}

#ui button, #ui input, #ui .interactive { pointer-events: auto; }

/* ---------- Rotate prompt (phones held upright) ---------- */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: var(--letterbox);
}
#rotate .rotate-icon { font-size: 56px; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 64px;
  min-width: 64px;
  padding: 0 24px;
  border-radius: 18px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  color: var(--text);
  font: 800 26px/1 var(--font);
  box-shadow: 0 4px 0 var(--btn-edge);
  cursor: pointer;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent-edge);
  color: var(--accent-text);
  box-shadow: 0 4px 0 var(--accent-edge);
}
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent-edge); }
.btn.danger { color: var(--danger); }
.btn.unaffordable { opacity: 0.5; }
.btn.big { min-height: 84px; padding: 0 56px; font-size: 36px; border-radius: 24px; }
.btn.icon { padding: 0; width: 64px; font-size: 26px; }

/* ---------- Menu ---------- */
.menu {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 40px 64px 36px;
  border-radius: 32px;
  background: var(--panel);
  border: 3px solid var(--panel-edge);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.menu .kicker {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.menu .title {
  margin: 0;
  font-size: 104px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}
.menu .tagline { margin: 0 0 8px; font-size: 24px; color: var(--muted); font-weight: 700; }
.seed-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.seed-row label { font-size: 20px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.seed-row input {
  height: 64px;
  width: 240px;
  padding: 0 16px;
  border-radius: 16px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  color: var(--text);
  font: 700 26px var(--font);
  user-select: text;
  -webkit-user-select: text;
}
.menu-stats { font-size: 20px; color: var(--muted); font-weight: 700; min-height: 24px; }

.menu-card > canvas { margin-bottom: -6px; }
.menu-card .actions { display: flex; gap: 18px; }

/* ---------- Full screens (chapter select, loadout) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 28px 20px;
  gap: 14px;
}
.screen-header { display: flex; align-items: center; gap: 22px; pointer-events: auto; }
.screen-header h2 { margin: 0; font-size: 40px; font-weight: 900; color: var(--text); }
.screen-footer { display: flex; align-items: center; justify-content: flex-end; gap: 20px; margin-top: auto; pointer-events: auto; }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  pointer-events: auto;
}
.chapter-card {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 214px;
  padding: 16px 18px;
  border-radius: 26px;
  border: 3px solid var(--panel-edge);
  background: var(--panel-solid);
  box-shadow: 0 5px 0 var(--panel-edge);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}
.chapter-card:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--panel-edge); }
.chapter-card:disabled { opacity: 0.55; cursor: default; }
.chapter-card.done { border-color: var(--good); box-shadow: 0 5px 0 var(--good); }
.chapter-card canvas { flex: none; }
.portrait-placeholder {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  font-size: 40px;
  color: var(--muted);
}
.chapter-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chapter-num { font-size: 18px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.chapter-name { font-size: 30px; font-weight: 900; line-height: 1.05; }
.chapter-name.hidden-name { filter: blur(7px); user-select: none; }
.chapter-setting { font-size: 19px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.chapter-dots { display: flex; gap: 8px; margin-top: 4px; }
.chapter-dots span { width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, 0.12); }
.chapter-dots span.on { background: var(--good); }

.overlay .card.level-picker { width: 860px; }
.level-row { display: flex; gap: 18px; justify-content: center; margin-top: 18px; }
.level-btn {
  width: 240px;
  height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 24px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  box-shadow: 0 5px 0 var(--btn-edge);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
}
.level-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--btn-edge); }
.level-btn:disabled { opacity: 0.5; cursor: default; }
.level-btn.done { border-color: var(--good); box-shadow: 0 5px 0 var(--good); }
.level-btn .num { font-size: 56px; font-weight: 900; line-height: 1; }
.level-btn .lbl { font-size: 22px; font-weight: 800; }
.level-btn .best { font-size: 18px; font-weight: 700; color: var(--muted); }

/* ---------- Story card ---------- */
.overlay .card.story-card { width: 1060px; display: flex; align-items: center; gap: 40px; text-align: left; }
.story-portrait { flex: none; }
.story-text h1 { font-size: 46px; }
.overlay .story-text p { font-size: 27px; color: var(--text); opacity: 0; animation: line-in 0.5s ease-out forwards; }
.story-text .btn { margin-top: 22px; }
.overlay .story-where { margin: -6px 0 10px; font-size: 22px; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-edge); }
@keyframes line-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Loadout ---------- */
.screen.loadout { padding-bottom: 28px; } /* button shadow included, so the bottom margin matches the sides */
.loadout-counter { font-size: 24px; font-weight: 800; color: var(--muted); }
.loadout-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; pointer-events: auto; }
.loadout-card {
  height: 216px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: 22px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  box-shadow: 0 5px 0 var(--btn-edge);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
}
.loadout-card canvas { width: 68px; height: 68px; flex: none; }
.loadout-card .name { font-size: 20px; font-weight: 900; line-height: 1.1; }
.loadout-card .desc { font-size: 15px; font-weight: 700; color: var(--muted); line-height: 1.22; }
.loadout-card.chosen { border-color: var(--accent-edge); box-shadow: 0 5px 0 var(--accent-edge); background: var(--panel-solid); }
.loadout-card.chosen .name::before { content: '✓ '; color: var(--accent-edge); }
.loadout-card:disabled { opacity: 0.45; cursor: default; }
.loadout-card .name.hidden-name { filter: blur(6px); user-select: none; }
.loadout-card canvas.hidden-icon { filter: blur(6px) grayscale(1); }
.threat-row { flex: 1; font-size: 17px; font-weight: 800; line-height: 1.3; color: var(--muted); }
.threat-row.warn { color: var(--danger); }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 80px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px 0 20px;
  background: var(--panel);
  border-bottom: 3px solid var(--panel-edge);
  pointer-events: auto;
}
.stat { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.stat .label {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .value { font-size: 32px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.stat.budget .value { min-width: 110px; }
.uptime-row { display: flex; align-items: center; gap: 10px; }
.uptime .bar {
  width: 150px;
  height: 20px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.09);
  overflow: hidden;
}
.uptime .fill { height: 100%; width: 100%; background: var(--good); transition: width 0.2s, background-color 0.3s; }
.uptime .value { min-width: 84px; }
.hud .spacer { flex: 1; }
.hud .btn.next { min-width: 200px; }
.hud .abilities { display: flex; gap: 10px; }
.hud .btn.ability { min-width: 150px; max-width: 190px; overflow: hidden; padding: 0 12px; font-size: 20px; line-height: 1.05; white-space: normal; }
.hud .btn.ability.ally .charge { background: #e05a7a; }

/* Two cores (Chapter 3): stacked mini bars with names. */
.uptime.multi .label { display: none; }
.uptime.multi { gap: 4px; }
.uptime.multi .uptime-row { gap: 6px; }
.uptime.multi .core-name { width: 66px; font-size: 16px; font-weight: 900; color: var(--muted); }
.uptime.multi .bar { width: 96px; height: 13px; }
.uptime.multi .value { font-size: 20px; min-width: 50px; }

/* Upgrade cards */
.card-choice { display: flex; flex-direction: column; align-items: center; gap: 22px; pointer-events: auto; }
.card-choice h1 { margin: 0; font-size: 52px; font-weight: 900; color: #fff; text-shadow: 0 3px 12px rgba(0, 0, 0, 0.5); }
.card-row { display: flex; gap: 22px; }
.upgrade-card {
  width: 330px;
  min-height: 250px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  border-radius: 26px;
  border: 4px solid var(--accent-edge);
  background: var(--panel-solid);
  box-shadow: 0 8px 0 var(--accent-edge), var(--shadow);
  color: var(--text);
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
  animation: pop-in 0.25s ease-out;
}
.upgrade-card:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--accent-edge); }
.upgrade-card .uc-name { font-size: 30px; font-weight: 900; line-height: 1.1; color: var(--accent-edge); }
.upgrade-card .uc-desc { font-size: 22px; font-weight: 700; line-height: 1.3; color: var(--text); }

/* Cameo: a hero pops in at the bottom-left for a moment. */
.cameo {
  position: absolute;
  left: 16px;
  bottom: 40px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 560px;
  padding: 10px 20px 10px 10px;
  border-radius: 999px 24px 24px 999px;
  background: var(--panel-solid);
  border: 3px solid var(--accent-edge);
  box-shadow: var(--shadow);
  animation: cameo-in 0.35s ease-out;
  transition: opacity 0.5s, transform 0.5s;
}
.cameo canvas { flex: none; }
.cameo .c-title { font-size: 26px; font-weight: 900; color: var(--accent-edge); }
.cameo .c-text { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.25; }
.cameo.out { opacity: 0; transform: translateX(-30px); }
@keyframes cameo-in { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
.btn.sneaky { background: #ffd166; border-color: #c99a2e; box-shadow: 0 4px 0 #c99a2e; color: #3b2a10; }
.btn.ability .charge {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--charge, 0%);
  background: var(--accent);
  opacity: 0.28;
  transition: width 0.25s linear;
}
.btn.ability .name { position: relative; }
.btn.ability:disabled { opacity: 1; color: var(--muted); }
.btn.ability.ready { border-color: var(--accent-edge); box-shadow: 0 4px 0 var(--accent-edge); animation: ready-glow 1.2s ease-in-out infinite; }
.btn.ability.ready .charge { opacity: 0.5; }
@keyframes ready-glow { 50% { transform: translateY(-2px); filter: brightness(1.08); } }
.hud .btn { min-height: 66px; position: relative; }
.hud .btn.icon { width: 72px; }
/* Invisible padding so near-misses on a small phone still count. */
.hud .btn::after { content: ''; position: absolute; inset: -7px -6px; }

.seed-tag {
  position: absolute;
  left: 10px;
  bottom: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.8;
}

.debug {
  position: absolute;
  right: 10px;
  bottom: 6px;
  font: 700 18px ui-monospace, Consolas, monospace;
  color: var(--text);
  background: var(--panel);
  padding: 4px 8px;
  border-radius: 8px;
}

/* ---------- Build menu and tower panel ---------- */
.popup {
  position: absolute;
  padding: 12px;
  border-radius: 24px;
  background: var(--panel-solid);
  border: 3px solid var(--panel-edge);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: pop-in 0.12s ease-out;
}
@keyframes pop-in { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.build-menu { display: flex; gap: 12px; }
.tower-card {
  width: 132px;
  height: 152px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 18px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  box-shadow: 0 4px 0 var(--btn-edge);
  color: var(--text);
  font: 800 20px/1.1 var(--font);
  cursor: pointer;
}
.tower-card:active:not(.unaffordable) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-edge); }
.tower-card canvas { width: 68px; height: 68px; }
.tower-card .cost { font-size: 24px; font-weight: 900; color: var(--accent-edge); }
.tower-card.picked { border-color: var(--accent-edge); background: var(--panel-solid); box-shadow: 0 4px 0 var(--accent-edge); }
.tower-card.picked .cost { font-size: 21px; }
.tower-card.unaffordable { opacity: 0.45; }
.tower-card.unaffordable .cost { color: var(--danger); }
.build-desc {
  width: 420px;
  margin-top: 10px;
  padding: 0 4px;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--muted);
}

.tower-panel { width: 420px; display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; }
.tower-panel h3 { margin: 0; font-size: 30px; font-weight: 900; }
.tower-panel p { margin: 0; font-size: 21px; line-height: 1.3; color: var(--muted); font-weight: 700; }
.tower-panel .stats { font-size: 20px; font-weight: 800; color: var(--text); }
.tower-panel .row { display: flex; gap: 10px; margin-top: 4px; }
.tower-panel .row .btn { flex: 1; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  pointer-events: auto;
  animation: fade-in 0.25s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.overlay .card {
  width: 680px;
  padding: 36px 44px 32px;
  border-radius: 32px;
  background: var(--panel-solid);
  border: 3px solid var(--panel-edge);
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop-in 0.2s ease-out;
}
.overlay h1 { margin: 0 0 14px; font-size: 56px; font-weight: 900; line-height: 1.05; }
.overlay p { margin: 6px 0; font-size: 25px; line-height: 1.35; font-weight: 700; color: var(--muted); }
.overlay .sign { margin-top: 16px; font-size: 34px; font-weight: 900; font-style: italic; color: var(--accent-edge); }
.overlay .result-stats { margin-top: 14px; font-size: 22px; font-weight: 800; color: var(--text); }
.overlay .actions { display: flex; gap: 16px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* Volume sliders (title screen Sound panel, pause menu). Big thumbs for fingers. */
.sound-settings { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.volume-row { display: flex; align-items: center; gap: 18px; font-size: 24px; font-weight: 800; color: var(--text); }
.volume-name { width: 190px; text-align: left; }
.volume-value { width: 74px; text-align: right; color: var(--muted); }
.volume-row input[type='range'] {
  flex: 1;
  height: 56px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}
.volume-row input[type='range']::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: var(--panel-edge); }
.volume-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 40px;
  height: 40px;
  margin-top: -14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--accent-edge);
}
.volume-row input[type='range']::-moz-range-track { height: 12px; border-radius: 6px; background: var(--panel-edge); }
.volume-row input[type='range']::-moz-range-thumb { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); border: 3px solid var(--accent-edge); }

/* ---------- Toasts ---------- */
/* Stacking: toasts sit under menus and overlays so they never hide a button. */
.toasts { z-index: 1; }
.hud, .popup { z-index: 2; }
.overlay { z-index: 3; }

.toasts {
  position: absolute;
  left: 0;
  right: 0;
  top: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.toast {
  max-width: 820px;
  padding: 12px 24px;
  border-radius: 20px;
  background: var(--panel-solid);
  border: 3px solid var(--panel-edge);
  box-shadow: var(--shadow);
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast b { color: var(--accent-edge); }
.toast.warn { border-color: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }

/* ---------- Upgrades ---------- */
.popup.build { width: min-content; }
.build-desc { width: auto; min-width: 420px; }
.tower-panel .upgrades { display: flex; flex-direction: column; gap: 8px; }
.upgrade-note { font-size: 19px; font-weight: 800; color: var(--muted); text-align: center; }
.upgrade-btn {
  /* centred: name and price on the first line, the description under them at full width */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  align-content: center;
  column-gap: 12px;
  min-height: 72px;
  padding: 8px 14px;
  border-radius: 16px;
  border: 3px solid var(--accent-edge);
  background: var(--btn);
  box-shadow: 0 4px 0 var(--accent-edge);
  color: var(--text);
  font-family: var(--font);
  text-align: center;
  cursor: pointer;
}
.upgrade-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-edge); }
.upgrade-btn:disabled { opacity: 0.5; border-color: var(--btn-edge); box-shadow: 0 4px 0 var(--btn-edge); cursor: default; }
.upgrade-btn.unaffordable { opacity: 0.5; }
.upgrade-btn.unaffordable .u-cost { color: var(--danger); }
.upgrade-btn .u-name { order: 1; font-size: 22px; font-weight: 900; }
.upgrade-btn .u-desc { order: 3; flex-basis: 100%; font-size: 17px; font-weight: 700; color: var(--muted); line-height: 1.2; }
.upgrade-btn .u-cost { order: 2; white-space: nowrap; font-size: 24px; font-weight: 900; color: var(--accent-edge); }
/* Threat Feed elite upgrade: gold */
.upgrade-btn.elite { border-color: #d99a1e; box-shadow: 0 4px 0 #b87a12; background: linear-gradient(135deg, #fff6d8, #ffe39a); color: #3a2a08; }
.upgrade-btn.elite .u-cost { color: #9a5f00; }
.upgrade-btn.elite .u-desc { color: #6b5220; }
.tower-panel h3.elite { color: #b87a12; }
.tower-panel h3.elite::after { content: ' ★★'; color: #f2b84b; }

/* ?noanim=1 (headless screenshots): show the end state of every animation immediately. */
.no-anim *, .no-anim *::before, .no-anim *::after { animation: none !important; transition: none !important; }
.no-anim .story-text p { opacity: 1; }

/* ---------- The birthday ending ---------- */
.overlay.ending { align-items: flex-end; padding-bottom: 20px; background: rgba(0, 0, 0, 0.2); }
.overlay .card.ending-card {
  width: 1100px;
  display: grid;
  grid-template-columns: 120px 1fr;
  column-gap: 28px;
  text-align: left;
  padding: 26px 36px 24px;
}
.ending-card .emblem { grid-row: 1 / span 4; align-self: start; }
/* The message box: the text shrinks to fit (see MESSAGE_FONT in src/scenes/ending.js). */
.ending-message { height: 330px; overflow: hidden; font-weight: 700; line-height: 1.4; color: var(--text); white-space: pre-line; }
.ending-card .sign { margin-top: 6px; }
.ending-card .actions { justify-content: flex-start; align-items: center; margin-top: 12px; }
.ending-preview { font-size: 18px; font-weight: 800; color: var(--muted); max-width: 520px; }
.ending-preview.warn { color: var(--danger); }

/* The Cyber Fox emblem on the title screen once the story is finished. */
.menu-card { position: relative; }
.menu-card .emblem-corner { position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 15px; font-weight: 900; color: var(--accent-edge); }

/* ---------- Certifications and achievements ---------- */
.screen-header .tabs { display: flex; gap: 10px; margin-left: auto; }
.btn.tab.active { background: var(--accent); border-color: var(--accent-edge); color: var(--accent-text); }
.xp-badge { padding: 10px 18px; border-radius: 18px; background: var(--panel-solid); border: 3px solid var(--accent-edge); font-size: 26px; font-weight: 900; color: var(--accent-edge); }
.screen-header .header-right { margin-left: auto; }
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  overflow-y: auto;
  pointer-events: auto;
  padding: 4px 4px 8px;
  touch-action: pan-y;
}
.trophy-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 170px;
  padding: 14px 16px;
  border-radius: 22px;
  border: 3px solid var(--btn-edge);
  background: var(--btn);
  box-shadow: 0 4px 0 var(--btn-edge);
}
.trophy-card .name { font-size: 22px; font-weight: 900; line-height: 1.15; }
.trophy-card .desc { font-size: 17px; font-weight: 700; color: var(--muted); line-height: 1.25; flex: 1; }
.trophy-card.achievement { position: relative; }
.trophy-card .date { position: absolute; top: 12px; right: 16px; font-size: 14px; font-weight: 800; font-style: italic; color: #1f5fbf; }
.trophy-card .btn { min-height: 52px; font-size: 20px; }
.trophy-card.owned { border-color: var(--good); box-shadow: 0 4px 0 var(--good); }
.trophy-card.achievement { min-height: 150px; }
.trophy-card.achievement .icon { font-size: 34px; line-height: 1; }
.trophy-card.locked { opacity: 0.6; }
.trophy-footer { font-size: 19px; font-weight: 800; color: var(--muted); }

/* Chapter 3 story card: the boys under Jessica's portrait */
.story-portraits { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: none; }
.story-family { display: flex; gap: 18px; align-items: flex-end; }
.story-family figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.story-family canvas { border-radius: 50%; box-shadow: 0 0 0 2px rgba(60, 90, 80, 0.25); }
.story-family figcaption { font-size: 20px; font-weight: 900; color: var(--text); }
/* the Chapter 3 easter egg: a little wiggle when a face is tapped */
.story-family canvas.boop { animation: boop 0.45s ease-out; }
@keyframes boop { 0% { transform: scale(1); } 30% { transform: scale(1.08) rotate(-4deg); } 60% { transform: scale(1.04) rotate(3deg); } 100% { transform: none; } }

/* Level intro: the HUD strip waits above the screen while the network boots up, then drops in */
#ui .hud { transition: transform 0.5s cubic-bezier(0.2, 1.25, 0.4, 1), opacity 0.3s; }
#ui .seed-tag { transition: opacity 0.4s; }
#ui.intro-hold .hud { transform: translateY(-130%); opacity: 0; transition: none; }
#ui.intro-hold .hud * { pointer-events: none; }
#ui.intro-hold .seed-tag { opacity: 0; transition: none; }

/* The cast (end credits): a Skip button, then the closing card */
.overlay.cast { background: none; pointer-events: none; }
.overlay.cast > * { pointer-events: auto; }
.overlay.cast.ended { background: var(--scrim); pointer-events: auto; }
.cast-skip { position: absolute; top: 18px; right: 18px; min-width: 110px; }
.overlay .card.cast-end { width: 640px; text-align: center; animation: cast-end-in 0.6s cubic-bezier(0.2, 1.3, 0.4, 1); }
.overlay .card.cast-end h1 { font-size: 72px; color: var(--accent-edge); text-shadow: 4px 4px 0 #3d2c52; -webkit-text-stroke: 2px #3d2c52; }
.overlay .card.cast-end canvas { margin: 0 auto 6px; display: block; }
.overlay .card.cast-end .actions { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }
@keyframes cast-end-in { from { transform: scale(0.6) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Threat Feed arcade board: black cabinet, neon letters */
.overlay.arcade { background: rgba(6, 4, 20, 0.82); }
.arcade-card {
  width: 760px;
  max-height: 690px;
  padding: 26px 40px 24px;
  border-radius: 24px;
  background: radial-gradient(ellipse at top, #22104a, #07061a 70%);
  border: 4px solid #ff4fd8;
  box-shadow: 0 0 0 4px #07061a, 0 0 34px rgba(255, 79, 216, 0.55), inset 0 0 30px rgba(73, 232, 255, 0.18);
  color: #f4f0ff;
  text-align: center;
  font-family: var(--font);
  animation: pop-in 0.25s ease-out;
}
.arcade-title {
  margin: 0 0 6px;
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #ffe94f;
  text-shadow: 0 0 8px #ff9b2f, 0 0 22px #ff4fd8, 3px 3px 0 #b0168f;
  animation: arcade-glow 1.2s ease-in-out infinite alternate;
}
@keyframes arcade-glow { from { filter: brightness(0.9); } to { filter: brightness(1.25); } }
.arcade-score { font-size: 64px; font-weight: 900; letter-spacing: 0.06em; color: #49e8ff; text-shadow: 0 0 14px rgba(73, 232, 255, 0.8); font-variant-numeric: tabular-nums; }
.arcade-note { margin: 4px 0 8px; font-size: 22px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #c9b8ff; }
.initials { display: flex; justify-content: center; gap: 26px; margin: 14px 0 18px; }
.initial { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.initial .arrow,
.initial .letter {
  width: 104px;
  border: 0;
  background: none;
  color: #ff4fd8;
  font: 900 34px/1 var(--font);
  cursor: pointer;
}
.initial .arrow { height: 60px; border-radius: 14px; }
.initial .arrow:active { background: rgba(255, 79, 216, 0.2); }
.initial .letter {
  height: 120px;
  border-radius: 16px;
  border: 3px solid #3b2c78;
  background: #0d0a26;
  color: #ffe94f;
  font-size: 92px;
  text-shadow: 0 0 12px #ff9b2f;
}
.initial.active .letter { border-color: #49e8ff; box-shadow: 0 0 18px rgba(73, 232, 255, 0.6); animation: arcade-blink 0.8s steps(2, start) infinite; }
@keyframes arcade-blink { to { color: transparent; text-shadow: none; } }
.arcade-ok { min-width: 220px; font-size: 32px; }
.scoreboard { list-style: none; margin: 10px 0 0; padding: 0; font-variant-numeric: tabular-nums; }
.scoreboard li {
  display: grid;
  grid-template-columns: 80px 110px 1fr 150px;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 30px;
  font-weight: 900;
}
.scoreboard li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.scoreboard .rank { color: #c9b8ff; text-align: left; }
.scoreboard .who { color: #ffe94f; letter-spacing: 0.14em; text-align: left; }
.scoreboard .pts { color: #49e8ff; text-align: right; padding-right: 26px; }
.scoreboard .wave { color: #c9b8ff; font-size: 22px; text-align: right; }
.scoreboard li.mine { background: rgba(255, 79, 216, 0.22); animation: arcade-row 0.9s ease-in-out infinite alternate; }
@keyframes arcade-row { from { box-shadow: 0 0 0 2px rgba(255, 79, 216, 0.4); } to { box-shadow: 0 0 18px 3px rgba(255, 79, 216, 0.75); } }
.scoreboard li.empty { display: block; height: auto; padding: 30px 0; font-size: 26px; color: #c9b8ff; text-align: center; }
.arcade-card .actions { display: flex; gap: 16px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
/* Threat Feed score, floating under the HUD strip */
.score-tag {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  border-radius: 12px;
  background: rgba(7, 6, 26, 0.72);
  border: 2px solid rgba(255, 79, 216, 0.7);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.score-tag .label { font-size: 16px; letter-spacing: 0.14em; text-transform: uppercase; color: #ff9be9; }
.score-tag .value { font-size: 26px; color: #49e8ff; text-shadow: 0 0 8px rgba(73, 232, 255, 0.6); }
#ui.intro-hold .score-tag { opacity: 0; }
