:root {
  color-scheme: dark;
  --panel: rgba(28, 8, 18, 0.66);
  --panel-border: rgba(255, 206, 196, 0.22);
  --text: #fff4ee;
  --muted: #ffcabd;
  --cyan: #66f2ff;
  --cyan-deep: #1eb6ce;
  --danger: #ff6a7c;
  --hud-gold: #ffd76e;
  --hud-cranberry: #481129;
  --hud-shadow: rgba(10, 0, 8, 0.48);
  --app-width: 100vw;
  --app-height: 100dvh;
}

/* Final HUD layer: generated transparent ornaments plus compact readable panels. */
.hud {
  inset: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) auto
    max(14px, env(safe-area-inset-left));
  grid-template-columns: 146px minmax(245px, 360px) auto;
  gap: 10px;
}

.hud__stat,
.health,
.mission-panel,
.level-meter {
  overflow: visible;
  isolation: isolate;
}

.hud__stat {
  min-height: 50px;
  padding: 8px 12px 8px 58px;
  border: 1px solid rgba(102, 242, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(8, 45, 54, 0.78), rgba(48, 9, 26, 0.78)),
    rgba(20, 5, 15, 0.58);
}

.hud__stat::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: auto;
  left: -8px;
  display: block;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 0;
  background: url("./assets/ui/hud-orn-score.png") center / contain no-repeat;
  box-shadow: none;
}

.hud__stat::after,
.health::after,
.mission-panel::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: block;
  width: 58px;
  height: 58px;
  background: url("./assets/ui/hud-orn-red-corner.png") center / contain no-repeat;
  opacity: 0.78;
  pointer-events: none;
}

.hud__stat--score {
  width: 146px;
}

.hud__stat--score .hud__label,
.hud__stat--level .hud__label,
.mission-panel__label {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.hud__stat strong,
.hud__stat--score strong,
.hud__stat--level strong {
  position: static;
  display: block;
  color: #fff7d3;
  font-size: 18px;
  line-height: 1;
  text-align: left;
}

.hud__stat--level {
  width: 70px;
  min-height: 56px;
  padding: 8px 5px 7px;
  border: 0;
  background: url("./assets/ui/hud-orn-level.png") center / contain no-repeat;
  box-shadow: none;
}

.hud__stat--level::before,
.hud__stat--level::after {
  display: none;
}

.hud__stat--level strong,
.hud__stat--level .hud__label {
  text-align: center;
}

.health {
  width: min(360px, 100%);
  height: 50px;
  border-color: rgba(102, 242, 255, 0.44);
  background:
    linear-gradient(90deg, rgba(8, 49, 57, 0.84), rgba(48, 9, 26, 0.76)),
    rgba(18, 5, 15, 0.58);
}

.health::after {
  top: -8px;
  right: auto;
  bottom: auto;
  left: -8px;
  width: 62px;
  height: 62px;
  background-image: url("./assets/ui/hud-orn-health.png");
  opacity: 1;
}

.health::before {
  content: "Health";
  position: absolute;
  top: 8px;
  left: 62px;
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.health__bar {
  position: absolute;
  z-index: 1;
  display: block;
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
  width: auto;
  max-width: none;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #56efff, #b5ffe9 52%, var(--hud-gold));
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.42),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.health__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  opacity: 0.62;
}

.mission-panel {
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  width: min(330px, calc(100vw - 32px));
  padding: 12px 12px 12px 62px;
  border-color: rgba(102, 242, 255, 0.36);
  background:
    linear-gradient(135deg, rgba(42, 8, 25, 0.88), rgba(16, 45, 52, 0.62)),
    rgba(18, 5, 15, 0.62);
}

.mission-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -8px;
  width: 62px;
  height: 62px;
  background: url("./assets/ui/hud-orn-mission.png") center / contain no-repeat;
  pointer-events: none;
}

.mission-panel::after {
  width: 50px;
  height: 50px;
}

.mission-panel strong {
  font-size: 14px;
  line-height: 1.05;
}

.mission-panel p {
  display: -webkit-box;
  max-width: 250px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 10px;
  line-height: 1.2;
}

.mission-panel__meta {
  gap: 4px;
}

.mission-panel__meta span,
#abilityDash,
#abilityPulse {
  width: auto;
  min-height: 20px;
  padding: 3px 7px;
  font-size: 9px;
}

.mission-panel__meta::after {
  content: "";
  flex-basis: 100%;
  height: 9px;
  margin-top: -1px;
  background: url("./assets/ui/hud-orn-gold-divider.png") left center / 150px auto no-repeat;
  opacity: 0.72;
}

.level-meter {
  height: 17px;
  overflow: hidden;
  border-color: rgba(102, 242, 255, 0.36);
}

.level-meter::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(340px, 50vw);
  height: 34px;
  background: url("./assets/ui/hud-orn-cyan-divider.png") center / contain no-repeat;
  opacity: 0.76;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.level-meter__fill {
  z-index: 1;
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: 102px minmax(116px, 1fr) auto;
    gap: 6px;
  }

  .hud__stat {
    min-height: 42px;
    padding: 6px 8px 6px 42px;
  }

  .hud__stat::before,
  .health::after,
  .mission-panel::before {
    width: 48px;
    height: 48px;
  }

  .hud__stat--score {
    width: 102px;
  }

  .hud__stat--level {
    width: 54px;
    min-height: 46px;
    padding: 6px 4px;
  }

  .health {
    width: min(210px, 100%);
    height: 42px;
  }

  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
  }

  .mission-panel {
    width: min(300px, calc(100vw - 18px));
    padding: 10px 10px 10px 48px;
  }

  .mission-panel p {
    max-width: none;
  }
}

/* Final health fill override for the applied generated HUD. */
.health::before {
  content: "Health";
  position: absolute;
  top: 8px;
  left: 62px;
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.health__bar {
  position: absolute;
  z-index: 1;
  display: block;
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
  width: auto;
  max-width: none;
  min-height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #56efff, #b5ffe9 52%, var(--hud-gold));
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.42),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.health__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  opacity: 0.62;
}

@media (max-width: 640px) {
  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
    min-height: 10px;
  }
}

/* Final health fill override for the applied generated HUD. */
.health::before {
  content: "Health";
  position: absolute;
  top: 8px;
  left: 62px;
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.health__bar {
  position: absolute;
  z-index: 1;
  display: block;
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
  width: auto;
  max-width: none;
  min-height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #56efff, #b5ffe9 52%, var(--hud-gold));
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.42),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.health__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  opacity: 0.62;
}

@media (max-width: 640px) {
  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
    min-height: 10px;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #160612;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: relative;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
  min-height: 420px;
  overflow: hidden;
  background: #160612;
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}

.phaser-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #160612;
  pointer-events: none;
}

.phaser-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.game-shell.is-phaser-renderer #game {
  opacity: 0;
}

.hud {
  position: absolute;
  inset: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) auto
    max(14px, env(safe-area-inset-left));
  z-index: 2;
  display: grid;
  grid-template-columns: 168px minmax(280px, 520px) auto;
  align-items: start;
  gap: 10px;
  pointer-events: none;
}

.hud__stat {
  position: relative;
  display: block;
  min-height: 0;
  border: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: var(--text);
  filter: drop-shadow(0 12px 18px var(--hud-shadow));
}

.hud__stat--score {
  width: 168px;
  height: 70px;
  background-image: url("./assets/ui/hud-score-frame.png");
}

.hud__stat--level {
  width: 86px;
  height: 80px;
  background-image: url("./assets/ui/hud-level-badge.png");
}

.hud__stat--score .hud__label,
.hud__stat--level .hud__label,
.mission-panel__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.hud__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud__stat strong {
  position: absolute;
  color: #fff7d3;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 11px rgba(255, 215, 110, 0.42),
    0 2px 8px rgba(12, 0, 8, 0.66);
}

.hud__stat--score strong {
  left: 78px;
  right: 24px;
  bottom: 15px;
  font-size: 20px;
}

.hud__stat--level strong {
  left: 0;
  right: 0;
  top: 45px;
  font-size: 22px;
  line-height: 1;
}

.hud__controls {
  display: grid;
  grid-template-columns: 92px 86px;
  align-items: start;
  justify-self: end;
  gap: 8px;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 82px;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(12, 2, 10, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
  pointer-events: auto;
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button.is-active {
  border-color: rgba(162, 255, 251, 0.58);
  box-shadow:
    0 0 20px rgba(102, 242, 255, 0.22),
    0 12px 32px rgba(12, 2, 10, 0.28);
  outline: none;
}

.pause-button[hidden] {
  display: none;
}

.pause-button {
  display: flex;
  position: relative;
  width: 92px;
  min-width: 92px;
  height: 58px;
  padding: 0 10px 0 46px;
  border: 0;
  background:
    url("./assets/ui/hud-pause-medallion.png") left center / 56px 58px no-repeat,
    linear-gradient(90deg, rgba(21, 8, 19, 0.22), rgba(37, 9, 25, 0.86)) right center /
      calc(100% - 40px) 34px no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 12px 18px var(--hud-shadow));
  backdrop-filter: none;
}

.pause-button::after {
  content: "";
  position: absolute;
  right: 0;
  width: calc(100% - 42px);
  height: 34px;
  border: 1px solid rgba(102, 242, 255, 0.34);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  box-shadow:
    inset 0 0 18px rgba(102, 242, 255, 0.09),
    0 0 16px rgba(102, 242, 255, 0.09);
  pointer-events: none;
}

.pause-button__bars {
  display: none;
}

.pause-button__bars span {
  display: block;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff9ed, var(--cyan));
  box-shadow: 0 0 10px rgba(102, 242, 255, 0.32);
}

.pause-button__label {
  color: #dfffff;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.36);
}

.pause-button:hover,
.pause-button:focus-visible,
.pause-button.is-active {
  border: 0;
  box-shadow: none;
  filter:
    drop-shadow(0 12px 18px var(--hud-shadow))
    drop-shadow(0 0 12px rgba(102, 242, 255, 0.28));
  outline: none;
}

