.battle-container {
  min-height: calc(100vh - 60px);
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
  padding: 40px 20px;
}

.battle-header {
  text-align: center;
  margin-bottom: 40px;
  color: #ffd534;
}

.battle-header h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
  font-size: 1.2rem;
  color: #cccccc;
  margin: 0;
}

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #ffd534;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 213, 52, 0.1);
  border-top-color: #ffd534;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 10px;
}

.wallet-prompt {
  text-align: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  border: 2px solid #ffd534;
}

.wallet-prompt h2 {
  color: #ffd534;
  margin: 20px 0;
}

.wallet-prompt p {
  color: #cccccc;
  font-size: 1.1rem;
}

.battle-content {
  max-width: 1400px;
  margin: 0 auto;
}

.selection-phase {
  display: block;
}

.selection-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.section-header {
  text-align: center;
}

.section-title {
  color: #ffd534;
  font-size: 1.8rem;
  margin: 0 0 20px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#battle-content .card-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px;
}

.guardian-selection {
  flex: 1;
}

.guardian-selection h2 {
  color: #ffd534;
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.8rem;
}

.guardian-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px;
}

.guardian-card {
  position: relative;
  background: #2a3248;
  /* Acts as border color */
  /* Chamfered edges using clip-path */
  clip-path: polygon(20px 0, 100% 0,
      100% calc(100% - 20px), calc(100% - 20px) 100%,
      0 100%, 0 20px);
  border: none;
  border-radius: 0;
  padding: 2px;
  /* Border width */
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.guardian-card-inner {
  background: #101320;
  clip-path: polygon(19px 0, 100% 0,
      100% calc(100% - 19px), calc(100% - 19px) 100%,
      0 100%, 0 19px);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.guardian-card:hover {
  background: #444;
  /* Hover border color */
  transform: translateY(-2px);
}

.guardian-card.selected {
  background: #ffd534;
  /* Selected border color */
  transform: translateY(-2px);
  filter: drop-shadow(0 0 12px rgba(255, 213, 52, 0.4));
}

/* --- Header --- */
.guardian-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.guardian-identity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.polygon-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* Ensure polygon styles from styles.css work here */
.polygon-title {
  width: 32px;
  height: 32px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Add background and border to match styles.css */
  background: linear-gradient(135deg, #00fff0 60%, #8c52ff 100%);
  box-shadow: 0 0 8px #00fff044, 0 0 1px #8c52ff;
  border: 2px solid #00fff0;
}

.polygon-level {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #000;
  /* Dark color for visibility on bright polygons */
  z-index: 2;
  text-shadow: none;
  padding-top: 4px;
  /* Visual adjustment for triangle centering */
}

.guardian-title {
  font-size: 0.8rem;
  color: #00fff0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.guardian-id {
  font-family: "Share Tech Mono", monospace;
  color: #7afde2;
  font-size: 1rem;
  opacity: 0.9;
}

/* --- Image --- */
.guardian-image-container {
  width: 100%;
  height: 260px;
  /* Taller image */
  background: radial-gradient(circle at center, #28324f 0%, #0b0e14 70%);
  /* Chamfered image corners */
  clip-path: polygon(8px 0, 100% 0,
      100% calc(100% - 8px), calc(100% - 8px) 100%,
      0 100%, 0 8px);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  /* Align image to bottom */
  justify-content: center;
  /* border removed to avoid clipping issues */
}

.guardian-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.guardian-card:hover .guardian-image-container img {
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .guardian-image-container {
    height: 180px;
    /* Reduce height on mobile */
  }
}

/* --- Bars --- */
.guardian-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.bar-label {
  width: 20px;
  color: #888;
  font-weight: bold;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: #000;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
}

.xp-fill {
  background: linear-gradient(90deg, #00ffae, #00fff0);
}

.energy-fill {
  background: linear-gradient(90deg, #b8002f, #ffd534);
}

/* --- Stats Grid --- */
.guardian-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  font-size: 0.65rem;
  color: #ccc;
  padding: 4px 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  /* Stack icon and value for square shape */
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
  background: #0b0e14;
  padding: 2px;
  aspect-ratio: 1;
  /* Make it square */
  /* Chamfered stats */
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
  /* border removed as requested */
  /* Ensure content doesn't spill */
}

@media (max-width: 768px) {
  .stat-item {
    aspect-ratio: auto;
    /* Remove square constraint on mobile */
    padding: 6px 2px;
    font-size: 0.8rem;
    /* Increase font size */
  }

  .stat-item i {
    font-size: 0.9rem;
  }

  .guardian-stats-grid {
    gap: 6px;
  }
}

.stat-item i {
  color: #555;
  font-size: 0.8rem;
  margin-bottom: 1px;
}

/* --- Ability Slots --- */
.ability-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.ability-slot {
  background: #161a26;
  aspect-ratio: 1;
  /* Make it square */
  height: auto;
  /* Let aspect-ratio control height */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #888;
  /* Chamfered slots */
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  /* border removed */
}

.ability-slot.equipped {
  color: #ffd534;
  background: #2a2a1a;
  border-color: #ffd534;
}

/* --- Overlay --- */
.guardian-select-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
  color: #ffd534;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
  /* Match card chamfer */
  clip-path: polygon(20px 0, 100% 0,
      100% calc(100% - 20px), calc(100% - 20px) 100%,
      0 100%, 0 20px);
}

.guardian-card.selected .guardian-select-overlay {
  opacity: 1;
}

.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  flex-shrink: 0;
}

.vs-text {
  font-size: 3rem;
  font-weight: bold;
  color: #ffd534;
  text-shadow: 0 0 20px rgba(255, 213, 52, 0.8);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.battle-phase {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.battle-arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 30px;
  align-items: start;
  padding: 20px;
}

.battle-phase .battle-arena {
  max-width: 1100px;
  margin: 0 auto;
}

.fighter-card {
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  border: 3px solid #ffd534;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.fighter-card.left-fighter {
  border-color: #21bf96;
}

.fighter-card.right-fighter {
  border-color: #cc0000;
}

.fighter-image-container {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 20px;
  border-radius: 15px;
  overflow: hidden;
  border: 3px solid rgba(255, 213, 52, 0.3);
}

.fighter-image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.fighter-stats {
  color: #fff;
}

.fighter-stats h3 {
  color: #ffd534;
  text-align: center;
  margin: 0 0 20px 0;
  font-size: 1.5rem;
}

.stat-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1.1rem;
}

.stat-value {
  font-weight: bold;
  color: #ffd534;
}

.health-bar {
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 15px;
  overflow: hidden;
  margin-top: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #21bf96 0%, #ffd534 100%);
  transition: width 1s ease;
  box-shadow: 0 0 10px rgba(33, 191, 150, 0.5);
}

.battle-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
  min-width: 300px;
}

.battle-log {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #444;
  border-radius: 15px;
  padding: 15px;
  max-height: 300px;
  overflow-y: auto;
  min-height: 200px;
}

.log-entry {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #ffd534;
}

.log-entry.log-success {
  border-left-color: #21bf96;
  background: rgba(33, 191, 150, 0.1);
}

.log-entry.log-error {
  border-left-color: #cc0000;
  background: rgba(204, 0, 0, 0.1);
}

.log-entry.log-info {
  border-left-color: #3498db;
  background: rgba(52, 152, 219, 0.1);
}

.log-time {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 5px;
}

.log-message {
  color: #fff;
  font-size: 0.95rem;
}

.attack-button {
  background: linear-gradient(135deg, #ffd534 0%, #febc15 100%);
  color: #000;
  border: none;
  padding: 20px 40px;
  font-size: 1.3rem;
  font-weight: bold;
  border-radius: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s ease;
  box-shadow: 0 5px 20px rgba(255, 213, 52, 0.4);
}

.attack-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 213, 52, 0.6);
}

.attack-button:active:not(:disabled) {
  transform: translateY(0);
}

.attack-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-icon {
  font-size: 1.5rem;
}

.back-button {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 2px solid #666;
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: #ffd534;
}

.fighter-card.attacking {
  animation: attackShake 0.6s ease;
}

@keyframes attackShake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-10px);
  }

  75% {
    transform: translateX(10px);
  }
}

