@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=DM+Sans:wght@400;500;600;700&display=swap");
:root {
  color-scheme: dark;
  --bg: #101412;
  --panel: #171d19;
  --line: #2b342c;
  --muted: #839080;
  --lime: #d4f58b;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: #e7eadd;
  font:
    13px "DM Sans",
    sans-serif;
}
button,
a {
  color: inherit;
}
button {
  font: inherit;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 13px;
}
button:hover {
  border-color: var(--lime);
  color: var(--lime);
}
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
header {
  height: 90px;
  padding: 0 3%;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.brand {
  text-decoration: none;
  font:
    800 29px "Barlow Condensed",
    sans-serif;
  letter-spacing: 2px;
  position: relative;
  padding-left: 46px;
}
.brand > span {
  color: var(--lime);
  position: absolute;
  left: 0;
  top: 0;
  font-size: 41px;
}
.brand small {
  display: block;
  font: 8px "DM Sans";
  letter-spacing: 1.6px;
  color: var(--muted);
  margin-top: 3px;
}
.sector {
  margin: auto;
  color: #acb5a6;
  font-size: 11px;
  letter-spacing: 1.6px;
}
i {
  color: #4c584a;
  font-style: normal;
  margin: 0 8px;
}
header button {
  font-size: 10px;
  letter-spacing: 1px;
}
main {
  max-width: 1700px;
  margin: auto;
  padding: 24px 3%;
}
.topline {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 1.8px;
  color: var(--muted);
  margin-bottom: 17px;
}
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  margin-right: 7px;
}
.layout {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr) 210px;
  gap: 20px;
}
aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 17px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #a4b19b;
  display: flex;
  justify-content: space-between;
}
.portrait {
  margin: 23px 0 12px;
  background: radial-gradient(ellipse, #495d38, #222c22 70%);
  height: 99px;
  border-radius: 5px;
  font-size: 64px;
  text-align: center;
  position: relative;
}
.portrait span {
  position: absolute;
  bottom: 9px;
  right: 9px;
  font: 12px monospace;
  color: #91a77d;
}
.portrait img {
  width: 100%;
  height: 120%;
  object-fit: contain;
  position: relative;
  top: -20%;
  filter: drop-shadow(0 5px 4px #17172a66);
}
.menu-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.menu-intro img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px #10172388);
}
h2 {
  font: 600 24px "Barlow Condensed";
  margin: 0;
}
p {
  line-height: 1.6;
}
.muted {
  color: var(--muted);
  font-size: 11px;
}
.stat {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  margin-top: 24px;
}
.stat strong {
  color: var(--lime);
}
.bar {
  height: 6px;
  background: #30392b;
  margin-top: 8px;
  border-radius: 3px;
  overflow: hidden;
}
.bar i {
  display: block;
  background: var(--lime);
  width: 100%;
  height: 100%;
  margin: 0;
}
.metrics {
  display: flex;
  gap: 30px;
  margin-top: 21px;
}
.metrics small {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 1px;
}
.metrics b {
  display: block;
  font: 600 25px "Barlow Condensed";
  margin-top: 6px;
}
.metrics div:first-child b {
  color: var(--lime);
}
.divider {
  height: 1px;
  background: var(--line);
  margin: 23px 0;
}
.gear {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid #293127;
}
.gear > b {
  font-size: 23px;
  width: 30px;
  color: #caeaa3;
}
.gear strong {
  font-size: 11px;
  font-weight: 500;
}
.gear small {
  display: block;
  font-size: 7px;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-top: 5px;
}
.gear em {
  margin-left: auto;
  font: 9px monospace;
  color: #6d7e66;
}
.synergy {
  background: #222c1d;
  border: 1px solid #394a2b;
  border-radius: 5px;
  padding: 12px;
  margin-top: 20px;
}
.synergy small {
  color: #c7e493;
  font-size: 8px;
  letter-spacing: 1px;
}
.synergy strong {
  display: block;
  font-size: 11px;
  margin-top: 8px;
}
.synergy p {
  font-size: 10px;
  color: #96a689;
  margin: 6px 0 0;
}
.arena-wrap {
  border: 1px solid #384132;
  border-radius: 8px;
  overflow: hidden;
  background: #141b15;
  display: flex;
  flex-direction: column;
}
.arena-head,
.arena-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 1.2px;
}
.arena-head small {
  color: var(--muted);
  font-size: 8px;
  margin-left: 12px;
}
.arena-head #wave {
  color: var(--lime);
}
.arena-head > span:first-child {
  min-width: 0;
}
#arenaName {
  font-weight: 600;
}
.boss-hud {
  flex: 0 0 auto;
  padding: 6px 12px 8px;
  background: #30223b;
  border-top: 1px solid #6e3e62;
}
.boss-hud > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 9px;
  letter-spacing: .6px;
}
.boss-hud strong {
  color: #ffc8dd;
}
.boss-hud span {
  color: #d3adbf;
  font-size: 8px;
}
.boss-track {
  height: 5px;
  overflow: hidden;
  border-radius: 4px;
  background: #17182b;
}
.boss-track i {
  display: block;
  height: 100%;
  margin: 0;
  background: linear-gradient(90deg, #f45d95, #ffd081);
}
.powerup-hud {
  display: flex;
  gap: 4px;
  margin-bottom: 5px;
  pointer-events: none;
}
.powerup-buff {
  flex: 1;
  max-width: 120px;
  padding: 5px 6px;
  border: 1px solid var(--buff-color, #ffe08a);
  border-radius: 6px;
  background: #181b31ed;
  color: var(--buff-color, #ffe08a);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.boss-hud[hidden], .powerup-hud[hidden] {
  display: none;
}
@media (max-width: 600px) {
  .powerup-buff {
    font-size: 9px;
    padding: 4px;
  }
}
.playfield {
  position: relative;
  min-height: 620px;
  flex: 1;
  overflow: hidden;
}
canvas {
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: fill;
  outline: none;
  touch-action: none;
}
.timer {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}
.timer small {
  font-size: 8px;
  letter-spacing: 2px;
  color: #abb898;
}
.timer strong {
  display: block;
  font: 600 40px "Barlow Condensed";
  letter-spacing: 1px;
}
.timer > div {
  height: 2px;
  background: var(--lime);
  margin-top: 8px;
}
.area-label {
  position: absolute;
  left: 21px;
  top: 27px;
  line-height: 1.8;
  letter-spacing: 1px;
  font-size: 8px;
  color: #819272;
  pointer-events: none;
}
.area-label span {
  color: #56634d;
  font-size: 7px;
}
.arena-foot {
  font-size: 8px;
  border-top: 1px solid var(--line);
}
.arena-foot button {
  padding: 3px;
  border: 0;
  font-size: 8px;
  letter-spacing: 1px;
}
.arena-foot button:first-of-type {
  margin-left: auto;
}
kbd {
  display: inline-block;
  border: 1px solid #48513e;
  background: #263021;
  border-radius: 3px;
  padding: 3px 5px;
  font: 8px monospace;
  color: #b9c6ac;
  margin: 0 2px;
}
.abilities {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.abilities button {
  background: #162018ec;
  border-color: #465239;
  white-space: nowrap;
  font-size: 21px;
  color: #cde8a9;
  display: flex;
  align-items: center;
  gap: 5px;
}
.abilities span {
  font-size: 8px;
  letter-spacing: 1px;
}
.abilities kbd {
  font-size: 7px;
}
h3 {
  font: 600 32px/1.06 "Barlow Condensed";
  margin: 20px 0 12px;
}
.objective {
  display: flex;
  gap: 12px;
  margin-top: 21px;
  font-size: 11px;
}
.objective > b {
  color: #718366;
  font: 11px monospace;
}
.objective small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-top: 6px;
}
.enemy-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 17px;
}
.enemy-row > b {
  font-size: 24px;
  width: 25px;
  text-align: center;
}
.enemy-row span {
  font-size: 11px;
}
.enemy-row small {
  display: block;
  font-size: 7px;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-top: 4px;
}
.tip {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 24px;
  font-size: 9px;
  color: var(--muted);
}
.tip > span {
  color: #baa877;
  font-size: 8px;
  letter-spacing: 1px;
}
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  color: #7e8a76;
  font-size: 8px;
  letter-spacing: 1px;
}
footer b {
  color: var(--lime);
  font-size: 20px;
  margin-left: 20px;
}
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0e170c99;
  backdrop-filter: blur(3px);
}
#overlay:empty {
  display: none;
}
.modal {
  width: 100%;
  max-width: 550px;
  padding: 29px;
  background: #172018f5;
  border: 1px solid #4c5a3c;
  border-radius: 10px;
  box-shadow: 0 24px 90px #0008;
}
.modal .tag {
  font-size: 9px;
  color: var(--lime);
  letter-spacing: 2px;
}
.modal h1 {
  font: 800 53px/0.95 "Barlow Condensed";
  margin: 15px 0;
}
.modal h1 em {
  font-style: normal;
  color: var(--lime);
}
.modal p {
  font-size: 12px;
  color: #a4b19b;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.choices label {
  font-size: 9px;
  letter-spacing: 1px;
  color: #a6b29b;
}
.choices select {
  width: 100%;
  margin-top: 8px;
  background: #222e20;
  color: #e6eedd;
  border: 1px solid #425337;
  padding: 10px;
  border-radius: 4px;
  font: 11px "DM Sans";
}
.primary {
  background: var(--lime);
  color: #1c2814 !important;
  border: 0;
  font-weight: bold;
  padding: 14px 20px;
}
.primary:hover {
  background: #e3ffae;
}
.wide {
  width: 100%;
}
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 17px 0;
}
.card {
  padding: 11px;
  border: 1px solid #3c4c32;
  border-radius: 6px;
  background: #202b1d;
}
.card strong {
  display: block;
  font-size: 12px;
  color: var(--lime);
}
.card p {
  font-size: 10px;
  min-height: 32px;
  margin: 6px 0;
}
.card button {
  font-size: 9px;
  padding: 6px;
  margin: 2px;
}
.modal .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.modal .row button {
  font-size: 10px;
}
#notice {
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--lime);
  font-size: 11px;
  pointer-events: none;
}
#stick,
#mineTouch {
  display: none;
}
@media (min-width: 1500px) {
  .playfield {
    min-height: 730px;
  }
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 180px 1fr;
  }
  .right {
    display: none;
  }
  .sector {
    font-size: 9px;
  }
  .playfield {
    min-height: 630px;
  }
  aside {
    padding: 15px 12px;
  }
}

