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

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(circle at 25% 10%, rgba(0, 128, 160, 0.18), transparent 34%),
    radial-gradient(circle at 78% 68%, rgba(190, 48, 72, 0.14), transparent 28%),
    #05070c;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: #f8fbff;
  background: rgba(20, 34, 48, 0.86);
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover { background: rgba(38, 64, 84, 0.96); }
button:active { transform: translateY(1px); }
button:disabled {
  cursor: default;
  opacity: 0.72;
}

button.is-max {
  border-color: rgba(109, 240, 255, 0.52);
  color: #7df6ff;
  font-weight: 900;
}

.owner-name,
.pilot-status strong.owner-name,
.chat-message strong.owner-name,
.team-member-main strong.owner-name,
.team-invite .owner-name {
  color: #c77dff;
  text-shadow: 0 0 10px rgba(199, 125, 255, 0.45);
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  z-index: 5;
  border: 1px solid rgba(180, 220, 255, 0.18);
  border-radius: 8px;
  background: rgba(4, 10, 17, 0.72);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.config-panel {
  touch-action: none;
  overflow: auto;
  scrollbar-width: thin;
}

body.is-auth-screen .hud,
body.is-auth-screen .boss-hud,
body.is-auth-screen .touch-controls {
  display: none !important;
}

.panel-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  margin: -4px -4px 8px;
  padding: 2px 2px 6px;
  border-bottom: 1px solid rgba(180, 220, 255, 0.14);
  color: #c9d9e7;
  cursor: grab;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
}

.panel-chrome:active {
  cursor: grabbing;
}

.panel-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-minimize {
  display: grid;
  place-items: center;
  min-width: 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 6px;
  line-height: 1;
  font-size: 16px;
}

.panel-resize {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 3;
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(109, 240, 255, 0.34) 50% 58%, transparent 58%),
    linear-gradient(135deg, transparent 0 64%, rgba(238, 245, 255, 0.48) 64% 70%, transparent 70%);
  box-shadow: none;
  cursor: nwse-resize;
  touch-action: none;
}

.panel-resize:hover {
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(109, 240, 255, 0.58) 50% 58%, transparent 58%),
    linear-gradient(135deg, transparent 0 64%, rgba(238, 245, 255, 0.7) 64% 70%, transparent 70%);
}

.panel-resize:active {
  transform: none;
}

.top-right .panel-chrome {
  grid-column: 1 / -1;
}

.bottom-right .panel-chrome {
  flex: 0 0 100%;
  width: 100%;
}

.config-panel.is-dragging {
  z-index: 18;
}

.config-panel.is-resizing {
  z-index: 18;
}

.config-panel.is-minimized {
  width: max-content !important;
  height: auto !important;
  min-width: 118px !important;
  padding: 8px 10px !important;
  overflow: hidden;
}

.config-panel.is-minimized > :not(.panel-chrome):not(.panel-resize) {
  display: none !important;
}

.config-panel.is-minimized .panel-resize {
  display: none !important;
}

.config-panel.is-minimized .panel-chrome {
  margin: 0;
  padding: 0;
  border-bottom: 0;
}

.top-left {
  left: 16px;
  top: 16px;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
}

.pilot-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
  color: #bcd0df;
  font-size: 13px;
}

.pilot-status strong {
  overflow: hidden;
  max-width: 190px;
  color: #f4fbff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(180, 220, 255, 0.14);
  font-size: 13px;
}

.skill-grid div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: #bcd0df;
}

.skill-grid strong {
  color: #f4fbff;
}

.skill-grid strong.is-max {
  color: #7df6ff;
}

.top-right {
  right: 16px;
  top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 12px 14px;
  width: 160px;
  font-size: 14px;
}

.top-right div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.boss-hud {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 16px;
  width: min(460px, calc(100vw - 680px));
  min-width: 280px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 207, 90, 0.34);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(4, 10, 17, 0.78);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.boss-hud.hidden {
  display: none;
}

.boss-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.boss-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.boss-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff395f, #ffcf5a);
}

.bottom-left {
  left: 16px;
  bottom: 16px;
  width: min(390px, calc(100vw - 32px));
  padding: 12px 14px;
  display: grid;
  gap: 3px;
}

