/* DOM mobile gameplay controls — synced to #gameCanvas bounding box */

.mobile-controls-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1100; /* above HUD chrome (1001), below modals (10000) */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-controls-layer[hidden] {
  display: none !important;
}

.mobile-controls {
  position: absolute;
  pointer-events: none;
  touch-action: none;
  overflow: visible;
}

.mc-control {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
}

.mc-control[hidden] {
  display: none !important;
}

.mc-interact {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 28%;
  min-width: 220px;
  max-width: 85%;
  height: 54px;
  padding: 0 24px;
  border-radius: 27px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 140, 0, 0.5));
  border: 2px solid rgba(255, 215, 0, 0.9);
  box-shadow: 0 0 20px rgba(255, 180, 0, 0.5), inset 0 0 12px rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-family: Orbitron, sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  pointer-events: auto;
  touch-action: none;
  z-index: 1200;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, background 0.15s ease;
}

.mc-interact[hidden] {
  display: none !important;
}

.mc-interact:active,
.mc-interact.mc-pressed {
  transform: translateX(-50%) scale(0.94);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.6), rgba(255, 140, 0, 0.85));
  box-shadow: 0 0 28px rgba(255, 215, 0, 0.9);
}

.mc-joystick,
.mc-button {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mc-joystick {
  background: radial-gradient(circle at 35% 30%, rgba(28, 34, 64, 0.72), rgba(0, 0, 8, 0.78));
  border: 2.5px solid rgba(120, 160, 255, 0.45);
  box-shadow: 0 0 18px rgba(4, 6, 18, 0.35);
}

.mc-joystick.mc-active {
  border-color: rgba(120, 160, 255, 0.9);
  box-shadow: 0 0 16px rgba(120, 160, 255, 0.35);
}

.mc-joystick.mc-primary {
  border-width: 3px;
}

.mc-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), rgba(95, 130, 215, 0.7));
  border: 1.5px solid rgba(120, 160, 255, 0.55);
  pointer-events: none;
  will-change: transform;
  z-index: 0;
}

.mc-button {
  background: rgba(8, 10, 24, 0.6);
  border: 2px solid rgba(120, 160, 255, 0.5);
  color: rgba(230, 235, 255, 0.92);
  font-family: Orbitron, monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.mc-button.mc-pressed {
  background: rgba(8, 10, 24, 0.88);
  border-color: rgba(255, 255, 255, 0.75);
  transform: scale(0.93);
  transform-origin: center center;
}

.mc-button.mc-directional::before {
  content: '';
  position: absolute;
  inset: 22%;
  border: 1.35px solid rgba(120, 160, 255, 0.42);
  border-radius: 50%;
  pointer-events: none;
}

.mc-label {
  position: relative;
  z-index: 1;
  pointer-events: none;
  text-align: center;
  line-height: 1.05;
  max-width: 88%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-family: Orbitron, monospace;
  font-weight: 700;
  font-size: clamp(8px, 2.2vw, 11px);
  letter-spacing: 0.04em;
  color: rgba(230, 235, 255, 0.95);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.85);
}

.mc-control.mc-aiming .mc-label {
  opacity: 0;
}

.mc-cooldown {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  background: conic-gradient(
    from -90deg,
    rgba(200, 50, 50, 0.4) var(--mc-cd, 0%),
    transparent var(--mc-cd, 0%)
  );
}

.mc-cd-text {
  position: absolute;
  left: 50%;
  bottom: -1.1em;
  transform: translateX(-50%);
  font-family: Orbitron, monospace;
  font-size: clamp(9px, 2vw, 11px);
  font-weight: 700;
  color: rgba(255, 210, 210, 0.95);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  z-index: 2;
}

.mc-charge-badge {
  position: absolute;
  right: -2px;
  top: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ffe97a, #cc8800);
  color: #1a0a00;
  font-family: Orbitron, monospace;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 3;
}

.mc-tutorial-glow {
  box-shadow: 0 0 0 4px rgba(255, 220, 80, 0.75), 0 0 18px rgba(255, 220, 80, 0.45) !important;
}

.mc-aim-ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 55%;
  background: linear-gradient(to top, rgba(120, 160, 255, 0.15), rgba(120, 160, 255, 0.85));
  transform-origin: bottom center;
  pointer-events: none;
  opacity: 0;
  z-index: 0;
}

.mc-joystick.mc-active .mc-aim-ray {
  opacity: 1;
}

/* ——— Editor (own layers; avoid ui-layer--modal display:flex trap) ———
   Stacking while editing (bottom → top):
   pause/modals (10000) < backdrop (10040) < controls (10045, inline)
   < editor chrome/popover/info (10050+). Backdrop and chrome are separate
   fixed layers so the popover is never trapped below the lifted controls. */

.mobile-control-editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(4, 6, 18, 0.55);
  pointer-events: auto;
}

.mobile-control-editor-backdrop[hidden] {
  display: none !important;
}

.mobile-control-editor-layer {
  position: fixed;
  inset: 0;
  z-index: 10050;
  pointer-events: none;
}

.mobile-control-editor-layer[hidden],
.mobile-control-editor-layer:not(.mobile-control-editor-layer--open) {
  display: none !important;
}

