:root {
  --party-hud-bottom: 10px;
  --party-hud-height: 0px;
  --party-hud-columns: 6;
  --party-slot-size: 52px;
}

.bottom-hud-dock {
  position: fixed;
  bottom: calc(var(--party-hud-bottom) + env(safe-area-inset-bottom, 0px));
  left: calc(var(--hud-left-inset, 12px) + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 8px;
  z-index: 1000;
  max-width: min(96vw, 980px);
  pointer-events: none;
}

.bottom-hud-dock > * {
  pointer-events: auto;
}

#pokemon-party-ui {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #555;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: auto;
  max-width: 100%;
  font-family: 'Arial', sans-serif;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.party-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.party-recall-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: #d8d8d8;
  opacity: 0.9;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.party-recall-btn__icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.party-recall-btn:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.08);
}

.party-recall-btn:focus-visible {
  outline: 1px solid rgba(200, 200, 200, 0.65);
  outline-offset: 2px;
}

.party-recall-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  transform: none;
}

.party-stance-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 22px;
  padding: 0 6px;
  margin: 2px 0 0;
  border: 1px solid #666;
  border-radius: 4px;
  background: rgba(40, 40, 48, 0.95);
  color: #d8d8d8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.party-stance-btn:hover {
  transform: scale(1.04);
}

.party-stance-btn:focus-visible {
  outline: 1px solid rgba(200, 200, 200, 0.65);
  outline-offset: 2px;
}

.party-stance-btn.is-neutral {
  border-color: #6a6a72;
  color: #b8b8c0;
}

.party-stance-btn.is-defender {
  border-color: #3d7a9e;
  background: rgba(30, 58, 78, 0.95);
  color: #9ed4f0;
}

.party-stance-btn.is-agro {
  border-color: #9e3d3d;
  background: rgba(78, 30, 30, 0.95);
  color: #f0a0a0;
}

.party-stance-btn__label {
  pointer-events: none;
  white-space: nowrap;
}

#party-bar-slots {
  display: grid;
  grid-template-columns: repeat(var(--party-hud-columns), var(--party-slot-size));
  justify-content: center;
  align-content: flex-start;
  gap: 6px;
  flex: 1;
  min-width: 0;
  max-height: 118px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 120, 0.6) transparent;
}

#pokemon-party-ui .pokemon-slot {
  width: var(--party-slot-size);
  height: var(--party-slot-size);
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.2s, opacity 0.2s;
  cursor: pointer;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

#pokemon-party-ui .pokemon-slot:not(.empty):hover {
  border-color: #888;
}

#pokemon-party-ui .pokemon-slot.active {
  border-color: #ffd700;
  border-width: 3px;
}

#pokemon-party-ui .pokemon-slot.out {
  border-color: #4a9eff;
  border-width: 3px;
}

#pokemon-party-ui .pokemon-slot.in-ball {
  border-color: #666;
  border-width: 2px;
  border-style: dashed;
  filter: grayscale(0.35);
}

#pokemon-party-ui .pokemon-slot.fainted {
  border-color: #8a4a4a;
  border-style: dashed;
  background: linear-gradient(180deg, #2a2228 0%, #1e1a22 100%);
  filter: grayscale(0.85) brightness(0.72);
  box-shadow: inset 0 0 0 1px rgba(180, 90, 90, 0.35);
}

#pokemon-party-ui .pokemon-slot.fainted .pokemon-slot__portrait,
#pokemon-party-ui .pokemon-slot.fainted .pokemon-slot__fallback {
  opacity: 0.45;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 3px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3ecf6a 0%, #6fe88f 100%);
  transition: width 0.2s ease, background 0.2s ease;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp-fill.is-mid {
  background: linear-gradient(90deg, #d4a82a 0%, #f0c84a 100%);
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp-fill.is-low {
  background: linear-gradient(90deg, #c43c3c 0%, #f06060 100%);
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp-fill.is-empty {
  width: 0 !important;
  background: #555;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__hp-text {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #c8e8c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 2;
}

#pokemon-party-ui .pokemon-slot.fainted .pokemon-slot__hp-text {
  color: #f0a0a0;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__faint-mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: rgba(240, 120, 120, 0.55);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 1;
}

#pokemon-party-ui .pokemon-slot .pokemon-slot__faint-mark[hidden] {
  display: none;
}

#pokemon-party-ui .pokemon-slot.symbiosis {
  border-color: #b886db;
  border-width: 3px;
  box-shadow:
    0 0 10px rgba(184, 134, 219, 0.8),
    0 0 20px rgba(184, 134, 219, 0.6),
    0 0 30px rgba(184, 134, 219, 0.4);
  animation: symbiosisGlow 2s ease-in-out infinite;
}

@keyframes symbiosisGlow {
  0%, 100% {
    box-shadow:
      0 0 10px rgba(184, 134, 219, 0.8),
      0 0 20px rgba(184, 134, 219, 0.6),
      0 0 30px rgba(184, 134, 219, 0.4);
  }
  50% {
    box-shadow:
      0 0 15px rgba(184, 134, 219, 1),
      0 0 30px rgba(184, 134, 219, 0.8),
      0 0 45px rgba(184, 134, 219, 0.6);
  }
}

#pokemon-party-ui .pokemon-slot.empty {
  border-style: dashed;
  border-color: #555;
}

