* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 25%, #2d1b4e 50%, #1a0a2e 75%, #0a0a1a 100%);
  background-size: 400% 400%;
  animation: magicalGradient 15s ease infinite;
  color: #e6d5ff;
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
  position: relative;
}

/* Animated starry background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 60% 70%, white, transparent),
    radial-gradient(1px 1px at 50% 50%, white, transparent),
    radial-gradient(1px 1px at 80% 10%, white, transparent),
    radial-gradient(2px 2px at 90% 60%, white, transparent),
    radial-gradient(1px 1px at 33% 80%, white, transparent),
    radial-gradient(2px 2px at 15% 90%, white, transparent);
  background-size: 200% 200%;
  animation: starTwinkle 8s ease-in-out infinite;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

@keyframes magicalGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

h1 {
  text-align: center;
  font-size: 3.5rem;
  margin-bottom: 20px;
  color: #c49dff;
  letter-spacing: 6px;
  font-weight: bold;
}


.game-status {
  background: rgba(109, 40, 217, 0.2);
  border: 2px solid #8b5cf6;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
  box-shadow:
    0 0 20px rgba(139, 92, 246, 0.3),
    inset 0 0 20px rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(10px);
}

#status-text {
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: #fbbf24;
  font-weight: bold;
}

#instruction-text {
  font-size: 1.1rem;
  color: #d8b4fe;
  font-style: italic;
}

.ship-list {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 0 25px rgba(167, 139, 250, 0.3), inset 0 0 60px rgba(139, 92, 246, 0.1);
  position: relative;
  overflow: hidden;
}

/* Magical star field background */
.ship-list::before {
  content: '✦';
  position: absolute;
  top: 15%;
  left: 20%;
  font-size: 8px;
  color: rgba(255, 255, 255, 0.6);
  animation: twinkle 3s infinite ease-in-out;
}

.ship-list::after {
  content: '✦';
  position: absolute;
  top: 60%;
  right: 15%;
  font-size: 12px;
  color: rgba(167, 139, 250, 0.8);
  animation: twinkle 2.5s infinite ease-in-out 0.5s;
}

.ship-list h3 {
  margin-bottom: 15px;
  color: #fbbf24;
  font-size: 1.3rem;
  text-align: center;
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
  position: relative;
  z-index: 1;
}

.ships {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.ship-item {
  background: rgba(167, 139, 250, 0.12);
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.3);
  display: flex;
  gap: 8px;
  align-items: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(30, 27, 75, 0.5), 0 0 20px rgba(167, 139, 250, 0.2);
  position: relative;
  overflow: hidden;
}

/* Magical star particles on each ship card */
.ship-item::before {
  content: '✦';
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  animation: twinkle 2s infinite ease-in-out;
  pointer-events: none;
}

.ship-item::after {
  content: '·';
  position: absolute;
  bottom: 10px;
  right: 30px;
  font-size: 14px;
  color: rgba(167, 139, 250, 0.5);
  animation: twinkle 3s infinite ease-in-out 1s;
  pointer-events: none;
}

.ship-item:hover {
  transform: translateY(-3px);
  background: rgba(167, 139, 250, 0.2);
  box-shadow: 0 6px 20px rgba(30, 27, 75, 0.6), 0 0 30px rgba(167, 139, 250, 0.5);
  border-color: rgba(167, 139, 250, 0.6);
}

/* Shimmer effect on hover */
.ship-item:hover::before {
  animation: twinkle 0.8s infinite ease-in-out;
}

.ship-item:hover::after {
  animation: twinkle 1s infinite ease-in-out 0.3s;
}

.ship-item.placed {
  background: rgba(74, 222, 128, 0.2);
  border-color: #10b981;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
  animation: placedPulse 2s ease-in-out infinite;
}

@keyframes placedPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(16, 185, 129, 0.5); }
  50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.8); }
}

/* Magical constellation twinkle animation */
@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.ship-name {
  font-weight: bold;
  color: #e9d5ff;
}

.ship-length {
  color: #c4b5fd;
  font-size: 0.9rem;
}

.ship-status {
  font-size: 1.2rem;
  filter: drop-shadow(0 0 5px currentColor);
}

.boards-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 30px;
  justify-content: center;
  margin-bottom: 30px;
  align-items: start; /* Keep tops aligned, boards will auto-stretch */
}

.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%; /* Fill grid cell height */
  justify-content: flex-start; /* Align content to top */
}

.board-wrapper h3 {
  margin-bottom: 15px;
  font-size: 1.5rem;
  color: #fbbf24;
}


