:root {
  color-scheme: dark;
  --ink: #e7e5dc;
  --muted: #adb7b8;
  --ground: #0d1012;
  --housing: #22282b;
  --steel: #465055;
  --screen: #101619;
  --rule: #364249;
  --amber: #e4bb83;
  --body: "Segoe UI", sans-serif;
  --display: Bahnschrift, "DIN Alternate", "Arial Narrow", sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.45 var(--body); }
a { color: inherit; text-underline-offset: 4px; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.terminal {
  width: min(1260px, 100% - 72px);
  margin: clamp(24px, 6vh, 68px) auto 0;
}
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: 23px 30px 22px;
  background: #1b2023;
  border: 1px solid var(--steel);
  box-shadow: inset 0 2px #333c40;
}
h1 {
  font: 700 clamp(28px, 4vw, 53px)/.95 var(--display);
  letter-spacing: -.025em;
  text-transform: uppercase;
}
.terminal-identity p { margin-top: 7px; color: var(--muted); font: 14px/1.25 var(--mono); }
.masthead-tools { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: flex-end; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font: 13px/1.3 var(--mono);
  white-space: nowrap;
}
.connection::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #959ea0;
  box-shadow: 0 0 0 3px #101417;
}
.connection[data-state="online"]::before { background: #a6c5a3; }
.connection[data-state="offline"]::before { background: #e38a7c; }

.console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(265px, 29%);
  align-items: stretch;
  padding: 12px;
  gap: 12px;
  background: var(--housing);
  border: 1px solid var(--steel);
  border-top: 0;
  box-shadow: inset 0 -2px #101315, 0 14px 34px #0005;
}
.deck {
  min-width: 0;
  min-height: 322px;
  background: var(--screen);
  border: 1px solid #0b0e10;
  box-shadow: 0 1px #454d51, inset 0 1px 3px #080d0f;
}
.deck-head {
  padding: 19px 23px 17px;
  border-bottom: 1px solid var(--rule);
  background: #1c262a;
}
h2 {
  font: 700 clamp(23px, 2.5vw, 31px)/1.12 var(--display);
  overflow-wrap: anywhere;
}
#directory-detail { margin-top: 6px; color: var(--muted); font: 14px/1.35 var(--mono); }
#directory-detail:empty { display: none; }

.pilot-station {
  align-self: start;
  min-width: 0;
  background: #2b3337;
  border: 1px solid #111618;
  box-shadow: inset 0 1px #4c5559, 0 1px #454d51;
}
.entry-actions { padding: 17px; border-bottom: 1px solid #111618; }
.station-actions, .form-actions, .squadron-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.station-actions { margin-top: 10px; }
.station-actions .button { flex: 1 0 auto; }
.insignia-plate {
  display: grid;
  place-items: center;
  min-height: 152px;
  margin: 14px 17px 16px;
  background: #192125;
  border: 1px solid #111618;
  box-shadow: inset 0 2px 3px #0d1114, 0 1px #414d52;
}
.squadron-mark {
  --stamp: #859094;
  display: grid;
  place-items: center;
  width: 100px;
  aspect-ratio: 1;
  border: 2px solid var(--stamp);
  border-radius: 50%;
}
.squadron-mark::before, .squadron-mark > span {
  grid-area: 1 / 1;
  aspect-ratio: 1;
}
.squadron-mark::before {
  content: "";
  width: 83%;
  border-radius: 50%;
  background: repeating-conic-gradient(from -13deg, var(--stamp) 0deg 26deg, transparent 26deg 60deg);
  mask-image: radial-gradient(circle, transparent 0 30%, #000 31%);
}
.squadron-mark > span {
  width: 68%;
  background: var(--stamp);
  clip-path: polygon(25% 7%, 75% 7%, 100% 50%, 75% 93%, 25% 93%, 0 50%, 25% 7%, 37% 28%, 24% 50%, 37% 72%, 63% 72%, 76% 50%, 63% 28%, 37% 28%);
}

label { display: block; color: #d0d6d4; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid #697378;
  border-radius: 2px;
  background: #101619;
  color: var(--ink);
}
input { box-shadow: inset 0 2px 3px #0005; }
input::placeholder { color: #a3aeb1; }
.button {
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #677277;
  border-radius: 2px;
  background: #333e43;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: inset 0 1px #ffffff18, inset 0 -2px #0004;
  cursor: pointer;
}
.button:hover:not(:disabled) { background: #435159; }
.button:active:not(:disabled) { box-shadow: inset 0 2px #0005; }
.button.primary { background: var(--amber); border-color: #d4ad76; color: #1c160e; }
.button.primary:hover:not(:disabled) { background: #f0cd9d; }
.button:disabled { opacity: .55; cursor: default; }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
.button.utility { background: #232b2e; }

.room-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 76px;
  align-items: end;
  gap: 12px;
  padding: 16px 23px;
  border-bottom: 1px solid var(--rule);
  background: #192125;
}
.room-form .form-actions { grid-column: 1 / -1; justify-content: flex-end; }
#join-form { grid-template-columns: minmax(130px, 225px) auto; justify-content: start; }
#join-form .form-actions { grid-column: auto; justify-content: flex-start; }
#room-code { text-transform: uppercase; letter-spacing: .08em; }

.message {
  padding: 11px 23px;
  border-bottom: 1px solid var(--rule);
  color: #e9bf8a;
  overflow-wrap: anywhere;
}
.message[data-error="true"] { color: #ffb6a8; }
.room-list, .squadron { padding-inline: 23px; }
.list-head, .room-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 54px 62px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
}
.list-head { padding-block: 11px; color: var(--muted); font: 13px/1.3 var(--mono); }
.room-row { min-height: 62px; padding-block: 8px; overflow-wrap: anywhere; }
.room-row span { color: var(--muted); font-size: 14px; }
.room-row button { padding-inline: 8px; }
.empty {
  min-height: 104px;
  display: flex;
  align-items: flex-start;
  padding-block: 18px;
  color: var(--muted);
}
.squadron-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-block: 12px;
  color: var(--muted);
  font: 14px/1.35 var(--mono);
}
.squadron-toolbar .button { font-family: var(--body); }
.pilot-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.pilot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 76px;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.pilot-row span { color: var(--muted); font-size: 14px; }
.pilot-row strong { overflow-wrap: anywhere; }
.pilot-row span.is-ready { color: #b7d0b3; }
.squadron-actions { justify-content: space-between; padding-block: 15px; }
footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 14px 2px 20px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 780px) {
  .terminal { width: calc(100% - 32px); }
  .masthead { padding: 17px; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .deck { min-height: 0; }
  .empty { min-height: 72px; }
  .pilot-station { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .entry-actions { border: 0; border-right: 1px solid #111618; align-content: center; }
  .insignia-plate { min-height: 120px; }
  .console:has(#squadron:not([hidden])) .pilot-station { display: none; }
}

@media (max-width: 515px) {
  .terminal { width: calc(100% - 22px); margin-top: 11px; }
  .masthead { align-items: stretch; flex-direction: column; gap: 14px; padding: 14px 12px 12px; }
  .terminal-identity { align-self: flex-start; }
  .masthead-tools { justify-content: space-between; gap: 7px; }
  .console { padding: 8px; gap: 8px; }
  .pilot-station { grid-template-columns: minmax(0, 1fr); }
  .entry-actions { padding: 13px; border: 0; border-bottom: 1px solid #111618; }
  .insignia-plate { margin-inline: 13px; }
  .deck-head, .room-list, .squadron, .room-form, .message { padding-inline: 12px; }
  .deck-head { padding-block: 13px; }
  .room-form { grid-template-columns: minmax(0, 1fr) 62px; }
  #host-form > :first-child { grid-column: 1 / -1; }
  #join-form { grid-template-columns: minmax(0, 1fr); }
  .list-head, .room-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px 50px; gap: 7px; }
  .room-row button { padding-inline: 5px; }
  .pilot-row { grid-template-columns: minmax(0, 1fr) 42px 54px; }
}
