@import url("fonts/fonts.css");

/* Olden Era look: night-blue panels, bronze/gold trim, parchment for lore and analysis */
:root {
  --night: #070b16; --panel: #111a2d; --panel2: #18233a; --panel3: #1e2b46;
  --bronze: #7a6232; --bronze2: #a8874a; --gold: #d9b45e; --gold2: #f3dc95; --ember: #c9783a;
  --text: #e9e2cf; --muted: #a19a87; --ink: #3a2814; --ink2: #5c4526; --parch: #e9dcbc;
  --good: #7fc790; --bad: #e0685a; --link: #f0cf7e;
  --human: #e9c46a; --undead: #9ec2a4; --dungeon: #c39af0; --nature: #8fd776; --demon: #ef7c62; --unfrozen: #74d3ea; --neutral: #b9b2a2;
  --head: "Cinzel", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); font: 16.5px/1.5 var(--body); font-variant-numeric: lining-nums; background: var(--night); }
body { min-height: 100vh; position: relative; overflow-x: hidden; }

/* starry background with a slow drift and twinkle */
body::before {
  content: ""; position: fixed; inset: -4%; z-index: -2;
  background: radial-gradient(ellipse at 50% 0%, rgba(40, 60, 110, .35), transparent 60%), url("/img/ui/bg_menu.webp") center / cover no-repeat, var(--night);
  animation: drift 90s ease-in-out infinite alternate;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(1.5px 1.5px at 12% 22%, #fff8, transparent 60%), radial-gradient(1px 1px at 68% 14%, #fff9, transparent 60%),
    radial-gradient(1.5px 1.5px at 84% 64%, #ffe9b088, transparent 60%), radial-gradient(1px 1px at 33% 78%, #fff7, transparent 60%),
    radial-gradient(1px 1px at 52% 41%, #cfe3ff99, transparent 60%), linear-gradient(180deg, rgba(7, 11, 22, .25), rgba(7, 11, 22, .82) 70%);
  animation: twinkle 7s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.1) translate(-1.5%, 1%); } }
@keyframes twinkle { from { opacity: .75; } to { opacity: 1; } }

a { color: var(--link); text-decoration: none; cursor: pointer; transition: color .15s, text-shadow .15s; }
a:hover { color: var(--gold2); text-shadow: 0 0 8px rgba(243, 220, 149, .45); }
h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0 0 .5em; letter-spacing: .4px; }
h1 { font-size: 28px; background: linear-gradient(100deg, #b8913f 0%, var(--gold2) 35%, #fff4cf 50%, var(--gold2) 65%, #b8913f 100%);
     background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: sheen 9s linear infinite;
     filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6)); display: inline-flex; align-items: center; gap: 10px; }
@keyframes sheen { from { background-position: 125% 0; } to { background-position: -125% 0; } }
h2 { font-size: 19px; color: var(--gold2); text-shadow: 0 1px 2px #000; display: flex; align-items: center; gap: 10px; }
h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--bronze2), transparent); }
h3 { font-size: 16px; color: var(--gold); }
.muted { color: var(--muted); } .small { font-size: 14.5px; }