#pokemon-party-ui .pokemon-slot.empty::after {
  content: '?';
  color: #666;
  font-size: 24px;
  font-weight: bold;
}

#pokemon-party-ui .pokemon-slot:not(.empty) {
  border-color: #666;
}

#pokemon-party-ui .pokemon-slot .slot-number {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #888;
  font-size: 10px;
  font-weight: bold;
  z-index: 1;
  pointer-events: none;
}

#pokemon-party-ui .pokemon-slot__portrait {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

#pokemon-party-ui .pokemon-slot__fallback {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

#symbiosis-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a1a3a 0%, #3a2a5a 50%, #1a1a2a 100%);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  font-family: 'Arial', sans-serif;
  font-weight: bold;
  font-size: 11px;
  color: #ffffff;
  text-shadow: 0 0 6px rgba(150, 100, 200, 0.9);
  box-shadow:
    0 0 20px rgba(100, 50, 150, 0.6),
    inset 0 0 30px rgba(150, 100, 200, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.5);
  padding: 0;
  flex-shrink: 0;
}

#symbiosis-button::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8a7a9a, #6a5a7a, #9a8aaa, #7a6a8a);
  z-index: -1;
}

#symbiosis-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(150, 100, 200, 0.8) 0%, rgba(100, 50, 150, 0.6) 50%, transparent 100%);
  animation: symbiosisBtnPulse 2s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

@keyframes symbiosisBtnPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.9; }
}

#symbiosis-button:hover:not(.disabled) {
  box-shadow:
    0 0 30px rgba(150, 100, 200, 0.9),
    inset 0 0 40px rgba(180, 130, 230, 0.4),
    0 6px 12px rgba(0, 0, 0, 0.6);
  transform: scale(1.08);
}

#symbiosis-button:hover:not(.disabled)::before {
  background: linear-gradient(135deg, #aa9aba, #8a7a9a, #baaaca, #9a8aaa);
}

#symbiosis-button.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

#symbiosis-button.disabled::before {
  background: linear-gradient(135deg, #555, #444, #555, #444);
}

#symbiosis-button.disabled::after {
  display: none;
}

#symbiosis-button.active {
  background: linear-gradient(135deg, #4a2a6a 0%, #5a3a7a 50%, #3a1a5a 100%);
  box-shadow:
    0 0 40px rgba(200, 150, 255, 1),
    inset 0 0 50px rgba(220, 170, 255, 0.5),
    0 6px 12px rgba(0, 0, 0, 0.6);
  animation: symbiosisBtnActivePulse 1.5s ease-in-out infinite;
}

#symbiosis-button.active::before {
  background: linear-gradient(135deg, #ba9aca, #aa8aba, #caaada, #ba9aca);
  animation: symbiosisBtnBorderGlow 2s ease-in-out infinite;
}

#symbiosis-button.active::after {
  background: radial-gradient(circle, rgba(220, 170, 255, 1) 0%, rgba(200, 150, 255, 0.8) 50%, transparent 100%);
  animation: symbiosisBtnActiveInner 1.5s ease-in-out infinite;
}

@keyframes symbiosisBtnActivePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 40px rgba(200, 150, 255, 1),
      inset 0 0 50px rgba(220, 170, 255, 0.5),
      0 6px 12px rgba(0, 0, 0, 0.6);
  }
  50% {
    transform: scale(1.05);
    box-shadow:
      0 0 60px rgba(220, 170, 255, 1.2),
      inset 0 0 60px rgba(240, 190, 255, 0.6),
      0 8px 16px rgba(0, 0, 0, 0.7);
  }
}

@keyframes symbiosisBtnActiveInner {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  50% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
}

@keyframes symbiosisBtnBorderGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

#symbiosis-button.active:hover {
  transform: scale(1.1);
}

#symbiosis-button .button-text {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.2;
}
