/* Bastion Siege — heraldic toybox.
   Board: painted tabletop diorama. UI: indigo enamel plaques with gold trim and chunky "toy" buttons. */

:root {
  --ink: #1e2433;
  --night: #141938;
  --enamel: #1b2140;
  --enamel-2: #252c55;
  --enamel-3: #313a6d;
  --line: #3e4885;
  --text: #eef1ff;
  --muted: #a9b0d6;
  --gold: #f2b33d;
  --gold-deep: #c98a1b;
  --blue: #3d7bd9;
  --red: #d9473b;
  --moss: #7fb24a;
  --violet: #8a4fd8;
  --common: #b9c1e6;
  --rare: #5aa7ff;
  --epic: #c27dff;
  --ui-scale: 1;
  --radius: 14px;
  --font: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Grenze Gotisch", Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
[data-colorblind="true"] { --red: #ff8a00; --moss: #3d9ad9; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--text); font-family: var(--font); font-size: calc(16px * var(--ui-scale)); -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
button { font-family: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- buttons ---------- */
.btn {
  --bg: var(--enamel-3); --fg: var(--text); --lip: #12162e;
  appearance: none; border: 2px solid var(--ink); border-radius: 12px; background: var(--bg); color: var(--fg);
  font: 700 1rem/1.1 var(--font); padding: .6em 1em; cursor: pointer; box-shadow: 0 4px 0 var(--lip); transition: transform .06s, box-shadow .06s, filter .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: .45em; user-select: none; min-height: 44px; text-align: center;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--lip); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.btn.gold { --bg: var(--gold); --fg: var(--ink); --lip: var(--gold-deep); }
.btn.blue { --bg: var(--blue); --lip: #234f97; }
.btn.red { --bg: var(--red); --lip: #8f2a22; }
.btn.moss { --bg: var(--moss); --fg: var(--ink); --lip: #4f7a2a; }
.btn.ghost { --bg: transparent; --lip: transparent; border-color: var(--line); box-shadow: none; }
.btn.small { font-size: .85rem; padding: .35em .7em; min-height: 34px; border-radius: 10px; box-shadow: 0 3px 0 var(--lip); }
.btn.big { font-size: 1.25rem; padding: .7em 1.4em; }
.btn.wide { width: 100%; }
.btn .cost { font-weight: 800; }
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .1em .55em; border-radius: 999px; background: var(--enamel-2); border: 1.5px solid var(--line); font-weight: 700; font-size: .85rem; }
.coin { color: var(--gold); }
.muted { color: var(--muted); }
.gold-text { color: var(--gold); }

/* ---------- panels / plaques ---------- */
.plaque { background: var(--enamel); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: inset 0 0 0 2px var(--line), 0 6px 0 #0d1128; padding: 1rem; }
.plaque.trim { box-shadow: inset 0 0 0 2px var(--gold-deep), 0 6px 0 #0d1128; }

/* ---------- screens ---------- */
#screen { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background:
  radial-gradient(1200px 600px at 50% -10%, #2b3473 0%, transparent 60%),
  linear-gradient(#171c3d, #10142e); }
#screen:empty { display: none; }
.screen-inner { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem calc(2rem + var(--safe-b)); }
.screen-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.screen-head h2 { margin: 0; font-size: 1.6rem; font-weight: 800; flex: 1; }
.grid { display: grid; gap: .9rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
h3 { margin: 0 0 .5rem; font-size: 1.15rem; }
p { margin: .3rem 0 .6rem; line-height: 1.45; }

/* Home */
.home { min-height: 100%; display: grid; place-items: center; padding: 1.5rem 1rem calc(2rem + var(--safe-b)); }
.home-wrap { width: min(980px, 100%); display: grid; gap: 1.1rem; }
.logo { text-align: center; }
.logo h1 { font-family: var(--display); font-weight: 800; font-size: clamp(3rem, 10vw, 6rem); line-height: .9; margin: 0; color: var(--gold); text-shadow: 0 4px 0 var(--ink), 0 0 40px rgba(242,179,61,.25); letter-spacing: .01em; }
.logo .sub { color: var(--muted); font-size: 1.05rem; margin-top: .4rem; }
.logo canvas { display: block; margin: 0 auto -.5rem; }
.home-main { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .home-main { grid-template-columns: 1fr; } }
.play-card { display: grid; gap: .7rem; }
.play-card .btn.big { min-height: 64px; font-size: 1.4rem; }
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; align-content: start; }
.btn.tile { text-align: left; display: grid; gap: .1rem; align-content: start; justify-items: start; justify-content: stretch; padding: .8rem .9rem; min-height: 86px; }
.tile .t-title { font-size: 1.1rem; font-weight: 800; }
.tile .t-sub { font-size: .85rem; color: var(--muted); font-weight: 600; }
.badge { background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font-size: .75rem; padding: 0 .45em; font-weight: 800; }
.daily { display: grid; gap: .3rem; }
.siege-mini .bar { margin-top: .35rem; }
.rival { font-size: .95rem; }

/* Bars */
.bar { position: relative; height: 14px; background: #3a1e26; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--red); border-radius: 999px; transition: width .25s; }
.bar.gold > i { background: var(--gold); }
.bar.moss > i { background: var(--moss); }
.bar.blue > i { background: var(--blue); }

/* Setup */
.map-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.map-card { cursor: pointer; padding: .6rem; display: grid; gap: .35rem; text-align: left; color: var(--text); }
.map-card canvas { width: 100%; height: auto; border-radius: 8px; border: 2px solid var(--ink); background: #8cc152; }
.map-card.sel { box-shadow: inset 0 0 0 3px var(--gold), 0 6px 0 #0d1128; }
.map-card.locked { opacity: .55; cursor: not-allowed; }
.map-card .best { font-size: .85rem; color: var(--muted); }
.opt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .55rem; }
.opt { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center; padding: .55rem .7rem; border-radius: 12px; border: 2px solid var(--line); background: var(--enamel-2); cursor: pointer; text-align: left; color: var(--text); font: inherit; }
.opt[aria-pressed="true"] { border-color: var(--gold); background: #33305a; }
.field + .opt, .opt + .opt, label + .opt { margin-top: .4rem; }
.opt-list .opt { margin-top: 0; }
.opt .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--ink); background: var(--enamel-3); display: grid; place-items: center; font-weight: 800; color: var(--ink); }
.opt[aria-pressed="true"] .box { background: var(--gold); }
.opt small { color: var(--muted); display: block; line-height: 1.25; }
.stepper { display: inline-flex; align-items: center; gap: .5rem; }
.stepper output { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.3rem; }
.weapon-row { display: flex; gap: .55rem; flex-wrap: wrap; }
.setup-foot { position: sticky; bottom: 0; padding: .8rem 0 calc(.8rem + var(--safe-b)); background: linear-gradient(transparent, #10142e 30%); display: flex; gap: .7rem; align-items: center; }

/* ---------- in-game ---------- */
#game-view { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
#hud { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; background: var(--enamel); border-bottom: 2px solid var(--ink); box-shadow: inset 0 -2px 0 var(--line); flex-wrap: wrap; z-index: 3; }
.hud-wave { display: flex; align-items: baseline; gap: .35rem; }
.hud-wave b { font-family: var(--display); font-size: 1.6rem; color: var(--gold); line-height: 1; }
.hud-wave span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.hud-bars { display: grid; grid-template-columns: auto 1fr; gap: 2px .4rem; align-items: center; min-width: 140px; flex: 1; max-width: 260px; font-size: .75rem; font-weight: 800; color: var(--muted); }
.hud-bars .bar { height: 11px; }
.hud-stat { display: flex; align-items: center; gap: .25rem; font-weight: 800; font-size: 1.05rem; padding: .1rem .55rem; border-radius: 10px; background: var(--enamel-2); border: 2px solid var(--ink); }
.hud-stat.gold { color: var(--gold); }
.hud-stat .lbl { font-size: .7rem; color: var(--muted); font-weight: 700; }
.hud-right { margin-left: auto; display: flex; gap: .4rem; align-items: center; }
.hud-flash { animation: flash .35s; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--red); } 100% { box-shadow: 0 0 0 0 transparent; } }

#board-wrap { position: relative; overflow: hidden; touch-action: none; background: #10142e; }
#board { position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair; }
#board-overlay { position: absolute; inset: 0; pointer-events: none; }
.next-chip { position: absolute; top: .5rem; right: .5rem; pointer-events: auto; display: flex; gap: .3rem; align-items: center; padding: .25rem .45rem; background: rgba(27,33,64,.88); border: 2px solid var(--ink); border-radius: 12px; max-width: calc(100% - 1rem); flex-wrap: wrap; }
.next-chip .lbl { font-size: .75rem; color: var(--muted); font-weight: 800; }
.next-chip .ico { display: inline-flex; align-items: center; font-weight: 800; font-size: .8rem; }
.next-chip .warn { color: #ffd0c8; background: var(--red); border-radius: 8px; padding: 0 .35rem; font-size: .75rem; font-weight: 800; border: 2px solid var(--ink); }
.hero-hud { position: absolute; left: 50%; bottom: .5rem; transform: translateX(-50%); display: flex; gap: .5rem; align-items: center; pointer-events: none; }
.ammo { display: flex; gap: 3px; padding: .25rem .4rem; background: rgba(27,33,64,.85); border: 2px solid var(--ink); border-radius: 10px; }
.ammo i { width: 7px; height: 18px; border-radius: 3px; background: var(--gold); border: 1.5px solid var(--ink); }
.ammo i.off { background: #3b416a; }
.ammo i.loading { background: linear-gradient(to top, var(--gold) var(--p), #3b416a var(--p)); }
.combo { font-weight: 800; font-size: 1.1rem; padding: .1rem .6rem; border-radius: 10px; background: rgba(27,33,64,.85); border: 2px solid var(--ink); color: var(--gold); transition: transform .1s; }
.combo.pop { transform: scale(1.25); }
.combo.dead { color: var(--muted); }
.hazard-chip { position: absolute; left: .5rem; bottom: .5rem; background: rgba(27,33,64,.88); border: 2px solid var(--ink); border-radius: 10px; padding: .15rem .5rem; font-weight: 800; font-size: .85rem; }

#dock { display: flex; gap: .5rem; align-items: stretch; padding: .45rem .5rem calc(.45rem + var(--safe-b)); background: var(--enamel); border-top: 2px solid var(--ink); box-shadow: inset 0 2px 0 var(--line); z-index: 3; }
.tower-bar { display: flex; gap: .35rem; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: thin; padding-bottom: 2px; }
.tbtn { position: relative; flex: 0 0 auto; width: 64px; padding: .2rem .15rem .25rem; border-radius: 12px; border: 2px solid var(--ink); background: var(--enamel-2); color: var(--text); cursor: pointer; display: grid; justify-items: center; gap: 0; box-shadow: 0 3px 0 #0d1128; font: inherit; }
.tbtn canvas { width: 44px; height: 44px; }
.tbtn .c { font-size: .78rem; font-weight: 800; color: var(--gold); }
.tbtn .k { position: absolute; top: 2px; left: 5px; font-size: .65rem; color: var(--muted); font-weight: 800; }
.tbtn.sel { background: #3b3570; box-shadow: inset 0 0 0 2px var(--gold), 0 3px 0 #0d1128; }
.tbtn.poor .c { color: #ff8f84; }
.tbtn.locked { opacity: .5; }
.tbtn.locked .c { color: var(--muted); font-size: .68rem; }
.tbtn.new::after { content: "NEW"; position: absolute; top: -6px; right: -4px; background: var(--red); color: #fff; font-size: .6rem; font-weight: 800; border: 1.5px solid var(--ink); border-radius: 6px; padding: 0 3px; }
.dock-actions { display: flex; gap: .35rem; align-items: center; }
.start-btn { min-width: 132px; flex-direction: column; gap: 0; line-height: 1; }
.start-btn small { font-size: .72rem; font-weight: 700; opacity: .85; }

#panel { position: absolute; right: .6rem; top: 4.2rem; width: 300px; max-height: calc(100% - 9rem); overflow-y: auto; z-index: 4; }
#panel .plaque { padding: .8rem; }
.panel-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.panel-head h3 { margin: 0; flex: 1; font-size: 1.1rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .8rem; font-size: .88rem; margin: .4rem 0 .6rem; }
.stat-grid div { display: flex; justify-content: space-between; gap: .4rem; }
.stat-grid b { color: var(--text); }
.stat-grid span { color: var(--muted); }
.seg { display: flex; gap: 3px; background: var(--enamel-2); border: 2px solid var(--ink); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font: 700 .8rem var(--font); padding: .3rem .2rem; border-radius: 7px; cursor: pointer; min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--ink); }
.spec-choice { display: grid; gap: .45rem; margin: .5rem 0; }
.spec-choice .btn { flex-direction: column; align-items: flex-start; text-align: left; gap: .15rem; }
.spec-choice .btn small { font-weight: 600; opacity: .85; font-size: .8rem; }
.section-label { font-size: .8rem; color: var(--muted); font-weight: 800; margin: .7rem 0 .3rem; }
.armory-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.armory-row small { display: block; color: var(--muted); font-size: .78rem; }

@media (max-width: 700px), (orientation: portrait) {
  #panel { left: .4rem; right: .4rem; width: auto; top: auto; bottom: calc(5.4rem + var(--safe-b)); max-height: 52%; }
  .hud-bars { min-width: 110px; }
  .hud-stat { font-size: .95rem; }
  .start-btn { min-width: 104px; flex: 1; }
  .tbtn { width: 56px; }
  #dock { flex-wrap: wrap; gap: .35rem; }
  .tower-bar { flex: 1 0 100%; }
  .dock-actions { flex: 1 0 100%; }
  .dock-actions .btn { min-height: 40px; }
  #panel { bottom: calc(8.6rem + var(--safe-b)); }
}
@media (orientation: portrait) {
  .hero-hud { top: .5rem; bottom: auto; left: .5rem; transform: none; }
  .next-chip { top: 3rem; }
}

/* Wave banner — the showpiece */
#wave-banner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); pointer-events: none; z-index: 2; }
.pennant { position: relative; min-width: 300px; padding: .5rem 2.6rem .9rem; text-align: center; color: var(--ink);
  background: linear-gradient(#f4c55a, #e5a628); border: 3px solid var(--ink);
  clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 50% 88%, 0 100%, 4% 50%);
  transform-origin: top center; animation: unfurl .55s cubic-bezier(.2,1.4,.4,1) both; filter: drop-shadow(0 6px 0 rgba(13,17,40,.6)); }
.pennant.boss { background: linear-gradient(#e2574b, #a8281f); color: #fff; }
.pennant.clear { background: linear-gradient(#a5d36d, #6ea43c); }
.pennant .t { font-family: var(--display); font-weight: 800; font-size: 3rem; line-height: 1; }
.pennant .s { font-weight: 800; font-size: 1rem; margin-top: .15rem; }
.pennant.out { animation: rollup .4s ease-in both; }
@keyframes unfurl { from { transform: scaleY(0) rotate(-2deg); opacity: 0; } to { transform: scaleY(1) rotate(0); opacity: 1; } }
@keyframes rollup { to { transform: scaleY(0); opacity: 0; } }

/* Toasts */
#toasts { position: fixed; bottom: calc(1rem + var(--safe-b)); left: 50%; transform: translateX(-50%); display: grid; gap: .4rem; z-index: 50; pointer-events: none; width: min(420px, 92vw); }
.toast { background: var(--enamel); border: 2px solid var(--ink); border-radius: 12px; box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 #0d1128; padding: .5rem .8rem; font-weight: 700; animation: toastin .25s ease-out both; display: flex; gap: .6rem; align-items: center; }
.toast.ach { box-shadow: inset 0 0 0 2px var(--gold), 0 4px 0 #0d1128; }
.toast.ach .ic { font-size: 1.5rem; }
.toast.out { animation: toastout .3s ease-in both; }
#app:has(#game-view:not([hidden])) #toasts { top: 4.6rem; bottom: auto; left: .8rem; transform: none; }
@keyframes toastin { from { transform: translateY(-12px); opacity: 0; } }
@keyframes toastout { to { transform: translateY(-12px); opacity: 0; } }

/* Modals */
#modal-root:empty { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(10,12,30,.7); display: grid; place-items: center; z-index: 40; padding: 1rem; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; }
.modal.wide { width: min(860px, 100%); }
.modal h2 { margin: 0 0 .4rem; }
.boons { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; margin: .8rem 0; }
.boon { text-align: left; display: grid; gap: .3rem; align-content: start; padding: .9rem; min-height: 150px; cursor: pointer; border-radius: 14px; border: 2px solid var(--ink); background: var(--enamel-2); color: var(--text); box-shadow: inset 0 0 0 3px var(--rc), 0 5px 0 #0d1128; font: inherit; transition: transform .12s; animation: dealt .35s both; }
.boon:hover { transform: translateY(-4px); }
.boon .r { font-size: .72rem; font-weight: 800; color: var(--rc); }
.boon .n { font-size: 1.15rem; font-weight: 800; }
.boon .d { color: var(--muted); font-size: .92rem; line-height: 1.3; }
.boon .stk { font-size: .78rem; color: var(--gold); font-weight: 700; }
.boon.common { --rc: var(--common); } .boon.rare { --rc: var(--rare); } .boon.epic { --rc: var(--epic); }
@keyframes dealt { from { transform: translateY(30px) rotate(-3deg); opacity: 0; } }

/* Summary */
.summary-head { text-align: center; }
.summary-head .big { font-family: var(--display); font-size: 3.4rem; color: var(--gold); line-height: 1; text-shadow: 0 3px 0 var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin: .8rem 0; }
.kpi { background: var(--enamel-2); border: 2px solid var(--ink); border-radius: 12px; padding: .5rem .7rem; }
.kpi b { display: block; font-size: 1.4rem; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.highlights { display: grid; gap: .35rem; margin: .6rem 0; }
.highlights div { background: var(--enamel-2); border-left: 4px solid var(--gold); border-radius: 8px; padding: .4rem .6rem; font-weight: 600; }
.records { color: var(--gold); font-weight: 800; }

/* Keep */
.keep-branch h3 { display: flex; align-items: center; gap: .5rem; }
.keep-node { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.keep-node:last-child { border-bottom: 0; }
.keep-node .pips { display: flex; gap: 3px; margin-top: .2rem; }
.keep-node .pips i { width: 14px; height: 6px; border-radius: 3px; background: #3b416a; border: 1px solid var(--ink); }
.keep-node .pips i.on { background: var(--gold); }
.renown { font-weight: 800; color: var(--gold); font-size: 1.2rem; }

/* Lists / tables */
.list { display: grid; gap: .35rem; }
.lrow { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .6rem; align-items: center; padding: .45rem .6rem; background: var(--enamel-2); border: 2px solid var(--ink); border-radius: 10px; }
.lrow.me { box-shadow: inset 0 0 0 2px var(--gold); }
.lrow .rank { font-weight: 800; text-align: center; color: var(--muted); }
.lrow .rank.top { color: var(--gold); }
.lrow .who small { display: block; color: var(--muted); font-size: .78rem; }
.lrow .val { font-weight: 800; }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button[aria-selected="true"] { --bg: var(--gold); --fg: var(--ink); --lip: var(--gold-deep); }
.empty { text-align: center; color: var(--muted); padding: 1.2rem; }
input[type="text"], input[type="search"], textarea { font: 600 1rem var(--font); padding: .55rem .7rem; border-radius: 10px; border: 2px solid var(--ink); background: #10142e; color: var(--text); min-height: 44px; }
textarea { width: 100%; min-height: 90px; }
input[type="range"] { width: 100%; accent-color: var(--gold); }
label.field { display: grid; gap: .25rem; font-weight: 700; margin-bottom: .6rem; }
.code { font: 800 1.3rem/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; color: var(--gold); }

/* Achievements & bestiary */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.ach { display: grid; grid-template-columns: 40px 1fr; gap: .6rem; align-items: center; padding: .55rem; border-radius: 12px; border: 2px solid var(--ink); background: var(--enamel-2); }
.ach .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.3rem; background: #2a2f55; border: 2px solid var(--ink); }
.ach.got .ic { background: var(--gold); }
.ach:not(.got) { opacity: .6; }
.ach b { display: block; }
.ach small { color: var(--muted); display: block; line-height: 1.25; }
.ach .rw { color: var(--gold); font-size: .75rem; font-weight: 700; }
.beast { display: grid; justify-items: center; gap: .2rem; padding: .6rem; text-align: center; }
.beast canvas { width: 72px; height: 72px; }
.chart-box canvas { width: 100%; height: 180px; display: block; }
.hbar { display: grid; grid-template-columns: 7.5rem 1fr 4rem; gap: .5rem; align-items: center; font-size: .88rem; margin-bottom: .25rem; }
.hbar .bar { height: 12px; }
.cos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }

/* Tutorial */
.tut { position: fixed; z-index: 30; max-width: 300px; pointer-events: none; }
.tut button { pointer-events: auto; }
.tut.passive .row { display: none; }
.tut.passive .plaque { opacity: .92; }
.tut .plaque { padding: .7rem .8rem; box-shadow: inset 0 0 0 2px var(--gold), 0 6px 0 #0d1128; }
.tut p { margin: 0 0 .5rem; font-weight: 600; }
.tut-pulse { position: fixed; border: 3px solid var(--gold); border-radius: 12px; pointer-events: none; animation: pulse 1s infinite; z-index: 29; }
@keyframes pulse { 50% { transform: scale(1.12); opacity: .5; } }

/* ---------- The Realm ---------- */
.realm-mini { display: grid; gap: .3rem; text-align: left; color: var(--text); font: inherit; cursor: pointer; width: 100%; }
.realm-mini:hover { filter: brightness(1.08); }
.rmini-row { display: grid; grid-template-columns: 8.5rem 1fr 3rem; gap: .5rem; align-items: center; font-size: .85rem; font-weight: 700; }
.rmini-row b { text-align: right; }
.realm-head { display: grid; gap: .4rem; }
.realm-card { display: grid; gap: .45rem; align-content: start; }
.realm-card.won { box-shadow: inset 0 0 0 3px var(--gold), 0 6px 0 #0d1128; }
.rpct { font-family: var(--display); font-size: 1.7rem; color: var(--gold); line-height: 1; }
.rmeter { display: grid; gap: .15rem; font-size: .88rem; }
.rtrack { position: relative; height: 34px; margin: .3rem .9rem 0; }
.rbar { position: absolute; left: 0; right: 0; top: 12px; height: 10px; border-radius: 999px; background: #3b416a; border: 2px solid var(--ink); overflow: hidden; }
.rbar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--blue), var(--gold)); transition: width .6s; }
.rmark { position: absolute; top: 2px; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--enamel-2); border: 2px solid var(--ink); font-size: .85rem; filter: grayscale(1) brightness(.7); }
.rmark.hit { filter: none; background: var(--gold); animation: pop .5s; }
@keyframes pop { 50% { transform: translateX(-50%) scale(1.35); } }
.rtiers { display: grid; gap: .25rem; }
.rtier { display: grid; grid-template-columns: 1.8rem 1fr auto; align-items: center; gap: .4rem; padding: .25rem .45rem; border-radius: 9px; background: var(--enamel-2); border: 2px solid var(--ink); opacity: .6; }
.rtier.hit { opacity: 1; box-shadow: inset 0 0 0 2px var(--moss); }
.rtier.claimed { opacity: .75; }
.rtier small { display: block; color: var(--muted); font-size: .76rem; line-height: 1.2; }
.rtier .rw { font-weight: 800; color: var(--gold); font-size: .85rem; }
.rshare { font-size: .88rem; }
.rrow .who .bar { height: 7px; margin-top: .2rem; border-width: 1.5px; }
.rme { background: var(--enamel-2); border-left: 4px solid var(--gold); border-radius: 8px; padding: .4rem .6rem; font-weight: 700; margin-bottom: .5rem; }
.rgain { margin: .8rem 0; text-align: left; display: grid; gap: .4rem; color: var(--text); }
.rgain-row { display: grid; grid-template-columns: 5.5rem 1fr 6.5rem; gap: .5rem; align-items: center; font-size: .88rem; font-weight: 700; }
.rgain-row b { text-align: right; font-size: .85rem; }
.rgain-tier { background: var(--enamel-2); border-left: 4px solid var(--gold); border-radius: 8px; padding: .4rem .6rem; font-weight: 700; animation: toastin .4s both; }
.online-box { text-align: center; }
.btn.pulse { animation: glow 1.4s infinite; }
@keyframes glow { 50% { box-shadow: 0 4px 0 var(--lip), 0 0 18px 4px rgba(242,179,61,.55); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
[data-reduced-motion="true"] *, [data-reduced-motion="true"] *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; }

/* kill-streak announcer */
.streak-pop{position:absolute;left:50%;top:22%;transform:translateX(-50%);font:800 clamp(22px,5vw,38px) "Baloo 2",system-ui;color:#ffd25e;
  -webkit-text-stroke:2px #1e2433;paint-order:stroke fill;text-shadow:0 4px 0 #1e2433;pointer-events:none;animation:streakPop 1.2s ease-out forwards;z-index:5;white-space:nowrap}
@keyframes streakPop{0%{transform:translateX(-50%) scale(.4);opacity:0}15%{transform:translateX(-50%) scale(1.25);opacity:1}30%{transform:translateX(-50%) scale(1)}85%{opacity:1}100%{transform:translateX(-50%) translateY(-30px) scale(1);opacity:0}}
@media (prefers-reduced-motion:reduce){.streak-pop{animation-duration:.01s;animation-fill-mode:forwards}}

.quest-card .qrow{margin-top:.45rem;font-size:.9rem}
.quest-card .qrow.done{opacity:.6}
