:root {
  color-scheme: dark;
  --ink-0: #05040f;
  --ink-1: #09071c;
  --ink-2: #12102d;
  --indigo: #191746;
  --violet: #6f4fc7;
  --violet-soft: #a88be7;
  --gold: #f3cf72;
  --gold-hot: #fff2b0;
  --cyan: #55e4ed;
  --cyan-soft: #b7f7f7;
  --cream: #f4edd7;
  --muted: #a7a2bf;
  --glass: rgba(10, 8, 29, 0.76);
  --glass-strong: rgba(8, 6, 24, 0.92);
  --line: rgba(190, 181, 245, 0.22);
  --line-hot: rgba(85, 228, 237, 0.62);
  --shadow: rgba(1, 0, 10, 0.72);
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink-0);
}

body {
  color: var(--cream);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
#game:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  background:
    radial-gradient(circle at 52% 36%, rgba(89, 65, 164, 0.25), transparent 35%),
    linear-gradient(145deg, var(--ink-1), var(--ink-0));
}

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

.glass-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(28, 23, 66, 0.82), rgba(7, 6, 23, 0.76)),
    var(--glass);
  box-shadow:
    0 14px 38px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
}

.hud {
  position: absolute;
  z-index: 10;
  inset: var(--safe-top) var(--safe-right) auto var(--safe-left);
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(260px, 340px);
  grid-template-areas:
    "location resources"
    "abilities resources";
  gap: 8px 14px;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

body[data-game-ready="false"] .hud,
body.is-title .hud {
  opacity: 0;
  transform: translateY(-8px);
}

.hud__location {
  grid-area: location;
  justify-self: start;
  max-width: min(520px, 58vw);
  padding: 10px 14px 11px;
  clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%);
}

.hud__eyebrow,
.menu-card__kicker,
.start-card__kicker {
  margin: 0;
  color: var(--cyan);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-transform: uppercase;
}

.hud__objective {
  margin: 4px 0 0;
  color: var(--cream);
  font-size: clamp(0.74rem, 1vw, 0.88rem);
  line-height: 1.3;
}

.hud__resources {
  grid-area: resources;
  padding: 12px 14px;
  border-radius: 4px 0 4px 4px;
}

.meter + .meter {
  margin-top: 8px;
}

.meter__header,
.compact-meter__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1;
}

.meter__header output,
.compact-meter output {
  color: var(--cream);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.meter__track,
.compact-meter__track {
  position: relative;
  overflow: hidden;
  height: 8px;
  border: 1px solid rgba(232, 224, 255, 0.12);
  background: rgba(3, 2, 13, 0.8);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.7);
}

.meter__track::after,
.compact-meter__track::after {
  position: absolute;
  inset: 0;
  content: "";
  background: repeating-linear-gradient(90deg, transparent 0 15%, rgba(5, 4, 15, 0.6) 15% calc(15% + 1px));
  pointer-events: none;
}

.meter__fill,
.compact-meter__fill {
  display: block;
  width: calc(clamp(0, var(--value), 1) * 100%);
  height: 100%;
  transform-origin: left center;
  transition: width 130ms linear, filter 160ms ease;
}

.meter--health .meter__fill {
  background: linear-gradient(90deg, #9ed8df, var(--cyan-soft) 70%, #f7ffff);
  box-shadow: 0 0 13px rgba(85, 228, 237, 0.56);
}

.meter--heat .meter__fill {
  background: linear-gradient(90deg, #8e6fdb, var(--gold), var(--gold-hot));
  box-shadow: 0 0 14px rgba(243, 207, 114, 0.58);
}

.hud__compact-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  margin-top: 10px;
}

.compact-meter__track {
  height: 5px;
}

.meter--dash .compact-meter__fill {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(85, 228, 237, 0.7);
}

.meter--flow .compact-meter__fill {
  background: linear-gradient(90deg, var(--violet-soft), var(--gold));
  box-shadow: 0 0 12px rgba(168, 139, 231, 0.66);
}

.hud__abilities {
  grid-area: abilities;
  display: flex;
  justify-self: start;
  gap: 6px;
  padding: 6px;
  border-radius: 3px;
}

.ability-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 25px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.ability-chip.is-ready {
  border-color: rgba(85, 228, 237, 0.26);
  color: var(--cream);
}

.ability-chip.is-locked {
  opacity: 0.42;
  filter: saturate(0.25);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7em;
  min-height: 1.55em;
  padding: 0.12em 0.36em;
  border: 1px solid rgba(183, 247, 247, 0.35);
  border-bottom-color: rgba(85, 228, 237, 0.64);
  border-radius: 2px;
  background: rgba(85, 228, 237, 0.08);
  color: var(--cyan-soft);
  font-family: inherit;
  font-size: 0.82em;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.36);
}