.health {
  position: relative;
  justify-self: center;
  width: min(500px, 100%);
  height: 74px;
  overflow: hidden;
  border: 0;
  background: url("./assets/ui/hud-health-frame.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 12px 18px var(--hud-shadow));
}

.health::before {
  content: none;
}

.health__bar {
  position: absolute;
  top: 41%;
  right: 6.5%;
  bottom: 23%;
  left: 20%;
  width: auto;
  max-width: none;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #56efff, #b5ffe9 52%, var(--hud-gold));
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.42),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.health__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  opacity: 0.62;
}

.mission-panel {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  top: calc(max(10px, env(safe-area-inset-top)) + 72px);
  z-index: 2;
  display: grid;
  gap: 5px;
  width: min(470px, calc(100vw - 32px));
  min-height: 154px;
  padding: 55px 36px 22px 82px;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: url("./assets/ui/hud-mission-frame.png") center / 100% 100% no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 14px 20px var(--hud-shadow));
  backdrop-filter: none;
  pointer-events: none;
}

.mission-panel__label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mission-panel strong {
  display: block;
  color: #fff7df;
  font-size: 17px;
  line-height: 1.1;
  text-shadow:
    0 0 14px rgba(255, 215, 110, 0.2),
    0 2px 8px rgba(12, 0, 8, 0.66);
}

.mission-panel p {
  margin: 0;
  color: rgba(255, 244, 238, 0.9);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  max-width: 330px;
}

.mission-panel__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mission-panel__meta span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 215, 110, 0.24);
  border-radius: 999px;
  color: #fff6d0;
  background: rgba(28, 6, 17, 0.56);
  font-size: 10px;
  font-weight: 850;
  text-shadow: 0 2px 8px rgba(12, 0, 8, 0.56);
}

#abilityDash,
#abilityPulse {
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  box-shadow: none;
}

#abilityDash {
  width: 132px;
  padding: 5px 16px 5px 58px;
  background-image: url("./assets/ui/hud-dash-chip-frame.png");
}

#abilityPulse {
  width: 174px;
  padding: 5px 18px 5px 92px;
  background-image: url("./assets/ui/hud-pulse-chip-frame.png");
}

.mission-panel__meta span.is-ready {
  border-color: rgba(102, 242, 255, 0.5);
  color: #dfffff;
  box-shadow: 0 0 14px rgba(102, 242, 255, 0.12);
}

.mission-panel__meta span.is-locked {
  opacity: 0.46;
}

.level-meter {
  position: absolute;
  left: max(30px, env(safe-area-inset-left));
  right: max(30px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 2;
  height: 54px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: url("./assets/ui/hud-progress-frame.png") center / 100% 100% no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 12px 18px var(--hud-shadow));
  pointer-events: none;
}

.level-meter__fill {
  position: absolute;
  top: 50%;
  right: 13.2%;
  left: 14.8%;
  display: block;
  width: auto;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #66f2ff, #b9ffe5 52%, var(--hud-gold));
  box-shadow:
    0 0 15px rgba(102, 242, 255, 0.44),
    0 0 22px rgba(255, 215, 110, 0.14);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 180ms ease;
}

.level-banner {
  position: absolute;
  left: 50%;
  top: 78px;
  z-index: 2;
  min-width: min(320px, calc(100vw - 48px));
  padding: 10px 16px;
  border: 1px solid rgba(255, 207, 174, 0.22);
  border-radius: 8px;
  color: #fff5e9;
  background: rgba(31, 7, 19, 0.62);
  box-shadow: 0 16px 40px rgba(12, 2, 10, 0.22);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  text-shadow: 0 2px 10px rgba(15, 0, 10, 0.38);
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.level-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 45%, rgba(42, 10, 24, 0.2), rgba(20, 3, 15, 0.68)),
    linear-gradient(180deg, rgba(20, 3, 12, 0.1), rgba(20, 3, 12, 0.48));
}

.overlay[hidden] {
  display: none;
}

.overlay h1 {
  margin: 0;
  color: #fff7ee;
  font-size: clamp(34px, 6vw, 82px);
  line-height: 0.95;
  text-align: center;
  text-shadow: 0 8px 30px rgba(15, 0, 10, 0.48);
  letter-spacing: 0;
}

.run-summary {
  max-width: min(560px, calc(100vw - 40px));
  margin: -6px 0 2px;
  color: rgba(255, 244, 238, 0.9);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 4px 18px rgba(15, 0, 10, 0.52);
}

.game-over-overlay {
  padding: clamp(8px, 2vw, 22px);
  background: rgba(12, 0, 8, 0.46);
}

.game-over-frame {
  position: relative;
  width: min(1240px, 99vw);
  aspect-ratio: 1672 / 941;
  color: #fff8ea;
}

.game-over-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  object-fit: contain;
  pointer-events: none;
}

.game-over-title,
.game-over-stats,
.game-over-details,
.game-over-restart {
  position: absolute;
  z-index: 1;
}

.game-over-title {
  top: 14.6%;
  right: 23.5%;
  left: 23.5%;
  display: grid;
  justify-items: center;
  gap: 0.16em;
  text-align: center;
}

.game-over-title .overlay-eyebrow {
  color: #dfffff;
  font-size: clamp(9px, 0.9vw, 13px);
  font-weight: 950;
  text-shadow:
    0 2px 6px rgba(4, 0, 12, 0.92),
    0 0 16px rgba(102, 242, 255, 0.72),
    0 0 28px rgba(102, 242, 255, 0.28);
}

.game-over-title h1 {
  max-width: 100%;
  color: #fff7df;
  font-size: clamp(17px, 2.55vw, 35px);
  line-height: 1;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(96, 25, 28, 0.78),
    0 0 20px rgba(255, 222, 164, 0.2);
  white-space: nowrap;
}

.game-over-title p {
  max-width: 74%;
  margin: 0;
  color: rgba(255, 238, 224, 0.9);
  font-size: clamp(7px, 0.82vw, 11px);
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 10px rgba(8, 0, 8, 0.72);
}

.game-over-stats {
  top: 35.8%;
  left: 27.2%;
  display: grid;
  width: 23.8%;
  height: 35.6%;
  grid-template-rows: repeat(4, 1fr);
  gap: 3.4%;
  margin: 0;
}

.game-over-stat {
  display: grid;
  align-content: center;
  position: relative;
  min-width: 0;
}

.game-over-stat--level {
  top: 7px;
}

.game-over-stat--sections {
  top: 12px;
}

.game-over-stat--virions {
  top: 18px;
}

.game-over-stat dt,
.game-over-details span {
  color: #66f2ff;
  font-size: clamp(7px, 0.78vw, 10px);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(102, 242, 255, 0.42);
}

.game-over-stat dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #fff4df;
  font-size: clamp(14px, 1.65vw, 25px);
  font-weight: 950;
  line-height: 1.12;
  text-overflow: ellipsis;
  text-shadow: 0 3px 12px rgba(6, 0, 10, 0.62);
  white-space: nowrap;
}

.game-over-details {
  top: 41.4%;
  right: 23%;
  display: grid;
  width: 20.8%;
  height: 26%;
  align-content: start;
  gap: 0.7em;
  color: rgba(255, 246, 236, 0.92);
  font-size: clamp(9px, 0.98vw, 14px);
  font-weight: 800;
  line-height: 1.2;
}

.game-over-details p,
.game-over-details div {
  display: grid;
  gap: 0.24em;
  margin: 0;
}

.game-over-details strong {
  color: #fff2c9;
  font-size: clamp(13px, 1.45vw, 22px);
  line-height: 1;
  text-shadow: 0 0 14px rgba(255, 214, 119, 0.24);
}

.game-over-details ul {
  display: grid;
  gap: 0.25em;
  max-height: 6.1em;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.game-over-details li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-over-restart {
  bottom: 11.4%;
  left: 36%;
  width: 28%;
  height: 7.3%;
  border: 0;
  color: #fff9e8;
  background: transparent;
  font-size: clamp(14px, 1.5vw, 22px);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
  -webkit-text-stroke: 1px rgba(4, 18, 24, 0.62);
  text-shadow:
    0 2px 5px rgba(0, 0, 0, 0.92),
    0 0 12px rgba(185, 255, 229, 0.48),
    0 0 22px rgba(102, 242, 255, 0.32);
  cursor: pointer;
}

.game-over-restart:hover,
.game-over-restart:focus-visible {
  color: #ffffff;
  outline: 2px solid rgba(255, 245, 210, 0.86);
  outline-offset: 4px;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.72);
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.94),
    0 0 12px rgba(255, 255, 255, 0.72),
    0 0 24px rgba(102, 242, 255, 0.64);
}

.game-over-restart:disabled {
  opacity: 0.58;
  cursor: default;
  filter: saturate(0.72);
  outline: 0;
  text-shadow:
    0 2px 5px rgba(0, 0, 0, 0.82),
    0 0 10px rgba(102, 242, 255, 0.18);
}

