:root {
  --bg-0: #03070d;
  --bg-1: #09131f;
  --bg-2: #132232;
  --bg-3: #1b3145;
  --ink: #edf7ff;
  --muted: #9fb8c9;
  --line: rgba(120, 181, 210, 0.24);
  --line-strong: rgba(180, 220, 245, 0.34);
  --panel: rgba(6, 14, 24, 0.86);
  --panel-strong: rgba(8, 18, 30, 0.94);
  --cyan: #7be7ff;
  --teal: #3fbac5;
  --gold: #ffcc62;
  --amber: #f29c38;
  --coral: #ff7455;
  --lime: #b7ff90;
  --danger: #ff5b7c;
  --shadow: 0 32px 80px rgba(0, 0, 0, 0.42);
  --space-bg-image: url("../assets/site/space-background.png");
}

* {
  box-sizing: border-box;
  letter-spacing: 0 !important;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "Bahnschrift SemiCondensed", "Trebuchet MS", "Yu Gothic UI", sans-serif;
  background-color: var(--bg-0);
  background-image:
    linear-gradient(180deg, rgba(1, 6, 13, 0.2), rgba(1, 6, 13, 0.72)),
    radial-gradient(circle at 50% 42%, rgba(7, 13, 22, 0.1) 0%, rgba(7, 13, 22, 0.5) 58%, rgba(3, 7, 13, 0.82) 100%),
    var(--space-bg-image),
    linear-gradient(135deg, #11181e 0%, #081019 48%, #04070d 100%);
  background-position: center top, center, center, center;
  background-repeat: no-repeat;
  background-size: cover;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(160, 214, 242, 0.06) calc(100% - 1px)),
    linear-gradient(180deg, transparent 0, transparent calc(100% - 1px), rgba(160, 214, 242, 0.04) calc(100% - 1px));
  background-size: 96px 96px;
}

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

button {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0.68rem 0.92rem;
  color: var(--ink);
  font: inherit;
  letter-spacing: 0.04em;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    linear-gradient(135deg, rgba(123, 231, 255, 0.14), rgba(242, 156, 56, 0.16));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07)),
    linear-gradient(135deg, rgba(123, 231, 255, 0.24), rgba(242, 156, 56, 0.22));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.2);
}

button,
.touch-button {
  touch-action: manipulation;
}

.page-shell {
  width: min(1540px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 8px 0 32px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 54px;
  padding: 6px 2px 10px;
  border-bottom: 1px solid rgba(174, 218, 242, 0.14);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: min(160px, 32vw);
  height: auto;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.24));
}

.brand-tagline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-tagline-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.app-footer {
  display: flex;
  justify-content: center;
  margin-top: 14px;
  color: rgba(223, 237, 248, 0.68);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.app-footer a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.18em;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

.app-footer a:hover {
  color: #fff7da;
  text-decoration-color: currentColor;
}

.app-footer a:focus-visible {
  outline: 1px solid rgba(255, 247, 218, 0.72);
  outline-offset: 3px;
}

.app-footer-landscape {
  display: none;
}

.header-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
  color: rgba(224, 239, 248, 0.9);
  font-size: 0.82rem;
}

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 8px;
  font-size: 1.22rem;
  font-weight: 800;
  line-height: 1;
}

.button-icon {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.button-icon path,
.button-icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: max-content;
  padding: 0.38rem 0.52rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #eef9ff;
  background: rgba(5, 10, 18, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  font-size: 0.76rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.icon-button:hover::after,
.icon-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.share-control {
  position: relative;
  display: inline-grid;
  place-items: center;
}

.share-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(5, 11, 20, 0.98);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.share-menu[hidden] {
  display: none;
}

.share-menu-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    linear-gradient(135deg, rgba(123, 231, 255, 0.14), rgba(242, 156, 56, 0.16));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  text-decoration: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.share-menu-button:hover,
.share-menu-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07)),
    linear-gradient(135deg, rgba(123, 231, 255, 0.24), rgba(242, 156, 56, 0.22));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.2);
}

.share-menu-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  min-width: max-content;
  padding: 0.38rem 0.52rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #eef9ff;
  background: rgba(5, 10, 18, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  font-size: 0.76rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.share-menu-button:hover::after,
.share-menu-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

#share-x-button .button-icon path:first-child,
#share-facebook-button .button-icon path {
  fill: currentColor;
  stroke: none;
}

#share-x-button .button-icon path:last-child {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.stage-frame::after,
.panel::after {
  display: none;
}