#overlay {
  z-index: 10;
}
.modal {
  max-height: 96%;
  overflow-y: auto;
}
#stick {
  z-index: 2;
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}
/* Prism Bloom: warm comic accents around the cool alien landscape. */
:root {
  --bg: #17172a;
  --panel: #222137;
  --line: #403d59;
  --muted: #a19bb8;
  --lime: #ffe08a;
}
body {
  background: radial-gradient(ellipse at 50% 0, #32304a, var(--bg) 65%);
  color: #f1ecfa;
}
header {
  background: #1b1b2ad9;
}
.sector {
  color: #b7b3ce;
}
.brand > span {
  color: #65e8d1;
}
.portrait {
  background: radial-gradient(ellipse, #777b75, #343349 75%);
  border: 1px solid #59516a;
}
.stat strong,
.metrics div:first-child b {
  color: #78eed7;
}
.bar i {
  background: linear-gradient(90deg, #5dd0bf, #b9f49a);
}
.bar {
  background: #37334c;
}
.gear {
  border-color: #38364c;
}
.gear > b {
  color: #81e9d7;
}
.gear small,
.gear em {
  color: #aaa4be;
}
.synergy {
  background: #333044;
  border-color: #5a5068;
}
.synergy small {
  color: #ffe08a;
}
.synergy p {
  color: #beb6cb;
}
.arena-wrap {
  border: 2px solid #514660;
  background: #242237;
  box-shadow: 0 8px 0 #100f2066;
}
.arena-head {
  background: #2e2a40;
}
.arena-head #wave {
  color: #ffe08a;
}
.arena-foot {
  background: #242237;
}
.timer {
  background: #24213fe8;
  border: 2px solid #605478;
  border-radius: 8px;
  padding: 8px 22px;
  top: 15px;
  box-shadow: 3px 4px 0 #19152d88;
}
.timer strong {
  font-size: 32px;
  color: #fff0b1;
}
.timer small {
  color: #e1d8f0;
}
.timer > div {
  background: #7fe8d1;
}
.area-label {
  color: #fff0ce;
  text-shadow: 1px 2px #29243e;
}
.area-label span {
  color: #e1cee7;
}
.abilities button {
  background: #29233fea;
  border: 2px solid #80708c;
  color: #ffe3a0;
  box-shadow: 2px 3px 0 #171427;
}
.abilities button:hover {
  background: #443751;
}
.abilities button:disabled {
  opacity: 0.62;
}
.primary {
  background: #ffe08a;
  box-shadow: 3px 4px 0 #130f22;
}
.primary:hover {
  background: #fff0b8;
}
.modal {
  background: #29243df5;
  border: 2px solid #8b7699;
  box-shadow: 8px 10px 0 #151124bb;
}
.modal p,
.choices label {
  color: #cbc0d6;
}
.choices select,
.card {
  background: #373047;
  border-color: #655773;
}
.card strong {
  color: #84eed4;
}
#overlay {
  background: #17132666;
  backdrop-filter: blur(1px);
}
kbd {
  background: #3c334d;
  border-color: #756781;
  color: #eddbed;
}
.enemy-row small {
  color: #a9a1bb;
}
.tip > span {
  color: #ebce91;
}
#notice {
  top: 116px;
  color: #fff0b9;
  font-weight: 700;
  text-shadow: 1px 2px 3px #201527;
}
#stick {
  border: 2px solid #edcfad99;
  background: #33294299;
}
#stick span {
  background: #f3d49caa;
}
#mineTouch {
  background: #393048;
  border: 2px solid #80708c;
}
canvas:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: -3px;
}

