:root {
  --bg: #15110d; --panel: rgba(30, 24, 18, .92); --panel2: #261e16; --ink: #eadfc8; --dim: #a8977a;
  --rust: #c0632e; --sand: #d9b56e; --line: #5a4630; --good: #9fc46a; --bad: #e0623f; --water: #6fc3ff;
  --brass: #b88a4a; --brass-hi: #e6c27e; --edge: #0b0806;
  --f-body: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  --f-head: "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "SimSun", serif;
  --f-num: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .42 0 0 0 0 .28 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --f-hand: "KaiTi", "STKaiti", "SimKai", var(--f-head);
  /* baked materials (scripts/ui_art.py) */
  --steel: url(../art/ui/steel.webp) 0 0 / 256px;
  --brass: url(../art/ui/brass.webp) 0 0 / 192px;
  --paint: url(../art/ui/paint-rust.webp) var(--bo, 0 0) / 192px;
  --paper: url(../art/ui/paper.webp) 0 0 / 420px;
  /* HUD plate: worn steel, lit from above */
  --plate-bg: linear-gradient(180deg, rgba(255, 235, 200, .08), rgba(0, 0, 0, .22) 60%, rgba(0, 0, 0, .4)), var(--steel);
  --engrave: 0 -1px 0 rgba(0, 0, 0, .85), 0 1px 0 rgba(255, 230, 190, .12);
  --emboss-dark: 0 1px 0 rgba(255, 238, 200, .45), 0 -1px 0 rgba(60, 30, 0, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--f-body); }
html, body { cursor: url(../art/ui/cursor.png) 2 2, default; }
button, .card, label, select, .map3d-label, [data-close], input[type=checkbox], input[type=range] { cursor: url(../art/ui/cursor-hover.png) 2 2, pointer; }
input[type=text] { cursor: text; }
body { user-select: none; -webkit-user-select: none; }
input, textarea, .log-list { user-select: text; -webkit-user-select: text; }
::selection { background: rgba(192, 99, 46, .55); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: #7a6448 rgba(0, 0, 0, .35); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, .4); box-shadow: inset 0 0 4px #000; border-radius: 6px; }
::-webkit-scrollbar-thumb { background: linear-gradient(90deg, rgba(255, 235, 200, .25), rgba(0, 0, 0, .3)), url(../art/ui/steel.webp) 0 0 / 128px; border: 2px solid rgba(0, 0, 0, .6); border-radius: 6px; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }

#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; overflow: hidden; }
#map > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#map.is3d { background: #1d2a2e; }
/* darkened screen edges over the map, so the HUD reads and the world feels framed */
#vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 120% 95% at 50% 50%, transparent 58%, rgba(10, 6, 3, .55) 100%),
    linear-gradient(180deg, rgba(10, 6, 3, .45), transparent 90px, transparent calc(100% - 120px), rgba(10, 6, 3, .5)); }
body[data-screen=title] #vignette { display: none; }
.map3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map3d-label { position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: auto; user-select: none;
  color: #f6ecd6; font-weight: 600; letter-spacing: .04em; padding: 0 .5em; line-height: 1.5; border-radius: 3px;
  background: rgba(24, 18, 12, .66); border-bottom: 2px solid var(--fc, #c9a24a);
  text-shadow: 0 1px 2px rgba(0,0,0,.9); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); will-change: transform; }
