/* ============================================================
   Beast Gambit — stylesheet
   Look: dark wood + parchment, pixel-art everywhere.
   UI sprites: Crusenho Agus Hennihuno (CC BY 4.0)
   Pixel art: Minifantasy by Krishna Palacio
   ============================================================ */

:root {
  --wood:      #2a1c12;
  --wood-2:    #3b2417;
  --parch:     #f0d9a8;
  --parch-2:   #e2c184;
  --ink:       #3a2410;
  --gold:      #d9a441;
  --blood:     #c0392b;
  --mana:      #3fa7dd;
  --atk:       #e8a33d;
  --hp:        #d6473c;
  --rar-c:     #b9b3a5;
  --rar-r:     #4da6ff;
  --rar-e:     #b36bff;
  --rar-l:     #ffb13d;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

html, body { height: 100%; }

body {
  background: var(--wood);
  color: var(--parch);
  font-family: "Verdana", "DejaVu Sans", sans-serif;
  overflow: hidden;
}

img { image-rendering: pixelated; -webkit-user-drag: none; }

#app { width: 100vw; height: 100vh; position: relative; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: bold;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: linear-gradient(180deg, #f3d9a4 0%, #e4bd7d 55%, #cda05c 100%);
  border: 2px solid #7a5126;
  border-radius: 6px;
  box-shadow: 0 3px 0 #5d3c1a, inset 0 1px 0 #fff3;
  padding: 0.5em 1.2em;
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5d3c1a; }
.btn:disabled { opacity: 0.45; cursor: default; filter: grayscale(0.6); }
.btn.big { font-size: 1.05rem; padding: 0.65em 1.8em; }
.btn.small { font-size: 0.72rem; padding: 0.35em 0.8em; }
.btn.danger { background: linear-gradient(180deg, #e8a193 0%, #cf6f5a 55%, #b25140 100%); border-color: #6e2a1c; box-shadow: 0 3px 0 #571f13, inset 0 1px 0 #fff3; color: #2d0d06; }
.btn.back { margin-right: 1rem; }

/* ---------- panels ---------- */
.panel {
  background: linear-gradient(180deg, #f3dba9, #e7c88d);
  border: 3px solid #7a5126;
  border-radius: 8px;
  box-shadow: 0 6px 18px #0008, inset 0 0 0 2px #fff2;
  color: var(--ink);
}

/* ============================================================
   TITLE SCREEN
   ============================================================ */
#screen-title { align-items: center; justify-content: center; }

.title-backdrop {
  position: absolute; inset: 0;
  background: url("assets/backdrops/title.png") center/cover no-repeat;
  image-rendering: pixelated;
  filter: brightness(0.55) saturate(1.1);
}
.title-backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 30%, #14080cdd 100%);
}

.title-inner { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }

.title-mascots { display: flex; gap: 2.2rem; height: 96px; align-items: flex-end; }
.mascot { width: 96px; height: 96px; overflow: hidden; position: relative; filter: drop-shadow(0 4px 6px #000a); }
.mascot img { position: absolute; width: 200%; left: -50%; top: -36%; }
.mascot.m2 { transform: scale(1.25); }

.game-title {
  font-size: 4.2rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 2px 0 #5d3c1a, 0 4px 0 #2a1607, 0 8px 22px #000c, 0 0 40px #d9a44144;
  font-family: Georgia, "Times New Roman", serif;
}
.game-sub { color: var(--parch-2); font-style: italic; text-shadow: 0 2px 4px #000; }

.title-menu { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.6rem; min-width: 260px; }
.title-foot { margin-top: 1.4rem; font-size: 0.72rem; color: #cdb088; text-shadow: 0 1px 2px #000; }

/* ============================================================
   GENERIC SCREEN HEADER
   ============================================================ */
.screen-head {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.8rem 1.2rem;
  background: linear-gradient(180deg, #46301d, #33210f);
  border-bottom: 3px solid #1b0f06;
  box-shadow: 0 3px 10px #0008;
  z-index: 2;
}
.screen-head h2 { color: var(--gold); letter-spacing: 0.06em; font-family: Georgia, serif; }
.head-note { margin-left: auto; font-size: 0.8rem; color: var(--parch-2); }

/* ============================================================
   CAMPAIGN
   ============================================================ */
#opponent-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1rem;
  padding: 1.4rem 12vw;
  background:
    radial-gradient(ellipse at top, #3b2417 0%, #241509 70%),
    var(--wood);
}

.opp-row {
  display: flex; align-items: center; gap: 1.2rem;
  background: linear-gradient(180deg, #f0d9a8, #ddbd80);
  color: var(--ink);
  border: 3px solid #7a5126;
  border-radius: 10px;
  padding: 0.8rem 1.2rem;
  box-shadow: 0 5px 14px #0007;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s;
}
.opp-row.unlocked:hover { transform: translateY(-2px) scale(1.01); box-shadow: 0 9px 20px #000a; }
.opp-row.locked { filter: grayscale(0.85) brightness(0.7); }
.opp-row.boss { border-color: var(--rar-l); box-shadow: 0 0 18px #ffb13d55, 0 5px 14px #0007; }

.opp-portrait {
  width: 84px; height: 84px; flex: none;
  border: 3px solid #7a5126; border-radius: 8px;
  background: radial-gradient(circle at 50% 35%, #6b4a86, #2c1c3c);
  overflow: hidden; position: relative;
}
.opp-portrait img { position: absolute; width: 200%; left: -50%; top: -36%; }

.opp-text { flex: 1; }
.opp-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; color: #8a5e22; font-weight: bold; }
.opp-name { font-size: 1.25rem; font-weight: bold; font-family: Georgia, serif; }
.opp-blurb { font-size: 0.8rem; margin-top: 0.2rem; color: #57401f; }
.opp-status { text-align: right; font-size: 0.78rem; font-weight: bold; color: #57401f; white-space: nowrap; }
.opp-status .beaten { color: #2e7d32; }
.opp-fight { margin-left: 0.6rem; }

/* ============================================================
   CARDS (hand, collection, booster, tooltip)
   ============================================================ */
.card {
  --cw: 130px;
  width: var(--cw);
  height: calc(var(--cw) * 1.45);
  position: relative;
  border-radius: calc(var(--cw) * 0.06);
  background:
    linear-gradient(160deg, #54391f 0%, #3a2412 55%, #2c1a0c 100%);
  border: 2px solid #1c0f05;
  box-shadow: 0 4px 10px #000a, inset 0 0 0 2px var(--rim, #8a6a3a);
  color: var(--parch);
  flex: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card.rar-c { --rim: #9b9485; }
.card.rar-r { --rim: #3f8fd9; }
.card.rar-e { --rim: #9a5de0; }
.card.rar-l { --rim: #e8a33d; }
.card.rar-l { box-shadow: 0 4px 10px #000a, inset 0 0 0 2px var(--rim), 0 0 12px #e8a33d66; }
.card.rar-t { --rim: #7c8f7a; }

.card-cost {
  position: absolute; top: calc(var(--cw) * -0.055); left: calc(var(--cw) * -0.055);
  width: calc(var(--cw) * 0.26); height: calc(var(--cw) * 0.26);
  background: radial-gradient(circle at 35% 30%, #7cc7ef, #2274a8 70%, #14506e);
  border: 2px solid #0c3349;
  border-radius: 28% 72% 60% 40% / 40% 45% 55% 60%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: calc(var(--cw) * 0.15);
  color: #fff; text-shadow: 0 1px 2px #000;
  z-index: 3;
}

.card-art {
  position: absolute;
  top: calc(var(--cw) * 0.07); left: calc(var(--cw) * 0.07);
  width: calc(var(--cw) * 0.86); height: calc(var(--cw) * 0.74);
  overflow: hidden;
  border-radius: 4px;
  border: 2px solid #00000088;
  box-shadow: inset 0 0 0 1px #ffffff22, inset 0 -10px 18px #0006;
  background: radial-gradient(circle at 50% 30%, var(--artbg1, #5e4a72), var(--artbg2, #241a31) 80%);
}
.card.tribe-Slime    .card-art { --artbg1:#4c7a4f; --artbg2:#17301c; }
.card.tribe-Beast    .card-art { --artbg1:#7a6440; --artbg2:#2c2112; }
.card.tribe-Dinosaur .card-art { --artbg1:#5c7a3c; --artbg2:#1e2c10; }
.card.tribe-Undead   .card-art { --artbg1:#4f5e78; --artbg2:#161d2c; }
.card.tribe-Monster  .card-art { --artbg1:#7a4444; --artbg2:#2c1212; }
.card.tribe-Humanoid .card-art { --artbg1:#6e5b85; --artbg2:#241a31; }
.card.tribe-Companion.card-art, .card.tribe-Companion .card-art { --artbg1:#3c6a7a; --artbg2:#0f242c; }
.card.spell .card-art { --artbg1:#41356b; --artbg2:#120d24; }

.card-art img { position: absolute; display: block; }

.card-name {
  position: absolute;
  top: calc(var(--cw) * 0.83); left: 4%; width: 92%;
  text-align: center;
  font-weight: bold;
  font-size: calc(var(--cw) * 0.085);
  line-height: 1.1;
  color: var(--parch);
  text-shadow: 0 1px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-text {
  position: absolute;
  top: calc(var(--cw) * 0.96); left: 5%; width: 90%;
  height: calc(var(--cw) * 0.40);
  font-size: calc(var(--cw) * 0.067);
  line-height: 1.22;
  text-align: center;
  color: var(--parch-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-text .kw { color: var(--gold); font-weight: bold; }

.card-atk, .card-hp {
  position: absolute; bottom: calc(var(--cw) * -0.05);
  width: calc(var(--cw) * 0.25); height: calc(var(--cw) * 0.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: calc(var(--cw) * 0.14);
  color: #fff; text-shadow: 0 1px 2px #000;
  border-radius: 50%;
  z-index: 3;
}
.card-atk { left: calc(var(--cw) * -0.05); background: radial-gradient(circle at 35% 30%, #f5c36a, #b06f17 75%); border: 2px solid #5d3a08; }
.card-hp  { right: calc(var(--cw) * -0.05); background: radial-gradient(circle at 35% 30%, #ef8a7a, #a3271c 75%); border: 2px solid #58110a; }

.card.spell .card-atk, .card.spell .card-hp { display: none; }

.card-rarity-gem {
  position: absolute; top: calc(var(--cw) * 0.76); left: 50%;
  width: calc(var(--cw) * 0.10); height: calc(var(--cw) * 0.10);
  transform: translateX(-50%) rotate(45deg);
  background: var(--rim);
  border: 1px solid #000a;
  box-shadow: 0 0 6px var(--rim);
  z-index: 2;
}

/* hand interactions */
#hand .card { cursor: pointer; }
#hand .card:hover { transform: translateY(-26px) scale(1.12); z-index: 20; box-shadow: 0 14px 26px #000c, inset 0 0 0 2px var(--rim); }
#hand .card.unaffordable { filter: grayscale(0.55) brightness(0.72); }
#hand .card.selected { transform: translateY(-30px) scale(1.14); z-index: 21; outline: 3px solid var(--gold); outline-offset: 2px; }

/* card backs (booster) */
.card.facedown { background: linear-gradient(160deg,#5d3c1a,#33200d); cursor: pointer; }
.card.facedown::after {
  content: "❖";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cw) * 0.5);
  color: var(--gold); text-shadow: 0 0 14px #d9a44188;
}
.card.facedown > * { visibility: hidden; }

/* ============================================================
   COLLECTION / DECK BUILDER
   ============================================================ */
#builder { flex: 1; display: flex; min-height: 0; background: radial-gradient(ellipse at top, #3b2417 0%, #241509 70%); }

#collection-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.4rem 0.9rem;
  padding: 1.6rem 1.4rem 2.5rem;
  align-content: start;
}
#collection-grid .ccell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.45rem; }
#collection-grid .card { --cw: 124px; cursor: pointer; }
#collection-grid .card:hover { transform: scale(1.06); z-index: 5; }
#collection-grid .card.unowned { filter: grayscale(1) brightness(0.5); }
.ccount { font-size: 0.72rem; color: var(--parch-2); }
.ccount .in-deck { color: var(--gold); font-weight: bold; }

#deck-panel {
  width: 300px; flex: none;
  background: linear-gradient(180deg, #f0d9a8, #ddbd80);
  border-left: 4px solid #1b0f06;
  color: var(--ink);
  display: flex; flex-direction: column;
  padding: 1rem;
}
#deck-panel h3 { font-family: Georgia, serif; display: flex; justify-content: space-between; align-items: baseline; }
#deck-count { font-size: 0.9rem; }
#deck-count.bad { color: var(--blood); }
#deck-count.good { color: #2e7d32; }

#deck-list { flex: 1; overflow-y: auto; margin: 0.7rem 0; display: flex; flex-direction: column; gap: 4px; }
.deck-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: #fff7e333;
  border: 1px solid #7a512655;
  border-left: 4px solid var(--rim, #9b9485);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}
.deck-row:hover { background: #c0392b22; }
.deck-row .dr-cost { font-weight: bold; color: #14506e; width: 1.2em; }
.deck-row .dr-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-row .dr-n { font-weight: bold; }
.deck-row.rar-r { --rim: var(--rar-r); }
.deck-row.rar-e { --rim: var(--rar-e); }
.deck-row.rar-l { --rim: var(--rar-l); }
.deck-actions { display: flex; gap: 0.5rem; }
.deck-hint { font-size: 0.7rem; margin-top: 0.5rem; color: #57401f; }

/* ============================================================
   BATTLE
   ============================================================ */
#battlefield {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bf-bg, url("assets/backdrops/plains.png")) center/cover no-repeat;
  position: relative;
  min-height: 0;
}
#battlefield::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, #100a14cc 0%, #1c102255 18%, #1c102255 82%, #100a14cc 100%);
  pointer-events: none;
}

.hero-bar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.45rem 1rem;
}
#enemy-bar { background: linear-gradient(180deg, #1a0e08ee, #1a0e0866); }
#player-bar { background: linear-gradient(0deg, #1a0e08ee, #1a0e0866); min-height: 150px; }

.hero-panel { display: flex; align-items: center; gap: 0.7rem; }
.hero-portrait {
  width: 72px; height: 72px; flex: none;
  border: 3px solid var(--gold); border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #57406b, #1d1428);
  overflow: hidden; position: relative;
  box-shadow: 0 0 10px #000a;
}
.hero-portrait img { position: absolute; width: 200%; left: -50%; top: -36%; }
.hero-panel.hit .hero-portrait { animation: shake 0.4s; border-color: var(--blood); }

.hero-name { font-weight: bold; font-family: Georgia, serif; text-shadow: 0 1px 3px #000; }
.hero-hp { display: flex; align-items: center; gap: 0.3rem; font-weight: bold; font-size: 1.05rem; }
.hero-hp::before {
  content: ""; width: 18px; height: 18px;
  background: url("assets/ui/icon_heart.png") center/contain no-repeat;
  image-rendering: pixelated;
}
.hp-num { text-shadow: 0 1px 2px #000; }
.hp-num.low { color: #ff7b6b; }

.mana-row { display: flex; gap: 3px; margin-top: 3px; height: 14px; align-items: center; }
.mana-gem {
  width: 11px; height: 11px;
  background: radial-gradient(circle at 35% 30%, #7cc7ef, #1c6794);
  border: 1px solid #0c3349;
  border-radius: 30% 70% 60% 40% / 40% 45% 55% 60%;
}
.mana-gem.spent { background: #20303a; opacity: 0.5; }
.mana-label { font-size: 0.7rem; margin-left: 4px; color: #9fd3f0; font-weight: bold; text-shadow: 0 1px 2px #000; }

.pile-info { display: flex; gap: 0.8rem; font-size: 0.75rem; color: var(--parch-2); text-shadow: 0 1px 2px #000; }
.pile-info .deck-count::before { content: "🂠 "; font-size: 0.9rem; }
.pile-info .hand-count::before { content: "✋ "; }

#btn-concede, #btn-mute { margin-left: auto; }
#btn-concede { margin-left: auto; }
#enemy-bar .pile-info { margin-left: 2rem; }

/* ----- lanes ----- */
#lanes {
  flex: 1; position: relative; z-index: 1;
  display: flex; justify-content: center; gap: 2.5%;
  padding: 0.5rem 4% 0.4rem;
  min-height: 0;
}
.lane {
  flex: 1; max-width: 250px;
  display: flex; flex-direction: column;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c0e2466, #0c081288 50%, #1c0e2466);
  box-shadow: inset 0 0 0 2px #d9a44140, inset 0 0 40px #000a;
  position: relative;
  padding: 6px;
}
.lane::after {
  content: "⚔"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: #d9a44166; font-size: 0.9rem; pointer-events: none;
}
.lane.droppable { box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 30px #d9a44133; cursor: pointer; }
.lane.spell-target { box-shadow: inset 0 0 0 3px #79e06b, inset 0 0 30px #79e06b33; cursor: pointer; }

.lane-half { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.lane-mid {
  height: 2px; margin: 2px 8%;
  background: linear-gradient(90deg, transparent, #d9a44155, transparent);
}

.slot {
  width: 46%; aspect-ratio: 0.92;
  max-height: 100%;
  border-radius: 10px;
  border: 2px dashed #d9a44138;
  background: #0000001c;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.slot.droppable { border-color: var(--gold); background: #d9a44122; cursor: pointer; box-shadow: 0 0 12px #d9a44155; }
.slot.occupied { border-style: solid; border-color: transparent; }

/* ----- units on board ----- */
.unit {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s ease;
}
.unit .u-sprite {
  position: absolute; inset: 4% 4% 18% 4%;
  overflow: hidden;
}
.unit .u-sprite img { position: absolute; display: block; }
.unit.enemy-side .u-sprite { transform: scaleX(-1); }

.unit .u-stats {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px;
  z-index: 3;
}
.unit .u-atk, .unit .u-hp {
  min-width: 22px; height: 22px; padding: 0 3px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000;
}
.unit .u-atk { background: radial-gradient(circle at 35% 30%, #f5c36a, #b06f17 75%); border: 2px solid #5d3a08; }
.unit .u-hp  { background: radial-gradient(circle at 35% 30%, #ef8a7a, #a3271c 75%); border: 2px solid #58110a; }
.unit .u-hp.hurt { color: #ffd2cc; }
.unit .u-atk.buffed, .unit .u-hp.buffed { box-shadow: 0 0 8px #79e06b; }

.unit .u-kw {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  font-size: 0.58rem; font-weight: bold; letter-spacing: 0.05em;
  background: #000a; color: var(--gold);
  border: 1px solid #d9a44166;
  border-radius: 8px; padding: 1px 7px;
  white-space: nowrap; z-index: 3;
}

.unit.sick::after {
  content: "z";
  position: absolute; top: 6%; right: 8%;
  color: #cfd8ff; font-weight: bold; font-size: 0.8rem;
  text-shadow: 0 1px 3px #000;
  animation: floaty 1.6s infinite ease-in-out;
  z-index: 3;
}
.unit.frozen { filter: saturate(0.4) brightness(1.05); }
.unit.frozen::before {
  content: "❄";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #bfe7ff;
  background: linear-gradient(180deg, #9fd3f044, #4d9fd066);
  border-radius: 10px;
  text-shadow: 0 0 8px #fff;
  z-index: 2;
}
.unit.can-attack .u-sprite { filter: drop-shadow(0 0 5px #79e06b88); }

.unit.spell-target { cursor: pointer; }
.unit.spell-target::after {
  content: ""; position: absolute; inset: -2px;
  border: 3px solid #79e06b; border-radius: 12px;
  box-shadow: 0 0 12px #79e06b88;
  animation: pulse 0.9s infinite;
  z-index: 4;
}
.hero-panel.spell-target { cursor: pointer; border-radius: 10px; }
.hero-panel.spell-target::after { content:""; position:absolute; }
.hero-panel.spell-target .hero-portrait { border-color: #79e06b; box-shadow: 0 0 14px #79e06b; }

/* attack lunge handled in JS via transform; death anim: */
.unit.dying { animation: die 0.5s forwards; }
@keyframes die {
  0% { filter: none; }
  100% { transform: scale(0.2) rotate(18deg); opacity: 0; filter: grayscale(1); }
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}
.shake { animation: shake 0.35s; }

@keyframes floaty {
  0%,100% { transform: translateY(0); opacity: 0.9; }
  50% { transform: translateY(-5px); opacity: 0.5; }
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.45; }
}

/* damage / heal popups */
.popup {
  position: fixed; z-index: 90;
  font-size: 1.5rem; font-weight: bold;
  pointer-events: none;
  text-shadow: 0 2px 2px #000, 0 0 8px #000;
  animation: popfloat 0.9s forwards ease-out;
  transform: translate(-50%, -50%);
}
.popup.dmg { color: #ff5b4a; }
.popup.heal { color: #7be06b; }
.popup.info { color: #ffd97a; font-size: 1rem; }
@keyframes popfloat {
  0% { opacity: 0; margin-top: 6px; transform: translate(-50%,-50%) scale(0.6); }
  18% { opacity: 1; transform: translate(-50%,-50%) scale(1.25); }
  100% { opacity: 0; margin-top: -44px; transform: translate(-50%,-50%) scale(1); }
}

/* fx overlay gif */
.fxgif {
  position: fixed; z-index: 85;
  width: 90px; height: 90px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  image-rendering: pixelated;
}

/* ----- hand ----- */
#hand {
  flex: 1;
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0; height: 100%;
  padding-bottom: 6px;
  min-width: 0;
}
#hand .card { --cw: 118px; margin: 0 -14px; }

#turn-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }

#banner {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
  z-index: 50;
  background: linear-gradient(90deg, transparent, #100a14ee 18%, #100a14ee 82%, transparent);
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 2rem; font-weight: bold; letter-spacing: 0.2em;
  padding: 0.5em 3em;
  text-shadow: 0 2px 6px #000;
  pointer-events: none;
  animation: bannerIn 1.4s forwards;
  white-space: nowrap;
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%,-50%) scale(1.05); }
  30% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   TOOLTIP (enlarged card preview)
   ============================================================ */
#tooltip {
  position: fixed; z-index: 120; pointer-events: none;
  filter: drop-shadow(0 10px 26px #000d);
}
#tooltip .card { --cw: 210px; }
#tooltip .tt-flavor {
  margin-top: 8px; width: 210px;
  background: #16100add; border: 1px solid #d9a44155; border-radius: 6px;
  color: var(--parch-2); font-style: italic; font-size: 0.72rem;
  padding: 6px 9px; text-align: center;
}
#tooltip .tt-kw {
  margin-top: 6px; width: 210px;
  background: #16100add; border: 1px solid #d9a44155; border-radius: 6px;
  color: var(--parch); font-size: 0.7rem;
  padding: 5px 9px; text-align: center;
}
#tooltip .tt-kw b { color: var(--gold); }

/* ============================================================
   OVERLAY MODALS (result, booster, confirm, campaign clear)
   ============================================================ */
#overlay {
  position: fixed; inset: 0; z-index: 100;
  background: #0a0510cc;
  display: flex; align-items: center; justify-content: center;
  animation: fadein 0.3s;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: linear-gradient(180deg, #f3dba9, #e0c084);
  border: 4px solid #7a5126;
  border-radius: 12px;
  box-shadow: 0 14px 50px #000d, inset 0 0 0 3px #fff3;
  color: var(--ink);
  padding: 2rem 2.6rem;
  text-align: center;
  max-width: min(760px, 92vw);
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal h2 { font-family: Georgia, serif; font-size: 2rem; margin-bottom: 0.4rem; }
.modal h2.victory { color: #2e7d32; text-shadow: 0 1px 0 #fff8; }
.modal h2.defeat { color: var(--blood); }
.modal p { margin: 0.4rem 0 1rem; font-size: 0.92rem; }
.modal .modal-buttons { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.2rem; }

.booster-row { display: flex; gap: 1.4rem; justify-content: center; margin: 1.4rem 0 0.6rem; perspective: 900px; }
.booster-row .card { --cw: 160px; }
.flip { transform-style: preserve-3d; transition: transform 0.45s; }
.flip.flipped { transform: rotateY(0deg); }
.booster-note { font-size: 0.78rem; color: #57401f; }
.rarename { font-weight: bold; }
.rarename.rar-c { color: #6e695e; }
.rarename.rar-r { color: #1f6dba; }
.rarename.rar-e { color: #7a36c9; }
.rarename.rar-l { color: #b06f17; }

.clear-art { display: flex; justify-content: center; gap: 1.6rem; margin: 1rem 0; height: 90px; align-items: flex-end; }
.clear-art .mascot { filter: drop-shadow(0 4px 6px #0008); }

/* credits */
.credits-body {
  margin: 2.5rem auto; padding: 2rem 3rem; max-width: 640px;
  overflow-y: auto;
}
.credits-body h3 { font-family: Georgia, serif; margin: 1rem 0 0.3rem; color: #7a5126; }
.credits-body p { font-size: 0.9rem; line-height: 1.5; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #1b0f06; }
::-webkit-scrollbar-thumb { background: #7a5126; border-radius: 5px; }

@media (max-width: 980px) {
  #hand .card { --cw: 96px; }
  .game-title { font-size: 2.8rem; }
  #deck-panel { width: 240px; }
}