.board {
  display: grid;
  grid-template-columns: repeat(10, 40px);
  grid-template-rows: repeat(10, 40px);
  gap: 2px;
  background: rgba(109, 40, 217, 0.3);
  padding: 10px;
  border-radius: 15px;
  box-shadow:
    0 0 30px rgba(139, 92, 246, 0.5),
    inset 0 0 20px rgba(139, 92, 246, 0.2);
  border: 2px solid #8b5cf6;
  position: relative;
}

.board::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #8b5cf6, #6d28d9, #7c3aed, #8b5cf6);
  background-size: 300% 300%;
  animation: borderGlow 4s ease infinite;
  border-radius: 15px;
  z-index: -1;
  opacity: 0.5;
}

@keyframes borderGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.cell {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 100%);
  border: 1px solid #6d28d9;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cell:hover::before {
  opacity: 1;
}

.cell:hover {
  background: linear-gradient(135deg, #2d1b4e 0%, #3d2b5e 100%);
  transform: scale(1.08);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
  border-color: #8b5cf6;
}

.cell.ship {
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 50%, #5b21b6 100%);
  border-color: #8b5cf6;
  box-shadow:
    0 0 10px rgba(139, 92, 246, 0.5),
    inset 0 0 10px rgba(167, 139, 250, 0.3);
  animation: shipGlow 2s ease-in-out infinite;
}

@keyframes shipGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(139, 92, 246, 0.5), inset 0 0 10px rgba(167, 139, 250, 0.3); }
  50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.8), inset 0 0 15px rgba(167, 139, 250, 0.5); }
}

.cell.ship::after {
  content: '✨';
  font-size: 1.5rem;
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.8; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 1; }
}

.cell.preview {
  background: rgba(139, 92, 246, 0.4);
  border-color: #a78bfa;
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.6);
}

.cell.preview-invalid {
  background: rgba(239, 68, 68, 0.4);
  border-color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

/* Mobile ship placement ghost styles */
.cell.mobile-ghost {
  background: rgba(139, 92, 246, 0.7);
  border-color: #a78bfa;
  box-shadow: 0 0 25px rgba(167, 139, 250, 0.9);
  animation: mobileGhostPulse 1.2s ease-in-out infinite;
  transform: scale(1.1);
  z-index: 100;
  position: relative;
}

@keyframes mobileGhostPulse {
  0%, 100% {
    box-shadow: 0 0 25px rgba(167, 139, 250, 0.9);
    transform: scale(1.1);
    opacity: 0.85;
  }
  50% {
    box-shadow: 0 0 35px rgba(167, 139, 250, 1);
    transform: scale(1.15);
    opacity: 1;
  }
}

.cell.mobile-ghost::after {
  content: '👻';
  position: absolute;
  font-size: 1.5rem;
  animation: ghostFloat 1s ease-in-out infinite;
}

@keyframes ghostFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}

/* Mobile ghost "ready to confirm" state - brighter, more vibrant */
.cell.mobile-ghost-ready {
  background: rgba(16, 185, 129, 0.8) !important;
  border-color: #34d399 !important;
  box-shadow: 0 0 35px rgba(16, 185, 129, 1) !important;
  animation: mobileGhostReadyPulse 0.6s ease-in-out infinite !important;
  transform: scale(1.15) !important;
}

@keyframes mobileGhostReadyPulse {
  0%, 100% {
    box-shadow: 0 0 35px rgba(16, 185, 129, 1);
    transform: scale(1.15);
    opacity: 0.95;
  }
  50% {
    box-shadow: 0 0 50px rgba(16, 185, 129, 1), 0 0 25px rgba(16, 185, 129, 0.8);
    transform: scale(1.2);
    opacity: 1;
  }
}

.cell.mobile-ghost-ready::after {
  content: '✓';
  position: absolute;
  font-size: 2rem;
  color: #10b981;
  font-weight: bold;
  animation: readyCheckmark 0.6s ease-in-out infinite;
  text-shadow: 0 0 10px rgba(16, 185, 129, 1);
}

@keyframes readyCheckmark {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.2) rotate(10deg);
    opacity: 1;
  }
}

.cell.mobile-ghost-invalid {
  background: rgba(239, 68, 68, 0.7);
  border-color: #f87171;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.9);
  animation: mobileGhostShake 0.4s ease-in-out infinite;
  transform: scale(1.1);
  z-index: 100;
  position: relative;
}

@keyframes mobileGhostShake {
  0%, 100% { transform: translateX(0) scale(1.1); }
  25% { transform: translateX(-3px) scale(1.1); }
  75% { transform: translateX(3px) scale(1.1); }
}