.run-build {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 88px;
  pointer-events: none;
}
.xp-track {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  background: #24213fe8;
  border-radius: 5px;
}
.xp-track span {
  font: 10px monospace;
  color: #c7b6ff;
  white-space: nowrap;
}
.xp-track > div {
  flex: 1;
  height: 4px;
  background: #4a3d60;
  border-radius: 3px;
  overflow: hidden;
}
#xpFill {
  display: block;
  height: 100%;
  margin: 0;
  background: #c3a0ff;
}
#weaponBelt {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  margin-top: 5px;
}
#weaponBelt span {
  background: #24213feb;
  border: 1px solid #786884;
  border-radius: 4px;
  padding: 4px 5px;
  font-size: 9px;
  display: flex;
  justify-content: space-between;
  gap: 3px;
}
.tier-2 {
  border-color: #7debbe !important;
}
.tier-3 {
  border-color: #c5a0ff !important;
}
.tier-4 {
  border-color: #ffd574 !important;
}
.settings,
.unlock-list,
.build-stats {
  border-top: 1px solid #655773;
  margin: 14px 0;
  padding-top: 10px;
}
summary {
  cursor: pointer;
  min-height: 44px;
  display: list-item;
  padding: 12px 0;
  font-size: 12px;
  color: #d7c9e7;
}
summary:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}
.settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
}
.settings select {
  background: #373047;
  color: #f1ecfa;
  padding: 8px;
  border: 1px solid #655773;
  border-radius: 4px;
  font-size: 16px;
}
.save-note,
.shop-hint {
  font-size: 11px !important;
  color: #c9bed6;
}
.modal:has(.shop-title) {
  max-width: 760px;
}
.shop-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.shop-title h1 {
  font-size: 35px;
}
.shop-title > strong {
  font:
    700 28px "Barlow Condensed",
    sans-serif;
  color: #7debbe;
  white-space: nowrap;
}
.next-wave {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-left: 3px solid #ffc773;
  background: #41364d;
  border-radius: 4px;
  font-size: 12px;
}
.next-wave span {
  color: #d4c9df;
}
.shop-offers .card {
  display: flex;
  flex-direction: column;
}
.shop-offers .card > small {
  color: #baadce;
  font-size: 9px;
  margin-bottom: 6px;
}
.shop-offers .card > strong {
  font-size: 16px;
}
.shop-offers .card > p {
  font-size: 12px;
  min-height: 0;
}
.shop-offers .buy {
  margin-top: auto;
  background: #4c425d;
  font-weight: bold;
}
.shop-offers .locked {
  border-color: #ffe08a;
}
.shop-offers .locked .lock {
  color: #ffe08a;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}
.section-heading h2 {
  font-size: 22px;
}
.section-heading > span {
  font-size: 10px;
  color: #d4c9df;
}
.weapon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.weapon-slot {
  padding: 10px;
  border: 1px solid #786884;
  border-radius: 6px;
  background: #211d32;
}
.weapon-slot > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.weapon-slot b {
  font-size: 13px;
}
.weapon-slot small {
  font-size: 10px;
  color: #ac9dc2;
}
.weapon-slot p {
  margin: 6px 0;
  font-size: 11px;
}
.weapon-slot .tier {
  color: #ffe08a;
  font: 12px monospace;
}
.weapon-actions {
  display: flex;
  gap: 4px;
}
.weapon-actions button {
  flex: 1;
  padding: 6px;
  font-size: 9px;
}
.set-bonuses {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0;
}
.set-bonuses > span {
  border: 1px solid #514660;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 10px;
  color: #ac9dc2;
}
.set-bonuses .active {
  color: #aaf1c7;
  border-color: #587766;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  font-size: 12px;
}
.stat-grid > span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #514660;
}
.stat-grid b {
  color: #ffe08a;
}
.route-choice {
  font-size: 12px;
}
.level-choices {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}
.level-choices button {
  display: grid;
  gap: 6px;
  min-height: 72px;
  text-align: left;
  background: #373047;
}
.level-choices strong {
  color: #ffe08a;
  font-size: 17px;
}
.level-choices span {
  color: #d7c9e7;
  font-size: 13px;
}
.unlock-banner {
  color: #aaf1c7 !important;
  border: 1px solid #7debbe;
  padding: 12px;
  border-radius: 6px;
}
.shop-continue {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  box-shadow: 0 -8px 12px #29243d;
}

