/* Layout: full-bleed canvas arena; HUD floats along the top edge; menus are centered panels that stack to one column on phones. */
/* One deliberate look: a mystic night-purple with gold, cartoon outlines and chunky "game" buttons.
   Colors are explicit so the game reads the same on any host theme. */
:root {
  --ink: #1d1530;        /* night background */
  --ink-2: #2b2148;      /* panels and cards */
  --line: #4b3b72;       /* borders */
  --deep: #140d24;       /* outlines and button depth */
  --fg: #fff7ea;
  --muted: #c2b3e0;
  --hero: #ffcf4a;       /* gold: primary actions */
  --hero-dark: #a8661a;
  --threat: #ff5d73;     /* enemies */
  --xp: #7af0ff;         /* essences */
  --evo: #ffd65d;        /* evolutions */
  --font-display: 'Lilita One', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body {
  height: 100%; margin: 0; overflow: hidden;
  background: var(--ink); color: var(--fg);
  font-family: var(--font-body); font-size: 15px;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 2;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 0;
  display: grid; gap: 6px; pointer-events: none;
}
.xpbar { height: 10px; background: rgba(122, 240, 255, .1); border: 1px solid rgba(122, 240, 255, .4); border-radius: 6px; overflow: hidden; }
#xpfill { height: 100%; background: linear-gradient(90deg, #1f9fbf, var(--xp)); transform-origin: left; transform: scaleX(0); }
.hudrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.lvl { font-family: var(--font-display); font-size: 15px; color: var(--xp); letter-spacing: .04em; }
#timer { font-family: var(--font-display); font-size: 26px; letter-spacing: .04em; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 #000; }
.hudright { justify-self: end; display: flex; align-items: center; gap: 10px; }
.kills { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.kills b { color: var(--fg); }
#pauseBtn {
  pointer-events: auto; width: 38px; height: 38px; border-radius: 10px;
  background: rgba(43, 33, 72, .85); border: 1px solid var(--line); color: var(--fg);
  font-family: var(--font-display); font-size: 14px; cursor: pointer;
}
#slots { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.slot {
  --c: var(--fg);
  width: 30px; height: 30px; border-radius: 8px; position: relative;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  background: rgba(43, 33, 72, .85); border: 1px solid var(--line); color: var(--c);
}
.slot.evo { border-color: var(--evo); box-shadow: 0 0 10px rgba(255, 214, 93, .45); }
.pips { position: absolute; left: 3px; right: 3px; bottom: -4px; display: flex; gap: 1px; }
.pip { flex: 1; height: 3px; border-radius: 2px; background: #3a2f55; }
.pip.on { background: var(--c); }
.slotgap { width: 8px; }
#bossbar { justify-self: center; width: min(100%, 420px); display: grid; gap: 3px; text-align: center; }
#bossname { font-family: var(--font-display); font-size: 13px; color: var(--threat); letter-spacing: .06em; }
.bosstrack { height: 9px; border-radius: 5px; background: rgba(255, 93, 115, .15); border: 1px solid rgba(255, 93, 115, .55); overflow: hidden; }
#bossfill { height: 100%; background: var(--threat); transform-origin: left; }

#banner {
  position: fixed; left: 0; right: 0; top: 32%; z-index: 3; pointer-events: none;
  text-align: center; font-family: var(--font-display); font-size: clamp(26px, 7vw, 48px);
  color: var(--fg); text-shadow: 0 4px 0 #000, 0 0 24px rgba(255, 93, 115, .5);
  opacity: 0;
}
#banner small { display: block; font-size: .45em; color: var(--threat); letter-spacing: .08em; }
#banner.evo small { color: var(--evo); }
#banner.show { animation: banner 2.2s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: scale(1.4); }
  12% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}
#hurt {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 40, 70, .55));
  transition: opacity .35s;
}
#hurt.low { opacity: .55; }
#flash { position: fixed; inset: 0; z-index: 9; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at center, #fff6d6 0%, rgba(255, 214, 93, .6) 40%, transparent 75%); }
#flash.go { animation: flash .6s ease-out; }
#coach {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); z-index: 4; transform: translateX(-50%);
  width: min(calc(100% - 32px), 420px); padding: 12px 16px; border-radius: 14px; pointer-events: none;
  background: rgba(43, 33, 72, .94); border: 1px solid var(--xp); color: var(--fg); font-weight: 600; text-align: center; line-height: 1.4;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}