.cell.mobile-ghost-invalid::after {
  content: '⚠️';
  position: absolute;
  font-size: 1.5rem;
  animation: warningPulse 0.5s ease-in-out infinite;
}

@keyframes warningPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.cell.hit {
  background: radial-gradient(circle, #dc2626 0%, #991b1b 100%);
  border-color: #fbbf24;
  animation: hitAnimation 0.6s ease;
  box-shadow:
    0 0 20px rgba(220, 38, 38, 0.8),
    0 0 40px rgba(251, 191, 36, 0.6);
}

.cell.hit::after {
  content: '💥';
  font-size: 1.8rem;
  animation: explosionSpin 0.6s ease;
}

@keyframes hitAnimation {
  0% { transform: scale(1); }
  25% { transform: scale(1.4) rotate(5deg); }
  50% { transform: scale(1.2) rotate(-5deg); }
  75% { transform: scale(1.3) rotate(3deg); }
  100% { transform: scale(1); }
}

@keyframes explosionSpin {
  0% { transform: scale(0.5) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(180deg); opacity: 1; }
  100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

.cell.miss {
  background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
  border-color: #6b7280;
  box-shadow: 0 0 10px rgba(107, 114, 128, 0.5);
}

.cell.miss::after {
  content: '💨';
  font-size: 1.2rem;
  opacity: 0.7;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 0.7; transform: scale(1); }
}

/* Oil Spill - Multi-turn expanding power-up */
.cell.oil-spill {
  background: radial-gradient(circle, #0a0a0a 0%, #1a1a1a 50%, #2a2a2a 100%);
  border-color: #3a3a3a;
  box-shadow:
    0 0 15px rgba(10, 10, 10, 0.9),
    inset 0 0 20px rgba(0, 0, 0, 0.8);
  animation: oilSpread 1s ease-out;
  position: relative;
  overflow: hidden;
  transform: translateZ(0); /* GPU acceleration */
  will-change: transform, opacity;
  backface-visibility: hidden;
}

/* Oil spill size indicators */
.cell.oil-spill-size-1::before {
  content: '🛢️';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  z-index: 2;
  animation: oilPulse 2s infinite;
}

.cell.oil-spill-size-2::before {
  content: '🛢️';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  z-index: 2;
  animation: oilPulse 2s infinite;
  filter: brightness(1.2);
}

.cell.oil-spill-size-3::before {
  content: '🛢️';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  z-index: 2;
  animation: oilPulse 2s infinite;
  filter: brightness(1.5);
}

/* Oil slick texture animation */
.cell.oil-spill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(50, 50, 50, 0.3) 10px,
    rgba(50, 50, 50, 0.3) 20px
  );
  animation: oilFlow 3s linear infinite;
  opacity: 0.5;
  z-index: 1;
}

@keyframes oilSpread {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes oilFlow {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 40px;
  }
}

