/* Import Inter Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;500;700;900&display=swap');

:root {
  /* Palette */
  --bg-deep: #0f172a;
  --bg-dark: #020617;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.15);

  /* Accents */
  --cyan-primary: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.6);
  --amber-primary: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.6);
  --red-vital: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  /* Sizing */
  --radius-lg: 24px;
  --radius-sm: 8px;
  font-size: 200%;
}

* {
  box-sizing: border-box;
}

/* --- Layout Main --- */
.battle-view {
  width: 100%;
  height: 100%;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(6, 182, 212, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.1) 0%, transparent 40%);
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center; /* Center everything horizontally */
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

/* Ambient floating blobs */
.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  z-index: 0;
  animation: float 10s infinite ease-in-out;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background: var(--cyan-primary);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: #7e22ce; /* Purple accent */
  bottom: -100px;
  right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20px, 40px); }
}

/* --- Header --- */
.battle-header {
  text-align: center;
  z-index: 2;
  margin-bottom: 2rem;
  width: 100%;
}

.header-badge {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--cyan-primary);
  background: rgba(6, 182, 212, 0.1);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  margin-bottom: 0.5rem;
}

.battle-header h1 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -1px;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.5));
}

/* --- Battle Stage (Center) --- */
.battle-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: row; /* Force row */
  flex-wrap: nowrap; /* Prevent wrapping */
  justify-content: center;
  align-items: center;
  gap: 2rem;
  position: relative;
  z-index: 2;
}

/* Card Styles */
.combatant-card {
  flex: 1;
  max-width: 500px;
  min-width: 300px; /* Ensure they don't shrink too much */
  position: relative;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px var(--glass-highlight);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Player Theme */
.combatant-card.player .card-glass {
  border-top: 4px solid var(--cyan-primary);
}
/* Enemy Theme */
.combatant-card.enemy .card-glass {
  border-top: 4px solid var(--amber-primary);
}

.combatant-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.combatant-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

.combatant-role {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 1px;
  opacity: 0.6;
}

/* Avatars */
.avatar-container {
  height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.combatant-avatar {
  font-size: 6rem;
  filter: drop-shadow(0 0 20px rgba(0,0,0,0.5));
  z-index: 1;
  transition: transform 0.2s ease;
}

/* Moves Popup */
.combatant-move {
  position: absolute;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fbbf24;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2;
  white-space: nowrap;
}

.combatant-move.active {
  transform: translateY(-10px);
  opacity: 1;
  box-shadow: 0 0 15px var(--amber-glow);
}

/* Stats */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-label-row {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Hearts & Energy Tracks */
.hearts-track, .energy-track {
  display: flex;
  gap: 6px;
  height: 24px;
  flex-wrap: wrap; /* Allow wrapping if many tiles */
}

.heart-pip, .energy-pip {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.heart-pip.full {
  background: var(--red-vital);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.energy-pip.full.cyan {
  background: var(--cyan-primary);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.energy-pip.full.amber {
  background: var(--amber-primary);
  box-shadow: 0 0 10px var(--amber-glow);
}

.hearts-update {
  animation: shake 0.3s ease-in-out;
}

/* Attributes */
.attributes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.5rem;
}

.attr-pill {
  background: rgba(255,255,255,0.05);
  padding: 8px;
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* VS Badge */
.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0; /* Don't shrink */
}

.vs-circle {
  width: 60px;
  height: 60px;
  background: var(--bg-dark);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-style: italic;
  color: var(--text-muted);
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* --- Hit Meter --- */
.hit-meter-container {
  margin-top: 1rem;
  background: #000;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideDown 0.3s ease;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.meter-track {
  height: 12px;
  background: #1e293b;
  border-radius: 100px;
  position: relative;
  display: flex;
  overflow: visible;
}

.zone-hit {
  background: var(--cyan-primary);
  height: 100%;
  border-radius: 100px 0 0 100px;
  transition: width 0.3s ease;
}

.zone-miss {
  background: #334155;
  height: 100%;
  border-radius: 0 100px 100px 0;
  transition: width 0.3s ease;
}

.meter-cursor {
  position: absolute;
  top: -4px;
  left: 0%;
  width: 4px;
  height: 20px;
  background: #fff;
  box-shadow: 0 0 10px #fff, 0 0 5px var(--cyan-primary);
  z-index: 10;
  transition: left 1.5s cubic-bezier(0.25, 1, 0.5, 1);
  transform: translateX(-50%);
}

.meter-cursor.rolling {
  /* No specific style needed */
}

.meter-cursor.locked {
  background: #fcd34d;
  box-shadow: 0 0 15px #fcd34d;
  width: 6px;
}

.meter-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.6rem;
  font-weight: 700;
}

.legend-item.hit { color: var(--cyan-primary); }
.legend-item.miss { color: var(--text-muted); }

/* --- Footer / Messages --- */
.hud-footer {
  margin-top: 2rem;
  z-index: 2;
  display: flex;
  justify-content: center;
  width: 100%;
}

.battle-message-glass {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  padding: 1rem 3rem;
  border-radius: 100px;
  border: 1px solid var(--glass-border);
  text-align: center;
  min-width: 400px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}

.msg-important { border-color: var(--cyan-primary); color: var(--cyan-primary); }
.msg-danger { border-color: var(--red-vital); color: var(--red-vital); }
.msg-action { border-color: var(--amber-primary); color: #fff; }
.msg-final { transform: scale(1.1); background: var(--cyan-primary); color: #000; font-weight: 800; }

/* --- Animations --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Combatant Reaction Classes */
.combatant-card.anim-damage {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
  filter: saturate(2) brightness(0.8) sepia(0.5) hue-rotate(-50deg);
}

.combatant-card.anim-dodge {
  transform: translateX(20px);
  opacity: 0.5;
}

.combatant-card.winner-glow .card-glass {
  box-shadow: 0 0 50px var(--cyan-glow), inset 0 0 20px rgba(255,255,255,0.2);
  border-color: var(--cyan-primary);
}

.combatant-card.loser-fade {
  opacity: 0.4;
  filter: grayscale(1);
}

/* Hit Flash Effects */
.flash-success { animation: flash-white 0.5s; }
.flash-fail { animation: flash-red 0.5s; }

@keyframes flash-white {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(2); }
}
@keyframes flash-red {
  0%, 100% { background: #334155; }
  50% { background: var(--red-vital); }
}