:root {
  --bg: #140d0b;
  --panel: rgba(30, 20, 16, 0.94);
  --line: #4a2f26;
  --text: #f3e6cf;
  --muted: #cdb89c;
  --accent: #b8322a;
  --accent-2: #e8b04a;
  --radius: 14px;
  --header-h: 48px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent-2);
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border: 1px solid rgba(243, 230, 207, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 700 0.82em/1.5 system-ui, sans-serif;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.page {
  padding: 8px 8px 40px;
}

/* ---------- Game area ---------- */

.game-root {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 1280px;
  height: calc(100vh - var(--header-h) - 16px);
  height: calc(100dvh - var(--header-h) - 16px);
  max-height: 860px;
  min-height: 300px;
  background: #0b0706;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.stage {
  position: absolute;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px;
  pointer-events: none;
}

.screen:empty {
  display: none;
}

.title-card {
  margin-top: 4%;
  padding: 10px 22px 12px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.title-kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.title-name {
  margin: 2px 0;
  font: 700 clamp(26px, 5vw, 44px) / 1.1 Georgia, 'Times New Roman', serif;
  letter-spacing: 0.04em;
}

.title-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Below the game ---------- */

.ad-slot {
  margin: 12px auto 0;
  max-width: 970px;
}

.about {
  max-width: 820px;
  margin: 24px auto 0;
  padding: 0 8px;
  line-height: 1.6;
  color: var(--muted);
}

.about h1,
.about h2,
.about strong {
  color: var(--text);
}

/* Phones: the game runs edge to edge. */
@media (max-width: 600px) {
  .page {
    padding: 0 0 32px;
  }

  .game-root {
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

/* Touch screens have no keyboard to hint at. */
@media (hover: none) and (pointer: coarse) {
  .title-card kbd {
    display: none;
  }
}

/* #484: the stage in play (DESIGN.md, "Layout" and "Fullscreen"). Nothing
   scrolls, zooms or selects on the stage. On phones a level fills the
   viewport with the site header hidden, and in fullscreen or the home-screen
   app the game area fills the screen with no 1280 px limit. */
.stage {
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html.wh-phone.wh-playing,
html.wh-phone.wh-playing body {
  overscroll-behavior: none;
}

html.wh-phone.wh-playing .site-header,
html.wh-app .site-header {
  display: none;
}

html.wh-phone.wh-playing .page {
  padding: 0 0 32px;
}

html.wh-phone.wh-playing .game-root,
html.wh-app .game-root {
  height: 100vh;
  height: 100dvh;
  max-height: none;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

html.wh-app .game-root,
.game-root:fullscreen {
  max-width: none;
  width: 100%;
  border: 0;
  border-radius: 0;
}

/* #531: no app gutter. */
html.wh-app .page {
  padding: 0;
}

.game-root:fullscreen {
  height: 100%;
  max-height: none;
}

/* #498: menus, HUD and controls. --ui is the class's HUD scale; targets
   keep 16 px inside safe areas and measure at least 44 px (DESIGN.md). */
.stage {
  --ui: 1;
  --pad-t: calc(max(var(--sat, env(safe-area-inset-top)), 0px) + 16px);
  --pad-r: calc(max(var(--sar, env(safe-area-inset-right)), 0px) + 16px);
  --pad-b: calc(max(var(--sab, env(safe-area-inset-bottom)), 0px) + 16px);
  --pad-l: calc(max(var(--sal, env(safe-area-inset-left)), 0px) + 16px);
  font-size: calc(15px * var(--ui));
}
html.wh-phone .stage {
  font-size: 14px;
}

.screen {
  padding: 0;
}
.ui-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  pointer-events: auto;
  background: radial-gradient(ellipse at 50% 40%, rgba(20, 13, 11, 0.35), rgba(11, 7, 6, 0.82));
}
.ui-in-play .ui-screen,
.ui-screen:empty {
  display: none;
}
.screen[data-screen='editor'] .ui-screen {
  align-items: flex-start;
  background: none;
  pointer-events: none;
}

.ui-panel {
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui));
  max-width: 100%;
  max-height: 100%;
  padding: calc(14px * var(--ui)) calc(18px * var(--ui));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  min-height: 0;
}
.ui-wide {
  width: min(100%, calc(860px * var(--ui)));
  height: 100%;
}
.ui-narrow {
  width: min(100%, calc(460px * var(--ui)));
  overflow: auto;
}
.ui-panel h2 {
  margin: 0;
  font: 700 1.5em/1.15 Georgia, 'Times New Roman', serif;
}
.ui-panel h3 {
  margin: 0.4em 0 0;
  font-size: 1em;
  color: var(--accent-2);
  letter-spacing: 0.06em;
}
.ui-sub {
  margin: 0;
  color: var(--muted);
  font-size: max(13px, 0.87em);
}
.ui-warn {
  margin: 0;
  color: var(--accent-2);
  font-size: max(13px, 0.87em);
}
.ui-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.ui-scroll {
  overflow: auto;
  min-height: 0;
  flex: 1;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-right: 4px;
}
.ui-row {
  display: flex;
  flex-wrap: wrap;
  gap: calc(10px * var(--ui));
  align-items: center;
}
.ui-col {
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--ui));
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-width: calc(44px * var(--ui));
  min-height: calc(44px * var(--ui));
  padding: 0.4em 1em;
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--ui));
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1em;
  text-decoration: none;
  cursor: pointer;
}
.ui-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.ui-btn:focus {
  outline: none;
}
.ui-btn:focus-visible,
.ui-btn:focus,
.ui-setting input:focus {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}
.ui-btn.primary {
  background: linear-gradient(#c43b31, #962620);
  border-color: #d9594d;
  font-weight: 700;
}
.ui-btn[aria-pressed='true'] {
  background: rgba(232, 176, 74, 0.22);
  border-color: var(--accent-2);
}
.ui-btn:disabled,
.ui-btn[aria-disabled='true'] {
  opacity: 0.55;
}
.ui-btn:disabled {
  cursor: default;
}
.ui-icon {
  width: 1.3em;
  height: 1.3em;
  flex: none;
}
.ui-flip {
  transform: scaleX(-1);
}

.ui-head {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--ui));
}
.ui-head-text {
  min-width: 0;
}