/* Oil spill combined with hit */
.cell.oil-spill.hit {
  background: radial-gradient(circle, #dc2626 0%, #0a0a0a 60%, #1a1a1a 100%);
  box-shadow:
    0 0 20px rgba(220, 38, 38, 0.8),
    0 0 40px rgba(10, 10, 10, 0.9);
}

/* Oil spill combined with miss */
.cell.oil-spill.miss {
  background: radial-gradient(circle, #374151 0%, #0a0a0a 60%, #1a1a1a 100%);
  box-shadow:
    0 0 10px rgba(107, 114, 128, 0.5),
    0 0 20px rgba(10, 10, 10, 0.9);
}

.cell.ship-revealed {
  background: rgba(139, 92, 246, 0.3);
  border-color: #6d28d9;
  animation: revealPulse 1s ease-in-out;
}

.cell.ship-revealed::after {
  content: '⚓';
  font-size: 1.3rem;
  opacity: 0.6;
  color: #a78bfa;
  text-shadow: 0 0 10px #8b5cf6;
}

@keyframes revealPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  color: #fff;
  border: 2px solid #8b5cf6;
  padding: 12px 30px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  box-shadow:
    0 4px 15px rgba(109, 40, 217, 0.4),
    inset 0 0 10px rgba(167, 139, 250, 0.2);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  border-color: #a78bfa;
  transform: translateY(-2px);
  box-shadow:
    0 6px 25px rgba(139, 92, 246, 0.6),
    inset 0 0 15px rgba(167, 139, 250, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow:
    0 2px 10px rgba(109, 40, 217, 0.4),
    inset 0 0 10px rgba(167, 139, 250, 0.2);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border-color: #ef4444;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #fca5a5;
  box-shadow:
    0 6px 25px rgba(239, 68, 68, 0.6),
    inset 0 0 15px rgba(252, 165, 165, 0.3);
}

.message-log {
  background: rgba(109, 40, 217, 0.15);
  border: 2px solid #7c3aed;
  border-radius: 15px;
  padding: 15px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow:
    0 0 20px rgba(124, 58, 237, 0.3),
    inset 0 0 10px rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(5px);
}

.message {
  padding: 8px 12px;
  margin-bottom: 5px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
  border-left: 3px solid #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
  color: #e9d5ff;
  transition: all 0.3s ease;
  animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
  0% { transform: translateX(-20px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

.message:hover {
  background: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
  transform: translateX(5px);
}

.message:last-child {
  margin-bottom: 0;
}

/* Scrollbar styling - magical purple/gold theme */
.message-log::-webkit-scrollbar {
  width: 12px;
}

.message-log::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.message-log::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #8b5cf6 0%, #fbbf24 50%, #6d28d9 100%);
  border-radius: 6px;
  box-shadow:
    0 0 10px rgba(139, 92, 246, 0.6),
    0 0 20px rgba(251, 191, 36, 0.4);
  border: 1px solid rgba(251, 191, 36, 0.3);
  transition: all 0.3s ease;
}

.message-log::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #a78bfa 0%, #fcd34d 50%, #8b5cf6 100%);
  box-shadow:
    0 0 15px rgba(167, 139, 250, 0.8),
    0 0 25px rgba(251, 191, 36, 0.6);
  transform: scaleY(1.05);
  filter: brightness(1.2);
}

/* Firefox scrollbar styling */
.message-log {
  scrollbar-width: thin;
  scrollbar-color: #8b5cf6 rgba(109, 40, 217, 0.2);
}

/* Sound control button */
#sound-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  border: 2px solid #8b5cf6;
  color: white;
  padding: 12px 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(109, 40, 217, 0.6);
  transition: all 0.3s ease;
  z-index: 1000;
}

#sound-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.8);
}

#sound-toggle.muted {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  border-color: #9ca3af;
  box-shadow: 0 4px 15px rgba(107, 114, 128, 0.4);
}

/* Particle effect container */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

.particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: radial-gradient(circle, #fbbf24 0%, #f59e0b 100%);
  border-radius: 50%;
  box-shadow: 0 0 10px #fbbf24, 0 0 20px #f59e0b;
  animation: particleFloat 2s ease-out forwards;
  pointer-events: none;
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-200px) scale(0);
    opacity: 0;
  }
}

/* Power-up system styles */
#powerup-container {
  background: rgba(109, 40, 217, 0.15);
  border: 2px solid #7c3aed;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
  backdrop-filter: blur(5px);
}

.powerup-title {
  margin-bottom: 15px;
  color: #fbbf24;
  font-size: 1.5rem;
  text-align: center;
}