button {
  touch-action: manipulation;
}
.abilities {
  z-index: 2;
}
.abilities button {
  min-width: 64px;
  min-height: 48px;
  touch-action: none;
  user-select: none;
}
.abilities small {
  font: 10px monospace;
  color: #d0c5df;
}
.abilities button:active,
.abilities .held {
  background: #5d4968;
  border-color: #ffe08a;
}
.mobile-hud {
  display: none;
}
.modal {
  overscroll-behavior: contain;
}
.modal button,
.choices select {
  min-height: 44px;
}
.modal input[type="checkbox"] {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  accent-color: var(--lime);
}
.modal label:has(input) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

/* A phone-sized game surface: status above the action, thumbs below it. */
@media (max-width: 1000px), (pointer: coarse) {
  .run-build {
    bottom: calc(var(--controls-height) + 7px);
    left: 10px;
    right: 10px;
  }
  #weaponBelt {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }
  #weaponBelt span {
    font-size: 9px;
    padding: 3px 5px;
  }
  .xp-track {
    padding: 4px 6px;
  }
  .xp-track span {
    font-size: 9px;
  }
  .shop-title h1 {
    font-size: 28px;
  }
  .weapon-actions {
    flex-direction: column;
  }
  .shop-title > strong {
    font-size: 24px;
  }
  body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  header {
    display: none;
    height: 52px;
    flex: 0 0 52px;
    padding: 0 12px;
    gap: 8px;
  }
  .brand {
    font-size: 23px;
    padding-left: 31px;
  }
  .brand > span {
    font-size: 29px;
    top: -3px;
  }
  .brand small,
  .sector,
  header #help span,
  .topline,
  .layout > aside,
  footer,
  .arena-head small,
  .area-label,
  .abilities kbd,
  .arena-foot kbd {
    display: none;
  }
  header button {
    min-width: 44px;
    min-height: 44px;
    font-size: 10px;
  }
  #sound {
    margin-left: auto;
  }
  main {
    width: 100%;
    padding: 0 6px 4px;
    flex: 1;
    min-height: 0;
    display: flex;
  }
  .layout {
    display: flex;
    width: 100%;
    min-height: 0;
  }
  .arena-wrap {
    width: 100%;
    min-height: 0;
    border-width: 1px;
    box-shadow: none;
  }
  .arena-head {
    min-height: 30px;
    padding: 6px 12px;
    font-size: 10px;
  }
  .playfield {
    --controls-height: 140px;
    min-height: 0;
    flex: 1;
    isolation: isolate;
  }
  canvas {
    top: 0;
    height: calc(100% - var(--controls-height));
  }
  .playfield::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--controls-height);
    background: #211d32;
    border-top: 1px solid #61516e;
    pointer-events: none;
    z-index: 1;
  }
  .mobile-hud {
    display: block;
    position: absolute;
    top: 10px;
    left: 10px;
    width: min(52%, 220px);
    padding: 8px 10px;
    background: #24213feb;
    border: 1px solid #605478;
    border-radius: 8px;
    pointer-events: none;
    font-size: 11px;
  }
  .mobile-vitals,
  .mobile-metrics {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }
  .mobile-vitals > span {
    font-size: 9px;
    color: #d0c5df;
  }
  .mobile-vitals strong {
    color: #b9f49a;
    font-variant-numeric: tabular-nums;
  }
  .mobile-hud .bar {
    margin: 6px 0;
    height: 5px;
  }
  .mobile-metrics strong {
    color: #78eed7;
  }
  .mobile-metrics span {
    font-size: 9px;
  }
  .low-health {
    border-color: #ff927f;
  }
  .low-health .mobile-vitals strong {
    color: #ff927f;
  }
  .low-health .bar i {
    background: #ff927f;
  }
  .timer {
    top: 10px;
    left: auto;
    right: 10px;
    transform: none;
    padding: 6px 10px;
    box-shadow: none;
  }
  .timer strong {
    font-size: 27px;
    line-height: 1.1;
  }
  .timer small {
    font-size: 7px;
    letter-spacing: 0.4px;
  }
  .timer > div {
    margin-top: 5px;
  }
  #notice {
    top: 88px;
    padding: 0 12px;
    font-size: 10px;
  }
  #stick {
    display: block;
    position: absolute;
    left: 18px;
    bottom: 18px;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    border: 2px solid #edcfad99;
    background: #332942;
    touch-action: none;
    user-select: none;
  }
  #stick span {
    position: absolute;
    left: calc(50% - 18px);
    top: calc(50% - 18px);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3d49c;
    box-shadow: 0 3px 0 #171427;
    pointer-events: none;
  }
  #stick small {
    position: absolute;
    bottom: 5px;
    width: 100%;
    text-align: center;
    font-size: 8px;
    letter-spacing: 2px;
    pointer-events: none;
  }
  .abilities {
    left: auto;
    right: 12px;
    bottom: 10px;
    transform: none;
    display: grid;
    grid-template-columns: repeat(2, 72px);
    gap: 8px;
  }
  .abilities button,
  .abilities #mineTouch {
    display: grid;
    grid-template-columns: 20px 1fr;
    grid-template-rows: 22px 14px;
    align-content: center;
    justify-items: center;
    gap: 0 3px;
    width: 72px;
    height: 56px;
    padding: 5px;
    border-radius: 12px;
  }
  .abilities b {
    font-size: 23px;
    font-weight: normal;
  }
  .abilities span {
    font-size: 9px;
    letter-spacing: 0;
  }
  .abilities small {
    grid-column: 1 / -1;
    font-size: 10px;
  }
  .abilities button:disabled {
    opacity: 0.65;
  }
  #overlay {
    padding: 10px;
  }
  .modal {
    max-height: 100%;
    padding: 18px;
    border-radius: 12px;
    box-shadow: none;
  }
  .modal h1 {
    font-size: clamp(32px, 8vw, 43px);
    margin: 12px 0;
  }
  .menu-intro {
    grid-template-columns: minmax(0, 1fr) 90px;
  }
  .menu-intro h1 {
    font-size: clamp(25px, 7vw, 36px);
    line-height: 1.05;
  }
  .menu-intro img {
    height: 120px;
  }
  .modal p {
    font-size: 12px;
  }
  .choices {
    gap: 10px;
    margin: 14px 0;
  }
  .choices label {
    font-size: 9px;
    letter-spacing: 0.3px;
    min-width: 0;
  }
  .choices select {
    font-size: 16px;
    padding: 8px 4px;
    margin-top: 6px;
  }
  .cards {
    gap: 8px;
  }
  .card {
    padding: 9px;
    min-width: 0;
  }
  .card strong {
    font-size: 13px;
  }
  .card p {
    font-size: 12px;
  }
  .card button {
    width: 100%;
    margin: 3px 0;
    font-size: 11px;
  }
  .modal .row {
    gap: 8px;
  }
  .modal .row button {
    flex: 1;
  }
  .arena-foot {
    min-height: 44px;
    padding: 0 8px;
    gap: 6px;
    font-size: 8px;
  }
  .arena-foot .dot {
    display: none;
  }
  .arena-foot button {
    min-height: 44px;
    min-width: 58px;
    font-size: 10px;
    padding: 0 6px;
    letter-spacing: 0;
  }
  .arena-foot #aim {
    display: none;
  }
  .arena-foot #pause {
    margin-left: auto;
  }
}

