:root {
  --gold: #e8b84a; --gold-hi: #fff3c4; --gold-lo: #8a5a12;
  --ink: #e9dcc0; --muted: #a8977a; --wood: #1b120a; --wood2: #2a1c10;
  --horde: #b3261e; --alliance: #2f6fd6;
  --q-poor: #9d9d9d; --q-common: #fff; --q-uncommon: #1eff00; --q-rare: #0070dd; --q-epic: #a335ee; --q-legendary: #ff8000;
  --title: Philosopher, "Trebuchet MS", sans-serif;
}
* { box-sizing: border-box; }
html, body { color-scheme: dark; overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background: #070b14;
  font: 17px/1.45 Philosopher, "Trebuchet MS", sans-serif;
}
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(79,195,232,.22), transparent 70%),
    radial-gradient(40% 30% at 85% 20%, rgba(232,184,74,.10), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'%3E%3Cpath d='M0 300V190l120-60 90 40 130-100 110 80 90-50 150 110 120-70 140 60 110-90 140 90V300z' fill='%230d1424'/%3E%3Cpath d='M0 300V240l160-50 140 40 170-60 160 50 180-40 150 40 240-30V300z' fill='%2309101c'/%3E%3C/svg%3E") bottom/100% 38% no-repeat,
    linear-gradient(#0b1630, #070b14 70%);
}
a { color: var(--gold); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ---- header ---- */
.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 28px; border-bottom: 2px solid var(--gold-lo);
  background: linear-gradient(#1d140b, #0e0905); box-shadow: 0 4px 24px #000a;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.emblem { width: 110px; height: 55px; filter: drop-shadow(0 2px 6px #000); }
.wordmark { display: flex; flex-direction: column; line-height: 1; }
.wordmark b {
  font: 700 36px var(--title); letter-spacing: .1em; text-transform: uppercase;
  background: linear-gradient(var(--gold-hi), var(--gold) 50%, var(--gold-lo)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 1px #000);
}
.wordmark i { font: italic 15px Philosopher, sans-serif; color: #8fd3ea; letter-spacing: .12em; margin-top: 2px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: center; }
.tabs a, .btn {
  font: 700 15px var(--title); letter-spacing: .02em; color: #ffd76a; text-decoration: none;
  padding: 7px 13px; border: 1px solid #c9952e; border-radius: 3px; cursor: pointer;
  background: linear-gradient(#8e1b12, #4c0b06); box-shadow: inset 0 1px 0 #ffffff30, inset 0 -2px 4px #0008, 0 2px 4px #0009;
  text-shadow: 0 1px 2px #000;
}
.tabs a:hover, .btn:hover { background: linear-gradient(#b0261a, #5e0e08); color: #fff1b8; }
.tabs a[aria-current="page"] { background: linear-gradient(#e8b84a, #8a5a12); color: #1b0d02; text-shadow: 0 1px 0 #ffffff60; }
.btn { display: inline-block; white-space: nowrap; text-align: center; }
.btn.big { font-size: 22px; padding: 12px 34px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 14px; }
.btn.small { font-size: 14px; padding: 4px 10px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }

main { max-width: 1280px; margin: 28px auto; padding: 0 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; }

/* ---- game-style window ---- */
.frame {
  position: relative; padding: 34px 24px 22px; border: 3px solid transparent; border-radius: 6px;
  background:
    linear-gradient(160deg, #24180d, #120c06 60%, #1a120a) padding-box,
    linear-gradient(var(--gold-hi), var(--gold) 30%, var(--gold-lo) 70%, var(--gold)) border-box;
  box-shadow: 0 10px 40px #000c, inset 0 0 0 1px #000, inset 0 0 40px #000a;
}
.frame::before, .frame::after {
  content: ""; position: absolute; top: -9px; width: 16px; height: 16px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--gold-hi), var(--gold-lo)); border: 2px solid #3a2405;
}
.frame::before { left: -9px; } .frame::after { right: -9px; }
.frame > h2 {
  position: absolute; top: -19px; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap;
  font: 700 20px var(--title); letter-spacing: .03em; color: #ffe39a; text-shadow: 0 2px 2px #000;
  padding: 5px 30px; border: 2px solid #c9952e; border-radius: 3px;
  background: linear-gradient(#5a1610, #2b0805); box-shadow: 0 3px 10px #000b;
}
.frame h3 { font: 700 19px var(--title); color: var(--gold); margin: 18px 0 10px; letter-spacing: .04em; border-bottom: 1px solid #5a4020; padding-bottom: 4px; }
.lead { color: var(--muted); margin: 0 0 14px; }
.note { color: var(--muted); font-style: italic; font-size: 15px; }

/* ---- controls ---- */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.bar input, .bar select {
  background: #0b0704; color: var(--ink); border: 1px solid #6b4c1c; border-radius: 3px; padding: 6px 10px; min-width: 220px;
  box-shadow: inset 0 2px 4px #000;
}
.seg { display: inline-flex; border: 1px solid #6b4c1c; border-radius: 3px; overflow: hidden; }
.seg button { background: #140d07; color: var(--muted); border: 0; padding: 6px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: linear-gradient(#e8b84a, #8a5a12); color: #1b0d02; }
.count { color: var(--muted); margin-left: auto; }

/* ---- grids & cards ---- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid.icons { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.card {
  position: relative; border: 1px solid #4a3418; border-radius: 4px; background: #0d0805; overflow: hidden;
  transition: transform .15s, border-color .15s;
}
@media (hover: hover) { .card:hover { transform: translateY(-2px); border-color: var(--gold); } }
.card img.render { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #000; }
.card .cap { padding: 8px 10px; }
.card .cap b { display: block; font-weight: 600; }
.card.missing img { filter: grayscale(.9) brightness(.55); }
.card.missing .cap b { color: var(--muted); }
.card.owned { border-color: #3fae4a; box-shadow: 0 0 0 1px #3fae4a, 0 0 18px #3fae4a40; }
.badge { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 2px 8px; border-radius: 2px; color: #fff; background: #000a; border: 1px solid #fff3; }
.badge.HORDE { background: var(--horde); } .badge.ALLIANCE { background: var(--alliance); }
.badge.got { left: 8px; right: auto; background: #1f6b27; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid #3a2914; border-radius: 3px; background: #0d0805; }
.row.missing { opacity: .55; }
.row.owned { border-color: #3fae4a; }
.row small { display: block; color: var(--muted); font-size: 14px; }
.ic { width: 40px; height: 40px; flex: none; border: 2px solid #6b4c1c; border-radius: 4px; box-shadow: 0 0 0 1px #000; background: #000; }
.ic.lg { width: 56px; height: 56px; }

/* ---- hero ---- */
.heroes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.hero {
  display: flex; gap: 16px; align-items: center; padding: 16px; border-radius: 4px; border: 1px solid #5a4020;
  background: linear-gradient(90deg, var(--fc, #333) 0 6px, #0d0805 6px 45%, #0d080500 80%) , var(--art, none) right center / auto 140% no-repeat, #0d0805;
}
.hero .portrait { width: 84px; height: 84px; border-radius: 50%; border: 4px solid var(--gold); box-shadow: 0 0 0 2px #000, 0 0 16px #000; }
.hero .nm { font: 700 26px var(--title); line-height: 1.1; }
.hero .lvl { display: inline-block; min-width: 34px; text-align: center; font-weight: 700; color: #ffd76a; border: 1px solid #c9952e; border-radius: 50%; padding: 4px; margin-right: 8px; background: #2b0805; }
.bars { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.meter b { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.meter .track { height: 18px; border: 1px solid #000; border-radius: 2px; background: #0a0a0a; box-shadow: inset 0 0 0 1px #6b4c1c; overflow: hidden; }
.meter .fill { height: 100%; background: linear-gradient(#5ee06a, #1d7a26); box-shadow: inset 0 1px 0 #ffffff50; }
.login { text-align: center; padding: 50px 24px 40px; }
.login p { max-width: 560px; margin: 0 auto 26px; color: var(--muted); }

/* ---- talents ---- */
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.picker button {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 3px; cursor: pointer;
  background: #140d07; color: var(--cc, var(--ink)); border: 1px solid #4a3418; font-weight: 600;
}
.picker button[aria-pressed="true"] { border-color: var(--gold); background: #2a1c10; box-shadow: 0 0 10px #e8b84a50; }
.picker img { width: 30px; height: 30px; border-radius: 3px; }
.tree {
  --sz: 54px; position: relative; display: grid; gap: 22px 34px; justify-content: center; padding: 26px; margin: 0 auto; width: fit-content; max-width: 100%;
  grid-template-columns: repeat(var(--n, 4), var(--sz)); grid-auto-rows: var(--sz); border: 1px solid #3a2914; border-radius: 4px;
  background: radial-gradient(circle at 50% 30%, #1d2b33, #0a0e10 80%);
}
.tree svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.node { position: relative; width: var(--sz); height: var(--sz); border: 2px solid #9c9c9c; border-radius: 6px; background: #000; z-index: 1; padding: 0; cursor: help; }
.node img { width: 100%; height: 100%; border-radius: 4px; display: block; }
.node .rk { position: absolute; right: -8px; bottom: -8px; font: 700 12px sans-serif; color: #1eff00; background: #000; border: 1px solid #666; border-radius: 3px; padding: 0 4px; }

/* ---- armory ---- */
.split { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 18px; }
.list { max-height: 640px; overflow: auto; border: 1px solid #3a2914; border-radius: 3px; }
.list button { display: block; width: 100%; text-align: left; padding: 7px 12px; background: none; border: 0; border-bottom: 1px solid #241808; color: var(--ink); cursor: pointer; }
.list button:hover, .list button[aria-pressed="true"] { background: #2a1c10; color: var(--gold-hi); }
.cols { columns: 3 220px; column-gap: 24px; }
.cols li { break-inside: avoid; padding: 2px 0; }
.q-POOR { color: var(--q-poor); } .q-COMMON { color: var(--q-common); } .q-UNCOMMON { color: var(--q-uncommon); }
.q-RARE { color: var(--q-rare); } .q-EPIC { color: var(--q-epic); } .q-LEGENDARY { color: var(--q-legendary); }

/* ---- in-game tooltip ---- */
.tip {
  position: fixed; z-index: 10; max-width: 340px; pointer-events: none; display: none;
  padding: 9px 11px; font: 15px/1.4 Philosopher, "Trebuchet MS", sans-serif; color: #fff;
  background: rgba(2, 6, 22, .94); border: 2px solid #9aa5b8; border-radius: 5px; box-shadow: 0 0 0 1px #000, 0 6px 20px #000;
}
.tip .t { font-size: 16px; font-weight: 700; }
.tip .two { display: flex; justify-content: space-between; gap: 20px; }
.tip .y { color: #ffd100; } .tip .g { color: #1eff00; } .tip .m { color: #9aa5b8; } .tip .r { color: #ff2020; }
.tip p { margin: 2px 0; }

.chg { margin: 4px 0; }
ul.chg { list-style: none; padding: 0; columns: 2 260px; }
ul.chg.add li { color: #5ee06a; } ul.chg.del li { color: #ff6a5a; }
details.chg { border: 1px solid #3a2914; border-radius: 3px; background: #0d0805; padding: 6px 10px; }
details.chg summary { cursor: pointer; color: #ffd76a; padding: 6px 0; }
.fld { display: grid; gap: 2px; padding: 6px 0; border-top: 1px solid #241808; white-space: pre-line; }
.fld b { color: var(--muted); font-weight: 400; font-size: 14px; }
.fld del { color: #ff8a7a; text-decoration-color: #ff8a7a80; }
.fld ins { color: #7ef08a; text-decoration: none; }
.qtext { white-space: pre-line; color: #e9dcc0; }
.quest .qbody { padding: 4px 0 8px; }
.y { color: #ffd100; }
.card .cap small { display: block; font-size: 13px; }
.star { color: #ffd100; }
.adv { font-size: 14px; }
.summary { border: 1px solid #6b4c1c; border-radius: 4px; background: #1a1208; padding: 10px 14px; margin-bottom: 12px; }
.md { white-space: pre-line; }
.chat { display: grid; gap: 10px; margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 6px; max-width: 90%; border: 1px solid #3a2914; }
.msg.me { justify-self: end; background: #2a1c10; border-color: #6b4c1c; }
.msg.ai { justify-self: start; background: rgba(2, 6, 22, .85); border-color: #4a5670; }
.msg.err { color: #ff8a7a; }
#af textarea { width: 100%; background: #0b0704; color: var(--ink); border: 1px solid #6b4c1c; border-radius: 3px; padding: 10px; font: inherit; box-shadow: inset 0 2px 4px #000; margin-bottom: 10px; }
.ideas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.idea { background: #140d07; color: var(--muted); border: 1px solid #4a3418; border-radius: 14px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 14px; }
.idea:hover { color: var(--gold-hi); border-color: var(--gold); }
.steps { padding-left: 22px; display: grid; gap: 12px; }
code { background: #0b0704; border: 1px solid #4a3418; border-radius: 3px; padding: 1px 6px; font-family: Consolas, monospace; font-size: .9em; }
code.key { display: inline-block; user-select: all; word-break: break-all; color: #ffd76a; padding: 6px 10px; }
.node.off { opacity: .35; filter: grayscale(.8); }
.node .lv { position: absolute; left: -7px; top: -7px; font: 700 11px sans-serif; color: #1b0d02; background: #e8b84a; border-radius: 8px; padding: 0 4px; z-index: 2; }
.badge-src { font-size: 13px; color: var(--muted); margin-left: 8px; }
.badge-src.guide { color: #5ee06a; } .badge-src.sim { color: #8fd3ea; }
.feat { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.shots { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.shots a { display: grid; gap: 6px; text-decoration: none; color: var(--muted); font-size: 14px; }
.shots img { width: 100%; border: 1px solid #6b4c1c; border-radius: 4px; background: #000; }
.btag { color: #8fd3ea; font-weight: 600; }
html.light .btag { color: #d9ecf5; }
.loading { text-align: center; color: var(--muted); padding: 40px; font-style: italic; }
.loading::before { content: ""; display: block; width: 34px; height: 34px; margin: 0 auto 10px; border: 3px solid #4a3418; border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
footer { text-align: center; color: #6d6150; font-size: 13px; padding: 20px; }
.tip.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; max-width: none; border-radius: 12px 12px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); font-size: 15px; }
@media (max-width: 760px) {
  body { font-size: 16px; }
  .btn.big { font-size: 18px; padding: 10px 22px; }
  .top { padding: 8px 12px 10px; gap: 8px 10px; }
  .emblem { width: 64px; height: 32px; }
  .wordmark b { font-size: 25px; } .wordmark i { font-size: 11px; }
  .who { margin-left: auto; } .who span { display: none; }
  .tabs { order: 3; flex: 0 0 100%; min-width: 0; flex-wrap: nowrap; justify-content: flex-start; overscroll-behavior-x: contain;
          overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; scroll-snap-align: start; font-size: 15px; padding: 10px 14px; }
  main { margin: 22px auto; padding: 0 10px; gap: 30px; }
  .frame { padding: 30px 12px 16px; }
  .frame > h2 { font-size: 17px; padding: 4px 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.icons, .heroes { grid-template-columns: 1fr; }
  .card .cap { padding: 6px 8px; font-size: 14px; }
  .badge { font-size: 11px; padding: 1px 6px; }
  .hero { padding: 12px; gap: 12px; } .hero .portrait { width: 64px; height: 64px; } .hero .nm { font-size: 22px; }
  .bar input, .bar select { min-width: 0; flex: 1 1 100%; }
  .seg { flex: 1 1 100%; } .seg button { flex: 1; padding: 10px 6px; }
  .count { margin-left: 0; font-size: 14px; }
  .picker { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .picker button { flex: none; min-height: 44px; }
  .split { grid-template-columns: 1fr; } .list { max-height: 280px; }
  .list button { padding: 11px 12px; }
  /* fit any column count into the phone width: 2*12 frame + 2*12 tree padding + 2px border + gaps */
  .tree { gap: 14px 12px; padding: 12px; --sz: clamp(30px, calc((100vw - 74px - (var(--n, 4) - 1) * 12px) / var(--n, 4)), 52px); }
  .node .rk { right: -5px; bottom: -6px; font-size: 11px; }
  .cols { columns: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- header switches ---- */
.prefs { display: flex; gap: 6px; }
.pref { font: 700 13px var(--title); min-width: 34px; height: 30px; color: #ffd76a; background: #1b120a; border: 1px solid #6b4c1c; border-radius: 3px; cursor: pointer; }
.pref:hover { border-color: var(--gold); color: #fff1b8; }

/* ---- light theme: muted parchment, still in the game's spirit (tooltips and talent trees stay dark, like in game) ---- */
html.light { color-scheme: light; --ink: #2e2010; --muted: #6e5a3c; }
html.light body { background: #cdbb93; }
html.light .sky {
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(255, 244, 214, .55), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 300' preserveAspectRatio='none'%3E%3Cpath d='M0 300V190l120-60 90 40 130-100 110 80 90-50 150 110 120-70 140 60 110-90 140 90V300z' fill='%23b8a47a'/%3E%3Cpath d='M0 300V240l160-50 140 40 170-60 160 50 180-40 150 40 240-30V300z' fill='%23a8936a'/%3E%3C/svg%3E") bottom/100% 38% no-repeat,
    linear-gradient(#e2d4b0, #cdbb93 70%);
}
html.light .top { background: linear-gradient(#6b4a24, #45301a); border-bottom-color: #8a5a12; }
html.light .frame {
  background:
    linear-gradient(160deg, #eadcb8, #ddcb9f 60%, #e5d5ad) padding-box,
    linear-gradient(var(--gold-hi), var(--gold) 30%, var(--gold-lo) 70%, var(--gold)) border-box;
  box-shadow: 0 8px 28px #5a3d1a55, inset 0 0 0 1px #8a6a3a, inset 0 0 36px #a8865055;
}
html.light .frame h3 { color: #7a4e0e; border-bottom-color: #b39256; }
html.light .lead, html.light .note { color: var(--muted); }
html.light .card, html.light .row, html.light details.chg, html.light .summary, html.light .list { background: #f1e6c8; border-color: #b39256; }
html.light .card .cap b { color: var(--ink); }
html.light .card.missing .cap b { color: #8a7656; }
html.light .card.owned, html.light .row.owned { border-color: #3c8a3f; box-shadow: 0 0 0 1px #3c8a3f; }
html.light .bar input, html.light .bar select, html.light #af textarea { background: #f8efd7; color: var(--ink); border-color: #a8864f; box-shadow: inset 0 1px 3px #8a6a3a55; }
html.light .seg { border-color: #a8864f; }
html.light .seg button, html.light .idea, html.light .picker button { background: #ecdfbf; color: var(--muted); border-color: #b39256; }
html.light .picker button[aria-pressed="true"], html.light .list button:hover, html.light .list button[aria-pressed="true"] { background: #e2cf9e; color: #4a2f0c; }
html.light .list button { color: var(--ink); border-bottom-color: #d8c597; }
html.light .hero { background: linear-gradient(90deg, var(--fc, #333) 0 6px, #f1e6c8 6px 45%, #f1e6c800 80%), var(--art, none) right center / auto 140% no-repeat, #f1e6c8; border-color: #b39256; }
html.light .meter .track { background: #e9dcb9; }
html.light .msg.me { background: #ecdfbf; border-color: #b39256; }
html.light .fld b { color: var(--muted); }
html.light .fld del { color: #a3321f; } html.light .fld ins { color: #2f7a2f; }
html.light ul.chg.add li { color: #2f7a2f; } html.light ul.chg.del li { color: #a3321f; }
html.light .q-COMMON { color: #2e2010; } html.light .q-UNCOMMON { color: #1d7a12; } html.light .q-POOR { color: #7a7a7a; }
html.light footer { color: #6e5a3c; }
html.light code { background: #f8efd7; border-color: #b39256; }
html.light code.key { color: #7a4e0e; }
html.light .badge-src.guide { color: #2f7a2f; } html.light .badge-src.sim { color: #1f5f8a; }
