/* Shared finishes for the illustrated atlas, market counter and encounter stage. */
:root {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --midnight: #202e40;
  --cream: #fff2d1;
  --brass: #c09a64;
  --walnut: #593822;
  --umber: #422b20;
  --paper: #fff2d5;
  --secondary-ink: #66503c;
  --focus-ring: #16779b;
  --target-gold: #ffda6b;
  --gold-ink: #764210;
  --gem-ink: #185975;
  --low-cells: repeating-linear-gradient(125deg,#ffd784 0 3px,#e89939 3px 6px);
  --number-font: "Trebuchet MS", "Microsoft YaHei UI", system-ui, sans-serif;
  --paper-ribbon: url('./assets/ui/ribbon.svg') center / 100% 100% no-repeat;
  --guild-sign: url('./assets/ui/guild-sign.svg') center / 100% 100% no-repeat;
}
.icon svg { display: block; width: 100%; height: 100%; }
:is(.game-number,.health-numbers,.price strong,.item-effect b,.recap strong,.hit-float,.enemy-preview b,.damage-list strong,.stat-delta) {
  font-family: var(--number-font); font-variant-numeric: lining-nums tabular-nums; font-weight: 800;
}
.health-numbers > span { font-size: .82em; font-weight: 650; }
.button { font-weight: 800; }
.button.primary:not(:disabled), .item-purchase .button:not(:disabled) {
  position: relative; isolation: isolate; color: #44271b; background: transparent;
  border-color: transparent; box-shadow: none; padding-bottom: .65em; text-shadow: 0 1px #fff0a2;
}
.button.primary:not(:disabled)::before, .item-purchase .button:not(:disabled)::before {
  content: ''; position: absolute; inset: -2px; z-index: -1; pointer-events: none;
  border: solid transparent; border-width: 13px 18px 16px;
  border-image: url('./assets/ui/gold-keycap.svg') 13 18 16 fill stretch;
}
.button.secondary:not(:disabled,.item-purchase .button) {
  border: 2px solid #283b4c; border-radius: 14px;
  background: #bad6e2; color: #203949;
  box-shadow: inset 0 2px #e9f6f8, inset 0 -3px #83acbd, 0 2px #122732;
}
.button:disabled:not(.quiet) { color: #514a42; background: #dfd6c2; border: 2px solid #948674; box-shadow: inset 0 2px #c9bfab; cursor: default; }
.button .icon-arrow, .button .icon-back { width: 1.05em; height: 1.05em; }
.button:not(:disabled):active { transform: translateY(2px) scale(.985); }
button:focus-visible { outline: 3px solid #78daff; outline-offset: 2px; }
.button:focus-visible,button.enemy:focus-visible { box-shadow: 0 0 0 2px #182b41; }

/* The brass-edged sign and portrait are two distance cues that survive on a phone. */
.game-logo {
  display: inline-grid; grid-auto-flow: column; place-content: center;
  width: 135px; height: 48px; padding-bottom: 1px; background: var(--guild-sign);
  font-size: 1.13rem; letter-spacing: .01em; color: #fff1ba;
  -webkit-text-stroke: 1.4px #542d21; paint-order: stroke fill; text-shadow: 0 2px #47281e;
}
.game-header { min-height: 56px; }
.mode-name { color: #eee3c7; }
.title-plaque { width: max-content; max-width: 100%; }
.title-plaque h1 {
  background: var(--guild-sign); padding: .52em .48em .65em; transform: rotate(-3deg);
  font-size: clamp(40px,4.9vw,74px); line-height: 1; letter-spacing: -.045em;
  text-shadow: 0 .06em #744321, 0 .10em #41281e; -webkit-text-stroke: .06em #64351e;
}
.title-plaque h1 span { display: inline; font-size: inherit; }
.home-copy p { margin-top: 16px; }
.stats {
  background: var(--midnight); border: 2px solid #bc986e; border-radius: 14px;
  box-shadow: inset 0 1px #f5dfb26b, inset 0 -3px #101d2d, 0 3px #0e202a;
}
.stat { align-items: center; justify-content: center; gap: 9px; }
.stats .stat:not(.life-stat) .game-number { display: inline-block; min-width: 2ch; line-height: 1.08; }
.stats [data-stat="value"] .game-number { color: #a9e6f4; }
.stats .stat-change { animation: hud-ink .65s ease-out; }
@keyframes hud-ink { from { background-color: #f7ce762c; } }
.stat-label { color: #f3dfb7; letter-spacing: .04em; line-height: 1.3; }
.stat strong { font-size: 1.65rem; }
.stats .stat > .icon { width: 40px; height: 40px; }
.stats .life-stat > .icon {
  width: 49px; height: 49px; padding: 2px; background: #f3ce89;
  border: 2px solid #7c5437; border-radius: 46% 50% 44% 46%; box-shadow: 0 0 0 1px #ffe5b6;
}
.health-track { border-color: #211c24; border-radius: 6px; background: #666170; }
.health-track { --cell-color: linear-gradient(#b9f869 0 18%,#83d438 19% 76%,#59af30 77%); }
.life-stat .health-track { box-shadow: 0 0 0 1px #d9c8a3; }
.health[data-tone="low"] .health-track { --cell-color: var(--low-cells); }
.life-stat .health:is([data-tone="low"],[data-tone="empty"]) [data-life-value] { color: #ffd18c; }
@media (min-width: 851px) {
  .stats:not(.prologue-stats) { display: grid; grid-template-columns: minmax(180px,1.85fr) repeat(5,minmax(0,1fr)); }
  .stats:not(.prologue-stats):has([data-stat="key"]) { grid-template-columns: minmax(175px,1.8fr) repeat(6,minmax(0,1fr)); }
  .stat { min-height: 66px; padding: 6px 12px; }
  .life-stat { max-width: none; }
  .life-stat .health { grid-template-columns: max-content minmax(48px,1fr); gap: 9px; }
  .life-stat .health-track { height: 13px; }
}
.scene-heading h1 { letter-spacing: .015em; font-weight: 900; paint-order: stroke fill; }
.explore-heading h1,.battle-scene h1,.shop-stage h1,.reward-scene h1,.chapter-screen .scene-heading h1 {
  width: fit-content; padding: .17em .85em .42em; line-height: 1.15;
  border: 0; border-radius: 0; background: var(--paper-ribbon);
  color: var(--umber); text-shadow: 0 1px #fff3c7;
  font-size: clamp(22px,2.45vw,36px);
}
.explore-heading > div { align-items: center; }
.dragon-bubble { background: var(--paper); border-color: #805b3e; border-radius: 22px 18px 21px 12px; box-shadow: inset 0 -2px #ead5af,0 2px 3px #241c2040; }
.dragon-bubble::before { border-color: #805b3e; }
.dragon-bubble p { color: #483324; line-height: 1.45; text-wrap: balance; }
.dragon-bubble .icon-close,.room-card-head .icon-close { width: 15px; height: 15px; }
.dragon-bubble .icon-close { color: #725638; }

/* Parchment locations and their attached field notes. Keep all map geometry intact. */
.node-label { border-color: #88633e; border-radius: 10px; box-shadow: inset 0 1px #fff5d9,0 1px #805734; }
.node-caption { letter-spacing: .03em; }
.map-node.inspecting .node-label { outline-color: var(--focus-ring); }
.map-node.available:not(.inspecting) .node-caption { background: #365c45; }
.map-node.closed .node-label { border-style: dashed; }
.map-node.passed:has(.node-done) .node-label { border-color: #55714c; }
@media (prefers-reduced-motion: no-preference) {
  .map-node.available:not(.inspecting) .node-caption { animation: route-caption 2.2s ease-in-out 2; }
  @keyframes route-caption { 50% { background-color: #51704c; } }
}
.map-legend { background: #ecd09b; color: #513c2c; }
.room-card { border-color: #906340; background: #ffedcc; box-shadow: inset 0 0 0 2px #fff7de,0 5px 13px #20201e65; }
#room-preview::before { background: #906340; }
.room-card-head { border-bottom: 1px solid #c7a476; gap: 8px; }
.room-card-head h2 { font-size: 1.18rem; line-height: 1.16; }
.room-stamp { background: #f4dba9; border: 1px solid #c39763; border-radius: 8px; padding: 2px; }
.room-card-body { padding-top: 4px; }
.enemy-preview li { border-color: #d3ad7a; }
.room-card .reward-badge { background: #f8df9e; }
.room-card .reward-badge[data-reward="gem"] { background: #dceced; border-color: #9ab4b4; color: var(--gem-ink); }
.room-card .enemy-preview b { color: var(--umber); font-size: 1.36em; }
.room-card .room-condition { color: #63472f; }

/* Goods are displayed as objects on named tickets, with a separate comparison line. */
body:has(.shop-scene) { background: linear-gradient(#122435e8,#182b36e8),var(--cave) center / cover fixed; }
.market { border-color: #ab7648; }
.counter { background: #694431; border-color: #af7646; }
.item-card {
  align-content: start; border: 2px solid #a8794c; border-radius: 17px 17px 11px 11px;
  background: #ffe9bb; box-shadow: inset 0 0 0 3px #fff3d3,0 3px #452e23;
}
.item-card:not(.unavailable) .item-art { background: radial-gradient(ellipse closest-side,#fff9d9 63%,transparent); }
.item-art { width: 100%; height: clamp(76px,12svh,116px); }
.item-card[data-kind="weapon"] .product-art { width: auto; max-width: 70%; height: 86%; transform: rotate(30deg); }
.item-card h3 {
  width: fit-content; max-width: 100%; min-width: 65%; padding: 3px 15px 8px;
  background: var(--paper-ribbon); color: #49301f; font-size: clamp(17px,1.48vw,22px);
}
.item-card .item-effect {
  display: flex; justify-content: center; align-items: baseline; gap: .35em; margin: 2px 0 4px;
  width: 100%; min-height: 1.9em; padding: 3px 2px; border-block: 1px solid #bf985d77;
  color: var(--secondary-ink); background: #fffae047;
}
.item-card .upgrade { display: inline-flex; align-items: baseline; gap: .2em; line-height: 1; }
.upgrade em { font-style: normal; }
.item-card .item-effect b { font-size: 1.48em; }
.item-effect .upgrade { color: #8f3621; }
.upgrade span,.upgrade small { color: #624c37; }
.upgrade span { font-size: .8em; }
.upgrade small { font: 700 .75em system-ui,sans-serif; }
.item-purchase .button { width: min(100%,166px); }
.item-purchase .price strong { font-size: 1.5em; }
.item-purchase .price { padding-right: .42em; border-right: 1px solid #89633573; }
.item-card.unavailable .item-effect { color: #544839; }
.item-card.unavailable { background: #e4d6bc; box-shadow: inset 0 0 0 2px #efe4ce,0 2px #473829; }
.item-card.unavailable .product-art { filter: saturate(.48); }
.item-card.unavailable h3 { filter: saturate(.48); }
.item-issue { color: #5d4735; font-weight: 700; }

/* Keep the life readout and the attack row on consistent baselines across all targets. */
.enemy.selected .ground-shadow { background: #ac78347a; box-shadow: 0 0 0 3px #ffdc6d,0 0 0 5px #895c2d; }
.enemy-marker { top: -19px; padding: 1px 9px 2px; border-radius: 11px; }

/* A seal behind the actual prize, and a paper receipt for the result. */
.reward-scene .scene-heading h1 { font-size: clamp(26px,3.1vw,44px); }
.chest-display,.loot-display:not(.loss-mark) {
  background: url('./assets/ui/prize-seal.svg') center / contain no-repeat,radial-gradient(ellipse closest-side,#efbc5a4d,transparent);
}
.reward-details {
  width: fit-content; min-width: min(100%,310px); padding: 14px clamp(12px,2vw,28px) 18px;
  background: var(--paper); border: 2px solid #986944; color: var(--umber);
  box-shadow: inset 0 0 0 3px #fff9e5,0 3px #493327;
}
.reward-title,.chest-note { color: #503420; text-shadow: none; }
.reward-totals .reward-badge,.score-line > .reward-badge { background: #ffe3a2; border-color: #c29a63; }
.reward-details .reward-actions { justify-content: center; }
.reward-stage { grid-template-columns: minmax(0,1fr); }
.reward-totals .reward-badge strong { font-size: 1.9em; }
.coin-drop-art { width: min(62%,230px); height: 82%; object-fit: contain; }
.coin-drop-art + .icon-gem { width: min(20%,68px); height: 32%; align-self: end; margin: 0 0 9% -32px; }
.score-line .stars,.empty-stars { display: inline-flex; align-items: center; }
.stars .icon-star { width: 29px; height: 29px; }
.stars > .icon-star:nth-child(2) { width: 34px; height: 34px; }
.empty-stars { --star-fill: #eadabe; --star-edge: #9d8c75; --star-shine: #eadabe; }
.battle-summary { border-color: #96724d; background: #f2dfbb; border-radius: 12px; }
.reward-totals,.score-line { margin-block: 9px 12px; }
:is(.reward-totals,.score-line) > .reward-badge {
  display: grid; grid-template-columns: auto auto; justify-content: center; gap: 0 7px;
  padding: 5px 14px; min-width: 96px; color: var(--gold-ink);
}
:is(.reward-totals,.score-line) > .reward-badge[data-reward="gem"] { color: var(--gem-ink); background: #d9edec; border-color: #95b8b4; }
:is(.reward-totals,.score-line) .reward-badge > .icon { grid-row: 1 / 3; width: 30px; height: 30px; }
:is(.reward-totals,.score-line) .reward-badge strong { font-size: clamp(30px,3.2vw,43px); line-height: 1; }
:is(.reward-totals,.score-line) .reward-badge > span:last-child { font-size: .8rem; }
[data-earned] .game-number { animation: tally-in .38s var(--bounce) both; }
@keyframes tally-in { 0% { opacity: .45; scale: .82; } 65% { scale: 1.07; } }
.reward-scene:not(.end-panel) > .battle-summary { margin-block: 12px; padding: 9px 16px; }
.reward-scene > .supplies { justify-content: center; }
.lost .reward-details { margin-top: 12px; }
.lost .battle-summary { margin: 12px auto; text-align: left; }
.lost .battle-summary .dragon-hint { margin: 5px 0 9px; }
.lost .battle-summary .dragon-hint > .icon { width: 48px; height: 48px; }
.lost .battle-summary { padding: 10px 12px; border: 1px solid #b99a72; }
.damage-list li { border-radius: 0; background: none; border-top: 1px dotted #b99a72; }
.damage-list strong { color: #683822; }
.recap { gap: 4px 14px; }
.recap > span { display: inline-flex; gap: .2em; align-items: center; }
.end-panel.lost h1 { filter: saturate(.64); }
dialog { background: #ffedce; box-shadow: inset 0 0 0 3px #fff7df,0 7px #32272270; }
dialog h2 { color: #513423; }
@media (hover: hover) {
  .map-node:not(.inspecting,.here):hover .node-label { background: #fff4cc; color: #49331d; outline: 2px solid #ac824f; }
  .map-node.here:not(.inspecting):hover .node-label { background: #864822; outline: 2px solid #c18e52; }
  .item-card:has(.button:not(:disabled):hover) { border-color: #7d552b; background: #fff1cc; }
}
@media (max-width: 850px) {
  .stat { gap: 5px; }
  .stats .stat > .icon { width: 28px; height: 28px; }
  .stats .life-stat > .icon { width: 35px; height: 35px; padding: 1px; }
}
@media (max-width: 650px) {
  .title-plaque h1 { font-size: clamp(35px,8vw,55px); }
  .game-logo { width: 97px; height: 37px; font-size: .83rem; }
  .game-header { min-height: 44px; }
  .stat { justify-content: start; }
  .stats:not(.prologue-stats) { grid-template-columns: 1.15fr 1fr .9fr; }
  .stats .stat > .icon { width: 24px; height: 24px; }
  .stats .life-stat > .icon { width: 30px; height: 30px; }
  .stat strong { font-size: 1.23rem; }
  .stats .stat-delta {
    top: calc(50% - .8em); left: 1px; right: auto; min-width: 24px; padding: 2px 3px;
    font: 800 .72rem/1.2 var(--number-font); font-variant-numeric: tabular-nums;
  }
  .stat-label { letter-spacing: 0; }
  .scene-heading h1 { font-size: 1.24rem; }
  .explore-heading > div { justify-items: start; gap: 3px; }
  .item-art { height: clamp(54px,8svh,70px); }
  .item-card h3 { font-size: 1rem; }
  .item-card .item-effect { margin: 0; }
  .enemy-marker { top: -15px; }
  .reward-scene .scene-heading h1 { font-size: 1.55rem; }
  .won .reward-actions:has(> :nth-child(3)) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .won .reward-actions:has(> :nth-child(3)) .primary { grid-column: 1 / -1; }
  .won .reward-actions:has(> :nth-child(3)) .secondary { padding-inline: 5px; }
  .recap { gap: 3px 6px; }
}
@media (max-width: 365px) {
  .game-name { gap: 3px; }
  .game-logo { width: 85px; font-size: .76rem; }
  .stat { gap: 3px; }
  .stats:not(.prologue-stats) { grid-template-columns: 1.08fr 1.12fr .85fr; }
  .stats:not(.prologue-stats) .stat:nth-child(n+4) { gap: 2px; }
}
.chapter-screen { padding-bottom: 32px; }
body:has(.chapter-screen) { background: linear-gradient(#102b34ef,#102b34b8), url('./assets/scenes/forest-gate.webp') center / cover fixed; }
.chapter-screen .game-header > .button { color: #fff0cf; }
.chapter-screen .scene-heading { justify-content: center; margin: 24px 0; }
.chapter-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: clamp(10px,2vw,24px); max-width: 1040px; margin: 0 auto; }
.chapter-card {
  display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 9px; padding: 16px;
  color: #492d1a; background: #fae5b8; border: 2px solid #ad7a48; border-radius: 16px;
  box-shadow: inset 0 0 0 3px #fff3d9,0 5px #362724; text-align: center;
}
.chapter-card h2 { color: #49301f; font-size: clamp(17px,2vw,24px); line-height: 1.25; }
.chapter-card > p { color: var(--secondary-ink); line-height: 1.45; }
.chapter-card p { font-size: .9rem; }
.chapter-figure {
  position: relative; isolation: isolate; overflow: hidden; height: clamp(95px,19vh,180px);
  border: 1px solid #89623e; border-radius: 10px 10px 5px 5px; background: #344853;
}
.chapter-figure::before { content: ''; position: absolute; inset: 0; background: var(--cave) center / cover; }
.chapter-card.chapter-locked .chapter-figure::before { filter: saturate(.45) brightness(.72); }
.chapter-figure .icon { position: absolute; inset: 13% 12% 5%; width: auto; height: auto; filter: drop-shadow(0 2px 2px #35271c99); }
.chapter-index {
  position: absolute; top: 0; left: 0; padding: 2px 9px 3px; border-radius: 0 0 7px 0;
  background: #233540; color: #fff1c6; font-size: .78rem; font-weight: 750;
}
.chapter-figure .icon .art { position: absolute; inset: 0; }
.chapter-locked .chapter-figure .icon { filter: saturate(.42); }
.chapter-record {
  display: flex; flex-wrap: wrap; min-height: 36px; align-items: center; justify-content: center;
  gap: 4px 10px; border-top: 1px solid #c49d677a; padding-top: 6px; font-size: .89rem;
}
.chapter-card .stars { display: inline-flex; align-items: center; margin: 0; font-size: .92rem; }
.chapter-card .stars .icon-star { width: 22px; height: 22px; }
.chapter-goals { margin: 8px 0 0; color: #fff1ce; font-size: .86rem; }
@media (max-width: 660px) {
  .chapter-grid { grid-template-columns: 1fr; }
  .chapter-card { grid-template: auto auto auto auto / 86px minmax(0,1fr); gap: 6px 10px; padding: 11px; text-align: left; }
  .chapter-figure { grid-row: 1 / 5; height: 100%; }
  .chapter-figure .icon { inset: 24% 4% 12%; }
  .chapter-record { justify-content: flex-start; }
  .chapter-card .button { justify-self: start; min-height: 44px; }
}
