:root {
  --bg-color: #0f172a;
  --surface: #1e293b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2828;
  --magic: #a855f7;
  --magic-hover: #9333ea;
  --heal: #22c55e;
  --heal-hover: #16a34a;
  --text: #f8fafc;
  --gold: #fbbf24;
  --border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(239, 68, 68, 0.15) 0%, transparent 40%);
}

#game-container {
  width: 100%;
  max-width: 800px;
  min-height: 650px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  position: relative;
}

.top-bar {
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.top-bar h1 {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.level-indicator {
  font-size: 1rem;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
}

/* BATTLEFIELD */
#battlefield {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem;
  position: relative;
  min-height: 300px;
  background: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><rect width="100" height="100" fill="none"/><path d="M0 100 L100 0" stroke="rgba(255,255,255,0.03)" stroke-width="2"/></svg>') repeat;
}

.character-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 40%;
  position: relative;
}

.vs-badge {
  font-size: 2rem;
  font-weight: 900;
  color: var(--danger);
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.8);
  animation: pulse 2s infinite;
}

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

.status-box {
  background: rgba(0,0,0,0.5);
  padding: 1rem;
  border-radius: 12px;
  width: 100%;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.char-name {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  text-align: center;
}

.bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.bar-label {
  font-weight: 900;
  font-size: 0.8rem;
  width: 25px;
}

.bar.bg-dark {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.5);
}

.bar-fill {
  height: 100%;
  transition: width 0.3s ease-out;
}

.hp-fill { background: linear-gradient(90deg, #16a34a, #22c55e); }
.mp-fill { background: linear-gradient(90deg, #2563eb, #3b82f6); }

.bar-text {
  font-size: 0.75rem;
  width: 45px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sprites */
.sprite-container {
  position: relative;
  width: 120px;
  height: 120px;
}

.sprite-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--primary);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  transition: transform 0.2s;
  background-color: var(--surface);
}

.sprite-container.enemy img {
  border-color: var(--danger);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* Animations */
.anim-attack { animation: attackMove 0.3s ease forwards; }
@keyframes attackMove {
  0% { transform: translateX(0); }
  50% { transform: translateX(30px) scale(1.1); }
  100% { transform: translateX(0); }
}

.anim-attack-enemy { animation: attackMoveEnemy 0.3s ease forwards; }
@keyframes attackMoveEnemy {
  0% { transform: translateX(0); }
  50% { transform: translateX(-30px) scale(1.1); }
  100% { transform: translateX(0); }
}

.anim-damage { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0) scale(0.95); filter: brightness(0.5) sepia(1) hue-rotate(-50deg) saturate(5); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

.damage-text {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 10px red;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.anim-dmg-text { animation: floatUp 1s ease-out forwards; }
@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.5); }
  20% { transform: translate(-50%, -20px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50px) scale(1); }
}

/* Dialog Box */
#dialog-box {
  padding: 1.5rem;
  background: rgba(0,0,0,0.6);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 80px;
  display: flex;
  align-items: center;
}

#dialog-text {
  font-size: 1.1rem;
  line-height: 1.5;
}

/* Menus */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}

.action-btn {
  background: var(--surface);
  color: var(--text);
  border: none;
  padding: 1.2rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn:hover:not(:disabled) { background: var(--primary); }
.action-btn:active:not(:disabled) { transform: scale(0.98); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.action-btn.magic-btn:hover { background: var(--magic); }
.action-btn[data-action="defend"]:hover { background: var(--gold); color: #000; }
.action-btn[data-action="item"]:hover { background: var(--heal); }
.skill-btn[data-skill="furacao"]:hover { background: var(--danger); }
.skill-btn[data-skill="gelo"]:hover { background: var(--primary); }
.skill-btn[data-skill="velocidade"]:hover { background: var(--gold); color:#000; }
.skill-btn[data-skill="magia"]:hover { background: var(--magic); }

/* Overlays (Selection & Victory) */
.overlay-screen {
  position: absolute;
  top: 90px; /* Below top bar */
  left: 0;
  width: 100%;
  height: calc(100% - 90px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  z-index: 50;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* Selection Grid */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
  overflow-y: auto;
}

.roster-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.roster-card:hover:not(.locked) {
  transform: translateY(-5px);
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.roster-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.roster-card img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.5rem;
}

/* Victory Screen */
.reward-box, .levelup-box {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  text-align: center;
}

.stat-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.stat-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.stat-btn:hover { background: var(--primary); border-color: var(--primary); }
