/* ═══════════════════════════════════════════════════════════
   ARCANE DUELS — Main Design System
   Fantasy medieval theme with rich browns, golds, purples
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS Variables (Design Tokens) ─────────────────────── */
:root {
  /* Primary palette */
  --bg-dark: #0a0a12;
  --bg-darker: #050508;
  --bg-card: #12121f;
  --bg-surface: #1a1a2e;
  --bg-surface-hover: #222240;
  --bg-elevated: #252545;

  /* Accent colors */
  --gold: #d4a843;
  --gold-light: #f0d078;
  --gold-dark: #a07828;
  --gold-glow: rgba(212, 168, 67, 0.4);
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --purple-dark: #6d28d9;
  --purple-glow: rgba(139, 92, 246, 0.4);
  --crimson: #dc2626;
  --crimson-light: #f87171;
  --crimson-glow: rgba(220, 38, 38, 0.3);
  --emerald: #10b981;
  --emerald-light: #6ee7b7;
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --cyan: #06b6d4;
  --cyan-light: #67e8f9;

  /* Element colors */
  --element-fire: #ef4444;
  --element-fire-bg: linear-gradient(135deg, #7f1d1d, #dc2626, #f97316);
  --element-nature: #22c55e;
  --element-nature-bg: linear-gradient(135deg, #14532d, #22c55e, #84cc16);
  --element-shadow: #8b5cf6;
  --element-shadow-bg: linear-gradient(135deg, #3b0764, #8b5cf6, #6366f1);
  --element-arcane: #3b82f6;
  --element-arcane-bg: linear-gradient(135deg, #1e3a5f, #3b82f6, #06b6d4);
  --element-holy: #f59e0b;
  --element-holy-bg: linear-gradient(135deg, #78350f, #f59e0b, #fbbf24);

  /* Rarity colors */
  --rarity-common: #9ca3af;
  --rarity-rare: #3b82f6;
  --rarity-epic: #a855f7;

  /* Text */
  --text-primary: #e8e6e3;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-gold: #d4a843;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-gold: rgba(212, 168, 67, 0.3);
  --border-glow: rgba(212, 168, 67, 0.6);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-gold: 0 0 20px rgba(212, 168, 67, 0.3);
  --shadow-purple: 0 0 20px rgba(139, 92, 246, 0.3);

  /* Typography */
  --font-heading: 'Cinzel', serif;
  --font-fantasy: 'MedievalSharp', cursive;
  --font-body: 'Inter', sans-serif;

  /* Sizes */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-round: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(212, 168, 67, 0.05) 0%, transparent 50%);
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ─── Particle Canvas ────────────────────────────────────── */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* ─── Scrollbar Styling ──────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-gold);
  letter-spacing: 0.03em;
}

h1 { font-size: 2.5rem; font-weight: 900; }
h2 { font-size: 1.8rem; font-weight: 700; }
h3 { font-size: 1.4rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 600; }

.fantasy-text {
  font-family: var(--font-fantasy);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-light));
  color: #1a1a2e;
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(212, 168, 67, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.btn-danger {
  background: linear-gradient(135deg, #7f1d1d, #dc2626);
  color: #fff;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn-large {
  padding: 16px 40px;
  font-size: 1.1rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-round);
  font-size: 1.2rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Inputs ─────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.input {
  padding: 12px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: all var(--transition-normal);
  outline: none;
}

.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}

.input::placeholder {
  color: var(--text-muted);
}

/* ─── Toast Notifications ────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.4s ease forwards;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  backdrop-filter: blur(10px);
}

.toast.toast-success {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.15);
}

.toast.toast-error {
  border-color: var(--crimson);
  background: rgba(220, 38, 38, 0.15);
}

.toast.toast-info {
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.15);
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

.toast-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ─── Modal ──────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s ease;
}

#modal-overlay.hidden {
  display: none;
}

#modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-xl), 0 0 60px rgba(212, 168, 67, 0.1);
  animation: modal-in 0.4s ease;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: center;
}

.modal-body {
  margin-bottom: 24px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ─── Loading Spinner ────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 18, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner-ring {
  width: 60px;
  height: 60px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  position: absolute;
}

.spinner-ring:nth-child(2) {
  width: 45px;
  height: 45px;
  border-top-color: var(--purple);
  animation-direction: reverse;
  animation-duration: 0.8s;
}

.spinner-ring:nth-child(3) {
  width: 30px;
  height: 30px;
  border-top-color: var(--crimson-light);
  animation-duration: 0.6s;
}

.spinner-text {
  margin-top: 50px;
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Screen Base ────────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen-enter {
  animation: screen-enter 0.5s ease forwards;
}

.screen-exit {
  animation: screen-exit 0.4s ease forwards;
}

/* ─── Ornamental Dividers ────────────────────────────────── */
.divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent);
  margin: 16px 0;
  position: relative;
}

.divider::after {
  content: '◆';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-surface);
  padding: 0 12px;
  color: var(--gold);
  font-size: 0.7rem;
}

/* ─── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-round);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-gold {
  background: rgba(212, 168, 67, 0.15);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 67, 0.3);
}

.badge-online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-offline {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* ─── HP Bar ─────────────────────────────────────────────── */
.hp-bar {
  width: 100%;
  height: 20px;
  background: var(--bg-dark);
  border-radius: var(--radius-round);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crimson), var(--emerald));
  transition: width 0.5s ease;
  border-radius: var(--radius-round);
  position: relative;
}

.hp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.2), transparent);
  border-radius: var(--radius-round) var(--radius-round) 0 0;
}

.hp-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ─── Mana Crystal ───────────────────────────────────────── */
.mana-display {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mana-crystal {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid #1e3a5f;
  transition: all var(--transition-normal);
}

.mana-crystal.filled {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  border-color: #93c5fd;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.mana-crystal.spent {
  background: var(--bg-dark);
  border-color: #374151;
  opacity: 0.4;
}

.mana-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: #60a5fa;
  font-weight: 700;
  margin-left: 6px;
}

/* ─── Utility Classes ────────────────────────────────────── */
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.w-full { width: 100%; }
.relative { position: relative; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.1rem; }

  .btn { padding: 10px 20px; font-size: 0.85rem; }
  .btn-large { padding: 14px 32px; font-size: 1rem; }

  #toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .toast {
    max-width: 100%;
  }
}

html { scroll-behavior:smooth; }
button, input, select { font:inherit; }
@media (max-width: 768px) {
  body { min-height:100dvh; }
  #app { min-height:100dvh; }
  .screen { min-height:100dvh; height:auto; }
  .modal-content { max-height:calc(100dvh - 28px); }
}
@media (max-width: 520px) {
  #toast-container { top: max(8px, env(safe-area-inset-top)); right:8px; left:8px; }
  .screen { padding-bottom:env(safe-area-inset-bottom); }
}
:root { --rarity-legendary: #f59e0b; }
