:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #ead9b8;
  background: #0c1518;
  --paper: #ead9b8;
  --gold: #edbc70;
  --teal: #86c1ca;
  --muted: #a5b4ae;
  --ink: #101e22;
  --line: #6b634b;
  --fine: #465047;
  --danger: #ffb49e;
  --border: 1px solid #d9bd8538;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; background: radial-gradient(ellipse at 25% -35%,#32413f,#111d20 57%,#0c1416 100%); }
.shell { width: min(1400px,100%); margin: auto; padding: 0 max(22px,env(safe-area-inset-right)) max(38px,env(safe-area-inset-bottom)) max(22px,env(safe-area-inset-left)); }
.masthead { display: flex; justify-content: space-between; align-items: center; padding: .75rem 0; }
.masthead h1 { font-size: 1.05rem; margin: 0; }
.masthead nav { display: flex; gap: .4rem; }
#game { -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-touch-callout: none; }
button, select { font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { background: #203338; color: var(--paper); border: 1px solid #74867d6e; border-radius: 5px; min-height: 40px; padding: .48rem .72rem; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button:not(:disabled):hover, button[aria-pressed="true"], button.selected { background-color: #30484a; border-color: #8ab2a6; }
button:focus-visible, select:focus-visible { outline: 2px solid #f3c678; outline-offset: 2px; }
button.primary { color: #281a0e; background: linear-gradient(#f4cc8a,#d8a254); border-color: #f7d69a; font-weight: 730; box-shadow: inset 0 1px #fff5,0 4px 12px #0b1011a0; }
button.primary:not(:disabled):hover { background: #ffe0a6; border-color: #fff2ce; }
button.subtle { background: #14252b80; border-color: #bca46a45; color: #f0ca88; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3 { font-family: Georgia,'Songti SC',STSong,serif; line-height: 1.12; font-weight: 600; }
h1 { font-size: clamp(1.7rem,4vw,3.2rem); color: #f5deb4; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.15rem; }
p { color: var(--muted); font-size: .91rem; line-height: 1.5; }
.eyebrow { color: var(--gold); font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
:lang(zh) .eyebrow { letter-spacing: .09em; }
.panel { background: linear-gradient(155deg,#1a292c,#101d21); border: var(--border); border-radius: 8px; box-shadow: 0 4px 20px #0003; }
.art { background-color: #19282d; background-size: cover; background-position: center; }
.town-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(280px,1fr); gap: 16px; }
.town-hero { min-height: 390px; border: var(--border); border-radius: 9px; position: relative; padding: clamp(22px,4vw,54px); display: flex; flex-direction: column; justify-content: space-between; isolation: isolate;
  background-image: linear-gradient(90deg,#101b20ef,#101b2048 53%,#0f171514),linear-gradient(0deg,#0e191cde,transparent 65%),var(--art); background-position: center,center,center 43%; }
.town-hero::after, .arena::after, .map::after { content: ''; position: absolute; inset: 5px; pointer-events: none; border: 1px solid #eedba52b; border-radius: 4px; }
.town-title h1 { margin-top: .6rem; text-shadow: 0 4px 24px #050607ac; }
.town-title p { max-width: 275px; color: #e4d7bb; margin-top: .7rem; }
.town-bottom { display: flex; align-items: flex-end; gap: 20px; justify-content: space-between; }
.town-bottom .primary { padding-inline: 1.1rem; min-height: 48px; }
.town-progress span { display: block; color: #f1c27c; font: 1.5rem Georgia,serif; }
.town-progress small { color: #e4d9be; }
.town-side { display: flex; flex-direction: column; gap: 12px; }
.resources { display: flex; align-items: center; justify-content: space-around; gap: .45rem; padding: .72rem .62rem; }
.resource { display: grid; grid-template-columns: auto auto; column-gap: .38rem; align-items: center; min-width: 0; }
.resource i { color: var(--gold); font-style: normal; grid-row: span 2; }
.resource span { color: #c0c9bd; font-size: .72rem; overflow-wrap: anywhere; }
.resource strong { color: #f2d29a; font-size: .96rem; font-variant-numeric: tabular-nums; }
.party-panel { flex: 1; padding: .9rem; }
.section-title { display: flex; gap: .5rem; justify-content: space-between; align-items: center; margin-bottom: .7rem; }
.section-title button { min-height: 32px; font-size: .8rem; }
.party-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.town-hero-card { text-align: left; background: #111c20; padding: .32rem; line-height: 1.15; overflow: hidden; }
.town-hero-card strong,.town-hero-card span,.town-hero-card small { display: block; padding-inline: .18rem; margin-block: .25rem; }
.town-hero-card span { font-size: .75rem; color: var(--muted); }
.portrait { background-color: #273238; background-image: var(--art); background-size: cover; background-position: center 32%; aspect-ratio: 1; border-radius: 4px; }
.town-hero-card .portrait { aspect-ratio: 1.6; }
.services { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-top: 15px; }
.service { position: relative; min-height: 114px; text-align: left; display: grid; grid-template-columns: auto 1fr auto; align-content: center; gap: .5rem; padding: .75rem;
  background-image: linear-gradient(90deg,#101c20ee,#122327d1 68%,#14222799),var(--art); }
.service-icon { align-self: start; color: var(--gold); }
.service strong { display: block; color: #f2d29a; font: 600 1.12rem Georgia,'Songti SC',serif; margin-bottom: .28rem; }
.service small { display: block; color: #d4dbd0; font-size: .76rem; }
.service > small { color: #eacc93; }
.dispatch { margin-block: 22px; padding: .8rem 0 .4rem; border-top: var(--border); }
.dispatch h2 { margin-bottom: .3rem; }
.expedition-head { margin-bottom: 13px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: .3rem 1rem; }
.expedition-head h1,.battle-heading h1 { font-size: clamp(1.55rem,3vw,2.55rem); margin-top: .2rem; }
.expedition-head .resources { gap: clamp(.7rem,3vw,2rem); }
.expedition-grid,.battle-grid { display: grid; grid-template-columns: minmax(0,2.22fr) minmax(265px,1fr); gap: 14px; }
.map,.arena { position: relative; isolation: isolate; min-height: 515px; overflow: clip; border-radius: 9px; border: 1px solid #83734f; background-image: linear-gradient(0deg,#0a181ed8,#14272d3c 52%,#10212662),var(--art); }
.map { background-image: radial-gradient(ellipse at center,#07202a25 0,#08151bc8 90%),linear-gradient(#101a2054,#131e246b),var(--art); }
.map-inner { position: absolute; inset: 11px 18px 17px; }
.map-links { width: 100%; height: 100%; pointer-events: none; position: absolute; inset: 0; overflow: visible; }
.map-links line { vector-effect: non-scaling-stroke; stroke-width: 2.65; }
.map-links .dry-edge { stroke: #efd09d; }
.map-links .tidal-edge { stroke: #78c3d6; stroke-dasharray: 6 5; }
.map-links .blocked-edge { stroke: #78c3d6; stroke-opacity: .37; stroke-dasharray: 3 5; }
.map-links .fog-edge { stroke: #82a1a4; stroke-opacity: .39; stroke-dasharray: 2 6; }
.node { position: absolute; top: var(--y); left: var(--x); transform: translate(-50%,-50%); width: 48px; height: 48px; min-height: 0; border-radius: 50%; padding: 0;
  border: 1px solid #8faab3; background: #14272e; color: var(--paper); box-shadow: 0 0 0 4px #0f1e24ab,0 4px 14px #050d12; }
.node:disabled { opacity: 1; }
.node i { font-style: normal; font-size: 1.24rem; line-height: 1; }
.node span { position: absolute; left: 50%; top: 102%; transform: translateX(-50%); display: block; width: max-content; max-width: 98px; padding: 1px 4px; border-radius: 3px; color: #f2ddba; background: #0c1a22e8; font-size: .7rem; line-height: 1.14; text-shadow: 0 1px #000; pointer-events: none; }
.node b { position: absolute; inset: auto -4px -1px auto; background: #2b4144; border: 1px solid #dbac68; border-radius: 50%; min-width: 18px; padding: 1px; font-size: .65rem; }
.node.open { color: #ffe3aa; border-color: #f3c27b; background: radial-gradient(#716045,#17282e); }
.node.current { color: #281b12; border-color: #ffe7b7; background: #f4c678; box-shadow: 0 0 0 4px #c991526e,0 0 24px #ffc8759c; z-index: 2; }
.node.resolved:not(.current):not(.open) { border-color: #a9966c; background: #273338; }
.node.unknown { width: 26px; height: 26px; color: #c3d7d9; border-color: #799393a3; opacity: .75; box-shadow: none; }
.node.unknown i { font-size: .82rem; }
.node.unknown span,.node.submerged span { display: none; }
.node.submerged { filter: saturate(.5) brightness(.74); }
.node.boss-node:not(.current) { color: #ffc1a1; }
.map-key { position: absolute; bottom: 11px; left: 14px; display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: .69rem; pointer-events: none; }
.map-key span { display: inline-flex; align-items: center; gap: 4px; }
.map-key span::before { content: ''; width: 16px; border-top: 2px solid #e4bd83; }
.map-key span+span::before { border-color: var(--teal); border-style: dashed; }
.map-compass { color: #e8d19e; position: absolute; text-align: center; top: 14px; right: 16px; font-size: .7rem; pointer-events: none; }
.map-compass b { display: block; font-size: 1.55rem; }
.expedition-side,.battle-side { display: flex; flex-direction: column; gap: 10px; }
.expedition-side .panel,.battle-side .panel { padding: .85rem; }
.expedition-side h2,.tactical h2 { margin-block: .28rem .4rem; }
.tide { margin-top: .8rem; }
.tide div:first-child { display: flex; justify-content: space-between; color: var(--teal); font-size: .83rem; }
.tide small { color: #c9d6d2; font-size: .72rem; }
.tide-meter { display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; margin: .35rem 0 .18rem; }
.tide-meter i { height: 6px; border-radius: 2px; background: #3b575e; }
.tide-meter .on { background: #94d3e1; box-shadow: 0 0 8px #70bfd866; }
.actions { display: flex; flex-wrap: wrap; gap: .44rem; align-items: center; }
.return-panel .actions { margin-top: .65rem; }
.party-field .party-grid { grid-template-columns: repeat(4,minmax(0,1fr)); text-align: center; font-size: .76rem; gap: .44rem; }
.party-field .party-grid span,.party-field .party-grid small { display: block; margin-top: .22rem; }
.party-field > p { margin-top: .6rem; font-size: .77rem; }
progress { display: block; width: 100%; height: 6px; border: 0; border-radius: 2px; overflow: hidden; accent-color: #ac684d; background: #2c3839; color: #d49571; }
progress::-webkit-progress-bar { background: #253b40; }
progress::-webkit-progress-value { background: linear-gradient(90deg,#8b4836,#f0ac85); }
progress::-moz-progress-bar { background: linear-gradient(90deg,#8b4836,#f0ac85); }
.cast-progress::-webkit-progress-value { background: #eab567; }
.cast-progress::-moz-progress-bar { background: #eab567; }
.danger { color: var(--danger); }
.battle-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: .35rem 0 .8rem; }
.battle-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.battle-controls button { white-space: nowrap; }
.arena { min-height: 500px; display: grid; grid-template-rows: 1.1fr auto .8fr; align-content: stretch; align-items: center;
  background-image: radial-gradient(ellipse at 50% 40%,#19181805 20%,#142128b0 80%),linear-gradient(#0f1c2454,#0e1a21d4),var(--art); }
.enemy-row,.ally-row { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(5px,2vw,21px); padding: 14px 10px; }
.enemy-row { align-self: center; margin-top: 39px; }
.ally-row { grid-row: 3; align-self: end; padding-bottom: 23px; }
.combat-unit { padding: 4px; width: clamp(75px,13%,119px); position: relative; background: #132027ec; border-color: #b7a77b70; text-align: center; min-height: 0; }
.combat-unit .portrait { aspect-ratio: 1; box-shadow: inset 0 0 10px #0c151a90; border: 1px solid #c8a96a4f; }
.combat-unit .unit-name { font-size: .76rem; color: #eddec0; display: block; margin-block: .3rem .25rem; line-height: 1.05; }
.combat-unit .unit-hp { display: block; margin-top: .27rem; color: #e4e8d8; font-size: .65rem; font-variant-numeric: tabular-nums; }
.boss-unit { width: clamp(112px,18%,174px); border-color: #be9c61; background: #251f1aee; }
.boss-unit .unit-name { font-size: .89rem; color: #ffce93; }
.combat-unit[aria-pressed="true"] { border-color: #ffca7c; box-shadow: 0 0 0 2px #c8873ca0,0 0 21px #e4a35068; }
.combat-unit.shielded .portrait { box-shadow: inset 0 0 0 2px #87cde3,inset 0 0 15px #a2e1ff; }
.combat-unit.fallen { filter: grayscale(1); opacity: .53; }
.unit-effect { position: absolute; top: 13%; right: 7%; pointer-events: none; color: #ffd2af; font-weight: 800; font-size: 1.25rem; text-shadow: 0 2px 3px #000,0 1px 6px #391410; }
.unit-effect[data-kind="heal"] { color: #b0e4a6; }
.boss-callout { position: absolute; z-index: 2; inset: 12px 13px auto; width: min(380px,calc(100% - 26px)); margin-inline: auto; background: #2c201add; border: 1px solid #dd9f63; box-shadow: 0 3px 20px #0007; padding: .47rem .6rem; border-radius: 5px; color: #ffcf96; }
.boss-callout > div { display: flex; justify-content: space-between; gap: 6px; font-size: .9rem; }
.boss-callout small { color: #edc6a5; font-size: .75rem; }
.boss-callout progress { margin: .3rem 0 .19rem; }
.arena-caption { justify-self: center; font-family: Georgia,'Songti SC',serif; font-size: 1.35rem; text-shadow: 0 2px 9px #000; color: #ffdf9b; padding: 6px 16px; background: #14232cd0; border: var(--border); border-radius: 4px; }
.skill-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.skill { padding: .45rem .35rem; }
.skill.ready { background: linear-gradient(140deg,#355053,#203033); border-color: #9aad8f; }
.skill strong { display: block; font-size: .81rem; }
.skill small { font-size: .68rem; color: var(--muted); }
.tactical p { margin-top: .56rem; font-size: .78rem; }
.combat-entries { flex: 1; min-height: 132px; }
.combat-entries ol { padding: 0; margin: .55rem 0 0; list-style: none; font-size: .77rem; line-height: 1.38; color: #b7c6c1; }
.combat-entries li { padding-block: .14rem; }
.combat-entries .warning { color: #ffc88f; }
.combat-entries .break,.combat-entries .heal { color: #b4dbae; }
.battle-footer { display: flex; justify-content: flex-end; }
.report { min-height: min(540px,75dvh); border: var(--border); border-radius: 8px; display: grid; place-items: center; padding: 22px; background-image: linear-gradient(#2131385e,#142024ae),var(--art); }
.report-card { width: min(510px,100%); text-align: center; padding: clamp(18px,4vw,32px); background: #18282ce9; }
.report h1 { margin-block: .55rem; font-size: clamp(1.7rem,4vw,2.6rem); }
.report-card .resources { justify-content: center; flex-wrap: wrap; gap: .7rem 1rem; margin-block: .55rem; }
.loot-list { padding: 0; list-style: none; font-size: .85rem; }
dialog { color: var(--paper); width: min(660px,calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 26px); border: 1px solid #9a916c; border-radius: 9px; padding: 0; background: #142329; box-shadow: 0 20px 70px #000b; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #071015bd; }
.panel-head { padding: 12px 14px 12px 18px; border-bottom: var(--border); display: flex; align-items: center; justify-content: space-between; background: #1c2f34; gap: 10px; }
.panel-head button { width: 40px; height: 38px; font-size: 1.4rem; padding: 0; }
#panel-body { overflow: auto; overscroll-behavior: contain; padding: 15px 18px 21px; }
#panel-body > p,#panel-body h3 { margin-block: .55rem .65rem; }
.guide-list { padding-inline-start: 1.25rem; color: #bfd0c7; }
.guide-list li { padding-block: .38rem; }
.chart-feature { border: var(--border); border-radius: 7px; min-height: 137px; display: flex; align-items: end; padding: 13px; background-image: linear-gradient(0deg,#101a1de6,#1721262f),var(--art); }
.chart-feature p { color: #e1d4b6; }
.chart-feature h3 { font-size: 1.55rem; }
.chart-choice .actions { margin-top: .62rem; }
.chart-choice > p { margin-top: .4rem; }
.chart-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .4rem .55rem; }
.chart-item { width: 100%; display: flex; justify-content: space-between; gap: .3rem; align-items: center; min-height: 35px; margin-bottom: 4px; font-size: .8rem; text-align: left; }
.chart-item small { color: #efc884; }
.item { border: var(--border); background: #1a2a2f; border-radius: 5px; padding: .55rem; margin-block: .35rem; }
.item small { display: block; font-size: .75rem; color: #b7c8c0; margin-top: .24rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.item button,.rule-entry button { min-height: 35px; font-size: .8rem; }
.roster { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .28rem .5rem; }
.roster-item { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: .45rem; font-size: .85rem; }
.hero-detail { display: grid; grid-template-columns: 114px 1fr; align-items: center; gap: .9rem; margin: .75rem 0; }
.hero-detail p { margin: .4rem 0; }
label { display: grid; gap: .2rem; color: #c7cdbd; font-size: .79rem; }
select { width: 100%; padding: .38rem .45rem; color: #eee3c5; background: #203439; border: 1px solid #7a866975; min-height: 38px; border-radius: 3px; }
.rule-entry { display: grid; gap: .35rem; }
.forge-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem; margin: .7rem 0; }
.gear .actions { margin-top: .45rem; }
.rarity-1 { color: #bde1a7; }
.rarity-2 { color: #98d4f0; }
.rarity-3 { color: #e2b1f4; }
.rarity-4 { color: #ffcb85; }
#toast { position: fixed; z-index: 20; bottom: max(18px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: min(430px,90vw); padding: .55rem .9rem; color: #ffe1a6; text-align: center; background: #1b2d32; border: 1px solid #c99b57; border-radius: 5px; box-shadow: 0 4px 18px #0008; pointer-events: none; }
.dialog-notice { color: #f2cb91; padding: .4rem 0; }
@media (max-width: 900px) {
  .town-grid { grid-template-columns: minmax(0,1.4fr) minmax(245px,1fr); }
  .services { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .service { min-height: 78px; }
  .node { width: 43px; height: 43px; }
}
@media (max-width: 670px) {
  .shell { padding-inline: max(10px,env(safe-area-inset-left)) max(10px,env(safe-area-inset-right)); }
  .town-grid,.expedition-grid,.battle-grid { grid-template-columns: 1fr; gap: 9px; }
  .town-hero { min-height: 255px; padding: 20px 15px; }
  .town-side { gap: 8px; }
  .party-panel { padding: .55rem; }
  .party-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: .38rem; }
  .town-hero-card { font-size: .81rem; }
  .town-hero-card .portrait { aspect-ratio: 1.15; }
  .town-hero-card span { font-size: .63rem; }
  .services { gap: 7px; margin-top: 9px; }
  .service { min-height: 68px; padding: .47rem; gap: .32rem; }
  .service strong { font-size: 1rem; }
  .service small { font-size: .66rem; }
  .service > small { display: none; }
  .dispatch { margin-top: 14px; }
  .resources { padding: .44rem; }
  .expedition-head { padding: 7px 8px; margin-bottom: 7px; flex-wrap: wrap; align-items: end; }
  .expedition-head .resources { justify-content: flex-start; gap: .65rem; padding: .28rem 0 0; }
  .map { min-height: clamp(332px,52dvh,460px); }
  .map-inner { inset: 8px 11px 15px; }
  .map-compass { top: 9px; right: 10px; }
  .node { width: 38px; height: 38px; }
  .node span { max-width: 69px; font-size: .59rem; }
  .node i { font-size: 1.03rem; }
  .node.unknown { width: 22px; height: 22px; }
  .expedition-side { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .expedition-side .panel,.battle-side .panel { padding: .52rem; }
  .expedition-side h2 { font-size: 1.03rem; }
  .expedition-side p { font-size: .74rem; }
  .expedition-side .actions button { min-height: 34px; padding: .25rem .4rem; font-size: .72rem; }
  .party-field { grid-column: 1/-1; }
  .party-field .portrait { aspect-ratio: 2; }
  .battle-heading { display: block; margin-top: .4rem; }
  .battle-controls { justify-content: flex-start; margin-top: .46rem; }
  .battle-controls button { min-height: 35px; padding: .3rem .42rem; font-size: .75rem; }
  .arena { min-height: clamp(282px,42dvh,360px); }
  .enemy-row,.ally-row { gap: 5px; padding: 9px 8px; }
  .enemy-row { margin-top: 33px; }
  .ally-row { padding-bottom: 10px; }
  .combat-unit { width: min(21%,86px); padding: 3px; }
  .boss-unit { width: min(31%,125px); }
  .combat-unit .unit-name { font-size: .63rem; }
  .combat-unit .unit-hp { font-size: .58rem; }
  .arena-caption { font-size: 1rem; padding: 3px 6px; }
  .battle-side { gap: 7px; }
  .tactical h2 { font-size: 1.1rem; }
  .skill-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .skill { min-height: 44px; overflow-wrap: anywhere; }
  .skill strong { font-size: .67rem; }
  .combat-entries { min-height: 0; }
  dialog { width: calc(100vw - 14px); }
  #panel-body { padding: 10px 11px 15px; }
  .roster { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
.journal-entry { padding: .6rem 0 .8rem; border-bottom: var(--border); }
.journal-entry h3 { color: var(--gold); margin-bottom: .4rem; }