.fighter-card.defeated {
  opacity: 0.5;
  filter: grayscale(100%);
  transition: all 1s ease;
}

@media (max-width: 1200px) {
  .battle-arena {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .selection-phase {
    grid-template-columns: 1fr;
  }

  .vs-divider {
    width: 100%;
    padding: 20px 0;
    transform: rotate(90deg);
  }
}

@media (max-width: 768px) {
  .battle-header h1 {
    font-size: 2rem;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .guardian-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .battle-controls {
    min-width: 100%;
  }

  .attack-button {
    padding: 15px 30px;
    font-size: 1.1rem;
  }

  .section-title {
    font-size: 1.4rem;
  }

  .vs-text {
    font-size: 2rem;
  }
}

/* --- Opponent selection modal --- */
.battle-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: flex-start;
  /* Changed from center to allow scrolling */
  justify-content: center;
  overflow-y: auto;
  /* Enable vertical scrolling */
  padding: 20px 0;
  /* Add vertical padding */
}

.battle-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.battle-modal-dialog {
  position: relative;
  z-index: 1;
  max-width: 900px;
  /* Scaled down from 1100px */
  width: 95%;
  margin: auto;
  /* Center horizontally */
  background: #ffd534;
  /* Border color */
  /* Chamfered edges */
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
  padding: 2px;
  /* Border width */
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.battle-modal-content {
  background: linear-gradient(135deg, #1b1b1b 0%, #262626 100%);
  /* Inner chamfer to create border effect */
  clip-path: polygon(19px 0, 100% 0, 100% calc(100% - 19px), calc(100% - 19px) 100%, 0 100%, 0 19px);
  padding: 24px;
  width: 100%;
  height: 100%;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 24px;
  /* Adjusted for chamfer */
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  z-index: 10;
}

.battle-modal-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.modal-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.modal-column-vs {
  align-items: center;
  justify-content: center;
}

.modal-title {
  color: #ffd534;
  font-size: 1.25rem;
  margin: 0;
  text-align: center;
}

/* Carousel Wrapper */
.opponent-carousel-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  width: 100%;
  justify-content: center;
}

.carousel-arrow {
  background: rgba(255, 213, 52, 0.1);
  border: 1px solid #ffd534;
  color: #ffd534;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.carousel-arrow:hover {
  background: #ffd534;
  color: #000;
  transform: scale(1.1);
}

.carousel-arrow:active {
  transform: scale(0.95);
}

/* Footer & Input */
.battle-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #444;
  padding-top: 20px;
  gap: 20px;
}

.opponent-manual-input {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #444;
}

.input-label {
  color: #888;
  font-size: 0.9rem;
}

.modal-input {
  background: transparent;
  border: 1px solid #666;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  width: 80px;
  text-align: center;
}

.modal-input:focus {
  border-color: #ffd534;
  outline: none;
}

.btn-large {
  padding: 12px 40px;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* Scale down cards in modal */
.battle-modal-body .guardian-image-container {
  height: 160px;
  /* Reduced from 200px for better mobile fit */
}

.battle-modal-body .guardian-card {
  font-size: 0.9em;
  /* Slightly smaller text */
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .battle-modal-body {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  /* ... rest of media query ... */

  .vs-text {
    transform: rotate(90deg);
    margin: 10px 0;
  }

  .battle-modal-footer {
    flex-direction: column;
    gap: 16px;
  }

  .opponent-manual-input {
    width: 100%;
    justify-content: center;
  }
}

/* reuse card-grid sizing similar to attack.html */
.modal-opponent-grid.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* mobile tweaks */
@media (max-width: 900px) {
  .battle-modal-body {
    grid-template-columns: 1fr;
  }

  .modal-column-vs {
    order: -1;
    flex-direction: row;
    justify-content: center;
  }

  .modal-guardian-card {
    flex-direction: column;
    align-items: center;
  }
}

/* Battle result banner styles */
.battle-result-banner {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
}

.battle-result-success {
  background: linear-gradient(90deg, #0f0c29, #00c853);
}

.battle-result-error {
  background: linear-gradient(90deg, #3a1c1c, #ff5252);
}

.battle-result-info {
  background: linear-gradient(90deg, #1e3c72, #2a5298);
}

/* Button ready pulse used when confirm button is enabled */
.ready-pulse {
  animation: readyPulse 1.2s infinite ease-in-out;
}

@keyframes readyPulse {
  0% {
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(255, 197, 0, 0.0);
  }

  50% {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(255, 197, 0, 0.18);
  }

  100% {
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(255, 197, 0, 0.0);
  }
}

.log-entry.log-ability {
  border-left-color: #9c27b0;
  background: rgba(156, 39, 176, 0.1);
}
