:root {
  color-scheme: dark;
  --ink: #f4f7ef;
  --muted: #9aa69a;
  --panel: rgba(14, 16, 14, 0.74);
  --panel-strong: rgba(22, 25, 21, 0.94);
  --line: rgba(244, 247, 239, 0.18);
  --green: #80f05b;
  --cyan: #42d9c8;
  --red: #ff5964;
  --amber: #f0c64d;
  --pink: #f06c9b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(128, 240, 91, 0.09), transparent 26%),
    radial-gradient(circle at 80% 80%, rgba(66, 217, 200, 0.08), transparent 24%),
    #060706;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
  color: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.74);
  color: var(--ink);
  font: inherit;
  padding: 10px;
}

#game {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background:
    radial-gradient(circle at center, rgba(8, 10, 8, 0.9), rgba(6, 7, 6, 1)),
    #060706;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.orientation-gate {
  display: none;
}

.auth-panel {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.is-playing .auth-panel,
.is-playing .resource-panel,
.is-playing .legal-corner-button {
  display: none !important;
}

.login-button,
.icon-text-button,
.settings-button,
.topbar-settings-button,
.settings-reset-button,
.keybind-button {
  border: 1px solid rgba(244, 247, 239, 0.2);
  border-radius: 8px;
  background: rgba(10, 12, 10, 0.78);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 9px 11px;
  backdrop-filter: blur(10px);
}

.login-button {
  min-width: 124px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.settings-button {
  min-width: 96px;
  padding: 9px 11px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.profile-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: min(310px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 12, 10, 0.82);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  text-align: left;
}

.profile-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(128, 240, 91, 0.92), rgba(66, 217, 200, 0.72));
  color: #061006;
  font-weight: 900;
}

.profile-card strong,
.profile-card span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card strong {
  font-size: 13px;
}

.profile-card span {
  color: var(--muted);
  font-size: 11px;
}

.profile-progress {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
}

.profile-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-progress-row b {
  color: var(--green);
  font-size: 11px;
  font-weight: 950;
}

.profile-card .profile-progress-row span {
  font-size: 10px;
}

.profile-xp-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(128, 240, 91, 0.22);
  border-radius: 999px;
  background: rgba(6, 7, 6, 0.72);
}

.profile-xp-track span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  box-shadow: 0 0 12px rgba(128, 240, 91, 0.32);
  transition: width 160ms ease;
}

.resource-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  pointer-events: auto;
}

.resource-card {
  min-width: 132px;
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(183, 237, 255, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(183, 237, 255, 0.18), rgba(66, 217, 200, 0.08)),
    rgba(10, 12, 10, 0.82);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  text-align: right;
}

.platinum-icon {
  position: relative;
  width: 30px;
  height: 30px;
  display: block;
  filter: drop-shadow(0 0 9px rgba(238, 249, 255, 0.45));
}

.platinum-icon::before,
.platinum-icon::after {
  content: "";
  position: absolute;
  inset: 2px 10px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 3px;
  background:
    linear-gradient(135deg, #ffffff 0%, #b8c9d2 42%, #f2fbff 68%, #8fa5b0 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 12px rgba(183, 237, 255, 0.38);
}

.platinum-icon::after {
  transform: rotate(90deg);
}

.resource-card b {
  display: block;
  color: #eef9ff;
  font-size: 28px;
  line-height: 0.95;
  font-weight: 950;
}

.icon-text-button {
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-settings-button {
  margin-left: 8px;
  padding: 5px 8px;
  color: var(--green);
  font-size: 12px;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.52);
  pointer-events: auto;
}

.settings-card {
  width: min(620px, calc(100vw - 36px));
  max-height: min(720px, calc(100svh - 36px));
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 25, 21, 0.98), rgba(9, 11, 9, 0.96)),
    var(--panel-strong);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.52);
}

.settings-head,
.settings-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-head h2,
.settings-section-title h3,
.settings-section-title p {
  margin: 0;
}

.settings-head h2 {
  font-size: 20px;
}

.settings-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding-right: 4px;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(244, 247, 239, 0.13);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.46);
}

.settings-section-title h3 {
  color: var(--green);
  font-size: 15px;
}

.settings-section-title p {
  color: var(--muted);
  font-size: 12px;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(244, 247, 239, 0.1);
  border-radius: 8px;
  background: rgba(12, 16, 16, 0.72);
  font-weight: 800;
}

.settings-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.keybind-list {
  display: grid;
  gap: 8px;
}

.keybind-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(108px, auto);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(244, 247, 239, 0.1);
  border-radius: 8px;
  background: rgba(12, 16, 16, 0.72);
}

.keybind-label {
  min-width: 0;
  font-weight: 800;
}

.keybind-button {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
}

.keybind-button.listening {
  border-color: rgba(240, 198, 77, 0.8);
  color: var(--amber);
}

.settings-reset-button {
  min-height: 38px;
  color: var(--muted);
  font-weight: 900;
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.48);
  pointer-events: auto;
}

.menu-modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.48);
  pointer-events: auto;
}

.menu-modal-card {
  width: min(560px, calc(100vw - 36px));
  min-height: 360px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 25, 21, 0.98), rgba(9, 11, 9, 0.96)),
    var(--panel-strong);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.52);
}

.menu-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.menu-modal-empty {
  min-height: 280px;
  margin-top: 14px;
  border: 1px dashed rgba(244, 247, 239, 0.16);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.36);
}

.shop-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.shop-card {
  min-height: 230px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 9px;
  padding: 13px;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--item-color), transparent 78%), transparent 34%),
    rgba(6, 7, 6, 0.56);
}

.shop-card.unavailable {
  filter: grayscale(1);
  opacity: 0.52;
}

.shop-card h3,
.shop-card p {
  margin: 0;
}

.shop-card h3 {
  font-size: 15px;
  line-height: 1.1;
}

.shop-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.shop-meta {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.shop-buy-button {
  min-height: 40px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  border-radius: 8px;
  color: #141712;
  background: linear-gradient(180deg, #f4f7ef, #9fb9a2);
  font-weight: 1000;
  cursor: pointer;
}

.shop-buy-button:disabled {
  cursor: not-allowed;
  color: rgba(244, 247, 239, 0.42);
  background: rgba(244, 247, 239, 0.08);
}

.shop-status {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.legal-corner-button {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 5;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(244, 247, 239, 0.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(6, 7, 6, 0.56);
  font-size: 11px;
  font-weight: 800;
  pointer-events: auto;
  cursor: pointer;
}

.legal-corner-button:hover {
  color: var(--text);
  border-color: rgba(244, 247, 239, 0.28);
}

.legal-modal-card {
  width: min(680px, calc(100vw - 36px));
  max-height: calc(100svh - 36px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.legal-copy {
  min-height: 0;
  margin-top: 14px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  padding-right: 4px;
}

.legal-copy section {
  padding: 12px;
  border: 1px solid rgba(244, 247, 239, 0.12);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.48);
}

.legal-copy h3,
.legal-copy p {
  margin: 0;
}

.legal-copy h3 {
  font-size: 16px;
}

.legal-copy p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.legal-copy a {
  color: var(--green);
  font-weight: 800;
}

.profile-modal-card {
  width: min(430px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 25, 21, 0.98), rgba(9, 11, 9, 0.96)),
    var(--panel-strong);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.52);
}

.profile-modal-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.profile-avatar-large {
  width: 48px;
  height: 48px;
}

.profile-modal h2,
.profile-modal p,
.profile-stats {
  margin: 0;
}

.profile-modal h2 {
  font-size: 20px;
}

.profile-modal p {
  color: var(--muted);
  font-size: 13px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.profile-stats div {
  padding: 10px;
  border: 1px solid rgba(244, 247, 239, 0.12);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.58);
}

.profile-stats dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.profile-stats dd {
  margin: 5px 0 0;
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

.profile-save-status {
  margin-top: 12px;
  min-height: 18px;
}

.profile-logout-button {
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(255, 89, 100, 0.42);
  border-radius: 8px;
  background: rgba(60, 16, 20, 0.72);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 10px;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 18px;
}

.start-layout {
  pointer-events: none;
  width: min(1120px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(340px, 420px) minmax(160px, 1fr);
  align-items: stretch;
  gap: 18px;
}

.start-side-panel {
  pointer-events: auto;
  min-height: 470px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(18, 21, 18, 0.82), rgba(8, 10, 8, 0.62)),
    rgba(6, 7, 6, 0.58);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
}

.default-ship-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  padding: 16px;
}

.default-ship-preview,
.default-ship-editor-shell {
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(8, 10, 8, 0.72), rgba(3, 4, 4, 0.54)),
    rgba(6, 7, 6, 0.48);
  overflow: hidden;
}

#defaultShipCanvas,
#defaultShipEditorCanvas {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  display: block;
}

#defaultShipEditorCanvas {
  max-width: 380px;
}