/* header */
header.top { display: flex; align-items: center; gap: 12px; padding: 8px 16px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, #0c1222f2, #0a0f1cf2); border-bottom: 1px solid var(--bronze);
  box-shadow: 0 1px 0 #000, 0 3px 0 -1px rgba(217, 180, 94, .25), 0 8px 24px rgba(0, 0, 0, .5); }
header.top .brand { font-family: var(--head); font-weight: 700; font-size: 17px; color: var(--gold2); white-space: nowrap; letter-spacing: 1px; text-shadow: 0 0 12px rgba(217, 180, 94, .35); }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav a { padding: 6px 8px; border-radius: 4px; color: #d8cfb7; font-family: var(--head); font-size: 12.5px; letter-spacing: .3px; text-transform: uppercase; border: 1px solid transparent; }
nav a:hover { color: var(--gold2); border-color: rgba(168, 135, 74, .4); }
nav a.active { color: var(--gold2); background: linear-gradient(180deg, rgba(217, 180, 94, .16), rgba(217, 180, 94, .04)); border-color: var(--bronze); }
header.top .spacer { flex: 1; }
input, select, button, textarea { background: #0d1424; color: var(--text); border: 1px solid var(--bronze); border-radius: 4px; padding: 6px 9px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217, 180, 94, .2); }
button { cursor: pointer; font-family: var(--head); font-size: 12.5px; letter-spacing: .5px; background: linear-gradient(180deg, #2a2414, #17140c); color: var(--gold2); }
button:hover { border-color: var(--gold); box-shadow: 0 0 10px rgba(217, 180, 94, .3); }

main { padding: 20px; max-width: 1520px; margin: 0 auto; }
main.enter > * { animation: rise .35s ease-out both; }
main.enter > *:nth-child(2) { animation-delay: .04s; } main.enter > *:nth-child(3) { animation-delay: .08s; } main.enter > *:nth-child(n+4) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.section { margin-top: 18px; }

/* framed panel with gold corner studs */
.card { position: relative; padding: 16px 18px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(24, 35, 58, .94), rgba(13, 20, 36, .96));
  border: 1px solid var(--bronze); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(243, 220, 149, .12), 0 6px 22px rgba(0, 0, 0, .45); }
.card::before, .card::after { content: ""; position: absolute; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg);
  box-shadow: 0 0 6px rgba(217, 180, 94, .6); top: -4px; left: -4px; }
.card::after { left: auto; right: -4px; }
.card.hover { transition: transform .2s, box-shadow .2s, border-color .2s; }
.card.hover:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6), 0 10px 30px rgba(0, 0, 0, .55), 0 0 18px rgba(217, 180, 94, .18); }

/* parchment */
.parch { color: var(--ink); background: linear-gradient(rgba(233, 220, 188, .35), rgba(233, 220, 188, .35)), url("/img/ui/scroll.webp") center / 100% 100%, var(--parch);
  border-radius: 4px; padding: 14px 18px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5), inset 0 0 30px rgba(92, 69, 38, .35); }