.powerup-btn {
  background: linear-gradient(135deg, var(--powerup-color, #6d28d9) 0%, rgba(0, 0, 0, 0.4) 100%);
  border: 2px solid var(--powerup-glow, #8b5cf6);
  border-radius: 12px;
  padding: 12px;
  margin: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-family: inherit;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 20px var(--powerup-glow, #8b5cf6);
  position: relative;
  overflow: hidden;
  min-width: 200px;
}

.powerup-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.powerup-btn:hover::before {
  width: 400px;
  height: 400px;
}

.powerup-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4), 0 0 40px var(--powerup-glow, #8b5cf6);
  border-color: #fff;
}

.powerup-btn:active {
  transform: translateY(-1px) scale(1);
}

.powerup-btn.active {
  animation: powerupActive 1s ease-in-out infinite;
  border-width: 3px;
  box-shadow: 0 0 40px var(--powerup-glow, #8b5cf6), inset 0 0 20px rgba(255, 255, 255, 0.3);
}

@keyframes powerupActive {
  0%, 100% {
    box-shadow: 0 0 40px var(--powerup-glow, #8b5cf6), inset 0 0 20px rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 60px var(--powerup-glow, #8b5cf6), inset 0 0 30px rgba(255, 255, 255, 0.5);
  }
}

.powerup-btn.depleted {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
  box-shadow: none;
}

.powerup-btn.depleted:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--powerup-glow, #8b5cf6);
}

.powerup-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 5px currentColor);
  z-index: 1;
}

.powerup-info {
  flex: 1;
  z-index: 1;
}

.powerup-name {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.powerup-desc {
  font-size: 0.85rem;
  opacity: 0.9;
  font-style: italic;
}

.powerup-uses {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(255, 255, 255, 0.2);
  z-index: 1;
}

/* Targeting overlay */
.board.targeting-mode {
  cursor: crosshair;
  box-shadow: 0 0 50px var(--powerup-glow, #8b5cf6), inset 0 0 30px rgba(255, 255, 255, 0.2);
  animation: targetingPulse 1.5s ease-in-out infinite;
}

@keyframes targetingPulse {
  0%, 100% {
    box-shadow: 0 0 50px rgba(139, 92, 246, 0.6), inset 0 0 30px rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 80px rgba(139, 92, 246, 0.9), inset 0 0 40px rgba(255, 255, 255, 0.3);
  }
}

.cell.target-preview {
  background: var(--preview-color, #8b5cf6) !important;
  border-color: #fff !important;
  box-shadow: 0 0 20px var(--preview-color, #8b5cf6), inset 0 0 10px rgba(255, 255, 255, 0.4);
  animation: targetBlink 0.5s ease-in-out infinite;
  transform: scale(1.1);
  z-index: 10;
}

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

/* EMP animation */
@keyframes empPulse {
  0% {
    filter: brightness(1);
    transform: scale(1);
  }
  25% {
    filter: brightness(2) hue-rotate(90deg);
    transform: scale(1.02);
  }
  50% {
    filter: brightness(0.5) hue-rotate(180deg);
    transform: scale(0.98);
  }
  75% {
    filter: brightness(2) hue-rotate(270deg);
    transform: scale(1.02);
  }
  100% {
    filter: brightness(1);
    transform: scale(1);
  }
}

/* Setup Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 50%, #1a0a2e 100%);
  border: 3px solid #8b5cf6;
  border-radius: 20px;
  padding: 40px;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(139, 92, 246, 0.8), inset 0 0 40px rgba(139, 92, 246, 0.2);
  animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
  0% { transform: translateY(-50px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
  text-align: center;
  font-size: 2.5rem;
  color: #fbbf24;
  margin-bottom: 30px;
}

.difficulty-section {
  margin-bottom: 30px;
}

.difficulty-section h3 {
  color: #c49dff;
  font-size: 1.5rem;
  margin-bottom: 15px;
  text-align: center;
}

.difficulty-options {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.difficulty-option {
  cursor: pointer;
}

.difficulty-option input[type="radio"] {
  display: none;
}

.difficulty-card {
  background: rgba(139, 92, 246, 0.2);
  border: 2px solid #6d28d9;
  border-radius: 12px;
  padding: 20px;
  min-width: 180px;
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.difficulty-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.6);
  border-color: #8b5cf6;
}

.difficulty-option input[type="radio"]:checked + .difficulty-card {
  border-color: #fbbf24;
  border-width: 3px;
  background: rgba(251, 191, 36, 0.2);
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.8);
  animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 40px rgba(251, 191, 36, 0.8); }
  50% { box-shadow: 0 0 60px rgba(251, 191, 36, 1); }
}

.difficulty-card.easy { border-color: #10b981; }
.difficulty-option input[type="radio"]:checked + .difficulty-card.easy {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.8);
}

.difficulty-card.medium { border-color: #f59e0b; }
.difficulty-option input[type="radio"]:checked + .difficulty-card.medium {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.8);
}

.difficulty-card.hard { border-color: #dc2626; }
.difficulty-option input[type="radio"]:checked + .difficulty-card.hard {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.2);
  box-shadow: 0 0 40px rgba(220, 38, 38, 0.8);
}

.difficulty-name {
  font-size: 1.3rem;
  font-weight: bold;
  color: #fbbf24;
  margin-bottom: 8px;
}

.difficulty-desc {
  font-size: 0.9rem;
  color: #d8b4fe;
  font-style: italic;
  margin-bottom: 12px;
}

.difficulty-stats {
  font-size: 0.85rem;
  color: #e9d5ff;
  line-height: 1.6;
}

/* Power-up Info Banner */
.powerup-info-banner {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(109, 40, 217, 0.2) 100%);
  border: 2px solid rgba(139, 92, 246, 0.5);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  animation: infoPulse 3s ease-in-out infinite;
}

@keyframes infoPulse {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
  }
  50% {
    box-shadow: 0 4px 25px rgba(139, 92, 246, 0.5);
  }
}

.powerup-info-banner .info-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 8px #fbbf24);
  animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.powerup-info-banner .info-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e9d5ff;
}

.powerup-info-banner .info-text strong {
  color: #fbbf24;
  font-weight: 700;
}

/* Power-up Charging Explanation Styles */
.charging-explanation {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.charging-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border-left: 3px solid rgba(251, 191, 36, 0.5);
  transition: all 0.3s ease;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform, background-color;
}

.charging-rule:hover {
  background: rgba(0, 0, 0, 0.35);
  border-left-color: #fbbf24;
  transform: translateX(4px);
}

.charging-rule .rule-icon {
  font-size: 1.2rem;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
  flex-shrink: 0;
}

.charging-rule .rule-text {
  font-size: 0.85rem;
  color: #e9d5ff;
  line-height: 1.4;
}

.charging-rule .rule-text strong {
  color: #c4b5fd;
  font-weight: 600;
}

.difficulty-reminder {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(251, 191, 36, 0.15);
  border-radius: 8px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  font-size: 0.85rem;
  color: #fde68a;
  text-align: center;
}

.difficulty-reminder strong {
  color: #fbbf24;
}

.loadout-section {
  margin-bottom: 30px;
}

.loadout-section h3 {
  color: #c49dff;
  font-size: 1.5rem;
  margin-bottom: 15px;
  text-align: center;
}

#slots-remaining {
  color: #fbbf24;
  font-size: 1.2rem;
}

.loadout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.loadout-card {
  background: linear-gradient(135deg, var(--powerup-color, #6d28d9) 0%, rgba(0, 0, 0, 0.4) 100%);
  border: 2px solid var(--powerup-glow, #8b5cf6);
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 20px var(--powerup-glow, #8b5cf6);
  position: relative;
  overflow: hidden;
}

.loadout-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4), 0 0 40px var(--powerup-glow, #8b5cf6);
}

.loadout-card.selected {
  border-color: #fbbf24;
  border-width: 3px;
  box-shadow: 0 0 50px #fbbf24;
  animation: loadoutSelected 1s ease-in-out infinite;
}

@keyframes loadoutSelected {
  0%, 100% { box-shadow: 0 0 50px #fbbf24; }
  50% { box-shadow: 0 0 70px #fbbf24; }
}

.loadout-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
}

.loadout-card-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 5px currentColor);
}

.loadout-card-info {
  flex: 1;
}

.loadout-card-name {
  font-weight: bold;
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 4px;
}

.loadout-card-desc {
  font-size: 0.85rem;
  color: #e9d5ff;
  opacity: 0.9;
  font-style: italic;
}

.loadout-card-earn {
  font-size: 0.75rem;
  color: #fbbf24;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  font-weight: 600;
  letter-spacing: 0.3px;
  display: inline-block;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

.btn-start {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #34d399;
  font-size: 1.3rem;
  padding: 15px 40px;
  width: 100%;
  margin-top: 20px;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
}

.btn-start:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 6px 30px rgba(16, 185, 129, 0.8);
}

.btn-start:disabled {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  border-color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

/* Notification System */
#notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.achievement-notification {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
  border: 2px solid #fbbf24;
  border-radius: 12px;
  padding: 15px 20px;
  min-width: 280px;
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.8), 0 4px 15px rgba(0, 0, 0, 0.5);
  animation: notificationSlideIn 0.5s ease, notificationFadeOut 0.5s ease 2.5s forwards;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  pointer-events: auto;
}

@keyframes notificationSlideIn {
  0% { transform: translateX(400px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes notificationFadeOut {
  0% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(400px); }
}

.notification-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 10px #fbbf24);
  animation: notificationBounce 0.6s ease;
}

@keyframes notificationBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.notification-text {
  flex: 1;
}

.notification-title {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.notification-desc {
  font-size: 0.85rem;
  opacity: 0.9;
  font-style: italic;
}

/* Board Header Stats (Integrated Design) */
.board-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 10px;
}

/* Battle Stats Column (Between Boards on Desktop) */
.battle-stats-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 15px;
  background: rgba(109, 40, 217, 0.3);
  border: 2px solid #8b5cf6;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  backdrop-filter: blur(10px);
  min-width: 200px;
  align-self: center; /* Center vertically in grid cell */
  justify-content: center; /* Center content vertically within column */
}

.board-header-stats {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-top: 8px;
  padding: 8px 15px;
  background: rgba(109, 40, 217, 0.3);
  border: 1px solid #8b5cf6;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.header-stat {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 1rem;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.battle-stats-column .header-stat {
  width: 100%;
}

.stat-label {
  color: #d8b4fe;
  font-weight: normal;
  white-space: nowrap;
}

.stat-value {
  color: #fbbf24;
  font-weight: bold;
  min-width: 30px;
  text-align: right;
}

/* Compact Progress Bars Container */
.compact-progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.compact-progress-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

.compact-progress-label {
  color: #d8b4fe;
  white-space: nowrap;
  min-width: 60px;
}

.compact-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #6d28d9;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.compact-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 0 5px #fbbf24;
  transition: width 0.5s ease;
  width: 0%;
}

/* Earned power-up animation */
.powerup-btn.earned {
  animation: powerupEarned 1s ease;
}

@keyframes powerupEarned {
  0% { transform: scale(1); }
  25% { transform: scale(1.2) rotate(5deg); }
  50% { transform: scale(1.1) rotate(-5deg); }
  75% { transform: scale(1.15) rotate(3deg); }
  100% { transform: scale(1); }
}

/* Mobile-First Glassmorphism Endgame Modal */
.endgame-content {
  max-width: min(450px, 95vw);
  width: 95vw;
  text-align: center;

  /* Glassmorphism effect */
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);

  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 20px;

  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(139, 92, 246, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);

  overflow-y: auto;
  max-height: 85vh;
  scroll-behavior: smooth;

  animation: glassSlideIn 0.5s cubic-bezier(0.34, 1.2, 0.64, 1);

  /* PERFORMANCE */
  will-change: transform, opacity;
  transform: translateZ(0);
  contain: layout style paint;
}

/* Minimal glass scrollbar */
.endgame-content::-webkit-scrollbar {
  width: 6px;
}

.endgame-content::-webkit-scrollbar-track {
  background: rgba(139, 92, 246, 0.1);
  border-radius: 10px;
}

.endgame-content::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.4);
  border-radius: 10px;
}

