/* Custom Parchment & War-Table Styles */
:root {
  --parchment-bg: #edd8b4;
  --parchment-dark: #caa778;
  --p1-blue: #1e3f66;
  --p1-accent: #3b82f6;
  --p2-red: #8b263e;
  --p2-accent: #ef4444;
  --gold-trim: #d4af37;
}

/* Base resets & touch friendly */
* {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  box-sizing: border-box;
}

body {
  background: radial-gradient(circle at center, #18100a 0%, #080503 100%);
  color: #ebd9b6;
}

/* Parchment frame aesthetic */
.parchment-frame {
  background: radial-gradient(ellipse at center, #ebd4ab 0%, #cbb080 60%, #b29057 100%);
  color: #2b1a09;
  box-shadow: inset 0 0 40px rgba(70, 42, 12, 0.45), 0 10px 30px rgba(0,0,0,0.8);
}

/* Grid Board Styling */
#board-container {
  width: 100%;
  max-width: 384px;
  aspect-ratio: 8 / 18.2;
  background-color: #dfc495;
  border-radius: 8px;
}

/* Custom grid tile */
.grid-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background-color: rgba(248, 237, 216, 0.45);
  border: 1px solid rgba(168, 131, 84, 0.45);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.grid-cell:active {
  transform: scale(0.93);
}

/* Cell Highlighting States */
.grid-cell.highlight-deploy {
  background-color: rgba(59, 130, 246, 0.35) !important;
  border: 1.5px dashed #3b82f6 !important;
  animation: pulse-border 1.5s infinite;
}

.grid-cell.highlight-deploy-p2 {
  background-color: rgba(239, 68, 68, 0.35) !important;
  border: 1.5px dashed #ef4444 !important;
  animation: pulse-border 1.5s infinite;
}

.grid-cell.highlight-move {
  background-color: rgba(34, 197, 94, 0.45) !important;
  border: 2px solid #16a34a !important;
  box-shadow: inset 0 0 8px rgba(34, 197, 94, 0.6);
  cursor: crosshair;
}

.grid-cell.highlight-move::after {
  content: '';
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 6px #22c55e;
}

.grid-cell.highlight-attack {
  background-color: rgba(220, 38, 38, 0.45) !important;
  border: 2px solid #dc2626 !important;
  box-shadow: inset 0 0 10px rgba(220, 38, 38, 0.7);
  animation: pulse-attack 1s infinite alternate;
}

.grid-cell.highlight-attack::after {
  content: '🎯';
  font-size: 11px;
}

.grid-cell.selected-unit {
  border: 2px solid #eab308 !important;
  background-color: rgba(234, 179, 8, 0.4) !important;
  box-shadow: 0 0 12px #eab308;
}

.grid-cell.razed-ruin {
  background: radial-gradient(circle, #38241e 20%, #170d09 90%) !important;
  border: 1px solid #5a382d !important;
}

/* Tokens / Units */
.unit-token {
  position: relative;
  width: 92%;
  height: 92%;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.45);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 1px;
}

.unit-token img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.p1-unit {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.85), rgba(30, 63, 102, 0.95));
  border: 1.5px solid #93c5fd;
}

.p2-unit {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.85), rgba(139, 38, 62, 0.95));
  border: 1.5px solid #fca5a5;
}

.castle-token {
  position: relative;
  width: 96%;
  height: 96%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.6);
  border: 2px solid #d4af37;
  padding: 2px;
}

.castle-token img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
}

.p1-castle {
  background: linear-gradient(135deg, #1d4ed8, #0f172a);
}

.p2-castle {
  background: linear-gradient(135deg, #b91c1c, #450a0a);
}

/* Unit shop cards */
.unit-shop-card.active {
  border-color: #d4af37 !important;
  background-color: #4a3424 !important;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.45);
}

@keyframes pulse-border {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

@keyframes pulse-attack {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* Floating Gold Bounty Animation */
.floating-gold {
  position: absolute;
  color: #f59e0b;
  font-weight: 900;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  pointer-events: none;
  z-index: 45;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 8px #f59e0b;
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  30% { opacity: 1; transform: translateY(-8px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-24px) scale(1); }
}

/* --- DEPLOYMENT BLAST VISUAL EFFECTS --- */
.blast-ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 3px solid #ff4500;
  box-shadow: 0 0 25px #ff8c00, inset 0 0 20px #ffd700;
  background: radial-gradient(circle, rgba(255, 69, 0, 0.4) 0%, rgba(255, 215, 0, 0.15) 60%, transparent 85%);
  animation: shockwaveExpand 0.75s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  z-index: 35;
}

@keyframes shockwaveExpand {
  0% {
    width: 20px;
    height: 20px;
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.3);
  }
  70% {
    opacity: 0.9;
  }
  100% {
    width: 220px;
    height: 220px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

.blast-cell-explosion {
  animation: blastShatter 0.6s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

@keyframes blastShatter {
  0% {
    background-color: rgba(255, 69, 0, 0.85) !important;
    transform: scale(1.25);
  }
  40% {
    background-color: rgba(255, 215, 0, 0.7) !important;
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* Screen shake for deployment blast */
.shake-board {
  animation: boardRumble 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes boardRumble {
  10%, 90% { transform: translate3d(-2px, 1px, 0); }
  20%, 80% { transform: translate3d(3px, -2px, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 2px, 0); }
  40%, 60% { transform: translate3d(2px, -1px, 0); }
}