.bottom-left span {
  color: #bcd0df;
  font-size: 14px;
}

.chat-panel {
  left: 16px;
  bottom: 104px;
  z-index: 12;
  width: min(390px, calc(100vw - 32px));
  padding: 10px;
  touch-action: pan-y;
}

.chat-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-tabs button {
  min-height: 30px;
  padding-inline: 8px;
  font-size: 12px;
}

.chat-tabs button.is-active {
  border-color: rgba(109, 240, 255, 0.72);
  background: rgba(18, 76, 94, 0.92);
}

.chat-messages {
  height: 150px;
  min-height: 82px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgba(180, 220, 255, 0.14);
  border-radius: 6px;
  background: rgba(1, 7, 12, 0.52);
  font-size: 12px;
  scrollbar-color: rgba(109, 240, 255, 0.52) rgba(1, 7, 12, 0.52);
  scrollbar-width: thin;
  user-select: text;
}

.team-vitals-panel {
  right: 16px;
  top: 312px;
  z-index: 11;
  width: min(320px, calc(100vw - 32px));
  max-height: min(330px, 42vh);
  overflow-y: auto;
  padding: 10px;
  touch-action: pan-y;
}

.team-vitals-panel.hidden {
  display: none;
}

.team-vitals-members {
  gap: 6px;
}

.chat-messages::-webkit-scrollbar {
  width: 9px;
}

.chat-messages::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(1, 7, 12, 0.52);
}

.chat-messages::-webkit-scrollbar-thumb {
  border: 2px solid rgba(1, 7, 12, 0.52);
  border-radius: 999px;
  background: rgba(109, 240, 255, 0.52);
}

.chat-message {
  display: grid;
  gap: 2px;
  color: #dcecff;
  overflow-wrap: anywhere;
}

.chat-message strong {
  color: #7df6ff;
  font-size: 11px;
}

.chat-message.is-private strong {
  color: #ffcf5a;
}

.chat-message.is-own {
  color: #f8fbff;
}

.chat-private-row {
  margin-top: 8px;
}

.chat-private-row.hidden {
  display: none;
}

.chat-private-row select,
.chat-form input {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: #f8fbff;
  background: rgba(20, 34, 48, 0.86);
  font: inherit;
}

.chat-private-row select {
  padding-inline: 8px;
}

.team-panel {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(180, 220, 255, 0.14);
  border-radius: 6px;
  background: rgba(1, 7, 12, 0.38);
  font-size: 12px;
}

.team-header,
.team-row,
.team-invite,
.team-member {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-header {
  justify-content: space-between;
  color: #f4fbff;
  font-weight: 900;
  text-transform: uppercase;
}

.team-row {
  display: grid;
  grid-template-columns: 1fr auto;
}

.team-row select {
  min-width: 0;
}

.team-row select,
.team-panel button {
  min-height: 28px;
  font-size: 12px;
}

.team-row select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding-inline: 8px;
  color: #f8fbff;
  background: rgba(20, 34, 48, 0.86);
}

.team-invites {
  display: grid;
  gap: 5px;
}

.team-invite {
  justify-content: space-between;
  color: #ffcf5a;
}

.team-members {
  display: grid;
  gap: 4px;
  color: #bcd0df;
}

