/* Pocket Legion — dark-fantasy GAME UI. Carved metal chrome, gem accents, painted backdrops. */

@font-face {
  font-family: 'Cinzel';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('../assets/fonts/cinzel-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Cinzel';
  font-style: normal; font-weight: 800; font-display: swap;
  src: url('../assets/fonts/cinzel-800.woff2') format('woff2');
}

:root {
  --bg0: #0a0b11;
  --bg1: #14172a;
  --ink: #ece6d6;          /* warm parchment text */
  --dim: #b3acc6;          /* muted text — brightened for readable contrast on dark panels */
  --gold: #f3c451;
  --gold-d: #a9791f;
  --red: #e8475c;
  --green: #58cf6d;
  --blue: #4aa8ff;
  --accent: #8b6bff;
  --steel: #2a3048;
  --steel-d: #11131f;
  --edge: rgba(243, 196, 81, 0.30);   /* gold hairline */
  --disp: 'Cinzel', Georgia, serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--bg0);
  display: flex;
  justify-content: center;
}

/* Painted atmosphere behind everything (falls back to gradient if art missing). */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(1000px 560px at 50% -8%, #28243f 0%, transparent 62%),
    radial-gradient(760px 480px at 82% 112%, #241531 0%, transparent 55%),
    var(--bg0);
  z-index: -2;
}
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: var(--scene, none);
  background-size: cover;
  background-position: center;
  opacity: 0.5;
  z-index: -1;
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.35) 55%, rgba(0,0,0,0.85));
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.35) 55%, rgba(0,0,0,0.85));
  transition: background-image 0.4s;
}
body.scene-title { --scene: url('../assets/icons/bg_title.png'); }
body.scene-game  { --scene: url('../assets/icons/bg_game.png'); }
body.scene-battle { --scene: url('../assets/icons/bg_battle.png'); }

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  animation: fadein 0.25s ease;
}

@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── inline art icons ── */
.ic { height: 1.05em; width: auto; vertical-align: -0.16em; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6)); }
.ic-mini { height: 12px; width: auto; vertical-align: -0.15em; }
.ic-lg { height: 1.4em; vertical-align: -0.28em; }

/* ── carved panel mixin (via utility class) ── */
.panel {
  background:
    linear-gradient(180deg, rgba(58,66,98,0.92), rgba(22,26,42,0.94));
  border: 1px solid var(--steel-d);
  border-radius: 9px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 0 0 1px rgba(243,196,81,0.08),
    0 4px 14px rgba(0,0,0,0.45);
}

/* Display headings */
h1, h2, h3 { font-family: var(--disp); font-weight: 800; letter-spacing: 0.5px; }