#coach.show { animation: coachIn .3s ease-out; }
@keyframes coachIn { from { opacity: 0; transform: translate(-50%, 12px); } }
.tip { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 214, 93, .1); border: 1px solid rgba(255, 214, 93, .5); color: var(--fg); line-height: 1.45; }
.tip b { color: var(--evo); }
.ldays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 520px) { .ldays { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.lday { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 10px 4px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); min-width: 0; }
.lday small { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.lday b { font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.lday.got { opacity: .45; }
.lday.today { border: 2px solid var(--hero); box-shadow: 0 0 14px rgba(255, 181, 71, .3); }
.missions { display: grid; gap: 8px; }
.mission { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); }
.mission.claimed { opacity: .55; }
.mission .mt { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.mission .mt small { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.mission .mr { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 700; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
#hurt.hit { opacity: 1; transition: none; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; overflow-x: hidden;
  display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: rgba(14, 8, 28, .78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  touch-action: pan-y;
}
#menu { background: radial-gradient(ellipse at 50% 30%, #3a2466 0%, var(--ink) 70%); }
.panel { width: min(100%, 460px); display: grid; gap: 16px; text-align: center; }
.panel.wide { width: min(100%, 860px); }
h1 {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: clamp(52px, 15vw, 96px); line-height: .88; letter-spacing: .01em;
  color: var(--hero); text-shadow: 5px 5px 0 #6b2338, 0 0 40px rgba(255, 181, 71, .3);
  text-wrap: balance;
}
h1 span { display: block; color: var(--threat); text-shadow: 5px 5px 0 #3b1030, 0 0 40px rgba(255, 93, 115, .35); }
h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(24px, 6vw, 34px); letter-spacing: .02em; text-wrap: balance; }
h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.lede { margin: 0 auto; max-width: 36ch; color: var(--muted); line-height: 1.5; }
.lede b { color: var(--fg); }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.meta { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.meta b { color: var(--evo); }

button { font: inherit; }
button:focus-visible { outline: 3px solid var(--xp); outline-offset: 3px; }
.primary {
  justify-self: center; min-width: 200px; padding: 14px 30px; cursor: pointer;
  font-family: var(--font-display); font-size: 24px; letter-spacing: .03em;
  color: var(--deep); background: var(--hero); border: 0; border-radius: 14px;
  box-shadow: 0 6px 0 var(--hero-dark), 0 10px 30px rgba(255, 181, 71, .25);
}
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--hero-dark); }
.ghost {
  justify-self: center; padding: 10px 18px; cursor: pointer; border-radius: 10px;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.ghost:hover { color: var(--fg); border-color: var(--muted); }
.ghost:disabled { opacity: .4; cursor: default; }
.btnrow { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.combos { display: grid; gap: 6px; text-align: left; }
.combo {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1.2fr; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 10px; background: rgba(43, 33, 72, .7); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.combo .op { color: var(--muted); }
.combo .res { color: var(--evo); }
.chip { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.chip i { font-style: normal; color: var(--c); font-size: 15px; width: 16px; text-align: center; flex: none; }
.chip span { min-width: 0; overflow-wrap: anywhere; }
.combo.done { border-color: var(--evo); }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 680px) { .cards { grid-template-columns: minmax(0, 1fr); } }
.card {
  --c: var(--fg);
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 14px; text-align: left; cursor: pointer; color: var(--fg);
  background: var(--ink-2); border: 2px solid var(--line); border-radius: 14px;
  transition: transform .12s, border-color .12s;
  animation: cardIn .25s ease-out backwards;
}
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } }
.card:hover, .card:focus-visible { border-color: var(--c); transform: translateY(-3px); outline: none; }
.card.evo { border-color: var(--evo); background: linear-gradient(160deg, #3d2e06 0%, var(--ink-2) 65%); box-shadow: 0 0 24px rgba(255, 214, 93, .25); }
.ic {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; line-height: 1; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.ct { display: grid; gap: 4px; min-width: 0; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--c); }
.card.evo .tag { color: var(--evo); }
.ct b { font-family: var(--font-display); font-weight: 400; font-size: 18px; line-height: 1.1; }
.ct .d { color: var(--muted); line-height: 1.4; font-size: 14px; }
.ct .h { font-size: 12px; color: var(--evo); font-weight: 600; }
.key { display: none; font-size: 11px; color: var(--muted); }
@media (hover: hover) { .key { display: inline; } }

.build { display: grid; gap: 8px; text-align: left; }
.buildrow { display: flex; flex-wrap: wrap; gap: 6px; }
.bitem {
  --c: var(--fg);
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px;
  background: rgba(43, 33, 72, .8); border: 1px solid var(--line); font-weight: 600; font-size: 13px;
}
.bitem i { font-style: normal; color: var(--c); }
.bitem small { color: var(--muted); font-weight: 400; }
.bitem.evo { border-color: var(--evo); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 480px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 10px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); display: grid; gap: 2px; }
.stat b { font-family: var(--font-display); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.stat.gold b { color: var(--evo); }
#overTitle.win { color: var(--evo); }
#overTitle.lose { color: var(--threat); }

/* ---------- Hub (out-of-run meta menu) ---------- */
.hub { place-items: start center; }
.hubwrap { width: min(100%, 760px); display: grid; gap: 16px; }
.hubhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { font-family: var(--font-display); font-size: clamp(22px, 6vw, 38px); line-height: .9; color: var(--hero); text-shadow: 3px 3px 0 #6b2338; }
.logo span { color: var(--threat); text-shadow: 3px 3px 0 #3b1030; margin-left: .25em; }
.wallet { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--ink-2); border: 1px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; }
.wallet i, .coin { font-style: normal; color: var(--evo); }
.wallets { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.wallet i.nrg { color: var(--hero); }
.wallet { padding: 7px 11px; }
.wallet i.gem, .gem { font-style: normal; color: #ff7ad9; }
.tabpanel { display: grid; gap: 14px; text-align: left; }
.tabpanel > h3 { margin-top: 4px; }
.box { padding: 14px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); display: grid; gap: 10px; }

.playhero { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 18px 14px; border-radius: 16px;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%), var(--ink-2); border: 1px solid var(--line); }
.playhero > b { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.playhero p { margin: 0; color: var(--muted); max-width: 42ch; line-height: 1.45; }

.chapters { display: flex; gap: 8px; width: 100%; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.chap { --c: var(--line); flex: 0 0 150px; scroll-snap-align: start; display: grid; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 35%, var(--ink)); border: 2px solid color-mix(in srgb, var(--c) 80%, transparent); color: var(--fg); }
.chap small { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.chap b { font-size: 14px; }
.chap span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chap[aria-pressed="true"] { border-color: var(--hero); box-shadow: 0 0 14px rgba(255, 181, 71, .3); }
.chap:disabled { opacity: .45; cursor: default; }
.chinfo { margin: 0; font-size: 13px; color: var(--muted); }
.energy { display: grid; gap: 6px; justify-items: center; }
.ebar { font-variant-numeric: tabular-nums; color: var(--muted); }
.ebar b { color: var(--hero); font-size: 17px; }
.primary:disabled { background: #3a2f55; color: var(--muted); box-shadow: none; cursor: default; }
.adchest { grid-template-columns: 1fr; }
.gemgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.gempack { position: relative; display: grid; gap: 6px; padding: 14px 12px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); }
.gempack b { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.ptag { position: absolute; top: -9px; right: 10px; padding: 2px 8px; border-radius: 999px; background: #ff7ad9; color: #2b0520; font-size: 11px; font-weight: 700; }
.adlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.adbox { display: grid; gap: 8px; justify-items: center; padding: 34px 16px; border-radius: 16px; border: 2px dashed var(--line);
  background: repeating-linear-gradient(45deg, var(--ink-2), var(--ink-2) 12px, #241a3c 12px, #241a3c 24px); }
.adbox b { font-size: 16px; }
.adbox span { color: var(--muted); }
.adcount { font-family: var(--font-display); font-size: 44px; color: var(--fg) !important; font-variant-numeric: tabular-nums; }
#revive .lede { max-width: 34ch; }
.chinfo b { color: var(--fg); }
.unlock { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 214, 93, .12); border: 1px solid var(--evo); color: var(--evo); font-weight: 700; }
.classgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.classcard { --c: var(--fg); display: grid; gap: 8px; align-content: start; text-align: left; padding: 12px; border-radius: 14px; cursor: pointer;
  background: var(--ink-2); border: 2px solid var(--line); color: var(--fg); }
.classcard.sel { border-color: var(--c); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 30%, transparent); }
.classcard.locked { opacity: .78; }
.classtop { display: flex; align-items: center; gap: 10px; }
.classtop .ic { width: 40px; height: 40px; font-size: 20px; }
.classtop b { font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.mods { display: flex; flex-wrap: wrap; gap: 4px; }
.mod { font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: rgba(122, 240, 255, .08); color: var(--fg); }
.mod.neg { background: rgba(255, 93, 115, .12); color: #ffb3bf; }
.mod.mech { background: rgba(255, 214, 93, .14); color: var(--evo); }
.passive { font-size: 13px; color: var(--muted); line-height: 1.4; }
.passive b { color: var(--fg); }
.state { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--c); }
.state.buy { color: var(--evo); }
.state.no { color: var(--muted); }

.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stile { padding: 10px 12px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); display: grid; gap: 2px; min-width: 0; }
.stile b { font-family: var(--font-display); font-weight: 400; font-size: 19px; font-variant-numeric: tabular-nums; }
.stile span { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.attrlist { display: grid; gap: 8px; }
.attr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--ink-2); border: 1px solid var(--line); }
.attr .ic { width: 40px; height: 40px; font-size: 19px; }
.attr .nm { display: grid; gap: 3px; min-width: 0; }
.attr .nm b { font-size: 15px; }
.attr .nm small { color: var(--muted); font-size: 12px; }
.lvlbar { height: 5px; border-radius: 3px; background: #1a1230; overflow: hidden; }
.lvlbar i { display: block; height: 100%; background: var(--c); }
.buybtn { min-width: 86px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--hero); color: var(--deep); border: 0; box-shadow: 0 3px 0 var(--hero-dark); }
.buybtn:disabled { background: #3a2f55; color: var(--muted); box-shadow: none; cursor: default; }
.buybtn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--hero-dark); }

.eqrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.eqslot { --r: var(--line); display: grid; gap: 6px; justify-items: center; text-align: center; padding: 10px 6px; border-radius: 14px; cursor: pointer;
  background: var(--ink-2); border: 2px solid var(--r); color: var(--fg); min-width: 0; }
.eqslot.empty { border-style: dashed; color: var(--muted); }
.eqslot .sl { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.eqslot .ii { font-size: 26px; line-height: 1; color: var(--r); }
.eqslot .nm { font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.invgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.itile { --r: var(--line); position: relative; aspect-ratio: 1; max-width: 100%; border-radius: 12px; cursor: pointer; display: grid; place-items: center;
  font-size: 24px; color: var(--r); background: color-mix(in srgb, var(--r) 10%, var(--ink-2)); border: 2px solid color-mix(in srgb, var(--r) 70%, transparent); }
.itile.sel { outline: 3px solid var(--fg); outline-offset: 2px; }
.itile em { position: absolute; top: 3px; right: 5px; font-style: normal; font-size: 10px; font-weight: 700; color: var(--fg); }
.detail { --r: var(--line); border-color: var(--r); }
.detail .dh { display: flex; align-items: center; gap: 12px; }
.detail .ic { color: var(--r); --c: var(--r); }
.detail .dh b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 18px; color: var(--r); }
.detail .dh small { color: var(--muted); }
.lines { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-weight: 600; font-size: 14px; }
.lines li.neg { color: #ffb3bf; }
.lines li.req { color: #ff8a9c; font-weight: 700; }
.lines li.mech { color: var(--evo); }
.lines li.mech small { display: block; color: var(--muted); font-weight: 400; }
.cmp { font-size: 12px; color: var(--muted); }
.empty-note { color: var(--muted); font-size: 14px; padding: 12px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }

.chestgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.chest { --c: var(--fg); display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--ink-2); border: 2px solid color-mix(in srgb, var(--c) 45%, var(--line)); }
.chest .cbox { height: 56px; border-radius: 10px; display: grid; place-items: center; font-size: 30px; color: var(--c);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, transparent), transparent); }
.chest b { font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.odds { display: grid; gap: 3px; font-size: 12px; font-variant-numeric: tabular-nums; }
.odd { display: grid; grid-template-columns: 70px 1fr 34px; align-items: center; gap: 6px; }
.odd .ob { height: 5px; border-radius: 3px; background: #1a1230; overflow: hidden; }
.odd .ob i { display: block; height: 100%; }
.odd span:last-child { text-align: right; color: var(--muted); }
.rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rcard { --r: var(--line); display: grid; gap: 4px; justify-items: center; padding: 10px; min-width: 110px; border-radius: 12px; background: var(--ink-2); border: 2px solid var(--r); }
.rcard .ii { font-size: 26px; color: var(--r); }
.rcard b { font-size: 13px; }
.rcard small { font-size: 11px; color: var(--r); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.itile .tp { position: absolute; bottom: 2px; left: 5px; font-size: 10px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.eqslot .pw { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.setline { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.invfilters { display: grid; gap: 6px; }
.cmp b.up { color: #7aff9c; }
.cmp b.down { color: #ff8a9c; }
.itile .dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.itile .lk { position: absolute; top: 3px; left: 5px; color: var(--fg); line-height: 0; }
.itile .lv { position: absolute; bottom: 2px; right: 5px; font-size: 9px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.itile .lv::before { content: "Nv "; font-weight: 600; }
.itile.req { filter: grayscale(.55); opacity: .7; }
.itile.req .lv { color: #ff8a9c; }
.setbar { display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.center { justify-content: center; }
.setchip, .tog {
  --c: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: var(--ink-2); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: 13px;
}
.setchip i { font-style: normal; color: var(--c); }
.setchip[aria-pressed="true"], .tog[aria-pressed="true"] { color: var(--fg); border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--ink-2)); }
.tog { --c: var(--xp); padding: 6px 11px; font-size: 12px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--xp); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.lockbtn { display: inline-flex; align-items: center; gap: 6px; }
.lockbtn[aria-pressed="true"] { color: var(--evo); border-color: var(--evo); }
.qsell b { font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.qsell .buybtn { justify-self: start; }
.setmini { display: flex; align-items: center; gap: 6px; }
.setmini .itile { width: 40px; font-size: 18px; cursor: default; }
.setmini .emptyt { --r: var(--line); color: var(--muted); border-style: dashed; }
#reveal .panel { gap: 14px; }
#reveal .rbig { justify-self: center; width: min(100%, 360px); text-align: left; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1) backwards; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
details.combobox summary { cursor: pointer; font-weight: 700; color: var(--muted); padding: 6px 0; }
details.combobox .combos { margin-top: 8px; }
@media (max-width: 480px) {
  .attr { grid-template-columns: auto minmax(0, 1fr); }
  .attr .buybtn { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  #reveal .rbig { animation: none; }
  #flash.go { animation-duration: .25s; }
  #banner.show { animation-duration: 2.2s; animation-name: bannerFade; }
  @keyframes bannerFade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
  .card { animation: none; transition: none; }
}

/* ---------- Active skill button ---------- */
#skillBtn {
  --p: 0;
  position: fixed; z-index: 3; right: calc(env(safe-area-inset-right, 0px) + 22px); bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
  width: 76px; height: 76px; border-radius: 50%; padding: 0; cursor: pointer; touch-action: none;
  display: grid; place-items: center; color: #fff; font-family: var(--font-display);
  background:
    conic-gradient(rgba(10, 6, 20, .72) calc(var(--p) * 360deg), transparent 0),
    radial-gradient(circle at 50% 35%, #ffe08a, #ff9a3d 70%);
  border: 3px solid #2a1840; box-shadow: 0 4px 0 #2a1840, 0 8px 18px rgba(0, 0, 0, .35);
}
#skillBtn.ready { animation: skillReady 1.2s ease-in-out infinite; }
@keyframes skillReady { 50% { box-shadow: 0 4px 0 #2a1840, 0 0 22px rgba(255, 214, 93, .85); } }
#skillBtn .sk-ic { grid-area: 1 / 1; font-size: 30px; line-height: 1; text-shadow: 0 2px 0 #2a1840; }
#skillBtn .sk-cd { grid-area: 1 / 1; font-size: 24px; text-shadow: 0 2px 0 #000; }
#skillBtn:not(.ready) .sk-ic { opacity: .35; }
#skillBtn .sk-key { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-family: var(--font-body); font-size: 10px; font-weight: 700; color: var(--muted); white-space: nowrap; }
@media (pointer: coarse) { #skillBtn .sk-key { display: none; } }
.passive.skill b { color: var(--evo); }
.skillline { margin: 0; font-size: 13px; color: var(--muted); }
.skillline b { color: var(--evo); }
.portrait { display: block; width: 120px; height: 140px; margin: -6px auto 0; }

/* ---------- Evolution trees (pause + Grimoire) ---------- */
.trees { display: grid; gap: 10px; }
.tree { --c: var(--fg); display: grid; gap: 6px; padding: 10px 12px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); text-align: left; }
.troot { display: flex; align-items: center; gap: 8px; color: var(--c); }
.troot i { font-style: normal; font-size: 18px; }
.troot.cur b { text-decoration: underline; text-underline-offset: 3px; }
.tbranch { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding-left: 10px; border-left: 2px solid var(--line); }
.tbranch.off { opacity: .4; }
.tneed { --c: var(--muted); font-size: 11px; font-weight: 700; color: var(--c); opacity: .8; }
.tneed.have { opacity: 1; text-decoration: underline; }
.tnode { --c: var(--fg); display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); color: var(--c); background: rgba(0, 0, 0, .18); }
.tnode i { font-style: normal; }
.tnode.fin { border-style: dashed; }
.tnode.on { border-color: var(--c); }
.tnode.cur { border: 2px solid var(--evo); box-shadow: 0 0 10px rgba(255, 214, 93, .45); color: #fff; }
.slot.asc { box-shadow: 0 0 14px rgba(255, 255, 255, .6); }
button.wide { width: 100%; }

/* ---------- Modes, daily, mastery, achievements, damage breakdown ---------- */
.modes { justify-content: center; }
.box.daily { display: grid; gap: 8px; text-align: left; }
.stars { margin-left: auto; color: var(--evo); font-size: 12px; letter-spacing: 1px; }
.mastery { display: grid; gap: 4px; justify-items: center; font-size: 12px; font-weight: 700; color: var(--evo); }
.mastery .lvlbar { width: 140px; }
.unlock.ach { color: var(--evo); }
.dmgrows { display: grid; gap: 6px; }
.dmgrow { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) 40px; gap: 8px; align-items: center; font-size: 13px; text-align: left; }
.dmgrow span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmgrow .ob { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.dmgrow .ob i { display: block; height: 100%; background: var(--evo); }
.dmgrow b { text-align: right; font-variant-numeric: tabular-nums; }
#saveCode { width: 100%; box-sizing: border-box; margin-top: 8px; border-radius: 10px; padding: 8px; font: 12px/1.4 ui-monospace, monospace;
  background: var(--ink); color: var(--fg); border: 1px solid var(--line); resize: vertical; user-select: text; -webkit-user-select: text; }

/* ---------- Theme: mystic cartoon ---------- */
html, body { font-weight: 700; }
#menu { background:
  radial-gradient(circle at 15% 12%, rgba(255, 214, 93, .10) 0 2px, transparent 3px) 0 0 / 90px 90px,
  radial-gradient(circle at 70% 60%, rgba(194, 179, 224, .10) 0 1.5px, transparent 2.5px) 0 0 / 70px 70px,
  radial-gradient(ellipse at 50% 20%, #3a2466 0%, var(--ink) 70%); }
.logo { color: #c9a6ff; text-shadow: 0 3px 0 var(--deep), 2px 0 0 var(--deep), -2px 0 0 var(--deep), 0 -2px 0 var(--deep), 0 6px 12px rgba(0, 0, 0, .4); letter-spacing: .02em; }
.logo span { margin-left: 0; color: var(--hero); text-shadow: 0 3px 0 var(--deep), 2px 0 0 var(--deep), -2px 0 0 var(--deep), 0 -2px 0 var(--deep); }
h2 { text-shadow: 0 3px 0 var(--deep); }
.box, .playhero, .classcard, .card, .stat, .stile, .attr, .mission, .lday, .gempack, .chest, .eqslot, .tree, .wallet {
  border-width: 2px; box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.panel { background: var(--ink-2); border: 3px solid var(--deep); border-radius: 22px; padding: 22px 18px; box-shadow: 0 8px 0 rgba(10, 4, 20, .6), inset 0 0 0 2px var(--line); }
#menu .panel, .hub .panel { background: none; border: 0; box-shadow: none; padding: 0; }
.primary { font-weight: 400; color: var(--deep); background: linear-gradient(180deg, #ffe08a, var(--hero) 55%, #f2b23a);
  border: 3px solid var(--deep); border-radius: 18px; box-shadow: 0 6px 0 var(--deep), 0 12px 24px rgba(0, 0, 0, .35); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--deep); }
.primary:disabled { background: #3a2f55; color: var(--muted); border-color: var(--deep); box-shadow: 0 4px 0 var(--deep); text-shadow: none; }
.buybtn { color: var(--deep); background: linear-gradient(180deg, #ffe08a, var(--hero)); border: 2px solid var(--deep); box-shadow: 0 3px 0 var(--deep); }
.buybtn:active:not(:disabled) { box-shadow: 0 1px 0 var(--deep); }
.buybtn:disabled { background: #3a2f55; border-color: var(--deep); box-shadow: 0 2px 0 var(--deep); }
.ghost { border: 2px solid var(--line); background: rgba(20, 13, 36, .35); color: var(--fg); }
.ghost:hover { border-color: var(--hero); }
.tog { border-width: 2px; }
.card { border-width: 3px; }
.card.evo { background: linear-gradient(160deg, #4a3510 0%, var(--ink-2) 65%); }
.ct b, .classtop b, .playhero b, .stat b, .stile b, .gempack b { letter-spacing: .01em; }
.wallet { background: rgba(20, 13, 36, .6); }
.ic { border-width: 2px; }
.lvlbar { background: #1a1230; }
#coach { background: rgba(43, 33, 72, .96); border: 2px solid var(--hero); box-shadow: 0 5px 0 var(--deep), 0 12px 30px rgba(0, 0, 0, .4); }
#banner { text-shadow: 0 4px 0 var(--deep), 2px 0 0 var(--deep), -2px 0 0 var(--deep), 0 0 24px rgba(180, 107, 255, .5); }
.xpbar { background: rgba(20, 13, 36, .7); border: 2px solid var(--deep); height: 12px; }
#xpfill { background: linear-gradient(90deg, #4fc8e8, var(--xp)); }
.slot { border-width: 2px; border-color: var(--deep); }
#pauseBtn { border: 2px solid var(--deep); box-shadow: 0 3px 0 var(--deep); background: rgba(43, 33, 72, .9); }

/* ---------- Skins ---------- */
.skingrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.skincard { --r: var(--line); display: grid; gap: 4px; justify-items: center; text-align: center; padding: 10px 8px 12px; border-radius: 16px;
  background: radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--r) 22%, transparent), transparent 70%), var(--ink-2);
  border: 2px solid var(--r); box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.skincard.on { box-shadow: 0 0 0 3px var(--hero), 0 4px 0 rgba(10, 4, 20, .55); }
.skincard canvas { width: 110px; height: 128px; }
.skincard b { font-family: var(--font-display); font-weight: 400; font-size: 16px; line-height: 1.1; }
.skincard small { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--r); }
.skincard .state { font-size: 11px; line-height: 1.3; }

/* ---------- Appearance editor ---------- */
.looks { grid-template-columns: 150px minmax(0, 1fr); align-items: start; }
@media (max-width: 560px) { .looks { grid-template-columns: minmax(0, 1fr); justify-items: center; } }
.lookprev { width: 150px; height: 180px; }
.lrows { display: grid; gap: 10px; width: 100%; }
.lrow { display: grid; gap: 5px; }
.lrow .lk { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.lnote { font-size: 12px; color: var(--muted); font-weight: 600; }
.swatch { --s: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; background: var(--s); border: 2px solid var(--deep); box-shadow: 0 2px 0 var(--deep); padding: 0; }
.swatch.on { outline: 3px solid var(--hero); outline-offset: 1px; }
.ghost.danger { color: #ffb3bf; border-color: #7a2a3a; }
.ghost.danger:hover { border-color: var(--threat); color: #fff; }

.trole { margin-left: auto; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tdesc { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- Cosmetic rarities and auras ---------- */
.rarlegend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.rarlegend span { --r: #fff; color: var(--r); display: inline-flex; align-items: center; gap: 5px; }
.rarlegend span::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--r); box-shadow: 0 0 6px var(--r); }
.skincard { border-width: 3px; }
.auragrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.auracard { --r: var(--line); --a: #fff; display: grid; gap: 5px; justify-items: center; text-align: center; padding: 12px 8px; border-radius: 16px;
  background: var(--ink-2); border: 3px solid var(--r); box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.auracard.on { box-shadow: 0 0 0 3px var(--hero), 0 4px 0 rgba(10, 4, 20, .55); }
.auracard b { font-family: var(--font-display); font-weight: 400; font-size: 15px; }
.auracard small { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--r); }
.auracard .state { font-size: 11px; line-height: 1.3; }
.aurasw { width: 46px; height: 18px; border-radius: 50%; border: 3px solid var(--a); box-shadow: 0 0 12px var(--a), inset 0 0 8px var(--a); }

/* ---------- Shadows, constellations, guilds, chronicles, rank ---------- */
.rankpill { gap: 5px; border-color: #b46bff; }
.rankpill i { font-style: normal; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.rankpill b { font-family: var(--font-display); font-weight: 400; font-size: 17px; color: #d6b8ff; }
.rankpill small { font-size: 11px; color: var(--muted); }
.tog.red[aria-pressed="true"] { background: #7a1e2a; border-color: #ff5d73; color: #fff; }
.shgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.shcard { --r: var(--line); position: relative; display: grid; gap: 6px; justify-items: center; text-align: center; padding: 12px 10px; border-radius: 16px;
  background: radial-gradient(ellipse at 50% 15%, rgba(180, 107, 255, .22), transparent 70%), var(--ink-2); border: 3px solid var(--r); box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.shcard.on { box-shadow: 0 0 0 3px #b46bff, 0 4px 0 rgba(10, 4, 20, .55); }
.shcard canvas { width: 90px; height: 90px; }
.shcard b { font-family: var(--font-display); font-weight: 400; font-size: 15px; line-height: 1.1; }
.shcard small { font-size: 12px; color: var(--muted); }
.shcard .btnrow { gap: 6px; }
.shcard .btnrow button { font-size: 12px; padding: 7px 9px; min-width: 0; }
.shrank { position: absolute; top: 8px; left: 10px; font-family: var(--font-display); font-size: 22px; color: var(--r); text-shadow: 0 2px 0 var(--deep); }
.unlock.shadowmsg { color: #d6b8ff; border-color: #b46bff; background: rgba(180, 107, 255, .12); }
.constels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.constel { --c: var(--fg); display: grid; gap: 6px; padding: 12px; border-radius: 16px; background: var(--ink-2); border: 2px solid var(--line); box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.constel .ch { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; color: var(--c); }
.constel .ch i { font-style: normal; font-size: 22px; grid-row: span 2; }
.constel .ch small { color: var(--muted); font-size: 12px; }
.star { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: rgba(20, 13, 36, .4); }
.star .si { color: var(--muted); font-size: 18px; }
.star.lit .si { color: var(--c); text-shadow: 0 0 8px var(--c); }
.star b { font-size: 13px; display: block; }
.star .buybtn { min-width: 52px; padding: 6px 8px; }
.guilds { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.guild { --c: var(--fg); display: grid; gap: 8px; padding: 12px; border-radius: 16px; background: var(--ink-2); border: 2px solid var(--c); box-shadow: 0 4px 0 rgba(10, 4, 20, .55); }
.guild .gh { display: flex; gap: 8px; align-items: center; color: var(--c); }
.guild .gh i { font-style: normal; font-size: 22px; }
.guild small, .guildbox small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.guildbox { border-color: var(--c); }
.pages { display: grid; gap: 10px; }
.pagech { display: grid; gap: 6px; }
.pagech > b { font-family: var(--font-display); font-weight: 400; color: var(--evo); }
.page { padding: 10px 12px; border-radius: 12px; background: #f2e2bc; color: #3a2a1a; border: 2px solid var(--deep); box-shadow: 0 3px 0 rgba(10, 4, 20, .5); }
.page b { font-family: var(--font-display); font-weight: 400; }
.page p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; font-weight: 600; }
.page.locked { background: var(--ink-2); color: var(--muted); }
#coach .story { display: block; font-style: italic; font-weight: 600; }
#coach .storyx { display: block; margin-top: 6px; color: #ff8a9c; }

/* ---------- Realms ---------- */
.realms { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; width: 100%; }
.realm { --c: var(--line); display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 14px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 18%, var(--ink-2)); border: 2px solid color-mix(in srgb, var(--c) 70%, transparent); color: var(--fg); box-shadow: 0 3px 0 rgba(10, 4, 20, .5); }
.realm i { font-style: normal; font-size: 24px; color: var(--c); grid-row: span 2; text-shadow: 0 0 10px var(--c); }
.realm b { font-family: var(--font-display); font-weight: 400; font-size: 15px; }
.realm small { font-size: 11px; color: var(--muted); }
.realm[aria-pressed="true"] { border-color: var(--hero); box-shadow: 0 0 0 2px var(--hero), 0 3px 0 rgba(10, 4, 20, .5); }
.realm.done small { color: var(--evo); }
.realm:disabled { opacity: .45; cursor: default; }
.realmdesc { max-width: 52ch; }

/* ---------- Onboarding ---------- */
.nextstep { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 10px; border-radius: 14px;
  background: color-mix(in srgb, var(--hero) 14%, var(--ink-2)); border: 2px solid color-mix(in srgb, var(--hero) 60%, transparent); }
.nextstep > i { font-style: normal; font-size: 20px; color: var(--hero); }
.nextstep > span { flex: 1; line-height: 1.35; }
.nextstep b { color: var(--hero); }
.introtip { margin-bottom: 10px; }
/* Download / update bar (Play tab): wraps on phones so the button never squeezes the text */
.appdl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; margin-bottom: 10px; border-radius: 14px;
  background: var(--ink-2); border: 2px solid var(--line); }
.appdl > i { font-style: normal; font-size: 20px; }
.appdl > span { flex: 1 1 200px; line-height: 1.35; }
.appdl b { color: var(--hero); }
.appdl a.buybtn { display: inline-block; text-align: center; text-decoration: none; }
.appdl .ghost { padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.appdl .ghost.x { padding: 6px 10px; }
.appdl.upd { background: color-mix(in srgb, var(--evo) 16%, var(--ink-2)); border-color: color-mix(in srgb, var(--evo) 60%, transparent); }
.appdl.upd b { color: var(--evo); }
.helpgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.helpcard { display: flex; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); }
.helpcard > i { font-style: normal; font-size: 24px; width: 30px; text-align: center; color: var(--hero); }
.helpcard p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.helpcard p b { color: var(--fg); }
#coach.task { border-color: var(--hero); }
#subSkillBtn { --p: 0; position: fixed; z-index: 3; right: calc(env(safe-area-inset-right, 0px) + 30px); bottom: calc(env(safe-area-inset-bottom, 0px) + 136px);
  width: 60px; height: 60px; border-radius: 50%; padding: 0; cursor: pointer; touch-action: none; display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); border: 3px solid #2a1840; box-shadow: 0 4px 0 #2a1840;
  background: conic-gradient(rgba(20, 10, 36, .72) calc(var(--p) * 360deg), transparent 0), radial-gradient(circle at 50% 35%, #5ad8ff, #2a4a8a 75%); }
#subSkillBtn[hidden] { display: none; }
#subSkillBtn .sk-ic { grid-area: 1 / 1; font-size: 24px; line-height: 1; text-shadow: 0 2px 0 #2a1840; }
#subSkillBtn .sk-cd { grid-area: 1 / 1; font-size: 20px; text-shadow: 0 2px 0 #000; }
#subSkillBtn:not(.ready) .sk-ic { opacity: .35; }
#subSkillBtn .sk-key { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-family: var(--font-body); font-size: 10px; font-weight: 700; color: var(--muted); }
@media (pointer: coarse) { #subSkillBtn .sk-key { display: none; } }
#skillBtn.teach { animation: skillTeach .9s ease-in-out infinite; }
@keyframes skillTeach { 50% { transform: scale(1.14); box-shadow: 0 0 0 6px rgba(255, 207, 74, .45), 0 0 26px rgba(255, 207, 74, .8); } }

/* ---------- Races ---------- */
.racegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.racecard { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 14px; background: var(--ink-2); border: 2px solid var(--line); }
.racecard.on { border-color: var(--hero); box-shadow: 0 0 0 2px var(--hero); }
.racecard .rh { display: flex; align-items: center; gap: 8px; }
.racecard .rh i { font-style: normal; font-size: 20px; color: var(--hero); }
.racecard small { color: var(--muted); line-height: 1.35; }
.racecard .buybtn, .racecard .state { margin-top: auto; }

/* ---------- Bigger look preview ---------- */
.looks .lookprev { width: 190px; height: 230px; position: sticky; top: 8px; align-self: start; }
@media (max-width: 520px) { .looks .lookprev { width: 150px; height: 182px; } }

.tree.locked { opacity: .6; }
.tlock { margin: 4px 0 6px; font-size: 12px; color: var(--hero); }

/* ---------- Shadow mode button, merge ---------- */
#shadowBtn { position: fixed; z-index: 3; right: calc(env(safe-area-inset-right, 0px) + 112px); bottom: calc(env(safe-area-inset-bottom, 0px) + 44px);
  width: 54px; height: 54px; border-radius: 50%; padding: 0; cursor: pointer; touch-action: none; font-size: 24px; color: #fff;
  background: radial-gradient(circle at 50% 35%, #8a5ad6, #3a1f6a 75%); border: 3px solid #2a1840; box-shadow: 0 4px 0 #2a1840, 0 0 14px rgba(180, 107, 255, .5); }
#shadowBtn.guard { background: radial-gradient(circle at 50% 35%, #7ad8ff, #2a4a9a 75%); }
.mergebox { margin: 8px 0; border-color: var(--hero); }
.mergebox p { margin: 4px 0; }
.shcard .ghost.on { border-color: var(--hero); color: var(--hero); }

/* ---------- Item sets ---------- */
.lines .setline { color: var(--c); font-weight: 700; }
.lines .setline small { display: block; font-weight: 400; color: var(--muted); }
.setlist { display: grid; gap: 6px; }
.setrow { display: grid; gap: 3px; padding: 8px 10px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: var(--ink-2); }
.setrow b { color: var(--c); }
.setrow small { color: var(--muted); font-weight: 400; }
.setrow span { opacity: .55; font-size: 12px; }
.setrow span.act { opacity: 1; }
.setrow.on { box-shadow: 0 0 0 1px var(--c); }
.setrow .mods, .setline .mods { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }

/* ---------- Curses ---------- */
.card.curse { background: linear-gradient(180deg, rgba(194, 58, 90, .28), rgba(40, 10, 30, .9)); border-color: #c23a5a; box-shadow: 0 0 0 2px rgba(194, 58, 90, .5), 0 6px 0 #2a0c1a; }
.card.curse .tag { color: #ff8aa8; }
.bitem.curse { border-color: #c23a5a; }

/* ---------- Bestiary ---------- */
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.bcard { display: grid; gap: 3px; justify-items: center; text-align: center; padding: 10px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); }
.bcard canvas { width: 56px; height: 56px; }
.bcard small { color: var(--muted); font-size: 11px; }
.bcard p { margin: 2px 0 0; font-size: 12px; line-height: 1.35; color: var(--fg); opacity: .85; }
.bcard.unknown b { color: var(--muted); }

/* ---------- Gamepad focus ---------- */
body.padnav :focus { outline: 3px solid var(--hero); outline-offset: 2px; }

/* ---------- Choice timer and build ---------- */
.lutimer { position: relative; width: min(420px, 90%); margin: -2px auto 8px; height: 22px; text-align: center; }
.lutimer i { position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: 2px; background: var(--hero); transform-origin: left; }
.lutimer span { display: block; padding-top: 7px; font-size: 12px; color: var(--muted); }
.buildchips { margin-bottom: 6px; }
.buildchips .tog.hintp { box-shadow: 0 0 0 2px var(--hero); }

/* ---------- Player profile ---------- */
.hubhead .logo { margin-right: auto; }
.profpill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; background: rgba(20, 13, 36, .6);
  border: 1px solid var(--line); color: inherit; font: inherit; cursor: pointer; min-width: 0; max-width: 46vw; }
.profpill[aria-pressed="true"] { border-color: var(--hero); }
.profpill i { font-style: normal; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--c) 35%, #1a1030); border: 2px solid var(--c); font-size: 15px; }
.profpill span { display: grid; text-align: left; line-height: 1.15; min-width: 0; }
.profpill b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profpill small { font-size: 10px; color: var(--muted); font-family: ui-monospace, monospace; letter-spacing: .04em; }
.profcard { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; border-color: var(--c); }
@media (max-width: 520px) { .profcard { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } .profcard .chips { justify-content: center; } }
.profprev { width: 150px; height: 180px; }
.profinfo { display: grid; gap: 8px; width: 100%; min-width: 0; }
.profname { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
@media (max-width: 520px) { .profname { justify-content: center; } }
.profname b { font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.05; overflow-wrap: anywhere; }
.pid { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); letter-spacing: .06em; }
.namefield { display: grid; gap: 4px; text-align: left; }
.namefield > span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.nrow { display: flex; gap: 6px; }
.nrow input { flex: 1; min-width: 0; border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; color: inherit;
  background: rgba(10, 6, 20, .55); border: 1px solid var(--line); }
.nrow input:focus { outline: 2px solid var(--hero); outline-offset: 1px; }
.pinrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 480px) { .pinrow { grid-template-columns: minmax(0, 1fr); } }
.pinach { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 12px 10px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 207, 74, .14), rgba(20, 13, 36, .6)); border: 1px solid rgba(255, 207, 74, .55); }
.pinach i { font-style: normal; font-size: 24px; }
.pinach b { font-family: var(--font-display); font-weight: 400; font-size: 16px; line-height: 1.1; }
.pinach small { font-size: 12px; color: var(--muted); }
.pinach.empty { background: rgba(20, 13, 36, .4); border-style: dashed; border-color: var(--line); }
.pinach.empty i { color: var(--muted); }
.pickach { margin-top: 8px; }
/* Narrow screens: logo + profile on the first row, wallets on their own row. */
@media (max-width: 620px) {
  .hubhead { flex-wrap: wrap; row-gap: 8px; }
  .hubhead .wallets { order: 3; width: 100%; justify-content: center; flex-wrap: nowrap; }
  .hubhead .wallet { padding: 6px 9px; }
  .profpill { max-width: 52vw; }
}

/* ---------- Inventory readability ---------- */
.isvg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.itile .isvg { width: 30px; height: 30px; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .5)); }
.eqslot .ii .isvg, .rcard .ii .isvg { width: 32px; height: 32px; }
.detail .ic .isvg { width: 34px; height: 34px; }
.setmini .itile .isvg { width: 22px; height: 22px; }
.cmp .ci .isvg { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; }
.itile .tp { color: var(--fg); opacity: .8; }
.upa { color: #7aff9c; font-size: 9px; margin-right: 2px; }
.itile .nw, .invlegend .nw { font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: #1a1030; background: var(--hero); border-radius: 4px; padding: 1px 3px; }
.itile .nw { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); }
.invlegend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 11px; }
.invlegend em { font-style: normal; font-weight: 700; color: var(--fg); }
.invlegend .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.flabel { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); align-self: center; min-width: 62px; }
.lines.diff { font-size: 13px; }
.lines.diff li.up { color: #7aff9c; }
.lines.diff li.down { color: #ff8a9c; }
.lines.diff li.up::before { content: '▲ '; font-size: 9px; }
.lines.diff li.down::before { content: '▼ '; font-size: 9px; }
.cmpbox { display: grid; gap: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(10, 6, 20, .35); }
.invlayout { display: grid; gap: 12px; }
.invmain { display: grid; gap: 10px; min-width: 0; align-content: start; }
.invmain h3 { margin: 0; }
.invside { order: -1; min-width: 0; }
@media (min-width: 900px) {
  .invlayout.hasdetail { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .invside { order: 0; position: sticky; top: 8px; }
  .invside .btnrow { flex-wrap: wrap; }
}
.bitem em { display: block; width: 100%; font-style: normal; font-size: 10px; color: var(--muted); font-weight: 400; }
.bitem em.rdy { color: var(--evo); font-weight: 700; }
.bitem.ready { border-color: var(--evo); box-shadow: 0 0 0 1px var(--evo), 0 0 10px color-mix(in srgb, var(--evo) 40%, transparent); }
.bitem { flex-wrap: wrap; row-gap: 2px; }
.invsep { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.invsep .isvg { width: 14px; height: 14px; }
.invsep:first-child { margin-top: 0; }
/* Phones: each filter row scrolls sideways instead of stacking up */
@media (max-width: 620px) {
  .invfilters .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .invfilters .chips::-webkit-scrollbar { display: none; }
  .invfilters .tog { flex: none; }
  .flabel { min-width: 0; flex: none; }
}

/* Game version, always readable in the hub and on the pause screen */
/* Version: at the end of the page, so it scrolls with the content instead of covering it */
.verbadge { display: block; width: max-content; margin: 18px 0 calc(6px + env(safe-area-inset-bottom, 0px)) auto; pointer-events: none;
  font: 600 11px/1 ui-monospace, monospace; letter-spacing: .04em; color: var(--muted); opacity: .8;
  padding: 4px 7px; border-radius: 6px; background: rgba(10, 6, 20, .55); }
.verbadge.inline { margin: -6px auto 6px; }

/* Shadow merge: picked cards, per-card result preview, confirm bar pinned to the bottom */
.shcard.picked { box-shadow: 0 0 0 3px var(--hero), 0 4px 0 rgba(10, 4, 20, .55); }
.shcard.picked2 { box-shadow: 0 0 0 3px var(--evo), 0 4px 0 rgba(10, 4, 20, .55); }
.mprev { font-size: 11px; color: var(--muted); line-height: 1.3; }
.mergebox { position: sticky; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 4; margin: 10px 0 0;
  background: rgba(29, 21, 48, .97); box-shadow: 0 -6px 24px rgba(0, 0, 0, .45); }
/* Shop */
.shopbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.chestbtns { gap: 6px; }
.chestbtns .buybtn { flex: 1; }
#revealBtns { flex-wrap: wrap; justify-content: center; }
.mergebox .warn { color: #ffb86b; font-size: 12px; } .mergebox .up { color: #7aff9c; font-size: 12px; font-weight: 700; }

/* Shop kinds and crystal expansions */
.chestkinds { margin-bottom: 4px; }
.chestkinds .ki .isvg { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.chest .cbox .isvg { width: 34px; height: 34px; }
.chest .ckind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: -6px; }
.xbox { display: grid; gap: 8px; }
.xrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.xrow span { display: grid; gap: 2px; }
.xrow small { color: var(--muted); font-size: 12px; }
.legionbox { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.chestbtns button { white-space: nowrap; font-size: 13px; padding-left: 10px; padding-right: 10px; }

/* Online account and leaderboards */
.acct { display: grid; gap: 6px; }
.acct.on { border-color: #7aff9c; }
.acct .warn { color: #ffb86b; }
.acct a { color: #7af0ff; }
.gbtn .g { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 900; margin-right: 6px; font-size: 13px; }
.ranklist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.ranklist li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--ink-2); border: 1px solid var(--line); }
.ranklist li.me { border-color: var(--hero); box-shadow: 0 0 0 1px var(--hero); }
.ranklist .rp { font-family: var(--font-display); font-size: 18px; text-align: center; color: var(--muted); }
.ranklist .top1 .rp { color: #ffd65d; } .ranklist .top2 .rp { color: #cfd6e3; } .ranklist .top3 .rp { color: #d08a4e; }
.ranklist .rn { display: grid; min-width: 0; }
.ranklist .rn b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranklist .rn small { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); }
.ranklist .rv { font-weight: 800; font-variant-numeric: tabular-nums; }

.optrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; }

/* ---------- City (hub map) ---------- */
/* Each place of the city opens one panel. Places stay on the map while locked, with a lock and what opens them. */
.city { position: relative; aspect-ratio: 16 / 10; border-radius: 20px; overflow: hidden; border: 2px solid var(--deep);
  box-shadow: 0 4px 0 var(--deep), inset 0 0 60px rgba(0, 0, 0, .45);
  background:
    radial-gradient(circle at 50% 52%, rgba(122, 240, 255, .22), transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(255, 247, 234, .5) 0 3%, transparent 3.6%),
    radial-gradient(1px 1px at 12% 8%, #fff8 50%, transparent), radial-gradient(1px 1px at 30% 4%, #fff6 50%, transparent),
    radial-gradient(1px 1px at 68% 7%, #fff7 50%, transparent), radial-gradient(1px 1px at 94% 26%, #fff5 50%, transparent),
    radial-gradient(ellipse at 50% 120%, #3b2a63, transparent 70%),
    linear-gradient(180deg, #160f2a 0%, #241a44 38%, #2e2352 100%); }
.cityroads { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cityroads line { stroke: rgba(255, 207, 74, .28); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1 10; vector-effect: non-scaling-stroke; }
.place { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 128px;
  display: grid; justify-items: center; gap: 2px; padding: 4px; border: 0; background: none; color: var(--fg); cursor: pointer;
  font: inherit; text-align: center; transition: transform .12s ease; }
.place:hover, .place:focus-visible { transform: translate(-50%, -50%) scale(1.06); outline: none; }
.place:active { transform: translate(-50%, -50%) scale(.97); }
.place .bld, .placehead .bld { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px 16px 12px 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, var(--ink-2)), color-mix(in srgb, var(--c) 22%, var(--deep)));
  border: 2px solid var(--deep); box-shadow: 0 4px 0 var(--deep), 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); }
.place .bld i, .placehead .bld i { font-style: normal; font-size: 28px; line-height: 1; filter: drop-shadow(0 2px 0 var(--deep)); }
.place b { font-family: var(--font-display); font-weight: 400; font-size: 15px; line-height: 1.1; text-shadow: 0 2px 0 var(--deep); }
.place small { font-size: 11px; color: var(--muted); line-height: 1.2; text-shadow: 0 1px 0 var(--deep); }
.place.portal { width: 150px; }
.place.portal .bld { width: 78px; height: 78px; border-radius: 50%; animation: portalglow 2.4s ease-in-out infinite; }
.place.portal .bld i { font-size: 40px; animation: portalspin 9s linear infinite; }
@keyframes portalglow { 50% { box-shadow: 0 4px 0 var(--deep), 0 0 34px color-mix(in srgb, var(--c) 80%, transparent); } }
@keyframes portalspin { to { transform: rotate(360deg); } }
.place.locked { cursor: help; }
.place.locked .bld { filter: grayscale(.9) brightness(.6); box-shadow: 0 4px 0 var(--deep); }
.place.locked b { color: var(--muted); }
.place.badge .bld::after { content: ''; position: absolute; top: -5px; right: -5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--threat); border: 2px solid var(--deep); box-shadow: 0 0 8px var(--threat); }
.place.new .bld::before { content: 'Novo'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); padding: 1px 6px; border-radius: 6px;
  font: 700 10px/1.3 var(--font-body); background: var(--threat); color: #fff; box-shadow: 0 2px 0 var(--deep); }
.place .bld { position: relative; }
@media (max-width: 600px) {
  .city { aspect-ratio: 4 / 5; }
  .place { width: 104px; }
  .place.portal { width: 120px; }
  .place .bld { width: 50px; height: 50px; }
  .place .bld i { font-size: 24px; }
  .place.portal .bld { width: 68px; height: 68px; }
  .place b { font-size: 14px; }
  .place small { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .place.portal .bld, .place.portal .bld i { animation: none; } }

/* Shortcut to the portal under the map */
.cityplay { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--c) 10%, var(--ink-2)); border: 2px solid var(--deep); box-shadow: 0 4px 0 var(--deep); }
.cityplay .portrait { width: 64px; height: 76px; margin: 0; }
.cpinfo { display: grid; gap: 2px; }
.cpinfo b { font-family: var(--font-display); font-weight: 400; font-size: 18px; }
.cpinfo small { color: var(--muted); }
.cpbtns { display: grid; gap: 6px; }
@media (max-width: 480px) {
  .cityplay { grid-template-columns: auto minmax(0, 1fr); }
  .cpbtns { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}

/* Title bar of a place, with the way back to the city */
.placehead { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: color-mix(in srgb, var(--c) 12%, var(--ink-2)); border: 2px solid var(--deep); box-shadow: 0 4px 0 var(--deep); }
.placehead .bld { flex: none; width: 48px; height: 48px; }
.placehead .bld i { font-size: 24px; }
.placehead > div { display: grid; gap: 2px; min-width: 0; }
.placehead b { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.placehead small { color: var(--muted); line-height: 1.3; }
.placehead .back { flex: none; padding: 8px 10px; white-space: nowrap; }
@media (max-width: 480px) {
  .placehead { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .placehead .back { grid-column: 1 / -1; justify-self: start; padding: 6px 12px; }
}
.placetabs .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--threat); vertical-align: middle; }

/* Shadow army: batch tools */
.armytools { display: grid; gap: 10px; text-align: left; }
.armyrow { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid rgba(194, 179, 224, .14); }
.armyrow small { display: block; color: var(--muted); }
.armyrow .buybtn { justify-self: start; }
.chips .lbl { align-self: center; color: var(--muted); font-size: 12px; margin-right: 2px; }

/* Saved run waiting to be continued (city and Portal) */
.savedrun { margin-bottom: 12px; border-color: color-mix(in srgb, var(--c) 60%, var(--deep)); }
.savedrun > .ic { font-size: 34px; width: 56px; text-align: center; }