.default-ship-edit-button {
  min-height: 112px;
}

.default-ship-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.default-ship-modal-card {
  min-height: 430px;
  max-height: calc(100svh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.default-ship-editor-shell {
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  min-height: 330px;
  margin-top: 14px;
  padding: 14px;
  overflow: hidden;
}

.default-ship-module-palette {
  width: 100%;
  max-height: min(154px, 28svh);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding-right: 4px;
}

.default-ship-module-palette button,
.default-ship-reset-button,
.default-ship-save-button {
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.default-ship-module-palette button {
  min-height: 38px;
  border: 1px solid rgba(244, 247, 239, 0.16);
  background: rgba(15, 18, 15, 0.78);
  font-size: 12px;
}

.default-ship-module-palette button.selected {
  border-color: rgba(128, 240, 91, 0.68);
  background: linear-gradient(180deg, rgba(55, 82, 45, 0.9), rgba(24, 35, 22, 0.9));
  box-shadow: inset 0 0 0 1px rgba(128, 240, 91, 0.18);
}

.default-ship-editor-actions {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(96px, 0.35fr) minmax(0, 1fr);
  gap: 8px;
}

.default-ship-reset-button {
  min-height: 48px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  background: rgba(10, 12, 10, 0.82);
}

.default-ship-save-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(128, 240, 91, 0.46);
  background: linear-gradient(180deg, rgba(71, 112, 55, 0.92), rgba(48, 78, 39, 0.9));
}

.menu-side-panel {
  display: grid;
  grid-template-rows: repeat(3, 104px) 92px;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.main-menu-button,
.booster-row button {
  border: 1px solid rgba(244, 247, 239, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(28, 33, 28, 0.88), rgba(10, 12, 10, 0.76)),
    rgba(10, 12, 10, 0.74);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 14px 30px rgba(0, 0, 0, 0.18);
}

.main-menu-button {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 104px;
  text-align: left;
}

.main-menu-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.12), transparent 32%);
  opacity: 0.44;
  pointer-events: none;
}

.main-menu-label {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 23px;
  line-height: 1;
}

.main-menu-button:hover,
.booster-row button:hover {
  border-color: rgba(183, 237, 255, 0.54);
  background: rgba(22, 30, 30, 0.78);
}

.menu-art {
  position: absolute;
  inset: auto 12px 12px auto;
  width: 128px;
  height: 82px;
  pointer-events: none;
}

.shop-bomb {
  position: absolute;
  left: 6px;
  bottom: 4px;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 239, 198, 0.8);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.7), transparent 18%),
    linear-gradient(135deg, #363c3f, #121617 72%);
  box-shadow: 0 0 18px rgba(240, 198, 77, 0.16);
}

.shop-bomb::before {
  content: "";
  position: absolute;
  right: -4px;
  top: -8px;
  width: 15px;
  height: 12px;
  border-radius: 4px;
  background: #d4b166;
  transform: rotate(28deg);
}

.shop-bomb::after {
  content: "";
  position: absolute;
  right: -17px;
  top: -18px;
  width: 22px;
  height: 18px;
  border-top: 3px solid #f0c64d;
  border-radius: 50%;
  transform: rotate(28deg);
}

