/* Horde of the Dead — cartoon siege.
   Ink-black outlines and hard offset shadows everywhere, so the UI matches Malachar.
   Torch orange = you and your actions. Bile green = the horde. */
:root {
  --night: #0d0f12;
  --night-2: #15181c;
  --panel: #1d2126;
  --ink: #140f12;
  --bone: #f1ead6;
  --ash: #a7aca5;
  --torch: #f08a24;
  --torch-hi: #ffa84a;
  --bile: #c6d84a;
  --rot: #6f8f58;
  --blood: #c9463a;

  --gothic: "Grenze Gotisch", "UnifrakturMaguntia", Georgia, serif;
  --head: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;

  --s1: .5rem; --s2: 1rem; --s3: 1.5rem; --s4: 2.5rem; --s5: 4rem; --s6: 6.5rem;
  --pop: 5px 5px 0 #000;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--night); color: var(--bone); scroll-behavior: smooth; }
body { margin: 0; font: 400 1.0625rem/1.6 var(--body); }
a { color: var(--torch-hi); text-underline-offset: .2em; }
a:hover { color: var(--bone); }
:focus-visible { outline: 3px solid var(--torch-hi); outline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; margin: 0 0 var(--s2); }
p { margin: 0 0 var(--s2); }
.muted { color: var(--ash); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--s2); top: var(--s2); z-index: 10; background: var(--bone); color: var(--night); padding: .5rem 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; font: 800 1.1rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em;
  text-decoration: none; cursor: pointer; padding: 1rem 1.6rem;
  border: 3px solid var(--ink); border-radius: 6px; box-shadow: var(--pop);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 #000; }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #000; }
.btn-torch { background: var(--torch); color: var(--ink); }
.btn-torch:hover { background: var(--torch-hi); color: var(--ink); }
.btn-ghost { background: var(--bone); color: var(--ink); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: var(--blood); color: var(--bone); }
.btn-danger:hover { color: var(--bone); }
.btn-small { padding: .6rem 1rem; font-size: .95rem; box-shadow: 3px 3px 0 #000; }
.cta-row { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: center; margin-top: var(--s3); }

/* ---------- Nav ---------- */
.navbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--s4);
  padding: .8rem clamp(var(--s2), 4vw, var(--s4));
  background: #000; border-bottom: 3px solid var(--ink);
}
.nav-brand, .foot-brand { font: 900 1.6rem/1 var(--gothic); color: var(--bone); text-decoration: none; }
.nav-brand span, .foot-brand span { font-size: .7em; color: var(--bile); }
.nav-links { display: flex; gap: var(--s3); flex: 1; }
.nav-links a, .nav-link { font: 700 1rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--ash); text-decoration: none; }
.nav-links a:hover, .nav-link:hover { color: var(--bone); }
.nav-actions { display: flex; gap: var(--s3); align-items: center; margin-left: auto; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: min(88svh, 900px);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: var(--s4) var(--s2) var(--s3);
}
.sky { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.malachar {
  width: min(78vw, 560px); height: auto; overflow: visible;
  margin-bottom: auto; margin-top: 1vh;
  animation: hover 6s ease-in-out infinite;
}
@keyframes hover { 50% { transform: translateY(-14px); } }

/* Tendrils sway around their roots (origins are root points measured from the viewBox corner) */
.malachar .tendril { transform-box: view-box; animation: sway 5s ease-in-out infinite; }
.malachar .tendril-0 { transform-origin: 150px 380px; animation-delay: -.6s; }
.malachar .tendril-1 { transform-origin: 140px 300px; animation-delay: -2.1s; animation-duration: 5.8s; }
.malachar .tendril-2 { transform-origin: 160px 220px; animation-delay: -3.3s; }
.malachar .tendril-3 { transform-origin: 225px 170px; animation-delay: -1.2s; animation-duration: 6.2s; }
.malachar .tendril-4 { transform-origin: 375px 170px; animation-delay: -4s; animation-duration: 5.6s; }
.malachar .tendril-5 { transform-origin: 440px 220px; animation-delay: -.3s; }
.malachar .tendril-6 { transform-origin: 460px 300px; animation-delay: -2.7s; animation-duration: 6s; }
.malachar .tendril-7 { transform-origin: 450px 380px; animation-delay: -1.6s; }
@keyframes sway { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

/* Purple lightning in the sky behind the town (bolts are drawn by storm.js) */
.storm path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.storm .bolt-glow { stroke: #9b6bd6; stroke-width: 22; opacity: .45; }
.storm .bolt-mid  { stroke: #b58ef0; stroke-width: 9; }
.storm .bolt-core { stroke: #f3eaff; stroke-width: 3.5; }

/* Spirits rise out of it and fade */
.malachar .ghost { animation: rise 7s ease-in infinite; opacity: 0; }
.malachar .ghost-1 { animation-delay: -1.5s; animation-duration: 8s; }
.malachar .ghost-2 { animation-delay: -3s; }
.malachar .ghost-3 { animation-delay: -4.6s; animation-duration: 7.6s; }
.malachar .ghost-4 { animation-delay: -5.8s; animation-duration: 6.4s; }
@keyframes rise {
  0%   { transform: translate(0, 0); opacity: 0; }
  20%  { opacity: .9; }
  60%  { transform: translate(-12px, -90px); opacity: .7; }
  100% { transform: translate(10px, -170px); opacity: 0; }
}

/* Jaw: snaps open with a little overshoot, eases shut */
.malachar .jaw { transition: transform .32s cubic-bezier(.4,0,.6,1); }
.malachar.is-roaring .jaw { transform: translateY(68px); transition: transform .22s cubic-bezier(.3,1.6,.5,1); }
.malachar .throat { opacity: 0; transition: opacity .25s; }
.malachar.is-roaring .throat { opacity: 1; animation: throb .5s ease-in-out infinite alternate; }
@keyframes throb { to { opacity: .6; } }
.malachar .skull-eyes { transition: opacity .2s; opacity: .55; }
.malachar.is-roaring .skull-eyes { opacity: 1; }
.malachar.is-roaring .aura { animation: flare .6s ease-out; }
@keyframes flare { 40% { opacity: 1.6; transform: scale(1.06); } }
.malachar .aura { transform-box: fill-box; transform-origin: center; }
.malachar { cursor: pointer; }

.logo-lockup { text-align: center; position: relative; margin-top: calc(-1 * var(--s4)); }
.logo {
  font: 900 clamp(3.4rem, 10vw, 7.5rem)/.9 var(--gothic); text-transform: none; letter-spacing: 0;
  color: var(--bone); margin: 0;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 6px 6px 0 #000, 0 0 40px #c6d84a55;
}
.logo-of { display: inline-block; font-size: .5em; color: var(--bile); vertical-align: middle; margin: 0 .1em; }
.logo-ribbon {
  display: inline-block; margin: var(--s2) 0 0; padding: .45rem 1.4rem;
  font: 800 1.05rem/1 var(--head); text-transform: uppercase; letter-spacing: .2em;
  background: var(--blood); color: var(--bone); border: 3px solid var(--ink); box-shadow: 4px 4px 0 #000;
  transform: rotate(-2deg);
}

/* ---------- CTA band ---------- */
.cta-band { text-align: center; padding: var(--s5) var(--s2); background: var(--night); border-top: 3px solid #000; }
.cta-band h2 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0; }
.note { max-width: 44rem; margin: var(--s3) auto 0; font-size: .95rem; color: var(--ash); }

/* ---------- Features (alternating rows) ---------- */
.features { padding: var(--s6) clamp(var(--s2), 6vw, 8rem); background: var(--night-2); }
.section-title { text-align: center; font-size: clamp(2rem, 5.5vw, 3.8rem); margin-bottom: var(--s6); }
.section-title span { color: var(--bile); }
.feature { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(var(--s4), 6vw, var(--s6)); align-items: center; max-width: 72rem; margin: 0 auto var(--s6); }
.feature:last-child { margin-bottom: 0; }
.feature-flip .feature-art { order: 2; }
.feature-copy h3 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); color: var(--torch); }
.feature-copy p { color: var(--bone); max-width: 32rem; }
.feature-art { display: flex; justify-content: center; }

.panel-mock {
  width: min(100%, 26rem); background: var(--panel); border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 8px 8px 0 #000; padding: var(--s3); transform: rotate(-1.5deg);
}
.feature-flip .panel-mock { transform: rotate(1.5deg); }
.mock-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s1); font: 800 1.35rem/1 var(--head); text-transform: uppercase; margin-bottom: var(--s2); }
.chip { font: 700 .8rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; padding: .35rem .6rem; border: 2px solid var(--ink); border-radius: 99px; background: var(--bone); color: var(--ink); white-space: nowrap; }
.chip-phase { background: var(--bile); }
.chip-boss { background: var(--blood); color: var(--bone); }
.mock-list, .party { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: .5rem; }
.mock-list li, .party li { background: var(--night-2); border: 2px solid #000; border-radius: 8px; padding: .55rem .8rem; }
.mock-list b { color: var(--torch); font-family: var(--head); font-size: 1.1rem; margin-right: .3rem; }
.mock-list .corrupt { border-color: var(--bile); color: var(--bile); }
.mock-foot { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .95rem; margin-bottom: var(--s2); }
.hp { flex: 1; min-width: 5rem; height: .7rem; background: #000; border-radius: 99px; overflow: hidden; }
.hp i { display: block; height: 100%; background: var(--blood); }
.hp-34 { width: 34%; }
.mock-btns { display: flex; gap: .6rem; }
.mbtn { font: 800 .9rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; padding: .6rem .9rem; border: 2px solid var(--ink); border-radius: 6px; background: var(--bone); color: var(--ink); box-shadow: 3px 3px 0 #000; }
.mbtn-torch { background: var(--torch); }
.party li { display: flex; align-items: center; gap: .7rem; }
.party small { margin-left: auto; color: var(--ash); }
.party .waiting { color: var(--torch); }
.avatar { width: 2rem; height: 2rem; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; font: 800 1rem/1 var(--head); color: var(--ink); }
.av1 { background: var(--torch); } .av2 { background: var(--bile); } .av3 { background: #7fb3d5; } .av4 { background: var(--ash); }

.round-track { list-style: none; padding: var(--s3); margin: 0; display: grid; gap: var(--s2); width: min(100%, 28rem);
  background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 8px 8px 0 #000; transform: rotate(1.5deg); }
.phase-name { display: block; font: 700 .95rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--ash); margin-bottom: .4rem; }
.cells { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell { aspect-ratio: 1.3; display: grid; place-items: center; font: 800 1.05rem/1 var(--head); color: var(--bone); background: var(--night-2); border: 2px solid #000; border-radius: 6px; }
.cell-boss { background: var(--blood); }
.cell-final { background: var(--bile); color: var(--ink); }
.legend { font-size: .95rem; color: var(--ash); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.key { width: 1rem; height: 1rem; display: inline-block; border: 2px solid #000; border-radius: 3px; }
.key-boss { background: var(--blood); } .key-final { background: var(--bile); margin-left: var(--s2); }

/* ---------- Access steps ---------- */
.access { padding: var(--s6) clamp(var(--s2), 6vw, 8rem); text-align: center; background: var(--night); border-top: 3px solid #000; }
.access .section-title { margin-bottom: var(--s5); }
.steps { list-style: none; padding: 0; margin: 0 auto; max-width: 72rem; display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s3); text-align: left; }
.steps li { background: var(--panel); border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--pop); padding: var(--s3) var(--s2) var(--s2); position: relative; }
.steps b { font-family: var(--head); text-transform: uppercase; font-size: 1.15rem; color: var(--torch); letter-spacing: .04em; }
.step-n { position: absolute; top: -1.1rem; left: var(--s2); width: 2.2rem; height: 2.2rem; display: grid; place-items: center;
  background: var(--bile); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%; font: 800 1.1rem/1 var(--head); }
.access .cta-row { margin-top: var(--s5); }

/* ---------- Footer ---------- */
.site-foot { background: #000; padding: var(--s5) clamp(var(--s2), 6vw, 8rem) var(--s4); border-top: 3px solid var(--ink); }
.foot-cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--s4); max-width: 72rem; margin: 0 auto var(--s4); }
.foot-cols h4 { font-size: 1rem; letter-spacing: .12em; color: var(--ash); }
.foot-cols a { display: block; color: var(--bone); text-decoration: none; margin-bottom: .4rem; }
.foot-cols a:hover { color: var(--torch-hi); }
.site-foot .fine { max-width: 72rem; margin: 0 auto; font-size: .85rem; color: #6f746e; border-top: 1px solid #22262b; padding-top: var(--s3); }

/* ---------- App pages (login, DM, admin) ---------- */
body.app, body.auth { min-height: 100svh; background: radial-gradient(ellipse 80% 50% at 50% 0%, #1f2a24, var(--night) 70%); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: .8rem clamp(var(--s2), 4vw, var(--s4)); background: #000; border-bottom: 3px solid var(--ink); gap: var(--s2); }
.wordmark { font: 900 1.6rem/1 var(--gothic); color: var(--bone); text-decoration: none; }
.topbar nav { display: flex; gap: var(--s3); align-items: center; }
.topbar nav a, .linkish { font: 700 1rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--ash); text-decoration: none; }
.topbar nav a:hover, .linkish:hover { color: var(--bone); }
.inline { display: inline; margin: 0; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; }

.sheet { width: min(100% - 2rem, 58rem); margin: var(--s4) auto var(--s6); }
body.auth .sheet { width: min(100% - 2rem, 28rem); margin-top: var(--s5); background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 8px 8px 0 #000; padding: var(--s4) var(--s3); }
.sheet h1 { font-size: clamp(2.2rem, 5vw, 3rem); }
.sheet .cta-row { justify-content: flex-start; }
.sheet h3 { font-size: 1.2rem; color: var(--ash); margin-top: var(--s3); }

.flash { padding: .8rem 1rem; border: 2px solid #000; border-left-width: 6px; border-radius: 6px; background: var(--night-2); }
.flash-error { border-left-color: var(--blood); }
.flash-ok { border-left-color: var(--bile); }
.flash-info { border-left-color: var(--torch); }

form.stack { display: grid; gap: var(--s2); margin-top: var(--s3); }
label { display: grid; gap: .35rem; font-weight: 500; }
label small { font-weight: 400; color: var(--ash); }
input[type=email], input[type=password], input[type=text], textarea, input[type=file] {
  font: inherit; color: var(--bone); background: var(--night); width: 100%;
  border: 2px solid #000; border-radius: 6px; padding: .7rem .8rem;
}
textarea { min-height: 9rem; resize: vertical; font-size: .95rem; }
input:focus, textarea:focus { border-color: var(--torch); outline: none; box-shadow: 0 0 0 3px #f08a2440; }
.form-foot { font-size: .95rem; color: var(--ash); margin-top: var(--s3); }
.or { text-align: center; color: var(--ash); font: 700 .9rem/1 var(--head); text-transform: uppercase; letter-spacing: .15em; }

.status { display: inline-block; font: 700 .85rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; padding: .3rem .6rem; border: 2px solid #000; border-radius: 99px; background: var(--ash); color: var(--ink); }
.status-pending, .status-pending_review { background: var(--torch); }
.status-approved { background: var(--bile); }
.status-rejected { background: var(--blood); color: var(--bone); }

.panel { background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--pop); padding: var(--s3); margin-top: var(--s4); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .97rem; }
th { text-align: left; font: 700 .9rem/1.2 var(--head); text-transform: uppercase; letter-spacing: .06em; color: var(--ash); border-bottom: 2px solid #000; padding: .5rem .6rem; }
td { border-bottom: 1px solid #2c3137; padding: .7rem .6rem; vertical-align: top; }
td form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: start; margin: 0; }
td input[type=text] { min-width: 10rem; padding: .45rem .6rem; }
.receipt { white-space: pre-wrap; max-height: 8rem; overflow: auto; font-size: .85rem; color: var(--ash); background: var(--night); padding: .5rem; margin: .4rem 0 0; border-radius: 4px; }
.copy-link { font-size: .9rem; word-break: break-all; background: var(--night); padding: .6rem .8rem; border-left: 4px solid var(--torch); border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr 1fr; row-gap: var(--s4); }
  .foot-cols { grid-template-columns: 1fr 1fr; }
  .foot-cols > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .nav-links { display: none; }
  .navbar { gap: var(--s2); }
  .feature { grid-template-columns: 1fr; gap: var(--s4); }
  .feature-flip .feature-art { order: 0; }
  .features, .access { padding-block: var(--s5); }
  .section-title { margin-bottom: var(--s5); }
  .malachar { width: 92vw; }
}
@media (max-width: 480px) { .steps { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .malachar, .malachar .tendril, .malachar .ghost { animation: none; }
  .malachar .ghost { opacity: .6; }
  .malachar .jaw { transition: none !important; }
  .btn { transition: none; }
}

@media (max-width: 480px) {
  .nav-brand { font-size: 1.3rem; white-space: nowrap; }
  .nav-actions { gap: var(--s2); }
  .hero { min-height: 0; padding-top: var(--s3); }
  .logo-lockup { margin-top: var(--s2); }
}

/* =====================================================================
   App v2: role nav, GM games, round tracker, kills, salvage, admin
   ===================================================================== */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wordmark span { font-size: .7em; color: var(--bile); }
body.wide .sheet { width: min(100% - 2rem, 76rem); }

/* ---------- Top bar ---------- */
.topbar { justify-content: flex-start; }
.app-nav { display: flex; gap: .3rem; margin-left: var(--s3); }
.topbar .app-nav a { padding: .5rem .8rem; border: 2px solid transparent; border-radius: 6px; }
.topbar .app-nav a[aria-current] { color: var(--ink); background: var(--bone); border-color: var(--ink); box-shadow: 3px 3px 0 #000; }
.topbar .who { margin-left: auto; }
.who-name { font: 600 1rem/1 var(--body); color: var(--bone); display: flex; align-items: center; gap: .5rem; }
.role-tag { font: 800 .75rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; padding: .25rem .45rem; border: 2px solid var(--ink); border-radius: 4px; background: var(--ash); color: var(--ink); }
.role-gm { background: var(--torch); }
.role-player { background: var(--bile); }
.role-superadmin { background: var(--blood); color: var(--bone); }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.page-head h1 { margin: 0; }
.page-head .muted { margin: .4rem 0 0; }
.crumb { margin: 0 0 .3rem; font: 700 .95rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; }
.crumb a { color: var(--ash); text-decoration: none; }
.crumb a::before { content: "\2039  "; }
.crumb a:hover { color: var(--bone); }
.new-game { display: flex; gap: .6rem; flex: 1 1 26rem; max-width: 34rem; }
.new-game input { flex: 1; }

.empty { text-align: center; padding: var(--s5) var(--s3); border: 3px dashed #2f353c; border-radius: 12px; }
.empty h2 { font-size: 1.8rem; color: var(--torch); }
.empty p { color: var(--ash); max-width: 32rem; margin-inline: auto; }

/* ---------- Status chips ---------- */
.chip-setup    { background: var(--ash); }
.chip-active   { background: var(--torch); }
.chip-victory  { background: var(--bile); }
.chip-defeat   { background: var(--blood); color: var(--bone); }
.chip-big { font-size: 1rem; padding: .5rem .9rem; box-shadow: 3px 3px 0 #000; }

/* ---------- Game cards ---------- */
.game-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: var(--s3); }
.game-card a {
  display: grid; gap: .8rem; height: 100%; padding: var(--s3); text-decoration: none; color: var(--bone);
  background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--pop);
  transition: transform .12s ease, box-shadow .12s ease;
}
.game-card a:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 #000; color: var(--bone); }
.game-card-name { font: 800 1.6rem/1.05 var(--head); text-transform: uppercase; }
.game-card .chip { justify-self: start; }
.game-card-stats { display: flex; gap: var(--s3); color: var(--ash); }
.game-card-stats b { color: var(--bone); font: 800 1.3rem/1 var(--head); }
.game-card-gm { font-size: .9rem; }

progress { appearance: none; width: 100%; height: .7rem; border: 2px solid #000; border-radius: 99px; background: #000; overflow: hidden; }
progress::-webkit-progress-bar { background: #000; }
progress::-webkit-progress-value { background: var(--torch); }
progress::-moz-progress-bar { background: var(--torch); }

/* ---------- Siege panel ---------- */
.panel { margin-top: var(--s3); }
.panel h2 { font-size: 1.7rem; }
.panel h2 small { font-size: .65em; color: var(--ash); letter-spacing: .04em; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.small-link { font-size: .9rem; }
.siege { margin-top: 0; }
.siege-now { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.siege-now p { margin: 0; }
.now-phase { font: 700 1rem/1 var(--head); text-transform: uppercase; letter-spacing: .1em; color: var(--ash); }
.now-round { font: 900 clamp(2.8rem, 7vw, 4.2rem)/1 var(--gothic); color: var(--bone); margin: .2rem 0 !important;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 #000; }
.now-round small { font: 700 1.2rem/1 var(--head); color: var(--ash); -webkit-text-stroke: 0; text-shadow: none; text-transform: uppercase; }
.now-kind { display: inline-block; font: 800 .95rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em;
  padding: .35rem .7rem; border: 2px solid var(--ink); border-radius: 4px; background: var(--night-2); color: var(--ash); }
.kind-boss .now-kind { background: var(--blood); color: var(--bone); transform: rotate(-2deg); }
.kind-final .now-kind { background: var(--bile); color: var(--ink); transform: rotate(-2deg); }
.kind-final .now-round { text-shadow: 4px 4px 0 #000, 0 0 30px #c6d84a66; }
.siege-controls { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.siege-controls form, .finish-row form { margin: 0; }
.finish-row { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin: var(--s3) 0 0; padding-top: var(--s2); border-top: 2px solid #000; }
.btn-bile { background: var(--bile); color: var(--ink); }
.btn-bile:hover { color: var(--ink); }

.round-strip { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.round-strip .cell { text-decoration: none; position: relative; }
.round-strip .cell-boss { background: #5a2420; }
.round-strip .cell-final { background: #4b5320; color: var(--bone); }
.round-strip .cell.is-done { background: var(--night); color: #59605a; }
.round-strip .cell-boss.is-done, .round-strip .cell-final.is-done { color: #8a6460; }
.round-strip .cell.is-done::after { content: ""; position: absolute; inset: 22% 22%; border-bottom: 3px solid currentColor; transform: rotate(-35deg); opacity: .5; }
.round-strip .cell.is-now { background: var(--torch); color: var(--ink); box-shadow: 3px 3px 0 #000; transform: translate(-1px, -2px); }
.round-strip .cell-boss.is-now { background: var(--blood); color: var(--bone); }
.round-strip .cell-final.is-now { background: var(--bile); color: var(--ink); }
.round-strip .cell.is-viewing { outline: 3px solid var(--bone); outline-offset: 1px; }
.round-strip a.cell:hover { outline: 3px solid var(--torch-hi); outline-offset: 1px; }

/* ---------- Two-up ---------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: start; }
.split > .panel { margin-top: var(--s3); }

/* ---------- Kill counter ---------- */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.kill-table th[scope=row] { font: 700 1.15rem/1.2 var(--head); text-transform: none; letter-spacing: 0; color: var(--bone); border-bottom: 1px solid #2c3137; vertical-align: middle; }
.kill-table td { vertical-align: middle; }
.kill-table td.counter { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; }
.kill-table td.counter form { margin: 0; }
.kill-table tfoot th, .kill-table tfoot td { border-bottom: 0; border-top: 2px solid #000; padding-top: .8rem; }
.kill-table tfoot b, .kill-table td b { font: 800 1.4rem/1 var(--head); }
.tick {
  width: 2.6rem; height: 2.6rem; font: 800 1.4rem/1 var(--head); cursor: pointer;
  background: var(--bone); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%; box-shadow: 3px 3px 0 #000;
  touch-action: manipulation;
}
.tick:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.tick:disabled { opacity: .6; }
.tick-plus { background: var(--torch); }
.tick-five { width: auto; padding: 0 .6rem; border-radius: 99px; font-size: 1rem; background: var(--bile); }
.count { min-width: 2.6ch; text-align: center; font: 900 2rem/1 var(--gothic); color: var(--bone); }
.count.bump { animation: bump .25s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--torch-hi); } }
.live-error { margin-top: var(--s2); }

details > summary { cursor: pointer; font: 700 1rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; color: var(--ash); }
details > summary:hover { color: var(--bone); }
.by-round, .ledger { margin-top: var(--s3); }
.grid-table { font-size: .95rem; }
.grid-table th, .grid-table td { padding: .45rem .5rem; white-space: nowrap; }
.grid-table th[scope=row] { font-family: var(--body); font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--bone); }
.grid-table .th-boss { color: var(--blood); }

/* ---------- Salvage ---------- */
.balances { list-style: none; padding: 0; margin: 0 0 var(--s3); display: grid; gap: .4rem; }
.balances li { display: flex; justify-content: space-between; align-items: center; padding: .5rem .8rem; background: var(--night-2); border: 2px solid #000; border-radius: 8px; }
.balances b { font: 800 1.5rem/1 var(--head); color: var(--bile); font-variant-numeric: tabular-nums; }
.salvage-form { display: grid; grid-template-columns: 1fr 7rem; gap: var(--s2); padding-top: var(--s2); border-top: 2px solid #000; }
.salvage-form .wide { grid-column: 1 / -1; }
.btn-pair { display: flex; gap: .6rem; flex-wrap: wrap; }
select, input[type=number], input[type=search] {
  font: inherit; color: var(--bone); background: var(--night); width: 100%;
  border: 2px solid #000; border-radius: 6px; padding: .7rem .8rem;
}
select:focus, input[type=number]:focus, input[type=search]:focus { border-color: var(--torch); outline: none; box-shadow: 0 0 0 3px #f08a2440; }
.ledger ul, .ledger-list { list-style: none; padding: 0; margin: var(--s2) 0 0; display: grid; gap: .5rem; }
.ledger li, .ledger-list li { display: flex; align-items: baseline; gap: .7rem; font-size: .95rem; }
.ledger li form { margin: 0 0 0 auto; }
.amt { min-width: 3.2rem; text-align: right; font: 800 1.15rem/1 var(--head); font-variant-numeric: tabular-nums; }
.amt-plus { color: var(--bile); }
.amt-minus { color: var(--blood); }

/* ---------- Players ---------- */
.roster { list-style: none; padding: 0; margin: 0 0 var(--s3); display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: .6rem; }
.roster li { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; background: var(--night-2); border: 2px solid #000; border-radius: 8px; }
.roster li form { margin: 0 0 0 auto; }
.roster li > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.roster .avatar { flex: none; background: var(--torch); }
.roster .is-waiting { border-style: dashed; border-color: #3a4048; }
.roster .is-waiting .avatar { background: var(--ash); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s2); margin: 0; }
.inline-form label { flex: 1 1 18rem; }

.settings > summary { font-size: 1.1rem; }
.settings[open] > summary { margin-bottom: var(--s3); }
.danger-zone { margin-top: var(--s3); padding-top: var(--s3); border-top: 2px solid #000; }
.danger-zone label small b { color: var(--bone); }

/* ---------- Player view ---------- */
.my-stats { display: flex; gap: var(--s3); margin: 0; }
.my-stats div { text-align: center; padding: .8rem 1.2rem; background: var(--night-2); border: 3px solid var(--ink); border-radius: 10px; box-shadow: 4px 4px 0 #000; }
.my-stats dt { font: 700 .9rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--ash); }
.my-stats dd { margin: .3rem 0 0; font: 900 2.6rem/1 var(--gothic); color: var(--torch); }
.my-stats div + div dd { color: var(--bile); }

.leaderboard { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.leaderboard li { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; background: var(--night-2); border: 2px solid #000; border-radius: 8px; }
.leaderboard .is-me { border-color: var(--torch); }
.rank { width: 1.9rem; height: 1.9rem; flex: none; display: grid; place-items: center; font: 800 1rem/1 var(--head); background: var(--bone); color: var(--ink); border: 2px solid var(--ink); border-radius: 50%; }
.leaderboard li:first-child .rank { background: var(--torch); }
.lb-name { flex: 1; font-weight: 500; }
.lb-stat { color: var(--ash); font-size: .95rem; white-space: nowrap; }
.lb-stat b { color: var(--bone); font: 800 1.15rem/1 var(--head); }

/* ---------- Admin ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s3); }
.filter-bar input[type=search] { width: auto; flex: 1 1 14rem; padding: .55rem .8rem; }
.seg { display: flex; flex-wrap: wrap; border: 2px solid #000; border-radius: 8px; overflow: hidden; }
.seg a { padding: .5rem .8rem; font: 700 .95rem/1 var(--head); text-transform: uppercase; letter-spacing: .04em; color: var(--ash); text-decoration: none; background: var(--night-2); border-right: 2px solid #000; }
.seg a:last-child { border-right: 0; }
.seg a:hover { color: var(--bone); }
.seg a[aria-current] { background: var(--bone); color: var(--ink); }
.status-pending_proof { background: var(--ash); }
.status-disabled { background: #000; color: var(--ash); border-color: #3a4048; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--s3); margin: 0; }
.stat-grid > div { padding: var(--s3); background: var(--panel); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--pop); }
.stat-grid dt { font: 700 .95rem/1 var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--ash); }
.stat-grid dd { margin: .4rem 0 0; font: 900 3rem/1 var(--gothic); color: var(--bone); }
.stat-grid p { margin: .5rem 0 0; font-size: .9rem; color: var(--ash); }

.fell-chart { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.fell-chart li { display: grid; grid-template-columns: 5.5rem 1fr 2rem; align-items: center; gap: .6rem; font-size: .9rem; color: var(--ash); }
.fell-chart li.kind-boss, .fell-chart li.kind-final { color: var(--bone); }
.fell-chart b { text-align: right; color: var(--bone); font-family: var(--head); }
meter { width: 100%; height: .8rem; border: 2px solid #000; border-radius: 4px; background: #000; }
meter::-webkit-meter-bar { background: #000; border: 0; border-radius: 2px; }
meter::-webkit-meter-optimum-value { background: var(--blood); }
meter::-moz-meter-bar { background: var(--blood); }

/* ---------- Auth extras ---------- */
.form-aside { margin: -.4rem 0 0; font-size: .9rem; text-align: right; }

/* ---------- Responsive (app) ---------- */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; gap: 0; }
  .round-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .app-nav { order: 3; width: 100%; margin: .3rem 0 0; overflow-x: auto; }
  .who-name { display: none; }
  .new-game { flex-direction: column; max-width: none; }
  .siege-now { align-items: flex-start; }
  .my-stats { width: 100%; }
  .my-stats div { flex: 1; }
}
@media (max-width: 480px) {
  .round-strip { grid-template-columns: 1fr; }
  .salvage-form { grid-template-columns: 1fr; }
  .tick { width: 2.4rem; height: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .count.bump { animation: none; }
  .game-card a { transition: none; }
}
.refresh-note { margin: var(--s2) 0 0; font-size: .85rem; }

/* ---------- Wave generator ---------- */
.wave .panel-head { align-items: center; }
.wave-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.wave-list li { background: var(--night-2); border: 2px solid #000; border-radius: 8px; padding: .6rem .9rem; }
.wave-row { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.wave-count { color: var(--torch); font: 800 1.35rem/1 var(--head); min-width: 2.2rem; }
.wave-name { font-size: 1.1rem; flex: 1; }
.wave-name small { color: var(--ash); font-size: .85rem; margin-left: .3rem; }
.wave-list .tags { display: flex; gap: .4rem; }
.wave-list .wave-boss { border-color: var(--blood); }
.wave-list .wave-boss .wave-count { color: var(--blood); }
.wave-list .wave-final { border-color: var(--bile); background: #232a14; }
.wave-list .wave-final .wave-count, .wave-list .wave-final .wave-name { color: var(--bile); }
.wave-list .is-corrupted { border-color: var(--bile); box-shadow: 0 0 0 2px #c6d84a33; }
.wave-list .is-corrupted .wave-name { color: var(--bile); }
.chip-corrupt { background: var(--bile); }
.boss-hp { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .6rem; }
.boss-hp meter { flex: 1 1 8rem; height: .9rem; }
.boss-hp meter::-webkit-meter-suboptimum-value, .boss-hp meter::-webkit-meter-even-less-good-value { background: var(--blood); }
.hp-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; }
.hp-form input[type=number] { width: 5.5rem; padding: .45rem .6rem; }
.hp-text { color: var(--ash); font-size: .9rem; white-space: nowrap; }
.wave-actions { display: flex; align-items: center; gap: var(--s2); margin: var(--s2) 0 0; }
.small-note { font-size: .85rem; }
.wave .sub-h { font: 800 1.1rem/1 var(--head); text-transform: uppercase; letter-spacing: .06em; color: var(--blood); margin: var(--s3) 0 var(--s2); }