/* ───────── buttons ───────── */
.btn {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #f4eeda;
  border: 1px solid var(--steel-d);
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  background: linear-gradient(180deg, #39405e, #232a44);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -2px 4px rgba(0,0,0,0.35), 0 3px 10px rgba(0,0,0,0.4);
  transition: transform 0.07s ease, filter 0.15s;
}
.btn:active { transform: translateY(1px) scale(0.99); filter: brightness(1.12); }
.btn.primary {
  color: #2a1d00;
  background: linear-gradient(180deg, #ffe39a, #f3c451 45%, #c9921f);
  border-color: #7d5a14;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -2px 5px rgba(120,80,0,0.4), 0 4px 16px rgba(243,196,81,0.32);
}
.btn.danger { color: #fff0f0; background: linear-gradient(180deg, #e05266, #9c2436); border-color: #6e1626; }
.btn.ghost { background: linear-gradient(180deg, rgba(70,78,108,0.5), rgba(30,36,56,0.6)); }
.btn.big { font-size: 18px; padding: 15px 22px; width: 100%; }
.btn.small { font-size: 12.5px; padding: 8px 12px; }
.btn.disabled, .btn[disabled] { opacity: 0.4; pointer-events: none; }
.iconbtn {
  border: 1px solid var(--steel-d);
  background: linear-gradient(180deg, #353c58, #20263c);
  color: var(--ink);
  width: 42px; height: 42px;          /* comfortable mobile tap target */
  border-radius: 9px;
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 6px rgba(0,0,0,0.4);
}
.iconbtn:active { transform: scale(0.92); }

/* ───────── title ───────── */
.title-screen { justify-content: space-between; text-align: center; padding-top: 7vh; position: relative; overflow: hidden; }
.embers { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.ember {
  position: absolute; bottom: -10px;
  width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, #ffd97a, #f3884a);
  box-shadow: 0 0 6px #f3a14a;
  opacity: 0; animation-name: emberRise; animation-iteration-count: infinite; animation-timing-function: ease-out;
}
@keyframes emberRise {
  0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  12% { opacity: 0.8; }
  70% { opacity: 0.5; }
  100% { transform: translateY(-92vh) translateX(18px) scale(0.4); opacity: 0; }
}
.title-art, .title-btns, .title-foot { position: relative; z-index: 1; }
.title-emoji img { height: 168px; width: auto; filter: drop-shadow(0 8px 26px rgba(243,196,81,0.45)); animation: bob 3.4s ease-in-out infinite; }
.title-emoji { font-size: 84px; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.title-screen h1 {
  font-size: 50px;
  line-height: 0.96;
  letter-spacing: 5px;
  margin-top: 6px;
  background: linear-gradient(180deg, #fff2c8, #f3c451 52%, #a9791f);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 1px #000) drop-shadow(0 4px 14px rgba(0,0,0,0.6));
  text-shadow: 0 0 1px rgba(0,0,0,0.5);
}
.tagline { color: var(--gold); opacity: 0.85; margin-top: 12px; letter-spacing: 4px; font-size: 11px; text-transform: uppercase; font-family: var(--disp); }
.title-btns { display: flex; flex-direction: column; gap: 9px; }
.row2 { display: flex; gap: 8px; }
.row2 .btn { flex: 1; font-size: 12.5px; letter-spacing: 0.3px; padding: 11px 6px; white-space: nowrap; }
.row2 .btn .ic { height: 14px; }
.title-foot { color: var(--dim); font-size: 11px; margin-top: 14px; opacity: 0.7; letter-spacing: 1px; }
.crown-row { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 6px 0; flex-wrap: wrap; }
.crown-label, .crown-desc { font-size: 11px; color: var(--dim); font-family: var(--disp); letter-spacing: 1px; }
.crown {
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--steel-d);
  background: linear-gradient(180deg, #2c3350, #191e30);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: all 0.15s;
}
.crown .ic { height: 20px; }
.crown.sel { border-color: var(--gold); box-shadow: 0 0 12px rgba(243,196,81,0.45), inset 0 1px 0 rgba(255,255,255,0.2); transform: translateY(-2px); }
.crown.locked { opacity: 0.32; filter: grayscale(1); }

/* ───────── howto / stats ───────── */
.howto-screen { gap: 12px; padding-top: 8px; }
/* shared secondary-screen header: back chevron (left), centered title, balancing spacer */
.sub-head { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.sub-head h2 { flex: 1; text-align: center; color: var(--gold); font-size: 23px; }
.sub-head .sub-spacer { width: 38px; flex: 0 0 38px; }
.stat-screen { gap: 12px; padding-top: 8px; }
.stat-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.stat-body .stats-grid { width: 100%; }
.howto-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; color: #d6cebb; font-size: 14px; line-height: 1.45; }
.howto-row {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(40,46,70,0.55), rgba(20,24,38,0.55));
  border: 1px solid var(--steel-d); border-left: 3px solid var(--gold-d);
  border-radius: 9px; padding: 11px 13px;
}
.hr-ic { flex: 0 0 30px; display: flex; align-items: center; justify-content: center; }
.hr-ic .ic { height: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5)); }
.hr-text { flex: 1; }
.howto-body b { color: var(--gold); font-family: var(--disp); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stat-box {
  background: linear-gradient(180deg, rgba(48,55,84,0.9), rgba(20,24,38,0.92));
  border: 1px solid var(--steel-d);
  border-radius: 9px;
  padding: 13px 6px;
  text-align: center;
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 0 0 1px rgba(243,196,81,0.06);
}
.stat-box span { display: block; font-family: var(--disp); font-size: 23px; font-weight: 800; color: var(--gold); margin-bottom: 3px; }

/* ───────── topbar ───────── */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 9px; gap: 8px; }
.stage-label { font-family: var(--disp); font-weight: 800; font-size: 17px; color: #f4eeda; }
.of15 { color: var(--dim); font-size: 12px; font-weight: 600; }
.stage-name { color: var(--gold); opacity: 0.8; font-size: 11px; letter-spacing: 0.8px; font-family: var(--disp); }
.tb-right { display: flex; gap: 6px; align-items: center; }
.pill {
  font-family: var(--disp);
  background: linear-gradient(180deg, #2b3150, #161a29);
  border: 1px solid var(--steel-d);
  padding: 6px 11px 6px 9px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 6px rgba(0,0,0,0.4);
  display: inline-flex; align-items: center; gap: 4px;
}
.pill .ic { height: 15px; }
.pill.gold { color: var(--gold); border-color: #6b5212; }
.pill.hp { color: #ff8b97; border-color: #7a2230; }
.pill.bump-gain { animation: bumpGain 0.45s ease; }
.pill.bump-loss { animation: bumpLoss 0.45s ease; }
@keyframes bumpGain { 0% { transform: scale(1); } 40% { transform: scale(1.22); filter: brightness(1.5); } 100% { transform: scale(1); } }
@keyframes bumpLoss { 0% { transform: scale(1); } 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); filter: brightness(1.3); } 60% { transform: translateX(-2px); } 100% { transform: none; } }

/* ───────── relic strip ───────── */
.relic-strip { display: flex; gap: 6px; padding: 0 2px 7px; flex-wrap: wrap; }
.relic-chip {
  width: 34px; height: 34px;
  border-radius: 7px;
  border: 1px solid #6b5212;
  background: linear-gradient(180deg, #3a3014, #221a0c);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,220,120,0.18), 0 2px 6px rgba(0,0,0,0.4);
}
.relic-chip .ic { height: 22px; }
.relic-chip:active { transform: scale(0.9); }

/* ───────── combat lanes: free-standing figures on an art-directed ground ───────── */
/* The lane is a lit stage/floor band; units STAND on it (no per-unit boxes). */
.lane {
  display: flex; gap: 1px; align-items: flex-end; justify-content: center;
  position: relative;
  border-radius: 10px;
  padding: 10px 4px 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 22%, transparent 60%),
    radial-gradient(120% 80% at 50% 100%, rgba(0,0,0,0.35), transparent 75%);
}
.lane::before { /* lit front edge of the platform */
  content: ''; position: absolute; left: 8%; right: 8%; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
}
.lane::after { /* grounding floor line the units stand on */
  content: ''; position: absolute; left: 4%; right: 4%; bottom: 6px; height: 2px; border-radius: 2px;
  background: radial-gradient(60% 100% at 50% 50%, rgba(0,0,0,0.45), transparent 80%);
}
.player-lane { background:
  linear-gradient(180deg, rgba(90,150,255,0.08) 0%, rgba(90,150,255,0.03) 22%, transparent 60%),
  radial-gradient(120% 80% at 50% 100%, rgba(0,0,0,0.4), transparent 75%); }
.enemy-lane { background:
  linear-gradient(180deg, rgba(232,71,92,0.09) 0%, rgba(232,71,92,0.03) 22%, transparent 60%),
  radial-gradient(120% 80% at 50% 100%, rgba(0,0,0,0.4), transparent 75%); }

.lane-cell { /* transparent stage spot — a tap target, NOT a visible box */
  flex: 1 1 0; min-width: 0; max-width: 88px;
  aspect-ratio: 0.74;
  display: flex; align-items: flex-end; justify-content: center;
  position: relative;
}
.lane-cell.empty::before { /* faint footprint where a unit can stand */
  content: ''; position: absolute; bottom: 8%; left: 50%; transform: translateX(-50%);
  width: 52%; height: 13%; border-radius: 50%;
  border: 1px dashed rgba(150,165,210,0.28);
}
.lane-plus { position: absolute; bottom: 30%; left: 50%; transform: translateX(-50%); color: var(--dim); font-size: 18px; opacity: 0.35; }
.lane-cell.hint-slot .lane-plus { opacity: 0.9; color: var(--gold); animation: hintPulse 1.2s ease-in-out infinite; }
.lane-cell.hint-slot::before { border-color: var(--gold); animation: hintPulse 1.2s ease-in-out infinite; }
@keyframes hintPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; filter: drop-shadow(0 0 6px var(--gold)); } }
.lane-cell.drop-target.empty::before { border-color: rgba(243,196,81,0.6); border-style: solid; box-shadow: 0 0 10px rgba(243,196,81,0.3); }

.lane-ends { display: flex; justify-content: space-between; font-size: 9px; color: var(--dim); padding: 4px 6px 0; letter-spacing: 0.5px; text-transform: uppercase; font-family: var(--disp); }
.lane-ends .ic { height: 11px; }

.intel {
  background: linear-gradient(180deg, rgba(70,28,34,0.5), rgba(30,16,22,0.55));
  border: 1px solid #5e2530;
  border-radius: 10px;
  padding: 8px 8px 4px;
  margin-bottom: 7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.intel-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #ff9aa4; font-weight: 700; letter-spacing: 0.8px; margin-bottom: 4px; font-family: var(--disp); text-transform: uppercase; }
.intel-themes { color: var(--dim); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.intel-themes .ic { height: 13px; }

.board-wrap { margin-bottom: 7px; }
.forces-panel {
  background: linear-gradient(180deg, rgba(40,64,104,0.5), rgba(18,26,44,0.55));
  border: 1px solid #2a4a7a;
  border-radius: 10px;
  padding: 8px 8px 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.board-cap { display: flex; justify-content: space-between; align-items: center; font-family: var(--disp); font-size: 11px; color: #9fc2ff; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; padding: 0 2px 4px; }
.board-cap .ic { height: 13px; }
.bc-count { color: var(--ink); opacity: 0.7; letter-spacing: 0; }
.forces-panel .trait-row { padding: 0 0 6px; }
.forces-panel .player-lane { margin: 0; }

/* ───────── free-standing unit figure ───────── */
.figure {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  transition: transform 0.12s ease, filter 0.2s;
}
.fig-art {
  position: relative; z-index: 2;
  height: 84%; width: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 24px; /* emoji fallback size */
}
.fig-art img {
  height: 100%; width: auto; max-width: 112%; object-fit: contain; object-position: bottom;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,0.45));
}
/* soft contact shadow — grounds the sprite so it stands rather than floats */
.fig-base {
  position: absolute; bottom: 4%; left: 50%; transform: translateX(-50%);
  width: 58%; height: 11%; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0.2) 55%, transparent 75%);
  filter: blur(1.5px); z-index: 0;
  transition: box-shadow 0.2s, width 0.2s;
}
/* tier = a colored ground glow under the figure (rarity read without a box) */
.figure.tier2 .fig-base { box-shadow: 0 0 9px 2px rgba(63,154,85,0.5); }
.figure.tier3 .fig-base { box-shadow: 0 0 9px 2px rgba(47,127,207,0.55); }
.figure.tier4 .fig-base { box-shadow: 0 0 10px 3px rgba(154,79,207,0.6); }
.figure.tier5 .fig-base { box-shadow: 0 0 12px 4px rgba(243,196,81,0.65); }
.figure.boss { transform: scale(1.12); }
.figure.boss .fig-base { box-shadow: 0 0 14px 4px rgba(232,71,92,0.7); }
.figure.boss .fig-art img { filter: drop-shadow(0 0 8px rgba(232,71,92,0.5)) drop-shadow(0 3px 3px rgba(0,0,0,0.5)); }
.figure.selected { transform: translateY(-4px) scale(1.08); z-index: 5; }
.figure.selected .fig-base { box-shadow: 0 0 0 2px var(--gold), 0 0 16px 4px rgba(243,196,81,0.7); }
.figure.selected .fig-art img { filter: drop-shadow(0 0 6px rgba(243,196,81,0.6)) drop-shadow(0 4px 3px rgba(0,0,0,0.5)); }

/* star pips float above the head on a small plate */
.fig-stars {
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  z-index: 4; font-size: 9px; line-height: 1; white-space: nowrap;
  padding: 1px 4px; border-radius: 6px;
  background: rgba(8,9,14,0.7); box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.fig-stars.boss { color: var(--red); font-family: var(--disp); font-weight: 800; font-size: 8px; letter-spacing: 1px; background: rgba(40,8,12,0.85); }
.stars { color: #ffe9a8; letter-spacing: 1px; text-shadow: 0 1px 1px #000; }
.stars.s2 { color: #8ef0ad; }
.stars.s3 { color: var(--gold); text-shadow: 0 0 6px rgba(243,196,81,0.8); }

/* Sprite idle loop — frame-quantized squash/stretch (reads like a hand-drawn 4-frame idle). */
.fig-art img.idle { animation-name: idle4; animation-iteration-count: infinite; animation-timing-function: steps(1, end); transform-origin: 50% 100%; }
@keyframes idle4 {
  0%   { transform: translateY(0)    scaleX(1.00) scaleY(1.00); }
  25%  { transform: translateY(-2px) scaleX(0.975) scaleY(1.045); }
  50%  { transform: translateY(-4px) scaleX(0.95) scaleY(1.075); }
  75%  { transform: translateY(-2px) scaleX(0.985) scaleY(1.03); }
  100% { transform: translateY(1px)  scaleX(1.035) scaleY(0.965); }
}
@media (prefers-reduced-motion: reduce) {
  .fig-art img.idle, .ember, .confetti, .title-emoji img, .end-art { animation: none !important; }
  .arena-shake, .screen.shake { animation: none !important; }
}

/* battle stat bars float above the unit's head */
.fig-bars { position: absolute; top: 1px; left: 14%; right: 14%; z-index: 4; display: flex; flex-direction: column; gap: 1px; }
.ut-hpbar { position: static; height: 4px; border-radius: 2px; background: rgba(0,0,0,0.7); display: flex; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6); }
.ut-hp { height: 100%; background: linear-gradient(90deg, #6ef089, #2fbf57); transition: width 0.18s; }
.ut-sh { height: 100%; background: #b7e2ff; transition: width 0.18s; }
.ut-mnbar { position: static; height: 3px; border-radius: 2px; background: rgba(0,0,0,0.6); overflow: hidden; }
.ut-mn { height: 100%; background: linear-gradient(90deg, #6cc0ff, #3f7dff); transition: width 0.18s; }

/* ───────── traits ───────── */
.trait-row { display: flex; gap: 5px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.trait-row::-webkit-scrollbar { display: none; }
.tchip {
  flex-shrink: 0;
  font-family: var(--disp);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px 7px 8px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(40,46,70,0.7), rgba(18,22,36,0.7));
  border: 1px solid var(--steel-d);
  color: var(--dim);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.tchip .ic { height: 14px; }
.tchip:not(.active) { opacity: 0.5; } /* progress traits recede so live synergies draw the eye */
.tchip.active { color: #fff; border-color: var(--tc); background: color-mix(in srgb, var(--tc) 24%, #14182a); box-shadow: 0 0 12px color-mix(in srgb, var(--tc) 35%, transparent), inset 0 1px 0 rgba(255,255,255,0.14); }
.tchip.trait-activated { animation: traitPop 0.7s cubic-bezier(0.34,1.5,0.5,1); }
@keyframes traitPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.32); box-shadow: 0 0 18px var(--tc), inset 0 1px 0 rgba(255,255,255,0.3); }
  100% { transform: scale(1); }
}
.trait-hint { font-size: 12px; color: var(--dim); padding: 5px; font-style: italic; }
.tchip-mini { display: inline-flex; }

/* ───────── bench: a reserve shelf the units stand on ───────── */
.bench {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 0;
  padding: 5px 6px 7px; margin-bottom: 7px; position: relative;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(74,54,34,0.5), rgba(40,28,16,0.6)),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 12.5%);
  border: 1px solid #50381f;
  box-shadow: inset 0 1px 0 rgba(255,220,150,0.12), inset 0 -6px 10px rgba(0,0,0,0.45);
}
.bench::after { /* shelf lip the units rest on */
  content: ''; position: absolute; left: 6px; right: 6px; bottom: 5px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,210,140,0.25), transparent);
}
.bench-cell { aspect-ratio: 0.82; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.bench-cell .fig-art { font-size: 17px; }
.bench-cell .fig-stars { font-size: 7px; top: 1px; padding: 0 3px; }

/* ───────── info sheet ───────── */
.info-sheet {
  background: linear-gradient(180deg, rgba(52,46,30,0.95), rgba(24,22,16,0.96));
  border: 1px solid var(--gold-d);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 7px;
  animation: fadein 0.15s ease;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255,220,120,0.18);
}
.is-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.is-name { font-family: var(--disp); font-size: 15px; }
.is-name b { color: var(--gold); }
.is-traits { font-size: 11px; color: var(--dim); }
.is-stats { font-size: 13px; margin: 7px 0 5px; color: #d8d0bf; }
.is-stats .ic { height: 14px; }
.is-ab { font-size: 12.5px; color: #b6ad9c; line-height: 1.4; }
.is-ab b { color: var(--gold); }
.is-actions { display: flex; gap: 8px; margin-top: 9px; justify-content: flex-end; align-items: center; }
.is-actions .ic { height: 14px; }

/* ───────── shop ───────── */
.shop { display: flex; gap: 6px; margin-bottom: 8px; }
/* staging holds both lines + divider and centers them, so slack splits evenly
   instead of pooling into one void; bottom controls stay docked. */
.staging { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 10px; min-height: 0; }
.battlefield { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 2px 4px; opacity: 0.55; }
.bf-line { height: 1px; flex: 1; max-width: 120px; background: linear-gradient(90deg, transparent, rgba(243,196,81,0.35), transparent); }
.bf-emblem { filter: drop-shadow(0 0 6px rgba(243,196,81,0.4)); opacity: 0.8; }
/* Premium portrait shop cards — the cost-colored frame is the rarity signal (TFT convention) */
.shop-card {
  flex: 1;
  min-width: 0;
  aspect-ratio: 0.72;
  max-height: 108px;
  border-radius: 9px;
  border: 1.5px solid var(--tier-c, #6f7c95);
  background: linear-gradient(180deg, #232a44, #14182a);
  color: var(--ink);
  padding: 0;
  display: flex; flex-direction: column;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-family: var(--body);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 3px 9px rgba(0,0,0,0.45);
  transition: transform 0.1s, box-shadow 0.2s;
}
.shop-card:active { transform: translateY(1px) scale(0.97); }
.shop-card.tier1 { --tier-c: #8595ad; }
.shop-card.tier2 { --tier-c: #4cb568; }
.shop-card.tier3 { --tier-c: #43a0e6; }
.shop-card.tier4 { --tier-c: #b46be0; }
.shop-card.tier5 { --tier-c: var(--gold); box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 0 16px rgba(243,196,81,0.35); }
.shop-card.cantafford { opacity: 0.5; filter: grayscale(0.3); }
.shop-card.sold { opacity: 0.28; border-style: dashed; pointer-events: none; }
.shop-card.sold { display: flex; align-items: center; justify-content: center; }
.sc-sold { font-family: var(--disp); font-size: 11px; color: var(--dim); letter-spacing: 3px; }

.sc-portrait {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: flex-end; justify-content: center;
  /* lit stage behind the character so the sprite reads clearly */
  background:
    radial-gradient(80% 60% at 50% 38%, color-mix(in srgb, var(--tier-c) 30%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0.35));
}
.sc-portrait::after { /* floor vignette so the figure is grounded in the card */
  content: ''; position: absolute; left: 12%; right: 12%; bottom: 5%; height: 10%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.55), transparent 72%);
}
.sc-art { position: relative; z-index: 1; height: 94%; width: 100%; display: flex; align-items: flex-end; justify-content: center; font-size: 26px; }
.sc-art img { height: 100%; width: auto; max-width: 116%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.55)); pointer-events: none; }

.sc-plate {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 3px 2px 5px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tier-c) 18%, #11141f), #0d0f18);
  border-top: 1px solid color-mix(in srgb, var(--tier-c) 50%, transparent);
}
.sc-name { font-family: var(--disp); font-size: 8.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: #eadfc8; letter-spacing: 0.2px; }
.sc-traits { display: flex; gap: 3px; }
.sc-cost {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  font-family: var(--disp); font-size: 10px; font-weight: 800; color: #2a1d00;
  display: inline-flex; align-items: center; gap: 1px;
  background: linear-gradient(180deg, #ffe39a, #f3c451); border: 1px solid #b9851f;
  padding: 1px 4px 1px 2px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.sc-cost .ic { height: 11px; }
.sc-pair, .sc-up {
  position: absolute; top: 3px; left: 3px; z-index: 2;
  font-size: 8px;
  background: var(--green);
  color: #04210c;
  border-radius: 6px;
  padding: 1px 4px;
  font-weight: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.sc-pair { padding: 2px 4px; }
.sc-up { background: var(--gold); color: #2a1c00; font-family: var(--disp); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* star-up burst on the merged token */
.figure.combo-pop { z-index: 6; }
.figure.combo-pop .fig-art { animation: comboPop 0.6s ease-out; }
.figure.combo-pop .fig-base { animation: comboRing 0.6s ease-out; }
@keyframes comboPop { 0% { transform: scale(1); } 35% { transform: scale(1.3) translateY(-3px); filter: brightness(1.8); } 100% { transform: scale(1); filter: none; } }
@keyframes comboRing { 0% { box-shadow: 0 0 0 0 var(--gold), 0 0 20px 6px var(--gold); } 100% { box-shadow: 0 0 0 12px transparent, 0 0 0 transparent; } }

/* centered banner flash (level up / star up) */
.flash-banner {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  z-index: 80; pointer-events: none; text-align: center;
  animation: flashIn 1.4s cubic-bezier(0.2,0.8,0.3,1) forwards;
}
.flash-banner .fb-title { font-family: var(--disp); font-weight: 800; font-size: 32px; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff2c8, #f3c451 55%, #b9851f); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.7)); }
.flash-banner .fb-sub { font-family: var(--disp); font-size: 12px; color: var(--ink); opacity: 0.85; letter-spacing: 1px; }
.flash-banner .fb-stars { font-size: 30px; color: var(--gold); text-shadow: 0 0 14px rgba(243,196,81,0.8); line-height: 1; }
.flash-banner.levelup .fb-title { background: linear-gradient(180deg, #d8c6ff, #9b7bff 55%, #6b4fd0); -webkit-background-clip: text; background-clip: text; }
@keyframes flashIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  26% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -72%) scale(0.96); }
}

/* pre-battle intro */
.battle-intro {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(ellipse at center, rgba(10,11,17,0.55), rgba(6,7,12,0.92));
  animation: introIn 0.35s ease-out;
}
.battle-intro.out { animation: introOut 0.35s ease-in forwards; }
.bi-stage { font-family: var(--disp); font-weight: 800; font-size: 30px; color: #f4eeda; letter-spacing: 1px; text-shadow: 0 2px 8px #000; animation: slamL 0.5s cubic-bezier(0.2,1.4,0.4,1) both; }
.bi-name { font-family: var(--disp); font-size: 14px; color: var(--gold); opacity: 0.9; letter-spacing: 2px; text-transform: uppercase; animation: slamR 0.5s 0.08s cubic-bezier(0.2,1.4,0.4,1) both; }
.bi-vs { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-family: var(--disp); font-weight: 800; font-size: 20px; letter-spacing: 4px; color: var(--red); animation: vsZoom 0.5s 0.18s cubic-bezier(0.2,1.5,0.4,1) both; }
@keyframes introIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes introOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slamL { 0% { opacity: 0; transform: translateX(-40px); } 100% { opacity: 1; transform: none; } }
@keyframes slamR { 0% { opacity: 0; transform: translateX(40px); } 100% { opacity: 1; transform: none; } }
@keyframes vsZoom { 0% { opacity: 0; transform: scale(2.2); } 100% { opacity: 1; transform: scale(1); } }

/* boss intro — dramatic red warning */
.boss-intro { background: radial-gradient(ellipse at center, rgba(60,12,18,0.6), rgba(8,5,8,0.95)); }
.bi-warn { font-family: var(--disp); font-weight: 800; font-size: 30px; letter-spacing: 6px; color: var(--red);
  text-shadow: 0 0 18px rgba(232,71,92,0.7), 0 2px 6px #000; animation: bossWarn 1.5s ease-in-out; display: flex; align-items: center; gap: 10px; }
.bi-warn .ic { height: 26px; }
.bi-bossname { font-family: var(--disp); font-weight: 800; font-size: 26px; color: #ffd9dd; letter-spacing: 1px; margin-top: 4px; animation: vsZoom 0.5s 0.2s cubic-bezier(0.2,1.5,0.4,1) both; }
.boss-intro .bi-vs { color: #ff9aa4; letter-spacing: 3px; font-size: 13px; margin-top: 10px; }
@keyframes bossWarn { 0% { opacity: 0; transform: scale(0.6); } 30% { opacity: 1; transform: scale(1.12); } 45% { transform: scale(1); } 70% { filter: brightness(1.6); } 100% { filter: none; } }

/* arena shake on crits */
.arena-shake { animation: arenaShake 0.22s ease; }
@keyframes arenaShake { 0%,100% { transform: none; } 25% { transform: translate(2px,-2px); } 50% { transform: translate(-2px,1px); } 75% { transform: translate(1px,2px); } }

/* victory confetti */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti { position: absolute; top: -16px; border-radius: 2px; opacity: 0.95; animation-name: confettiFall; animation-timing-function: ease-in; animation-iteration-count: 1; }
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0.9; }
}

/* ───────── action bar ───────── */
.actionbar { display: flex; gap: 6px; }
.btn.act {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px;
  font-size: 13px;
}
.btn.act .ic { height: 18px; }
.btn.act .sub { font-family: var(--body); font-size: 10px; color: var(--dim); font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.btn.act .sub .ic { height: 11px; }
.btn.act.locked { border-color: var(--gold); }
.btn.fight {
  flex: 1.6;
  color: #2a1700;
  background: linear-gradient(180deg, #ffd87a, #f0a91f 50%, #c2780f);
  border-color: #7d4f0f;
  font-size: 17px;
  letter-spacing: 1.5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -2px 6px rgba(120,70,0,0.4), 0 4px 16px rgba(240,169,31,0.35);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.fight .ic { height: 20px; }
.lvl-line { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim); padding-top: 8px; font-family: var(--disp); letter-spacing: 0.5px; }
.lvl-line .ic { height: 12px; vertical-align: -0.18em; }
.ll-lvl { color: var(--gold); font-weight: 700; white-space: nowrap; }
.ll-xpbar { position: relative; flex: 1; height: 14px; border-radius: 7px; background: rgba(0,0,0,0.4); border: 1px solid var(--steel-d); overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); }
.ll-xpfill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #6a8bff, #9b7bff); transition: width 0.3s ease; box-shadow: 0 0 8px rgba(139,107,255,0.5); }
.ll-xptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; color: #e8ecf8; text-shadow: 0 1px 2px #000; letter-spacing: 0.5px; }
.ll-econ { color: var(--gold); opacity: 0.85; font-size: 10px; white-space: nowrap; }
.ll-streak { color: #ff9a5a; opacity: 0.9; font-size: 10px; white-space: nowrap; }

/* ───────── battle ───────── */
.battle-screen { position: relative; }
.arena {
  flex: 1; display: flex; flex-direction: column;
  justify-content: space-evenly; align-items: stretch;
  gap: 4px; position: relative; padding: 8px 0 16px;
}
/* central clash glow so the facing lines read as a battlefield, not floating cards */
.arena::before {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 75%; height: 38%;
  background: radial-gradient(ellipse at center, rgba(243,196,81,0.10), transparent 70%);
  pointer-events: none; z-index: 0;
}
/* battle armies stand on a lit arena floor band — no per-unit boxes */
.battle-lane {
  justify-content: center; align-items: flex-end; position: relative; z-index: 1;
  padding: 4px 4px 8px; border-radius: 12px;
}
.battle-lane::after { /* arena floor the army stands on */
  content: ''; position: absolute; left: 4%; right: 4%; bottom: 6px; height: 3px; border-radius: 3px;
  background: radial-gradient(70% 100% at 50% 50%, rgba(0,0,0,0.5), transparent 80%);
}
.enemy-blane { background: linear-gradient(180deg, rgba(232,71,92,0.07), transparent 70%); }
.player-blane { background: linear-gradient(180deg, rgba(90,150,255,0.07), transparent 70%); }
.battle-lane .bcell {
  flex: 0 1 62px; aspect-ratio: 0.84;
  display: flex; align-items: flex-end; justify-content: center;
  position: relative;
}
.lane-tag { font-family: var(--disp); font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-align: center; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 5px; }
.lane-tag .ic { height: 13px; }
.enemy-tag { color: #ff9aa4; }
.player-tag { color: #9fc2ff; }
.vs-line { text-align: center; color: var(--gold); font-size: 13px; padding: 1px 0; opacity: 0.55; letter-spacing: 3px; }
.battle-token { transition: transform 0.12s ease, opacity 0.4s, filter 0.2s; }
.battle-token.dead { opacity: 0.1; filter: grayscale(1); transform: translateY(2px) scale(0.78); }
.battle-token.dead .fig-art img.idle { animation: none; }
.battle-token.flash .fig-art img { animation: hitflash 0.18s ease; }
@keyframes hitflash { 0% { filter: brightness(2.6) saturate(0.4) drop-shadow(0 3px 2px rgba(0,0,0,0.45)); } 100% { filter: drop-shadow(0 3px 2px rgba(0,0,0,0.45)); } }
.battle-token.casting .fig-base { animation: castglow 0.5s ease; }
@keyframes castglow { 0% { box-shadow: 0 0 0 2px rgba(201,95,222,0.9), 0 0 18px 6px rgba(201,95,222,0.7); } 100% { box-shadow: 0 0 0 0 transparent; } }

.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.dmgnum {
  position: absolute;
  font-family: var(--disp);
  font-weight: 800;
  font-size: 14px;
  color: #ffd9d9;
  text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,0.6);
  animation: floatup 0.85s ease-out forwards;
  transform: translateX(-50%);
}
.dmgnum.crit { color: var(--gold); font-size: 19px; }
.dmgnum.heal { color: #8dffac; }
.dmgnum.abil { color: #e0aaff; font-size: 16px; }
.dmgnum.shieldfx { color: #bfe2ff; }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); } 15% { opacity: 1; transform: translate(-50%, -4px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -34px) scale(1); } }

.proj {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #f3c451);
  box-shadow: 0 0 10px #f3c451;
  transition: left 0.2s linear, top 0.2s linear;
  transform: translate(-50%, -50%);
}

/* trait-colored cast burst */
.cast-burst {
  position: absolute;
  width: 54px; height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--cc, #f3c451);
  box-shadow: 0 0 16px var(--cc, #f3c451), inset 0 0 12px var(--cc, #f3c451);
  opacity: 0;
  animation: castBurst 0.5s ease-out;
}
@keyframes castBurst {
  0% { transform: translate(-50%,-50%) scale(0.35); opacity: 0.95; }
  100% { transform: translate(-50%,-50%) scale(1.5); opacity: 0; }
}

/* death soul motes */
.death-mote {
  position: absolute;
  width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(circle, #fff, #b9a0e0);
  box-shadow: 0 0 6px #c9b0f0;
  transform: translate(-50%, -50%);
  animation: deathMote 0.55s ease-out forwards;
}
@keyframes deathMote {
  0% { opacity: 0.95; transform: translate(-50%,-50%) scale(1.1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); }
}

.cast-banner {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(28,24,44,0.96), rgba(16,14,26,0.96));
  border: 1px solid var(--bc, #8a4fbf);
  box-shadow: 0 0 14px color-mix(in srgb, var(--bc, #8a4fbf) 45%, transparent), inset 0 1px 0 rgba(255,255,255,0.12);
  color: #f1ecff;
  border-radius: 8px;
  padding: 6px 16px;
  font-family: var(--disp);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
}
.cast-banner.show { animation: bannerpop 1.1s ease forwards; }
@keyframes bannerpop { 0% { opacity: 0; transform: translateX(-50%) scale(0.8); } 12% { opacity: 1; transform: translateX(-50%) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); } }

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

/* ───────── overlays & sheets ───────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4, 5, 10, 0.8);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  animation: fadein 0.2s ease;
  padding: 18px;
}
.sheet {
  background: linear-gradient(180deg, #2a3150, #161a2c);
  border: 1px solid var(--steel-d);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255,255,255,0.1), inset 0 0 0 1px rgba(243,196,81,0.08);
  animation: sheetIn 0.28s cubic-bezier(0.34,1.4,0.5,1) both;
}
@keyframes sheetIn { 0% { opacity: 0; transform: translateY(14px) scale(0.94); } 100% { opacity: 1; transform: none; } }
.sheet h3 { margin-bottom: 8px; color: var(--gold); }
.sheet p { color: var(--dim); font-size: 14px; margin-bottom: 14px; }
.sheet-btns, .menu-btns { display: flex; gap: 8px; }
.menu-btns { flex-direction: column; }
.sheet-btns .btn { flex: 1; }

.result-crest { font-size: 0; margin-bottom: 4px; }
.result-crest .ic { height: 64px; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.55)); animation: crestPop 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes crestPop { 0% { transform: scale(0.2) rotate(-12deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.result-sheet h2 { font-family: var(--disp); font-size: 32px; margin-bottom: 6px; letter-spacing: 3px; }
.result-sheet.won h2 { color: var(--gold); text-shadow: 0 0 24px rgba(243,196,81,0.5); }
.result-sheet.lost h2 { color: var(--red); }
.hp-loss { color: #ff8b97 !important; font-weight: 700; }
.gold-lines { margin: 10px 0 4px; }
.gl { display: flex; justify-content: space-between; font-size: 13.5px; color: #cfc7b6; padding: 3px 6px; }
.gl span:last-child { font-family: var(--disp); }
.gl.total { border-top: 1px solid var(--steel-d); margin: 4px 0 14px; padding-top: 8px; font-weight: 800; color: var(--gold); }

/* ───────── almanac ───────── */
.almanac-screen { gap: 10px; }
.almanac-head { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.almanac-head h2 { flex: 1; text-align: center; color: var(--gold); font-size: 22px; }
.almanac-head .tab-spacer { width: 38px; }
.almanac-tabs { display: flex; gap: 8px; }
.atab { flex: 1; font-family: var(--disp); font-weight: 700; font-size: 14px; color: var(--dim); padding: 9px; border-radius: 8px; border: 1px solid var(--steel-d); background: linear-gradient(180deg, rgba(40,46,70,0.5), rgba(20,24,38,0.6)); cursor: pointer; }
.atab.sel { color: #2a1d00; background: linear-gradient(180deg, #ffe39a, #f3c451 50%, #c9921f); border-color: #7d5a14; }
.almanac-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 8px; scrollbar-width: thin; }
.alm-tier-cap { font-family: var(--disp); font-size: 12px; color: var(--ink); letter-spacing: 1px; text-transform: uppercase; padding: 0 2px 6px; display: flex; align-items: center; gap: 6px; }
.alm-tier-cap span[style] { font-size: 14px; color: var(--tc); }
.alm-cost { color: var(--gold); display: inline-flex; align-items: center; gap: 2px; }
.alm-cost .ic { height: 12px; }
.alm-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.alm-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.alm-cell .figure { width: 100%; aspect-ratio: 0.84; cursor: pointer; }
.alm-name { font-size: 8.5px; color: #c6bca8; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.alm-trait { background: linear-gradient(180deg, rgba(40,46,70,0.5), rgba(20,24,38,0.55)); border: 1px solid var(--steel-d); border-radius: 9px; padding: 10px 12px; }
.alm-trait-head { font-family: var(--disp); font-size: 16px; color: var(--tc); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.alm-trait-head b { color: var(--ink); }
.alm-trait-th { font-size: 12.5px; color: #b6ad9c; line-height: 1.5; }
.alm-trait-th span { color: var(--gold); font-weight: 700; }

/* ───────── relic pick ───────── */
.relic-screen { justify-content: center; gap: 8px; text-align: center; }
.relic-screen h2 { color: var(--gold); }
.relic-sub { color: var(--dim); font-size: 13px; margin-bottom: 14px; font-style: italic; }
.relic-cards { display: flex; flex-direction: column; gap: 12px; }
.relic-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(180deg, #352c16, #1d180e);
  border: 1px solid var(--gold-d);
  border-radius: 12px;
  padding: 16px;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--body);
  box-shadow: inset 0 1px 0 rgba(255,220,120,0.18), 0 4px 14px rgba(0,0,0,0.45);
  transition: transform 0.12s, box-shadow 0.2s;
}
.relic-card:active { transform: scale(0.97); box-shadow: 0 0 26px rgba(243,196,81,0.4); border-color: var(--gold); }
.rc-emoji { font-size: 40px; filter: drop-shadow(0 4px 12px rgba(243,196,81,0.35)); }
.rc-emoji .ic { height: 52px; }
.rc-name { font-family: var(--disp); font-size: 17px; font-weight: 800; color: var(--gold); }
.rc-desc { font-size: 13px; color: #cbc3b2; line-height: 1.4; }

/* ───────── events ───────── */
.event-screen { justify-content: center; gap: 16px; }
.event-card {
  background: linear-gradient(180deg, rgba(44,50,76,0.9), rgba(20,24,38,0.92));
  border: 1px solid var(--steel-d);
  border-radius: 14px;
  padding: 22px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 6px 20px rgba(0,0,0,0.45);
}
.ev-emoji { font-size: 56px; margin-bottom: 8px; }
.ev-emoji .ic { height: 96px; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5)); }
.event-card h2 { color: var(--gold); }
.ev-text { color: #cbc3b2; font-size: 14.5px; line-height: 1.5; margin-top: 8px; font-style: italic; }
.ev-status { margin-top: 12px; font-size: 13px; color: var(--dim); font-family: var(--disp); }
.ev-status .ic { height: 13px; }
.ev-options { display: flex; flex-direction: column; gap: 10px; }
.event-opt { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; }
.eo-label { font-family: var(--disp); font-size: 15px; }
.eo-detail { font-family: var(--body); font-size: 12px; color: var(--gold); font-weight: 600; }

/* ───────── end screens ───────── */
.end-screen { justify-content: center; text-align: center; gap: 10px; }
.end-art { font-size: 78px; animation: bob 3.4s ease-in-out infinite; }
.end-art .ic { height: 96px; filter: drop-shadow(0 8px 22px rgba(0,0,0,0.55)); }
.end-screen h1 { font-size: 30px; letter-spacing: 2px; }
.end-screen.win h1 { color: var(--gold); text-shadow: 0 0 30px rgba(243,196,81,0.5); }
.end-screen.loss h1 { color: #b9c0d6; }
.end-sub { color: var(--dim); font-size: 14px; }
.unlock-note { color: var(--gold); font-family: var(--disp); font-weight: 800; animation: pulse 1.2s ease-in-out infinite; }

/* ───────── toast ───────── */
#toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%) translateY(16px);
  background: linear-gradient(180deg, rgba(30,34,54,0.97), rgba(16,19,30,0.97));
  border: 1px solid var(--steel-d);
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  line-height: 1.45;
  max-width: min(86vw, 400px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.08);
  text-align: center;
}
#toast .ic { height: 14px; vertical-align: -0.2em; }
#toast b { color: var(--gold); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Tiny screens */
@media (max-height: 700px) {
  .fig-art { font-size: 19px; }
  .battle-lane .bcell { flex-basis: 52px; }
  .title-screen h1 { font-size: 42px; }
  .title-emoji img { height: 132px; }
  .shop-card { aspect-ratio: 0.84; max-height: 82px; }
  .lane-cell { max-width: 58px; aspect-ratio: 0.92; }
  .bench-cell { aspect-ratio: 0.92; }
  .intel, .forces-panel { padding: 5px 8px 2px; }
  .staging { gap: 4px; }
  .lane { padding: 4px 4px 5px; }
  .lane-ends { padding: 2px 6px 0; font-size: 8px; }
  .battlefield { padding: 0; }
  .lvl-line { padding-top: 5px; }
  .relic-strip { padding-bottom: 4px; }
  /* keep the tight short-screen layout: compact tap targets here, comfortable on larger phones */
  .iconbtn { width: 38px; height: 38px; }
  .tchip { padding: 5px 9px 5px 7px; }
}
