/* ===================== DEADMAN'S CROSS - theme ===================== */
:root {
  --bg: #0a0a0d;
  --panel: #16131a;
  --ink: #e7e2d8;
  --muted: #8a8275;
  --blood: #8e1c20;
  --gold: #c8a45a;

  --r-common: #6b6b6b;
  --r-rare:   #3f7fb0;
  --r-super:  #8a4fb0;
  --r-ultra:  #c8a45a;
  --r-legend: #cf5a2a;
  --r-mythic: #e23b6d;
  --r-deity:  #ffd970;

  --aff-spirit: #6fb6c9;
  --aff-flesh:  #b07a5a;
  --aff-blood:  #b03442;
  --aff-void:   #9b8fb0;
  --aff-storm:  #3aa8e8;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body {
  margin: 0; min-height: 100%; max-width: 100%; overflow-x: clip;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
/* body must stay transparent, otherwise it paints over the z-index:-1 board layer */
body { background: transparent; }
/* the board art + vignette live on ONE fixed, full-viewport layer so they never
   scroll away no matter how tall the page content is */
body::before {
  content: ""; position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0.45), rgba(0,0,0,0.85)),
    url('art/board-bg.png') center / cover no-repeat;
  background-color: #000;
  pointer-events: none; z-index: -1;
}

.screen { position: relative; z-index: 1; min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- Lobby ---------- */
#lobby, #gameover { display: flex; align-items: center; justify-content: center; }
.lobby-box {
  background: rgba(12,10,14,0.85);
  border: 1px solid #2a242f;
  border-radius: 10px;
  padding: 32px 40px; width: min(520px, 92vw); box-sizing: border-box; text-align: center;
  overflow-wrap: break-word; box-shadow: 0 0 60px rgba(142,28,32,0.25);
}
@media (max-width: 480px) { .lobby-box { padding: 24px 18px; } }
#logo { max-width: 280px; margin-bottom: 8px; }
.title {
  font-size: 44px; letter-spacing: 6px; margin: 6px 0;
  color: var(--ink); text-shadow: 0 0 18px var(--blood);
  font-family: "Georgia", serif; font-weight: 700;
}
.subtitle { color: var(--muted); margin-top: 0; }
#nameInput {
  display: block; width: 100%; margin: 18px 0; padding: 12px;
  background: #0c0a0e; border: 1px solid #3a3340; color: var(--ink);
  border-radius: 6px; font-size: 16px; text-align: center;
}
button {
  background: linear-gradient(180deg, #b3262b, #6e1417);
  color: #fff; border: 1px solid #d8b27a40; padding: 12px 28px;
  font-size: 16px; letter-spacing: 2px; border-radius: 6px; cursor: pointer;
  font-weight: 700; transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.15); }
button:active { transform: translateY(1px); }
button:disabled { filter: grayscale(.8) brightness(.6); cursor: default; }
.status { color: var(--gold); min-height: 22px; margin-top: 14px; }
.rules { margin-top: 18px; text-align: left; color: var(--muted); font-size: 13px; }
.rules summary { cursor: pointer; color: var(--gold); }
.rules li { margin: 4px 0; }