.boss-hud {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 20px);
  width: min(620px, calc(100vw - 44px));
  padding: 10px 14px 9px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.boss-hud__title {
  margin: 0 0 7px;
  color: var(--gold-hot);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.78rem, 1.4vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.boss-hud__track {
  position: relative;
  overflow: hidden;
  height: 7px;
  background: rgba(2, 1, 10, 0.84);
  border: 1px solid rgba(243, 207, 114, 0.28);
}

.boss-hud__fill {
  display: block;
  width: calc(clamp(0, var(--value), 1) * 100%);
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--gold), var(--cream));
  box-shadow: 0 0 16px rgba(243, 207, 114, 0.58);
  transition: width 160ms linear;
}

.boss-hud__phase {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.overlay {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 12px) calc(var(--safe-left) + 12px);
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.overlay::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 50% 35%, rgba(83, 60, 156, 0.18), transparent 42%),
    rgba(4, 3, 15, 0.78);
  backdrop-filter: blur(7px) saturate(0.75);
  -webkit-backdrop-filter: blur(7px) saturate(0.75);
}

.overlay.is-visible,
.overlay:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

.overlay--start {
  z-index: 40;
  background:
    radial-gradient(circle at 50% 39%, rgba(243, 207, 114, 0.14) 0 6%, transparent 25%),
    radial-gradient(ellipse at 50% 72%, rgba(44, 32, 105, 0.32), transparent 45%),
    linear-gradient(145deg, rgba(5, 4, 18, 0.89), rgba(9, 7, 29, 0.78));
}

#qualiacology-home {
  position: fixed;
  z-index: 2147483647;
  top: var(--safe-top);
  left: var(--safe-left);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(117, 246, 255, 0.34);
  border-radius: 999px;
  background: rgba(7, 6, 23, 0.76);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34);
  color: var(--cyan-soft);
  text-decoration: none;
  font: 800 11px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#qualiacology-home:hover,
#qualiacology-home:focus-visible {
  border-color: rgba(255, 224, 127, 0.78);
  color: var(--gold-hot);
  outline: 2px solid rgba(117, 246, 255, 0.72);
  outline-offset: 2px;
}

.overlay--start::after {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: min(88vmin, 760px);
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgba(243, 207, 114, 0.12);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 7vmin rgba(111, 79, 199, 0.025),
    0 0 0 17vmin rgba(85, 228, 237, 0.015);
  animation: title-orbit 18s linear infinite;
}

.start-card {
  position: relative;
  width: min(700px, 94vw);
  text-align: center;
}

.start-card__kicker {
  margin-bottom: clamp(14px, 3vh, 30px);
  color: var(--violet-soft);
}

.game-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: clamp(10px, 2.2vw, 24px);
  margin: 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 10vw, 7.8rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.85;
  text-shadow: 0 12px 42px rgba(0, 0, 0, 0.66);
}

.game-title__sun {
  position: relative;
  color: var(--gold-hot);
  font-style: italic;
  text-shadow:
    0 0 16px rgba(243, 207, 114, 0.45),
    0 0 54px rgba(243, 207, 114, 0.22);
}

.game-title__sun::before {
  position: absolute;
  z-index: -1;
  top: 48%;
  left: 52%;
  width: 0.82em;
  aspect-ratio: 1;
  content: "";
  border: 1px solid rgba(243, 207, 114, 0.35);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 45px rgba(243, 207, 114, 0.18);
}

.start-card__promise {
  margin: clamp(16px, 3vh, 28px) 0 clamp(20px, 4vh, 36px);
  color: var(--cyan-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.34rem);
  font-style: italic;
  letter-spacing: 0.03em;
}

.primary-button,
.text-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: min(330px, 82vw);
  min-height: 66px;
  padding: 12px 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 242, 176, 0.62);
  background:
    linear-gradient(110deg, rgba(111, 79, 199, 0.38), rgba(243, 207, 114, 0.18)),
    rgba(9, 7, 28, 0.92);
  color: var(--gold-hot);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow:
    0 12px 38px rgba(0, 0, 0, 0.38),
    inset 0 0 22px rgba(243, 207, 114, 0.07);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.primary-button::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  transform: translateX(-115%);
  transition: transform 420ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  border-color: var(--cyan);
  background:
    linear-gradient(110deg, rgba(85, 228, 237, 0.2), rgba(243, 207, 114, 0.22)),
    rgba(12, 9, 35, 0.96);
  box-shadow: 0 0 30px rgba(85, 228, 237, 0.16), inset 0 0 25px rgba(243, 207, 114, 0.08);
  transform: translateY(-2px);
}

