:root {
  color-scheme: dark;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: #080b14;
  color: #f4f1e8;
  --ink: #f4f1e8;
  --muted: #9ca8b7;
  --panel: #111724;
  --line: rgb(191 203 218 / 17%);
  --amber: #f0a34a;
  --teal: #62cabb;
  --red: #f27b62;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 2.5rem 1.25rem;
  background:
    radial-gradient(ellipse at 50% 100%, rgb(48 54 86 / 42%), transparent 52%),
    radial-gradient(circle at 11% 14%, #e4e8ef 0 1px, transparent 2px),
    radial-gradient(circle at 76% 18%, #626d81 0 1px, transparent 2px),
    radial-gradient(circle at 91% 71%, #596377 0 1px, transparent 2px),
    #080b14;
}

button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  z-index: 5;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  transform: translateY(-180%);
  color: #080b14;
  background: var(--teal);
  font-weight: 800;
}
.skip-link:focus { transform: translateY(0); }

.launch-shell {
  position: relative;
  width: min(100%, 800px);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgb(19 24 37 / 97%), rgb(10 14 23 / 97%));
  box-shadow: 0 28px 100px rgb(0 0 0 / 48%);
}

.launch-shell::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 42%;
  height: 5px;
  background: linear-gradient(90deg, transparent, var(--amber), var(--teal));
  content: "";
}

.masthead { text-align: center; }
.signal, .eyebrow, .edition, .capacity, .section-heading > span, .shell-footer {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.signal {
  margin: 0;
  color: #a0adbf;
  font-size: 0.68rem;
}
.signal span, .eyebrow span { color: var(--amber); }

.brand-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.8rem;
}

h1 {
  margin: 0;
  color: #f3eee3;
  font-size: clamp(4.2rem, 16vw, 7.8rem);
  font-weight: 950;
  letter-spacing: -0.095em;
  line-height: 0.94;
  text-shadow: 0 5px 0 #a14f28, 0 12px 38px rgb(240 163 74 / 18%);
}

.edition {
  padding: 0.35rem 0.45rem;
  border: 1px solid rgb(240 163 74 / 45%);
  color: var(--amber);
  font-size: 0.56rem;
  line-height: 1.4;
  transform: rotate(5deg);
}

.subtitle {
  margin: 0.85rem 0 0;
  color: #efab60;
  font-size: clamp(0.95rem, 3vw, 1.15rem);
}

.service-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  margin: 1.75rem 0 2rem;
  padding: 0.6rem 0.9rem;
  border-block: 1px solid rgb(98 202 187 / 20%);
  color: var(--teal);
  font: 700 0.73rem/1.35 ui-monospace, monospace;
  letter-spacing: 0.035em;
  text-align: center;
}
.service-status[data-kind="error"] { color: var(--red); border-color: rgb(242 123 98 / 32%); }
.status-lamp {
  flex: 0 0 auto;
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.screen { animation: signal-in 180ms ease-out both; }
.briefing { margin: 0 0 1.5rem; }
.eyebrow {
  margin: 0 0 0.45rem;
  color: #9aa8bc;
  font-size: 0.62rem;
}
.briefing h2, .results-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 5vw, 2rem);
  letter-spacing: -0.035em;
}
.briefing > p:last-child, .results-panel > p:not(.eyebrow) {
  margin: 0.55rem 0 0;
  color: #b2bdcb;
  line-height: 1.55;
}