/* town names hang on little riveted steel signs */
.map3d-label.town { padding: 1px 1.1em 0; letter-spacing: .14em; font-family: var(--f-head); font-weight: 900; color: #f3e2bc; text-shadow: var(--engrave); border-radius: 4px;
  background: radial-gradient(circle at 6px 50%, #c8b090 0 1.6px, #2a1c10 2.2px, transparent 2.8px), radial-gradient(circle at calc(100% - 6px) 50%, #c8b090 0 1.6px, #2a1c10 2.2px, transparent 2.8px),
    linear-gradient(180deg, rgba(255, 235, 200, .12), rgba(0, 0, 0, .35)), url(../art/ui/steel.webp) 0 0 / 160px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, .25), inset 0 -1px 0 rgba(0, 0, 0, .6), 0 0 0 1px #0b0806, 0 3px 6px rgba(0, 0, 0, .6); }
.map3d-label.hover { background: rgba(70, 46, 24, .9); color: #fff; }
.map3d-label.town.hover { filter: brightness(1.35); background: radial-gradient(circle at 6px 50%, #c8b090 0 1.6px, #2a1c10 2.2px, transparent 2.8px), radial-gradient(circle at calc(100% - 6px) 50%, #c8b090 0 1.6px, #2a1c10 2.2px, transparent 2.8px),
    linear-gradient(180deg, rgba(255, 235, 200, .12), rgba(0, 0, 0, .35)), url(../art/ui/steel.webp) 0 0 / 160px; }
.map3d-label.beast { pointer-events: none; font-size: 11px; background: rgba(60, 22, 14, .72); color: #f0c8b0; }
.map3d-label.beast.chase { background: rgba(150, 40, 20, .88); color: #fff; }
.map3d-label.contract::after { content: ''; display: inline-block; width: .55em; height: .55em; margin-left: .4em; border-radius: 50%; background: var(--water); box-shadow: 0 0 6px var(--water); vertical-align: .05em; }
.map3d-tip { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; background: rgba(27,23,18,.85); color: #eadfc8; font-size: 12px; line-height: 20px; border-radius: 2px; pointer-events: none; }
/* ---------- buttons: a baked bevel (border-image) over a material fill ---------- */
button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  color: var(--ink); font: inherit; padding: 2px 9px; text-shadow: var(--engrave);
  border: 3px solid transparent; border-radius: 6px; border-image: url(../art/ui/bevel.png) 16 / 8px round;
  background: linear-gradient(180deg, rgba(255, 235, 200, .07), rgba(0, 0, 0, .18)), url(../art/ui/steel.webp) var(--bo, 0 0) / 256px;
  background-origin: border-box; background-clip: border-box;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .55);
  transition: filter .12s, box-shadow .12s, transform .06s; }
button:nth-child(3n+2) { --bo: -83px -41px; } button:nth-child(3n) { --bo: -170px -118px; }
button[hidden] { display: none; }
button:hover:not(:disabled) { filter: brightness(1.25) saturate(1.1); box-shadow: 0 2px 3px rgba(0, 0, 0, .55), 0 0 10px rgba(230, 150, 70, .35); }
button:active:not(:disabled) { transform: translateY(1px); border-image-source: url(../art/ui/bevel-in.png); box-shadow: 0 1px 1px rgba(0, 0, 0, .6); filter: brightness(.95); }
button:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }
button:disabled { opacity: .5; filter: grayscale(.6) brightness(.85); }
button.primary { color: #fff1dc; font-weight: 700; letter-spacing: .05em; text-shadow: 0 -1px 0 rgba(40, 10, 0, .9), 0 1px 0 rgba(255, 200, 150, .2);
  background: linear-gradient(180deg, rgba(255, 220, 170, .14), rgba(60, 15, 0, .18)), url(../art/ui/paint-rust.webp) var(--bo, 0 0) / 192px; }
button.active { color: #2a1a08; font-weight: 600; text-shadow: var(--emboss-dark);
  background: linear-gradient(180deg, rgba(255, 245, 210, .22), rgba(60, 35, 0, .12)), url(../art/ui/brass.webp) var(--bo, 0 0) / 192px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .55), 0 0 8px rgba(230, 190, 110, .3); }
button.danger { color: #ffd2c0; text-shadow: 0 -1px 0 rgba(30, 0, 0, .9);
  background: linear-gradient(180deg, rgba(255, 200, 170, .1), rgba(40, 0, 0, .2)), url(../art/ui/paint-red.webp) var(--bo, 0 0) / 192px; }
button.ghost { background: none; border-image: none; border-color: transparent; box-shadow: none; color: var(--dim); }
input[type=text], select { background: linear-gradient(180deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .35)), var(--steel); color: var(--ink); border: 1px solid #000; border-radius: 4px; padding: 6px 9px; font: inherit;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 220, 160, .12); }
select option { background: #1d1711; }
input[type=text] { width: 220px; }
input[type=text]:focus, select:focus { outline: none; border-color: var(--rust); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 0 0 2px rgba(192, 99, 46, .35); }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 2; }
body[data-screen=title] .hud, body[data-screen=title] #map { display: none !important; }
/* a screwed-down steel plate: the frame is baked, the fill is the steel tile */
.plate, .frame-plate { border: 6px solid transparent; border-image: url(../art/ui/frame-plate.png) 32 / 16px round; border-radius: 8px;
  background: var(--plate-bg); background-origin: border-box; box-shadow: 0 4px 12px rgba(0, 0, 0, .6); }
#hud-top { top: 8px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: stretch; pointer-events: none; }
#hud-top > * { pointer-events: auto; }
#clock { display: flex; align-items: center; gap: 9px; padding: 2px 16px 2px 8px; min-width: 176px; font-family: var(--f-num); }
/* the sun/moon sits in a brass-rimmed socket */
#clock .ico { width: 34px; height: 34px; padding: 6px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a2219, #0c0906 75%);
  box-shadow: inset 0 2px 4px #000, 0 0 0 2px #1a120a, 0 0 0 4px #9a7038, 0 0 0 5px #2a1c0c, 0 1px 0 5px rgba(255, 220, 160, .25); }
#clock .sun { color: #ffcf6a; filter: drop-shadow(0 0 4px rgba(255, 190, 80, .6)); }
#clock .moon { color: #b9cbe6; filter: drop-shadow(0 0 4px rgba(150, 180, 230, .5)); }
#clock .day { font-size: 21px; font-weight: 700; color: var(--brass-hi); line-height: 1; text-shadow: var(--engrave); }
#clock .day small { font: 12px var(--f-body); color: var(--dim); margin: 0 2px; }
#clock .time { font-size: 18px; color: #ffd890; letter-spacing: .06em; padding: 1px 7px; border-radius: 3px; background: #0b0805;
  box-shadow: inset 0 1px 3px #000, 0 1px 0 rgba(255, 220, 160, .15); text-shadow: 0 0 6px rgba(255, 180, 70, .55); }
#res { display: flex; flex: 1; min-width: 0; padding: 0 8px; align-items: center; }
#res .chip { display: flex; align-items: center; gap: 6px; padding: 2px 9px 2px 5px; position: relative; cursor: default; border-radius: 14px; }
#res .chip + .chip::before { content: ''; position: absolute; left: -1px; top: 18%; bottom: 18%; width: 2px; background: rgba(0, 0, 0, .55); box-shadow: 1px 0 0 rgba(255, 225, 180, .1); }
#res .chip .ico { width: 28px; height: 28px; padding: 4px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(255, 230, 190, .08), rgba(0, 0, 0, .65) 70%);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, .9), inset 0 -1px 0 rgba(255, 225, 180, .12), 0 1px 0 rgba(255, 225, 180, .1);
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6)); }
#res .chip .v { display: flex; flex-direction: column; line-height: 1.05; }
#res .chip b { font: 600 16px var(--f-num); color: #f3e6c8; white-space: nowrap; text-shadow: var(--engrave); }
#res .chip b em { font: 600 11px var(--f-body); font-style: normal; color: #fff; background: var(--bad); border-radius: 3px; padding: 0 3px; margin-left: 3px; vertical-align: 2px; }
#res .chip small { font-size: 10px; color: var(--dim); letter-spacing: .1em; }
#res .caps .ico { color: #d9b56e; } #res .water .ico { color: #6fc3ff; } #res .food .ico { color: #c9a26a; }
#res .fuel .ico { color: #d0643a; } #res .parts .ico { color: #a9b2b8; } #res .people .ico { color: #e8d8b8; }
#res .medicine .ico { color: #e85a5a; } #res .morale .ico { color: #9fc46a; } #res .cargo .ico { color: #b88a4a; }
#res .chip.low b { color: #ff7a55; }
#res .chip.low { animation: low-pulse 1.4s ease-in-out infinite; }
@keyframes low-pulse { 50% { background: rgba(224, 98, 63, .2); } }
#speedbar { display: flex; padding: 3px 9px; gap: 3px; align-items: center; }
#speedbar button { padding: 4px 8px; }
#speedbar .ico { width: 15px; height: 15px; }
#wind { display: flex; align-items: center; gap: 5px; color: var(--brass-hi); font-size: 13px; white-space: nowrap; cursor: default; text-shadow: var(--engrave);
  padding: 2px 14px; border: 6px solid transparent; border-image: url(../art/ui/frame-plate.png) 32 / 16px round; border-radius: 8px;
  background: var(--plate-bg); background-origin: border-box; box-shadow: 0 4px 12px rgba(0, 0, 0, .6); }
