:root {
  color-scheme: dark;
  font:
    14px "Segoe UI",
    sans-serif;
  --cyan: #81e6df;
  --orange: #ffad72;
  --text: #eaf4f5;
  --muted: #8fa6b7;
  --line: #2a4152;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #07101b;
  color: var(--text);
  overflow: hidden;
}
button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font:
    600 12px "Segoe UI",
    sans-serif;
  color: var(--text);
  background: #132333;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 18px;
  cursor: pointer;
}
button:hover {
  border-color: var(--cyan);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.primary {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #07232a;
}
a {
  color: var(--muted);
  text-decoration: none;
}
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
#arena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
header {
  position: fixed;
  inset: 0 0 auto;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #29405077;
  background: #07101beb;
  z-index: 5;
}
header a {
  font:
    11px Consolas,
    monospace;
  letter-spacing: 0.1em;
}
header strong {
  font-size: 14px;
  letter-spacing: 0.12em;
}
header span {
  color: var(--muted);
  font-weight: 400;
}
.panel {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #0c1928f7;
  border: 1px solid var(--line);
  border-top: 2px solid var(--cyan);
  border-radius: 5px;
  padding: 28px 34px;
  width: min(560px, calc(100% - 30px));
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  box-shadow: 0 25px 100px #0008;
}
.eyebrow {
  font:
    10px Consolas,
    monospace;
  letter-spacing: 0.13em;
  color: var(--cyan);
}
h1 {
  font-size: 42px;
  line-height: 1.06;
  letter-spacing: -0.05em;
  margin: 18px 0;
}
h2 {
  font-size: 30px;
}
.intro {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}
label {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin: 10px 0 6px;
}
input {
  width: 100%;
  background: #08131f;
  border: 1px solid #344c60;
  border-radius: 4px;
  padding: 11px;
  color: var(--text);
  font:
    13px Consolas,
    monospace;
}
.small {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.room-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  margin: 24px 0;
  align-items: end;
}
.join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.join label {
  grid-column: 1/-1;
  margin: 0;
}
#room-code {
  text-transform: uppercase;
  min-width: 0;
}
#status {
  color: var(--cyan);
  font-size: 12px;
  line-height: 1.5;
  min-height: 18px;
}
#status.error {
  color: var(--orange);
}
.controls-note {
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.9;
}
.limits {
  margin-bottom: 0;
}
#waiting {
  padding: 18px;
  background: #102d3a;
  border: 1px solid #397078;
}
#share-code {
  display: block;
  font:
    30px Consolas,
    monospace;
  color: var(--cyan);
  letter-spacing: 0.14em;
  margin: 12px 0;
}
#waiting p {
  font-size: 12px;
  color: var(--muted);
}
#match-hud {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  z-index: 4;
}
.ship-health {
  position: fixed;
  width: 100px;
  padding: 4px 5px;
  border-radius: 4px;
  background: #07101bea;
  transform: translate(-50%, -100%);
  pointer-events: none;
  z-index: 3;
  font:
    10px Consolas,
    monospace;
}
.ship-health b {
  float: right;
}
progress {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 7px;
  border: 0;
  accent-color: var(--cyan);
}
.orange progress {
  accent-color: var(--orange);
}
.cyan {
  color: var(--cyan);
}
.orange {
  color: var(--orange);
}
#round-clock {
  font:
    20px Consolas,
    monospace;
  text-align: center;
}
#countdown {
  position: fixed;
  inset: 40% 0 auto;
  text-align: center;
  font-size: 70px;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 0 40px #4ae2e788;
}
footer {
  position: fixed;
  bottom: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font:
    10px Consolas,
    monospace;
  gap: 10px;
  z-index: 4;
}
#result-detail {
  color: var(--muted);
  line-height: 1.6;
}
#rematch-status {
  font-size: 12px;
  color: var(--cyan);
}
#touch-controls {
  position: fixed;
  inset: auto 15px 48px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
  z-index: 6;
}
.thumb-cluster {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 82px;
  pointer-events: auto;
}
#touch-controls button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  min-height: 48px;
  padding: 9px 5px;
  font-size: 11px;
}
#touch-controls button.pressed {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px #ffad7277;
}
.turn-fallback {
  display: flex;
  gap: 5px;
}
.turn-fallback button {
  flex: 1;
}
#boost-state,
#trap-state {
  display: block;
  font-size: 9px;
  margin-top: 3px;
  color: var(--cyan);
}
#boost-button.cooling {
  border-color: #456071;
  background: #0a1926;
}
#trap-button { border-color: #bc78d4; color: #f3bdff; }
#trap-button.cooling { border-color: #53425f; background: #191528; }
.lock-state { color: #f3bdff; font-size: 9px; }
#trap-hud {
  position: fixed;
  top: 126px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  min-width: 160px;
  padding: 6px 10px;
  background: #0c1327e8;
  border: 1px solid #755187;
  border-radius: 4px;
  text-align: center;
  color: #f3bdff;
  font: 11px Consolas, monospace;
  pointer-events: none;
}
#trap-hud small { font-size: 9px; color: var(--muted); }
#trap-hud.locked { border-color: #f3bdff; background: #342040; }
#trap-meter { height: 4px; margin: 4px 0; }
#trap-meter::-webkit-progress-value { background: #db98f2; }
#trap-meter::-moz-progress-bar { background: #db98f2; }
@media (max-width: 600px) and (orientation: portrait) {
  #trap-hud { top: 200px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  #trap-hud { top: 40px; right: 8px; left: auto; transform: none; min-width: 118px; font-size: 10px; }
  #trap-hud small { display: none; }
}
#mobile-utilities {
  position: fixed;
  top: 72px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 270px;
  z-index: 6;
}
#mobile-utilities button {
  padding: 8px;
  font-size: 10px;
  min-height: 34px;
}
#tilt-status {
  width: 100%;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}