/* ---------- Game layout ---------- */
#game { display: flex; flex-direction: column; gap: 6px; padding: 8px; min-height: 100vh; }
.hero-row { display: flex; align-items: center; justify-content: center; gap: 16px; }
.hero {
  display: flex; align-items: center; gap: 12px;
  background: rgba(14,12,16,0.7); border: 1px solid #2a242f;
  border-radius: 10px; padding: 6px 14px; min-width: 320px;
}
.hero.targetable { outline: 2px solid var(--blood); cursor: crosshair; box-shadow: 0 0 16px var(--blood); }
.hero-portrait { width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
  background: #241b22 url('art/skull.png') center/cover; border: 2px solid #4a3f33; }
.hero-portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero-stats { display: flex; flex-direction: column; line-height: 1.3; }
.hero-name { font-weight: 700; color: var(--gold); }
.hero-life { color: #e06a6a; font-weight: 700; }
.hero-life::before { content: "♥ "; }
.hero-mana { color: var(--aff-spirit); }
.hero-mana::before { content: "✦ "; }
.hero-cards { color: var(--muted); font-size: 12px; }

.divider { text-align: center; color: var(--muted); letter-spacing: 4px; font-size: 12px; opacity: .8; }
#turnBanner.my-turn { color: var(--gold); text-shadow: 0 0 10px var(--gold); }

.board {
  display: flex; gap: 8px; justify-content: center; align-items: center;
  min-height: 130px; padding: 6px; flex-wrap: wrap;
}

#endTurnBtn { margin-left: 10px; }

/* ---------- Cards ---------- */
.hand { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding-top: 6px; }

.card {
  position: relative; width: 120px; height: 168px; border-radius: 10px;
  background: #14111a; border: none;
  overflow: hidden; cursor: pointer; user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.6); transition: transform .1s;
}
.card:hover { transform: translateY(-6px); }
.card.rarity-rare   { border-color: var(--r-rare); }
.card.rarity-super  { border-color: var(--r-super); }
.card.rarity-ultra  { border-color: var(--r-ultra); box-shadow: 0 0 16px var(--r-ultra); }
.card.rarity-legend { border-color: var(--r-legend); box-shadow: 0 0 20px var(--r-legend); }
.card.rarity-mythic { border-color: var(--r-mythic); box-shadow: 0 0 22px var(--r-mythic); }
.card.rarity-deity  { border-color: var(--r-deity);  box-shadow: 0 0 28px var(--r-deity), 0 0 14px var(--r-deity); }

.card-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.card-art-fallback { position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(160deg, #2a1f2b, #0c0a0e); }
/* The frame PNG carries transparent padding around the ornament; over-scale it
   slightly so the decorative border bleeds to the actual card edges. */
.card-frame { position: absolute; inset: 0; z-index: 2; background-size: 108% 108%;
  background-position: center; background-repeat: no-repeat; pointer-events: none; }

.card-cost, .card-atk, .card-hp {
  position: absolute; z-index: 3; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px;
  box-sizing: border-box; white-space: nowrap; line-height: 1;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  font-size: 15px; color: #fff; text-shadow: 0 1px 2px #000;
  border: 1px solid rgba(0,0,0,.5);
}
.card-cost { top: 1px; left: 1px; background: radial-gradient(circle, #4a7fc0, #1b3a66); }
.card-atk  { bottom: 1px; left: 1px; background: radial-gradient(circle, #d8b048, #7a5b14); }
.card-hp   { bottom: 1px; right: 1px; background: radial-gradient(circle, #d85a5a, #6e1414); }

.card-name {
  position: absolute; z-index: 3; bottom: 34px; left: 0; right: 0; text-align: center;
  font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000;
  padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-aff {
  position: absolute; z-index: 3; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,.6);
}
.aff-SPIRIT { background: var(--aff-spirit); }
.aff-FLESH  { background: var(--aff-flesh); }
.aff-BLOOD  { background: var(--aff-blood); }
.aff-VOID   { background: var(--aff-void); }
.aff-STORM  { background: var(--aff-storm); }

.card-kw { position: absolute; z-index: 3; top: 28px; left: 0; right: 0; text-align: center;
  font-size: 9px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 1px 2px #000; }

/* ---------- Board minions ---------- */
.minion { width: 96px; height: 128px; }
.minion.can-attack { box-shadow: 0 0 10px 2px #6fc97a; }
.minion.selected { outline: 3px solid var(--gold); box-shadow: 0 0 18px var(--gold); }
.minion.targetable { outline: 2px solid var(--blood); cursor: crosshair; }
.minion .card-name { bottom: 30px; font-size: 9px; }
.minion .card-cost { display: none; }
.minion.taunt::after {
  content: "GUARDIAN"; position: absolute; z-index: 3; top: 2px; left: 0; right: 0;
  text-align: center; font-size: 8px; letter-spacing: 1px; color: #cdb27a;
  text-shadow: 0 1px 2px #000;
}

/* ---------- Card back (opponent hand, decorative) ---------- */
.cardback {
  width: 40px; height: 56px; border-radius: 6px;
  background: #1a1420 url('art/card-back.png?v=2') center/cover; border: 1px solid #3a3340;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(120,20,24,0.95); color: #fff; padding: 10px 20px; border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.7); font-weight: 600;
}

/* ---- swappable battle stage (Pixi 2D / Babylon 3D renderers) ---- */
.battle-stage { position: relative; width: 100%; height: 70vh; overflow: hidden; }
.battle-stage.hidden { display: none; }
.battle-stage canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.battle-wrap.stage-hidden { display: none !important; }
@media (max-width: 640px) { .battle-stage { height: 62vh; } }

/* battle-graphics 2D/3D toggle lives on the hub — styled in app.css
   (.gfx-bar / .gfx-toggle / .gfx-knob / .gfx-side) */

/* ===================== forced onboarding (appended) ===================== */
/* locked nav / hub tiles while the Saga tutorial is unfinished */
#topbar .navbtn.onb-locked { opacity: .55; }
#topbar .navbtn.onb-locked::after { content: " 🔒"; font-size: 11px; }
.hub-card.onb-locked { position: relative; opacity: .6; filter: saturate(.55); }
.hub-card.onb-locked::after {
  content: "🔒 Complete the Saga tutorial"; position: absolute; left: 8px; bottom: 8px;
  font-size: 11px; color: var(--gold); text-shadow: 0 1px 2px #000;
}
/* pulsing "go forge" attention glow on the Upgrade nav */
#topbar .navbtn.attn { animation: onbAttn 1.4s ease-in-out infinite; border-radius: 6px; }
@keyframes onbAttn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200,164,90,0); }
  50% { box-shadow: 0 0 14px 3px rgba(200,164,90,.75); }
}
/* Saga next-chapter extras */
.cn-teach { color: var(--gold); font-size: 13px; margin: 2px 0 6px; letter-spacing: 1px; }
.cn-gate {
  margin-top: 10px; padding: 12px 14px; border: 1px dashed #6a5a33; border-radius: 8px;
  background: rgba(40,32,18,.55);
}
.cn-gate-title { color: var(--gold); font-weight: 700; letter-spacing: 2px; margin-bottom: 4px; }
.cn-gate p { margin: 4px 0 10px; color: var(--ink); }
.cr-gate { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--gold);
  border: 1px solid #6a5a33; border-radius: 10px; padding: 1px 8px; background: rgba(40,32,18,.5); }
.onb-locked-card { opacity: .9; }

/* ---------- guided demonstration overlay (tutorial ch5-8) ---------- */
.demo-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(5,4,7,.92);
  display: flex; align-items: center; justify-content: center; overflow-y: auto; }
.demo-overlay.hidden { display: none; }
.demo-box { width: min(980px, 96vw); max-height: 96vh; overflow-y: auto; padding: 14px 16px;
  background: rgba(14,11,16,.97); border: 1px solid #3a3340; border-radius: 12px;
  box-shadow: 0 0 60px rgba(142,28,32,.3); }
.demo-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.demo-head #demo-title { font-weight: 700; color: var(--gold); letter-spacing: 2px; flex: 1; }
.demo-teamname { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: 2px; margin: 4px 0; }
.demo-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 120px; }
.demo-cell { position: relative; width: 104px; transition: transform .15s, filter .2s; }
.demo-cell .card { width: 104px; height: 146px; cursor: default; }
.demo-cell .card:hover { transform: none; }
.demo-cell.acting { transform: translateY(-6px) scale(1.06); z-index: 2; }
.demo-cell.acting .card { box-shadow: 0 0 18px var(--gold); outline: 2px solid var(--gold); }
.demo-cell.targeted .card { outline: 2px solid var(--blood); box-shadow: 0 0 16px var(--blood); }
.demo-cell.dead { filter: grayscale(1) brightness(.45); }
.demo-hp { position: relative; height: 14px; margin-top: 3px; background: #241b22;
  border: 1px solid #3a3340; border-radius: 7px; overflow: hidden; }
.demo-hpfill { height: 100%; background: #6fc97a; transition: width .3s; }
.demo-hp span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
.demo-pop { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); z-index: 5;
  font-size: 20px; font-weight: 800; color: #e06a6a; text-shadow: 0 2px 4px #000;
  animation: demoPop 1s ease-out forwards; pointer-events: none; }
.demo-pop.heal { color: #6fc97a; }
@keyframes demoPop { 0% { opacity: 0; transform: translate(-50%, 6px); } 20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -22px); } }
.demo-caption { display: flex; align-items: center; gap: 10px; margin: 10px auto; padding: 12px 16px;
  width: min(760px, 100%); min-height: 58px; background: rgba(30,24,34,.9);
  border: 1px solid #4a3f55; border-left: 4px solid var(--gold); border-radius: 8px; }
.demo-tag { flex-shrink: 0; padding: 3px 10px; border-radius: 12px; background: var(--gold); color: #1a1410;
  font-size: 12px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.demo-tag.hidden { display: none; }
#demo-text { color: var(--ink); font-size: 15px; line-height: 1.45; }
.demo-controls { text-align: center; margin-top: 6px; }
@media (max-width: 640px) {
  .demo-cell { width: 82px; }
  .demo-cell .card { width: 82px; height: 115px; }
  #demo-text { font-size: 13px; }
}

/* ---------- full-launch countdown chip + announcement ---------- */
.launch-chip { position: fixed; left: 12px; right: auto; bottom: 12px; z-index: 55;
  background: linear-gradient(180deg, #2a2030, #17121c); border: 1px solid var(--gold);
  color: var(--ink); padding: 8px 14px; font-size: 13px; letter-spacing: 1px; border-radius: 20px;
  box-shadow: 0 0 18px rgba(200,164,90,.35); }
.launch-chip b { color: var(--gold); }
.launch-pop { position: fixed; inset: 0; z-index: 70; background: rgba(5,4,7,.9);
  display: flex; align-items: center; justify-content: center; }
.launch-pop.hidden { display: none; }
.launch-box { width: min(480px, 92vw); text-align: center; padding: 28px 26px;
  background: rgba(14,11,16,.98); border: 1px solid var(--gold); border-radius: 12px;
  box-shadow: 0 0 80px rgba(200,164,90,.25); }
.launch-box h2 { margin: 0 0 4px; color: var(--gold); letter-spacing: 3px; font-family: Georgia, serif; }
.launch-when { color: var(--muted); letter-spacing: 2px; font-size: 13px; }
.launch-count { font-size: 34px; font-weight: 800; color: var(--ink); margin: 12px 0;
  text-shadow: 0 0 16px var(--blood); font-family: Georgia, serif; }