.primary-action {
  min-width: 154px;
  min-height: 48px;
  border: 1px solid rgba(162, 255, 251, 0.55);
  border-radius: 8px;
  color: #05232b;
  background: linear-gradient(180deg, #a6fff8, #55dcea);
  box-shadow:
    0 0 22px rgba(102, 242, 255, 0.32),
    0 18px 34px rgba(6, 0, 16, 0.34);
  font-weight: 850;
  letter-spacing: 0;
  cursor: pointer;
}

.primary-action:hover,
.primary-action:focus-visible {
  transform: translateY(-1px);
  outline: 2px solid rgba(255, 245, 210, 0.9);
  outline-offset: 3px;
}

.pause-overlay {
  background:
    radial-gradient(circle at 50% 44%, rgba(30, 182, 206, 0.12), rgba(20, 3, 15, 0.7)),
    linear-gradient(180deg, rgba(20, 3, 12, 0.16), rgba(20, 3, 12, 0.62));
}

.pause-panel {
  display: grid;
  justify-items: center;
  width: min(360px, calc(100vw - 48px));
  padding: 28px;
  border: 1px solid rgba(255, 206, 196, 0.2);
  border-radius: 8px;
  background: rgba(30, 8, 20, 0.58);
  box-shadow:
    0 0 42px rgba(102, 242, 255, 0.14),
    0 26px 70px rgba(7, 0, 10, 0.42);
  backdrop-filter: blur(14px);
}

.pause-panel h1 {
  margin-bottom: 18px;
  font-size: clamp(44px, 7vw, 72px);
}

.pause-menu {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
}

.pause-audio-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.menu-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.menu-action--primary {
  border: 1px solid rgba(162, 255, 251, 0.68);
  color: #05232b;
  background: linear-gradient(180deg, #b7fff9, #54ddea);
  box-shadow:
    0 0 24px rgba(102, 242, 255, 0.32),
    0 16px 30px rgba(6, 0, 16, 0.34);
}

.menu-action--secondary {
  border: 1px solid rgba(255, 206, 196, 0.28);
  color: #fff4ee;
  background: rgba(45, 13, 26, 0.76);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.menu-action--toggle {
  justify-content: space-between;
  gap: 14px;
  min-height: 50px;
  padding: 0 14px 0 18px;
  border: 1px solid rgba(102, 242, 255, 0.44);
  color: #fff4ee;
  background:
    radial-gradient(circle at 12% 50%, rgba(102, 242, 255, 0.18), transparent 44%),
    linear-gradient(180deg, rgba(54, 23, 39, 0.9), rgba(35, 9, 25, 0.94));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(102, 242, 255, 0.12);
}

.menu-action__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.menu-action__status {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 58px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(162, 255, 251, 0.4);
  border-radius: 999px;
  color: #082026;
  font-size: 12px;
  font-weight: 950;
  background: linear-gradient(180deg, #c7fff4, #64dce8);
  box-shadow: 0 0 12px rgba(102, 242, 255, 0.2);
}

.menu-action--toggle.is-muted {
  border-color: rgba(255, 202, 116, 0.42);
  color: rgba(255, 238, 224, 0.86);
  background:
    radial-gradient(circle at 12% 50%, rgba(255, 202, 116, 0.12), transparent 44%),
    linear-gradient(180deg, rgba(60, 17, 34, 0.9), rgba(35, 8, 24, 0.94));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 16px rgba(255, 202, 116, 0.08);
}

.menu-action--toggle.is-muted .menu-action__status {
  border-color: rgba(255, 211, 130, 0.46);
  color: #fff4d5;
  background: linear-gradient(180deg, rgba(111, 38, 45, 0.96), rgba(56, 14, 31, 0.96));
  box-shadow: 0 0 10px rgba(255, 202, 116, 0.12);
}

.menu-action--danger {
  border: 1px solid rgba(255, 202, 116, 0.5);
  color: #fff7df;
  background:
    linear-gradient(180deg, rgba(128, 36, 46, 0.92), rgba(72, 14, 32, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(255, 94, 100, 0.14);
}

.menu-action:hover,
.menu-action:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(162, 255, 251, 0.52);
  outline: 2px solid rgba(255, 245, 210, 0.8);
  outline-offset: 3px;
}

.menu-action--secondary:hover,
.menu-action--secondary:focus-visible {
  background: rgba(56, 17, 32, 0.86);
  box-shadow: 0 0 18px rgba(102, 242, 255, 0.14);
}

.menu-action--toggle:hover,
.menu-action--toggle:focus-visible {
  background:
    radial-gradient(circle at 12% 50%, rgba(102, 242, 255, 0.25), transparent 44%),
    linear-gradient(180deg, rgba(64, 27, 44, 0.94), rgba(42, 11, 29, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 0 20px rgba(102, 242, 255, 0.16);
}

.menu-action--toggle.is-muted:hover,
.menu-action--toggle.is-muted:focus-visible {
  background:
    radial-gradient(circle at 12% 50%, rgba(255, 202, 116, 0.18), transparent 44%),
    linear-gradient(180deg, rgba(72, 21, 38, 0.94), rgba(42, 10, 27, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 18px rgba(255, 202, 116, 0.12);
}

.menu-action--danger:hover,
.menu-action--danger:focus-visible {
  border-color: rgba(255, 222, 140, 0.76);
  background:
    linear-gradient(180deg, rgba(154, 44, 56, 0.96), rgba(92, 17, 38, 0.96));
  box-shadow:
    0 0 20px rgba(255, 196, 108, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.restart-confirm {
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid rgba(255, 211, 130, 0.22);
  border-radius: 8px;
  color: #fff7ec;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 213, 118, 0.1), transparent 62%),
    rgba(35, 9, 22, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 14px 32px rgba(8, 0, 10, 0.24);
}

.restart-confirm[hidden] {
  display: none;
}

.restart-confirm__title {
  margin: 0;
  color: #fff8df;
  font-size: 17px;
  font-weight: 900;
}

.restart-confirm__copy {
  margin: 0;
  color: rgba(255, 238, 224, 0.82);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.restart-confirm__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.restart-confirm__actions .menu-action {
  min-height: 44px;
  padding: 0 10px;
  font-size: 13px;
}

.level-complete-overlay {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 208, 110, 0.13), rgba(20, 3, 15, 0.72)),
    linear-gradient(180deg, rgba(20, 3, 12, 0.14), rgba(20, 3, 12, 0.66));
}

.level-complete-panel {
  display: grid;
  justify-items: center;
  width: min(620px, calc(100vw - 44px));
  padding: 28px;
  border: 1px solid rgba(255, 226, 148, 0.24);
  border-radius: 8px;
  background: rgba(30, 8, 20, 0.64);
  box-shadow:
    0 0 48px rgba(255, 208, 110, 0.12),
    0 30px 80px rgba(7, 0, 10, 0.46);
  backdrop-filter: blur(16px);
}

.level-complete-panel h1 {
  font-size: clamp(38px, 6vw, 70px);
}

.level-complete-panel p {
  margin: 12px 0 0;
  color: rgba(255, 244, 238, 0.9);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.4;
  text-align: center;
}

.level-complete-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 4px;
}

.level-complete-stats span {
  min-height: 30px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 206, 196, 0.18);
  border-radius: 999px;
  color: rgba(255, 244, 238, 0.9);
  background: rgba(20, 4, 13, 0.42);
  font-size: 12px;
  font-weight: 850;
}

#nextMissionPreview {
  margin-bottom: 20px;
  color: rgba(185, 255, 229, 0.94);
}

.upgrade-overlay {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(12, 3, 13, 0.12), rgba(11, 1, 9, 0.7)),
    radial-gradient(ellipse at 50% 40%, rgba(102, 242, 255, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(20, 3, 12, 0.12), rgba(20, 3, 12, 0.7));
}

.upgrade-overlay::before,
.upgrade-overlay::after {
  content: "";
  position: absolute;
  left: -5vw;
  right: -5vw;
  height: 145px;
  z-index: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 20% 55%, rgba(255, 148, 108, 0.22), transparent 22%),
    radial-gradient(ellipse at 75% 45%, rgba(255, 104, 116, 0.18), transparent 26%),
    linear-gradient(180deg, rgba(179, 46, 53, 0.82), rgba(69, 10, 24, 0.9));
  box-shadow:
    0 0 42px rgba(242, 123, 100, 0.28),
    inset 0 -18px 36px rgba(69, 10, 24, 0.6),
    inset 0 12px 18px rgba(255, 168, 128, 0.1);
  opacity: 0.82;
  pointer-events: none;
}

.upgrade-overlay::before {
  top: -82px;
}

.upgrade-overlay::after {
  bottom: -86px;
  transform: rotate(180deg);
}

.upgrade-panel {
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: grid;
  justify-items: center;
  width: min(1240px, calc(100vw - 32px));
  max-height: calc(100dvh - 30px);
  padding: 4px 0 0;
}

.upgrade-panel:focus {
  outline: none;
}

.upgrade-plaque {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(955px, calc(100vw - 74px));
  aspect-ratio: 956 / 222;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: url("./assets/ui/upgrade-title-plaque.png") center / 100% 100% no-repeat;
  filter:
    drop-shadow(0 18px 42px rgba(7, 0, 10, 0.44))
    drop-shadow(0 0 20px rgba(255, 177, 95, 0.18));
  text-align: center;
}

.upgrade-plaque::before,
.upgrade-plaque::after {
  display: none;
}

.upgrade-plaque__emblem {
  display: none;
}

.overlay-eyebrow {
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.upgrade-plaque .overlay-eyebrow,
.upgrade-plaque h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#upgradeIntro {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 5.5%;
  max-width: none;
  margin: 0;
  color: rgba(255, 244, 238, 0.94);
  font-size: clamp(11px, 1.05vw, 15px);
  font-weight: 780;
  line-height: 1.12;
  text-align: center;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.72);
}

.upgrade-tree {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 28px;
  width: 100%;
  margin-top: -16px;
  padding: 100px 38px 0;
}

.upgrade-tree::before {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  top: -34px;
  height: 170px;
  background: url("./assets/ui/upgrade-connectors.svg") center top / 100% 100% no-repeat;
  filter: drop-shadow(0 0 18px rgba(102, 242, 255, 0.5));
  opacity: 0.95;
  pointer-events: none;
}

.upgrade-tree::after {
  display: none;
}

.upgrade-branch {
  --branch: #66f2ff;
  --branch-soft: #9eeeff;
  --branch-glow: rgba(102, 242, 255, 0.42);
  --branch-panel: #06213a;
  position: relative;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
  justify-items: stretch;
  gap: 20px;
  height: 100%;
  min-width: 0;
}

.upgrade-branch:nth-child(2) {
  --branch: #d56cff;
  --branch-soft: #f0b4ff;
  --branch-glow: rgba(213, 108, 255, 0.38);
  --branch-panel: #371043;
}

.upgrade-branch:nth-child(3) {
  --branch: #7dffc1;
  --branch-soft: #cbffe2;
  --branch-glow: rgba(125, 255, 193, 0.38);
  --branch-panel: #0a3428;
}

.upgrade-branch::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 52px;
  height: 58px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--branch), rgba(102, 242, 255, 0.18));
  box-shadow: 0 0 18px var(--branch-glow);
  transform: translateX(-50%);
  pointer-events: none;
}

.upgrade-branch__root {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 10px;
  width: min(286px, 100%);
  height: 54px;
  padding: 6px 16px 6px 6px;
  border: 1px solid color-mix(in srgb, var(--branch) 76%, rgba(255, 226, 148, 0.32));
  border-radius: 999px;
  color: #efffff;
  background:
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.12), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--branch-panel) 78%, #163f4b), color-mix(in srgb, var(--branch-panel) 88%, #050b17));
  box-shadow:
    0 0 22px var(--branch-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0.88;
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease,
    transform 150ms ease;
}

.upgrade-branch__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: center / 118% 118% no-repeat;
  filter: drop-shadow(0 0 13px var(--branch-glow));
}

.upgrade-branch:nth-child(1) .upgrade-branch__icon {
  background-image: url("./assets/ui/upgrade-medallion-antibody.png");
}

.upgrade-branch:nth-child(2) .upgrade-branch__icon {
  background-image: url("./assets/ui/upgrade-medallion-complement.png");
}

.upgrade-branch:nth-child(3) .upgrade-branch__icon {
  background-image: url("./assets/ui/upgrade-medallion-chemotaxis.png");
}

.upgrade-node {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows:
    auto
    auto
    auto
    minmax(86px, 1fr)
    auto
    auto
    auto
    auto;
  align-content: start;
  min-height: clamp(340px, 37vh, 394px);
  height: 100%;
  overflow: visible;
  padding: 80px 28px 22px;
  border: 2px solid color-mix(in srgb, var(--branch) 62%, rgba(255, 226, 148, 0.36));
  border-radius: 8px;
  color: #fff4ee;
  background:
    radial-gradient(circle at 50% 0%, var(--branch-glow), transparent 24%),
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(180deg, color-mix(in srgb, var(--branch-panel) 72%, #2a0717), rgba(17, 4, 17, 0.93));
  box-shadow:
    0 24px 54px rgba(7, 0, 10, 0.44),
    0 0 20px color-mix(in srgb, var(--branch-glow) 62%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    inset 0 22px 40px rgba(255, 255, 255, 0.035);
  cursor: pointer;
  text-align: center;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.upgrade-node::before,
.upgrade-node::after {
  content: "";
  position: absolute;
  z-index: -1;
  border: 1px solid color-mix(in srgb, var(--branch) 52%, transparent);
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.08), transparent 38%),
    rgba(18, 6, 18, 0.58);
  box-shadow: 0 0 18px var(--branch-glow);
}

.upgrade-node::before {
  left: -18px;
  top: 72px;
  width: 28px;
  height: 150px;
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.upgrade-node::after {
  right: -18px;
  top: 72px;
  width: 28px;
  height: 150px;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.upgrade-branch:hover .upgrade-branch__root,
.upgrade-branch:focus-within .upgrade-branch__root {
  border-color: color-mix(in srgb, var(--branch) 88%, white 10%);
  box-shadow:
    0 0 28px var(--branch-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  opacity: 1;
  transform: translateY(-1px);
}

.upgrade-branch:hover .upgrade-node,
.upgrade-branch:focus-within .upgrade-node {
  border-color: color-mix(in srgb, var(--branch) 84%, white 10%);
  box-shadow:
    0 0 42px var(--branch-glow),
    0 30px 64px rgba(7, 0, 10, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  outline: 2px solid rgba(255, 245, 210, 0.84);
  outline-offset: 4px;
  transform: translateY(-3px);
}

.upgrade-node:focus-visible {
  outline: 2px solid rgba(255, 245, 210, 0.84);
  outline-offset: 4px;
}

.upgrade-node:hover {
  outline: none;
}

.upgrade-node:disabled,
.upgrade-node.is-maxed {
  cursor: default;
  opacity: 0.72;
}

.upgrade-node:disabled:hover,
.upgrade-node.is-maxed:hover {
  border-color: color-mix(in srgb, var(--branch) 62%, rgba(255, 226, 148, 0.36));
  box-shadow:
    0 24px 54px rgba(7, 0, 10, 0.44),
    0 0 34px var(--branch-glow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.055);
  transform: none;
}

.upgrade-node__medallion {
  position: absolute;
  left: 50%;
  top: -58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 118px;
  height: 118px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  filter:
    drop-shadow(0 0 26px var(--branch-glow))
    drop-shadow(0 12px 18px rgba(6, 0, 12, 0.38));
  transform: translateX(-50%);
}

.upgrade-node__medallion img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upgrade-node__term {
  justify-self: center;
  min-height: 26px;
  padding: 5px 16px;
  border: 1px solid color-mix(in srgb, var(--branch) 54%, transparent);
  border-radius: 999px;
  color: var(--branch-soft);
  background: rgba(9, 21, 35, 0.7);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
}

.upgrade-node__title {
  margin-top: 12px;
  color: #fff9ee;
  font-size: clamp(19px, 1.8vw, 25px);
  font-weight: 950;
  line-height: 1.05;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.36);
}

.upgrade-node__use {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 46px;
  margin-top: 14px;
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--branch) 56%, transparent);
  border-radius: 999px;
  color: #dfffff;
  background: rgba(6, 24, 38, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
}

.upgrade-node__keys {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.upgrade-node__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 23px;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--branch) 76%, white 12%);
  border-radius: 6px;
  color: #fff9ee;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.14)),
    color-mix(in srgb, var(--branch) 36%, rgba(15, 5, 18, 0.86));
  box-shadow: 0 0 10px var(--branch-glow);
}

.upgrade-node__body {
  align-self: start;
  margin-top: 14px;
  color: rgba(255, 244, 238, 0.9);
  font-size: 14px;
  font-weight: 720;
  line-height: 1.36;
}

.upgrade-node__divider {
  display: block;
  width: min(240px, 82%);
  height: 1px;
  justify-self: center;
  margin-top: 14px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 226, 148, 0.86), transparent);
}

.upgrade-node__next-label {
  margin-top: 8px;
  color: #ffe294;
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.upgrade-node__next {
  margin-top: 7px;
  color: #ffe294;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}

.upgrade-node__rank {
  margin-top: 12px;
  color: rgba(255, 226, 148, 0.96);
  font-size: 12px;
  font-weight: 950;
}

.upgrade-node__pips {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.upgrade-node__pip {
  width: 15px;
  height: 15px;
  border: 1px solid color-mix(in srgb, var(--branch) 78%, #ffd06e 16%);
  border-radius: 999px;
  background: rgba(20, 4, 13, 0.56);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.38);
}

.upgrade-node__pip.is-filled {
  border-color: #ffe294;
  background:
    radial-gradient(circle, #fff8c8 0 18%, #ffd767 22% 54%, #b87316 58% 100%);
  box-shadow:
    0 0 9px rgba(255, 226, 148, 0.96),
    0 0 20px rgba(255, 184, 64, 0.48),
    inset 0 0 7px rgba(255, 255, 255, 0.22);
  animation: rankPulse 1.45s ease-in-out infinite;
}

@keyframes rankPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 8px rgba(255, 226, 148, 0.9),
      0 0 16px rgba(255, 184, 64, 0.38),
      inset 0 0 7px rgba(255, 255, 255, 0.2);
  }

  50% {
    transform: scale(1.14);
    box-shadow:
      0 0 13px rgba(255, 241, 176, 1),
      0 0 28px rgba(255, 190, 64, 0.62),
      inset 0 0 8px rgba(255, 255, 255, 0.28);
  }
}

.upgrade-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(760px, calc(100vw - 58px));
  min-height: 38px;
  margin-top: 18px !important;
  padding: 8px 18px;
  border: 1px solid rgba(255, 196, 108, 0.72);
  border-radius: 8px;
  color: rgba(255, 244, 238, 0.94);
  background: rgba(29, 6, 16, 0.74);
  box-shadow:
    0 0 22px rgba(255, 208, 110, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  font-size: 14px !important;
}

.upgrade-tip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(102, 242, 255, 0.72);
  border-radius: 50%;
  color: #dfffff;
  font-size: 13px;
  font-weight: 950;
}

@media (max-width: 640px) {
  .game-shell {
    min-height: 360px;
  }

  .hud {
    grid-template-columns: 116px minmax(150px, 1fr) auto;
    gap: 6px;
    inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) auto
      max(8px, env(safe-area-inset-left));
  }

  .hud__stat--score {
    width: 116px;
    height: 50px;
  }

  .hud__stat--score strong {
    right: 16px;
    bottom: 10px;
    left: 54px;
    font-size: 15px;
  }

  .hud__stat--level {
    width: 56px;
    height: 54px;
  }

  .hud__stat--level strong {
    top: 31px;
    font-size: 15px;
  }

  .level-banner {
    top: 64px;
    min-width: min(280px, calc(100vw - 36px));
    padding: 8px 12px;
    font-size: 12px;
  }

  .mission-panel {
    top: auto;
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 34px);
    width: min(340px, calc(100vw - 18px));
    min-height: 118px;
    padding: 43px 23px 18px 60px;
  }

  .mission-panel strong {
    font-size: 15px;
  }

  .mission-panel p {
    font-size: 11px;
  }

  .mission-panel__meta {
    gap: 4px;
  }

  .mission-panel__meta span {
    min-height: 20px;
    font-size: 9px;
  }

  #abilityDash {
    width: 110px;
    padding: 4px 12px 4px 47px;
  }

  #abilityPulse {
    width: 142px;
    padding: 4px 13px 4px 76px;
  }

  .health {
    width: min(240px, 100%);
    height: 50px;
  }

  .hud__controls {
    grid-template-columns: 48px 56px;
    gap: 4px;
  }

  .icon-button {
    width: 48px;
    height: 48px;
    gap: 0;
    padding: 0;
  }

  .pause-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(102, 242, 255, 0.42);
    border-radius: 8px;
    background:
      linear-gradient(135deg, rgba(18, 60, 68, 0.88), rgba(31, 7, 23, 0.78));
    box-shadow:
      0 10px 24px rgba(10, 0, 8, 0.34),
      inset 0 0 0 1px rgba(255, 215, 110, 0.1);
    filter: none;
  }

  .pause-button::after {
    display: none;
  }

  .pause-button__bars {
    display: grid;
    grid-template-columns: repeat(2, 5px);
    gap: 5px;
    width: 15px;
    height: 20px;
  }

  .pause-button__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .level-meter {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(4px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    height: 34px;
  }

  .level-meter__fill {
    height: 3px;
  }

  .pause-panel {
    width: min(300px, calc(100vw - 36px));
    padding: 22px;
  }

  .level-complete-panel {
    width: min(320px, calc(100vw - 36px));
    padding: 22px;
  }

  .level-complete-stats {
    gap: 6px;
  }

  .level-complete-stats span {
    min-height: 28px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .pause-panel h1 {
    margin-bottom: 14px;
  }

  .menu-action {
    min-height: 48px;
    font-size: 15px;
  }

  .upgrade-panel {
    width: calc(100vw - 28px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    padding: 36px 12px 18px;
  }

  .upgrade-plaque {
    width: 100%;
    aspect-ratio: 956 / 222;
    min-height: 0;
    padding: 0;
  }

  .upgrade-plaque::before,
  .upgrade-plaque::after {
    display: none;
  }

  .upgrade-plaque__emblem {
    display: none;
  }

  #upgradeIntro {
    left: 12%;
    right: 12%;
    bottom: 5%;
    font-size: clamp(9px, 2.8vw, 11px);
    line-height: 1.08;
  }

  .upgrade-tree {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-top: -4px;
    padding: 58px 0 0;
  }

  .upgrade-tree::before,
  .upgrade-tree::after {
    display: none;
  }

  .upgrade-branch {
    grid-template-rows: 48px minmax(0, 1fr);
    gap: 22px;
  }

  .upgrade-branch::before {
    top: 46px;
    height: 56px;
    width: 3px;
  }

  .upgrade-branch__root {
    width: min(270px, 100%);
    height: 48px;
    padding: 6px 14px 6px 6px;
    font-size: 12px;
  }

  .upgrade-branch__icon {
    flex-basis: 40px;
    width: 38px;
    height: 38px;
  }

  .upgrade-node {
    min-height: auto;
    padding: 62px 18px 18px;
  }

  .upgrade-node::before,
  .upgrade-node::after {
    display: none;
  }

  .upgrade-node__medallion {
    top: -29px;
    width: 70px;
    height: 70px;
    font-size: 27px;
  }

  .upgrade-node__title {
    font-size: 20px;
  }

  .upgrade-node__use {
    border-radius: 8px;
  }

  .upgrade-tip {
    width: 100%;
    font-size: 12px !important;
  }
}

/* Generated HUD ornament integration. Text and layout stay live/readable; art is decorative. */
.hud {
  grid-template-columns: 146px minmax(245px, 360px) auto;
  gap: 10px;
}

.hud__stat,
.health,
.mission-panel,
.level-meter {
  isolation: isolate;
}

.hud__stat {
  min-height: 50px;
  padding: 8px 12px 8px 58px;
  border-color: rgba(102, 242, 255, 0.42);
  background:
    linear-gradient(90deg, rgba(8, 45, 54, 0.78), rgba(48, 9, 26, 0.78)),
    rgba(20, 5, 15, 0.58);
}

.hud__stat::before {
  top: -8px;
  bottom: auto;
  left: -8px;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 0;
  background: url("./assets/ui/hud-orn-score.png") center / contain no-repeat;
  box-shadow: none;
  z-index: 0;
}

.hud__stat::after,
.health::after,
.mission-panel::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 58px;
  height: 58px;
  background: url("./assets/ui/hud-orn-red-corner.png") center / contain no-repeat;
  opacity: 0.84;
  pointer-events: none;
  z-index: 0;
}