.stage-frame::before,
.panel::before {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  justify-items: center;
  transition: grid-template-columns 220ms ease, gap 220ms ease;
}

.stage-frame,
.panel {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.014)),
    rgba(6, 12, 20, 0.94);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
}

.stage-frame {
  overflow: hidden;
  width: 100%;
  max-width: 840px;
  justify-self: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.014)),
    rgba(7, 13, 22, 0.97);
}

.panel {
  padding: 12px 16px;
}

body[data-runtime-state]:not([data-runtime-state="title"]) .layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

#game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  image-rendering: auto;
  cursor: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, rgba(9, 16, 31, 0.98), rgba(2, 4, 10, 1));
  filter: saturate(1.06) contrast(1.04);
}

body[data-runtime-state="paused"] #game-canvas {
  cursor: pointer;
}

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

.header-pause-button:disabled {
  opacity: 0.48;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  color: #eef9ff;
  background:
    radial-gradient(circle at center, rgba(123, 231, 255, 0.1), transparent 38%),
    rgba(3, 7, 13, 0.82);
  text-align: center;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(237, 247, 255, 0.18);
  border-top-color: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(123, 231, 255, 0.22);
  animation: loadingSpin 900ms linear infinite;
}

.loading-copy {
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff7da;
}

.touch-console {
  display: none;
  position: fixed;
  left: max(12px, calc(env(safe-area-inset-left) + 12px));
  right: auto;
  bottom: max(12px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 48;
  pointer-events: none;
}

body[data-mobile-loadout-position="left"] .touch-console {
  left: max(12px, calc(env(safe-area-inset-left) + 12px));
  right: auto;
}

body[data-mobile-loadout-position="right"] .touch-console {
  left: auto;
  right: max(12px, calc(env(safe-area-inset-right) + 12px));
}

.touch-cluster {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    rgba(8, 14, 24, 0.9);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
}

.touch-label {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(223, 237, 248, 0.82);
}

.touch-weapon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: min(48vw, 240px);
}

.touch-button {
  min-height: 46px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.touch-button-weapon {
  --weapon-shot-size: 22px;
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
  min-width: 0;
  min-height: 52px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)),
    linear-gradient(135deg, rgba(123, 231, 255, 0.16), rgba(242, 156, 56, 0.18));
}

.touch-button-label {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: center;
  max-width: 100%;
  line-height: 1;
  overflow-wrap: anywhere;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.75),
    0 0 10px rgba(6, 12, 20, 0.65);
}

.touch-weapon-shots {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.touch-weapon-shot {
  position: absolute;
  width: var(--weapon-shot-size);
  height: var(--weapon-shot-size);
  background-image: url("../assets/generated/spritesheet.png");
  background-repeat: no-repeat;
  background-size: 800% 1100%;
  filter:
    drop-shadow(0 0 5px rgba(255, 255, 255, 0.42))
    drop-shadow(0 2px 5px rgba(0, 0, 0, 0.56));
}

.touch-weapon-shot--diagonal-up {
  background-position: 42.857142857% 10%;
}

.touch-weapon-shot--diagonal-down {
  background-position: 100% 10%;
}

.touch-weapon-shot--rear {
  background-position: 100% 0%;
}

.touch-weapon-shot--bounce-up {
  background-position: 42.857142857% 20%;
}

.touch-weapon-shot--bounce-down {
  background-position: 100% 20%;
}

.touch-weapon-shot--up {
  background-position: 42.857142857% 30%;
}

.touch-weapon-shot--down {
  background-position: 100% 30%;
}

.touch-weapon-shot--top-left {
  top: 4px;
  left: 6px;
}

.touch-weapon-shot--bottom-left {
  bottom: 4px;
  left: 6px;
}

.touch-weapon-shot--top-right {
  top: 4px;
  right: 6px;
}

.touch-weapon-shot--bottom-right {
  right: 6px;
  bottom: 4px;
}

.touch-weapon-shot--left-center {
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
}

.touch-weapon-shot--top-center {
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.touch-weapon-shot--bottom-center {
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.touch-button-weapon[data-selected="true"] {
  border-color: rgba(255, 225, 154, 0.42);
  color: #fff9df;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, rgba(255, 204, 98, 0.38), rgba(255, 116, 85, 0.24));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 28px rgba(242, 156, 56, 0.16);
}

.touch-button:active {
  transform: translateY(1px) scale(0.985);
}

.control-deck {
  display: grid;
  gap: 16px;
}

.panel-pilot {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(6, 12, 20, 0.94);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 0.98rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffffff;
}

.pilot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pilot-grid div,
.pilot-secondary div {
  position: relative;
  overflow: hidden;
  padding: 14px 14px 13px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018)),
    rgba(255, 255, 255, 0.025);
}

.pilot-card::after {
  content: "";
  position: absolute;
  inset: auto 14px 10px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent);
  opacity: 0.55;
}

