:root {
  color-scheme: dark;
  --void: #080d1b;
  --chart: #101a2b;
  --bone: #e8e3d5;
  --cyan: #62d7d0;
  --coral: #ff756b;
  --solar: #f2c14e;
}

* { box-sizing: border-box; }

.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;
}

html,
body,
#arena-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
}

body {
  font-family: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  color: var(--bone);
}

#arena-shell {
  position: relative;
  isolation: isolate;
}

#arena-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .24;
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(98, 215, 208, .08) 50%, transparent 50.1%),
    repeating-linear-gradient(0deg, transparent 0 71px, rgba(232, 227, 213, .025) 72px),
    radial-gradient(circle at 38% 44%, rgba(98, 215, 208, .08), transparent 29%),
    var(--void);
}

#lagrange-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  cursor: crosshair;
}

#lagrange-canvas:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}

#minimap-focus-proxy {
  position: absolute;
  z-index: 3;
  right: 22px;
  bottom: 48px;
  display: none;
  width: 320px;
  aspect-ratio: 64 / 27;
  border: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

#arena-shell[data-phase="battle"] #minimap-focus-proxy { display: block; }

#minimap-focus-proxy:focus-visible {
  outline: 2px solid var(--solar);
  outline-offset: 3px;
}

@media (max-width: 1499px) {
  #minimap-focus-proxy {
    right: 12px;
    bottom: 38px;
    width: 240px;
  }
}

#pilot-dom {
  position: absolute;
  z-index: 4;
  inset: 0 0 0 auto;
  width: min(520px, 42vw);
  display: flex;
  align-items: center;
  padding: 64px 52px;
  background: var(--chart);
  transition: opacity 160ms ease;
}

#pilot-dom[hidden] { display: none; }

#settings-dom {
  position: absolute;
  z-index: 5;
  top: 18px;
  right: 204px;
  width: 270px;
  border: 1px solid #28354b;
  background: rgba(8, 13, 27, .96);
  color: var(--bone);
  font-size: 11px;
}

#settings-dom[hidden] { display: none; }

#settings-dom summary {
  padding: 10px 12px;
  color: var(--bone);
  cursor: pointer;
  letter-spacing: .1em;
  text-transform: uppercase;
}

#settings-dom label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid #202b3e;
}

#settings-dom input[type="range"] { width: 104px; accent-color: var(--cyan); }
#settings-dom input[type="checkbox"] { accent-color: var(--cyan); }

#phase-actions {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 12px;
  width: min(940px, calc(100vw - 48px));
  transform: translateX(-50%);
  color: var(--bone);
  font-size: 11px;
  pointer-events: none;
}

#phase-actions > div {
  padding: 10px 12px;
  border: 1px solid #28354b;
  background: rgba(8, 13, 27, .96);
  pointer-events: auto;
}

#draft-actions:not([hidden]) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  padding: 6px 12px;
}

#draft-actions p { margin: 0; }
#draft-actions fieldset { grid-column: 1 / -1; grid-row: 2; }
#draft-lock { grid-column: 2; grid-row: 1; min-height: 36px; }