/* Title */
.ui-title {
  align-items: center;
  text-align: center;
  width: min(100%, calc(460px * var(--ui)));
  overflow: auto;
}
/* The title sits at the left, over a shaded edge, and leaves the scene and
   Rei in view: only its panel takes taps and clicks. */
.screen[data-screen='title'] .ui-screen {
  justify-content: flex-start;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(11, 7, 6, 0.8), rgba(11, 7, 6, 0.3) 50%, rgba(11, 7, 6, 0));
}
.screen[data-screen='title'] .ui-panel {
  pointer-events: auto;
}
@media (max-width: 600px) {
  .screen[data-screen='title'] .ui-screen {
    justify-content: center;
  }
}
.ui-title .title-name {
  font-size: calc(clamp(30px, 6vw, 48px) * var(--ui));
}
.ui-brand {
  margin-bottom: 0.2em;
}
.ui-main {
  justify-content: center;
}
.ui-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(8px * var(--ui));
  width: 100%;
}
.ui-mode {
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.1em;
}
.ui-mode.locked strong {
  color: var(--muted);
}
.ui-lock {
  width: 1.1em;
  height: 1.1em;
  color: var(--muted);
}
.ui-mode .ui-lock {
  position: absolute;
  right: 0.6em;
  top: 0.6em;
}
.ui-sound {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin: 0;
  color: var(--muted);
  font-size: max(13px, 0.87em);
}