.hud__stat .hud__label,
.hud__stat strong,
.health__bar,
.mission-panel > * {
  position: relative;
  z-index: 1;
}

.health::before {
  z-index: 1;
}

.hud__stat--score {
  width: 146px;
}

.hud__stat--level {
  width: 70px;
  min-height: 56px;
  padding: 8px 5px 7px;
  border: 0;
  background: url("./assets/ui/hud-orn-level.png") center / contain no-repeat;
  box-shadow: none;
}

.hud__stat--level::before,
.hud__stat--level::after {
  display: none;
}

.hud__stat--level .hud__label {
  color: #ffe18a;
}

.hud__stat--score strong,
.hud__stat--level strong {
  font-size: 18px;
}

.health {
  width: min(360px, 100%);
  height: 50px;
  padding-left: 60px;
  border-color: rgba(102, 242, 255, 0.44);
  background:
    linear-gradient(90deg, rgba(8, 49, 57, 0.84), rgba(48, 9, 26, 0.76)),
    rgba(18, 5, 15, 0.58);
}

.health::after {
  top: -8px;
  right: auto;
  bottom: auto;
  left: -8px;
  width: 62px;
  height: 62px;
  background-image: url("./assets/ui/hud-orn-health.png");
  opacity: 1;
}

.health::before {
  left: 62px;
}