#wind .arr { display: inline-block; width: 1em; text-align: center; transition: transform .6s; font-size: 16px; }
#wind.storm { color: var(--bad); animation: low-pulse 1.4s ease-in-out infinite; }
/* travel panel, top right */
#hud-side { top: 76px; right: 10px; width: 304px; max-height: calc(100vh - 196px); overflow-y: auto; padding: 8px 4px 8px; font-size: 13px;
  border: 6px solid transparent; border-image: url(../art/ui/frame-plate.png) 32 / 16px round; border-radius: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .25), rgba(0, 0, 0, .45)), var(--steel); background-origin: border-box; box-shadow: 0 6px 16px rgba(0, 0, 0, .6); }
#travel-fold { position: absolute; top: 9px; right: 12px; z-index: 1; padding: 1px 3px; color: #2a1a08; }
#travel-fold .ico { width: 14px; height: 14px; transition: transform .2s; transform: rotate(180deg); }
#hud-side.folded #travel-fold .ico { transform: none; }
#hud-side.folded #travel .note { display: none; }
/* location name on a brass strip */
#travel h3 { margin: 0 6px 8px; padding: 4px 40px 4px 22px; font: 900 15px var(--f-head); letter-spacing: .18em; color: #2a1a08; text-shadow: var(--emboss-dark);
  border: 0 solid transparent; border-image: url(../art/ui/nameplate.png) 24 40 fill / 12px 20px round;
  min-height: 36px; display: flex; align-items: center; }
#travel > :not(h3) { margin-left: 10px; margin-right: 10px; }
#travel .row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
#travel .row b { font: 600 15px var(--f-num); color: #f3e6c8; }
#travel .note { color: var(--dim); font-size: 12px; line-height: 1.5; }
#travel .note.good { color: var(--good); }
#travel .warn { color: #ffb39a; font-size: 12px; margin-top: 3px; padding: 2px 8px; border-left: 3px solid var(--bad); background: linear-gradient(90deg, rgba(224, 98, 63, .22), transparent); border-radius: 0 3px 3px 0; }
/* action bar, bottom centre */
#forage-row { left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#forage-row > * { pointer-events: auto; }
#forage-row .note { font-size: 12px; color: var(--ink); background: rgba(14, 10, 7, .8); padding: 2px 12px; border-radius: 10px; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px #000;
  box-shadow: inset 0 1px 2px #000, 0 1px 0 rgba(255, 220, 160, .12); }