.shop-bullet {
  position: absolute;
  right: 4px;
  bottom: 13px;
  width: 58px;
  height: 14px;
  border-radius: 999px 6px 6px 999px;
  background:
    linear-gradient(90deg, #f7e5aa 0 24%, #b6803f 24% 38%, #f0c64d 38% 100%);
  transform: rotate(-18deg);
  box-shadow: 0 0 14px rgba(240, 198, 77, 0.24);
}

.shop-bullet::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 0;
  border-left: 16px solid #fff2c4;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

.shop-weapon {
  position: absolute;
  right: 18px;
  top: 14px;
  width: 78px;
  height: 16px;
  border-radius: 5px;
  background: linear-gradient(90deg, #1c2428, #6a7680 48%, #d4dde2 100%);
  transform: rotate(13deg);
}

.shop-weapon::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 13px;
  width: 22px;
  height: 22px;
  border: 5px solid #222a2e;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.shop-weapon::after {
  content: "";
  position: absolute;
  left: -18px;
  top: 3px;
  width: 20px;
  height: 10px;
  border-radius: 5px 0 0 5px;
  background: #151b1e;
}

.paint-can {
  position: absolute;
  left: 10px;
  bottom: 6px;
  width: 42px;
  height: 48px;
  border: 2px solid rgba(244, 247, 239, 0.7);
  border-radius: 8px 8px 10px 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(135deg, #2e3942, #11161a);
}

.paint-can::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -10px;
  width: 24px;
  height: 13px;
  border: 2px solid #aebdc6;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}

.paint-can::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  height: 15px;
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(90deg, #42d9c8, #f06c9b 55%, #f0c64d);
}

.paint-swatch {
  position: absolute;
  width: 42px;
  height: 30px;
  border: 2px solid rgba(244, 247, 239, 0.44);
  border-radius: 7px;
  transform: rotate(-12deg);
}

.swatch-a {
  right: 40px;
  top: 10px;
  background: #42d9c8;
}

.swatch-b {
  right: 8px;
  top: 28px;
  background: #f06c9b;
  transform: rotate(14deg);
}

.paint-drop {
  position: absolute;
  right: 22px;
  bottom: 3px;
  width: 22px;
  height: 30px;
  border-radius: 50% 50% 52% 52%;
  background: linear-gradient(180deg, #f0c64d, #ff8c42);
  transform: rotate(18deg);
  box-shadow: 0 0 14px rgba(240, 198, 77, 0.24);
}

.inventory-crate {
  position: absolute;
  left: 10px;
  bottom: 2px;
  width: 62px;
  height: 48px;
  border: 2px solid rgba(255, 224, 102, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 224, 102, 0.2), transparent 38%),
    linear-gradient(180deg, #2b2f24, #11140f);
  box-shadow: 0 0 18px rgba(255, 224, 102, 0.18);
}

.inventory-crate::before,
.inventory-crate::after {
  content: "";
  position: absolute;
  background: rgba(255, 224, 102, 0.66);
}

.inventory-crate::before {
  left: 0;
  right: 0;
  top: 21px;
  height: 2px;
}

.inventory-crate::after {
  top: 0;
  bottom: 0;
  left: 29px;
  width: 2px;
}

.inventory-core {
  position: absolute;
  right: 14px;
  top: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #f4f7ef 0 17%, #8bd4ff 18% 34%, transparent 35%),
    conic-gradient(from 0.15turn, #8bd4ff, #ffe066, #7cff95, #8bd4ff);
  box-shadow: 0 0 18px rgba(139, 212, 255, 0.32);
}

.inventory-spark {
  position: absolute;
  width: 20px;
  height: 20px;
  transform: rotate(45deg);
  background: #7cff95;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}

.spark-a {
  right: 66px;
  bottom: 15px;
}

.spark-b {
  right: 2px;
  bottom: 8px;
  width: 14px;
  height: 14px;
  background: #ffe066;
}

.booster-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.booster-row button {
  min-height: 92px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background:
    linear-gradient(180deg, rgba(22, 26, 22, 0.9), rgba(8, 10, 8, 0.76)),
    rgba(10, 12, 10, 0.74);
}

.item-slot-row button {
  position: relative;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  overflow: hidden;
  padding: 8px 6px;
}

.item-slot-row button.active {
  border-color: rgba(128, 240, 91, 0.72);
  background:
    linear-gradient(180deg, rgba(42, 72, 40, 0.92), rgba(11, 18, 12, 0.82)),
    rgba(10, 12, 10, 0.74);
}

.item-slot-key {
  justify-self: start;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.item-slot-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--slot-glow, #d8f3ff) 0 17%, var(--slot-color, #8bd4ff) 18% 42%, transparent 43%),
    conic-gradient(var(--slot-color, #8bd4ff), #f4f7ef, var(--slot-color, #8bd4ff));
  box-shadow: 0 0 14px rgba(139, 212, 255, 0.36);
}

.item-slot-count {
  color: var(--ink);
  font-size: 12px;
  line-height: 1;
}

.item-slot-row button.empty {
  filter: grayscale(1);
  opacity: 0.5;
}

.item-slot-row button:disabled {
  cursor: not-allowed;
}

.inventory-modal-card {
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100svh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.inventory-shell {
  min-height: 0;
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.38fr);
  gap: 12px;
}

.inventory-grid {
  min-height: 260px;
  max-height: 58svh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.inventory-card {
  position: relative;
  min-height: 142px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at 70% 18%, rgba(244, 247, 239, 0.16), transparent 34%),
    linear-gradient(180deg, rgba(16, 20, 20, 0.94), rgba(8, 10, 10, 0.94));
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.inventory-card.selected,
.inventory-card.active {
  border-color: var(--item-color);
}

.inventory-card.active::after {
  content: "ACTIVE";
  position: absolute;
  right: 8px;
  top: 8px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
}

.inventory-item-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--item-glow) 0 16%, var(--item-color) 17% 42%, transparent 43%),
    conic-gradient(from 0.1turn, var(--item-color), #f4f7ef, var(--item-color));
  box-shadow: 0 0 18px rgba(139, 212, 255, 0.32);
}

.inventory-card h3,
.inventory-detail h3,
.inventory-card p,
.inventory-detail p {
  margin: 0;
}

.inventory-card h3 {
  font-size: 14px;
  line-height: 1.1;
}

.inventory-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.inventory-count {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.inventory-detail {
  min-height: 260px;
  padding: 14px;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.56);
}

.inventory-detail {
  display: grid;
  align-content: start;
  gap: 10px;
}

.inventory-detail h3 {
  font-size: 20px;
}

.inventory-detail p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.inventory-detail .inventory-item-icon {
  width: 58px;
  height: 58px;
}

.start-panel {
  pointer-events: auto;
  width: 100%;
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(26, 31, 23, 0.96), rgba(12, 14, 11, 0.92)),
    radial-gradient(circle at top left, rgba(128, 240, 91, 0.12), transparent 42%);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.start-panel h1,
.start-panel p {
  margin: 0;
}

.start-panel h1 {
  font-size: 34px;
  line-height: 1;
}

.eyebrow {
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

.start-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

#playButton {
  border: 1px solid rgba(128, 240, 91, 0.72);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(71, 112, 55, 0.92), rgba(48, 78, 39, 0.9));
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 11px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#playButton:disabled {
  cursor: wait;
  opacity: 0.62;
}

#startStatus {
  color: var(--muted);
  font-size: 13px;
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  padding: 14px;
}

.topbar,
.leaderboard,
.minimap,
.module-panel,
.actions,
.help {
  pointer-events: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(22, 25, 21, 0.92), rgba(12, 14, 11, 0.82)),
    var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.topbar strong {
  margin-right: 12px;
  letter-spacing: 0;
}

.topbar span {
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

.stats b {
  color: var(--green);
  font-weight: 700;
}

.leaderboard {
  align-self: start;
  justify-self: end;
  width: min(260px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.7);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.leaderboard h2 {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leaderboard ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.leaderboard li::before {
  content: attr(data-rank);
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(244, 247, 239, 0.1);
  color: var(--cyan);
  font-size: 12px;
}

.leaderboard li.is-self {
  color: var(--ink);
}

.leaderboard span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard b {
  color: var(--green);
  font-size: 13px;
}

.minimap {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 174px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 7, 6, 0.7);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.minimap h2 {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

#minimapCanvas {
  display: block;
  width: 152px;
  height: 152px;
  border: 1px solid rgba(244, 247, 239, 0.12);
  border-radius: 6px;
  background: rgba(6, 7, 6, 0.84);
}

.module-panel {
  display: none;
}

.module-button,
.actions button {
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(34, 39, 31, 0.96), rgba(18, 20, 17, 0.96)),
    var(--panel-strong);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.module-button:hover,
.actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(128, 240, 91, 0.48);
}

.module-button {
  position: relative;
  overflow: hidden;
  padding-left: 14px;
  background-image:
    linear-gradient(135deg, rgba(35, 41, 34, 0.96), rgba(17, 20, 17, 0.98));
}

.module-button::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--module-accent, var(--green));
  opacity: 0.92;
}

.module-button::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 247, 239, 0.18), transparent 72%);
  opacity: 0.3;
}

.module-button[data-module="engine"] {
  --module-accent: var(--green);
}

.module-button[data-module="booster"] {
  --module-accent: #ff8a30;
}

.module-button[data-module="radar"] {
  --module-accent: #f4f7ef;
}

.module-button[data-module="turret"] {
  --module-accent: var(--cyan);
}

.module-button[data-module="missile"] {
  --module-accent: var(--amber);
}

.module-button[data-module="flame"] {
  --module-accent: #ff8a42;
}

.module-button[data-module="laser"] {
  --module-accent: var(--pink);
}

.module-button[data-module="forcefield"] {
  --module-accent: #7dd8ff;
}

.module-button[data-module="drone"] {
  --module-accent: #d8e35f;
}

.module-button[data-module="weaponContainer"] {
  --module-accent: #b8c9d2;
}

.module-button.selected {
  border-color: var(--green);
  background: rgba(54, 91, 44, 0.72);
}

.module-button.locked,
.default-ship-module-palette button.locked,
.builder-card.locked {
  position: relative;
  color: rgba(244, 247, 239, 0.58);
  filter: grayscale(1);
}

.module-button.locked::after,
.default-ship-module-palette button.locked::after,
.builder-card.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    rgba(244, 247, 239, 0.08) 0 8px,
    rgba(8, 10, 8, 0.22) 8px 16px
  );
}