.health__bar {
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
}

.mission-panel {
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  width: min(330px, calc(100vw - 32px));
  padding: 12px 12px 12px 62px;
  border-color: rgba(102, 242, 255, 0.36);
  background:
    linear-gradient(135deg, rgba(42, 8, 25, 0.88), rgba(16, 45, 52, 0.62)),
    rgba(18, 5, 15, 0.62);
}

.mission-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -8px;
  width: 62px;
  height: 62px;
  background: url("./assets/ui/hud-orn-mission.png") center / contain no-repeat;
  pointer-events: none;
  z-index: 0;
}

.mission-panel::after {
  width: 50px;
  height: 50px;
}

.mission-panel strong {
  font-size: 14px;
  line-height: 1.05;
}

.mission-panel p {
  display: -webkit-box;
  max-width: 250px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 10px;
  line-height: 1.2;
}

.mission-panel__meta {
  gap: 4px;
}

.mission-panel__meta span,
#abilityDash,
#abilityPulse {
  min-height: 20px;
  padding: 3px 7px;
  font-size: 9px;
}

.mission-panel__meta::after {
  content: "";
  flex-basis: 100%;
  height: 9px;
  margin-top: -1px;
  background: url("./assets/ui/hud-orn-gold-divider.png") left center / 150px auto no-repeat;
  opacity: 0.72;
}

.level-meter {
  height: 17px;
  border-color: rgba(102, 242, 255, 0.36);
}

.level-meter::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(340px, 50vw);
  height: 34px;
  background: url("./assets/ui/hud-orn-cyan-divider.png") center / contain no-repeat;
  opacity: 0.76;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 0;
}

.level-meter__fill {
  z-index: 1;
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: 102px minmax(116px, 1fr) auto;
    gap: 6px;
  }

  .hud__stat {
    min-height: 42px;
    padding: 6px 8px 6px 42px;
  }

  .hud__stat::before,
  .health::after,
  .mission-panel::before {
    width: 48px;
    height: 48px;
  }

  .hud__stat--score {
    width: 102px;
  }

  .hud__stat--level {
    width: 54px;
    min-height: 46px;
    padding: 6px 4px;
  }

  .health {
    width: min(210px, 100%);
    height: 42px;
    padding-left: 47px;
  }

  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
  }

  .mission-panel {
    width: min(300px, calc(100vw - 18px));
    padding: 10px 10px 10px 48px;
  }

  .mission-panel p {
    max-width: none;
  }
}

/* HUD polish pass: keep the generated-art direction without stretching bitmap frames. */
.hud {
  inset: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) auto
    max(14px, env(safe-area-inset-left));
  grid-template-columns: 132px minmax(250px, 390px) auto;
  align-items: start;
  gap: 12px;
}

.hud__stat,
.health,
.mission-panel,
.level-meter {
  background-image: none;
}

.hud__stat {
  display: grid;
  align-content: center;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid rgba(102, 242, 255, 0.34);
  border-radius: 8px;
  background:
    radial-gradient(circle at 16% 48%, rgba(102, 242, 255, 0.28), transparent 18%),
    linear-gradient(135deg, rgba(40, 9, 24, 0.84), rgba(23, 5, 17, 0.66));
  box-shadow:
    0 10px 24px rgba(10, 0, 8, 0.34),
    inset 0 0 0 1px rgba(255, 215, 110, 0.12),
    inset 0 0 22px rgba(102, 242, 255, 0.07);
  filter: none;
  overflow: hidden;
}

.hud__stat::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 9px;
  width: 28px;
  border: 1px solid rgba(255, 215, 110, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(102, 242, 255, 0.9) 0 18%, rgba(102, 242, 255, 0.22) 20% 42%, transparent 46%),
    rgba(25, 6, 18, 0.72);
  box-shadow: 0 0 16px rgba(102, 242, 255, 0.24);
}

.hud__stat--score,
.hud__stat--level {
  width: auto;
  height: 48px;
  padding-left: 48px;
}

.hud__stat--level {
  width: 78px;
  padding: 8px 10px;
  text-align: center;
}

.hud__stat--level::before {
  display: none;
}