.primary-button:hover::before,
.primary-button:focus-visible::before {
  transform: translateX(115%);
}

.primary-button:active {
  transform: translateY(1px) scale(0.99);
}

.primary-button small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: none;
}

.primary-button--small {
  min-width: 210px;
  min-height: 48px;
  padding: 10px 18px;
  font-size: 0.78rem;
}

.start-card__controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(620px, 90vw);
  margin: clamp(20px, 4vh, 38px) auto 0;
}

.start-card__controls p {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.start-card__status {
  min-height: 1.2em;
  margin: 16px 0 0;
  color: rgba(244, 237, 215, 0.56);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
}

.menu-card {
  width: min(480px, 94vw);
  padding: clamp(22px, 5vw, 42px);
  text-align: center;
}

.menu-card h2,
.map-card h2,
.upgrade-card h2,
.ending-card h2 {
  margin: 7px 0 24px;
  color: var(--gold-hot);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 6vw, 3.3rem);
  font-weight: 400;
  line-height: 1;
}

.menu-card__actions {
  display: grid;
  justify-items: stretch;
  gap: 8px;
}

.menu-card__actions .primary-button {
  width: 100%;
}

.text-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(183, 247, 247, 0.12);
  background: rgba(85, 228, 237, 0.035);
  color: var(--cream);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  transition: border-color 130ms ease, color 130ms ease, background 130ms ease;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: var(--cyan);
  background: rgba(85, 228, 237, 0.09);
  color: var(--cyan-soft);
}

.text-button--quiet {
  color: var(--muted);
}

.pause-home-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.settings-panel {
  display: grid;
  gap: 15px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr minmax(110px, 1.5fr) 38px;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.setting-row input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.setting-row output {
  color: var(--cyan-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  cursor: pointer;
}

.setting-toggle span {
  display: grid;
  gap: 3px;
}

.setting-toggle strong {
  color: var(--cream);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
}

.setting-toggle small {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.3;
}

.setting-toggle input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--cyan);
}

.menu-card__controls {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.62rem;
}

.map-card {
  width: min(940px, 96vw);
  height: min(720px, 90vh);
  min-height: 420px;
  padding: clamp(16px, 3vw, 28px);
}

.overlay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.overlay-header h2 {
  margin-bottom: 14px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(85, 228, 237, 0.04);
  color: var(--cyan-soft);
  font-size: 1.6rem;
  line-height: 1;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--cyan);
  background: rgba(85, 228, 237, 0.1);
}

