/* SpireForge Deckbuilder */

:root {
  --bg-deep: #080808;
  --bg-card: #0f0f0f;
  --gold: #C9A84C;
  --gold-dim: #8a7030;
  --red: #B83232;
  --parchment: #F5E6C8;
  --text-primary: #E8D9B5;
  --text-secondary: #8A7D5A;
  --text-muted: #4A3E2A;
  --green: #3A9B5C;
  --blue: #4A7FBF;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Nunito Sans', system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* SCREENS */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}
.screen.active { display: flex; flex-direction: column; }

/* ==================== NAV ==================== */
#game-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: rgba(8,8,8,0.95);
  border-bottom: 1px solid rgba(201,168,76,0.12);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.game-nav-brand {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.game-nav-info {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  align-items: center;
}
.game-nav-info .sep { color: var(--text-muted); }
#nav-back {
  background: transparent;
  border: 1px solid rgba(201,168,76,0.2);
  color: var(--gold-dim);
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 6px 16px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
#nav-back:hover { border-color: var(--gold); color: var(--gold); }

/* ==================== START SCREEN ==================== */
#start-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#start-screen.hidden { display: none; }
.start-inner { text-align: center; }
.start-sigil { margin-bottom: 20px; animation: pulse-sigil 3s ease-in-out infinite; }
@keyframes pulse-sigil {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.start-brand {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 3rem;
  color: var(--parchment);
  letter-spacing: 0.15em;
  margin-bottom: 12px;
}
.start-tagline {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: 40px;
}
.start-divider {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  margin: 0 auto 40px;
}
.start-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  background: var(--gold);
  color: var(--bg-deep);
  border: none;
  padding: 14px 48px;
  cursor: pointer;
  transition: background 0.2s;
}
.start-btn:hover { background: var(--parchment); }
.start-hint {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ==================== MAP ==================== */
#map-screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 60% 80% at 50% 30%, rgba(201,168,76,0.04) 0%, transparent 70%);
}
#map-screen.active { display: flex; }
.map-inner {
  width: 100%;
  max-width: 900px;
  padding: 40px 32px;
  text-align: center;
}
.map-header {
  margin-bottom: 60px;
}
.map-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--gold-dim);
  display: block;
  margin-bottom: 16px;
}
.map-progress {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  color: var(--parchment);
  font-weight: 700;
}
.map-progress-label { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 0.1em; }
.map-nodes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 60px;
  position: relative;
}
.map-node {
  flex: 0 0 140px;
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.1);
  padding: 28px 16px;
  cursor: default;
  transition: all 0.25s;
  position: relative;
}
.map-node::before {
  content: '';
  position: absolute;
  top: 50%;
  right: -30px;
  width: 30px;
  height: 1px;
  background: rgba(201,168,76,0.15);
}
.map-node:last-child::before { display: none; }
.map-node-available {
  cursor: pointer;
  border-color: rgba(201,168,76,0.25);
}
.map-node-available:hover {
  border-color: var(--gold);
  background: rgba(201,168,76,0.05);
  transform: translateY(-4px);
}
.map-node-cleared {
  border-color: rgba(58,155,92,0.3);
  background: rgba(58,155,92,0.05);
}
.node-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}
.node-label {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.node-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.map-node-available .node-status { color: var(--gold-dim); }
.map-node-cleared .node-status { color: var(--green); }
.map-node-locked .node-icon { opacity: 0.25; }
.map-node-locked .node-label { opacity: 0.25; }
.map-footer { border-top: 1px solid rgba(201,168,76,0.08); padding-top: 20px; }
.run-stats { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.08em; }

/* ==================== COMBAT SCREEN ==================== */
#combat-screen {
  min-height: 100vh;
  background: var(--bg-deep);
  flex-direction: column;
  position: relative;
}

/* Enemy area */
#enemy-area {
  flex: 0 0 auto;
  padding: 32px 32px 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 220px;
}
#enemy-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.enemy-card {
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.2);
  padding: 20px 28px;
  min-width: 180px;
  text-align: center;
  position: relative;
}
.enemy-name {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}
.enemy-intent {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
  height: 18px;
}
.enemy-intent.attacking { color: var(--red); }
.enemy-intent.defending { color: var(--blue); }
.enemy-intent.buffing { color: var(--gold); }
.enemy-health-bar {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.enemy-hp-fill { background: var(--red); height: 100%; transition: width 0.3s; }
.enemy-hp-text { font-size: 0.8rem; color: var(--text-secondary); }
.enemy-damage-flash {
  animation: damage-flash 0.3s ease-out;
}
@keyframes damage-flash {
  0% { background: rgba(184,50,50,0.4); }
  100% { background: transparent; }
}
.enemy-debuff-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 20px;
  margin-top: 6px;
}
.debuff-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(184,50,50,0.15);
  color: #e07070;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.debuff-badge.weak { background: rgba(74,127,191,0.2); color: #7aadcf; }
.debuff-badge.vulnerable { background: rgba(201,168,76,0.2); color: var(--gold); }

/* Combat divider */
.combat-divider {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 32px 8px;
  flex-shrink: 0;
}
.divider-line { flex: 1; height: 1px; background: rgba(201,168,76,0.1); }
.divider-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
}

/* Player status bar */
#player-status {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 32px;
  border-top: 1px solid rgba(201,168,76,0.08);
  border-bottom: 1px solid rgba(201,168,76,0.08);
  flex-shrink: 0;
}
.player-stat { display: flex; align-items: center; gap: 8px; }
.stat-icon { font-size: 1rem; }
#player-hp { font-size: 0.95rem; color: var(--text-primary); font-weight: 600; }
.hp-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
#hp-fill { background: var(--red); height: 100%; transition: width 0.3s; }
#player-block, #player-energy { font-size: 0.9rem; color: var(--text-primary); }
.player-debuff-list { display: flex; gap: 4px; margin-left: 8px; }