#phase-actions p { margin: 0 0 8px; color: #9da7b6; }
#phase-actions fieldset { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; margin: 0 0 8px; border: 0; padding: 0; }
#draft-actions p,
#draft-actions fieldset { margin: 0; }
#phase-actions legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
#phase-actions button {
  min-height: 44px;
  border: 1px solid #34425a;
  border-radius: 0;
  padding: 0 10px;
  background: var(--chart);
  color: var(--bone);
  cursor: pointer;
}
#draft-actions [data-ship-class] {
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.draft-ship-glyph {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  transform: rotate(-90deg);
}
.draft-ship-glyph::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: currentColor;
  clip-path: var(--ship-hull);
}
.draft-ship-glyph i {
  position: absolute;
  left: var(--cut-x, 48%);
  top: var(--cut-y, 48%);
  width: var(--cut-size, 6px);
  height: var(--cut-size, 6px);
  transform: translate(-50%, -50%);
  border: 1px solid var(--solar);
  border-left-color: transparent;
  border-radius: 50%;
  background: var(--void);
}
.ship-bastion { --ship-hull: polygon(4% 24%, 75% 18%, 96% 36%, 96% 68%, 71% 82%, 4% 72%); --cut-x: 45%; --cut-y: 29%; }
.ship-ram { --ship-hull: polygon(2% 50%, 45% 5%, 51% 34%, 96% 45%, 96% 55%, 51% 66%, 45% 95%); --cut-x: 44%; }
.ship-specter { --ship-hull: polygon(7% 12%, 78% 20%, 52% 40%, 95% 62%, 68% 91%, 38% 72%, 4% 90%, 22% 46%); --cut-x: 48%; --cut-y: 59%; }
.ship-swift { --ship-hull: polygon(1% 50%, 84% 4%, 66% 42%, 98% 50%, 66% 58%, 84% 96%, 47% 70%, 31% 96%, 28% 61%); --cut-x: 51%; }
.ship-spear { --ship-hull: polygon(0 47%, 32% 33%, 98% 48%, 98% 52%, 32% 67%, 0 53%); --cut-x: 40%; }
.ship-nova { --ship-hull: polygon(2% 50%, 38% 14%, 68% 0, 89% 27%, 67% 50%, 91% 75%, 66% 100%, 35% 81%); --cut-x: 51%; --cut-y: 47%; }
.ship-orbit { --ship-hull: polygon(1% 32%, 38% 4%, 78% 12%, 100% 50%, 78% 88%, 38% 96%, 1% 68%, 46% 72%, 72% 50%, 46% 28%); --cut-x: 75%; --cut-size: 9px; }
.ship-impulse { --ship-hull: polygon(1% 50%, 26% 14%, 81% 2%, 62% 41%, 98% 50%, 62% 59%, 81% 98%, 26% 86%); --cut-x: 45%; }
.ship-mirage { --ship-hull: polygon(1% 19%, 50% 19%, 87% 0, 68% 39%, 100% 50%, 68% 61%, 87% 100%, 50% 81%, 1% 81%, 31% 50%); --cut-x: 55%; }
.ship-forge { --ship-hull: polygon(1% 19%, 29% 19%, 29% 1%, 60% 1%, 60% 14%, 98% 14%, 98% 85%, 61% 85%, 61% 99%, 27% 99%, 27% 81%, 1% 81%); --cut-x: 69%; }
#phase-actions button[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
#phase-actions button:disabled { opacity: .34; cursor: not-allowed; }
#phase-actions button:focus-visible { outline: 2px solid var(--solar); outline-offset: 2px; }

#pilot-form {
  width: 100%;
  display: grid;
  gap: 14px;
}

.pilot-index {
  margin: 0;
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: .16em;
}

#pilot-form h2 {
  margin: 0;
  color: var(--bone);
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1;
  letter-spacing: -.035em;
}

.pilot-copy,
#pilot-viewport-status {
  margin: 0 0 8px;
  color: #9da7b6;
  font-size: 13px;
  line-height: 1.45;
}

#pilot-form label {
  margin-top: 14px;
  color: #808da0;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
}

#pilot-name {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--cyan);
  border-radius: 0;
  padding: 13px 2px;
  background: transparent;
  color: var(--bone);
  font: 600 21px/1.2 "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  outline: 0;
  caret-color: var(--solar);
}

#pilot-name:focus { border-bottom-color: var(--solar); }
#pilot-name[aria-invalid="true"] { border-bottom-color: var(--coral); }

#pilot-name-error {
  min-height: 16px;
  margin: 0;
  color: var(--coral);
  font-size: 10px;
  letter-spacing: .05em;
}

#pilot-name-error[data-valid="true"] { color: var(--cyan); }

#pilot-submit {
  width: 100%;
  min-height: 54px;
  margin-top: 8px;
  border: 1px solid var(--cyan);
  border-radius: 0;
  background: #102333;
  color: var(--bone);
  font: 700 12px/1 system-ui, sans-serif;
  letter-spacing: .12em;
  cursor: pointer;
}

#pilot-submit:hover:not(:disabled),
#pilot-submit:focus-visible {
  border-color: var(--solar);
  background: #142b38;
  outline: 1px solid var(--solar);
  outline-offset: 2px;
}

#pilot-submit:disabled { opacity: .38; cursor: not-allowed; }

#pilot-viewport-status {
  margin-top: 5px;
  color: #717e91;
  font-size: 10px;
}

#boot-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #8190a6;
  letter-spacing: .18em;
  font-size: 11px;
  pointer-events: none;
}

#boot-copy i {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  color: var(--bone);
  font: normal 48px Georgia, serif;
  animation: atlas-lock 1.8s cubic-bezier(.4, 0, .2, 1) infinite alternate;
}

canvas + #boot-copy,
body[data-bevy-ready="true"] #boot-copy { display: none; }

noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--void);
}

@keyframes atlas-lock {
  from { transform: rotate(-7deg) scale(.96); border-color: rgba(98, 215, 208, .45); }
  to { transform: rotate(7deg) scale(1.02); border-color: var(--solar); }
}

@media (prefers-reduced-motion: reduce) {
  #boot-copy i { animation: none; }
}