.pilot-grid div::before,
.pilot-secondary div::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(123, 231, 255, 0.52), rgba(255, 204, 98, 0));
  opacity: 0.82;
}

.pilot-grid div:nth-child(2n)::before,
.pilot-secondary div:nth-child(2n)::before {
  background: linear-gradient(90deg, rgba(255, 204, 98, 0.52), rgba(123, 231, 255, 0));
}

.pilot-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.pilot-grid strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.15;
  color: #fff9e8;
  text-wrap: balance;
}

.pilot-card-stage,
.pilot-card-main-score {
  min-height: 74px;
}

.pilot-card-stage strong {
  font-size: 1.55rem;
  color: #f8fcff;
  text-shadow: 0 0 16px rgba(123, 231, 255, 0.1);
}

.pilot-card-main-score strong,
.pilot-card-area-score dd {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.pilot-card-main-score strong {
  color: #fff4d7;
  text-shadow: 0 0 16px rgba(255, 204, 98, 0.12);
}

.pilot-card-weapon {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.028);
}

.pilot-card-weapon strong {
  font-size: 1.26rem;
  color: #fbfdff;
  line-height: 1.08;
}

.pilot-card-power {
  background:
    linear-gradient(90deg, rgba(123, 231, 255, 0.08), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.028);
}

.pilot-card-power strong {
  color: #dffbff;
}

.pilot-card-rank dd {
  color: #fff1cb;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pilot-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 0;
}

.pilot-secondary dt {
  margin: 0 0 8px;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.pilot-secondary dd {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

body[data-runtime-state="active"] .panel-pilot,
body[data-runtime-state="player-explosion"] .panel-pilot,
body[data-runtime-state="continue"] .panel-pilot {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(6, 12, 20, 0.94);
}

.telemetry-panel summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: -2px 0 14px;
  cursor: pointer;
  list-style: none;
}

.telemetry-panel summary::-webkit-details-marker {
  display: none;
}

.telemetry-panel summary span:first-child {
  font-size: 0.98rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffffff;
}

.telemetry-summary-copy {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.telemetry-panel[open] .telemetry-summary-copy {
  color: #dceef8;
}

.telemetry-note {
  margin-top: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  margin: 0;
}

.stat-grid div {
  position: relative;
  overflow: hidden;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025)),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-grid div::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, rgba(123, 231, 255, 0.44), rgba(255, 204, 98, 0));
  opacity: 0.75;
}

.stat-grid div:nth-child(2n)::before {
  background: linear-gradient(90deg, rgba(255, 204, 98, 0.44), rgba(123, 231, 255, 0));
}

.stat-grid dt {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-grid dd {
  margin: 0;
  font-size: 1.02rem;
  color: var(--ink);
}

.panel-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.modal-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  overflow: hidden;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  scrollbar-width: none;
}

.modal-dialog::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.modal-dialog::backdrop {
  background: rgba(0, 4, 10, 0.7);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: min(720px, calc(100vh - 32px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018)),
    rgba(6, 12, 20, 0.98);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.56);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.app-language-control,
.help-language-control {
  display: inline-grid;
  min-width: 126px;
}

