:root {
  --primary: #6C5CE7;
  --secondary: #A29BFE;
  --accent: #FFEAA7;
  --background: #0F0A1A;
  --surface: #1e1b2e;
  --error: #FF7675;
  --success: #55EFC4;
  --text: #F5F5F5;
  --text-muted: #B2BEC3;
  --card-bg: rgba(45, 52, 54, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--background);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

/* Typography */
h1, h2, h3 {
  margin: 0;
  font-weight: 700;
}

/* Overlay Screens */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 10, 26, 0.98);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.5s ease;
  padding: 20px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.deck-options {
  display: flex;
  gap: 20px;
  margin-top: 40px;
  flex-wrap: wrap;
  justify-content: center;
}

.deck-btn {
  background: rgba(108, 92, 231, 0.2);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 20px;
  width: 140px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
}

.deck-btn:hover {
  background: var(--primary);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(108, 92, 231, 0.4);
}

/* Game Screen Layout */
#game-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(5px);
}

#turn-indicator {
  font-weight: bold;
  color: var(--secondary);
}

#log-display {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Arena */
.arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 20px;
  gap: 20px;
}

.player-area {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  position: relative;
}

#enemy-area {
  flex-direction: row-reverse; /* Enemy on right/top usually, but here row-reverse makes avatar right */
}

.avatar {
  font-size: 3rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  border: 2px solid var(--secondary);
}

.stats-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-container {
  width: 100%;
  height: 12px;
  background: #2d3436;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.health-fill {
  background: var(--error);
}

.shield-fill {
  background: var(--secondary);
}

.bar-text {
  position: absolute;
  top: -18px;
  right: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mana-text {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: bold;
}

.intent-icon {
  font-size: 1.5rem;
  margin-top: 5px;
  text-align: center;
}

/* Hand */
.hand-wrapper {
  height: 220px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 20px;
  perspective: 1000px;
}

.hand-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
  height: 100%;
}

.card {
  width: 130px;
  height: 190px;
  background: linear-gradient(145deg, #2d3436, #000000);
  border: 1px solid var(--secondary);
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  padding: 12px;
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
  margin-right: -40px; /* Overlap */
  transform-origin: bottom center;
  color: var(--text);
  flex-shrink: 0;
}

.card:last-child {
  margin-right: 0;
}

.card:hover {
  margin-right: 20px; /* Make space */
  margin-left: 20px;
  transform: translateY(-40px) scale(1.1) rotate(0deg) !important;
  z-index: 100;
  box-shadow: 0 20px 30px rgba(108, 92, 231, 0.3);
  border-color: var(--primary);
}

.card-cost {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border: 2px solid var(--background);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.card-image {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card-title {
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
  margin-bottom: 5px;
}

.card-desc {
  font-size: 0.7rem;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Controls */
.controls {
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(10px);
}

.mana-gem {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--secondary);
}

.btn-primary:disabled {
  background: #555;
  cursor: not-allowed;
}

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

.shake {
  animation: shake 0.4s ease-in-out;
}

.damage-text {
  position: absolute;
  color: var(--error);
  font-weight: bold;
  font-size: 1.5rem;
  animation: floatUp 1s forwards;
  pointer-events: none;
  z-index: 50;
}

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

/* Card Types */
.card-attack { border-top: 4px solid var(--error); }
.card-defense { border-top: 4px solid var(--secondary); }
.card-spell { border-top: 4px solid var(--success); }