.mobile-control-editor-layer--open {
  display: block !important;
}

.mobile-control-editor-bar {
  position: absolute;
  left: 50%;
  top: max(12px, env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: rgba(8, 10, 24, 0.94);
  border: 1px solid rgba(120, 160, 255, 0.35);
  border-radius: 12px;
  pointer-events: auto;
  max-width: min(96vw, 560px);
  z-index: 2;
}

.mobile-control-editor-badge {
  width: 100%;
  text-align: center;
  color: rgba(255, 230, 140, 0.95);
  font-family: Orbitron, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.mobile-control-editor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

.mc-class-chip {
  appearance: none;
  border: 1px solid rgba(120, 160, 255, 0.4);
  background: rgba(20, 28, 56, 0.9);
  color: rgba(220, 230, 255, 0.9);
  font-family: Orbitron, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
}

.mc-class-chip.is-active {
  border-color: rgba(255, 220, 100, 0.85);
  background: rgba(60, 48, 16, 0.95);
  color: #ffe9a0;
}

.mobile-control-editor-hint {
  width: 100%;
  text-align: center;
  color: rgba(220, 230, 255, 0.75);
  font-size: 11px;
  font-family: Orbitron, monospace;
  line-height: 1.35;
}

.mobile-control-editor-help {
  width: 100%;
  text-align: center;
  color: rgba(180, 210, 255, 0.9);
  font-size: 11px;
  font-family: Orbitron, monospace;
  line-height: 1.35;
  min-height: 1.35em;
}

.mobile-control-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.mobile-control-editor-bar .btn {
  min-height: 40px;
}

.mc-control.mc-editing {
  outline: 2px dashed rgba(255, 220, 80, 0.85);
  outline-offset: 4px;
  cursor: grab;
}

.mc-control.mc-editing.mc-dragging {
  cursor: grabbing;
  outline-color: rgba(120, 255, 180, 0.9);
}

.mc-control.mc-type-open {
  z-index: 6;
}

.mc-control.mc-type-open .mc-type-trigger {
  border-color: rgba(255, 220, 100, 0.9);
  color: #ffe9a0;
}

.mc-type-trigger {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  z-index: 4;
  /* flipped above the control when it would clip the bottom edge */
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(120, 160, 255, 0.55);
  background: rgba(8, 10, 24, 0.95);
  color: #e8eeff;
  font-family: Orbitron, monospace;
  font-size: 9px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 140px;
  overflow: visible;
  cursor: pointer;
}

/* A short stem points back to the control face. This stays deliberately faint:
   it clarifies ownership when chips flip sides without adding gameplay noise. */
.mc-type-trigger::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  width: 1px;
  height: 6px;
  transform: translateX(-50%);
  background: rgba(255, 220, 100, 0.65);
  box-shadow: 0 -1px 0 rgba(255, 220, 100, 0.35);
  pointer-events: none;
}

.mc-type-trigger--above {
  top: auto;
  bottom: calc(100% + 4px);
}

.mc-type-trigger--above::before {
  top: auto;
  bottom: -6px;
  box-shadow: 0 1px 0 rgba(255, 220, 100, 0.35);
}

.mc-type-popover {
  position: fixed;
  z-index: 5;
  display: none;
  flex-direction: column;
  gap: 4px;
  width: min(240px, calc(100vw - 16px));
  padding: 8px;
  background: rgba(8, 10, 24, 0.97);
  border: 1px solid rgba(120, 160, 255, 0.5);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.mc-type-popover[hidden] {
  display: none !important;
}

.mc-type-popover-title {
  font-family: Orbitron, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #ffe9a0;
  text-align: center;
  padding: 2px 0 4px;
  letter-spacing: 0.03em;
}

.mc-type-option {
  appearance: none;
  border: 1px solid rgba(120, 160, 255, 0.3);
  background: rgba(20, 28, 56, 0.95);
  color: #e8eeff;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: Orbitron, monospace;
}

.mc-type-option strong {
  font-size: 12px;
  font-weight: 700;
}

.mc-type-option span {
  font-size: 10px;
  font-weight: 400;
  color: rgba(190, 210, 255, 0.8);
  line-height: 1.3;
}

.mc-type-option.is-active {
  border-color: rgba(255, 220, 100, 0.8);
  background: rgba(60, 48, 16, 0.95);
}

.mc-type-info-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.mc-type-info-modal[hidden] {
  display: none !important;
}

.mc-type-info-card {
  max-width: 360px;
  width: 100%;
  background: rgba(10, 14, 32, 0.98);
  border: 1px solid rgba(120, 160, 255, 0.45);
  border-radius: 12px;
  padding: 16px 18px;
  color: rgba(230, 235, 255, 0.95);
  font-family: Orbitron, monospace;
}

.mc-type-info-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #ffe9a0;
}

.mc-type-info-card p,
.mc-type-info-card li {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(210, 220, 245, 0.9);
}

.mc-type-info-card ul {
  margin: 10px 0 14px;
  padding-left: 1.2em;
}

.mc-type-info-close {
  width: 100%;
  min-height: 40px;
}