.module-button span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 6px;
  border-radius: 8px;
  background: rgba(244, 247, 239, 0.12);
  color: var(--cyan);
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.actions {
  display: none;
  justify-self: center;
  gap: 8px;
}

.actions button {
  min-width: 104px;
  text-align: center;
}

.actions button.active {
  border-color: var(--amber);
  background: rgba(116, 87, 21, 0.72);
}

.help {
  display: none;
}

.builder-toggle {
  position: fixed;
  left: 0;
  top: 18%;
  z-index: 24;
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  width: 108px;
  height: 188px;
  padding: 18px 8px 14px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(15, 18, 16, 0.92);
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
}

.builder-toggle:not(.hidden),
.base-action-rail:not(.hidden),
.ship-builder-panel.open .builder-close {
  animation: builder-control-glow 560ms ease-out;
}

.builder-toggle:hover {
  border-color: rgba(128, 240, 91, 0.52);
}

.base-action-rail {
  position: fixed;
  left: 0;
  top: calc(18% + 204px);
  z-index: 24;
  display: grid;
  gap: 16px;
  width: 108px;
  pointer-events: auto;
  transition: left 180ms ease;
}

body.builder-panel-open .base-action-rail {
  left: min(390px, calc(100vw - 74px));
}

.base-action-button {
  position: relative;
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  width: 108px;
  height: 104px;
  padding: 12px 8px 10px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(7, 9, 9, 0.94);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.base-action-button:hover:not(:disabled) {
  border-color: rgba(128, 240, 91, 0.52);
}

.base-action-button.unavailable {
  opacity: 0.42;
}

.base-action-svg,
.service-progress-svg {
  position: static;
  margin: auto;
  width: 50px;
  height: 50px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.base-action-svg path:first-child,
.service-progress-svg path:first-child {
  fill: currentColor;
  fill-opacity: 0.22;
}

.repair-svg {
  color: var(--green);
  stroke: var(--green);
}

.rearm-svg {
  color: var(--amber);
  stroke: var(--amber);
}

.ship-builder-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 25;
  width: min(390px, calc(100vw - 74px));
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100svh;
  padding: 18px 16px 16px;
  border-right: 1px solid rgba(244, 247, 239, 0.16);
  background: rgba(7, 9, 9, 0.94);
  box-shadow: 18px 0 52px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(16px);
  transform: translateX(-100%);
  transition: transform 180ms ease;
  pointer-events: auto;
  overflow: visible;
}

.ship-builder-panel.open {
  transform: translateX(0);
}

.builder-close {
  position: absolute;
  right: -108px;
  top: 18%;
  z-index: 1;
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  width: 108px;
  height: 188px;
  padding: 18px 8px 14px;
  border: 1px solid rgba(244, 247, 239, 0.16);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(7, 9, 9, 0.94);
  color: var(--green);
  cursor: pointer;
}

.toolbox-svg {
  width: 68px;
  height: 68px;
  fill: rgba(128, 240, 91, 0.2);
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.control-label {
  align-self: end;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.builder-toggle .control-label,
.builder-close .control-label {
  color: var(--green);
}

.base-action-button.unavailable .control-label {
  color: rgba(244, 247, 239, 0.42);
}

@keyframes builder-control-glow {
  0% {
    box-shadow: 0 0 0 rgba(128, 240, 91, 0), 0 16px 32px rgba(0, 0, 0, 0.34);
    filter: brightness(1);
  }
  38% {
    box-shadow: 0 0 24px rgba(128, 240, 91, 0.42), 0 18px 36px rgba(0, 0, 0, 0.38);
    filter: brightness(1.28);
  }
  100% {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.34);
    filter: brightness(1);
  }
}

.builder-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.builder-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0;
}

.builder-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.builder-sell,
.builder-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 24, 22, 0.96);
  color: var(--ink);
  cursor: pointer;
}

.builder-sell {
  min-width: 82px;
  height: 34px;
}

.builder-sell.active {
  border-color: var(--amber);
  color: var(--amber);
}

.builder-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-bottom: 12px;
}

.builder-tab {
  height: 38px;
  font-weight: 700;
}

.builder-tab.selected {
  border-color: var(--green);
  background: rgba(35, 58, 35, 0.92);
  color: var(--green);
}

.builder-palette {
  flex: 1 1 0;
  min-height: 0;
  min-block-size: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  gap: 10px;
  padding: 2px 4px 18px 0;
  scrollbar-gutter: stable;
}

.builder-palette::-webkit-scrollbar {
  width: 8px;
}

.builder-palette::-webkit-scrollbar-track {
  background: rgba(244, 247, 239, 0.06);
  border-radius: 999px;
}

.builder-palette::-webkit-scrollbar-thumb {
  background: rgba(128, 240, 91, 0.36);
  border-radius: 999px;
}

.builder-card {
  position: relative;
  align-self: start;
  min-width: 0;
  display: grid;
  grid-template-rows: 104px minmax(56px, auto);
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background: rgba(16, 20, 20, 0.94);
  cursor: grab;
  overflow: hidden;
  text-align: left;
  touch-action: pan-y;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
}

.builder-card:hover,
.builder-card.selected {
  border-color: rgba(128, 240, 91, 0.62);
}

.builder-card:active {
  cursor: grabbing;
}

.builder-card canvas {
  display: block;
  align-self: center;
  justify-self: center;
  width: 92px;
  height: 92px;
  background: rgba(5, 7, 7, 0.88);
  pointer-events: none;
  -webkit-user-drag: none;
}

.builder-card-body {
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 56px;
  padding: 9px 9px 10px;
  background: rgba(12, 16, 16, 0.96);
  pointer-events: none;
}

.builder-card-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.15;
}

.builder-card-price {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
}

.builder-card.locked .builder-card-price {
  white-space: normal;
}

.builder-tooltip {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  padding: 9px 10px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  border-radius: 8px;
  background: rgba(7, 9, 9, 0.94);
  color: var(--ink);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
  pointer-events: none;
  font-size: 12px;
}

.builder-tooltip b {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
  font-size: 13px;
}

.service-progress {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  width: 62px;
  height: 62px;
  transform: translateX(-50%);
  pointer-events: none;
}

.service-progress-ring {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background:
    conic-gradient(var(--green) calc(var(--progress, 0) * 1%), rgba(244, 247, 239, 0.14) 0),
    rgba(7, 9, 9, 0.9);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
}

.service-progress-ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: rgba(9, 12, 11, 0.96);
}

.service-progress-svg {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  width: 30px;
  height: 30px;
}

.service-progress[data-action="repair"] .repair-svg,
.service-progress[data-action="rearm"] .rearm-svg {
  display: block;
}

.mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  pointer-events: none;
  touch-action: none;
}

.mobile-controls.visible {
  display: block;
  pointer-events: auto;
}

.mobile-joystick {
  --stick-x: 0px;
  --stick-y: 0px;
  --stick-base-x: 0px;
  --stick-base-y: 0px;
  --stick-size: clamp(112px, 22vw, 152px);
  position: absolute;
  left: var(--stick-base-x);
  top: var(--stick-base-y);
  width: var(--stick-size);
  height: var(--stick-size);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

.mobile-joystick-base {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(244, 247, 239, 0.24);
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 50%, rgba(244, 247, 239, 0.12), transparent 38%),
    rgba(7, 9, 9, 0.28);
  box-shadow:
    inset 0 0 24px rgba(66, 217, 200, 0.12),
    0 12px 34px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(4px);
}

.mobile-joystick-base-attack {
  border-color: rgba(255, 89, 100, 0.26);
  box-shadow:
    inset 0 0 24px rgba(255, 89, 100, 0.12),
    0 12px 34px rgba(0, 0, 0, 0.18);
}