/* Landscape phones keep their thumb controls alongside the arena. */
@media (max-height: 500px) and (max-width: 1000px),
  (max-height: 500px) and (pointer: coarse) {
  .run-build {
    left: 128px;
    right: 178px;
    bottom: 7px;
  }
  #weaponBelt {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  #weaponBelt span {
    font-size: 8px;
    overflow: hidden;
  }
  header {
    height: 44px;
    flex-basis: 44px;
  }
  main {
    padding-top: 4px;
  }
  .playfield {
    --controls-height: 0px;
  }
  canvas {
    left: 122px;
    width: calc(100% - 294px);
  }
  .playfield::after {
    display: none;
  }
  #stick {
    left: 10px;
    bottom: 16px;
  }
  .abilities {
    right: 10px;
    bottom: 12px;
  }
  .mobile-hud {
    width: 110px;
    left: 5px;
    padding: 7px;
  }
  .mobile-vitals > span {
    display: none;
  }
  .mobile-metrics {
    font-size: 10px;
  }
  .mobile-metrics span {
    font-size: 8px;
  }
  .timer {
    right: 28px;
  }
  #notice {
    top: 8px;
    left: 124px;
    right: 170px;
    font-size: 9px;
  }
  .modal {
    max-width: 600px;
  }
}

/* Optional risk/reward stays outside the combat view; color always has a symbol/label. */
.objective-hud { padding: 5px 12px; color: #ffe5a0; background: #302a40; font: 600 11px/1.3 var(--font-mono, monospace); }
.objective-hud[hidden] { display: none; }
.companion-hud { color: #b9e9d9; font-size: 10px; white-space: nowrap; }
@media (max-width: 600px) {
  .objective-hud { font-size: 9px; padding: 4px 9px; }
  .companion-hud { font-size: 8px; }
}

/* Native controls remain comfortable at phone scale and enlarged text. */
button, select, input:not([type="checkbox"]), summary { min-height: 48px; }
header button, .arena-foot button { min-height: 48px; min-width: 48px; }
.modal :is(button, select, summary), .card button { min-height: 48px; }
.modal input[type="checkbox"] { width: 24px; height: 24px; }
.modal label:has(input[type="checkbox"]) { min-height: 48px; }
.tutorial-hud { display:flex;align-items:center;gap:12px;justify-content:space-between;padding:7px 12px;background:#283a45;color:#edfff6;border-bottom:1px solid #75aaad;font-size:12px; }
.tutorial-hud[hidden] { display:none; }
.tutorial-copy { min-width:0;line-height:1.35; }
.tutorial-hud button { flex:none;min-width:56px;min-height:48px; }
@media(max-width:1000px),(pointer:coarse) {
  header { height:52px;flex-basis:52px; }
  header .brand { font-size:20px;padding-left:25px;min-height:48px;display:flex;align-items:center; }
  header .brand>span { top:7px;font-size:25px; }
  header button { min-width:48px;min-height:48px;padding:4px;font-size:10px; }
  .arena-foot { min-height:48px;flex-shrink:0; }
  .arena-foot button { min-height:48px; }
  .modal { scroll-padding-top:120px; }
  .modal .choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .modal .choices select { min-height:48px; }
  .modal .settings label { gap:10px;flex-wrap:wrap; }
  .modal .card { padding:13px; }
  .modal .card>strong { font-size:15px;line-height:1.3; }
  .modal .card>p { line-height:1.5; }
  .tutorial-hud { padding:4px 8px;font-size:11px; }
}
@media(max-width:360px) {
  header { padding-inline:7px;gap:4px; }
  header .brand { font-size:18px;letter-spacing:0;padding-left:23px; }
  #sound { font-size:8px;max-width:58px; }
  .modal .choices { grid-template-columns:minmax(0,1fr); }
}