.map-surface {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(100% - 150px);
  min-height: 250px;
  overflow: hidden;
  border: 1px solid rgba(85, 228, 237, 0.17);
  background:
    linear-gradient(rgba(85, 228, 237, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 228, 237, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(111, 79, 199, 0.2), transparent 55%),
    rgba(4, 3, 17, 0.7);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.map-placeholder {
  display: grid;
  place-items: center;
  gap: 16px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  text-align: center;
}

.map-placeholder__sun {
  display: block;
  width: 30px;
  aspect-ratio: 1;
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(243, 207, 114, 0.48), 38px 26px 0 -12px rgba(85, 228, 237, 0.42);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.63rem;
  letter-spacing: 0.06em;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.legend-dot--current { color: var(--gold); box-shadow: 0 0 7px currentColor; }
.legend-dot--secret { color: var(--cyan); border-radius: 0; transform: rotate(45deg); }
.legend-dot--gate { color: var(--violet-soft); border-radius: 1px; }

.overlay--upgrade::before,
.overlay--ending::before {
  background:
    radial-gradient(circle at 50% 42%, rgba(243, 207, 114, 0.15), transparent 34%),
    rgba(3, 2, 13, 0.91);
}

.upgrade-card,
.ending-card {
  width: min(650px, 94vw);
  text-align: center;
}

.upgrade-glyph {
  position: relative;
  width: 110px;
  aspect-ratio: 1;
  margin: 0 auto 24px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow:
    0 0 24px rgba(85, 228, 237, 0.42),
    inset 0 0 22px rgba(85, 228, 237, 0.2);
}

.upgrade-glyph::before,
.upgrade-glyph::after {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.upgrade-glyph::before {
  width: 38px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--gold-hot);
  box-shadow: 0 0 28px var(--gold);
}

.upgrade-glyph::after {
  width: 86px;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 -16px 0 rgba(85, 228, 237, 0.34), 0 16px 0 rgba(85, 228, 237, 0.34);
}

.upgrade-card > p:not(.menu-card__kicker),
.ending-card > p:not(.menu-card__kicker) {
  max-width: 520px;
  margin: 0 auto 24px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.96rem, 2vw, 1.2rem);
  line-height: 1.55;
}

.upgrade-card__instruction {
  color: var(--cyan-soft) !important;
  font-family: inherit !important;
  font-style: normal !important;
}

.ending-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 30px 0;
  background: var(--line);
}

.ending-stats div {
  padding: 14px;
  background: var(--glass-strong);
}

.ending-stats dt {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.ending-stats dd {
  margin: 5px 0 0;
  color: var(--gold-hot);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.toast {
  position: absolute;
  z-index: 22;
  top: calc(var(--safe-top) + 112px);
  left: 50%;
  display: grid;
  min-width: min(390px, 86vw);
  max-width: min(560px, 90vw);
  padding: 10px 16px 11px;
  border: 1px solid var(--line-hot);
  background: var(--glass-strong);
  box-shadow: 0 12px 34px var(--shadow), 0 0 24px rgba(85, 228, 237, 0.08);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.toast__title {
  color: var(--cyan-soft);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.toast__copy {
  margin-top: 3px;
  color: var(--cream);
  font-size: 0.76rem;
}

.subtitle {
  position: absolute;
  z-index: 21;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 112px);
  width: min(720px, 88vw);
  padding: 8px 13px;
  border-left: 2px solid var(--cyan);
  background: rgba(4, 3, 15, 0.82);
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.86rem, 1.6vw, 1.06rem);
  line-height: 1.45;
  text-align: center;
  text-shadow: 0 2px 3px #000;
  transform: translateX(-50%);
  pointer-events: none;
}

.touch-controls {
  --touch-size: clamp(112px, 27vw, 154px);
  position: absolute;
  z-index: 18;
  inset: 0;
  display: none;
  pointer-events: none;
  touch-action: none;
}

html.touch-mode .touch-controls,
html.force-touch .touch-controls,
body.force-touch .touch-controls {
  display: block;
}

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

.touch-stick {
  --stick-x: 0;
  --stick-y: 0;
  position: absolute;
  bottom: calc(var(--safe-bottom) + 16px);
  width: var(--touch-size);
  height: var(--touch-size);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}

.touch-stick--move {
  left: calc(var(--safe-left) + 12px);
}

.touch-stick--aim {
  right: calc(var(--safe-right) + 12px);
}

.touch-stick__ring {
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(183, 247, 247, 0.29);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 25%, rgba(85, 228, 237, 0.025) 26% 56%, rgba(6, 5, 20, 0.52) 57%);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.38), 0 8px 24px rgba(0, 0, 0, 0.24);
}

.touch-stick__nub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38%;
  aspect-ratio: 1;
  border: 1px solid rgba(183, 247, 247, 0.62);
  border-radius: 50%;
  background: rgba(19, 17, 55, 0.82);
  box-shadow: 0 0 14px rgba(85, 228, 237, 0.15), inset 0 0 10px rgba(85, 228, 237, 0.08);
  transform: translate(calc(-50% + var(--stick-x) * 42%), calc(-50% + var(--stick-y) * 42%));
}

.touch-stick--aim .touch-stick__nub {
  border-color: rgba(255, 242, 176, 0.7);
  box-shadow: 0 0 16px rgba(243, 207, 114, 0.17), inset 0 0 10px rgba(243, 207, 114, 0.08);
}

.touch-stick__label {
  position: absolute;
  left: 50%;
  bottom: 1px;
  color: rgba(244, 237, 215, 0.54);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.touch-action {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(58px, 14vw, 74px);
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(183, 247, 247, 0.44);
  border-radius: 50%;
  background: rgba(11, 9, 35, 0.72);
  color: var(--cyan-soft);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.28), inset 0 0 15px rgba(85, 228, 237, 0.06);
  pointer-events: auto;
  touch-action: none;
}

.touch-action--dash {
  right: calc(var(--safe-right) + var(--touch-size) + 9px);
  bottom: calc(var(--safe-bottom) + 86px);
  border-color: rgba(255, 242, 176, 0.6);
  color: var(--gold-hot);
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.28), inset 0 0 15px rgba(243, 207, 114, 0.08);
}

.touch-action--pin {
  right: calc(var(--safe-right) + var(--touch-size) + 23px);
  bottom: calc(var(--safe-bottom) + 18px);
}

.touch-action.is-pressed {
  transform: scale(0.92);
  background: rgba(85, 228, 237, 0.17);
  filter: brightness(1.25);
}