.mobile-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  height: 44%;
  border: 2px solid rgba(244, 247, 239, 0.34);
  border-radius: inherit;
  background: rgba(244, 247, 239, 0.2);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
}

.mobile-joystick-knob::before,
.mobile-joystick-knob::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}

.mobile-joystick-left .mobile-joystick-knob::before {
  width: 58%;
  height: 58%;
  background:
    linear-gradient(rgba(244, 247, 239, 0.68), rgba(244, 247, 239, 0.68)) 50% 0 / 2px 100% no-repeat,
    linear-gradient(90deg, rgba(244, 247, 239, 0.68), rgba(244, 247, 239, 0.68)) 0 50% / 100% 2px no-repeat;
}

.mobile-joystick-left .mobile-joystick-knob::after {
  width: 68%;
  height: 68%;
  background:
    conic-gradient(from 45deg, transparent 0 12.5%, rgba(244, 247, 239, 0.74) 12.5% 14.5%, transparent 14.5% 37.5%, rgba(244, 247, 239, 0.74) 37.5% 39.5%, transparent 39.5% 62.5%, rgba(244, 247, 239, 0.74) 62.5% 64.5%, transparent 64.5% 87.5%, rgba(244, 247, 239, 0.74) 87.5% 89.5%, transparent 89.5%);
  clip-path: polygon(50% 0, 58% 16%, 53% 16%, 53% 47%, 84% 47%, 84% 42%, 100% 50%, 84% 58%, 84% 53%, 53% 53%, 53% 84%, 58% 84%, 50% 100%, 42% 84%, 47% 84%, 47% 53%, 16% 53%, 16% 58%, 0 50%, 16% 42%, 16% 47%, 47% 47%, 47% 16%, 42% 16%);
}

.mobile-joystick-right .mobile-joystick-knob::before {
  width: 62%;
  height: 62%;
  border: 2px solid rgba(244, 247, 239, 0.72);
  border-radius: 50%;
}

.mobile-joystick-right .mobile-joystick-knob::after {
  width: 72%;
  height: 72%;
  background:
    linear-gradient(rgba(244, 247, 239, 0.7), rgba(244, 247, 239, 0.7)) 50% 0 / 2px 100% no-repeat,
    linear-gradient(90deg, rgba(244, 247, 239, 0.7), rgba(244, 247, 239, 0.7)) 0 50% / 100% 2px no-repeat;
  border-radius: 50%;
}

.mobile-joystick.active .mobile-joystick-base {
  background:
    radial-gradient(circle at 50% 50%, rgba(128, 240, 91, 0.18), transparent 42%),
    rgba(7, 9, 9, 0.34);
}

.mobile-joystick.active .mobile-joystick-base-attack {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 89, 100, 0.2), transparent 42%),
    rgba(7, 9, 9, 0.34);
}

.mobile-joystick.active .mobile-joystick-knob {
  background: rgba(244, 247, 239, 0.26);
}

.builder-panel-open .mobile-controls,
.mobile-controls.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

@media (pointer: coarse) and (orientation: portrait) {
  .orientation-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
      radial-gradient(circle at 50% 20%, rgba(128, 240, 91, 0.14), transparent 32%),
      rgba(6, 7, 6, 0.96);
    text-align: center;
    pointer-events: auto;
  }

  .orientation-gate div {
    display: grid;
    gap: 8px;
    max-width: 320px;
  }

  .orientation-gate strong {
    color: var(--green);
    font-size: clamp(22px, 7vw, 30px);
    line-height: 1.1;
  }

  .orientation-gate span {
    color: var(--muted);
    font-size: 14px;
  }

  .auth-panel,
  .resource-panel,
  .legal-corner-button,
  .profile-modal,
  .menu-modal,
  .start-screen,
  .hud,
  .mobile-controls {
    display: none !important;
  }
}

.help p {
  margin: 0;
}