.endgame-content::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.6);
}

/* Glass entrance animation */
@keyframes glassSlideIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Mobile-Compact Result Section */
.endgame-result {
  padding: 30px 20px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: visible;
  pointer-events: none;
  contain: layout style;
}

.endgame-result h2,
.endgame-result p {
  pointer-events: auto;
}

/* Victory - Clean Glass Style */
.endgame-result.victory {
  background: radial-gradient(ellipse at center, rgba(251, 191, 36, 0.08) 0%, transparent 70%);
}

/* Compact trophy icon */
.endgame-result.victory::before {
  content: '🏆';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.3));
  z-index: 10;
  opacity: 0.9;
}

/* Defeat - Clean Glass Style */
.endgame-result.defeat {
  background: radial-gradient(ellipse at center, rgba(239, 68, 68, 0.06) 0%, transparent 70%);
}

/* Compact swords icon */
.endgame-result.defeat::before {
  content: '⚔️';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.25));
  z-index: 10;
  opacity: 0.8;
}

/* Mobile-Friendly Typography */
.endgame-result h2 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin: 50px 0 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
  z-index: 5;
  line-height: 1.2;
}

/* Victory Text - Clean Gold */
.endgame-result.victory h2 {
  color: #fbbf24;
  text-shadow:
    0 0 8px rgba(251, 191, 36, 0.4),
    1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Defeat Text - Clean Red */
.endgame-result.defeat h2 {
  color: #ef4444;
  text-shadow:
    0 0 8px rgba(239, 68, 68, 0.3),
    1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Subtitle Text - Mobile Compact */
.endgame-result p {
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 500;
  margin-top: 8px;
  position: relative;
  z-index: 5;
  letter-spacing: 0.5px;
  color: #e5e7eb;
  opacity: 0.9;
}

/* Victory Subtitle */
.endgame-result.victory p {
  color: #fde047;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.25);
}

/* Defeat Subtitle */
.endgame-result.defeat p {
  color: #e5e7eb;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.15);
}

/* Compact Glass Stats Section */
.endgame-stats {
  padding: 20px;
  background: rgba(17, 24, 39, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  margin: 0 15px 20px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  contain: layout style;
}

.endgame-stats h3 {
  font-size: clamp(1.3rem, 5vw, 1.6rem);
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(139, 92, 246, 0.3);
}

/* Mobile-Compact Stat Rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
  font-size: clamp(0.95rem, 3.5vw, 1.1rem);
}

.stat-row:last-child {
  border-bottom: none;
}

/* Clean Stat Labels */
.stat-row span:first-child {
  color: #e5e7eb;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Accent Stat Values */
.stat-row span:last-child {
  color: #fbbf24;
  font-weight: 700;
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.3);
}

/* Compact Glass Buttons */
.endgame-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
}

.endgame-buttons .btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  font-size: clamp(1rem, 4vw, 1.15rem);
  min-height: 55px;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.btn-subtitle {
  font-size: clamp(0.75rem, 3vw, 0.85rem);
  color: rgba(255, 255, 255, 0.7);
  margin-top: 3px;
  font-weight: normal;
  opacity: 0.85;
}

.btn-primary {
  background: rgba(16, 185, 129, 0.3);
  border: 1px solid rgba(52, 211, 153, 0.4);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
  background: rgba(16, 185, 129, 0.4);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(59, 130, 246, 0.3);
  border: 1px solid rgba(96, 165, 250, 0.4);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-secondary:hover {
  background: rgba(59, 130, 246, 0.4);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
  transform: translateY(-1px);
}

.endgame-buttons .btn-danger {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.4);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

.endgame-buttons .btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

/* Responsive design */
@media (max-width: 1200px) {
  /* Revert to vertical stacking on tablet/mobile */
  .boards-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
  }

  /* Stats column becomes horizontal bar on tablet */
  .battle-stats-column {
    width: 100%;
    max-width: 600px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 0;
    padding: 15px;
    gap: 10px;
  }

  .battle-stats-column .header-stat {
    width: auto;
    min-width: 140px;
  }

  .compact-progress-container {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  h1 {
    font-size: 2.5rem;
  }

  /* Compact board header stats for tablet */
  .board-header-stats {
    padding: 6px 12px;
    gap: 12px;
  }

  .header-stat {
    font-size: 0.9rem;
    padding: 6px 10px;
  }

  .compact-progress-item {
    font-size: 0.75rem;
    min-width: 140px;
  }
}

@media (max-width: 600px) {
  .board {
    grid-template-columns: repeat(10, 30px);
    grid-template-rows: repeat(10, 30px);
  }

  .cell {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }

  .cell.ship::after,
  .cell.hit::after,
  .cell.miss::after {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.8rem;
    letter-spacing: 3px;
  }

  #status-text {
    font-size: 1.3rem;
  }

  #sound-toggle {
    bottom: 10px;
    right: 10px;
    padding: 10px 12px;
    font-size: 1.2rem;
  }

  /* Mobile: Stack stats vertically in column */
  .battle-stats-column {
    flex-direction: column;
    max-width: 320px;
    padding: 12px;
    gap: 8px;
  }

  .battle-stats-column .header-stat {
    width: 100%;
    min-width: auto;
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  .compact-progress-container {
    flex-direction: column;
    width: 100%;
    gap: 6px;
  }

  .compact-progress-item {
    font-size: 0.7rem;
    width: 100%;
  }

  .compact-progress-label {
    min-width: 50px;
  }

  .compact-progress-bar {
    height: 3px;
  }

  /* Mobile: Stack board header stats vertically */
  .board-header-stats {
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    width: 100%;
    max-width: 280px;
  }

  .header-stat {
    font-size: 0.85rem;
  }
}

/* ========== MOBILE LONG-PRESS ROTATION VISUAL FEEDBACK ========== */
.long-press-indicator {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.5) 0%, rgba(139, 92, 246, 0) 70%);
  border: 3px solid rgba(139, 92, 246, 0);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(0);
  transition: all 0.1s ease-out;
}

