:root {
  color-scheme: dark;
  --ink: #eee6d1;
  --muted: #bbb6a4;
  --gold: #dfbb77;
  --edge: #544c3b;
  --surface: #211f1b;
  --sky: #192623;
  --accent: #7b886f;
  --accent-rgb: 123 136 111;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 0%, var(--sky), transparent 72%),
    linear-gradient(165deg, #181c19, #111311 75%);
}
body[data-region="wild"] { --sky: #392919; --accent: #c5a266; --accent-rgb: 197 162 102; --arena-art: url("assets/art/arena-wild.webp"); }
body[data-region="forest"] { --sky: #152e29; --accent: #7fa78b; --accent-rgb: 127 167 139; --arena-art: url("assets/art/arena-forest.webp"); }
body[data-region="forge"] { --sky: #392419; --accent: #d18a63; --accent-rgb: 209 138 99; --arena-art: url("assets/art/arena-forge.webp"); }
body[data-region="demon"] { --sky: #282537; --accent: #a995bf; --accent-rgb: 169 149 191; --arena-art: url("assets/art/arena-demon.webp"); }
body[data-region="fort"] { --sky: #223039; --accent: #9baeb8; --accent-rgb: 155 174 184; --arena-art: url("assets/art/arena-fort.webp"); }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid #ffd987; outline-offset: 3px; }
button:disabled { cursor: default; }
h1, h2, p { margin: 0; }
h1, h2, .brand { font-family: "STSong", "Songti SC", "Noto Serif CJK SC", serif; }
.icon { display: inline-block; width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar { border-bottom: 1px solid #a990622b; background: #151713ec; }
.bar-content {
  max-width: 1190px;
  min-height: 62px;
  margin: auto;
  padding: 6px 24px;
  display: flex;
  align-items: center;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-weight: 700; letter-spacing: .08em; }
.brand .icon { color: var(--gold); }
.run-stats, .bar-actions, .stat { display: flex; align-items: center; gap: 8px; }
.run-stats { gap: 18px; }
.stat { font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.health .icon { color: #e19083; }
.money .icon, .relic-button .icon { color: var(--gold); }

#game { max-width: 1190px; margin: auto; padding: 30px 24px 48px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: #272620;
  text-align: center;
  font-weight: 650;
}
.button:hover:not(:disabled) { background: #39362b; border-color: var(--gold); }
.button.primary { background: #cfad6c; border-color: #e3c58d; color: #211b11; }
.button.primary:hover:not(:disabled) { background: #e7c88b; }
.button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.button:disabled { opacity: .45; }
.button small { color: var(--muted); font-weight: 400; line-height: 1.5; }
.button.option { flex-direction: column; width: 100%; text-align: left; align-items: start; padding: 13px 17px; }
.bar-content .button { font-size: .86rem; padding-inline: 8px; }
.eyebrow { color: var(--gold); font-size: .83rem; letter-spacing: .12em; font-weight: 650; }
.notice { color: #f0cc86; line-height: 1.55; }

.hero {
  min-height: min(690px, 82vh);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-items: center;
  border: 1px solid #a389554d;
  border-radius: 9px;
  background: #1a211b;
}
.hero-art { position: absolute; inset: 0 0 0 29%; z-index: -1; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 27%; }
.hero-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #1a211b 0%, #1a211b67 35%, transparent 72%), linear-gradient(0deg, #151a15b3, transparent 53%);
}
.hero-copy { padding: clamp(28px, 6vw, 84px); }
.hero-copy h1 {
  margin-block: 18px 30px;
  font-size: clamp(3rem, 8vw, 6.6rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: .04em;
  text-shadow: 0 3px 18px #000b;
}
.hero-actions, .scene-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-copy .notice { margin-top: 16px; }

.map-layout { display: grid; grid-template-columns: minmax(230px, 330px) 1fr; gap: 24px; }
.map-aside { padding: 40px 20px 24px 8px; }
.scene-heading h1 { margin-top: 8px; font-size: clamp(1.65rem, 4vw, 2.7rem); line-height: 1.15; }
.legend { display: grid; grid-template-columns: repeat(2, max-content); gap: 14px 24px; margin-block: 30px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend .icon { color: var(--accent); }
.map-board {
  min-height: 565px;
  display: grid;
  place-items: center;
  padding: 24px 12px;
  border-radius: 8px;
  border: 1px solid #8274566b;
  background:
    repeating-linear-gradient(122deg, transparent, transparent 31px, #b2a16f09 32px, transparent 34px),
    radial-gradient(ellipse at 50% 62%, rgb(var(--accent-rgb) / .19), transparent 82%),
    #252821;
}
.map-field { position: relative; width: min(100%, 330px); aspect-ratio: 300 / var(--map-height); }
.map-lines { position: absolute; width: 100%; height: 100%; overflow: visible; fill: none; stroke: #b9ae8f63; stroke-width: 1.7; stroke-dasharray: 3 5; }
.map-lines path.next { stroke: #d6b36c; stroke-width: 2; }
.map-lines path.taken { stroke: #d6b36c; stroke-width: 2; stroke-dasharray: none; }
.map-node {
  width: 43px;
  height: 43px;
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  display: grid;
  place-items: center;
  border: 1px solid #9d8d6e91;
  border-radius: 50%;
  color: #cec4a9;
  background: #252923;
}
.map-node.boss { border-radius: 8px; color: #f4ce8e; }
.map-node.elite { color: #efaa89; }
.map-node.camp { color: #f4c483; }
.map-node.treasure { color: #e8ce9a; }
.map-node.available { color: #271e10; background: #e6c98f; border-color: #ffdc9b; box-shadow: 0 0 0 4px #e6c98f28; }
.map-node.available:hover { background: #ffe1aa; }
.map-node.visited { border-color: #d1ad69; color: #edce92; box-shadow: 0 0 0 2px #b1976144; }
.boss-label { position: absolute; white-space: nowrap; bottom: 100%; padding-bottom: 4px; font-size: .78rem; color: #efdfbd; }
.welcome-label { position: absolute; white-space: nowrap; left: calc(100% + 11px); color: var(--gold); font-weight: 650; font-size: .8rem; }

.battle { border: 1px solid #83785858; border-radius: 8px; overflow: hidden; background: #181b17; }
.battle-heading, .round-controls, .battle-bottom {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 20px;
}
.battle-heading { min-height: 44px; color: var(--muted); background: #23251f; font-size: .88rem; }
.battle-heading .eyebrow { margin-right: auto; }
.sword-active { display: inline-flex; align-items: center; gap: 6px; color: #ffdb8e; font-weight: 750; }
.arena {
  min-height: 310px;
  display: grid;
  grid-template-columns: minmax(200px, .6fr) minmax(0, 1fr);
  position: relative;
  isolation: isolate;
  background: linear-gradient(0deg, #080c13c9, #14252912 54%, #10202133),
    linear-gradient(rgb(var(--accent-rgb) / .2), rgb(var(--accent-rgb) / .06)),
    var(--arena-art, url("assets/art/arena.webp")) center 62% / cover;
}
.arena::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.holy-arena::after { background: radial-gradient(ellipse at 21% 58%, #ffe08d38, transparent 56%); }
.fighter { position: relative; min-height: 310px; isolation: isolate; }
.hero-unit { position: absolute; inset: 18px 8% 49px; display: grid; place-items: end center; }
.hero-unit::before, .enemy-stage::before {
  content: ""; position: absolute; inset: auto 12% -3px; height: 12%; border-radius: 50%;
  background: #070a10a8; filter: blur(6px);
}
.fighter-art {
  position: relative; width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center bottom;
  filter: drop-shadow(0 4px 8px #090b13ba);
}
.holy-arena .fighter-art { filter: drop-shadow(0 0 13px #ffe29382) drop-shadow(0 4px 6px #090b13a3); }
.fighter-info { position: absolute; inset: auto 12% 10px 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: .82rem; text-shadow: 0 2px 3px #111; }
.fighter-info strong { font-size: 1.05rem; }
.fighter-info .health-track { flex-basis: 100%; }
.enemies { display: flex; gap: 8px; justify-content: center; align-items: end; padding: 12px 13px 10px; }
.enemy {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px 8px;
  min-width: 0;
  flex: 1 1 145px;
  max-width: 190px;
  background: linear-gradient(0deg, #141914b3, #18181910 47%);
  border: 1px solid transparent;
  border-radius: 7px;
}
.enemy.target { border-color: #e7c689b3; box-shadow: inset 0 0 20px #e8b65c22; }
.enemy.defeated { opacity: .42; }
.enemy strong, .enemy .intent { text-align: center; overflow-wrap: anywhere; }
.intent { color: #ffe2b6; background: #1b1b22dd; border: 1px solid #c89e6455; padding: 2px 7px; border-radius: 5px; font-size: .8rem; font-weight: 650; min-height: 1.3em; }
.enemy-stage { width: 100%; aspect-ratio: 1; max-height: 175px; max-width: 175px; display: grid; place-items: center; position: relative; }
.atlas { display: block; background-image: var(--atlas); background-repeat: no-repeat; background-position: var(--tile-x) var(--tile-y); background-size: 400% 200%; }
.unit-tile { position: relative; width: 100%; aspect-ratio: 1; filter: drop-shadow(0 3px 4px #090b12ba); }
.enemy.defeated .unit-tile { filter: grayscale(1); }
.combat-number {
  position: absolute; left: 50%; top: 28%; translate: -50% 0; pointer-events: none; z-index: 2;
  font-size: clamp(1rem, 3vw, 1.9rem); font-weight: 850; line-height: 1; text-shadow: 0 2px 2px #171b24, 0 0 7px #090b13;
  white-space: nowrap;
}
.combat-number.hurt { color: #ffad97; }
.combat-number.holy { color: #ffe299; }
.combat-number.heal { color: #d3f6ae; }
.combat-number.guard { color: #c9e4fa; }
.combat-burst { position: absolute; z-index: 1; pointer-events: none; inset: 21% 6%; }
.combat-burst.hurt, .combat-burst.holy {
  clip-path: polygon(0 91%, 54% 38%, 98% 7%, 63% 54%, 16% 88%, 48% 53%);
  background: linear-gradient(153deg, #fff7dd 35%, #ffc0a8 58%, #ca5c58);
}
.combat-burst.holy { background: linear-gradient(153deg, #fffdf0 33%, #fff2b0 56%, #edab50); }
.combat-burst.guard, .combat-burst.heal {
  border-radius: 45%;
  border: 3px solid #add8f7;
  background: radial-gradient(ellipse, #a4d9ff35, #62bfff09 70%);
  box-shadow: inset 0 0 17px #9edfff95, 0 0 16px #a2daff94;
}
.combat-burst.heal { border-color: #c4eda8; box-shadow: inset 0 0 16px #b9fda2a0, 0 0 12px #d4f2a2a0; }
.flying-card { position: fixed; z-index: 20; pointer-events: none; margin: 0; }
.flying-blade {
  position: fixed; width: 31px; height: 9px; z-index: 19; pointer-events: none;
  clip-path: polygon(0 40%, 30% 40%, 30% 10%, 42% 10%, 42% 28%, 83% 18%, 100% 50%, 83% 74%, 42% 70%, 42% 90%, 30% 90%, 30% 60%, 0 60%);
  background: linear-gradient(90deg, #b17f46 34%, #fff5dd 42%, #b8d6de);
}
.flying-blade.holy { background: linear-gradient(90deg, #d1933c 34%, #ffffd6 48%, #ffd569); }
.card-back {
  width: 34px; height: 46px; border: 2px solid #c1a063; border-radius: 5px;
  background: radial-gradient(ellipse, #cdad70 0 8%, #25453e 11% 32%, #bc9b65 34% 38%, #1f312d 41%);
  box-shadow: 0 3px 9px #0b100bcc;
}
#game[aria-busy="true"] .battle button { cursor: wait; }
.enemy-hp { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .81rem; }
.block { display: inline-flex; gap: 3px; align-items: center; color: #b5dbe6; font-size: .79rem; font-weight: 700; }
.block .icon { width: 15px; height: 15px; }
.health-track { display: block; width: 100%; height: 5px; border-radius: 9px; background: #75514a74; overflow: hidden; }
.health-track > span { display: block; width: var(--health); height: 100%; background: #d07769; }
.conditions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.condition { border-radius: 3px; padding: 2px 4px; background: #38463d; color: #e2e0cd; font-size: .68rem; }
.demon-tag { background: #50342e; color: #ffd2b9; }
.round-controls { background: #21241e; border-block: 1px solid #a28d6228; }
.energy { display: flex; align-items: center; gap: 6px; color: #f2cc86; }
.energy strong { font-size: 1.5rem; }
.piles { display: flex; gap: 3px; margin-left: auto; }
.round-controls .quiet, .battle-bottom .quiet { font-size: .8rem; padding-inline: 8px; }
.hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 14px 18px 6px; }
.hand-notice { padding: 9px 18px 0; }
.battle-bottom { justify-content: space-between; }
.potions { display: flex; flex-wrap: wrap; gap: 4px; }

.card {
  --card-color: #9da592;
  width: 100%;
  min-width: 0;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px 12px;
  border: 1px solid var(--card-color);
  border-radius: 6px;
  color: #201e17;
  background: linear-gradient(165deg, #f2e7d1, #d4c7aa);
  text-align: left;
  overflow-wrap: anywhere;
}
.card-attack { --card-color: #b36551; }
.card-skill { --card-color: #648e7d; }
.card-power { --card-color: #9982b3; }
.card-curse, .card-status { background: #bcb6ab; --card-color: #938b9e; }
.card.empowered { border-color: #ffe59d; box-shadow: inset 0 0 0 2px #edc06970; }
button.card:hover:not(:disabled), button.card.chosen { background-image: linear-gradient(165deg, #fff2d6, #e0cea8); box-shadow: 0 0 0 2px #efc27a; }
button.card:active:not(:disabled) { transform: translateY(1px); }
button.card:disabled { filter: saturate(.44) brightness(.82); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 5px; font-size: .7rem; font-weight: 700; }
.card-top > span:last-child { padding: 2px 6px; border-radius: 3px; background: var(--card-color); color: #130f13; }
.card-cost { border-radius: 50%; background: #33372d; color: #f9edcd; min-width: 24px; height: 24px; padding: 3px; text-align: center; line-height: 18px; font-size: .83rem; }
.card-art {
  width: 100%; height: clamp(66px, 10vw, 111px); overflow: hidden; border: 1px solid #533e3059;
  border-radius: 4px; position: relative; background: #393637;
}
.card-tile { width: 100%; aspect-ratio: 1; position: absolute; top: 50%; translate: 0 -50%; }
.card strong { font-size: .9rem; line-height: 1.3; }
.card-effect, .card-preview { font-size: .78rem; line-height: 1.45; }
.card-preview { border-top: 1px solid #6b6b4060; color: #2e4c33; padding-top: 4px; }
.card-preview::before { content: "升级后 "; font-weight: 700; }
.price { margin-top: auto; color: #483711; font-size: .84rem; font-weight: 700; }
.price .icon { width: 16px; height: 16px; margin-right: 3px; }

.scene-panel {
  width: min(100%, 750px);
  margin: 28px auto 0;
  padding: clamp(18px, 5vw, 46px);
  border: 1px solid #99865c60;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 0%, rgb(var(--accent-rgb) / .12), transparent 65%), var(--surface);
}
.scene-symbol { display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid #9c885e7d; border-radius: 50%; color: var(--gold); margin-bottom: 20px; }
.scene-symbol .icon { width: 32px; height: 32px; }
.scene-copy { margin-top: 16px; max-width: 52ch; line-height: 1.75; color: #d8cfb9; }
.scene-actions { margin-top: 20px; }
.camp-look { display: flex; align-items: center; gap: 18px; margin-top: 20px; border-top: 1px solid #bca47a35; padding-top: 16px; }
.camp-portrait { width: 88px; height: 97px; object-fit: contain; }
.camp-look p { color: var(--muted); font-size: .85rem; margin-top: 5px; line-height: 1.5; }
.wardrobe { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.outfit-choice {
  display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid var(--edge); border-radius: 6px; padding: 9px 8px;
  background: radial-gradient(ellipse at 50% 32%, #4b4938, #292923 73%);
}
.outfit-choice:hover, .outfit-choice[aria-pressed="true"] { border-color: var(--gold); }
.outfit-preview { display: block; width: 100%; height: clamp(90px, 17vh, 124px); object-fit: contain; }
dialog:has(.wardrobe) .dialog-top { position: sticky; top: -20px; z-index: 1; background: #24231d; }
.outfit-choice strong { font-size: .9rem; }
.outfit-choice small { color: var(--muted); line-height: 1.5; font-size: .76rem; }
.outfit-state { margin-top: auto; color: var(--gold); font-size: .76rem; }
.selection { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-block: 18px 12px; }
.selection .card-art { aspect-ratio: 1; height: auto; }
.reward-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.shop-panel { width: min(100%, 880px); }
.shop-extras { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.empty { color: var(--muted); grid-column: 1 / -1; padding-block: 12px; }

dialog {
  width: min(720px, calc(100% - 24px));
  max-height: 85vh;
  padding: 20px;
  color: var(--ink);
  background: #24231d;
  border: 1px solid #8d7952;
  border-radius: 8px;
}
dialog::backdrop { background: #0a0b09cc; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.help-list { padding-left: 1.4em; line-height: 1.6; }
.help-list li + li { margin-top: 9px; }
.relic-list dt { color: var(--gold); font-weight: 650; }
.relic-list dd { color: var(--muted); margin: 5px 0 13px; line-height: 1.5; }

@media (max-width: 720px) {
  #game { padding: 14px 12px 28px; }
  .bar-content { min-height: 53px; gap: 10px; padding-inline: 12px; flex-wrap: wrap; justify-content: space-between; }
  .brand { font-size: .94rem; }
  .run-stats { gap: 10px; }
  .stat { font-size: .8rem; gap: 4px; }
  .stat .icon, .bar-content .button .icon { width: 16px; height: 16px; }
  .bar-actions { gap: 0; }
  .hero { min-height: 72vh; align-items: end; }
  .hero-art { inset: 0; }
  .hero-art img { object-position: 54% 20%; }
  .hero-art::after { background: linear-gradient(0deg, #151a15 0%, #171b16b8 27%, transparent 68%); }
  .hero-copy h1 { margin-block: 10px 19px; }
  .map-layout { grid-template-columns: 1fr; gap: 10px; }
  .map-aside { padding: 8px 4px 0; }
  .map-aside h1 { font-size: 1.35rem; }
  .legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-block: 11px 4px; font-size: .75rem; }
  .legend span { gap: 4px; }
  .legend .icon { width: 16px; height: 16px; }
  .map-board { min-height: 0; padding-block: 22px 10px; }
  .map-field { width: min(100%, 304px); }
  .scene-panel { margin-top: 8px; }
  .battle-heading, .round-controls, .battle-bottom { padding: 7px 10px; gap: 5px 9px; }
  .battle-heading .eyebrow { letter-spacing: 0; font-size: .74rem; }
  .battle-heading { font-size: .76rem; }
  .sword-active .icon { width: 15px; height: 15px; }
  .arena { grid-template-columns: minmax(75px, .43fr) minmax(0, 1fr); min-height: 176px; }
  .fighter { min-height: 176px; }
  .hero-unit { inset: 8px 3% 43px; }
  .fighter-info { inset: auto 5px 8px 7px; font-size: .72rem; gap: 3px 6px; }
  .fighter-info strong { font-size: .8rem; }
  .enemies { padding: 5px; gap: 4px; }
  .enemy { padding: 4px 2px; gap: 3px; }
  .enemy strong { font-size: .75rem; }
  .enemy .intent, .enemy-hp { font-size: .67rem; }
  .enemy .intent { padding: 2px 3px; }
  .enemy-stage { max-height: 105px; max-width: 105px; }
  .condition { font-size: .62rem; }
  .round-controls .quiet, .battle-bottom .quiet { min-height: 40px; padding-inline: 5px; font-size: .74rem; }
  .end-turn { order: 2; margin-left: auto; padding-inline: 10px; }
  .piles { order: 3; margin: 0; }
  .energy strong { font-size: 1.2rem; }
  .hand { padding: 8px; gap: 7px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card { min-height: 136px; padding: 6px 7px 9px; }
  .card-art { height: clamp(52px, 16vw, 95px); }
  .card-effect, .card-preview { font-size: .74rem; }
}

@media (max-width: 440px) {
  .hero-copy { padding-inline: 20px; }
  .scene-panel { padding-inline: 14px; }
  .selection { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); }
  .reward-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .wardrobe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .bar-content:has(.run-stats) .brand { display: none; }
  .bar-content { gap: 4px; padding-inline: 8px; }
  .bar-content .button { padding-inline: 5px; }
  .bar-content .button .icon { width: 14px; height: 14px; }
  .run-stats { gap: 6px; }
}