.hud__stat--score .hud__label,
.hud__stat--level .hud__label,
.mission-panel__label {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.hud__label,
.mission-panel__label {
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.hud__stat strong,
.hud__stat--score strong,
.hud__stat--level strong {
  position: static;
  display: block;
  color: #fff7d3;
  font-size: 20px;
  line-height: 1;
  text-align: left;
}

.hud__stat--level strong {
  text-align: center;
}

.hud__controls {
  grid-template-columns: 78px 78px;
  gap: 8px;
}

.pause-button {
  width: 78px;
  min-width: 78px;
  height: 48px;
  padding: 0 9px;
  border: 1px solid rgba(102, 242, 255, 0.36);
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 50%, rgba(102, 242, 255, 0.32), transparent 22%),
    linear-gradient(135deg, rgba(15, 56, 64, 0.82), rgba(35, 7, 24, 0.72));
  box-shadow:
    0 10px 24px rgba(10, 0, 8, 0.34),
    inset 0 0 0 1px rgba(255, 215, 110, 0.11);
  filter: none;
}

.pause-button::after {
  display: none;
}

.pause-button__bars {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 4px);
  gap: 4px;
  width: 12px;
  height: 15px;
}

.pause-button:hover,
.pause-button:focus-visible,
.pause-button.is-active {
  border-color: rgba(102, 242, 255, 0.66);
  box-shadow:
    0 0 16px rgba(102, 242, 255, 0.18),
    0 10px 24px rgba(10, 0, 8, 0.34);
  filter: none;
}

.health {
  width: min(390px, 100%);
  height: 48px;
  border: 1px solid rgba(102, 242, 255, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(102, 242, 255, 0.12), transparent 44%),
    linear-gradient(135deg, rgba(18, 55, 63, 0.82), rgba(43, 7, 24, 0.78));
  box-shadow:
    0 10px 24px rgba(10, 0, 8, 0.34),
    inset 0 0 0 1px rgba(255, 215, 110, 0.11);
  filter: none;
}

.health::before {
  content: "Health";
  position: absolute;
  top: 7px;
  left: 14px;
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.health__bar {
  top: 24px;
  right: 12px;
  bottom: 9px;
  left: 12px;
}

.mission-panel {
  top: calc(max(12px, env(safe-area-inset-top)) + 58px);
  width: min(350px, calc(100vw - 32px));
  min-height: 0;
  padding: 12px 14px 13px;
  border: 1px solid rgba(102, 242, 255, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 22%, rgba(102, 242, 255, 0.18), transparent 22%),
    linear-gradient(135deg, rgba(48, 9, 25, 0.84), rgba(23, 5, 17, 0.66));
  box-shadow:
    0 12px 28px rgba(10, 0, 8, 0.34),
    inset 0 0 0 1px rgba(255, 215, 110, 0.12);
  filter: none;
  gap: 5px;
}

.mission-panel strong {
  font-size: 15px;
}

.mission-panel p {
  max-width: none;
  font-size: 11px;
}

.mission-panel__meta {
  gap: 5px;
}

.mission-panel__meta span,
#abilityDash,
#abilityPulse {
  width: auto;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 215, 110, 0.26);
  border-radius: 999px;
  background: rgba(21, 5, 15, 0.58);
}

.level-meter {
  right: max(22px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(22px, env(safe-area-inset-left));
  height: 16px;
  overflow: hidden;
  border: 1px solid rgba(102, 242, 255, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(102, 242, 255, 0.1), rgba(255, 215, 110, 0.08)),
    rgba(18, 5, 15, 0.64);
  box-shadow:
    0 10px 24px rgba(10, 0, 8, 0.3),
    inset 0 0 0 1px rgba(255, 215, 110, 0.08);
  filter: none;
}

.level-meter__fill {
  top: 3px;
  right: 3px;
  bottom: 3px;
  left: 3px;
  height: auto;
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: 96px minmax(120px, 1fr) auto;
    gap: 6px;
    inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) auto
      max(8px, env(safe-area-inset-left));
  }

  .hud__stat--score,
  .hud__stat--level,
  .pause-button {
    height: 42px;
  }

  .hud__stat--score {
    padding-left: 40px;
  }

  .hud__stat--level {
    width: 58px;
    padding: 6px 8px;
  }

  .hud__stat--level::before {
    display: none;
  }

  .hud__stat strong,
  .hud__stat--score strong,
  .hud__stat--level strong {
    font-size: 15px;
  }

  .hud__label,
  .mission-panel__label,
  .health::before {
    font-size: 8px;
  }

  .hud__controls {
    grid-template-columns: 42px 58px;
    gap: 5px;
  }

  .pause-button {
    width: 42px;
    min-width: 42px;
  }

  .pause-button__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .health {
    width: min(220px, 100%);
    height: 42px;
  }

  .health__bar {
    top: 22px;
    bottom: 8px;
  }

  .mission-panel {
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 28px);
    width: min(320px, calc(100vw - 18px));
    padding: 10px 12px 11px;
  }

  .level-meter {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(5px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    height: 12px;
  }
}

/* Active HUD layer: generated transparent ornaments plus compact readable panels. */
.hud {
  inset: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) auto
    max(14px, env(safe-area-inset-left));
  grid-template-columns: 146px minmax(245px, 360px) auto;
  gap: 10px;
}

.hud__stat,
.health,
.mission-panel,
.level-meter {
  overflow: visible;
  isolation: isolate;
}

.hud__stat {
  min-height: 50px;
  padding: 8px 12px 8px 58px;
  border: 1px solid rgba(102, 242, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(8, 45, 54, 0.78), rgba(48, 9, 26, 0.78)),
    rgba(20, 5, 15, 0.58);
}

.hud__stat::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: auto;
  left: -8px;
  display: block;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 0;
  background: url("./assets/ui/hud-orn-score.png") center / contain no-repeat;
  box-shadow: none;
}

.hud__stat::after,
.health::after,
.mission-panel::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: block;
  width: 58px;
  height: 58px;
  background: url("./assets/ui/hud-orn-red-corner.png") center / contain no-repeat;
  opacity: 0.78;
  pointer-events: none;
}

.hud__stat--score {
  width: 146px;
}

.hud__stat--score .hud__label,
.hud__stat--level .hud__label,
.mission-panel__label {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  clip-path: none;
  white-space: normal;
}

.hud__stat strong,
.hud__stat--score strong,
.hud__stat--level strong {
  position: static;
  display: block;
  color: #fff7d3;
  font-size: 18px;
  line-height: 1;
  text-align: left;
}

.hud__stat--level {
  width: 70px;
  min-height: 56px;
  padding: 8px 5px 7px;
  border: 0;
  background: url("./assets/ui/hud-orn-level.png") center / contain no-repeat;
  box-shadow: none;
}

.hud__stat--level::before,
.hud__stat--level::after {
  display: none;
}

.hud__stat--level strong,
.hud__stat--level .hud__label {
  text-align: center;
}

.health {
  width: min(360px, 100%);
  height: 50px;
  border-color: rgba(102, 242, 255, 0.44);
  background:
    linear-gradient(90deg, rgba(8, 49, 57, 0.84), rgba(48, 9, 26, 0.76)),
    rgba(18, 5, 15, 0.58);
}

.health::after {
  top: -8px;
  right: auto;
  bottom: auto;
  left: -8px;
  width: 62px;
  height: 62px;
  background-image: url("./assets/ui/hud-orn-health.png");
  opacity: 1;
}

.health::before {
  left: 62px;
}

.health__bar {
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
}

.mission-panel {
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  width: min(330px, calc(100vw - 32px));
  padding: 12px 12px 12px 62px;
  border-color: rgba(102, 242, 255, 0.36);
  background:
    linear-gradient(135deg, rgba(42, 8, 25, 0.88), rgba(16, 45, 52, 0.62)),
    rgba(18, 5, 15, 0.62);
}

.mission-panel::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -8px;
  width: 62px;
  height: 62px;
  background: url("./assets/ui/hud-orn-mission.png") center / contain no-repeat;
  pointer-events: none;
}

.mission-panel::after {
  width: 50px;
  height: 50px;
}

.mission-panel strong {
  font-size: 14px;
  line-height: 1.05;
}

.mission-panel p {
  display: -webkit-box;
  max-width: 250px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 10px;
  line-height: 1.2;
}

.mission-panel__meta {
  gap: 4px;
}

.mission-panel__meta span,
#abilityDash,
#abilityPulse {
  width: auto;
  min-height: 20px;
  padding: 3px 7px;
  font-size: 9px;
}

.mission-panel__meta::after {
  content: "";
  flex-basis: 100%;
  height: 9px;
  margin-top: -1px;
  background: url("./assets/ui/hud-orn-gold-divider.png") left center / 150px auto no-repeat;
  opacity: 0.72;
}

.level-meter {
  height: 17px;
  overflow: hidden;
  border-color: rgba(102, 242, 255, 0.36);
}

.level-meter::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(340px, 50vw);
  height: 34px;
  background: url("./assets/ui/hud-orn-cyan-divider.png") center / contain no-repeat;
  opacity: 0.76;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.level-meter__fill {
  z-index: 1;
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: 102px minmax(116px, 1fr) auto;
    gap: 6px;
  }

  .hud__stat {
    min-height: 42px;
    padding: 6px 8px 6px 42px;
  }

  .hud__stat::before,
  .health::after,
  .mission-panel::before {
    width: 48px;
    height: 48px;
  }

  .hud__stat--score {
    width: 102px;
  }

  .hud__stat--level {
    width: 54px;
    min-height: 46px;
    padding: 6px 4px;
  }

  .health {
    width: min(210px, 100%);
    height: 42px;
  }

  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
  }

  .mission-panel {
    width: min(300px, calc(100vw - 18px));
    padding: 10px 10px 10px 48px;
  }

  .mission-panel p {
    max-width: none;
  }
}

/* Final health fill override for the applied generated HUD. */
.health::before {
  content: "Health";
  position: absolute;
  top: 8px;
  left: 62px;
  color: #66f2ff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(102, 242, 255, 0.34);
}

