/* ==========================================================================
   SPELLBOUND: CARD RUNE DUELS - DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #0a0814;
  --bg-card: rgba(19, 16, 36, 0.88);
  --bg-card-border: rgba(147, 112, 219, 0.35);
  --accent-gold: #ffd700;
  --accent-cyan: #00f0ff;
  --accent-purple: #9d4edd;
  --accent-fire: #ff4500;
  --accent-ice: #00d2ff;
  --accent-elec: #ffea00;
  --accent-holy: #ff69b4;
  --accent-void: #b100e8;

  --text-main: #f0e6ff;
  --text-muted: #a092b8;

  --font-heading: 'Cinzel', serif;
  --font-body: 'Outfit', sans-serif;

  --shadow-glow: 0 0 25px rgba(157, 78, 221, 0.4);
  --shadow-fire: 0 0 25px rgba(255, 69, 0, 0.5);
  --shadow-ice: 0 0 25px rgba(0, 210, 255, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% 30%, #1a103c 0%, #080512 80%);
}

/* ==========================================================================
   HEADER HUD
   ========================================================================== */
#game-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(12, 9, 24, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px #9d4edd);
}

.logo-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #fff 0%, #d8b4fe 50%, #9333ea 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-mode-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(157, 78, 221, 0.2);
  border: 1px solid rgba(157, 78, 221, 0.5);
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.clash-timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.timer-label {
  font-size: 0.65rem;
  letter-spacing: 1px;
  color: var(--text-muted);
}

#match-timer {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.hud-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  background: rgba(157, 78, 221, 0.3);
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(157, 78, 221, 0.4);
}

.highlight-btn {
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.4), rgba(0, 240, 255, 0.2));
  border-color: var(--accent-cyan);
}

/* ==========================================================================
   ARENA CANVASES & WIZARD COMBAT HUD
   ========================================================================== */
#arena-section {
  flex: 1;
  position: relative;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  overflow: hidden;
}

#arena-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.wizard-hud {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid var(--bg-card-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  min-width: 320px;
}

.avatar-frame {
  position: relative;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #191233;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--accent-purple);
  box-shadow: 0 0 15px rgba(157, 78, 221, 0.5);
}

.avatar-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(157, 78, 221, 0.4) 0%, transparent 70%);
  animation: pulse-glow 2.5s infinite alternate;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.6; }
  100% { transform: scale(1.1); opacity: 1; }
}

.opp-glow {
  background: radial-gradient(circle, rgba(255, 69, 0, 0.4) 0%, transparent 70%);
}

.avatar-emoji {
  font-size: 2.2rem;
  z-index: 2;
}

.wiz-level {
  position: absolute;
  bottom: -8px;
  background: var(--accent-gold);
  color: #000;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.wiz-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.wiz-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.align-right {
  align-items: flex-end;
  text-align: right;
}

.stat-bar-container {
  position: relative;
  width: 100%;
  height: 18px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.hp-fill {
  background: linear-gradient(90deg, #ff4e50 0%, #f9d423 100%);
  box-shadow: 0 0 10px rgba(255, 78, 80, 0.5);
}

.opp-hp {
  background: linear-gradient(90deg, #e52d27 0%, #b31217 100%);
}

.mana-fill {
  background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
  box-shadow: 0 0 10px rgba(0, 198, 255, 0.5);
}

.status-fill {
  background: linear-gradient(90deg, #9d4edd 0%, #ff007f 100%);
}

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  color: #fff;
}

/* Arena Clash Banner */
#clash-banner {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(10, 8, 20, 0.9);
  border: 2px solid var(--accent-gold);
  padding: 12px 28px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
  animation: clash-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes clash-pop {
  0% { transform: translate(-50%, -20px) scale(0.8); opacity: 0; }
  100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.clash-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent-gold);
  letter-spacing: 2px;
}

.clash-subtitle {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  margin-top: 4px;
}

/* ==========================================================================
   DIRECT ON-CARD DRAWING DOCK & HAND SYSTEM
   ========================================================================== */
#card-dock {
  height: 250px;
  background: rgba(12, 9, 24, 0.92);
  border-top: 2px solid var(--accent-purple);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 20px;
  z-index: 8;
}

.dock-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.dock-title {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
}

.dock-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#card-hand-container {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 900px;
}

.spell-card {
  width: 190px;
  height: 180px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 2px dashed rgba(157, 78, 221, 0.6);
  cursor: crosshair;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  touch-action: none;
}

.spell-card.active-drawing {
  transform: translateY(-16px) scale(1.08);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 30px rgba(0, 240, 255, 0.6);
  z-index: 20;
}

/* Canvas positioned over card face */
.card-draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  border-radius: 16px;
  touch-action: none;
}

.card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  pointer-events: none; /* Allows pointer to pass through to canvas */
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  z-index: 2;
}

.card-element-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-gold);
}

.card-cost {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.card-canvas-preview {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

.draw-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.pencil-icon {
  font-size: 1.5rem;
  animation: float-pencil 2s ease-in-out infinite;
}

@keyframes float-pencil {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.card-footer-info {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  z-index: 2;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.card-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Transformed Card Styles */
.transformed-card {
  border-style: solid;
  cursor: pointer;
  box-shadow: 0 0 25px rgba(157, 78, 221, 0.7);
  animation: card-morph 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes card-morph {
  0% { transform: scale(0.8) rotateY(90deg); filter: brightness(2); }
  100% { transform: scale(1) rotateY(0deg); filter: brightness(1); }
}

.rank-badge-s {
  position: absolute;
  top: 4px;
  right: 4px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #000;
  font-weight: 900;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* ==========================================================================
   SPELL CODEX MODAL & GAME OVER MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 12, 0.85);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.close-modal-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal-btn:hover {
  background: #ff4500;
}

.codex-card {
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  background: rgba(16, 12, 34, 0.95);
  border: 2px solid var(--accent-gold);
  border-radius: 20px;
  padding: 24px;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
}

.codex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.codex-header h2 {
  font-family: var(--font-heading);
  color: var(--accent-gold);
}

.codex-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.codex-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 12px;
}

.rune-symbol {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.codex-info h3 {
  font-size: 0.85rem;
  font-family: var(--font-heading);
}

.codex-info p {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 2px 0;
}

.element-tag {
  font-weight: 800;
}
.element-tag.fire { color: var(--accent-fire); }
.element-tag.ice { color: var(--accent-ice); }
.element-tag.elec { color: var(--accent-elec); }
.element-tag.arcane { color: var(--accent-purple); }
.element-tag.holy { color: var(--accent-holy); }
.element-tag.meteor { color: var(--accent-gold); }
.element-tag.blade { color: var(--accent-cyan); }
.element-tag.void { color: var(--accent-void); }

.tip-line {
  font-size: 0.65rem;
  color: var(--accent-gold);
  margin-top: 4px;
}

/* Gameover Card */
.gameover-card {
  width: 90%;
  max-width: 420px;
  background: rgba(16, 12, 34, 0.95);
  border: 3px solid var(--accent-gold);
  border-radius: 24px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255, 215, 0, 0.5);
}

.go-icon {
  font-size: 3.5rem;
  margin-bottom: 10px;
}

#go-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--accent-gold);
}

#go-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.stats-summary {
  display: flex;
  justify-content: space-around;
  margin-bottom: 24px;
  background: rgba(0,0,0,0.4);
  padding: 14px;
  border-radius: 12px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
}