.team-member {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(120px, 1.15fr);
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.team-member-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.team-member-main strong {
  overflow: hidden;
  color: #7df6ff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-member-main span {
  color: #bcd0df;
}

.team-member-vitals {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.team-vital-line {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: #bcd0df;
  font-size: 10px;
  line-height: 1;
}

.team-vital-line strong {
  overflow: hidden;
  color: #f4fbff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-vital-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.team-vital-bar span {
  display: block;
  height: 100%;
}

.team-vital-bar.hp span {
  background: linear-gradient(90deg, #ff395f, #ffb04f);
}

.team-vital-bar.shield span {
  background: linear-gradient(90deg, #39c8ff, #6dffbe);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-top: 8px;
}

.chat-form input {
  padding-inline: 10px;
  min-width: 0;
  user-select: text;
}

.chat-form button {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 12px;
}

.bottom-right {
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px;
  max-width: min(390px, calc(100vw - 32px));
}

.bottom-right button {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 12px;
}

.ammo-hotbar {
  left: 50%;
  bottom: 76px;
  width: min(560px, calc(100vw - 32px));
  padding: 7px;
  transform: translateX(-50%);
}

.ammo-hotbar .panel-chrome {
  margin-bottom: 6px;
}

.ammo-hotbar-slots {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}

.ammo-hotbar-slot {
  display: grid;
  grid-template-rows: auto 1fr auto;
  place-items: center;
  gap: 1px;
  min-width: 0;
  min-height: 46px;
  padding: 4px 3px;
  border-color: rgba(180, 220, 255, 0.18);
  background: rgba(9, 18, 30, 0.82);
  font-size: 11px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.ammo-hotbar-slot span,
.ammo-hotbar-slot small {
  color: #9fb6c8;
  font-size: 10px;
}

.ammo-hotbar-slot strong {
  max-width: 100%;
  overflow: hidden;
  color: #f4fbff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ammo-hotbar-slot.is-active {
  border-color: rgba(109, 240, 255, 0.82);
  background: rgba(16, 82, 96, 0.88);
  box-shadow: inset 0 0 18px rgba(109, 240, 255, 0.12);
}

.ammo-hotbar-slot.is-dragging {
  opacity: 0.78;
  transform: translateY(-2px);
  cursor: grabbing;
  border-color: rgba(125, 255, 158, 0.72);
}

.ammo-hotbar-slot.is-empty,
.ammo-hotbar-slot.is-empty-stock {
  opacity: 0.62;
}

.ammo-hotbar-config {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(180, 220, 255, 0.14);
  border-radius: 8px;
  background: rgba(9, 18, 30, 0.46);
}

.ammo-slot-config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.ammo-slot-config {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.ammo-slot-config span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 28px;
  border: 1px solid rgba(180, 220, 255, 0.18);
  border-radius: 6px;
  color: #7df6ff;
  font-size: 12px;
  font-weight: 900;
}

.ammo-slot-config select {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(180, 220, 255, 0.22);
  border-radius: 6px;
  color: #eef5ff;
  background: rgba(16, 28, 42, 0.94);
  font-weight: 700;
}

.galaxy-panel {
  right: 16px;
  top: 276px;
  width: min(320px, calc(100vw - 32px));
  padding: 12px;
}

.galaxy-panel.hidden {
  display: none;
}

.galaxy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.galaxy-header button {
  min-height: 30px;
  padding-inline: 10px;
  font-size: 12px;
}

.galaxy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sector-card {
  display: grid;
  gap: 3px;
  min-height: 74px;
  padding: 10px;
  border: 1px solid rgba(180, 220, 255, 0.18);
  border-radius: 8px;
  color: #c7d7e5;
  background: rgba(9, 18, 30, 0.78);
  text-align: left;
}

.sector-card.is-active {
  border-color: rgba(109, 240, 255, 0.78);
  background: rgba(16, 56, 78, 0.82);
  box-shadow: inset 0 0 0 1px rgba(109, 240, 255, 0.22);
}

.sector-card strong {
  color: #f4fbff;
  font-size: 16px;
}

.sector-card span {
  font-size: 12px;
}

.base-mission-panel {
  z-index: 12;
  right: 16px;
  top: 276px;
  width: min(390px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 170px));
  padding: 12px;
  touch-action: pan-y;
}

.base-mission-panel.hidden {
  display: none;
}

.base-mission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.base-mission-header button {
  min-height: 30px;
  padding-inline: 10px;
  font-size: 12px;
}

.base-mission-status {
  margin-bottom: 10px;
  color: #bcd0df;
  font-size: 13px;
}

.base-page-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.base-page-tabs button {
  min-height: 30px;
  padding-inline: 6px;
  font-size: 12px;
}

.base-page-tabs button.is-active {
  border-color: rgba(109, 240, 255, 0.72);
  background: rgba(18, 76, 94, 0.92);
}

.base-mission-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-right: 2px;
}

.base-list-header {
  margin-top: 4px;
  color: #f4fbff;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.base-shop {
  display: grid;
  gap: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(180, 220, 255, 0.14);
}

.base-shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #f4fbff;
  font-size: 13px;
}

.base-shop-header span {
  color: #7df6ff;
  font-size: 12px;
  font-weight: 800;
}

.base-shop-grid {
  display: grid;
  gap: 7px;
}

.ammo-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(180, 220, 255, 0.18);
  border-radius: 8px;
  background: rgba(9, 18, 30, 0.78);
}

.ammo-card.is-selected {
  border-color: rgba(109, 240, 255, 0.72);
  background: rgba(16, 56, 78, 0.82);
}

.ammo-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ammo-info strong {
  color: #f4fbff;
}

.ammo-info span {
  color: #bcd0df;
  font-size: 12px;
}

.ammo-actions {
  display: grid;
  gap: 5px;
  min-width: 82px;
}

.ammo-actions button {
  min-height: 28px;
  padding-inline: 8px;
  font-size: 12px;
}

.mission-card {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(180, 220, 255, 0.18);
  border-radius: 8px;
  background: rgba(9, 18, 30, 0.78);
}

.mission-card.is-active {
  border-color: rgba(109, 240, 255, 0.78);
  background: rgba(16, 56, 78, 0.82);
}

.mission-card.is-complete {
  border-color: rgba(125, 255, 158, 0.72);
}

.mission-card.is-locked {
  opacity: 0.58;
  border-color: rgba(180, 220, 255, 0.1);
}

.mission-card strong {
  color: #f4fbff;
}

.mission-card span {
  color: #bcd0df;
  font-size: 12px;
}

.mission-card button {
  justify-self: end;
  min-height: 30px;
  padding-inline: 10px;
  font-size: 12px;
}

.admin-panel {
  z-index: 13;
  left: 16px;
  top: 286px;
  display: grid;
  gap: 8px;
  width: min(300px, calc(100vw - 32px));
  padding: 10px;
}

.admin-panel.hidden {
  display: none;
}

.admin-panel label {
  display: grid;
  gap: 4px;
  color: #bcd0df;
  font-size: 12px;
}

.admin-panel input {
  min-height: 32px;
  border: 1px solid rgba(180, 220, 255, 0.22);
  border-radius: 6px;
  padding: 0 9px;
  color: #f4fbff;
  background: rgba(13, 28, 42, 0.92);
}

.admin-status {
  color: #f4fbff;
  font-size: 12px;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.admin-owner-actions.hidden {
  display: none;
}

.admin-panel button {
  min-height: 32px;
  padding-inline: 8px;
  font-size: 12px;
}

.brand {
  margin-bottom: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.bars {
  display: grid;
  gap: 5px;
}

.bars label {
  display: flex;
  justify-content: space-between;
  color: #d8e8f5;
  font-size: 13px;
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff395f, #ffb04f);
}

.bar.shield span {
  background: linear-gradient(90deg, #39c8ff, #6dffbe);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.28);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(520px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 24px;
  background: rgba(5, 11, 18, 0.86);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

.panel h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 7vw, 58px);
  line-height: 1;
}

.account-window.hidden,
.account-window[hidden] {
  display: none;
}

.pilot-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  color: #d8e8f5;
  font-weight: 800;
}

.pilot-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  padding: 0 12px;
  color: #f8fbff;
  background: rgba(20, 34, 48, 0.86);
  font: inherit;
  touch-action: manipulation;
  user-select: text;
}

.pilot-row input:focus {
  outline: 2px solid rgba(109, 240, 255, 0.45);
  outline-offset: 2px;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-actions button {
  min-height: 46px;
}

.account-message {
  margin-top: 12px;
  min-height: 38px;
  border: 1px solid rgba(255, 110, 100, 0.44);
  border-radius: 6px;
  padding: 9px 11px;
  color: #ffe1dc;
  background: rgba(95, 20, 24, 0.48);
  font-size: 13px;
  font-weight: 800;
}

.account-message.is-hidden {
  display: none;
}

#startBtn {
  background: #e64d46;
}

#registerBtn {
  background: rgba(23, 69, 72, 0.92);
}