.health__bar {
  position: absolute;
  z-index: 1;
  display: block;
  top: 25px;
  right: 12px;
  bottom: 9px;
  left: 62px;
  width: auto;
  max-width: none;
  min-height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #56efff, #b5ffe9 52%, var(--hud-gold));
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.42),
    inset 0 0 10px rgba(255, 255, 255, 0.16);
  transform-origin: left center;
  transition: transform 160ms ease;
}

.health__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  opacity: 0.62;
}

@media (max-width: 640px) {
  .health::before {
    left: 48px;
  }

  .health__bar {
    right: 9px;
    bottom: 8px;
    left: 48px;
    min-height: 10px;
  }
}
/* Final corner cleanup: use the generated ornament as a real corner, not an end cap. */
.hud__stat::after {
  content: none;
  display: none;
}

.hud__stat--score::after,
.mission-panel::after {
  content: "";
  position: absolute;
  display: block;
  width: 40px;
  height: 43px;
  background: url("./assets/ui/hud-orn-cyan-corner.png") center / contain no-repeat;
  opacity: 0.56;
  pointer-events: none;
}

.hud__stat--score::after {
  top: -4px;
  right: -4px;
  bottom: auto;
  left: auto;
  transform: scaleX(-1);
}

.hud__stat--level::after {
  content: none;
  display: none;
}

.mission-panel::after {
  top: auto;
  right: -5px;
  bottom: -5px;
  left: auto;
  width: 42px;
  height: 45px;
  transform: rotate(180deg);
}

@media (max-width: 640px) {
  .hud__stat--score::after,
  .mission-panel::after {
    width: 32px;
    height: 35px;
  }
}

.touch-start-note {
  display: none;
  max-width: min(460px, calc(100vw - 42px));
  margin: -10px 0 0;
  color: rgba(223, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 4px 18px rgba(15, 0, 10, 0.52);
}

.mobile-controls,
.orientation-prompt {
  display: none;
}

.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.mobile-joystick,
.mobile-actions {
  position: absolute;
  pointer-events: auto;
}

.mobile-joystick {
  left: max(20px, env(safe-area-inset-left));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  touch-action: none;
}

.mobile-joystick__ring {
  position: absolute;
  inset: 8px;
  display: block;
  border: 2px solid rgba(102, 242, 255, 0.42);
  border-radius: inherit;
  background:
    radial-gradient(circle, rgba(102, 242, 255, 0.08), rgba(29, 6, 19, 0.46) 62%),
    rgba(13, 4, 14, 0.2);
  box-shadow:
    0 0 24px rgba(102, 242, 255, 0.12),
    inset 0 0 28px rgba(102, 242, 255, 0.08);
  backdrop-filter: blur(8px);
}

.mobile-joystick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 247, 211, 0.42);
  border-radius: inherit;
  background:
    radial-gradient(circle at 38% 32%, rgba(255, 255, 255, 0.84), rgba(102, 242, 255, 0.82) 38%, rgba(23, 74, 88, 0.84)),
    rgba(102, 242, 255, 0.72);
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.46),
    0 10px 26px rgba(12, 2, 10, 0.38);
  transform: translate(-50%, -50%);
  transition: transform 90ms ease;
}

.mobile-joystick.is-active .mobile-joystick__knob {
  transition: none;
}

.mobile-actions {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 74px 74px;
  grid-template-areas:
    "dash fire"
    "pulse fire";
  align-items: center;
  gap: 10px;
  touch-action: none;
}

.mobile-action {
  min-width: 0;
  border: 1px solid rgba(102, 242, 255, 0.34);
  border-radius: 999px;
  color: #e8ffff;
  background:
    linear-gradient(145deg, rgba(14, 67, 76, 0.82), rgba(54, 8, 29, 0.78)),
    rgba(14, 4, 16, 0.42);
  box-shadow:
    0 0 18px rgba(102, 242, 255, 0.12),
    0 12px 28px rgba(12, 2, 10, 0.38);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(12, 0, 8, 0.66);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-action--fire {
  grid-area: fire;
  width: 84px;
  height: 84px;
  border-color: rgba(255, 215, 110, 0.54);
  color: #fff7d3;
  background:
    radial-gradient(circle at 40% 32%, rgba(255, 255, 255, 0.34), transparent 35%),
    linear-gradient(145deg, rgba(114, 42, 22, 0.88), rgba(55, 8, 31, 0.9));
}

.mobile-action--dash,
.mobile-action--pulse {
  width: 74px;
  height: 54px;
  font-size: 11px;
}

.mobile-action--dash {
  grid-area: dash;
}

.mobile-action--pulse {
  grid-area: pulse;
}

.mobile-action small {
  display: block;
  margin-top: 2px;
  color: rgba(255, 247, 211, 0.76);
  font-size: 8px;
  line-height: 1;
}

.mobile-action.is-pressed,
.mobile-action:active {
  border-color: rgba(185, 255, 229, 0.78);
  filter: brightness(1.13);
  transform: translateY(1px) scale(0.98);
}

.mobile-action:disabled {
  opacity: 0.44;
  filter: grayscale(0.35);
}

.orientation-prompt {
  position: absolute;
  inset: 0;
  z-index: 7;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 42%, rgba(63, 10, 31, 0.78), rgba(15, 3, 13, 0.94)),
    rgba(15, 3, 13, 0.92);
  text-align: center;
}

.orientation-prompt div {
  display: grid;
  gap: 10px;
}

.orientation-prompt span {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(102, 242, 255, 0.34);
}

.orientation-prompt strong {
  max-width: 280px;
  color: #fff7ee;
  font-size: clamp(24px, 8vw, 42px);
  line-height: 1.02;
  text-shadow: 0 8px 30px rgba(15, 0, 10, 0.52);
}

@media (pointer: coarse) {
  .touch-start-note {
    display: block;
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  .game-shell {
    min-height: 0;
  }

  .mobile-controls:not([hidden]) {
    display: block;
  }

  .hud {
    grid-template-columns: 124px minmax(210px, 330px) auto;
    gap: 6px;
    inset: max(8px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) auto
      max(9px, env(safe-area-inset-left));
  }

  .hud__stat--score {
    width: 124px;
    height: 52px;
  }

  .hud__stat--score strong {
    left: 58px;
    right: 16px;
    bottom: 10px;
    font-size: 16px;
  }

  .health {
    width: min(330px, 100%);
    height: 52px;
  }

  .hud__controls {
    grid-template-columns: 48px 58px;
    gap: 4px;
  }

  .pause-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid rgba(102, 242, 255, 0.42);
    border-radius: 8px;
    background:
      linear-gradient(135deg, rgba(18, 60, 68, 0.88), rgba(31, 7, 23, 0.78)) !important;
    box-shadow:
      0 10px 24px rgba(10, 0, 8, 0.34),
      inset 0 0 0 1px rgba(255, 215, 110, 0.1);
    filter: none;
  }

  .pause-button::after,
  .pause-button__label {
    display: none;
  }

  .pause-button__bars {
    display: grid;
    grid-template-columns: repeat(2, 5px);
    gap: 5px;
    width: 15px;
    height: 20px;
  }

  .hud__stat--level {
    width: 58px;
    height: 54px;
  }

  .hud__stat--level strong {
    top: 30px;
    font-size: 15px;
  }

  .mission-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 54px);
    bottom: auto;
    width: min(340px, 42vw);
    min-height: 104px;
    padding: 38px 22px 16px 60px;
  }

  .mission-panel strong {
    font-size: 14px;
  }

  .mission-panel p {
    max-width: 250px;
    font-size: 10px;
    -webkit-line-clamp: 2;
  }

  .mission-panel__meta span {
    min-height: 19px;
    font-size: 8px;
  }

  #abilityDash {
    width: 106px;
    padding-left: 44px;
  }

  #abilityPulse {
    width: 132px;
    padding-left: 68px;
  }

  .level-meter {
    left: calc(max(150px, env(safe-area-inset-left)) + 6px);
    right: calc(max(150px, env(safe-area-inset-right)) + 6px);
    bottom: max(4px, env(safe-area-inset-bottom));
    height: 22px;
    opacity: 0.8;
  }

  .level-banner {
    top: 58px;
  }

  .overlay {
    padding: 16px;
  }

  .level-complete-overlay {
    align-content: start;
    justify-items: center;
    place-items: start center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-block: max(16px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-bottom));
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .overlay h1 {
    font-size: clamp(32px, 7vw, 58px);
  }

  .level-complete-panel {
    width: min(420px, calc(100vw - 44px));
    max-height: none;
    padding: 20px;
    touch-action: pan-y;
  }

  .pause-panel {
    width: min(420px, calc(100vw - 44px));
    padding: 20px;
  }

  .level-complete-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .upgrade-panel {
    width: min(1120px, calc(100vw - 24px));
    max-height: calc(100dvh - 18px);
    overflow: auto;
    padding-top: 18px;
  }

  .upgrade-plaque {
    width: min(700px, 72vw);
  }

  .upgrade-tree {
    gap: clamp(10px, 2vw, 22px);
    margin-top: -8px;
  }

  .upgrade-node {
    min-height: 230px;
    padding: 58px 20px 18px;
  }

  .upgrade-node__title {
    font-size: clamp(18px, 2.2vw, 24px);
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 430px) {
  .mobile-joystick {
    width: 98px;
    height: 98px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .mobile-joystick__knob {
    width: 42px;
    height: 42px;
  }

  .mobile-actions {
    grid-template-columns: 58px 66px;
    gap: 7px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .mobile-action--fire {
    width: 70px;
    height: 70px;
    font-size: 14px;
  }

  .mobile-action--dash,
  .mobile-action--pulse {
    width: 58px;
    height: 42px;
    font-size: 9px;
  }

  .mobile-action small {
    font-size: 7px;
  }

  .mission-panel {
    width: min(310px, 38vw);
    min-height: 92px;
    padding: 34px 18px 14px 56px;
    transform: scale(0.78);
    transform-origin: top left;
  }

  .mission-panel p {
    display: none;
  }

  .level-meter {
    left: calc(max(122px, env(safe-area-inset-left)) + 4px);
    right: calc(max(122px, env(safe-area-inset-right)) + 4px);
    height: 18px;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .orientation-prompt {
    display: grid;
  }

  .mobile-controls {
    display: none !important;
  }
}

html.is-touch-device,
html.is-touch-device body {
  width: var(--app-width, 100vw);
  height: var(--app-height, 100dvh);
}

html.is-touch-device body {
  position: fixed;
  inset: 0;
}

html.is-touch-device .touch-start-note {
  display: block;
}

html.is-touch-device.is-landscape .game-shell {
  min-height: 0;
}

html.is-touch-device.is-landscape .mobile-controls:not([hidden]) {
  display: block;
}

html.is-touch-device.is-landscape .hud {
  grid-template-columns: 124px minmax(210px, 330px) auto;
  gap: 6px;
  inset: max(8px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) auto
    max(9px, env(safe-area-inset-left));
}

html.is-touch-device.is-landscape .hud__stat--score {
  width: 124px;
  height: 52px;
}

html.is-touch-device.is-landscape .hud__stat--score strong {
  left: 58px;
  right: 16px;
  bottom: 10px;
  font-size: 16px;
}

html.is-touch-device.is-landscape .health {
  width: min(330px, 100%);
  height: 52px;
}

html.is-touch-device.is-landscape .hud__controls {
  grid-template-columns: 48px 58px;
  gap: 4px;
}

html.is-touch-device.is-landscape .pause-button {
  width: 48px;
  min-width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(102, 242, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 60, 68, 0.88), rgba(31, 7, 23, 0.78)) !important;
  box-shadow:
    0 10px 24px rgba(10, 0, 8, 0.34),
    inset 0 0 0 1px rgba(255, 215, 110, 0.1);
  filter: none;
}

html.is-touch-device.is-landscape .pause-button::after,
html.is-touch-device.is-landscape .pause-button__label {
  display: none;
}

html.is-touch-device.is-landscape .pause-button__bars {
  display: grid;
  grid-template-columns: repeat(2, 5px);
  gap: 5px;
  width: 15px;
  height: 20px;
}

html.is-touch-device.is-landscape .pause-button__bars span {
  width: 5px;
  height: 20px;
}

html.is-touch-device.is-landscape .hud__stat--level {
  width: 58px;
  height: 54px;
}

html.is-touch-device.is-landscape .hud__stat--level strong {
  top: 30px;
  font-size: 15px;
}

html.is-touch-device.is-landscape .mission-panel {
  top: calc(max(8px, env(safe-area-inset-top)) + 54px);
  bottom: auto;
  width: min(340px, 42vw);
  min-height: 104px;
  padding: 38px 22px 16px 60px;
}

html.is-touch-device.is-landscape .mission-panel strong {
  font-size: 14px;
}

html.is-touch-device.is-landscape .mission-panel p {
  max-width: 250px;
  font-size: 10px;
  -webkit-line-clamp: 2;
}

html.is-touch-device.is-landscape .mission-panel__meta span {
  min-height: 19px;
  font-size: 8px;
}

html.is-touch-device.is-landscape #abilityDash {
  width: 106px;
  padding-left: 44px;
}

html.is-touch-device.is-landscape #abilityPulse {
  width: 132px;
  padding-left: 68px;
}

