:root {
  color-scheme: dark;
  --bg: #15121b;
  --panel: #1f1a27;
  --line: #3b3146;
  --text: #f1e8df;
  --muted: #c2b5c8;
  --gold: #e8bd81;
  --mint: #98e1c3;
  --lavender: #cdb1f1;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 42% 0%, #302037, transparent 37rem), var(--bg);
  color: var(--text);
  font: 1rem/1.45 system-ui, sans-serif;
}
button, a { touch-action: manipulation; }
a, button:focus-visible { outline-color: var(--mint); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
a { color: var(--muted); }
button {
  appearance: none;
  min-height: 44px;
  padding: .5rem .8rem;
  border: 1px solid #665575;
  border-radius: 6px;
  background: #30263b;
  color: var(--text);
  font: 700 .875rem/1.25 system-ui, sans-serif;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--lavender); background: #443353; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: default; color: #afa0b7; background: #251f2d; border-color: var(--line); }
button.primary:not(:disabled) { background: var(--mint); color: #15241e; border-color: var(--mint); }
button.primary:hover:not(:disabled) { background: #bcf3dc; }
.top { background: #15121bea; border-bottom: 1px solid var(--line); }
.top-inner, main { width: min(100% - 2rem, 70rem); margin-inline: auto; }
.top-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1rem; padding-block: .5rem; }
.top-links { display: flex; align-items: center; gap: .7rem; }
.back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-weight: 650; font-size: .875rem; }
.back:hover { color: var(--mint); }
.start-over { background: transparent; border-color: transparent; color: var(--muted); }
#reset-dialog { width: min(calc(100% - 2rem), 26rem); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
#reset-dialog::backdrop { background: #120d19c9; }
#reset-details, #reset-error { margin-top: .75rem; color: var(--muted); }
button.danger { background: #643142; border-color: #b77b8d; }
button.danger:hover { background: #783c50; }
.wallet { display: flex; flex-wrap: wrap; gap: .35rem; }
.wallet div { display: flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 5px; padding: .35rem .5rem; font-size: .875rem; color: var(--muted); }
.wallet strong { color: var(--text); font-variant-numeric: tabular-nums; }
.dust { color: var(--gold); }
.essence { color: var(--lavender); }
.title { margin-block: 1.9rem 1.55rem; }
.title p:last-child { margin: .35rem 0 0; color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; }
h1 { font-size: clamp(2.85rem, 8vw, 5rem); line-height: .99; letter-spacing: -.055em; margin-top: .25rem; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.15; }
h3 { font-size: 1.15rem; line-height: 1.15; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .11em; font-size: .875rem; font-weight: 750; }
.layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: .9rem; align-items: start; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .9rem 1rem; }
.tag { flex-shrink: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--mint); font-size: .875rem; padding: .25rem .45rem; }
#scene { display: block; width: 100%; height: auto; image-rendering: pixelated; background: #1a1726; border-block: 1px solid var(--line); }
.battle-status { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; align-items: center; }
#hit-sound { color: var(--muted); background: transparent; border-color: var(--line); }
#hit-sound[aria-pressed="true"] { color: var(--mint); border-color: #6a9a89; }
.battle-controls { padding: .9rem 1rem 1rem; }
.route { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin-bottom: .9rem; color: var(--muted); font-size: .875rem; }
.route > span { font-variant-numeric: tabular-nums; }
#run-dust { color: var(--gold); }
#wave-track { display: flex; flex: 1 1 5rem; gap: .25rem; }
.wave { flex: 1; height: .38rem; background: #574461; border-radius: 2px; }
.wave.cleared { background: #83cdae; }
.wave.current { background: var(--gold); }
.wave.guardian { height: .6rem; margin-block: -.11rem; }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.meter-title { color: var(--text); font-size: .875rem; font-weight: 750; margin-bottom: .35rem; }
.meter-list { display: grid; gap: .45rem; }
.meter { min-width: 0; }
.meter label { overflow-wrap: anywhere; }
.meter.fallen { opacity: .72; }
#skeleton-meters { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.5rem), 1fr)); }
.meter > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .45rem; color: var(--muted); font-size: .875rem; }
.meter span { color: var(--text); font-variant-numeric: tabular-nums; }
progress { appearance: none; display: block; width: 100%; height: .55rem; margin-top: .35rem; border: 0; border-radius: 3px; background: #382c42; color: #d894a9; overflow: hidden; }
progress::-webkit-progress-bar { background: #382c42; }
progress::-webkit-progress-value { background: #d894a9; border-radius: 3px; }
progress::-moz-progress-bar { background: #d894a9; }
.army-hp::-webkit-progress-value { background: #83cdae; }
.army-hp::-moz-progress-bar { background: #83cdae; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem; }
.actions button, .action-link { flex: 1 1 8rem; }
.action-link { display: grid; place-items: center; min-height: 44px; background: #493458; border: 1px solid #9471ac; border-radius: 6px; padding: .5rem; text-decoration: none; color: var(--text); font-size: .875rem; font-weight: 750; }
@media (min-width: 781px) {
  .battlefield { grid-area: 1 / 1; }
  .crypt { grid-area: 1 / 2; }
  .forge { grid-area: 2 / 1; }
  .rituals { grid-area: 2 / 2; }
}
.hint, .section-note { color: var(--muted); font-size: .875rem; }
.hint { min-height: 2.6em; margin-top: .65rem; }
.section-note { padding: 0 1rem .8rem; }
.list { display: grid; gap: .45rem; padding: 0 .75rem .75rem; }
.row { background: #251e2e; border: 1px solid var(--line); border-radius: 6px; padding: .7rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .4rem .65rem; }
.row.active { border-color: #6a9a89; }
.row p { color: var(--muted); font-size: .875rem; margin-top: .25rem; }
.row .status { color: var(--gold); font-weight: 700; font-size: .875rem; }
.row.champion { grid-template-columns: 2.35rem minmax(0, 1fr); }
.portrait { display: grid; place-items: center; align-self: start; width: 2.35rem; height: 2.35rem; background: #36283e; color: var(--lavender); border: 1px solid #534361; border-radius: 5px; font-size: 1.3rem; }
.champion button { grid-column: 2; justify-self: start; }
.champion button[data-state="available"] { background: #493458; border-color: #9471ac; }
.journal { grid-column: 1 / -1; }
.journal ol { margin: 0; padding: 0 1rem 1rem; list-style: none; display: grid; gap: .4rem; color: var(--muted); font-size: .875rem; }
.journal li:first-child { color: var(--text); }
footer { color: var(--muted); padding: 1rem 0 1.5rem; font-size: .875rem; }
@media (max-width: 780px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .title { margin-block: 1.25rem 1rem; }
}
@media (max-width: 380px) {
  .top-inner, main { width: calc(100% - 1.25rem); }
  .top-inner { column-gap: .5rem; }
  .panel-head, .battle-controls { padding-inline: .75rem; }
  .tag { font-size: .8125rem; }
}

.squad { margin: .15rem .75rem .8rem; padding: .85rem .2rem .15rem; border-top: 1px solid var(--line); }
.squad > p, .squad-slot p { margin: .3rem 0 .65rem; color: var(--muted); font-size: .875rem; }
.squad-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .65rem; }
.squad-slot { min-width: 0; }
.squad-slot label { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .875rem; }
.squad-slot select {
  appearance: none;
  width: 100%;
  min-height: 44px;
  border: 1px solid #685876;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: .45rem 2rem .45rem .6rem;
  background:
    linear-gradient(45deg, transparent 50%, var(--gold) 51%) calc(100% - 15px) 55% / 5px 5px no-repeat,
    linear-gradient(135deg, var(--gold) 50%, transparent 51%) calc(100% - 10px) 55% / 5px 5px no-repeat,
    #30263b;
}
.squad-slot select:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

#summon-dialog {
  width: min(calc(100% - 2rem), 28rem);
  max-height: calc(100% - 2rem);
  overflow: auto;
  background: #1a1424;
  color: var(--text);
  border: 1px solid #8b729f;
  border-radius: 10px;
  padding: .85rem 1rem 1rem;
  text-align: center;
}
#summon-dialog::backdrop { background: #100b18e8; }
#summon-dialog[data-champion="0"] { --summon-glow: #9ee4b0; }
#summon-dialog[data-champion="1"] { --summon-glow: #efad77; }
#summon-dialog[data-champion="2"] { --summon-glow: #c5a8ff; }
.summon-art {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(6rem, 23vh, 11rem);
  background: radial-gradient(ellipse at 50% 73%, color-mix(in srgb, var(--summon-glow) 24%, transparent), transparent 67%), #130e1a;
  border-radius: 6px;
  margin-bottom: .85rem;
}
.summon-ring {
  position: absolute;
  width: 67%;
  height: 26%;
  bottom: 13%;
  border: 2px solid var(--summon-glow);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--summon-glow), inset 0 0 12px var(--summon-glow);
}
#summon-portrait { width: min(55%, 14rem); height: auto; image-rendering: pixelated; position: relative; }
#summon-dialog[open] .summon-ring { animation: open-portal .86s ease-out both; }
#summon-dialog[open] #summon-portrait { animation: rise-champion 1.05s .12s cubic-bezier(.25,.75,.35,1) both; }
#summon-dialog h2 { margin: .25rem 0; }
#summon-boon { color: var(--muted); font-size: .95rem; }
#summon-dialog form { margin-top: .85rem; }
@keyframes open-portal {
  from { opacity: .15; transform: scale(.25); }
  65% { opacity: 1; transform: scale(1.13); }
  to { opacity: .8; transform: scale(1); }
}
@keyframes rise-champion {
  from { opacity: 0; transform: translateY(26%) scale(.74); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #summon-dialog[open] .summon-ring, #summon-dialog[open] #summon-portrait { animation: none; }
}