#registerConfirmBtn {
  background: #e64d46;
}

#registerBackBtn {
  background: rgba(20, 34, 48, 0.86);
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(238, 245, 255, 0.92);
  color: #09111c;
  font-weight: 800;
}

.toast.hidden { display: none; }

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  height: 140px;
  padding: 0 max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.touch-stick {
  position: relative;
  width: 104px;
  height: 104px;
  border: 1px solid rgba(180, 220, 255, 0.28);
  border-radius: 50%;
  background: rgba(4, 10, 17, 0.48);
  box-shadow: inset 0 0 26px rgba(109, 240, 255, 0.12), 0 14px 40px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(109, 240, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 24px rgba(109, 240, 255, 0.32);
}

.touch-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.touch-actions button {
  border-radius: 999px;
  padding: 0;
  touch-action: none;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}

.touch-fire {
  width: 92px;
  height: 92px;
  background: rgba(230, 77, 70, 0.86);
}

.touch-boost {
  width: 70px;
  height: 70px;
  background: rgba(41, 90, 126, 0.86);
  font-size: 12px;
}

.touch-actions button.is-down,
.touch-stick.is-down {
  filter: brightness(1.25);
}

@media (max-width: 720px) {
  .hud {
    border-radius: 6px;
  }

  .panel-chrome {
    min-height: 28px;
    margin-bottom: 6px;
    font-size: 10px;
  }

  .top-left {
    left: 8px;
    top: 8px;
    width: min(220px, calc(100vw - 16px));
    padding: 10px;
  }

  .top-right {
    top: 96px;
    right: 8px;
    bottom: auto;
    grid-template-columns: 1fr;
    gap: 5px;
    width: 132px;
    padding: 8px;
    font-size: 12px;
  }

  .boss-hud {
    left: 8px;
    right: 8px;
    top: 205px;
    width: auto;
    min-width: 0;
    transform: none;
    padding: 8px;
  }

  .bottom-right {
    left: 8px;
    right: 8px;
    bottom: calc(126px + env(safe-area-inset-bottom));
    justify-content: stretch;
    gap: 5px;
    padding: 5px;
    max-width: none;
  }

  .bottom-right button {
    flex: 1;
    min-width: 64px;
    min-height: 30px;
    padding-inline: 5px;
    font-size: 11px;
  }

  .ammo-hotbar {
    left: 8px;
    right: 8px;
    bottom: calc(188px + env(safe-area-inset-bottom));
    width: auto;
    padding: 5px;
    transform: none;
  }

  .ammo-hotbar-slots {
    gap: 3px;
  }

  .ammo-hotbar-slot {
    min-height: 40px;
    padding: 3px 1px;
    font-size: 10px;
  }

  .ammo-hotbar-slot span,
  .ammo-hotbar-slot small {
    font-size: 9px;
  }

  .bottom-left {
    display: none;
  }

  .chat-panel {
    left: 8px;
    right: 8px;
    bottom: calc(244px + env(safe-area-inset-bottom));
    width: auto;
    padding: 8px;
  }

  .team-vitals-panel {
    left: auto;
    right: 8px;
    top: 252px;
    width: min(300px, calc(100vw - 16px));
    max-height: 30vh;
    padding: 8px;
  }

  .chat-messages {
    height: 104px;
  }

  .chat-form {
    grid-template-columns: 1fr 72px;
  }

  .galaxy-panel {
    left: 8px;
    right: 8px;
    top: 178px;
    width: auto;
    padding: 9px;
  }

  .base-mission-panel {
    left: 8px;
    right: 8px;
    top: 178px;
    width: auto;
    max-height: calc(100vh - 312px);
    padding: 9px;
  }

  .base-mission-list {
    max-height: calc(100vh - 420px);
  }

  .ammo-card {
    grid-template-columns: 1fr;
  }

  .ammo-actions {
    grid-template-columns: 1fr 1fr;
  }

  .ammo-slot-config-grid {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    left: 8px;
    right: 8px;
    top: 178px;
    width: auto;
    padding: 9px;
  }

  .brand {
    margin-bottom: 7px;
    font-size: 13px;
  }

  .bars label {
    font-size: 12px;
  }

  .bar {
    height: 8px;
  }

  .panel {
    padding: 18px;
  }

}

@media (max-width: 720px), (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}