@media (max-width: 760px) {
  .hud {
    padding: 10px;
    gap: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .leaderboard {
    width: min(220px, calc(100vw - 20px));
  }

  .minimap {
    left: 10px;
    bottom: 10px;
    width: 136px;
    padding: 8px;
  }

  #minimapCanvas {
    width: 118px;
    height: 118px;
  }

  .stats {
    flex-wrap: wrap;
    gap: 8px 12px;
  }

  .auth-panel {
    left: 10px;
    top: 10px;
    gap: 6px;
  }

  .profile-card {
    width: min(250px, calc(100vw - 112px));
  }

  .settings-button {
    min-width: 82px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .resource-panel {
    right: 10px;
    top: 10px;
  }

  .resource-card {
    min-width: 86px;
    grid-template-columns: 22px auto;
    gap: 6px;
    padding: 7px 8px;
  }

  .platinum-icon {
    width: 21px;
    height: 21px;
  }

  .platinum-icon::before,
  .platinum-icon::after {
    inset: 1px 7px;
  }

  .resource-card b {
    font-size: 21px;
  }

  .profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .default-ship-module-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inventory-shell {
    grid-template-columns: 1fr;
  }

  .inventory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shop-grid {
    grid-template-columns: 1fr;
  }

  .shop-card {
    min-height: 160px;
  }

  .legal-corner-button {
    right: 10px;
    bottom: 8px;
  }

  .start-layout {
    width: min(420px, calc(100vw - 20px));
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .start-side-panel {
    display: none;
  }

  .start-screen {
    padding: 10px;
  }

  .start-panel {
    max-height: calc(100svh - 20px);
    gap: clamp(8px, 2.4vmin, 10px);
    overflow-y: auto;
    padding: clamp(14px, 4vmin, 18px);
    border-radius: 10px;
  }

  .start-panel h1 {
    font-size: clamp(25px, 8vw, 30px);
  }

  input,
  select {
    padding: clamp(8px, 2.2vmin, 10px);
  }

  #playButton {
    padding: 10px 12px;
  }

  .module-panel {
    grid-template-columns: repeat(2, minmax(104px, 1fr));
    max-width: 232px;
  }

  .module-button,
  .actions button {
    padding: 8px;
    font-size: 13px;
  }

  .actions {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .help {
    font-size: 12px;
  }
}

@media (max-width: 760px), (max-height: 620px) {
  .hud {
    padding: clamp(6px, 1.8vmin, 10px);
    gap: clamp(5px, 1.4vmin, 8px);
  }

  .topbar {
    max-width: min(520px, calc(100vw - 16px));
    padding: clamp(6px, 1.8vmin, 9px) clamp(8px, 2.2vmin, 11px);
    border-radius: 8px;
    font-size: clamp(11px, 2.7vmin, 13px);
  }

  .topbar strong {
    margin-right: 8px;
  }

  .leaderboard {
    width: min(clamp(150px, 34vw, 220px), calc(100vw - 16px));
    padding: clamp(6px, 1.6vmin, 8px);
    font-size: clamp(10px, 2.5vmin, 12px);
  }

  .leaderboard h2,
  .leaderboard b,
  .leaderboard li {
    font-size: clamp(10px, 2.5vmin, 12px);
  }

  .leaderboard li {
    grid-template-columns: clamp(16px, 4.8vmin, 20px) minmax(0, 1fr) auto;
    gap: 6px;
  }

  .leaderboard li::before {
    width: clamp(16px, 4.8vmin, 20px);
    height: clamp(16px, 4.8vmin, 20px);
    border-radius: 6px;
    font-size: clamp(9px, 2.3vmin, 11px);
  }

  .minimap {
    left: clamp(6px, 1.8vmin, 10px);
    bottom: clamp(6px, 1.8vmin, 10px);
    width: clamp(100px, 28vmin, 136px);
    padding: clamp(5px, 1.6vmin, 8px);
  }

  .minimap h2 {
    margin-bottom: 5px;
    font-size: clamp(9px, 2.3vmin, 11px);
  }

  #minimapCanvas {
    width: calc(clamp(100px, 28vmin, 136px) - clamp(12px, 3.6vmin, 18px));
    height: calc(clamp(100px, 28vmin, 136px) - clamp(12px, 3.6vmin, 18px));
  }

  .builder-toggle,
  .builder-close {
    width: clamp(58px, 15vw, 82px);
    height: clamp(86px, 23vh, 132px);
    padding: clamp(9px, 2.4vmin, 12px) 5px clamp(8px, 2vmin, 10px);
  }

  .builder-toggle {
    top: clamp(64px, 16vh, 18%);
  }

  .builder-close {
    right: calc(clamp(58px, 15vw, 82px) * -1);
    top: clamp(64px, 16vh, 18%);
  }

  .toolbox-svg {
    width: clamp(34px, 9vw, 50px);
    height: clamp(34px, 9vw, 50px);
  }

  .control-label {
    font-size: clamp(12px, 3.4vw, 17px);
  }

  .base-action-rail {
    top: calc(clamp(64px, 16vh, 18%) + clamp(96px, 25vh, 146px));
    gap: clamp(7px, 1.8vmin, 11px);
    width: clamp(58px, 15vw, 82px);
  }

  body.builder-panel-open .base-action-rail {
    left: min(340px, calc(100vw - clamp(50px, 13vw, 66px)));
  }

  .base-action-button {
    width: clamp(58px, 15vw, 82px);
    height: clamp(58px, 14vh, 78px);
    padding: clamp(7px, 1.8vmin, 9px) 5px clamp(6px, 1.6vmin, 8px);
  }

  .base-action-svg {
    width: clamp(28px, 7.5vw, 38px);
    height: clamp(28px, 7.5vw, 38px);
  }

  .ship-builder-panel {
    width: min(340px, calc(100vw - clamp(50px, 13vw, 66px)));
    padding: clamp(10px, 2.6vmin, 14px);
  }

  .builder-header {
    gap: 8px;
    padding-bottom: 10px;
  }

  .builder-header h2 {
    font-size: clamp(17px, 4.4vw, 20px);
  }

  .builder-tabs {
    gap: 6px;
    padding-bottom: 8px;
  }

  .builder-tab {
    height: clamp(30px, 7.5vh, 36px);
    font-size: clamp(11px, 3vw, 13px);
  }

  .builder-palette {
    grid-template-columns: 1fr;
    gap: clamp(7px, 1.8vmin, 10px);
  }

  .builder-card {
    grid-template-rows: minmax(58px, auto);
    grid-template-columns: clamp(58px, 16vmin, 78px) minmax(0, 1fr);
    min-height: clamp(58px, 16vmin, 72px);
  }

  .builder-card canvas {
    width: clamp(46px, 12vmin, 58px);
    height: clamp(46px, 12vmin, 58px);
  }

  .builder-card-body {
    min-height: 0;
    padding: 7px;
  }

  .mobile-joystick {
    --stick-size: clamp(84px, 20vmin, 126px);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .start-screen {
    align-items: start;
    padding: 54px 18px 16px clamp(114px, 18vw, 126px);
  }

  .start-layout {
    width: min(520px, calc(100vw - clamp(142px, 21vw, 154px)));
    grid-template-columns: minmax(110px, 1fr) clamp(218px, 35vw, 238px) minmax(110px, 1fr);
    gap: 8px;
  }

  .start-side-panel {
    display: grid;
    min-height: calc(100svh - 70px);
  }

  .default-ship-panel,
  .menu-side-panel {
    padding: 8px;
  }

  .default-ship-panel {
    gap: 7px;
  }

  .default-ship-preview {
    min-height: 0;
  }

  #defaultShipCanvas {
    max-width: min(100%, 110px);
  }

  .default-ship-edit-button {
    min-height: 48px;
  }

  .default-ship-status {
    min-height: 14px;
    font-size: 10px;
  }

  .menu-side-panel {
    grid-template-rows: repeat(3, minmax(0, 1fr)) 38px;
    gap: 7px;
  }

  .main-menu-button {
    min-height: 0;
    padding: 8px;
  }

  .main-menu-label {
    font-size: clamp(12px, 2.4vw, 16px);
  }

  .menu-art {
    right: 6px;
    bottom: 6px;
    width: 64px;
    height: 42px;
    transform: scale(0.52);
    transform-origin: right bottom;
  }

  .booster-row {
    gap: 5px;
  }

  .booster-row button {
    min-height: 38px;
    padding: 6px;
    font-size: 13px;
  }

  .start-panel {
    max-height: calc(100svh - 70px);
    gap: 5px;
    padding: 8px 14px;
  }

  .start-panel h1 {
    font-size: clamp(23px, 5.2vw, 27px);
  }

  .start-panel label,
  #startStatus {
    font-size: 12px;
  }

  input,
  select {
    padding: 7px 9px;
  }

  #playButton {
    padding: 7px 10px;
  }

  .login-button {
    min-width: 108px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .settings-button {
    min-width: 88px;
  }

  .resource-panel {
    right: 18px;
    top: 10px;
  }

  .minimap {
    left: clamp(112px, 20vw, 140px);
    width: clamp(86px, 22vmin, 112px);
  }

  #minimapCanvas {
    width: calc(clamp(86px, 22vmin, 112px) - clamp(10px, 3vmin, 16px));
    height: calc(clamp(86px, 22vmin, 112px) - clamp(10px, 3vmin, 16px));
  }

  .builder-toggle,
  .builder-close {
    width: clamp(50px, 10vw, 64px);
    height: clamp(64px, 28vh, 92px);
  }

  .builder-close {
    right: calc(clamp(50px, 10vw, 64px) * -1);
  }

  .base-action-rail,
  .base-action-button {
    width: clamp(50px, 10vw, 64px);
  }

  .base-action-rail {
    top: calc(clamp(64px, 16vh, 18%) + clamp(72px, 31vh, 102px));
  }

  .base-action-button {
    height: clamp(48px, 18vh, 62px);
  }

  .control-label {
    font-size: clamp(10px, 2vw, 13px);
  }

  .builder-palette {
    grid-template-columns: 1fr;
    gap: 6px;
    padding-bottom: 10px;
  }

  .builder-card {
    grid-template-columns: 54px minmax(0, 1fr);
    grid-template-rows: minmax(50px, auto);
    min-height: 52px;
  }

  .builder-card canvas {
    width: 42px;
    height: 42px;
  }

  .builder-card-body {
    min-height: 0;
    padding: 6px 7px;
    align-content: center;
  }
}

.start-advanced-fields {
  display: grid;
  gap: 12px;
}

.mobile-menu-button,
.mobile-fullscreen-button,
.mobile-ship-button,
.mobile-ship-drawer,
.mobile-menu-drawer {
  display: none;
}

