:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050b14;
  color: #eaf4ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, rgba(38, 91, 137, 0.2), transparent 38rem), #050b14;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
}

.hidden { display: none !important; }


.company-splash {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: grid;
  place-items: center;
  background: #08010a;
  transition: opacity 900ms ease, visibility 900ms ease;
}
.company-splash img {
  width: 100vw;
  height: 100svh;
  max-width: 100vw;
  max-height: 100svh;
  object-fit: contain;
  display: block;
}
.company-splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 68% 22%, rgba(255, 164, 64, 0.22), transparent 19rem),
    radial-gradient(circle at 22% 12%, rgba(93, 184, 255, 0.2), transparent 24rem),
    rgba(2, 7, 17, 0.96);
  backdrop-filter: blur(8px);
}
.start-card {
  width: min(720px, 94vw);
  max-height: min(92vh, 860px);
  overflow: auto;
  border: 1px solid rgba(142, 210, 255, 0.28);
  border-radius: 22px;
  padding: clamp(18px, 3vw, 28px);
  background: linear-gradient(180deg, rgba(12, 25, 42, 0.96), rgba(4, 11, 22, 0.98));
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.5);
}
.start-card.title-card {
  position: relative;
  width: min(1120px, 96vw);
  min-height: min(72vh, 660px);
  overflow: hidden;
  padding: 0;
  background: #020711;
}
.game-title-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.95;
  background: #020711;
}
.start-control-panel {
  position: absolute;
  z-index: 1;
  left: clamp(18px, 3vw, 34px);
  bottom: clamp(18px, 3vw, 34px);
  width: min(430px, calc(100% - 48px));
  max-height: calc(100% - 48px);
  overflow: auto;
  padding: clamp(16px, 2.4vw, 24px);
  border: 1px solid rgba(142, 210, 255, 0.22);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(2,7,17,0.78), rgba(2,7,17,0.58));
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(4px);
}
.start-screen.config-mode {
  background:
    radial-gradient(circle at 50% 18%, rgba(59, 162, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 50% 100%, rgba(255, 133, 64, 0.14), transparent 32rem),
    rgba(2, 7, 17, 0.98);
}
.start-screen.config-mode .start-card.title-card {
  width: min(660px, 94vw);
  min-height: auto;
  max-height: min(88svh, 760px);
  overflow: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: grid;
  place-items: center;
}
.start-screen.config-mode .game-title-image { display: none; }
.start-screen.config-mode .start-control-panel {
  position: relative;
  inset: auto;
  width: min(590px, 94vw);
  max-height: min(86svh, 720px);
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(9, 22, 39, 0.96), rgba(3, 9, 19, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  font-size: 0.8rem;
}
.start-screen.config-mode .start-control-panel h1 { font-size: clamp(1.2rem, 3vw, 1.65rem); margin-bottom: 6px; }
.start-screen.config-mode .match-config-panel h2 { font-size: 1rem; margin-bottom: 8px; }
.start-screen.config-mode .start-field,
.start-screen.config-mode .config-grid label { font-size: 0.62rem; gap: 5px; }
.start-screen.config-mode .start-field input,
.start-screen.config-mode .config-grid input,
.start-screen.config-mode .config-grid select,
.start-screen.config-mode .join-match-panel input { padding: 8px 10px; border-radius: 10px; }
.start-screen.config-mode .start-actions-row,
.start-screen.config-mode .match-choice-panel { gap: 8px; margin-top: 10px; }
.start-screen.config-mode .start-action { min-height: 34px; padding: 7px 13px; font-size: 0.78rem; }
.start-screen.config-mode .match-url-card { padding: 10px; gap: 6px; margin: 8px 0 11px; }
.start-screen.config-mode .match-url-card strong { font-size: 0.68rem; }
.start-screen.config-mode .config-grid { gap: 9px; }
.start-screen.config-mode .start-status { font-size: 0.68rem; margin-top: 8px; }
.start-card h1 { margin-bottom: 8px; }
.start-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  color: #9edaff;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.start-field input,
.config-grid input,
.config-grid select,
.join-match-panel input {
  width: 100%;
  border: 1px solid rgba(142, 210, 255, 0.32);
  border-radius: 12px;
  padding: 11px 12px;
  background: rgba(0, 0, 0, 0.34);
  color: #f2fbff;
  outline: none;
}
.match-choice-panel,
.start-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.start-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid rgba(142, 210, 255, 0.34);
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(30, 62, 92, 0.95), rgba(10, 27, 48, 0.96));
  color: #e8f8ff;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}
.start-action.primary {
  background: linear-gradient(180deg, rgba(64, 180, 255, 0.96), rgba(16, 87, 143, 0.98));
  border-color: rgba(151, 231, 255, 0.6);
  color: #03111c;
}
.start-action.ghost { background: rgba(255,255,255,0.05); }
.start-action.launch { width: 100%; margin-top: 14px; }
.start-action.sms { color: #07121b; background: linear-gradient(180deg, #b7ffe0, #59d79a); }
.match-config-panel { margin-top: 14px; }
.match-url-card {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  background: rgba(255,255,255,0.035);
}
.match-url-card span, .match-url-card strong { overflow-wrap: anywhere; }
.match-url-card span { color: #7f94aa; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; }
.match-url-card strong { color: #eaffff; font-size: 0.82rem; }
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.config-grid label {
  display: grid;
  gap: 7px;
  color: #9edaff;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.config-grid label:last-child { grid-column: 1 / -1; }
.config-grid strong { color: #f4fbff; font-size: 0.78rem; }
.start-status { min-height: 1.2em; margin-top: 12px; color: #aee7ff; font-size: 0.78rem; }

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #79cfff;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 2.5vw, 2.35rem); }
h2 { margin-bottom: 6px; font-size: 1rem; }
p { color: #9fb1c5; }

.badge,
.room-state {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.connected,
.room-state.active {
  background: rgba(59, 207, 130, 0.14);
  color: #8ff1b8;
  border-color: rgba(88, 235, 155, 0.34);
}

.badge.disconnected,
.room-state.waiting {
  background: rgba(255, 185, 73, 0.12);
  color: #ffd58a;
  border-color: rgba(255, 190, 84, 0.34);
}

.stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.stats > div,
.arena-card,
.panel {
  border: 1px solid rgba(142, 190, 230, 0.14);
  background: linear-gradient(180deg, rgba(14, 27, 43, 0.96), rgba(8, 16, 28, 0.96));
  box-shadow: 0 18px 50px rgba(0,0,0,0.24);
}

.stats > div {
  min-width: 0;
  border-radius: 11px;
  padding: 8px 10px;
}

.stats span {
  display: block;
  margin-bottom: 3px;
  color: #7f94aa;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.stats strong.critical { color: #ff6d75; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 12px;
  align-items: start;
}

.arena-card {
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
}

.arena-header {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(142, 190, 230, 0.13);
}

.arena-header p { margin-bottom: 0; font-size: 0.8rem; }

.arena-header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.arena-select-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  background: rgba(0,0,0,0.32);
  color: #aee7ff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arena-select-control select {
  min-width: 128px;
  border: 1px solid rgba(255,255,255,0.34);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(5, 13, 25, 0.94);
  color: white;
  font-weight: 850;
}

.mobile-arena-control { display: none; }

.arena {
  position: relative;
  width: 100%;
  height: min(74vh, 790px);
  min-height: 520px;
  overflow: hidden;
  background: #020711;
  touch-action: none;
  user-select: none;
}

.game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.game-overlay {
  position: absolute;
  z-index: 25;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(1, 6, 13, 0.68);
  backdrop-filter: blur(5px);
  transition: opacity 160ms ease;
}

.game-overlay strong {
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  letter-spacing: 0.05em;
}
.game-overlay span { color: #b9c9d9; }
.game-overlay.hidden { opacity: 0; pointer-events: none; }

.crosshair {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 47%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  opacity: 0.42;
  pointer-events: none;
}

.crosshair span:first-child,
.crosshair span:last-child {
  position: absolute;
  background: #dff7ff;
  box-shadow: 0 0 8px rgba(135, 229, 255, 0.85);
}
.crosshair span:first-child { width: 42px; height: 1px; top: 20px; left: 0; }
.crosshair span:last-child { width: 1px; height: 42px; left: 20px; top: 0; }

.desktop-help {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(1, 7, 14, 0.72);
  color: #a9bfd3;
  font-size: 0.68rem;
  text-align: center;
  pointer-events: none;
}

.fullscreen-btn {
  position: absolute;
  z-index: 16;
  top: max(9px, env(safe-area-inset-top));
  right: 9px;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.72);
  background: rgba(0,0,0,0.48);
  color: white;
  font-size: 22px;
  cursor: pointer;
}

.camera-controls {
  position: absolute;
  z-index: 15;
  top: 9px;
  right: 58px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 156px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.48);
  color: white;
  font-size: 0.68rem;
}

.camera-controls label { display: flex; flex-direction: column; gap: 2px; }
.camera-controls input[type="range"] { width: 100%; }
.camera-controls .hud-end-match {
  width: 100%;
  min-height: 28px;
  padding: 5px 8px;
  font-size: 0.58rem;
  line-height: 1;
}

.weapon-select {
  position: absolute;
  z-index: 15;
  top: 9px;
  right: 222px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
  touch-action: none;
}

.weapon-select-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 5px;
  border: 2px solid rgba(255,255,255,0.82);
  color: #07111f;
  font-weight: 900;
  cursor: pointer;
}
.weapon-select-button.primary { background: rgb(60, 190, 255); }
.weapon-select-button.missile { background: linear-gradient(135deg, #bfc7cc 0%, #8f989e 49%, #d91f2a 50%, #f34848 100%); }
.weapon-select-button.bomb { background: rgb(255, 90, 210); color: white; }
.weapon-select-button.selected {
  outline: 2px solid white;
  box-shadow: 0 0 11px rgba(255,255,255,0.88);
  transform: scale(1.08);
}

.mobile-health-hud {
  position: absolute;
  z-index: 17;
  top: 9px;
  left: 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 222px;
  padding: 7px 8px;
  border: 1px solid rgba(255,255,255,0.42);
  border-radius: 9px;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.hud-meter-row {
  display: grid;
  grid-template-columns: 48px minmax(105px, 152px) 39px;
  align-items: center;
  gap: 6px;
}
.mobile-health-track,
.mobile-boost-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
}
.mobile-health-track i,
.mobile-boost-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 100ms linear;
}
.mobile-health-track i { background: linear-gradient(90deg, #45dd8a, #a8f06a); }
.mobile-health-track i.critical { background: linear-gradient(90deg, #ff3c52, #ff8b62); }
.mobile-boost-track i {
  background: linear-gradient(90deg, #c99b00, #ffe34f 55%, #fff4a6);
  box-shadow: 0 0 8px rgba(255, 220, 58, 0.65);
}
.boost-meter-row.active { color: #fff3a0; }
.boost-meter-row.active .mobile-boost-track i { animation: boostPulse 420ms ease-in-out infinite alternate; }
@keyframes boostPulse {
  from { filter: brightness(1); box-shadow: 0 0 8px rgba(255, 220, 58, 0.65); }
  to { filter: brightness(1.45); box-shadow: 0 0 15px rgba(255, 236, 105, 0.95); }
}
.mobile-health-hud strong { text-align: right; font-size: 0.66rem; }
.assist-meter-row { pointer-events: auto; }
.assist-meter-row label { cursor: pointer; }
.assist-meter-row input[type="range"] {
  width: 100%;
  height: 12px;
  margin: 0;
  cursor: pointer;
  touch-action: none;
}
.laser-assist-row input[type="range"] { accent-color: #61d8ff; }
.missile-assist-row input[type="range"] { accent-color: #ff8b4d; }


.mobile-controls { display: none; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  border-radius: 14px;
  padding: 13px;
}
.panel > p { margin-bottom: 10px; font-size: 0.78rem; }

.desktop-key-grid {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  grid-template-rows: repeat(3, 58px);
  justify-content: center;
  gap: 7px;
  user-select: none;
}

.desktop-key {
  border: 1px solid rgba(130, 208, 255, 0.25);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(34, 70, 98, 0.95), rgba(15, 34, 52, 0.98));
  color: #dff6ff;
  font-size: 0.88rem;
  font-weight: 900;
  cursor: pointer;
}
.desktop-key small { font-size: 0.55rem; opacity: 0.72; }
.desktop-key.pressed {
  transform: translateY(2px) scale(0.98);
  background: linear-gradient(180deg, rgba(65, 147, 197, 0.98), rgba(22, 70, 101, 0.98));
}
.desktop-key.fire {
  background: radial-gradient(circle at 50% 35%, #ff996a, #c0394b 58%, #6b182b);
}

.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-row {
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 11px;
  padding: 9px;
  background: rgba(255,255,255,0.025);
}
.player-row.destroyed { opacity: 0.55; }
.player-row-top { display: flex; align-items: center; gap: 9px; }
.player-chip {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  font-weight: 900;
}
.slot-1 .player-chip { color: #61d8ff; }
.slot-2 .player-chip { color: #75f4a5; }
.slot-3 .player-chip { color: #ffd56a; }
.slot-4 .player-chip { color: #dc8cff; }
.player-copy { min-width: 0; flex: 1; }
.player-copy strong,
.player-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-copy strong { font-size: 0.78rem; }
.player-copy span { margin-top: 2px; color: #8196aa; font-size: 0.65rem; }
.health-number { font-size: 0.78rem; }
.health-track {
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.health-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ee5f69, #f6c459 42%, #5de29c);
  transition: width 100ms linear;
}

.match-roster-hud {
  position: absolute;
  z-index: 17;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 210px;
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 12px;
  background: rgba(0,0,0,0.46);
  color: white;
  pointer-events: none;
}
.match-roster-title {
  color: #9edaff;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
}
.match-roster-rows { display: grid; gap: 6px; }
.roster-pilot {
  display: grid;
  gap: 3px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.roster-pilot:first-child { padding-top: 0; border-top: 0; }
.roster-pilot.local {
  padding: 6px;
  border: 1px solid rgba(142, 218, 255, 0.28);
  border-radius: 8px;
  background: rgba(86, 197, 255, 0.08);
}
.roster-pilot.opponent {
  padding-left: 6px;
  border-left: 2px solid rgba(93, 226, 156, 0.42);
}
.roster-pilot-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.66rem; font-weight: 900; }
.roster-pilot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-pilot-kills { color: #ffd56a; flex: 0 0 auto; }
.roster-health-track { height: 5px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.13); }
.roster-health-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ee5f69, #f6c459 42%, #5de29c); transition: width 100ms linear; }
.roster-pilot.opponent .roster-health-track { width: 50%; }
.roster-pilot.opponent .roster-health-track span { background: linear-gradient(90deg, #39d777, #8cffad); }

.event-panel { min-height: 150px; }
.event-log { max-height: 184px; overflow: auto; }
.event-line {
  margin: 0;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #9fb3c7;
  font-size: 0.7rem;
  line-height: 1.35;
}
.muted { margin: 0; color: #7d91a6; font-size: 0.78rem; }

#rotateDeviceOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(0,0,0,0.94);
}
.rotate-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 290px;
  padding: 24px 20px;
  border: 2px solid rgba(255,255,255,0.74);
  border-radius: 18px;
  background: rgba(255,255,255,0.08);
}
.rotate-icon { font-size: 54px; line-height: 1; }
.rotate-card span { color: #b9c9d9; font-size: 0.86rem; }

@media (max-width: 1120px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .event-panel { grid-column: 1 / -1; }
}

@media (pointer: coarse) {
  html, body { overflow: hidden; touch-action: none; }
  .shell { width: 100%; height: 100vh; padding: 0; }
  .topbar, .stats, .arena-header, .side-panel { display: none; }
  .game-layout, .arena-card { width: 100%; height: 100%; display: block; border: 0; border-radius: 0; }
  .arena { width: 100vw; height: 100vh; min-height: 0; }
  .desktop-help { display: none; }
  .desktop-arena-control, .mobile-arena-control { display: none; }

  .camera-controls {
    top: max(7px, env(safe-area-inset-top));
    right: 53px;
    width: 104px;
    padding: 5px;
    gap: 3px;
    border-radius: 7px;
    font-size: 0.54rem;
  }
  .camera-controls input[type="range"] { height: 9px; }
  .camera-controls .hud-end-match {
    min-height: 24px;
    padding: 4px 6px;
    font-size: 0.48rem;
  }
  .weapon-select {
    position: absolute;
    z-index: 17;
    top: auto;
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 62px);
    right: max(8px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px;
    border-radius: 9px;
    background: rgba(0,0,0,0.42);
  }
  .weapon-select-button { width: 32px; height: 32px; font-size: 0.72rem; border-width: 1px; }
  .fullscreen-btn { width: 39px; height: 39px; font-size: 19px; }

  .match-roster-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(9px, env(safe-area-inset-left));
    min-width: 168px;
    max-width: 220px;
    padding: 7px 8px;
    border-radius: 9px;
    font-size: 0.56rem;
  }
  .hud-meter-row {
    display: grid;
    grid-template-columns: 48px minmax(105px, 152px) 39px;
    align-items: center;
    gap: 6px;
  }
  .mobile-health-track,
  .mobile-boost-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
  }
  .mobile-health-track i,
  .mobile-boost-track i {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    transition: width 100ms linear;
  }
  .mobile-health-track i { background: linear-gradient(90deg, #45dd8a, #a8f06a); }
  .mobile-health-track i.critical { background: linear-gradient(90deg, #ff3c52, #ff8b62); }
  .mobile-boost-track i {
    background: linear-gradient(90deg, #c99b00, #ffe34f 55%, #fff4a6);
    box-shadow: 0 0 8px rgba(255, 220, 58, 0.65);
  }
  .boost-meter-row.active { color: #fff3a0; }
  .boost-meter-row.active .mobile-boost-track i {
    animation: boostPulse 420ms ease-in-out infinite alternate;
  }
  @keyframes boostPulse {
    from { filter: brightness(1); box-shadow: 0 0 8px rgba(255, 220, 58, 0.65); }
    to { filter: brightness(1.45); box-shadow: 0 0 15px rgba(255, 236, 105, 0.95); }
  }
  .mobile-health-hud strong { text-align: right; font-size: 0.66rem; }
  .assist-meter-row input[type="range"] { height: 16px; }

  .mobile-controls {
    position: absolute;
    z-index: 14;
    inset: 0;
    display: block;
    pointer-events: none;
  }

  .steer-pad,
  .mini-fire,
  .throttle-button {
    position: absolute;
    pointer-events: auto;
    color: white;
    touch-action: none;
    user-select: none;
  }

  .steer-pad {
    width: 94px;
    height: 94px;
    bottom: max(16px, env(safe-area-inset-bottom));
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.88);
    background: rgba(255,255,255,0.12);
    font-size: 34px;
    font-weight: 900;
  }
  .left-pad { left: 16px; }
  .right-pad { right: 16px; }
  .steer-pad.pressed { background: rgba(74, 177, 235, 0.3); transform: scale(0.98); }
  .steer-pad.boost-requested { border-color: rgba(255, 198, 77, 0.96); }
  .steer-pad.boosting {
    background: rgba(255, 96, 31, 0.38);
    box-shadow: 0 0 22px rgba(255, 92, 24, 0.82), inset 0 0 18px rgba(255,232,180,0.18);
  }
  .steer-pad.boost-locked {
    border-color: rgba(146, 127, 62, 0.76);
    box-shadow: none;
    filter: saturate(0.45);
  }

  .mini-fire {
    width: 46px;
    height: 46px;
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 24px);
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(220, 32, 32, 0.92);
    font-size: 19px;
    font-weight: 900;
  }
  .left-fire { left: 124px; }
  .right-fire { right: 124px; }
  .mini-fire.pressed { transform: scale(0.92); box-shadow: 0 0 18px rgba(255,80,80,0.9); }

  .radar-cluster {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 66px;
    height: 66px;
    transform: translateX(-50%);
    pointer-events: none;
  }
  .radar-hud {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid rgba(148, 255, 225, 0.88);
    background: radial-gradient(circle at 50% 50%, rgba(0, 84, 74, 0.28), rgba(0, 18, 24, 0.92) 68%);
    box-shadow: 0 0 18px rgba(35, 222, 178, 0.24), inset 0 0 22px rgba(9, 122, 108, 0.16);
    overflow: hidden;
  }
  .radar-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    image-rendering: auto;
    display: block;
    border-radius: 50%;
  }
  .radar-caption {
    position: absolute;
    left: 50%;
    bottom: 2px;
    transform: translateX(-50%);
    font-size: 0.38rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    color: rgba(181, 255, 229, 0.94);
    text-shadow: 0 0 8px rgba(80, 255, 212, 0.52);
  }

  .crosshair { top: 45%; }
}

@media (orientation: portrait) and (pointer: coarse) {
  #rotateDeviceOverlay { display: flex; }
}

@media (pointer: fine) {
  .fullscreen-btn { display: none; }
}

.mobile-controls.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.arena-select-button {
  min-width: 148px;
  padding: 12px 15px;
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(82, 181, 244, 0.34), rgba(17, 56, 93, 0.78));
  color: white;
  font-weight: 900;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.arena-select-button.sphere {
  background: radial-gradient(circle at 30% 24%, rgba(255, 223, 125, 0.72), rgba(90, 184, 255, 0.38) 42%, rgba(19, 48, 94, 0.88) 100%);
}

.arena-select-button.corridor1 {
  background: linear-gradient(135deg, rgba(255, 211, 106, 0.38), rgba(77, 169, 255, 0.42) 46%, rgba(11, 27, 50, 0.9));
}

.arena-select-button.ocean {
  background: linear-gradient(135deg, rgba(67, 205, 255, 0.58), rgba(11, 102, 164, 0.82) 54%, rgba(3, 27, 58, 0.94));
}

.arena-select-button.approve { background: linear-gradient(180deg, rgba(91, 225, 146, 0.52), rgba(10, 78, 52, 0.9)); }
.arena-select-button.decline { background: linear-gradient(180deg, rgba(255, 103, 120, 0.5), rgba(89, 16, 35, 0.9)); }

.hud-popup {
  position: absolute;
  z-index: 26;
  left: 50%;
  top: 18%;
  max-width: min(520px, calc(100% - 36px));
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.68);
  border-radius: 999px;
  background: rgba(1, 7, 14, 0.76);
  color: #fff4bc;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 172, 67, 0.72);
  box-shadow: 0 0 24px rgba(255, 156, 52, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px) scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease;
}

.hud-popup.visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (pointer: coarse) {
  .weapon-select {
    top: 50%;
    right: max(14px, env(safe-area-inset-right));
    bottom: auto;
    transform: translateY(-50%);
    gap: 8px;
    padding: 6px;
  }

  .weapon-select-button {
    width: 38px;
    height: 38px;
    font-size: 0.82rem;
  }

  .hud-popup {
    top: 15%;
    font-size: 0.74rem;
  }
}

@media (max-width: 760px) {
  .start-card.title-card { min-height: min(92svh, 760px); }
  .game-title-image { opacity: 0.9; object-position: center; object-fit: contain; }
  .start-control-panel {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: 50svh;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(2,7,17,0.78), rgba(2,7,17,0.58));
  }
  .start-control-panel h1 { font-size: clamp(1.35rem, 6vw, 1.9rem); }
  .start-control-panel #startCopy { font-size: 0.82rem; margin-bottom: 8px; }
  .start-screen.config-mode .start-card.title-card {
    min-height: auto;
    max-height: 92svh;
  }
  .start-screen.config-mode .start-control-panel {
    width: min(520px, calc(100vw - 24px));
    max-height: 88svh;
    padding: 13px;
  }
  .start-screen.config-mode .start-actions-row { flex-direction: row; }
}

@media (max-width: 640px) {
  .config-grid { grid-template-columns: 1fr; }
  .start-actions-row, .match-choice-panel { flex-direction: column; }
  .start-action { width: 100%; }
}


/* v3.8.4 title flow and host controls */
.start-screen.title-splash-mode {
  background: #020711;
  backdrop-filter: none;
}
.start-screen.title-splash-mode .start-card.title-card {
  width: min(1180px, 100vw);
  height: min(760px, 100svh);
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: #020711;
  box-shadow: none;
}
.start-screen.title-splash-mode .game-title-image {
  display: block;
  object-fit: contain;
  opacity: 1;
}
.start-screen.title-splash-mode .start-control-panel { display: none; }

.start-screen.choice-mode {
  background: #000;
  backdrop-filter: none;
}
.start-screen.choice-mode .start-card.title-card {
  width: min(520px, 94vw);
  min-height: auto;
  max-height: min(90svh, 680px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  display: grid;
  place-items: center;
}
.start-screen.choice-mode .game-title-image { display: none; }
.start-screen.choice-mode .start-control-panel {
  position: relative;
  inset: auto;
  width: min(440px, 92vw);
  max-height: min(88svh, 640px);
  overflow: auto;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid rgba(142, 210, 255, 0.2);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.76);
  box-shadow: 0 24px 80px rgba(0,0,0,0.56);
  text-align: center;
}
.start-screen.choice-mode .start-field { text-align: left; }
.start-screen.choice-mode .match-choice-panel,
.start-screen.choice-mode .start-actions-row { justify-content: center; }
.start-screen.config-mode { background: #000; backdrop-filter: none; }
.config-actions-row { align-items: stretch; }
.config-actions-row .launch { flex: 1 1 220px; margin-top: 0; }
.config-actions-row .ghost { flex: 0 0 auto; }
.host-match-action {
  min-height: 34px;
  border: 1px solid rgba(255, 214, 120, 0.44);
  border-radius: 999px;
  padding: 7px 12px;
  background: linear-gradient(180deg, rgba(255, 164, 62, 0.22), rgba(70, 32, 9, 0.72));
  color: #ffe1a1;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.host-match-action:hover { border-color: rgba(255, 229, 162, 0.72); color: #fff4c8; }

@media (max-width: 760px) {
  .start-screen.title-splash-mode .start-card.title-card {
    width: 100vw;
    height: 100svh;
    min-height: 0;
  }
  .start-screen.choice-mode .start-control-panel {
    left: auto;
    right: auto;
    bottom: auto;
    width: min(430px, calc(100vw - 24px));
    max-height: 88svh;
  }
  .arena-header-controls { flex-wrap: wrap; }
  .host-match-action { font-size: 0.58rem; padding: 6px 9px; }
  .camera-controls .hud-end-match { font-size: 0.48rem; padding: 4px 6px; }
}
