:root {
  --ground-blue: #68e2ff;
  --ground-gold: #ffd166;
  --ground-green: #8bf18a;
}

.ground-mode-panel {
  right: 222px;
  bottom: 16px;
  z-index: 7;
  width: min(270px, calc(100vw - 32px));
  padding: 10px 12px;
  pointer-events: none;
}
.ground-mode-panel > strong,
.ground-mode-panel > span,
.ground-mode-panel > small { display: block; }
.ground-mode-panel > strong {
  margin-top: 3px;
  color: var(--ground-gold);
  font-size: 14px;
  letter-spacing: .05em;
}
.ground-mode-panel > span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ground-mode-panel > small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.touch-action.ground-action {
  grid-column: 2;
  border-color: rgba(104,226,255,.62);
  background: linear-gradient(145deg, rgba(34,126,153,.68), rgba(7,18,29,.72));
}
#touchSwitch.hidden + #touchGroundAction { grid-column: 1 / -1; }


/* Context-sensitive PlayStation-style dual-stick layout. The original left
   stick remains the flight stick while mounted. On foot or as a pig it becomes
   movement, and the right stick independently controls camera/aim. */
#lookJoystickBase {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: none;
  width: 122px;
  height: 122px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, rgba(104,226,255,.12), rgba(7,18,29,.42));
  pointer-events: auto;
  touch-action: none;
}
#mobileControls.dual-stick #lookJoystickBase { display: block; }
#mobileControls.dual-stick #joystickBase {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 122px;
  height: 122px;
  background: radial-gradient(circle at 50% 46%, rgba(120,227,107,.11), rgba(7,18,29,.42));
}
#mobileControls.dual-stick #joystickBase::after,
#mobileControls.dual-stick #lookJoystickBase::after {
  position: absolute;
  left: 50%;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(4,14,23,.72);
  color: rgba(255,255,255,.78);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .14em;
  pointer-events: none;
  transform: translateX(-50%);
}
#mobileControls.dual-stick #joystickBase::after { content: "LIIKE"; }
#mobileControls.dual-stick #lookJoystickBase::after { content: "KATSE"; }
#mobileControls.dual-stick .action-stack {
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 146px);
  grid-template-columns: repeat(3, minmax(70px, 82px));
  grid-auto-rows: minmax(42px, auto);
  gap: 6px;
}
#mobileControls.dual-stick .touch-action {
  min-height: 42px;
  padding: 5px 6px;
  border-radius: 10px;
  font-size: 8px;
  line-height: 1.08;
}

.ground-arsenal-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--meta-line);
}
.ground-arsenal-section .section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}
.ground-arsenal-section .section-heading h3 {
  margin: 2px 0 0;
  font-size: 17px;
}
.ground-arsenal-section .section-heading p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  text-align: right;
}
.ground-arsenal-grid { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); }
.ground-weapon-card.selected {
  border-color: rgba(104,226,255,.72);
  box-shadow: inset 0 0 0 1px rgba(104,226,255,.18), 0 12px 30px rgba(0,0,0,.2);
}
.ground-weapon-card.locked { filter: saturate(.52); }
.ground-weapon-visual {
  position: relative;
  height: 72px;
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(circle at 72% 28%, color-mix(in srgb, var(--weapon-color) 35%, transparent), transparent 25%),
    linear-gradient(145deg, rgba(255,255,255,.06), rgba(0,0,0,.18));
}
.ground-weapon-visual::before {
  position: absolute;
  left: 17%;
  top: 30px;
  width: 61%;
  height: 12px;
  border-radius: 999px 4px 4px 999px;
  background: linear-gradient(90deg, var(--weapon-accent), var(--weapon-color));
  box-shadow: 0 0 18px color-mix(in srgb, var(--weapon-color) 28%, transparent);
  content: "";
  transform: rotate(-9deg);
}
.ground-weapon-visual::after {
  position: absolute;
  left: 39%;
  top: 38px;
  width: 11px;
  height: 22px;
  border-radius: 3px 3px 7px 7px;
  background: var(--weapon-accent);
  content: "";
  transform: rotate(8deg);
}
.ground-weapon-visual i,
.ground-weapon-visual b {
  position: absolute;
  display: block;
  border-radius: 999px;
  background: var(--weapon-color);
}
.ground-weapon-visual i { right: 13%; top: 26px; width: 17px; height: 17px; }
.ground-weapon-visual b { left: 12%; top: 27px; width: 19px; height: 19px; opacity: .72; }
.ground-weapon-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ground-weapon-stats span {
  padding: 4px 6px;
  border-radius: 7px;
  background: rgba(255,255,255,.055);
  color: var(--muted);
  font-size: 8px;
}
.ground-weapon-card .inventory-count strong { color: var(--ground-gold); }

@media (max-width: 1180px) {
  .ground-mode-panel {
    right: 16px;
    bottom: 222px;
    width: 215px;
  }
}

@media (max-width: 900px) {
  .ground-mode-panel {
    left: 16px;
    right: auto;
    top: 116px;
    bottom: auto;
    width: 235px;
  }
  .ground-arsenal-section .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .ground-arsenal-section .section-heading p { text-align: left; }
}

@media (pointer: coarse) {
  .action-stack { grid-auto-rows: minmax(46px, auto); }
  .touch-action.ground-action { min-height: 48px; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .ground-mode-panel {
    left: 8px;
    top: 116px;
    width: 205px;
    padding: 8px 9px;
  }
  .ground-mode-panel > span { font-size: 9px; }
  .ground-mode-panel > small { font-size: 8px; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  .ground-mode-panel {
    left: 365px;
    right: auto;
    top: 12px;
    bottom: auto;
    width: 250px;
    padding: 7px 9px;
  }
  .ground-mode-panel > strong { font-size: 11px; }
  .ground-mode-panel > span { font-size: 8px; }
  .ground-mode-panel > small { display: none; }
  .action-stack { grid-auto-rows: minmax(42px, auto); }
  .touch-action { min-height: 42px; }
}

@media (pointer: coarse) and (orientation: portrait) {
  #mobileControls.dual-stick #joystickBase,
  #mobileControls.dual-stick #lookJoystickBase {
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 112px;
    height: 112px;
  }
  #mobileControls.dual-stick .action-stack {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 138px);
    grid-template-columns: repeat(2, 78px);
    grid-auto-rows: minmax(47px, auto);
  }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  #mobileControls.dual-stick #joystickBase,
  #mobileControls.dual-stick #lookJoystickBase {
    bottom: max(13px, env(safe-area-inset-bottom));
    width: 112px;
    height: 112px;
  }
  #mobileControls.dual-stick #joystickBase { left: max(13px, env(safe-area-inset-left)); }
  #mobileControls.dual-stick #lookJoystickBase { right: max(13px, env(safe-area-inset-right)); }
  #mobileControls.dual-stick .action-stack {
    right: max(9px, env(safe-area-inset-right));
    bottom: calc(max(13px, env(safe-area-inset-bottom)) + 132px);
    grid-template-columns: repeat(3, 74px);
    grid-auto-rows: 39px;
    gap: 5px;
  }
  #mobileControls.dual-stick .touch-action {
    min-height: 39px;
    padding: 4px;
    font-size: 7.5px;
  }
}

@media (max-width: 620px) {
  .ground-arsenal-grid { grid-template-columns: 1fr; }
}