/* Map */
.ui-chapter {
  margin-bottom: calc(10px * var(--ui));
}
.ui-chapter h3 {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.4em;
}
.ui-ch-n {
  display: inline-grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text);
}
.ui-ch-name {
  color: var(--text);
  flex: 1;
}
.ui-ch-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  color: var(--muted);
  font-weight: 400;
}
.ui-ch-star {
  width: 1em;
  height: 1em;
  color: var(--accent-2);
}
.ui-levels {
  display: grid;
  /* #531: fit the safe panel. */
  grid-template-columns: repeat(auto-fit, minmax(calc(44px * var(--ui)), 1fr));
  gap: calc(6px * var(--ui));
}
.ui-level {
  flex-direction: column;
  gap: 0;
  padding: 0.2em;
}
.ui-level.boss {
  border-color: var(--accent);
}
.ui-level.cleared {
  background: rgba(232, 176, 74, 0.1);
}
.ui-n {
  font-weight: 700;
}
.ui-stars {
  display: inline-flex;
  gap: 0.1em;
  color: var(--accent-2);
}
.ui-star svg {
  width: 0.8em;
  height: 0.8em;
  display: block;
}
.ui-star:not(.on) {
  color: var(--muted);
  opacity: 0.8;
}
.ui-result .ui-star svg {
  width: 2.4em;
  height: 2.4em;
}
.ui-level-name {
  font: 700 1.3em/1.2 Georgia, serif !important;
  color: var(--text) !important;
  letter-spacing: 0 !important;
}
.ui-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3em;
  color: var(--muted);
}
.ui-goals li {
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.ui-goals li.on {
  color: var(--text);
}
.ui-star-s {
  width: 1.1em;
  height: 1.1em;
  color: var(--accent-2);
}

/* Results */
.ui-result {
  align-items: center;
  text-align: center;
}
.ui-result-title {
  font-size: 1.8em !important;
}
.ui-result.loss .ui-result-title {
  color: #e2806f;
}
.ui-stats {
  display: flex;
  gap: calc(22px * var(--ui));
  margin: 0;
}
.ui-stats dt {
  color: var(--muted);
  font-size: max(13px, 0.87em);
}
.ui-stats dd {
  margin: 0;
  font-size: 1.3em;
  font-weight: 700;
}
.ui-result .ui-row {
  justify-content: center;
}

/* The choice of hero (#849, src/ui/hero.js): the man and the woman side by
   side, each painted in full at the screen's own pixels, the card a button. */
.ui-hero {
  width: min(100%, calc(720px * var(--ui)));
}
.ui-heroes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(12px * var(--ui));
  flex: 1;
  min-height: 0;
}
.ui-hero-pick {
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.15em;
  min-height: 0;
  padding: 0.5em 0.5em 0.6em;
  background: radial-gradient(ellipse at 50% 85%, rgba(232, 176, 74, 0.16), rgba(255, 255, 255, 0.03) 70%);
}
.ui-hero-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
}
.ui-hero-text strong {
  font: 700 1.2em/1.1 Georgia, 'Times New Roman', serif;
}
.ui-hero-art {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 0;
}
/* A phone on its side: each hero beside its name, as tall as the card. */
@media (max-height: 430px) {
  .ui-hero-pick {
    flex-direction: row;
    align-items: stretch;
    padding: 0.3em 0.6em 0.3em 0.3em;
  }
  .ui-hero-art {
    flex: 1.2 1 0;
    width: 0;
    height: 100%;
  }
  .ui-hero-text {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    text-align: center;
  }
}

/* A header's action at its right end: the map's Dojo button (#533). */
.ui-head-act {
  margin-left: auto;
}