.long-press-indicator.active {
  animation: longPressGrow 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes longPressGrow {
  0% {
    transform: translate(-50%, -50%) scale(0);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 0 rgba(139, 92, 246, 0.6);
  }
  50% {
    border-color: rgba(139, 92, 246, 0.7);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    border-color: rgba(251, 191, 36, 1);
    background: radial-gradient(circle, rgba(251, 191, 36, 0.6) 0%, rgba(139, 92, 246, 0.3) 40%, rgba(139, 92, 246, 0) 70%);
    box-shadow:
      0 0 30px rgba(251, 191, 36, 0.8),
      0 0 50px rgba(139, 92, 246, 0.6),
      inset 0 0 20px rgba(251, 191, 36, 0.3);
  }
}

/* Rotate button flash animation when long-press triggers */
@keyframes buttonFlash {
  0%, 100% {
    box-shadow:
      0 0 20px rgba(251, 191, 36, 0.3),
      inset 0 0 20px rgba(251, 191, 36, 0.1);
    border-color: #fbbf24;
  }
  50% {
    box-shadow:
      0 0 40px rgba(251, 191, 36, 0.8),
      0 0 60px rgba(251, 191, 36, 0.5),
      inset 0 0 30px rgba(251, 191, 36, 0.3);
    border-color: #fcd34d;
    transform: scale(1.05);
  }
}

.control-btn.flash {
  animation: buttonFlash 0.3s ease-in-out;
}

/* Improve touch targets for mobile */
@media (max-width: 768px) {
  .cell {
    min-height: 30px;
    min-width: 30px;
  }

  .control-btn {
    min-height: 44px; /* iOS recommended touch target size */
    padding: 12px 20px;
  }
}