html.is-touch-device.is-landscape .level-meter {
  left: calc(max(150px, env(safe-area-inset-left)) + 6px);
  right: calc(max(150px, env(safe-area-inset-right)) + 6px);
  bottom: max(4px, env(safe-area-inset-bottom));
  height: 22px;
  opacity: 0.8;
}

html.is-touch-device.is-landscape .level-banner {
  top: 58px;
}

html.is-touch-device.is-landscape .overlay {
  padding: 16px;
}

html.is-touch-device.is-landscape .level-complete-overlay {
  align-content: start;
  justify-items: center;
  place-items: start center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: max(16px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-bottom));
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

html.is-touch-device.is-landscape .overlay h1 {
  font-size: clamp(32px, 7vw, 58px);
}

html.is-touch-device.is-landscape .level-complete-panel {
  width: min(420px, calc(100vw - 44px));
  max-height: none;
  padding: 20px;
  touch-action: pan-y;
}

html.is-touch-device.is-landscape .pause-panel {
  width: min(420px, calc(100vw - 44px));
  padding: 20px;
}

html.is-touch-device.is-landscape .level-complete-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

html.is-touch-device.is-landscape .upgrade-panel {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(var(--app-height, 100dvh) - 18px);
  overflow: auto;
  padding-top: 18px;
}

html.is-touch-device.is-landscape .upgrade-plaque {
  width: min(700px, 72vw);
}

html.is-touch-device.is-landscape .upgrade-tree {
  gap: clamp(10px, 2vw, 22px);
  margin-top: -8px;
}

html.is-touch-device.is-landscape .upgrade-node {
  min-height: 230px;
  padding: 58px 20px 18px;
}

html.is-touch-device.is-landscape .upgrade-node__title {
  font-size: clamp(18px, 2.2vw, 24px);
}

html.is-touch-device.is-short-landscape .mobile-joystick {
  width: 98px;
  height: 98px;
  bottom: max(10px, env(safe-area-inset-bottom));
}

html.is-touch-device.is-short-landscape .mobile-joystick__knob {
  width: 42px;
  height: 42px;
}

html.is-touch-device.is-short-landscape .mobile-actions {
  grid-template-columns: 58px 66px;
  gap: 7px;
  bottom: max(10px, env(safe-area-inset-bottom));
}

html.is-touch-device.is-short-landscape .mobile-action--fire {
  width: 70px;
  height: 70px;
  font-size: 14px;
}

html.is-touch-device.is-short-landscape .mobile-action--dash,
html.is-touch-device.is-short-landscape .mobile-action--pulse {
  width: 58px;
  height: 42px;
  font-size: 9px;
}

html.is-touch-device.is-short-landscape .mobile-action small {
  font-size: 7px;
}

html.is-touch-device.is-short-landscape .mission-panel {
  width: min(310px, 38vw);
  min-height: 92px;
  padding: 34px 18px 14px 56px;
  transform: scale(0.78);
  transform-origin: top left;
}

html.is-touch-device.is-short-landscape .mission-panel p {
  display: none;
}

html.is-touch-device.is-short-landscape .level-meter {
  left: calc(max(122px, env(safe-area-inset-left)) + 4px);
  right: calc(max(122px, env(safe-area-inset-right)) + 4px);
  height: 18px;
}

html.is-touch-device.is-portrait .orientation-prompt {
  display: grid;
}

html.is-touch-device.is-portrait .mobile-controls {
  display: none !important;
}

html.is-touch-device,
html.is-touch-device body,
html.is-touch-device .game-shell,
html.is-touch-device #game,
html.is-touch-device .phaser-stage,
html.is-touch-device .mobile-controls,
html.is-touch-device .mobile-joystick,
html.is-touch-device .mobile-action {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html.is-touch-device .mobile-action > * {
  pointer-events: none;
}

html.is-touch-device.is-landscape .mission-panel,
html.is-touch-device.is-short-landscape .mission-panel {
  display: none !important;
}

@media (pointer: coarse) and (orientation: landscape) {
  .mission-panel {
    display: none !important;
  }
}

html.is-touch-device .game-over-overlay {
  align-content: start;
  justify-items: center;
  place-items: start center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(38px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

html.is-touch-device .game-over-frame {
  flex: 0 0 auto;
  width: min(760px, calc(var(--app-width, 100vw) - 24px));
  min-width: 0;
  margin-block: 6px 22px;
  touch-action: pan-y;
}

html.is-touch-device .game-over-art {
  object-fit: contain;
}

html.is-touch-device .game-over-overlay .game-over-title {
  top: 13.8%;
  right: 21.5%;
  left: 21.5%;
  gap: 0.1em;
}

html.is-touch-device .game-over-overlay .game-over-title .overlay-eyebrow {
  font-size: clamp(7px, 1.15vw, 10px);
  letter-spacing: 0;
}

html.is-touch-device .game-over-overlay .game-over-title h1 {
  font-size: clamp(22px, 3.8vw, 32px);
  line-height: 0.96;
  white-space: normal;
  text-wrap: balance;
}

html.is-touch-device .game-over-overlay .game-over-title p {
  max-width: 86%;
  font-size: clamp(7px, 1.12vw, 10px);
  line-height: 1.05;
}

html.is-touch-device .game-over-stats {
  top: 35.2%;
  left: 27%;
  width: 24.5%;
  height: 36.6%;
  gap: 2.2%;
}

html.is-touch-device .game-over-stat--level,
html.is-touch-device .game-over-stat--sections,
html.is-touch-device .game-over-stat--virions {
  top: 0;
}

html.is-touch-device .game-over-stat dt,
html.is-touch-device .game-over-details span {
  font-size: clamp(6px, 1.08vw, 9px);
}

html.is-touch-device .game-over-stat dd {
  font-size: clamp(14px, 2.55vw, 21px);
}

html.is-touch-device .game-over-details {
  top: 40.2%;
  right: 22.5%;
  width: 21.8%;
  height: 28.5%;
  gap: 0.45em;
  font-size: clamp(7px, 1.18vw, 10px);
  line-height: 1.08;
}

html.is-touch-device .game-over-details strong {
  font-size: clamp(13px, 2.35vw, 20px);
}

html.is-touch-device .game-over-details ul {
  max-height: 7.8em;
  gap: 0.18em;
}

html.is-touch-device .game-over-restart {
  bottom: 9.3%;
  left: 35.9%;
  width: 28.4%;
  height: 7.8%;
  font-size: clamp(13px, 2.1vw, 18px);
  touch-action: manipulation;
}

html.is-touch-device.is-short-landscape .game-over-overlay {
  padding-block: 8px max(46px, env(safe-area-inset-bottom));
}

html.is-touch-device.is-short-landscape .game-over-frame {
  width: min(720px, calc(var(--app-width, 100vw) - 20px));
  margin-block: 4px 26px;
}