#forage-row .note:empty { display: none; }
#forage-row .bar, #side-buttons { display: flex; gap: 8px; padding: 6px 10px;
  border: 6px solid transparent; border-image: url(../art/ui/frame-plate.png) 32 / 16px round; border-radius: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .3), rgba(0, 0, 0, .5)), var(--steel); background-origin: border-box; box-shadow: 0 5px 14px rgba(0, 0, 0, .65); }
button.act { flex-direction: column; gap: 2px; min-width: 78px; padding: 5px 10px 4px; font-size: 13px; font-weight: 600; }
button.act .ico, #side-buttons .ico { width: 24px; height: 24px; color: var(--brass-hi); filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .9)) drop-shadow(0 1px 0 rgba(255, 230, 190, .18)); }
#fish-cast .ico { color: var(--water); } #site-work .ico { color: #d0a070; }
/* hotkey badge: a little brass key cap */
button[data-key]::after { content: attr(data-key); position: absolute; top: -9px; right: -9px; min-width: 18px; padding: 0 4px; border-radius: 4px;
  font: 700 10px/16px var(--f-num); color: #2a1a08; text-shadow: var(--emboss-dark);
  background: linear-gradient(180deg, rgba(255, 245, 210, .35), rgba(60, 35, 0, .2)), url(../art/ui/brass.webp) 0 0 / 96px;
  box-shadow: inset 0 1px 0 rgba(255, 245, 210, .5), inset 0 -1px 0 rgba(60, 30, 0, .4), 0 0 0 1px #1a1008, 0 2px 2px rgba(0, 0, 0, .7); pointer-events: none; }
/* menu buttons, bottom right */
#side-buttons { right: 12px; bottom: 16px; }
#side-buttons button { flex-direction: column; gap: 1px; width: 60px; padding: 4px 0 3px; font-size: 12px; }
#side-buttons .ico { width: 22px; height: 22px; }
/* toast: a stamped dog tag hanging under the top bar */
#toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -8px); z-index: 6; max-width: min(620px, 56vw); text-align: center;
  padding: 5px 28px; color: #f6ecd6; text-shadow: var(--engrave); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
  border: 6px solid transparent; border-image: url(../art/ui/frame-plate.png) 32 / 16px round; border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 235, 200, .06), rgba(0, 0, 0, .3)), var(--steel); background-origin: border-box; box-shadow: 0 6px 16px rgba(0, 0, 0, .7); }
#toast:empty { display: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body:has(#screen:not([hidden])) #toast { top: auto; bottom: 24px; }
@media (max-width: 1360px) {
  #res .chip small { display: none; }
  #res .chip { padding: 4px 7px; }
  #clock { min-width: 0; }
}
@media (max-width: 1080px) { #side-buttons span { display: none; } #side-buttons button { width: 42px; } }
/* ---------- screens ---------- */
#screen { position: fixed; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(20, 14, 9, .5), rgba(8, 5, 3, .85)); }
#screen[hidden] { display: none; }
/* title and character creation: concept paintings, slowly panning and crossfading */
#title-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #0c0805; display: none; }
body[data-screen=title] #title-bg { display: block; }
#title-bg i { position: absolute; inset: -4%; background: center / cover no-repeat; opacity: 0; animation: kb 40s linear infinite; }
#title-bg .a { background-image: url(../art/ui/title-floating-city.webp); animation-delay: 0s; }
#title-bg .b { background-image: url(../art/ui/title-town-scorpion.webp); animation-delay: 10s; }
#title-bg .c { background-image: url(../art/ui/title-coast.webp); animation-delay: 20s; }
#title-bg .d { background-image: url(../art/ui/title-town-anvil.webp); animation-delay: 30s; }
@keyframes kb { 0% { opacity: 0; transform: scale(1.02) translate(0, 0); } 6%, 25% { opacity: 1; } 31%, 100% { opacity: 0; transform: scale(1.12) translate(-1.5%, -1%); } }
body[data-screen=title] #screen { overflow: hidden;
  background: radial-gradient(ellipse 70% 60% at 50% 46%, rgba(10, 6, 3, .2), rgba(10, 6, 3, .55) 60%, rgba(6, 4, 2, .9) 100%),
    linear-gradient(180deg, rgba(10, 6, 3, .55), transparent 30%, transparent 65%, rgba(10, 6, 3, .75)); }