.app-language-select,
.help-language-select {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 2rem 0 0.75rem;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    rgba(7, 14, 24, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  outline: none;
}

.app-language-select:focus-visible,
.help-language-select:focus-visible {
  border-color: rgba(123, 231, 255, 0.56);
  box-shadow:
    0 0 0 3px rgba(123, 231, 255, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.app-language-select option,
.help-language-select option {
  color: #0b1320;
  background: #f4f8ff;
}

.modal-close {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 1.2rem;
}

.modal-body {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  gap: 16px;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 18px 34px 18px 18px;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
  scrollbar-width: none;
}

.modal-body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: transparent;
}

.modal-scrollbar {
  position: absolute;
  top: 92px;
  right: 10px;
  bottom: 18px;
  z-index: 2;
  width: 12px;
  border-radius: 8px;
  border: 1px solid rgba(123, 231, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(123, 231, 255, 0.18), rgba(255, 204, 98, 0.12)),
    rgba(4, 9, 16, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 18px rgba(0, 0, 0, 0.28),
    0 0 16px rgba(123, 231, 255, 0.08);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.modal-scrollbar[hidden] {
  display: none;
}

.modal-scrollbar span {
  position: absolute;
  inset: 1px 2px auto;
  min-height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #9ff2ff 0%, #62d6ec 44%, #ffd36e 100%);
  box-shadow:
    0 0 16px rgba(123, 231, 255, 0.36),
    0 0 18px rgba(255, 204, 98, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  cursor: grab;
  pointer-events: auto;
}

.modal-scrollbar[data-dragging="true"] span {
  cursor: grabbing;
}

.help-content section,
.setting-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.help-content h3,
.setting-copy h3 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.help-content p,
.setting-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.settings-content {
  gap: 14px;
}

.setting-group {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.setting-copy {
  display: grid;
  gap: 4px;
}

.setting-language-control {
  min-width: 186px;
}

.setting-toggle {
  min-width: 104px;
}

.setting-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 8px;
  min-width: 168px;
}

.setting-option {
  min-width: 0;
  padding-inline: 0.78rem;
}

.setting-option[data-selected="true"] {
  border-color: rgba(255, 225, 154, 0.44);
  color: #fff9df;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, rgba(255, 204, 98, 0.36), rgba(123, 231, 255, 0.18));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 26px rgba(255, 204, 98, 0.12);
}

.range-control {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.range-control output {
  color: #fff8de;
  font-variant-numeric: tabular-nums;
}

.volume-slider {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--cyan);
}

.jukebox-control {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.jukebox-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.jukebox-copy span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.jukebox-copy strong,
.jukebox-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jukebox-copy strong {
  font-size: 0.94rem;
}

.jukebox-copy small {
  color: var(--muted);
  font-size: 0.76rem;
}

.jukebox-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jukebox-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
}

.jukebox-play-button {
  width: 44px;
  min-width: 44px;
}

.jukebox-play-button[data-playing="true"] {
  border-color: rgba(255, 225, 154, 0.44);
  color: #fff9df;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, rgba(255, 204, 98, 0.34), rgba(123, 231, 255, 0.18));
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

@keyframes gridDrift {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(-24px, 18px, 0);
  }
}

@keyframes loadingSpin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .app-header {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
    padding-right: 0;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .brand-tagline-row {
    align-items: center;
    width: 100%;
    padding-right: 0;
  }

  .brand-mark {
    width: min(240px, 72vw);
  }

  .header-actions {
    position: absolute;
    top: 14px;
    right: 0;
    display: grid;
    grid-template-columns: repeat(2, 40px);
    justify-content: flex-end;
    align-items: start;
  }

  .modal-dialog {
    width: min(100vw - 20px, 560px);
  }

  .setting-group {
    grid-template-columns: 1fr;
  }

  .setting-toggle {
    width: 100%;
  }

  .setting-language-control {
    width: 100%;
  }

  .setting-segmented {
    width: 100%;
  }

  .jukebox-control {
    grid-template-columns: 1fr;
  }

  .jukebox-buttons {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    width: 100%;
  }

  .jukebox-button,
  .jukebox-play-button {
    width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100vw - 20px, 1280px);
    padding-top: 14px;
  }
}

@media (max-width: 980px), (pointer: coarse) {
  .page-shell {
    touch-action: none;
  }

  #game-canvas {
    touch-action: none;
  }

  .page-shell {
    padding-bottom: max(208px, calc(env(safe-area-inset-bottom) + 208px));
  }

  .touch-console {
    display: block;
  }

  .header-pause-button {
    display: inline-grid;
  }
}

@media (orientation: landscape) and (max-height: 560px) and (pointer: coarse),
  (orientation: landscape) and (max-height: 560px) and (any-pointer: coarse) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  body {
    min-height: 100dvh;
  }

  body::before {
    opacity: 0.1;
  }

  .page-shell {
    --landscape-playfield-height: min(100dvh, calc(100dvw * 0.75));
    --landscape-playfield-width: calc(var(--landscape-playfield-height) * 1.333333);
    --landscape-side-pane-width: max(0px, calc((100dvw - var(--landscape-playfield-width)) / 2));
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--landscape-playfield-width) minmax(0, 1fr);
    grid-template-rows: 100dvh;
    width: 100dvw;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
  }

  .layout {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: center;
    display: grid;
    width: var(--landscape-playfield-width);
    height: var(--landscape-playfield-height);
    gap: 0;
  }

  .stage-frame {
    width: 100%;
    height: 100%;
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #game-canvas {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  .app-header {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--landscape-playfield-width) minmax(0, 1fr);
    grid-template-rows: 100%;
    gap: 0;
    align-items: start;
    min-height: 0;
    padding: 0;
    border-bottom: 0;
    pointer-events: none;
  }

  .brand-lockup {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    display: grid;
    width: auto;
    max-width: max(0px, calc(var(--landscape-side-pane-width) - max(10px, env(safe-area-inset-left))));
    min-width: 0;
    margin: max(8px, env(safe-area-inset-top)) 8px 0 max(8px, env(safe-area-inset-left));
    gap: 6px;
    pointer-events: auto;
  }

  .brand-mark {
    width: min(150px, 100%);
    max-width: 100%;
  }

  .brand-tagline-row {
    display: block;
    width: 100%;
    min-width: 0;
    padding-right: 0;
  }

  .brand-tagline-row p {
    max-width: 100%;
    font-size: clamp(0.64rem, 2.1vh, 0.82rem);
    line-height: 1.18;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }

  .header-actions {
    position: static;
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
    gap: 6px;
    width: min(78px, max(36px, calc(var(--landscape-side-pane-width) - max(10px, env(safe-area-inset-right)))));
    max-width: max(36px, calc(var(--landscape-side-pane-width) - max(10px, env(safe-area-inset-right))));
    margin: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 8px;
    pointer-events: auto;
  }

  .header-actions .icon-button,
  .header-actions .share-control {
    justify-self: end;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 1.02rem;
  }

  .share-menu {
    top: 0;
    right: calc(100% + 8px);
  }

  .share-menu-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .icon-button::after {
    top: 0;
    right: calc(100% + 8px);
  }

  .share-menu-button::after {
    top: 0;
    right: calc(100% + 8px);
  }

  .touch-console {
    display: block;
    width: clamp(58px, calc(var(--landscape-side-pane-width) - 16px), 116px);
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 8px));
  }

  .app-footer-page {
    display: none;
  }

  .app-footer-landscape {
    display: flex;
    justify-content: flex-start;
    max-width: 100%;
    margin: 0;
    font-size: clamp(0.62rem, 1.9vh, 0.76rem);
  }

  body[data-mobile-loadout-position="left"] .touch-console {
    top: max(120px, calc(env(safe-area-inset-top) + 120px));
    left: max(8px, calc(env(safe-area-inset-left) + 8px));
    right: auto;
  }

  body[data-mobile-loadout-position="right"] .touch-console {
    top: max(134px, calc(env(safe-area-inset-top) + 134px));
    left: auto;
    right: max(8px, calc(env(safe-area-inset-right) + 8px));
  }

  .touch-cluster {
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 6px;
    padding: 8px;
  }

  .touch-label {
    font-size: 0.58rem;
    line-height: 1;
  }

  .touch-weapon-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(4, minmax(32px, 1fr));
    gap: 6px;
    height: 100%;
    min-width: 0;
    min-height: 0;
  }

  .touch-button,
  .touch-button-weapon {
    width: 100%;
    height: 100%;
    min-height: 32px;
    padding: 0.25rem 0.2rem;
    font-size: 0.58rem;
    line-height: 1.05;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .touch-button-weapon {
    --weapon-shot-size: 14px;
  }

  .touch-weapon-shot--top-left,
  .touch-weapon-shot--bottom-left,
  .touch-weapon-shot--left-center {
    left: 3px;
  }

  .touch-weapon-shot--top-right,
  .touch-weapon-shot--bottom-right {
    right: 3px;
  }

  .touch-weapon-shot--top-left,
  .touch-weapon-shot--top-right {
    top: 2px;
  }

  .touch-weapon-shot--bottom-left,
  .touch-weapon-shot--bottom-right {
    bottom: 2px;
  }

  #touch-weapon-front {
    order: 1;
  }

  #touch-weapon-vertical {
    order: 2;
  }

  #touch-weapon-ricochet {
    order: 3;
  }

  #touch-weapon-rear {
    order: 4;
  }

  .modal-dialog {
    width: min(560px, calc(100dvw - 24px));
    max-height: calc(100dvh - 24px);
  }

  .modal-panel {
    max-height: calc(100dvh - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  body::before,
  .stage-frame,
  .panel,
  .stage-frame::before,
  .panel::before {
    animation: none !important;
  }
}