/* Hand area */
#hand-area {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 20px 12px;
  overflow-x: auto;
}
.hand-cards {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Turn controls */
#turn-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 12px 32px;
  border-top: 1px solid rgba(201,168,76,0.08);
  flex-shrink: 0;
}
#end-turn-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--gold);
  color: var(--bg-deep);
  border: none;
  padding: 10px 28px;
  cursor: pointer;
  transition: background 0.2s;
}
#end-turn-btn:hover { background: var(--parchment); }
#end-turn-btn:disabled { background: var(--text-muted); cursor: not-allowed; }
.pile-count { font-size: 0.75rem; color: var(--text-muted); }

/* Combat log */
#combat-log {
  height: 80px;
  overflow-y: auto;
  padding: 6px 32px 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(201,168,76,0.05);
  flex-shrink: 0;
  line-height: 1.6;
}
#combat-log .log-entry { margin-bottom: 2px; }
#combat-log .log-damage { color: var(--red); }
#combat-log .log-heal { color: var(--green); }
#combat-log .log-block { color: var(--blue); }
#combat-log .log-enemy { color: var(--gold-dim); }

/* ==================== CARDS ==================== */
.gcard {
  background: var(--bg-card);
  border: 1px solid rgba(201,168,76,0.2);
  width: 110px;
  padding: 12px 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
  font-family: 'Nunito Sans', system-ui, sans-serif;
}
.gcard:hover {
  transform: translateY(-8px);
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(201,168,76,0.15);
  z-index: 10;
}
.gcard.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.gcard-played {
  opacity: 0.25;
  pointer-events: none;
}
.card-cost {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 24px;
  height: 24px;
  background: var(--gold);
  color: var(--bg-deep);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: 'Cinzel', serif;
}
.card-type-attack { border-left: 3px solid var(--red); }
.card-type-skill { border-left: 3px solid var(--blue); }
.card-type-power { border-left: 3px solid var(--gold); }
.card-name {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.card-desc {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.card-type-label {
  font-family: 'Cinzel', serif;
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 8px;
  border-top: 1px solid rgba(201,168,76,0.08);
  padding-top: 6px;
}

/* ==================== REWARD SCREEN ==================== */
#reward-screen {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse 60% 50% at 50% 30%, rgba(58,155,92,0.05) 0%, transparent 70%);
}
#reward-screen.active { display: flex; }
.reward-inner { text-align: center; padding: 40px 32px; max-width: 800px; width: 100%; }
.reward-title {
  font-family: 'Cinzel', serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--green);
  margin-bottom: 8px;
}
.reward-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 40px;
}
.reward-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.reward-card {
  background: var(--bg-card);
  border: 2px solid rgba(201,168,76,0.2);
  width: 150px;
  padding: 20px 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.reward-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(201,168,76,0.15);
}
.reward-card-name {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 8px;
}
.reward-card-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.reward-card-cost {
  margin-top: 8px;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  color: var(--gold-dim);
}
.reward-actions { display: flex; gap: 12px; justify-content: center; }
.reward-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(201,168,76,0.15);
  padding: 10px 28px;
  cursor: pointer;
  transition: all 0.2s;
}
.reward-btn:hover { border-color: var(--gold-dim); color: var(--text-primary); }
.reward-btn-primary {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold);
}
.reward-btn-primary:hover { background: var(--parchment); border-color: var(--parchment); }

/* ==================== GAME OVER ==================== */
#gameover-screen {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
#gameover-screen.active { display: flex; }
.gameover-inner { text-align: center; padding: 40px 32px; }
.gameover-title {
  font-family: 'Cinzel', serif;
  font-size: 4rem;
  font-weight: 900;
  color: var(--red);
  margin-bottom: 12px;
}
.gameover-subtitle { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 40px; }
.gameover-stats, .victory-stats {
  margin-bottom: 40px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gameover-stats div, .victory-stats div { color: var(--text-muted); }

/* ==================== VICTORY ==================== */
#victory-screen {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse 60% 50% at 50% 30%, rgba(201,168,76,0.06) 0%, transparent 70%);
}
#victory-screen.active { display: flex; }
.victory-inner { text-align: center; padding: 40px 32px; }
.victory-title {
  font-family: 'Cinzel', serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 12px;
  text-shadow: 0 0 40px rgba(201,168,76,0.3);
}
.victory-sub { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 40px; }

/* ==================== CARD PREVIEW ==================== */
.card-preview {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--gold);
  padding: 16px 20px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.card-preview.hidden { display: none; }
.preview-name {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 4px;
}
.preview-type {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.preview-desc { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.4; margin-bottom: 8px; }
.preview-cost { font-size: 0.7rem; color: var(--gold-dim); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  #game-nav { padding: 12px 16px; }
  #enemy-area { padding: 20px 16px 10px; }
  .map-nodes { gap: 0; }
  .map-node { flex: 0 0 110px; padding: 20px 10px; }
  .gcard { width: 90px; }
  #player-status { gap: 16px; padding: 8px 16px; }
  #turn-controls { padding: 10px 16px; gap: 12px; }
  .reward-cards { gap: 12px; }
  .reward-card { width: 130px; }
}

@media (max-width: 480px) {
  .map-node { flex: 0 0 80px; }
  .node-icon { font-size: 1.8rem; }
  .node-label { font-size: 0.7rem; }
  #combat-log { display: none; }
}