body[data-screen=title] #screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--grain); opacity: .8; animation: drift 30s linear infinite; }
@keyframes drift { to { background-position: 320px 80px; } }
#screen > * { position: relative; z-index: 1; }
.title-menu { display: flex; flex-direction: column; align-items: center; margin-bottom: 4vh; animation: rise .8s ease-out both; }
/* cast-iron letters with a hot rim */
.title-menu .logo { margin: 0; font: 900 clamp(60px, 9.5vw, 112px)/1.05 var(--f-head); letter-spacing: .14em; padding-left: .14em;
  background: linear-gradient(180deg, rgba(255, 220, 160, .9) 0%, rgba(230, 150, 80, .5) 30%, rgba(80, 30, 10, .2) 52%, rgba(255, 170, 90, .35) 74%, rgba(30, 10, 0, .4) 100%), url(../art/ui/paint-rust.webp) 0 0 / 220px;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1px rgba(40, 14, 2, .8);
  filter: drop-shadow(0 2px 0 #1a0a03) drop-shadow(0 4px 0 #2a1206) drop-shadow(0 10px 22px rgba(0, 0, 0, .9)); }
.title-menu .tagline { margin: 8px 0 26px; color: #ecd6aa; letter-spacing: .35em; font-size: 15px; text-shadow: 0 2px 4px #000, 0 0 12px #000; }
.title-menu .tagline::before, .title-menu .tagline::after { content: ''; display: inline-block; width: 60px; height: 2px; margin: 0 14px; vertical-align: middle; background: linear-gradient(90deg, transparent, var(--brass-hi)); box-shadow: 0 1px 0 #000; }
.title-menu .tagline::after { transform: scaleX(-1); }
.title-menu .menu { display: flex; flex-direction: column; gap: 8px; width: 330px; padding: 20px 22px; }
.title-menu .menu button { padding: 7px 16px; font-size: 16px; letter-spacing: .12em; }
.title-menu .menu button.primary { font-size: 20px; font-weight: 900; font-family: var(--f-head); padding: 9px 16px; letter-spacing: .2em; }
.title-menu .menu button.ghost { font-size: 13px; }
.title-menu .build { margin: 18px 0 0; font-size: 11px; letter-spacing: .1em; color: rgba(234, 223, 200, .45); text-shadow: 0 1px 2px #000; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
/* panels: a heavy riveted steel frame (baked 9-slice) around a dark, worn steel sheet */
.panel, .title-menu .menu { border: 26px solid transparent; border-image: url(../art/ui/frame-panel.png) 52 / 26px round; border-radius: 7px;
  background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(40, 30, 20, .55), rgba(14, 10, 7, .8) 70%, rgba(8, 6, 4, .88)), var(--steel);
  background-origin: border-box; box-shadow: 0 18px 60px rgba(0, 0, 0, .8), 0 0 0 1px rgba(0, 0, 0, .6); }
.panel { width: min(880px, 94vw); max-height: 88vh; overflow-y: auto; padding: 6px 14px 10px; color: var(--ink); }
#screen.fresh > .panel { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.panel h1 { margin: 0 0 4px; color: var(--rust); letter-spacing: 6px; font: 900 34px var(--f-head); }
/* titles are stamped into a screwed-on brass plate */
.panel h2 { display: flow-root; width: fit-content; max-width: 100%; margin: 2px 0 12px; padding: 0 34px; min-height: 40px; line-height: 40px;
  font: 900 21px/40px var(--f-head); letter-spacing: .1em; color: #2b1a08; text-shadow: var(--emboss-dark);
  border: 0 solid transparent; border-image: url(../art/ui/nameplate.png) 24 40 fill / 12px 20px round;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .7)); }
.panel h2 .tag { color: var(--ink); border-color: rgba(0, 0, 0, .7); background: rgba(22, 14, 6, .82); box-shadow: inset 0 1px 2px #000, 0 1px 0 rgba(255, 240, 200, .35); text-shadow: none; vertical-align: 2px; letter-spacing: 0; }
.panel h2 small, .panel h2 .dim { color: #4a3216; text-shadow: none; }
/* section headings: stencilled paint with a welded seam underneath */
.panel h3 { margin: 18px 0 8px; padding: 0 0 5px 22px; font: 700 14px var(--f-head); letter-spacing: .16em; color: var(--brass-hi); text-shadow: var(--engrave); position: relative;
  border-bottom: 2px solid rgba(0, 0, 0, .55); box-shadow: 0 1px 0 rgba(255, 225, 180, .1); }
.panel h3::before { content: ''; position: absolute; left: 3px; top: .38em; width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0d8a0, #9a7038 45%, #3a2410 80%); box-shadow: 0 1px 1px #000; }
.panel p { margin: 4px 0 8px; }
/* what people say: a quote set into a recessed slot */
.panel p.greeting { position: relative; padding: 8px 14px 8px 40px; color: #f0dca8; font-family: var(--f-head); font-size: 15px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, .28)); border-radius: 6px; border: 1px solid rgba(0, 0, 0, .7);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .7), 0 1px 0 rgba(255, 225, 180, .1); }
.panel p.greeting::before { content: '“'; position: absolute; left: 10px; top: -4px; font: 900 44px/1 var(--f-head); color: var(--brass); opacity: .75; text-shadow: 0 2px 2px #000; }
.dim { color: var(--dim); }
.good { color: var(--good); } .bad { color: var(--bad); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
/* cards are loose steel plates: raised bevel, lift on hover, brass when chosen */
.card { position: relative; padding: 6px 12px; border: 4px solid transparent; border-image: url(../art/ui/bevel.png) 16 / 8px round; border-radius: 6px;
  background: linear-gradient(180deg, rgba(30, 24, 18, .42), rgba(10, 8, 6, .62)), url(../art/ui/steel.webp) var(--bo, 0 0) / 256px; background-origin: border-box;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .55); transition: transform .12s, box-shadow .12s, filter .12s; }
.card:nth-child(3n+2) { --bo: -97px -53px; } .card:nth-child(3n) { --bo: -181px -140px; }
.card:hover { transform: translateY(-2px); filter: brightness(1.15); box-shadow: 0 8px 14px rgba(0, 0, 0, .6), 0 0 10px rgba(230, 150, 70, .25); }
.card.sel { background: linear-gradient(180deg, rgba(150, 105, 45, .5), rgba(70, 42, 14, .55) 50%, rgba(20, 12, 4, .6)), url(../art/ui/steel.webp) var(--bo, 0 0) / 256px;
  box-shadow: 0 0 0 2px var(--brass-hi), 0 0 18px rgba(230, 190, 110, .4), 0 3px 6px rgba(0, 0, 0, .55); }
.card.sel::after { content: '✓'; position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; text-align: center; font: 900 13px/22px var(--f-body); color: #2a1a08;
  background: radial-gradient(circle at 35% 30%, #fff0c0, #d0a050 45%, #7a5020 90%); box-shadow: 0 1px 2px #000, inset 0 -1px 1px rgba(60, 30, 0, .5); }
.card b { color: var(--brass-hi); font-family: var(--f-head); font-size: 16px; text-shadow: var(--engrave); }
.card p { text-shadow: 0 1px 1px rgba(0, 0, 0, .6); }
/* tables: a recessed well cut into the sheet */
table { border-collapse: separate; border-spacing: 0; width: 100%; margin: 4px 0; border-radius: 6px; overflow: hidden;
  background: linear-gradient(180deg, rgba(0, 0, 0, .5), rgba(0, 0, 0, .32)); border: 1px solid rgba(0, 0, 0, .8);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .75), 0 1px 0 rgba(255, 225, 180, .1); }
td, th { padding: 5px 8px; border-bottom: 1px solid rgba(0, 0, 0, .55); box-shadow: 0 1px 0 rgba(255, 225, 180, .04); text-align: left; vertical-align: middle; }
tr:last-child > td { border-bottom: 0; box-shadow: none; }
tr:nth-child(even) > td { background: rgba(255, 220, 160, .03); }
tr:hover > td { background: rgba(230, 170, 90, .09); }
th { color: var(--brass); font-weight: 600; font-size: 12px; letter-spacing: .1em; background: rgba(0, 0, 0, .4); text-shadow: var(--engrave); }
td button { padding: 0 8px; font-size: 13px; border-image-width: 6px; }
td button + button { margin-left: 4px; }
[data-buy], [data-vbuy], [data-gbuy] { color: #d8f0b8; }
[data-sell], [data-vsell] { color: #ffd0b8; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.close { float: right; margin: 0 0 6px 10px; z-index: 2; }
/* the log is a ledger: stained paper, ruled lines, ink */
.log-list { font-size: 13px; color: #3a2a18; padding: 10px 14px 10px 34px; border-radius: 3px; position: relative;
  background: linear-gradient(90deg, transparent 24px, rgba(160, 40, 20, .35) 24px, rgba(160, 40, 20, .35) 25px, transparent 25px),
    radial-gradient(ellipse at 50% 40%, transparent 55%, rgba(90, 55, 20, .35)), var(--paper);
  box-shadow: inset 0 0 0 1px rgba(80, 50, 20, .4), inset 0 0 30px rgba(90, 55, 20, .35), 0 4px 12px rgba(0, 0, 0, .7); }
.log-list > div { padding: 3px 4px; border-bottom: 1px solid rgba(70, 90, 120, .28); line-height: 1.5; }
.log-list .good { color: #2f5a14; } .log-list .bad { color: #9a2410; }
.log-list .dim, .log-list small { color: #6a5434; }
.tag { display: inline-block; font: 400 11px/1.6 var(--f-body); padding: 0 7px; border-radius: 9px; border: 1px solid rgba(0, 0, 0, .6); background: rgba(0, 0, 0, .4); color: var(--dim); margin-left: 4px; letter-spacing: 0; vertical-align: 3px; text-shadow: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .7), 0 1px 0 rgba(255, 225, 180, .1); }
/* settlement tabs: steel keys on a rail, the open one in brass */
.tabs { display: flex; gap: 4px; margin: 8px 0 12px; padding: 4px; border-radius: 7px; align-items: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .35)); border: 1px solid rgba(0, 0, 0, .8); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 225, 180, .1); }
.tabs button { padding: 3px 14px; color: var(--dim); }
.tabs button.active { color: #2a1a08; }
.tabs [data-wait] { margin-left: auto; color: var(--ink); }
.name-row { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; color: var(--sand); margin-bottom: 4px; }

/* meetings on the road */
.panel p.greeting.bad { color: #ffb39a; border-left-color: var(--bad); background: linear-gradient(90deg, rgba(224, 98, 63, .16), transparent 80%); }
.map3d-label.folk { font-size: 11px; background: rgba(24, 18, 12, .7); color: #f2e6cc; }
.map3d-label.folk:hover { background: rgba(70, 46, 24, .9); color: #fff; }
.map3d-label.folk.hostile { background: rgba(150, 40, 20, .88); color: #fff; }
.map3d-label.folk.escort { background: rgba(70, 52, 24, .9); color: #fff4d8; box-shadow: 0 0 6px rgba(255, 230, 170, .55); }
.fish-panel { width: min(900px, 96vw); }
.fish-panel .fish-where { font-size: 13px; font-weight: normal; }
#fish-canvas { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid #000; border-radius: 3px; box-shadow: 0 0 0 1px rgba(184, 138, 74, .35), 0 4px 14px rgba(0, 0, 0, .5); touch-action: none; cursor: pointer; user-select: none; }
.fish-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.fish-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid rgba(184, 138, 74, .3); background: rgba(0, 0, 0, .25); border-radius: 12px; font-size: 13px; }
.fish-ico { width: 22px; height: 22px; object-fit: contain; }
.fish-ico.wide { width: 40px; }
.fish-catches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fish-dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 10px; }
.fish-dex > p { grid-column: 1 / -1; margin: 0; }
.fish-dex-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border: 1px solid #000; box-shadow: inset 0 0 0 1px rgba(184, 138, 74, .2); background: rgba(0, 0, 0, .2); border-radius: 4px; font-size: 12px; }
.fish-dex-cell .fish-ico.wide { width: 96px; height: 48px; }
.fish-dex-cell.unknown img { filter: brightness(0) opacity(.35); }
.map3d-label.site { pointer-events: none; font-size: 11px; background: rgba(40, 32, 18, .72); color: #f0dca8; border-bottom-color: #c9a24a; }
.map3d-label.site.fish { color: #cfe4e2; background: rgba(18, 34, 38, .72); border-bottom-color: #7aa0a8; }
.map3d-label.site.done { color: #a89f92; background: rgba(30, 28, 26, .6); border-bottom-color: #6a6460; }
.site-table th { white-space: nowrap; padding-right: 10px; }
/* settlement banner: small 3D scene of the place (town3d.js) */
.town-banner { position: relative; height: 170px; margin: -2px -10px 12px; border-radius: 4px; overflow: hidden; border: 1px solid #000; background: linear-gradient(#3a3026, #241d16 70%, #2e251b);
  box-shadow: 0 0 0 2px rgba(255, 225, 180, .08), 0 3px 8px rgba(0, 0, 0, .7); }
.town-banner[hidden] { display: none; }
.town-banner canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .4s; }
.town-banner canvas.ready { opacity: 1; }
.town-banner::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 -30px 30px -18px rgba(20, 15, 10, .85), inset 0 0 60px rgba(0, 0, 0, .35); }
.panel:has(> .town-banner) { position: relative; }
.panel:has(> .town-banner) > .close { position: absolute; top: 12px; right: 14px; }
/* the town name plate overlaps the bottom of the banner like a sign bolted to it */
.panel > .town-banner + .close + h2, .panel > .town-banner + h2 { margin-top: -34px; position: relative; z-index: 1; margin-left: 6px; }
.panel > .town-banner:is([hidden]) + .close + h2, .panel > .town-banner:is([hidden]) + h2 { margin-top: 2px; }
@media (max-height: 640px) { .town-banner { height: 120px; } }
/* onboarding hint card (hints.js) */
/* a scrap of paper taped to the screen, with a red stamp */
#hint-card { position: fixed; left: 16px; bottom: 18px; z-index: 5; width: min(320px, 80vw); padding: 16px 18px 14px; font-size: 13.5px; color: #3a2814; border-radius: 2px;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(110, 70, 25, .35)), var(--paper); background-position: 0 0, -140px -60px;
  box-shadow: inset 0 0 22px rgba(110, 70, 25, .35), 0 1px 1px rgba(0, 0, 0, .4), 0 10px 22px rgba(0, 0, 0, .65);
  transform: rotate(-1.2deg); animation: note-in .35s ease-out; }
@keyframes note-in { from { opacity: 0; transform: translateY(14px) rotate(-3deg); } }
#hint-card::before { content: ''; position: absolute; top: -12px; left: 50%; width: 104px; height: 26px; margin-left: -52px; transform: rotate(2.5deg);
  background: url(../art/ui/tape.png) center / 100% 100%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }
#hint-card::after { content: '提示'; position: absolute; top: 8px; right: 12px; padding: 1px 6px; font: 900 13px/1.3 var(--f-head); letter-spacing: .1em; color: rgba(170, 30, 15, .78);
  border: 2px solid rgba(170, 30, 15, .7); border-radius: 3px; transform: rotate(8deg); mix-blend-mode: multiply; }
#hint-card[hidden] { display: none; }
body:not([data-screen="map"]) #hint-card { display: none; }
/* the town hint sits over the settlement screen: the panel stops above it */
body:has(#hint-card:not([hidden])) #screen > .panel { max-height: calc(88vh - 180px); margin-bottom: 180px; }
#hint-card .t { display: block; padding-right: 46px; color: #2a1a08; font: 900 17px/1.3 var(--f-hand); }
#hint-card p { margin: 6px 0 0; line-height: 1.6; font-family: var(--f-hand); font-size: 15px; }
#hint-card .actions { margin-top: 10px; }
#hint-card .dim { color: #6a5434; } #hint-card .good { color: #2f5a14; } #hint-card .bad { color: #9a2410; }
#hint-card b:not(.t) { color: #7a2a10; }
/* alerts that pause the game (alerts.js, ui-ux.js) */
.alert-box { width: min(480px, 94vw);
  background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(110, 20, 5, .55), rgba(20, 6, 3, .82) 70%, rgba(8, 4, 2, .9)), var(--steel); background-origin: border-box;
  box-shadow: 0 0 50px rgba(224, 98, 63, .3), 0 18px 60px rgba(0, 0, 0, .8); }
.alert-box h2 { color: #6a1206; }
.alert-box h2::before { content: '⚠ '; }
.alert-item { border-left: 3px solid var(--bad); padding: 4px 12px; margin: 8px 0; background: linear-gradient(90deg, rgba(224, 98, 63, .12), transparent 80%); }
.alert-item b { color: var(--sand); }
.log-list .alert { font-weight: 600; border-left: 3px solid var(--bad); padding-left: 6px; background: rgba(214,90,58,.1); }
/* settings */
.set-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.set-row > span:first-child { min-width: 72px; }
.set-row input[type=range] { flex: 1; accent-color: var(--rust); }
.set-row input[type=checkbox] { accent-color: var(--rust); width: 16px; height: 16px; }
.set-row b { min-width: 3em; text-align: right; color: var(--sand); font: 400 14px var(--f-num); }
.keys .row { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px solid rgba(90,70,48,.35); font-size: 13px; }
.keys .row > span:first-child { min-width: 150px; color: var(--dim); }
.keys .tag { margin-left: 0; min-width: 2.6em; text-align: center; border-radius: 3px; font: 700 12px/1.6 var(--f-num); color: #1b1309; background: linear-gradient(180deg, #ecd08f, #b88a4a); border-color: #3b2a12; vertical-align: 0; }
/* enclave trades (deep.js): keep the trade button on one line when the item text is long */
[data-trade] { white-space: nowrap; }
/* commissions tab and clue journal (ui-quests.js) */
.panel p.standing-hint { margin-top: -4px; }
.quest-table td:nth-child(3) { white-space: nowrap; }
.quest-table td:last-child { white-space: nowrap; text-align: right; }
ol.clues { margin: 4px 0 8px; padding-left: 22px; }
ol.clues li { color: var(--dim); margin: 2px 0; }
ol.clues li.done { color: var(--good); }
ol.clues li.current { color: var(--sand); font-weight: 600; }
/* battle screen (ui-battle.js) */
.panel.battle { width: min(920px, 96vw); }
.battle-wrap { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.battle-board { max-width: 100%; height: auto; box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(184, 138, 74, .4), 0 6px 18px rgba(0, 0, 0, .55); border-radius: 3px; flex: none; }
.battle-side { flex: 1 1 260px; min-width: 240px; }
.panel p.battle-count { margin: 0 0 6px; color: var(--sand); font-family: var(--f-num); font-size: 15px; }
.battle-small { font-size: 12px; }
.battle-orders { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.battle-order { display: flex; gap: 8px; align-items: baseline; }
.battle-order button { min-width: 6.5em; flex: none; }
.battle-orders[hidden], .battle-result[hidden] { display: none; }
.battle-result h3 { margin-top: 4px; }
ol.battle-log { margin: 8px 0 0; padding: 4px 8px; list-style: none; max-height: 190px; overflow-y: auto; font-size: 12px; color: var(--dim); background: rgba(0, 0, 0, .25); border-radius: 3px; }
ol.battle-log li { padding: 2px 0; border-bottom: 1px solid rgba(90,70,48,.3); }
ol.battle-log li.good { color: var(--good); } ol.battle-log li.bad { color: var(--bad); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.map3d-recovery { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); max-width: 80%; padding: 8px 12px; border: 1px solid #657b72; border-radius: 4px; background: #172e30; color: #e6ddbb; font-size: 13px; z-index: 5; pointer-events: none; }

/* Metropolitan ferry navigation uses the existing street scene, not another modal service screen. */
.capital-district-picker { position:absolute; z-index:8; right:18px; top:90px; width:min(430px,calc(100% - 36px)); max-height:calc(100% - 245px); overflow:auto; padding:18px; background:rgba(21,34,34,.97); border:1px solid #a98c59; box-shadow:0 12px 40px #0008; }
.capital-district-picker[hidden] { display:none; }
.capital-district-picker > b { color:#e3c78f; font-size:20px; }
.capital-district-picker p { color:#b9c2b4; font-size:13px; }
.capital-district-picker button { display:block; width:100%; text-align:left; padding:10px 12px; margin:6px 0; }
.capital-district-picker strong,.capital-district-picker small { display:block; }
.capital-district-picker small { color:#b3b8a8; font-size:12px; margin-top:4px; }
.capital-district-picker button[aria-current] { border-color:#dbc080; opacity:.65; }
@media(max-width:600px) { .settlement-walk-header h1 { font-size:18px; } .settlement-walk-buttons { flex-wrap:wrap; justify-content:flex-end; } .capital-district-picker { top:105px; } }