.pilot-field { display: grid; gap: 0.45rem; min-width: 0; }
.pilot-field label, .share-panel label {
  color: #cbd1d9;
  font-size: 0.83rem;
  font-weight: 700;
}
input, select {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgb(180 194 212 / 25%);
  border-radius: 2px;
  outline: none;
  color: var(--ink);
  background: #0a0f19;
}
input::placeholder { color: #6f7c8e; }
input:focus-visible, select:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgb(98 202 187 / 22%);
}
input[readonly] { color: #b8c5d1; }
.field-hint { color: #7f8b9a; font-size: 0.72rem; line-height: 1.35; }

.launch-actions, .form-actions, .lobby-actions, .share-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.launch-actions { margin-top: 1rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 3rem;
  padding: 0.72rem 1rem;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button-primary { color: #17120c; background: var(--amber); }
.button-primary:hover:not(:disabled) { background: #ffc16e; }
.button-secondary { border-color: rgb(98 202 187 / 52%); color: #85e2d4; background: rgb(28 72 73 / 26%); }
.button-secondary:hover:not(:disabled) { background: rgb(28 92 88 / 52%); }
.button-join { flex: 0 0 auto; border-color: var(--line); color: var(--ink); background: #20293a; }
.button-join:hover:not(:disabled), .button-quiet:hover:not(:disabled) { background: #2a3548; }
.button-quiet { border-color: var(--line); color: #aab5c4; background: transparent; }

.join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.8rem;
  margin-top: 1.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.control-hint {
  margin: 1.3rem 0 0;
  color: #8490a0;
  font-size: 0.72rem;
  line-height: 1.8;
}
kbd {
  display: inline-block;
  min-width: 1.35rem;
  margin: 0 0.08rem;
  padding: 0.05rem 0.22rem;
  border: 1px solid rgb(180 194 212 / 28%);
  border-radius: 2px;
  color: #d5d9de;
  background: #151c28;
  font: 700 0.68rem/1.5 ui-monospace, monospace;
  text-align: center;
}

.setup-grid { display: grid; gap: 1rem; }
.form-actions { justify-content: space-between; margin-top: 0.5rem; }

.lobby-panel { max-width: 620px; margin: 0 auto; }
.lobby-heading { margin-bottom: 1rem; }
.room-code-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid rgb(240 163 74 / 26%);
  background: linear-gradient(100deg, rgb(240 163 74 / 9%), rgb(16 22 34 / 78%));
}
.room-code { display: block; margin-top: 0.2rem; color: var(--amber); font: 900 1.85rem/1 ui-monospace, monospace; letter-spacing: 0.16em; }
.capacity { color: #95a3b4; font-size: 0.61rem; text-align: right; }
.capacity strong { display: block; color: var(--teal); font-size: 1.3rem; }
.share-panel { display: grid; gap: 0.5rem; }
.share-row input { min-width: 0; flex: 1; font-size: 0.75rem; }
.share-row .button { flex: 0 0 auto; }
.roster-panel { margin-top: 1.5rem; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: 0.55rem; border-bottom: 1px solid var(--line); }
.section-heading h3 { margin: 0; font-size: 0.95rem; }
.section-heading > span { color: #7f8c9e; font-size: 0.6rem; }
.roster { display: grid; gap: 0.5rem; margin: 0.65rem 0 0; padding: 0; list-style: none; }
.roster li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgb(180 194 212 / 12%);
  background: #0d131e;
  color: #e5e4de;
}
.pilot-tag { color: var(--teal); font: 750 0.6rem/1 ui-monospace, monospace; letter-spacing: 0.12em; }
.lobby-actions { justify-content: space-between; margin-top: 1.2rem; }
.lobby-actions .button-primary { margin-right: auto; }
.results-panel { min-height: 15rem; padding: 1.5rem; border: 1px solid var(--line); background: rgb(11 16 26 / 70%); }
.results-panel .button { margin-top: 1.25rem; }
.shell-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: #697586;
  font-size: 0.55rem;
}

@keyframes signal-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  body { padding: 0; }
  .launch-shell { min-height: 100vh; padding: 2rem 1.1rem 1.2rem; border-inline: 0; }
  .signal { font-size: 0.58rem; }
  .service-status { margin: 1.3rem 0 1.5rem; font-size: 0.68rem; }
  .launch-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .launch-actions .button { padding-inline: 0.6rem; }
  .join-form { grid-template-columns: 1fr; }
  .button-join { width: 100%; }
  .room-code-card { padding: 0.85rem; }
  .room-code { font-size: 1.55rem; }
  .share-row { align-items: stretch; flex-direction: column; }
  .share-row .button { width: 100%; }
  .lobby-actions { align-items: stretch; flex-direction: column; }
  .lobby-actions .button { width: 100%; }
  .shell-footer { align-items: flex-start; flex-direction: column; font-size: 0.52rem; }
}

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

#app:has(#match-panel:not([hidden])) { width: min(100%, 1120px); }
.match-panel { min-width: 0; }
.match-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.match-header h2 { margin: 0; font-size: clamp(1.35rem, 4vw, 2rem); letter-spacing: -0.035em; }
.match-turn-message { margin: 0.45rem 0 0; color: var(--teal); font-size: 0.78rem; }
.match-readouts { display: flex; align-items: center; gap: 0.85rem; }
.match-readouts p { display: grid; gap: 0.25rem; min-width: 5.2rem; margin: 0; padding: 0.55rem 0.7rem; border: 1px solid var(--line); background: #0d131e; }
.match-readouts p span, .console-heading > span { color: #8492a5; font: 750 0.56rem/1.3 ui-monospace, monospace; letter-spacing: 0.11em; }
.match-readouts p strong { color: #f2c17d; font: 800 0.92rem/1 ui-monospace, monospace; }
.match-readouts .button { min-height: 2.8rem; padding-inline: 0.75rem; white-space: nowrap; }
.arena-frame { position: relative; overflow: hidden; border: 1px solid rgb(146 154 194 / 42%); background: #080b14; box-shadow: 0 14px 38px rgb(0 0 0 / 35%); }
#arena { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; touch-action: none; outline: none; }
#arena:focus-visible { outline: 3px solid var(--teal); outline-offset: -4px; }
.reconnect-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; color: #ffe1ac; background: rgb(8 11 20 / 76%); font: 850 0.95rem/1.4 ui-monospace, monospace; letter-spacing: 0.13em; text-align: center; }
.match-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: 0.9rem; margin-top: 0.9rem; }
.match-console, .match-sidebar { display: grid; align-content: start; gap: 0.75rem; min-width: 0; }
.control-card { min-width: 0; padding: 0.9rem; border: 1px solid var(--line); background: linear-gradient(145deg, rgb(19 26 39 / 95%), rgb(12 17 27 / 96%)); }
.console-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.7rem; }
.console-heading h3 { margin: 0; font-size: 0.91rem; }
.range-control { display: flex; align-items: baseline; gap: 0.32rem; margin: 0.45rem 0 0.2rem; color: #c0c9d4; font-size: 0.74rem; }
.range-control output { color: #f5bc70; font: 800 0.78rem ui-monospace, monospace; }
.game-range { display: block; width: 100%; height: 2.5rem; margin: 0; accent-color: var(--teal); cursor: pointer; }
.game-range:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.direction-row { display: flex; gap: 0.55rem; margin-top: 0.45rem; }
.game-button { flex: 1 1 0; min-width: 0; min-height: 3rem; padding: 0.55rem 0.7rem; border: 1px solid rgb(180 194 212 / 25%); color: #d8dedf; background: #172131; font-size: 0.77rem; font-weight: 750; cursor: pointer; }
.game-button:hover:not(:disabled) { border-color: rgb(98 202 187 / 65%); background: #1e3040; }
.game-button:focus-visible, .weapon-button:focus-visible, .sound-button:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.game-button:disabled, .weapon-button:disabled { cursor: not-allowed; opacity: 0.48; }
.game-button[aria-pressed="true"] { border-color: var(--teal); color: #a6efe3; background: rgb(40 104 96 / 28%); }
.weapon-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; }
.weapon-button { display: grid; align-content: center; gap: 0.3rem; min-width: 0; min-height: 3.45rem; padding: 0.45rem; border: 1px solid rgb(180 194 212 / 22%); color: #d8dedf; background: #0d141f; text-align: left; cursor: pointer; }
.weapon-button span { overflow: hidden; color: #e7e4db; font-size: 0.68rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.weapon-button small { color: #93a1b1; font: 700 0.6rem ui-monospace, monospace; }
.weapon-button[aria-pressed="true"] { border-color: var(--amber); background: rgb(108 67 35 / 24%); }
.weapon-button[aria-pressed="true"] small { color: #f4c386; }
.fire-button { width: 100%; min-height: 3.35rem; margin-top: 0.75rem; }
.match-roster, .match-feed { display: grid; gap: 0.45rem; margin: 0; padding: 0; list-style: none; }
.match-roster li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.15rem 0.55rem; min-height: 3.05rem; padding: 0.45rem 0.55rem; border: 1px solid rgb(180 194 212 / 12%); background: #0b111b; }
.match-roster li.is-active { border-color: rgb(98 202 187 / 60%); background: rgb(31 77 76 / 22%); }
.match-roster li.is-eliminated { opacity: 0.56; }
.pilot-name { overflow: hidden; color: #e5e4de; font-size: 0.77rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.pilot-state { color: #91a1ae; font: 750 0.54rem ui-monospace, monospace; letter-spacing: 0.07em; text-align: right; }
.match-roster meter { width: 100%; height: 0.45rem; grid-column: 1 / -1; accent-color: var(--teal); }
.match-roster .health-value { color: #c5d0d5; font: 700 0.62rem ui-monospace, monospace; }
.match-feed { max-height: 10rem; overflow: auto; }
.match-feed li { padding: 0.48rem 0.55rem; border-left: 2px solid rgb(240 163 74 / 65%); color: #b9c4d1; background: #0b111b; font-size: 0.7rem; line-height: 1.4; }
.sound-button { width: 100%; min-height: 3rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 760px) {
  .match-grid { grid-template-columns: 1fr; }
  .match-sidebar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sound-button { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  #app:has(#match-panel:not([hidden])) { padding: 1.5rem 0.75rem 1rem; }
  .match-header { flex-direction: column; }
  .match-readouts { width: 100%; justify-content: space-between; gap: 0.4rem; }
  .match-readouts p { flex: 1 1 auto; min-width: 0; padding: 0.48rem; }
  .match-readouts .button { flex: 0 0 auto; font-size: 0.72rem; }
  .match-grid { gap: 0.65rem; margin-top: 0.65rem; }
  .control-card { padding: 0.75rem; }
  .match-sidebar { grid-template-columns: 1fr; }
  .sound-button { grid-column: auto; }
  .weapon-choices { gap: 0.32rem; }
  .weapon-button { padding-inline: 0.35rem; }
  .weapon-button span { font-size: 0.62rem; }
}