/* Settings and controls */
.ui-settings h3 {
  margin-top: 0.8em;
}
.ui-setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4em 1em;
  padding: 0.25em 0;
  border-bottom: 1px solid rgba(74, 47, 38, 0.6);
}
.ui-label {
  flex: 1 1 10em;
}
.ui-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
}
.ui-seg .ui-btn {
  padding: 0.3em 0.75em;
}
.ui-range {
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.ui-range input {
  width: min(42vw, calc(220px * var(--ui)));
  height: calc(44px * var(--ui));
  accent-color: var(--accent);
}
.ui-range output {
  min-width: 3em;
  text-align: right;
}
.ui-padicon {
  width: 1.4em;
  height: 1.4em;
}

/* The HUD */
.ui-hud-top {
  position: absolute;
  left: var(--pad-l);
  right: var(--pad-r);
  top: var(--pad-t);
  display: flex;
  align-items: flex-start;
  gap: calc(14px * var(--hud, 1));
  font-size: var(--text, 14px);
}
.ui-meters {
  display: grid;
  gap: calc(5px * var(--hud, 1));
  padding: calc(6px * var(--hud, 1)) calc(10px * var(--hud, 1));
  border-radius: calc(10px * var(--hud, 1));
  background: rgba(14, 9, 7, 0.55);
}
.ui-meter {
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.ui-tag {
  width: 3.6em;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ui-bar {
  position: relative;
  width: var(--bar-w, 240px);
  height: var(--bar-h, 14px);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 1px rgba(243, 230, 207, 0.25);
  overflow: hidden;
}
.ui-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  transition: width 0.15s linear;
}
.ui-hp .ui-fill {
  background: linear-gradient(#e4574a, #a92a22);
}
.ui-hp.low .ui-fill {
  background: linear-gradient(#ff6d5c, #c42a1f);
}
.ui-chi .ui-fill {
  background: linear-gradient(#f1c46a, #c58a26);
}
.ui-chi.full {
  box-shadow: inset 0 0 0 1px #f6d58e, 0 0 calc(8px * var(--hud, 1)) rgba(241, 196, 106, 0.8);
}
.ui-num {
  min-width: 2em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ui-weapon {
  display: flex;
  align-items: center;
  gap: 0.45em;
  padding: calc(6px * var(--hud, 1)) calc(10px * var(--hud, 1));
  border-radius: calc(10px * var(--hud, 1));
  background: rgba(14, 9, 7, 0.55);
  font-weight: 600;
}
.ui-dura {
  position: relative;
  padding-bottom: 0.25em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ui-dura::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--left, 0%);
  background: var(--accent-2);
  border-radius: 2px;
}
/* The weapon's durability bar flashes once it is down to 25% (#501). */
.ui-dura.low::after {
  background: #e4574a;
  animation: ui-dura-flash 0.6s steps(2, jump-none) infinite;
}
.ui-dura.low.steady::after {
  animation: none;
}
@keyframes ui-dura-flash {
  50% {
    opacity: 0.2;
  }
}
.ui-hud-pause {
  margin-left: auto;
  pointer-events: auto;
  background: rgba(14, 9, 7, 0.55);
}
html:not(.wh-desktop) .ui-hud-pause {
  display: none;
}
.ui-combo {
  position: absolute;
  right: var(--pad-r);
  top: calc(var(--pad-t) + 64px * var(--hud, 1));
  display: flex;
  align-items: baseline;
  gap: 0.3em;
  font-size: var(--text, 14px);
  color: var(--accent-2);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}
.ui-combo strong {
  font: 700 2.2em/1 Georgia, serif;
  color: var(--text);
}
.ui-combo.bump strong {
  animation: ui-bump 0.18s ease-out;
}
@keyframes ui-bump {
  from {
    transform: scale(1.25);
  }
}
.ui-mark {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-height: calc(32px * var(--hud, 1));
  display: flex;
  align-items: center;
  padding: 0 0.7em;
  border-radius: 999px;
  background: rgba(12, 8, 6, 0.8);
  color: #f0b44c;
  border: 2px solid #f0b44c;
  font-size: var(--text, 14px);
  font-weight: 700;
}
.ui-mark.left {
  left: calc(var(--pad-l) + 40px * var(--hud, 1));
}
.ui-mark.right {
  right: calc(var(--pad-r) + 40px * var(--hud, 1));
}
.ui-notice {
  position: absolute;
  left: 50%;
  bottom: var(--pad-b);
  transform: translateX(-50%);
  z-index: 40;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 0.5em 1em;
  border-radius: 999px;
  background: rgba(14, 9, 7, 0.9);
  border: 1px solid var(--line);
  text-align: center;
  pointer-events: none;
}

/* Touch controls: drawn circles with icons, at the options' opacity, and
   100% while pressed. Taps go to the stage's touch source, not to these. */
.ui-touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  --op: 0.5;
}
.ui-touch.faded {
  opacity: 0;
}
.ui-tb {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(20, 13, 11, 0.55);
  border: 2px solid rgba(243, 230, 207, 0.75);
  color: var(--text);
  opacity: var(--op);
  transition: transform 0.06s, opacity 0.06s;
}
.ui-tb svg {
  width: 52%;
  height: 52%;
}
.ui-tb-label {
  position: absolute;
  bottom: -1.35em;
  font-size: 13px;
  white-space: nowrap;
  color: var(--text);
  text-shadow: 0 1px 3px #000;
  display: none;
}
.ui-touch.labels .ui-tb-label {
  display: block;
}
.ui-tb.down {
  opacity: 1;
  transform: scale(1.06);
  background: rgba(184, 50, 42, 0.75);
}
.ui-tb.dim {
  opacity: calc(var(--op) * 0.45);
}
/* #533: a button at rest over a fighter shows the fight through it. */
.ui-tb.over:not(.down) {
  opacity: calc(var(--op) * 0.4);
  background: rgba(20, 13, 11, 0.2);
  transition: opacity 0.15s;
}
.ui-tb.lit {
  opacity: 1;
  border-color: #f1c46a;
  box-shadow: 0 0 14px rgba(241, 196, 106, 0.85);
}
.ui-stick {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(243, 230, 207, 0.6);
  background: rgba(20, 13, 11, 0.35);
  opacity: max(var(--op), 0.6);
}
.ui-stick.dpad {
  border-radius: 12px;
  background: none;
  border: 0;
}
.ui-stick.dpad .ui-cross {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(20, 13, 11, 0.6), rgba(20, 13, 11, 0.6)) center / 33% 100% no-repeat, linear-gradient(rgba(20, 13, 11, 0.6), rgba(20, 13, 11, 0.6)) center / 100% 33% no-repeat;
  outline: 2px solid rgba(243, 230, 207, 0.35);
  border-radius: 12px;
}
.ui-knob {
  position: absolute;
  left: 25%;
  top: 25%;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background: rgba(243, 230, 207, 0.55);
}
.ui-stick.dpad .ui-knob {
  display: none;
}
.ui-touch.editing .ui-tb,
.ui-touch.editing .ui-stick {
  pointer-events: auto;
  opacity: 0.95;
  outline: 2px dashed rgba(243, 230, 207, 0.6);
  outline-offset: 4px;
  cursor: grab;
}
.ui-touch.editing .ui-tb-pause {
  pointer-events: none;
  outline: 0;
  opacity: 0.5;
}
.ui-touch.editing .picked,
.ui-touch.editing :focus {
  outline: 3px solid var(--accent-2);
}
.ui-editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  max-width: min(100%, 640px);
  margin-right: 60px;
  padding: 0.4em 0.7em;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  pointer-events: auto;
}
.ui-editor-bar p {
  margin: 0;
  flex: 1 1 14em;
  color: var(--muted);
  font-size: 13px;
}

/* The rotate prompt and the home-screen card */
.ui-rotate {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: #140d0b;
  text-align: center;
  font-size: 18px;
}
.ui-rotate-icon {
  width: 120px;
  height: 120px;
  color: var(--text);
}
.ui-rotate-phone {
  transform-origin: 48px 40px;
  animation: ui-turn 2.4s ease-in-out infinite;
}
@keyframes ui-turn {
  0%,
  25% {
    transform: rotate(0deg);
  }
  55%,
  100% {
    transform: rotate(-90deg);
  }
}
.ui-cards {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  background: rgba(11, 7, 6, 0.7);
}
.ui-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(100%, 420px);
  padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.ui-card p {
  margin: 0;
}
.ui-setup {
  margin: 0.4em 0;
  font-size: 1.3em;
  font-weight: 700;
}
.ui-share {
  width: 44px;
  height: 44px;
  color: #6fb0ff;
}

/* Short screens (phones in landscape): tighter panels. Upright phones lay the
   menus out in one column. */
@media (max-height: 430px) {
  .ui-panel {
    padding: 10px 14px;
    gap: 8px;
  }
  .ui-title .title-name {
    font-size: 30px;
  }
  .ui-brand .title-kicker {
    display: none;
  }
}
@media (max-width: 600px) {
  .ui-modes {
    grid-template-columns: 1fr;
  }
  .ui-stats {
    gap: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ui-rotate-phone {
    animation: none;
  }
  .ui-fill,
  .ui-touch,
  .ui-tb {
    transition: none;
  }
}

/* #531: fill short and upright stages; scroll short menus. */
html.wh-phone .game-root,
html.wh-tablet .game-root {
  min-height: 0;
  max-height: none;
}
.ui-title {
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
@media (max-height: 430px) {
  /* #531: saved-run actions fit below the header on a 300px phone. */
  .ui-endless {
    width: min(100%, 640px);
    padding: 6px 12px;
    gap: 2px;
  }
  .ui-endless > .ui-head,
  .ui-endless > .ui-saved,
  .ui-endless > .ui-row {
    flex-shrink: 0;
  }
  .ui-endless .ui-sub {
    line-height: 1.3;
  }
  .ui-endless .ui-saved {
    padding: 4px 10px;
  }
  .ui-endless-facts {
    min-height: 0;
    overflow: auto;
  }
  .ui-endless-facts .ui-stats > div {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
}

/* ---------- #515: the boss bar, its lines and its title card (src/ui/boss-bar.js) ----------
   DESIGN.md, "Bosses": the boss's name, its hp bar and a pip for each phase
   change across the top of the screen, under the HUD's row; the title card
   at the start of the fight. Sized by the HUD's scale. */
.boss-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--text);
}
.boss-ui[hidden] {
  display: none;
}
.boss-head {
  position: absolute;
  left: 50%;
  top: calc(var(--pad-t) + 58px * var(--ui, 1));
  transform: translateX(-50%);
  width: min(58%, calc(560px * var(--ui, 1)));
  display: grid;
  justify-items: center;
  gap: calc(4px * var(--ui, 1));
  font-size: calc(14px * var(--ui, 1));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.boss-name {
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.boss-bar {
  position: relative;
  width: 100%;
  height: calc(12px * var(--ui, 1));
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 0 0 1px rgba(243, 230, 207, 0.3);
  overflow: hidden;
}
.boss-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(180deg, #e0573d, #9c2a1c);
  transition: width 0.25s ease-out;
}
.boss-pips {
  position: absolute;
  inset: 0;
}
.boss-pip {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #f6d58e;
  box-shadow: 0 0 4px rgba(246, 213, 142, 0.9);
}
.boss-pip.passed {
  background: rgba(243, 230, 207, 0.35);
  box-shadow: none;
}
.boss-ui.changing .boss-bar {
  box-shadow: inset 0 0 0 2px #f6d58e;
}
.boss-line {
  margin: 0;
  max-width: 100%;
  font-style: italic;
  text-align: center;
}
.boss-line[hidden] {
  display: none;
}
.boss-card {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  display: none;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}
.boss-ui.intro .boss-card {
  display: block;
  animation: boss-card-in 0.5s ease-out;
}
.boss-ui.intro .boss-head {
  visibility: hidden;
}
.boss-kicker {
  margin: 0;
  color: #f6d58e;
  font-size: calc(14px * var(--ui, 1));
  letter-spacing: 0.4em;
  text-transform: uppercase;
}
.boss-title {
  margin: 0.1em 0;
  font-size: calc(46px * var(--ui, 1));
  letter-spacing: 0.08em;
}
.boss-sub {
  margin: 0;
  font-size: calc(16px * var(--ui, 1));
  color: var(--muted, #d8c8aa);
}
@keyframes boss-card-in {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .boss-fill {
    transition: none;
  }
  .boss-ui.intro .boss-card {
    animation: none;
  }
}

/* ---------- #605: the endless mode's menus (src/endless/menu.js) ----------
   DESIGN.md, "Menus, pause and resume": the Endless screen and its saved
   run, the run's pause menu, and the cards that ask before a saved run is
   lost or a run is left. Menus like the rest, sized by --ui, laid out in one
   column on an upright phone. */
.ui-endless-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(6px * var(--ui)) calc(18px * var(--ui));
}
.ui-endless .ui-stats {
  justify-content: flex-start;
}
.ui-saved {
  display: grid;
  gap: calc(2px * var(--ui));
  padding: calc(8px * var(--ui)) calc(12px * var(--ui));
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--ui));
  background: rgba(255, 255, 255, 0.04);
}
.ui-saved p {
  margin: 0;
}
.ui-saved-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.7em;
}
.ui-saved-kicker {
  font-size: max(13px, 0.8em);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.ui-saved-wave {
  font: 700 1.4em/1.1 Georgia, 'Times New Roman', serif;
}
.ui-endless-where {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.ui-ask {
  gap: calc(10px * var(--ui));
  max-width: min(100%, calc(420px * var(--ui)));
}
.ui-ask-title {
  font: 700 1.3em/1.2 Georgia, 'Times New Roman', serif;
}
.ui-ask .ui-row {
  justify-content: center;
}
/* A phone on its side: the title's mode select in three columns, so every
   mode shows without scrolling, Endless last among them. */
@media (max-height: 430px) and (min-width: 601px) {
  .ui-title {
    width: min(100%, calc(640px * var(--ui)));
  }
  .ui-title .ui-modes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* The card between legs says the run is saved after a boss. */
.endless-kept {
  margin: 0.9em 0 0;
  color: #f6d58e;
  font-size: calc(14px * var(--ui, 1));
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.endless-kept:empty {
  display: none;
}
@media (max-height: 430px) {
  /* A phone on its side: the run's pause menu in two columns, all in view. */
  .ui-endless-pause .ui-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ui-saved {
    padding: 6px 10px;
  }
  .ui-saved-wave {
    font-size: 1.2em;
  }
  .ui-ask {
    padding: 12px 16px;
  }
}

/* ---------- #603: the endless mode (src/endless/page.js) ----------
   DESIGN.md, "Endless mode": the wave at the top of the view, each wave's
   announcement, and the card between legs, a black layer the view fades to
   and from over 0.5 s. DOM over the canvas, never a filter on it. */
.endless-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.endless-ui[hidden] {
  display: none;
}
.endless-wave {
  position: absolute;
  left: 50%;
  top: var(--pad-t);
  transform: translateX(-50%);
  margin: 0;
  padding: calc(5px * var(--hud, 1)) calc(12px * var(--hud, 1));
  border-radius: calc(10px * var(--hud, 1));
  background: rgba(14, 9, 7, 0.55);
  font-size: var(--text, 14px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.endless-banner {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  text-align: center;
  animation: endless-banner 2.2s ease-out both;
}
.endless-banner[hidden] {
  display: none;
}
.endless-kicker {
  margin: 0;
  color: #f6d58e;
  font-size: calc(14px * var(--ui, 1));
  letter-spacing: 0.4em;
  text-transform: uppercase;
}
.endless-big {
  margin: 0;
  font-size: calc(54px * var(--ui, 1));
  line-height: 1;
  letter-spacing: 0.04em;
}
.endless-sub {
  margin: 0.2em 0 0;
  font-size: calc(16px * var(--ui, 1));
  color: var(--muted, #d8c8aa);
}
.endless-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b0706;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease-in-out, visibility 0s linear 0.5s;
}
.endless-ui.carding .endless-card {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease-in-out, visibility 0s;
}
.endless-ui.carding .endless-wave,
.endless-ui.carding .endless-banner {
  visibility: hidden;
}
.endless-card-text {
  text-align: center;
  padding: 0 calc(24px * var(--ui, 1));
}
.endless-title {
  margin: 0.15em 0;
  font-size: calc(44px * var(--ui, 1));
  letter-spacing: 0.06em;
}
/* #604: the run's score under the wave, and a modified stretch's line on its card. */
.endless-score {
  position: absolute;
  left: 50%;
  top: calc(var(--pad-t) + 2.3em * var(--hud, 1));
  transform: translateX(-50%);
  margin: 0;
  color: #f6d58e;
  font-size: calc(var(--text, 14px) * 0.95);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.endless-ui.carding .endless-score {
  visibility: hidden;
}
.endless-mod {
  margin: 0.9em auto 0;
  max-width: 28em;
  padding-top: 0.7em;
  border-top: 1px solid rgba(246, 213, 142, 0.35);
  font-size: calc(17px * var(--ui, 1));
  color: #f6d58e;
}
.endless-mod[hidden] {
  display: none;
}
@keyframes endless-banner {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  15%,
  75% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .endless-banner {
    animation: none;
  }
  .endless-card,
  .endless-ui.carding .endless-card {
    transition: none;
  }
}