.parch b, .parch h3 { color: #4a2f12; } .parch .why { color: var(--ink2); } .parch a, .parch .chip { color: #4a2f12; }
.parch .chip { background: rgba(255, 248, 225, .55); border-color: rgba(92, 69, 38, .45); }
.parch .stars .off { color: rgba(92, 69, 38, .3); }

/* tables */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 9px; border-bottom: 1px solid rgba(122, 98, 50, .28); text-align: left; vertical-align: middle; }
th { color: var(--gold); font-family: var(--head); font-weight: 500; font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; cursor: pointer; white-space: nowrap;
  position: sticky; top: 52px; background: #10182b; z-index: 2; border-bottom: 1px solid var(--bronze); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(217, 180, 94, .07); }

/* pictures */
.ico { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; flex: none; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 50%; border: 1px solid var(--bronze2); background: #0b1120;
  box-shadow: 0 0 0 2px #0b1120, 0 0 0 3px rgba(122, 98, 50, .6); vertical-align: middle; }
.thumb.sq { border-radius: 6px; object-fit: contain; }
.namecell { display: flex; align-items: center; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 3px; border-radius: 999px; background: rgba(13, 20, 36, .8); border: 1px solid rgba(122, 98, 50, .55);
  font-size: 14.5px; margin: 2px 4px 2px 0; white-space: nowrap; color: var(--text); }
.chip:not(:has(img)) { padding-left: 9px; }
.chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
a.chip:hover { border-color: var(--gold); text-decoration: none; box-shadow: 0 0 8px rgba(217, 180, 94, .25); }
.fac { font-weight: 700; font-family: var(--head); font-size: .95em; }
.fac-human { color: var(--human); } .fac-undead { color: var(--undead); } .fac-dungeon { color: var(--dungeon); }
.fac-nature { color: var(--nature); } .fac-demon { color: var(--demon); } .fac-unfrozen { color: var(--unfrozen); } .fac-neutral { color: var(--neutral); }
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; text-shadow: 0 0 6px rgba(217, 180, 94, .5); }
.stars .off { color: #3b3728; text-shadow: none; }
.bar { height: 9px; background: #0a0f1c; border: 1px solid rgba(122, 98, 50, .6); border-radius: 5px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6b4f1d, var(--gold), var(--gold2)); box-shadow: 0 0 8px rgba(217, 180, 94, .6); animation: grow 1s ease-out both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.rarity-common { color: #d2cbbb; } .rarity-rare { color: #73b6ff; } .rarity-epic { color: #c99bff; } .rarity-legendary { color: #ffb44a; text-shadow: 0 0 8px rgba(255, 180, 74, .35); }
.pill { font-size: 11.5px; padding: 1px 7px; border-radius: 3px; background: rgba(217, 180, 94, .12); border: 1px solid rgba(122, 98, 50, .6); color: var(--gold2); margin-left: 4px; font-family: var(--body); font-weight: 500; -webkit-text-fill-color: var(--gold2); }

/* advice */
.tip { display: flex; gap: 12px; align-items: flex-start; padding: 9px 12px; margin: 7px 0; border-radius: 4px; border: 1px solid rgba(122, 98, 50, .35);
  background: linear-gradient(90deg, rgba(30, 43, 70, .9), rgba(17, 26, 45, .85)); animation: rise .3s ease-out both; animation-delay: calc(var(--i, 0) * 40ms); }
.tip.p1 { border-left: 3px solid var(--gold); } .tip.p2 { border-left: 3px solid #6f8fb8; } .tip.p3 { opacity: .8; border-left: 3px solid #4a4a4a; }
.tip .tico { width: 46px; height: 46px; flex: none; border-radius: 6px; object-fit: cover; border: 1px solid var(--bronze2); background: #0b1120; }
.tip .t { font-weight: 700; } .tip .d { white-space: pre-line; color: #d6cfbd; margin-top: 3px; font-size: 15px; }
.tip .cat { font-family: var(--head); font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--gold); margin-right: 7px; opacity: .85; }
.recruit { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 6px; }
.slot { position: relative; text-align: center; font-size: 12.5px; color: var(--muted); }
.slot img { width: 60px; height: 60px; border-radius: 6px; object-fit: cover; border: 1px solid var(--bronze2); background: #0b1120; display: block; margin: 0 auto 2px; }
.slot b { position: absolute; right: 2px; top: 44px; background: #0b1120e0; color: var(--gold2); font-size: 12px; padding: 0 4px; border-radius: 3px; border: 1px solid var(--bronze); }
.warn { background: linear-gradient(90deg, rgba(90, 60, 20, .85), rgba(60, 40, 15, .85)); border: 1px solid #a07a32; padding: 9px 13px; border-radius: 4px; color: #f6e1ad; margin-bottom: 12px; }
.res { display: flex; gap: 16px; flex-wrap: wrap; font-variant-numeric: tabular-nums; align-items: center; }
.res span { display: inline-flex; align-items: center; gap: 5px; } .res b { color: var(--gold2); } .res img { width: 22px; height: 22px; }
.army { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* entity art */
.ability { margin: 8px 0; } .ability b { color: var(--gold2); }
.desc { white-space: pre-line; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.artcard { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--bronze2); aspect-ratio: 5 / 7; max-width: 380px; width: 100%;
  box-shadow: 0 0 0 3px #0b1120, 0 0 0 4px var(--bronze), 0 14px 40px rgba(0, 0, 0, .6); background: #0b1120 center / cover no-repeat; }
.artcard::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(7, 11, 22, .92)); }
.artcard img { position: absolute; left: 50%; bottom: 6%; width: 92%; transform: translateX(-50%); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .7)); animation: idle 4.5s ease-in-out infinite; transform-origin: 50% 100%; }
.artcard .cap { position: absolute; left: 0; right: 0; bottom: 10px; z-index: 1; text-align: center; font-family: var(--head); color: var(--gold2); font-size: 18px; text-shadow: 0 2px 4px #000; }
@keyframes idle { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.018) translateY(-1.5%); } }
.portrait { width: 100%; max-width: 300px; border-radius: 8px; border: 1px solid var(--bronze2); box-shadow: 0 0 0 3px #0b1120, 0 0 0 4px var(--bronze), 0 10px 30px rgba(0, 0, 0, .6);
  background: radial-gradient(circle at 50% 35%, #2c3f66, #0b1120 70%); display: block; }
.hero-art { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 20px; align-items: start; }
.banner { position: relative; min-height: 170px; border-radius: 8px; overflow: hidden; border: 1px solid var(--bronze2); margin-bottom: 18px;
  background: #0b1120 center 72% / cover no-repeat; box-shadow: 0 0 0 3px #0b1120, 0 0 0 4px var(--bronze), 0 12px 34px rgba(0, 0, 0, .55); display: flex; align-items: flex-end; padding: 18px 22px; }
.banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7, 11, 22, .9) 0%, rgba(7, 11, 22, .45) 55%, rgba(7, 11, 22, .1)), linear-gradient(0deg, rgba(7, 11, 22, .8), transparent 60%); }
.banner > * { position: relative; }
.banner h1 { font-size: 32px; margin: 0; }
.banner.zoom { animation: kenburns 30s ease-in-out infinite alternate; }
@keyframes kenburns { from { background-size: 110%; } to { background-size: 125%; } }
.faccard { padding: 0; overflow: hidden; }
.faccard .pic { height: 140px; background: center 45% / cover no-repeat; border-bottom: 1px solid var(--bronze); transition: transform .5s; }
.faccard:hover .pic { transform: scale(1.05); }
.faccard .body { padding: 12px 16px 16px; }

/* synergy */
.syn { margin: 0; }
.syn .how { margin-top: 6px; } .syn .why { font-size: 13.5px; margin-top: 6px; }
.err { color: var(--bad); white-space: pre-wrap; }
.loading { color: var(--gold); padding: 40px; text-align: center; font-family: var(--head); letter-spacing: 1px; animation: twinkle 1s ease-in-out infinite alternate; }
footer { color: var(--muted); }

@media (max-width: 760px) { .g2 { grid-template-columns: 1fr; } header.top { flex-wrap: wrap; } .hero-art { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.nowrap { white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; }
.parch .fac { filter: brightness(.42) saturate(1.6); }

/* hover card + quick-view popup */
#tt { position: fixed; z-index: 50; max-width: 380px; min-width: 240px; padding: 11px 13px; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s; border-radius: 6px; border: 1px solid var(--bronze2);
  background: linear-gradient(180deg, rgba(27, 39, 64, .98), rgba(12, 18, 32, .98)); box-shadow: 0 10px 30px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(243, 220, 149, .15); font-size: 15px; }
#tt.show { opacity: 1; transform: none; }
#tt .ability { margin: 6px 0 0; }
#modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px;
  background: rgba(4, 7, 14, .72); backdrop-filter: blur(3px); }
#modal.show { display: flex; animation: fade .15s ease-out; }
#modal .qv { width: min(720px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; animation: pop .18s ease-out; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
.qv-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.qv-pic { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 1px solid var(--bronze2); background: #0b1120; flex: none;
  box-shadow: 0 0 0 2px #0b1120, 0 0 0 3px rgba(122, 98, 50, .6); }
.qv-pic.sq { border-radius: 8px; object-fit: contain; }
#modal .qv-pic { width: 96px; height: 96px; }
.qv-name { font-family: var(--head); color: var(--gold2); font-size: 16px; font-weight: 700; }
.qv-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0; } .qv-stats b { color: var(--gold2); }
.qv-tags { margin-top: 6px; } .qv-tags .chip { padding-left: 9px; }
.qv-foot { margin-top: 14px; border-top: 1px solid rgba(122, 98, 50, .4); padding-top: 10px; }
.chip .lvl { font-size: 11px; color: var(--night); background: var(--gold); border-radius: 3px; padding: 0 4px; font-weight: 700; }
[data-tt] { cursor: pointer; }
.zoom { display: inline-flex; align-items: center; gap: 4px; } .zoom button { padding: 3px 8px; } #zval { font-size: 12px; color: var(--muted); min-width: 36px; text-align: center; }

/* 3D model on the unit card */
.artcard::after { pointer-events: none; }
.artcard .stage { position: absolute; inset: 0; z-index: 0; }
.artcard .stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.artcard.is3d > img { display: none; }
.artcard.is3d { max-width: 520px; }
.btn3d { position: absolute; top: 10px; right: 10px; z-index: 2; }
.ld3d { position: absolute; left: 0; right: 0; top: 45%; z-index: 2; text-align: center; font-family: var(--head); color: var(--gold2); text-shadow: 0 2px 4px #000; animation: twinkle 1s ease-in-out infinite alternate; }
a.brand { text-decoration: none; } a.brand:hover { text-shadow: 0 0 14px rgba(243, 220, 149, .6); }
