/* Divinity Worlds: Clash of Beasts — base tokens & shared components.
 * Visual language from the divinity-worlds-website: black grounds,
 * gold trim (#D8C26B/#A17A37), Trajan Pro display type, element accents. */

@font-face {
  font-family: "Trajan";
  src: url("../assets/fonts/TRAJANPRO3-REGULAR.otf") format("opentype");
  font-weight: 400;
}
@font-face {
  font-family: "Trajan";
  src: url("../assets/fonts/TRAJANPRO3-BOLD_1.otf") format("opentype");
  font-weight: 700;
}
@font-face {
  font-family: "Elan";
  src: url("../assets/fonts/ELAN_REGULAR.TTF") format("truetype");
}

:root {
  --gold: #d8c26b;
  --gold-dark: #a17a37;
  --gold-dim: #7c6530;
  --gold-pale: #bfa05a;
  --ink: #0a0806;
  --panel: #14100a;
  --panel-2: #1c1610;
  --line: #2a2926;
  --text: #e6e0d2;
  --text-dim: #8b877c;
  --danger: #d05a48;
  --rar-common: #9aa0a8;
  --rar-rare: #d8c26b;
  --rar-epic: #a884e0;
  --rar-legendary: #e0a24a;
  /* refined near-black grounds (cool, like divinityworlds.com), warmth removed */
  --ink: #08090b;
  --panel: #0e0f12;
  --panel-2: #141519;
  /* subtle gold accents used as hairlines, not fills */
  --gold-line: rgba(216, 194, 107, 0.16);
  --gold-line-hi: rgba(216, 194, 107, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: "Elan", Georgia, serif;
  background: var(--ink);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

/* ---------- shared starfield (identical to divinityworlds.com) ----------
 * Three tiled layers: static stars, a slow-drifting twinkle, and clouds.
 * Sits behind everything so the game reads as the same site — the moment
 * you cross from divinityworlds.com into /game the backdrop never changes. */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #000;
}
#starfield .stars,
#starfield .twinkling,
#starfield .clouds {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#starfield .stars { background: #000 url("../assets/site/stars.png") repeat top center; }
#starfield .twinkling { background: transparent url("../assets/site/twinkling.png") repeat top center; animation: moveTwinkBack 200s linear infinite; }
#starfield .clouds { background: transparent url("../assets/site/clouds.png") repeat top center; opacity: 0.16; animation: moveCloudsBack 240s linear infinite; }
@keyframes moveTwinkBack { from { background-position: 0 0; } to { background-position: -10000px 5000px; } }
@keyframes moveCloudsBack { from { background-position: 0 0; } to { background-position: 10000px 0; } }

#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

#screens { position: fixed; inset: 0; z-index: 2; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  opacity: 0;
}
.screen.active { display: flex; opacity: 1; }
.screen.entering { animation: screenIn 0.45s ease-out; }
.screen.exiting { animation: screenOut 0.3s ease-in forwards; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.015); } to { opacity: 1; transform: none; } }
@keyframes screenOut { to { opacity: 0; transform: scale(0.99); } }

/* ---------- type ---------- */

.h-display {
  font-family: "Trajan", serif;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}