.mobile-menu-button,
.mobile-fullscreen-button {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 70;
  width: 46px;
  height: 42px;
  place-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(244, 247, 239, 0.22);
  border-radius: 8px;
  background: rgba(7, 9, 9, 0.88);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.mobile-menu-button {
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  gap: 4px;
}

.mobile-fullscreen-button {
  right: calc(env(safe-area-inset-right, 0px) + 64px);
}

.mobile-ship-button {
  position: fixed;
  left: 0;
  top: 48%;
  z-index: 69;
  width: 34px;
  height: 70px;
  place-items: center;
  border: 1px solid rgba(244, 247, 239, 0.2);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(7, 9, 9, 0.88);
  color: var(--green);
  box-shadow: 10px 0 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transform: translateY(-50%);
}

.mobile-ship-button span {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.mobile-menu-button span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.mobile-fullscreen-button span {
  width: 22px;
  height: 22px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 9px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 0 / 2px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 0 / 9px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 0 / 2px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 100% / 9px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 100% / 2px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 100% / 9px 2px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 100% / 2px 9px no-repeat;
}

.mobile-menu-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.mobile-ship-drawer {
  position: fixed;
  inset: 0;
  z-index: 79;
  pointer-events: none;
}

.mobile-menu-drawer:not(.hidden) {
  display: block;
}

.mobile-ship-drawer:not(.hidden) {
  display: block;
}

.mobile-menu-backdrop,
.mobile-ship-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.48);
  opacity: 0;
  transition: opacity 160ms ease;
}

.mobile-ship-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(314px, calc(100vw - 44px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-right: 1px solid rgba(244, 247, 239, 0.16);
  background: rgba(7, 9, 9, 0.96);
  box-shadow: 18px 0 46px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(18px);
  transform: translateX(-102%);
  transition: transform 180ms ease;
}

.mobile-menu-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(330px, calc(100vw - 18px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-left: 1px solid rgba(244, 247, 239, 0.16);
  background: rgba(7, 9, 9, 0.96);
  box-shadow: -18px 0 46px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(18px);
  transform: translateX(102%);
  transition: transform 180ms ease;
}

body.mobile-menu-open .mobile-menu-drawer {
  pointer-events: auto;
}

body.mobile-ship-open .mobile-ship-drawer {
  pointer-events: auto;
}

body.mobile-menu-open .mobile-menu-backdrop,
body.mobile-ship-open .mobile-ship-backdrop {
  opacity: 1;
}

body.mobile-menu-open .mobile-menu-sheet {
  transform: translateX(0);
}

body.mobile-ship-open .mobile-ship-sheet {
  transform: translateX(0);
}

.mobile-menu-head,
.mobile-ship-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
}

.mobile-menu-head h2,
.mobile-ship-head h2 {
  margin: 0;
  color: var(--green);
  font-size: 18px;
  line-height: 1;
}

.mobile-menu-close,
.mobile-ship-close {
  min-height: 38px;
  border: 1px solid rgba(244, 247, 239, 0.2);
  border-radius: 8px;
  background: rgba(14, 17, 15, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  padding: 8px 10px;
}

.mobile-ship-slot {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mobile-menu-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 2px;
}

.mobile-menu-slot:empty {
  display: none;
}

.mobile-drawer-action {
  min-height: 44px;
  border: 1px solid rgba(244, 247, 239, 0.2);
  border-radius: 8px;
  background: rgba(14, 17, 15, 0.92);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  padding: 9px 10px;
  text-align: left;
}

body.is-small-mobile .orientation-gate {
  display: none !important;
  pointer-events: none !important;
}

body.is-small-mobile .mobile-menu-button:not(.hidden) {
  display: grid !important;
}

body.is-small-mobile .mobile-fullscreen-button:not(.hidden) {
  display: grid !important;
}

body.is-small-mobile .mobile-ship-button:not(.hidden) {
  display: grid !important;
}

body.is-playing .mobile-ship-button,
body.is-playing .mobile-ship-drawer {
  display: none !important;
}

body.is-small-mobile:not(.is-playing) .auth-panel {
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex !important;
  gap: 6px;
}

body.is-small-mobile:not(.is-playing) .auth-panel .settings-button {
  display: none;
}

body.is-small-mobile:not(.is-playing) .login-button {
  min-width: 96px;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 12px;
}

body.is-small-mobile:not(.is-playing) .profile-card {
  width: min(190px, calc(100vw - 128px));
  padding: 7px;
  border-radius: 8px;
}

body.is-small-mobile:not(.is-playing) .resource-panel:not(.hidden) {
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  right: auto;
  top: calc(env(safe-area-inset-top, 0px) + 56px);
  display: block !important;
}

body.is-small-mobile:not(.is-playing) .resource-card {
  min-width: 84px;
  padding: 6px 8px;
  border-radius: 8px;
}

body.is-small-mobile .start-screen:not(.hidden),
body.is-small-mobile .hud:not(.hidden),
body.is-small-mobile .profile-modal:not(.hidden),
body.is-small-mobile .menu-modal:not(.hidden),
body.is-small-mobile .settings-modal:not(.hidden) {
  display: grid !important;
}

body.is-small-mobile .mobile-controls.visible:not(.hidden) {
  display: block !important;
}

body.is-small-mobile .start-screen {
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 76px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
}

body.is-small-mobile .start-layout {
  width: min(380px, calc(100vw - 24px));
  grid-template-columns: 1fr;
  gap: 0;
}

body.is-small-mobile .start-panel {
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 96px);
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  overflow: hidden;
}

body.is-small-mobile .start-advanced-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.is-small-mobile .start-advanced-fields label {
  min-width: 0;
  font-size: 12px;
}

body.is-small-mobile .start-advanced-fields select {
  min-height: 40px;
  padding: 8px;
  font-size: 13px;
}

body.is-small-mobile .custom-server-field {
  display: grid;
  gap: 5px;
}

body.is-small-mobile .start-panel h1 {
  font-size: 29px;
  line-height: 1.02;
}

body.is-small-mobile .eyebrow {
  font-size: 13px;
}

body.is-small-mobile #playButton {
  min-height: 46px;
  border-radius: 8px;
  font-size: 16px;
}

body.is-small-mobile #startStatus {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.2;
}

body.is-small-mobile .mobile-menu-drawer .auth-panel {
  position: static;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

body.is-small-mobile .mobile-menu-drawer .profile-card {
  grid-column: 1 / -1;
  width: 100%;
}

body.is-small-mobile .mobile-menu-drawer .login-button,
body.is-small-mobile .mobile-menu-drawer .settings-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

body.is-small-mobile .mobile-menu-drawer .resource-panel {
  position: static;
  display: block !important;
}

body.is-small-mobile .mobile-menu-drawer .resource-panel.hidden {
  display: none !important;
}

body.is-small-mobile .mobile-menu-drawer .resource-card {
  width: 100%;
  min-width: 0;
  justify-content: start;
}

body.is-small-mobile .mobile-menu-drawer .start-side-panel,
body.is-small-mobile .mobile-ship-drawer .start-side-panel {
  display: grid !important;
  min-height: 0;
  border-radius: 8px;
}

body.is-small-mobile .mobile-menu-drawer .menu-side-panel {
  padding: 10px;
  gap: 8px;
}

body.is-small-mobile .mobile-ship-drawer .default-ship-panel {
  min-height: 100%;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 12px;
}

body.is-small-mobile .mobile-ship-drawer .default-ship-preview {
  min-height: 260px;
  align-content: center;
}

body.is-small-mobile .mobile-ship-drawer #defaultShipCanvas {
  width: min(260px, 100%);
  max-width: none;
}

body.is-small-mobile .mobile-ship-drawer .default-ship-edit-button {
  min-height: 50px;
}

body.is-small-mobile .mobile-ship-drawer .default-ship-status {
  min-height: 14px;
  font-size: 11px;
}

body.is-small-mobile .mobile-menu-drawer .start-advanced-fields {
  padding: 10px;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background: rgba(12, 14, 12, 0.72);
  gap: 9px;
}

