/* WLK 3.3.5 Talent Calculator — dark classic theme */
:root {
  --gold: #e8c15a;
  --gold-dim: #9c8a54;
  --panel: #241c14;
  --panel2: #2f2417;
  --panel3: #3a2d1d;
  --edge: #5c4a30;
  --ink: #e9ddc2;
  --ink-dim: #a8956f;
  --red: #c23b2e;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, #3b2f1c 0%, transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 2px, transparent 2px 46px),
    #17110a;
  color: var(--ink);
  min-height: 100%;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- header ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 8px 16px;
  background: linear-gradient(#241b10, #160f08);
  border-bottom: 2px solid #4a3b23;
  box-shadow: 0 4px 18px rgba(0,0,0,.55);
}
.brand-title {
  font-size: 19px; font-weight: 800; letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 14px rgba(232,193,90,.35);
}
.brand-sub { font-size: 11px; color: var(--ink-dim); letter-spacing: .4px; }
#classBar { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.cls-btn {
  display: flex; align-items: center; gap: 6px;
  background: #1d160e; color: #cfc2a6;
  border: 1px solid #55432a; border-radius: 8px;
  padding: 3px 9px 3px 4px; font-size: 13px; cursor: pointer;
  transition: filter .12s, transform .05s;
}
.cls-btn img { width: 22px; height: 22px; border-radius: 4px; }
.cls-btn:hover { filter: brightness(1.25); }
.cls-btn.active { background: #3a2c16; color: #fff; border-color: var(--gold); box-shadow: 0 0 8px rgba(232,193,90,.5); }
#topRight { display: flex; align-items: center; gap: 8px; }
.ctrl-group { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-dim); }
select, textarea {
  background: #1b140c; color: var(--ink); border: 1px solid var(--edge);
  border-radius: 6px; padding: 5px 8px; font-size: 14px;
}
.btn {
  background: linear-gradient(#3d311d, #2a2113);
  color: #eedfb2; border: 1px solid var(--edge);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
.btn:hover { filter: brightness(1.2); }
.btn.primary { background: linear-gradient(#7a5c22, #55401a); border-color: var(--gold-dim); color: #fff; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.btn.danger { border-color: var(--red); color: #f0b0aa; }

/* ---------- status bar ---------- */
#statusbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 18px 6px;
}
.pts-left { display: flex; align-items: baseline; gap: 8px; }
.pts-left .big { font-size: 40px; font-weight: 900; color: var(--gold); line-height: 1; text-shadow: 0 2px 0 #000; }
.pts-left .small { color: var(--ink-dim); font-size: 13px; }
#treeStats { display: flex; gap: 8px; flex-wrap: wrap; }
.tree-stat {
  display: flex; align-items: center; gap: 6px; background: var(--panel2);
  border: 1px solid var(--edge); border-radius: 20px; padding: 3px 10px 3px 4px;
  font-size: 13px;
}
.tree-stat img { width: 20px; height: 20px; border-radius: 4px; }
.tree-stat b { color: var(--gold); font-size: 14px; }
.tree-stat.zero { opacity: .55; }
.mode-tip { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.mode-btn { min-width: 110px; }
.hint { font-size: 12px; color: var(--ink-dim); }
.mobile-only { display: none; }

/* ---------- board ---------- */
#board {
  display: flex; justify-content: center; gap: 18px; align-items: flex-start;
  padding: 4px 10px 20px; flex-wrap: wrap;
}
.tree {
  width: 250px; background: linear-gradient(#241c12, #1d150d 60%, #171009);
  border: 1px solid #5a4427; border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.tree-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px;
  border-bottom: 1px solid #49381f;
}
.tree-head img { width: 26px; height: 26px; border-radius: 5px; border: 1px solid var(--edge); }
.tree-head .tname { font-size: 15px; font-weight: 700; }
.tree-head .tpts { margin-left: auto; font-size: 12px; color: var(--ink-dim); }
.tree-head .tpts b { color: var(--gold); font-size: 14px; }
.tree-grid { position: relative; padding: 8px 4px 10px;
  display: grid; grid-template-columns: repeat(4, 52px);
  justify-content: center; column-gap: 3px; row-gap: 2px; }
svg.links { position: absolute; inset: 0; pointer-events: none; z-index: 0; width: 100%; height: 100%; }
.talent-row {
  display: flex; justify-content: center; gap: 4px; margin: 0 0 6px;
}
.talent { position: relative; width: 52px; height: 56px; z-index: 1; }
.iconbox {
  position: relative; width: 46px; height: 46px; margin: 0 auto;
  border-radius: 6px; overflow: hidden; cursor: pointer; padding: 0;
  background: #120d07;
  border: 2px solid #51402a;
  transition: border-color .12s, box-shadow .12s, filter .12s;
}
.iconbox img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.iconbox::after { content: ""; position: absolute; inset: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,235,170,.12), inset 0 2px 6px rgba(255,255,255,.1), inset 0 -3px 8px rgba(0,0,0,.5); pointer-events: none; }
.iconbox:hover { border-color: var(--gold); filter: brightness(1.15); }
.talent .rnum {
  position: absolute; top: -3px; right: 1px; min-width: 15px; text-align: center;
  font-size: 11px; font-weight: 800; color: #0b0703;
  background: linear-gradient(#f5d97e, #c9962f); border: 1px solid #ffe9ae;
  border-radius: 4px; padding: 0 2px; z-index: 3; box-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.rankpips { display: flex; justify-content: center; gap: 2px; height: 7px; margin-top: 2px; }
.pip {
  width: 5px; height: 5px; transform: rotate(45deg);
  background: #574a30; border-radius: 1px;
}
.pip.on { background: var(--gold); box-shadow: 0 0 4px rgba(232,193,90,.8); }
/* states */
.talent.locked .iconbox img { filter: grayscale(.95) brightness(.42); }
.talent.locked .iconbox { border-color: #372c1b; cursor: not-allowed; }
.talent.locked .iconbox .lock {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #d8c9a5; text-shadow: 0 1px 2px #000; background: rgba(0,0,0,.28);
}
.talent.reqlock .iconbox { border-color: #6d5522; }
.talent.reqlock .iconbox img { filter: saturate(.5) brightness(.6); }
.talent.reqlock .need {
  position: absolute; bottom: 1px; left: 1px; font-size: 8px; color: #ffd9a0; background: rgba(40,20,0,.7);
  border-radius: 2px; padding: 0 2px; z-index: 2; white-space: nowrap;
}
.talent.available .iconbox { border-color: #6a5333; }
.talent.spent .iconbox { border-color: #b98d33; box-shadow: 0 0 7px rgba(232,193,90,.35); }
.talent.maxed .iconbox { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,215,90,.7); }
.talent.spent .fillbar {
  position: absolute; left: 2px; bottom: 2px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, #caa24a, #ffe08a);
  z-index: 3;
}
.cap-row-label {
  font-size: 10px; color: #6f6046; text-align: center; letter-spacing: 2px; margin-bottom: 2px;
}

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 200; width: 316px; max-width: calc(100vw - 20px);
  background: rgba(12,8,4,.97); border: 1px solid #8a6d33;
  border-radius: 10px; padding: 10px 12px 10px;
  box-shadow: 0 10px 34px rgba(0,0,0,.75), 0 0 0 1px rgba(0,0,0,.8), 0 0 24px rgba(232,193,90,.12);
  pointer-events: auto; color: #e9dcc0; font-size: 13px; line-height: 1.5;
}
.tip.pinned { width: 330px; }
.tip-head { display: flex; gap: 10px; align-items: flex-start; }
.tip-head img { width: 42px; height: 42px; border-radius: 6px; border: 1px solid #8a6d33; }
.tip-name { font-size: 15px; font-weight: 800; color: var(--gold); }
.tip-en { margin-left: 6px; font-size: 10.5px; color: #9d8b64; font-weight: 400; }
.tip-name .tag-en { margin-left: 6px; font-size: 10px; color: #c8b06a; border: 1px solid #6b5a33; border-radius: 3px; padding: 0 4px; vertical-align: 1px; }
.tip-sub { font-size: 11px; color: #b5a176; }
.tip-req { margin: 6px 0 0; padding: 4px 8px; background: rgba(150,50,30,.16); border: 1px solid rgba(190,80,50,.45); border-radius: 6px; color: #ffb9a6; font-size: 12px; }
.tip-req.ok { background: rgba(60,130,70,.12); border-color: rgba(90,180,110,.4); color: #b9e6bd; }
.tip-meta { margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.tip-meta .m-cell { display: flex; }
.tip-meta .m-cell em { font-style: normal; color: #d4a24b; margin-right: 6px; min-width: 44px; }
.tip-meta .m-cell span { color: #e6d9bb; }
.tip-body { margin-top: 8px; color: #f0e6cd; }
.tip-body .en-note { margin-top: 4px; font-size: 11px; color: #9d8b64; }
.tip-ranks { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.rankchip {
  width: 24px; height: 20px; border-radius: 4px; border: 1px solid #6d5a32; background: #241a0d;
  color: #cdb98a; font-size: 12px; cursor: pointer; text-align: center; line-height: 18px;
}
.rankchip:hover { filter: brightness(1.3); }
.rankchip.cur { background: linear-gradient(#8a6a26, #5f461a); color: #fff; border-color: #d8ad4d; }
.tip-actions { display: none; margin-top: 10px; gap: 8px; }
.tip.pinned .tip-actions { display: flex; }
.tip-close { position: absolute; top: 5px; right: 8px; background: none; border: 0; color: #a08858; font-size: 16px; cursor: pointer; }
.tip-close:hover { color: #fff; }

/* ---------- dialog / toast ---------- */
.dlg {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6);
}
.dlg-box { width: min(560px, 92vw); background: #241a10; border: 1px solid #8a6d33; border-radius: 12px; padding: 18px; }
.dlg-box h3 { color: var(--gold); margin-bottom: 8px; }
.dlg-box p { color: var(--ink-dim); font-size: 12.5px; margin-bottom: 8px; }
.dlg-box textarea { width: 100%; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 400;
  background: rgba(10,6,2,.96); border: 1px solid var(--edge); color: #ffe6ae;
  padding: 9px 18px; border-radius: 20px; font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,.6); white-space: nowrap;
}
.toast.warn { border-color: var(--red); color: #ffc4bc; }
#footnote { text-align: center; color: #6d5d41; font-size: 12px; padding: 6px 12px 20px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  #board { gap: 14px; }
  .tree { width: 235px; }
}
@media (max-width: 860px) {
  .desktop-only { display: none; }
  .mobile-only { display: inline; }
  #board { padding: 0 0 60px; }
  .tree { width: 100%; max-width: 420px; margin: 0 auto; }
  #board .tree { display: none; }
  #board .tree.active { display: block; }
  #mobTabs { display: flex; gap: 6px; width: 100%; }
  .mobtab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 0; background: var(--panel2); border: 1px solid var(--edge);
    border-radius: 8px; color: #cfc2a6; font-size: 13px; cursor: pointer;
  }
  .mobtab img { width: 18px; height: 18px; border-radius: 3px; }
  .mobtab.active { color: #fff; border-color: var(--gold); background: #3a2c16; }
  .talent-row { justify-content: center; }
  #topbar { gap: 6px; padding: 6px 8px; }
  #statusbar { padding: 6px 8px 4px; gap: 8px; }
  .mode-tip { margin-left: 0; width: 100%; order: 8; }
  .hint.mobile-only { flex: 1; }
}
#mobTabs { display: none; }
@media (max-width: 480px) {
  .brand-sub { display: none; }
  #topRight { flex-wrap: wrap; }
}