@media (pointer: coarse) {
  #touch-controls:not([hidden]) {
    display: flex;
  }
  #flight-help {
    display: none;
  }
}
@media (max-width: 600px) {
  header {
    padding: 0 15px;
    height: 58px;
  }
  header strong {
    font-size: 11px;
  }
  .panel {
    padding: 20px;
    max-height: calc(100dvh - 80px);
  }
  h1 {
    font-size: 35px;
  }
  .room-actions {
    gap: 12px;
    grid-template-columns: 1fr;
  }
  .join {
    grid-template-columns: 1fr auto;
  }
  #match-hud {
    top: 74px;
  }
  footer {
    font-size: 9px;
    left: 15px;
    right: 15px;
  }
  #flight-help {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

#connection-settings {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  margin: 18px 0;
}
#connection-settings summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}
#connection-settings[open] summary {
  color: var(--text);
  margin-bottom: 12px;
}
#arena:focus {
  outline: none;
}

progress {
  appearance: none;
  background: #17313d;
  border-radius: 5px;
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: #17313d;
}
progress::-webkit-progress-value {
  background: var(--cyan);
}
.orange progress::-webkit-progress-value {
  background: var(--orange);
}
progress::-moz-progress-bar {
  background: var(--cyan);
}
.orange progress::-moz-progress-bar {
  background: var(--orange);
}

#portrait-hint {
  display: none;
}
@media (max-width: 600px) and (orientation: portrait) {
  #flight-footer #portrait-hint {
    display: block;
    color: var(--cyan);
  }
  #flight-footer {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 600px) and (orientation: portrait) {
  #mobile-utilities {
    top: 123px;
    left: 15px;
    right: 15px;
    max-width: none;
  }
  #mobile-utilities button {
    min-height: 40px;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  header {
    height: 34px;
    padding: 0 10px;
  }
  header strong {
    font-size: 10px;
  }
  header button {
    padding: 5px 10px;
  }
  #match-hud {
    top: 38px;
  }
  .ship-health {
    font-size: 9px;
    width: 92px;
  }
  progress {
    height: 5px;
    margin-top: 3px;
  }
  #round-clock {
    font-size: 15px;
  }
  #mobile-utilities {
    top: 42px;
    left: max(8px, env(safe-area-inset-left));
    right: auto;
    width: 132px;
  }
  #mobile-utilities button {
    padding: 7px;
    min-height: 34px;
  }
  #touch-controls {
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }
  .thumb-cluster {
    width: 74px;
    gap: 5px;
  }
  #touch-controls button {
    min-height: 46px;
  }
  #flight-footer {
    bottom: 3px;
    justify-content: center;
    font-size: 8px;
    pointer-events: none;
  }
  #flight-footer #network-status {
    display: none;
  }
  .panel {
    max-height: calc(100dvh - 48px);
    padding: 16px 24px;
    top: calc(50% + 12px);
  }
}

#mode-picker { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
#mode-picker legend { font: 11px Consolas, monospace; color: var(--cyan); }
#match-mode { width: 100%; padding: 10px; color: var(--text); background: #0c1b29; border: 1px solid var(--line); border-radius: 4px; }
.violet { color: #c7a6ff; }
.violet progress { accent-color: #c7a6ff; }
.violet progress::-webkit-progress-value { background: #c7a6ff; }
.violet progress::-moz-progress-bar { background: #c7a6ff; }
#spectator-status { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 7; max-width: 90vw; padding: 8px 12px; text-align: center; background: #0b152eee; border: 1px solid #c7a6ff; border-radius: 6px; font: 12px Consolas, monospace; color: #e3d6ff; pointer-events: none; }
@media (orientation: landscape) and (max-height: 600px) { #spectator-status { bottom: 28px; max-width: 65vw; font-size: 10px; } }