body.is-small-mobile .mobile-menu-drawer .custom-server-field {
  padding: 10px;
  border: 1px solid rgba(244, 247, 239, 0.14);
  border-radius: 8px;
  background: rgba(12, 14, 12, 0.72);
  color: var(--muted);
  font-size: 12px;
}

body.is-small-mobile .mobile-menu-drawer .start-advanced-fields label {
  gap: 5px;
  font-size: 12px;
}

body.is-small-mobile .mobile-menu-drawer input,
body.is-small-mobile .mobile-menu-drawer select {
  min-height: 40px;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
}

body.is-small-mobile .mobile-menu-drawer .menu-side-panel {
  grid-template-rows: none;
  grid-auto-rows: minmax(54px, auto);
}

body.is-small-mobile .mobile-menu-drawer .main-menu-button {
  min-height: 58px;
  padding: 10px;
}

body.is-small-mobile .mobile-menu-drawer .main-menu-label {
  font-size: 17px;
}

body.is-small-mobile .mobile-menu-drawer .menu-art {
  right: 7px;
  bottom: 5px;
  width: 72px;
  height: 46px;
  transform: scale(0.56);
  transform-origin: right bottom;
}

body.is-small-mobile .mobile-menu-drawer .booster-row {
  gap: 6px;
}

body.is-small-mobile .mobile-menu-drawer .booster-row button {
  min-height: 44px;
  border-radius: 8px;
  font-size: 14px;
}

body.is-small-mobile .mobile-menu-drawer .legal-corner-button {
  position: static;
  display: block !important;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  font-size: 13px;
}

body.is-small-mobile .topbar {
  max-width: calc(100vw - 68px - env(safe-area-inset-right, 0px));
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 11px;
}

body.is-small-mobile .topbar > div:first-child {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 7px;
}

body.is-small-mobile .topbar strong {
  margin-right: 0;
  font-size: 12px;
}

body.is-small-mobile .topbar-settings-button {
  display: none;
}

body.is-small-mobile .stats {
  gap: 6px;
  font-size: 11px;
}

body.is-small-mobile .stats span:nth-child(3) {
  display: none;
}

body.is-small-mobile .leaderboard {
  display: none;
}

body.is-small-mobile .minimap {
  left: 8px;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  bottom: auto;
  width: 92px;
  padding: 5px;
  border-radius: 8px;
}

body.is-small-mobile .minimap h2 {
  display: none;
}

body.is-small-mobile #minimapCanvas {
  width: 80px;
  height: 80px;
}

body.is-small-mobile .mobile-joystick {
  --stick-size: clamp(88px, 27vmin, 116px);
}

body.is-small-mobile .builder-tooltip {
  display: none !important;
}

body.is-small-mobile .builder-toggle,
body.is-small-mobile .builder-close,
body.is-small-mobile .base-action-button {
  border-radius: 8px;
}

body.is-small-mobile.small-mobile-landscape .start-screen {
  padding: calc(env(safe-area-inset-top, 0px) + 50px) 12px 10px;
}

body.is-small-mobile.small-mobile-landscape .start-layout {
  width: min(430px, calc(100vw - 24px));
}

body.is-small-mobile.small-mobile-landscape .start-panel {
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - 64px);
  gap: 7px;
  padding: 10px 12px;
}

body.is-small-mobile.small-mobile-landscape .start-panel h1 {
  font-size: 25px;
}

body.is-small-mobile.small-mobile-landscape .start-panel label,
body.is-small-mobile.small-mobile-landscape #startStatus {
  font-size: 11px;
}

body.is-small-mobile.small-mobile-landscape .start-panel input {
  min-height: 38px;
  padding: 7px 8px;
}

body.is-small-mobile.small-mobile-landscape #playButton {
  min-height: 38px;
  padding: 7px 10px;
}

body.is-small-mobile.small-mobile-landscape .ship-builder-panel {
  width: min(318px, calc(100vw - 58px));
}

body.is-small-mobile.small-mobile-landscape .builder-toggle {
  width: 52px;
  height: 76px;
}

body.is-small-mobile.small-mobile-landscape .builder-close {
  right: -52px;
  width: 52px;
  height: 76px;
}

body.is-small-mobile.small-mobile-landscape .base-action-rail,
body.is-small-mobile.small-mobile-landscape .base-action-button {
  width: 52px;
}

body.is-small-mobile.small-mobile-landscape .base-action-button {
  height: 52px;
}

body.is-small-mobile.small-mobile-portrait .mobile-menu-sheet {
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: min(calc(100svh - 60px), 720px);
  border-top: 1px solid rgba(244, 247, 239, 0.16);
  border-left: 0;
  border-radius: 8px 8px 0 0;
  transform: translateY(102%);
  box-shadow: 0 -18px 46px rgba(0, 0, 0, 0.44);
}

body.is-small-mobile.small-mobile-portrait.mobile-menu-open .mobile-menu-sheet {
  transform: translateY(0);
}

body.is-small-mobile.small-mobile-portrait .start-layout {
  width: min(360px, calc(100vw - 24px));
}

body.is-small-mobile.small-mobile-portrait .start-advanced-fields {
  grid-template-columns: 1fr;
}

body.is-small-mobile.small-mobile-portrait .ship-builder-panel {
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  width: 100vw;
  height: min(62svh, 430px);
  max-height: calc(100svh - 84px);
  padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid rgba(244, 247, 239, 0.16);
  border-right: 0;
  border-radius: 8px 8px 0 0;
  transform: translateY(100%);
  box-shadow: 0 -18px 46px rgba(0, 0, 0, 0.46);
}

body.is-small-mobile.small-mobile-portrait .ship-builder-panel.open {
  transform: translateY(0);
}

body.is-small-mobile.small-mobile-portrait .builder-close {
  right: 10px;
  top: -48px;
  width: 48px;
  height: 42px;
  padding: 7px;
  border: 1px solid rgba(244, 247, 239, 0.16);
  border-radius: 8px 8px 0 0;
}

body.is-small-mobile.small-mobile-portrait .builder-close .control-label {
  display: none;
}

body.is-small-mobile.small-mobile-portrait .builder-close .toolbox-svg {
  width: 28px;
  height: 28px;
}

body.is-small-mobile.small-mobile-portrait .builder-toggle {
  left: 50%;
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 128px);
  width: 66px;
  height: 58px;
  padding: 7px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  transform: translateX(-50%);
}

body.is-small-mobile.small-mobile-portrait .builder-toggle .toolbox-svg {
  width: 30px;
  height: 30px;
}

body.is-small-mobile.small-mobile-portrait .builder-toggle .control-label {
  font-size: 10px;
}

body.is-small-mobile.small-mobile-portrait .base-action-rail {
  left: 8px;
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 126px);
  display: flex;
  width: auto;
  gap: 6px;
}

body.is-small-mobile.small-mobile-portrait .base-action-button {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(244, 247, 239, 0.18);
  padding: 6px;
}

body.is-small-mobile.small-mobile-portrait .base-action-button .control-label {
  display: none;
}

body.is-small-mobile.small-mobile-portrait .base-action-svg {
  width: 30px;
  height: 30px;
}

body.is-small-mobile .settings-card,
body.is-small-mobile .profile-modal-card,
body.is-small-mobile .menu-modal-card {
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100svh - 20px);
  border-radius: 8px;
}

body.is-small-mobile.small-mobile-portrait .default-ship-modal-card,
body.is-small-mobile.small-mobile-portrait .inventory-modal-card {
  min-height: 0;
}