.h-sub {
  font-family: "Trajan", serif;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---------- buttons ---------- */

/* refined: hairline gold on near-black, muted gold text — like the site's
 * "VIEW ALL CHARACTERS" / card-type tabs. No filled warm gradients. */
.btn {
  font-family: "Trajan", serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-pale);
  background: rgba(216, 194, 107, 0.025);
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  padding: 10px 22px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}
.btn:hover { border-color: var(--gold-line-hi); color: #efe4c4; background: rgba(216, 194, 107, 0.06); }
.btn:disabled { opacity: 0.3; cursor: default; background: none; border-color: var(--gold-line); color: var(--gold-pale); }
.btn.primary {
  background: rgba(216, 194, 107, 0.10);
  color: var(--gold);
  border-color: var(--gold-line-hi);
}
.btn.primary:hover { background: rgba(216, 194, 107, 0.17); border-color: var(--gold); color: #f4ebcf; }
.btn.big { font-size: 14px; padding: 15px 42px; letter-spacing: 0.22em; }
.btn.danger { color: #b06a5c; border-color: rgba(208, 90, 72, 0.28); background: rgba(208, 90, 72, 0.03); }
.btn.danger:hover { color: #d0806f; border-color: rgba(208, 90, 72, 0.5); background: rgba(208, 90, 72, 0.07); }

/* ornate gold-bracket CTA — modelled on the site's "Bio" / crystal buttons.
 * Notched corners, a double gold frame, gold gradient text, and small
 * diamond bracket accents flanking the label. Scales to any width. */
.btn.ornate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: "Trajan", serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #e7d5a2;
  background: linear-gradient(180deg, rgba(44, 35, 18, 0.55), rgba(18, 13, 6, 0.7));
  border: 1px solid #9a7433;
  border-radius: 0;
  padding: 15px 40px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  box-shadow: inset 0 0 0 1px rgba(216, 194, 107, 0.16), inset 0 0 22px rgba(0, 0, 0, 0.5), 0 6px 22px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
/* diamond bracket accents on each side of the label */
.btn.ornate::before,
.btn.ornate::after {
  content: "";
  width: 6px; height: 6px;
  flex: 0 0 auto;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 8px rgba(216, 194, 107, 0.6);
  transition: all 0.2s ease;
}
.btn.ornate:hover {
  color: #fbf1d2;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(62, 49, 24, 0.6), rgba(26, 19, 9, 0.75));
  box-shadow: inset 0 0 0 1px rgba(216, 194, 107, 0.32), inset 0 0 26px rgba(0, 0, 0, 0.5), 0 0 26px rgba(216, 194, 107, 0.18);
}
.btn.ornate:hover::before, .btn.ornate:hover::after { box-shadow: 0 0 12px rgba(216, 194, 107, 0.9); }
.btn.ornate:disabled { opacity: 0.4; cursor: default; box-shadow: inset 0 0 0 1px rgba(216, 194, 107, 0.12); }
.btn.ornate.big { font-size: 15px; padding: 17px 52px; letter-spacing: 0.34em; }

/* ---------- top bar shared by inner screens ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 8, 6, 0.82);
  flex: 0 0 auto;
  z-index: 5;
}
.topbar .back { flex: 0 0 auto; }
.topbar .title { font-size: 16px; }
.topbar .spacer { flex: 1; }
.topbar .currency {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-dim);
}
.topbar .currency b { color: var(--gold-pale); font-size: 15px; }

/* ---------- cards (shared component) ---------- */

.card {
  position: relative;
  width: 118px;
  aspect-ratio: 5 / 7;
  border-radius: 7px;
  background: linear-gradient(180deg, #2a2214, #171208);
  border: 1px solid var(--gold-dim);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  flex: 0 0 auto;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s, filter 0.2s;
  --accent: var(--gold);
  --rar: var(--rar-common);
}
.card:hover { transform: translateY(-6px) scale(1.04); z-index: 30; }

.card .art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 18%;
  background-color: #1a140c;
}
.card .art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 22%, transparent 55%, rgba(5,3,1,0.92) 88%);
}
.card .art.noart {
  display: flex; align-items: center; justify-content: center;
}
.card .art.noart img { width: 46%; opacity: 0.8; filter: drop-shadow(0 0 12px var(--accent)); }

.card .frame {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-image: linear-gradient(160deg, var(--gold-pale), #4a3a18 40%, var(--gold-dark)) 1;
  pointer-events: none;
  z-index: 5;
}
.card.r-epic .frame { border-image: linear-gradient(160deg, #c9a4ff, #3a2470 40%, var(--rar-epic)) 1; }
.card.r-legendary .frame { border-image: linear-gradient(160deg, #ffd9a4, #703a10 40%, var(--rar-legendary)) 1; }

.card .cost {
  position: absolute;
  top: 4px; left: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffefa9, var(--gold-dark));
  border: 1px solid #fff3c4;
  color: #171004;
  font-family: "Trajan", serif;
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  z-index: 6;
}

.card .element {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px;
  z-index: 6;
}
.card .element img { width: 100%; height: 100%; object-fit: contain; }

.card .rargem {
  position: absolute;
  top: 30px; right: 9px;
  width: 13px; height: 13px;
  transform: rotate(45deg);
  background: var(--rar);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 6px var(--rar);
  z-index: 6;
}

.card .name {
  position: absolute;
  left: 0; right: 0;
  bottom: 34px;
  text-align: center;
  font-family: "Trajan", serif;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4ead0;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.9);
  padding: 0 4px;
  z-index: 6;
}

.card .kw {
  position: absolute;
  left: 0; right: 0;
  bottom: 22px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-shadow: 0 1px 2px #000;
  z-index: 6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

.card .spelltext {
  position: absolute;
  left: 0; right: 0;
  bottom: 6px;
  padding: 0 6px;
  text-align: center;
  font-size: 9.5px;
  line-height: 1.25;
  color: var(--text);
  text-shadow: 0 1px 2px #000;
  z-index: 6;
}

.card .stats {
  position: absolute;
  bottom: 3px; left: 4px; right: 4px;
  display: flex;
  justify-content: space-between;
  z-index: 6;
}
.card .stats span {
  font-family: "Trajan", serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 0 5px #000, 0 0 5px #000;
}
.card .stats .atk { color: #ffd76e; }
.card .stats .hp { color: #ff8d75; }
.card .stats .hp.wounded { color: var(--danger); }
.card .stats .buffed { color: #8fdd4c; }

.card .count-badge {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(10, 8, 6, 0.9);
  border: 1px solid var(--gold-dim);
  color: var(--gold-pale);
  border-radius: 9px;
  font-size: 10px;
  padding: 1px 7px;
  z-index: 7;
  font-family: "Trajan", serif;
  font-weight: 700;
}

.card.unowned { filter: grayscale(0.95) brightness(0.45); }
.card.unowned:hover { filter: grayscale(0.7) brightness(0.6); }

/* legendary shimmer */
.card.r-legendary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 214, 140, 0.16) 46%, rgba(255, 244, 214, 0.28) 50%, rgba(255, 214, 140, 0.16) 54%, transparent 70%);
  background-size: 260% 100%;
  animation: foil 4.5s linear infinite;
}
@keyframes foil { 0% { background-position: 130% 0; } 100% { background-position: -130% 0; } }

.card-back {
  width: 96px;
  aspect-ratio: 5 / 7;
  border-radius: 7px;
  border: 1px solid var(--gold-dim);
  background:
    url("../assets/art/cardback.jpg") center / cover no-repeat,
    linear-gradient(160deg, #221a0e, #0e0a05);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.card-back img { display: none; }

/* ---------- overlays ---------- */

#modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#modal-root .overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  animation: screenIn 0.25s ease-out;
}
#modal-root .panel {
  max-width: 760px;
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 34px 42px;
  text-align: center;
  box-shadow: 0 0 60px rgba(216, 194, 107, 0.12);
}

#toast {
  position: fixed;
  top: 64px; left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 16, 10, 0.95);
  border: 1px solid var(--gold-dim);
  color: var(--gold-pale);
  font-family: "Trajan", serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 26px;
  border-radius: 4px;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#toast.show { opacity: 1; }

#zoom {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  display: none;
  width: 250px;
  aspect-ratio: 5 / 7;
  filter: drop-shadow(0 12px 40px #000);
}
#zoom .card { width: 100%; height: 100%; cursor: default; }
#zoom .card:hover { transform: none; }
#zoom .card .name { font-size: 15px; bottom: 74px; }
#zoom .card .kw { font-size: 12px; bottom: 54px; }
#zoom .card .spelltext { font-size: 13px; bottom: 24px; }
#zoom .card .stats span { font-size: 22px; }
#zoom .card .cost { width: 38px; height: 38px; font-size: 20px; }
#zoom .card .element { width: 34px; height: 34px; }
#zoom .card .rargem { top: 46px; right: 12px; width: 17px; height: 17px; }
#zoom .card .flavor {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  padding: 0 10px;
  font-size: 10.5px;
  font-style: italic;
  color: #cfc5a6;
  text-shadow: 0 1px 2px #000;
  z-index: 6;
  text-align: center;
}

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* page tabs (Collection ⇄ Deck Builder consolidated view) */
.page-tabs { display: flex; gap: 4px; }
.page-tab {
  font-family: "Trajan", serif; font-weight: 700; font-size: 12px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-dim); background: transparent;
  border: 1px solid transparent; border-bottom: 2px solid transparent;
  padding: 8px 16px; cursor: pointer; transition: all 0.16s ease;
}
.page-tab:hover { color: var(--gold-pale); }
.page-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