.touch-menu {
  position: absolute;
  z-index: 3;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  width: 44px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(183, 247, 247, 0.38);
  border-radius: 999px;
  background: rgba(11, 9, 35, 0.76);
  color: var(--cream);
  font: 900 0.66rem/1 inherit;
  letter-spacing: 0.12em;
  transform: translateX(-50%);
  pointer-events: auto;
  touch-action: none;
}

.touch-menu.is-pressed {
  background: rgba(85, 228, 237, 0.2);
}

.boot-error,
.noscript {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 8px;
  width: min(520px, 90vw);
  padding: 24px;
  border: 1px solid var(--gold);
  background: var(--glass-strong);
  color: var(--cream);
  transform: translate(-50%, -50%);
  text-align: center;
}

.boot-error strong {
  color: var(--gold-hot);
  letter-spacing: 0.12em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html.edge-emphasis {
  --line-hot: rgba(85, 228, 237, 0.92);
  --cyan: #75f6ff;
  --gold: #ffe07f;
}

html.edge-emphasis .meter__track,
html.edge-emphasis .compact-meter__track,
html.edge-emphasis .glass-panel {
  border-color: rgba(183, 247, 247, 0.38);
}

@keyframes title-orbit {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (max-width: 760px) {
  .hud {
    grid-template-columns: 1fr minmax(185px, 44vw);
    gap: 6px 8px;
  }

  .hud__location {
    max-width: 50vw;
    padding: 8px 10px;
  }

  .hud__objective {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.66rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .hud__resources {
    padding: 9px 10px;
  }

  .hud__abilities {
    display: none;
  }

  .meter__header,
  .compact-meter__label {
    font-size: 0.52rem;
  }

  .start-card__controls {
    grid-template-columns: repeat(2, 1fr);
    max-width: 380px;
  }

  .boss-hud {
    bottom: calc(var(--safe-bottom) + 162px);
  }

  .boss-hud:not([hidden]) ~ .subtitle {
    bottom: calc(var(--safe-bottom) + 230px);
  }
}

@media (max-width: 520px) and (orientation: portrait) {
  #qualiacology-home {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 0;
  }

  #qualiacology-home::after {
    content: "Q.";
    color: var(--cyan);
    font: 900 13px/1 system-ui, sans-serif;
    letter-spacing: 0.04em;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "location resources";
    align-items: start;
  }

  .hud__location {
    width: 100%;
    max-width: none;
  }

  .hud__resources {
    width: 100%;
  }

  .hud__eyebrow {
    font-size: 0.55rem;
    letter-spacing: 0.13em;
  }

  .hud__objective {
    margin-top: 3px;
    font-size: 0.59rem;
  }

  .meter__track {
    height: 7px;
  }

  .hud__compact-row {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 7px;
  }

  .compact-meter__label {
    margin-bottom: 2px;
  }

  .game-title {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: clamp(4rem, 22vw, 6.4rem);
  }

  .game-title__sun {
    margin-left: 0.35em;
  }

  .start-card__promise {
    margin-top: 18px;
  }

  .start-card__controls {
    display: none;
  }

  .start-card__status {
    margin-top: 18px;
  }

  .menu-card {
    padding: 24px 18px;
  }

  .setting-row {
    grid-template-columns: 1fr 100px 36px;
  }

  .map-card {
    height: min(770px, 92vh);
    min-height: 500px;
  }

  .ending-stats {
    grid-template-columns: 1fr;
  }

  .ending-stats div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }

  .toast {
    top: calc(var(--safe-top) + 132px);
  }

  .subtitle {
    bottom: calc(var(--safe-bottom) + 174px);
    width: 92vw;
    font-size: 0.82rem;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .start-card__kicker,
  .start-card__controls,
  .start-card__status {
    display: none;
  }

  .game-title {
    font-size: clamp(3rem, 14vh, 5rem);
  }

  .start-card__promise {
    margin: 12px 0 16px;
  }

  .primary-button {
    min-height: 52px;
  }

  .touch-controls {
    --touch-size: min(32vh, 126px);
  }

  .touch-action--dash {
    bottom: calc(var(--safe-bottom) + 62px);
  }

  .boss-hud {
    bottom: calc(var(--safe-bottom) + 5px);
  }

  .subtitle {
    bottom: calc(var(--safe-bottom) + 82px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

html.reduced-motion *,
html.reduced-motion *::before,
html.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

@media (forced-colors: active) {
  .glass-panel,
  .overlay,
  .primary-button,
  .text-button,
  .touch-action,
  .touch-stick__ring,
  .touch-stick__nub {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    forced-color-adjust: auto;
  }
}
