/* Koggenzeit — a late-medieval counting house: parchment, dark oak, ink,
   brass and sealing wax. Self-hosted Pirata One display font for the title. */
@font-face {
  font-family: "Pirata One";
  src: url("pirata-one.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --oak: #2e1c10;
  --oak2: #4a2e1a;
  --oak3: #6b4527;
  --parch: #f3e6c8;
  --parch2: #e8d5aa;
  --parch3: #d9c08c;
  --ink: #2a1c10;
  --ink2: #5a4630;
  --brass: #b8893a;
  --brass2: #e0b860;
  --seal: #9c2a20;
  --seal2: #c2412f;
  --good: #2f6a2a;
  --bad: #a3261d;
  --event: #2c4f7c;
  --info: #5a4630;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "DejaVu Serif", serif;
  --text: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "DejaVu Serif", serif;
  --num: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --hud-h: 54px;
  --nav-h: 0px;
  --panel-w: 600px;
  --pic-max-h: 30vh;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden; background: #1d2f3a; color: var(--ink);
  font: 15px/1.4 var(--text); -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background:
  radial-gradient(ellipse at 40% 40%, #36596a, #1d2f3a 75%); }

/* ---------- textures ---------- */
.parch, #panel, #card, .mbox, .tcard, .toast, #alert {
  background-color: var(--parch);
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(255, 255, 240, .55), transparent 55%),
    radial-gradient(ellipse at 90% 95%, rgba(150, 105, 45, .20), transparent 60%),
    repeating-linear-gradient(0deg, rgba(120, 85, 40, .035) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--parch), var(--parch2));
}
.oak, #hud, #nav, #panel .ph {
  background-color: var(--oak);
  background-image:
    repeating-linear-gradient(92deg, rgba(255, 220, 170, .045) 0 2px, transparent 2px 9px, rgba(0, 0, 0, .08) 9px 11px, transparent 11px 17px),
    linear-gradient(180deg, var(--oak2), var(--oak));
  color: #f4e4c4;
}

/* ---------- controls ---------- */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  min-height: 40px; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid #8a6a3a; color: var(--ink);
  background: linear-gradient(180deg, #fbf3df, #e6d0a0);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 1px 2px rgba(60, 35, 10, .25);
  touch-action: manipulation;
}
button:hover:not(:disabled) { background: linear-gradient(180deg, #fff8e8, #ecd8ab); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 3px rgba(60, 35, 10, .35); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--brass2); outline-offset: 1px; }
button.pri {
  color: #fff6e6; border-color: #5f1610; text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  background: radial-gradient(ellipse at 35% 25%, #d4553f, var(--seal) 55%, #6e1a12);
  box-shadow: inset 0 1px 0 rgba(255, 200, 180, .35), 0 1px 3px rgba(60, 10, 0, .4);
}
button.pri:hover:not(:disabled) { background: radial-gradient(ellipse at 35% 25%, #e0624b, #ac3326 55%, #761c13); }
button.danger { color: var(--bad); border-color: #b07060; }
button.small { padding: 4px 9px; font-size: 14px; }
button.big { font-size: 18px; padding: 10px 22px; }
button.link { background: none; border: 0; box-shadow: none; padding: 0 2px; min-height: 0; color: var(--seal); text-decoration: underline; text-underline-offset: 2px; font-weight: bold; }
button.x { min-width: 40px; font-size: 22px; line-height: 1; padding: 0; background: transparent; border-color: transparent; box-shadow: none; color: inherit; }
select, input[type=text], input[type=number], textarea {
  min-height: 40px; padding: 6px 8px; border: 1px solid #9c7c4a; border-radius: 5px;
  background: #fffaf0; color: var(--ink); max-width: 100%;
}
textarea { width: 100%; font: 12px/1.3 ui-monospace, monospace; }
input[type=number] { width: 84px; font-family: var(--num); font-variant-numeric: tabular-nums; text-align: right; }
input[type=range] { width: 100%; accent-color: var(--seal); min-height: 32px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--seal); flex: none; }
label { display: block; margin: 8px 0; }
label > select, label > input[type=text] { display: block; width: 100%; margin-top: 3px; }
label.chk { display: flex; gap: 10px; align-items: center; min-height: 40px; }
label.slider { display: grid; grid-template-columns: 1fr 70px; gap: 2px 10px; align-items: center; }
label.slider > span, label.slider { font-size: 14px; }
label.slider input { grid-column: 1; }
label.slider output { grid-column: 2; grid-row: 1 / span 2; text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.btns.col { flex-direction: column; align-items: stretch; }
.btns.col button small { display: block; font-size: 12px; opacity: .85; }
.btns button small { display: block; font-size: 11px; opacity: .8; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.muted { color: #8a765a; }
.small { font-size: 13px; }
.ok { color: var(--good); }
.no { color: var(--bad); }
small { font-size: 12.5px; }
h2, h3, h4, .th { font-family: var(--serif); font-weight: bold; letter-spacing: .01em; }
h3 { margin: 4px 0 8px; font-size: 17px; color: #3b2412; }
h4 { margin: 14px 0 6px; font-size: 15px; color: #5a3a1c; border-bottom: 1px solid rgba(120, 85, 40, .3); padding-bottom: 2px; }
p { margin: 6px 0; }
.drop::first-letter { font-family: var(--serif); float: left; font-size: 2.6em; line-height: .9; padding: 3px 6px 0 0; color: var(--seal); font-weight: bold; }
.tag { display: inline-block; font: bold 11px/1.5 var(--num); padding: 0 6px; border-radius: 9px; background: var(--brass); color: #2a1a08; vertical-align: middle; letter-spacing: .02em; }
.chip { display: inline-block; font-size: 12.5px; padding: 2px 8px; border-radius: 10px; margin: 2px 4px 2px 0; border: 1px solid; }
.chip.bad { color: var(--bad); border-color: var(--bad); background: rgba(163, 38, 29, .08); }
.chip.good { color: var(--good); border-color: var(--good); background: rgba(47, 106, 42, .08); }
.hint { padding: 8px 10px; border-left: 4px solid var(--brass); background: rgba(184, 137, 58, .13); border-radius: 0 5px 5px 0; font-size: 14px; margin: 8px 0; }
.hint.bad { border-color: var(--bad); background: rgba(163, 38, 29, .09); color: #6d1912; }
.hint.tip { border-color: var(--event); background: rgba(44, 79, 124, .08); }

.bar { display: inline-block; width: 70px; height: 9px; border-radius: 5px; background: rgba(60, 40, 15, .18); vertical-align: middle; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25); }
.bar > i { display: block; height: 100%; background: linear-gradient(180deg, var(--brass2), var(--brass)); }
.bar.low > i { background: linear-gradient(180deg, #d0604f, var(--bad)); }
.bar.hi > i { background: linear-gradient(180deg, #6fae5f, var(--good)); }
.bar.rep > i { background: linear-gradient(90deg, #8a5a20, var(--brass2)); }

.ic { display: inline-block; vertical-align: middle; object-fit: contain; flex: none; }
.icf { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-family: var(--serif); font-weight: bold; line-height: 1;
  background: radial-gradient(circle at 35% 30%, #f8e7b8, #c99a4a); color: #3a2410; border: 1px solid #8a6a3a; }
.icf-ship { border-radius: 4px; background: linear-gradient(#d8e3ea, #8fa9b8); color: #1d2f3a; }
.icf-ui { background: radial-gradient(circle at 35% 30%, #ffe9a0, #b8893a); }

/* ---------- top bar ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hud-h); z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  border-bottom: 3px solid #1a0f07; box-shadow: 0 2px 0 var(--brass), 0 4px 12px rgba(0, 0, 0, .45);
}
.brand { font: 400 26px/1 "Pirata One", var(--serif); color: var(--brass2); letter-spacing: .04em; text-shadow: 0 1px 0 #000; white-space: nowrap; }
#stats { display: flex; gap: 16px; align-items: center; min-width: 0; white-space: nowrap; font-size: 15px; overflow: hidden; }
#stats b { font-weight: 600; }
.st-date { font-family: var(--serif); font-weight: bold; color: #fff1d6; min-width: 9.5em; }
.st-gold { color: var(--brass2); display: inline-flex; gap: 5px; align-items: center; font-size: 16px; }
.st-gold.neg { color: #ff8a7a; }
.st-rank { padding: 1px 9px; border: 1px solid rgba(224, 184, 96, .6); border-radius: 10px; color: #f6deaa; font-size: 13.5px; }
.st-val, .st-loan { color: #d9c7a6; font-size: 13.5px; }
.st-loan b { color: #ff9a8a; }
#speed { display: flex; gap: 3px; margin-left: auto; }
#speed button { min-width: 44px; padding: 4px 6px; color: #f4e4c4; background: rgba(0, 0, 0, .25); border-color: rgba(224, 184, 96, .45); box-shadow: none; font-family: var(--num); font-weight: 600; }
#speed button.on { background: linear-gradient(180deg, var(--brass2), var(--brass)); color: #2a1a08; border-color: #f0d080; }
#speed .pz { display: inline-block; width: 12px; height: 14px; border-left: 4px solid currentColor; border-right: 4px solid currentColor; vertical-align: middle; }

#nav { display: flex; gap: 4px; align-items: center; background: none; box-shadow: none; flex: none; }
#nav button { position: relative; display: flex; align-items: center; gap: 6px; color: #f4e4c4; background: rgba(0, 0, 0, .22); border-color: rgba(224, 184, 96, .45); box-shadow: none; padding: 4px 10px; }
#nav button.on { background: linear-gradient(180deg, #6b4527, #4a2e1a); border-color: var(--brass2); color: #fff; }
#nav .ni { font-size: 18px; line-height: 1; width: 22px; text-align: center; }
#nav .ni .ic { width: 22px; height: 22px; }
#nav .nl { font-size: 14px; }
#nav .badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--seal); color: #fff; font: bold 11px/18px var(--num); font-style: normal; text-align: center; padding: 0 4px; }
#nav .badge:empty { display: none; }

/* ---------- side panel ---------- */
#panel {
  position: fixed; z-index: 15; top: var(--hud-h); right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw;
  display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease-out;
  border-left: 6px solid var(--oak); box-shadow: -6px 0 18px rgba(0, 0, 0, .45);
}
#panel.open { transform: none; }
#panel.wide { width: min(1120px, calc(100vw - 384px)); }
#panel .ph { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; flex: none; border-bottom: 2px solid var(--brass); }
#panel .ph h2 { margin: 0; font-size: 20px; flex: 1; color: #fbe9c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#panel .ph .tag { font-size: 11px; }
#pbody { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: 0 14px 24px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; container-type: inline-size; container-name: pb; }

/* Picture slots: always exactly 16:5 (the documented 1920x600 panorama).
   When the height must be capped, the box narrows and is letterboxed. */
.pic-wrap { margin: 0 -14px; background: #17100a; border-bottom: 3px solid var(--oak); position: relative; overflow: hidden; display: flex; justify-content: center; }
.pic-wrap.none { display: none; }
.pic-wrap canvas { display: block; width: min(100%, calc(var(--pic-max-h) * 3.2)); height: auto; aspect-ratio: 16 / 5; }
.chead { padding: 8px 0 2px; }
.cline { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; font-size: 14px; }
.cline .rep .bar { width: 90px; }
.cline .sat { display: inline-flex; gap: 3px; }
.cline .sat .bar { width: 26px; height: 8px; }
.cmeta { font-size: 13px; color: var(--ink2); }
.fx { margin-top: 4px; }
.chead > button { margin-top: 4px; }
.chead .hint { margin: 6px 0 2px; }
.hint.ice { border-color: #5b86b0; background: rgba(120, 170, 220, .16); color: #1d3a5a; }
.tag.ice { background: #9cc2e4; color: #10263a; }
.tag.ok { background: var(--good); color: #fff; }

/* Action results inside the panel: stays put at the bottom, content does not move. */
#pmsg { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 6px 10px; border-top: 2px solid var(--brass); background: rgba(255, 248, 228, .97); box-shadow: 0 -3px 10px rgba(60, 35, 10, .18); max-height: 40%; overflow: auto; }
#pmsg .pm { font-size: 14.5px; padding: 6px 10px; border-left: 5px solid var(--info); border-radius: 4px; background: #fffaf0; cursor: pointer; animation: tin .2s ease-out; }
#pmsg .pm.k-good { color: #1d4a19; background: #eef6e4; }
#pmsg .pm.k-bad { color: #6d1912; background: #fbe9e4; font-weight: bold; }
.mmsg { font-size: 14.5px; padding: 7px 10px; margin: 6px 0 10px; border-radius: 5px; border-left: 5px solid var(--info); background: rgba(255, 255, 255, .6); }
.mmsg.k-good { color: #1d4a19; background: #eef6e4; }
.mmsg.k-bad { color: #6d1912; background: #fbe9e4; font-weight: bold; }

.tabs { display: flex; gap: 0; margin: 8px -14px 10px; padding: 0 10px; border-bottom: 2px solid var(--oak3); position: sticky; top: 0; z-index: 2; background: var(--parch2); overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 1 0 auto; border-radius: 6px 6px 0 0; border-bottom: 0; margin-bottom: -2px; box-shadow: none; background: transparent; border-color: transparent; font-family: var(--serif); font-weight: bold; color: var(--ink2); white-space: nowrap; }
.tabs button.on { background: var(--parch); border-color: var(--oak3); color: var(--seal); border-bottom: 2px solid var(--parch); }
.tabs.wrap { flex-wrap: wrap; gap: 4px; padding: 6px 10px; overflow-x: visible; }
.tabs.wrap button { flex: 1 1 auto; min-height: 34px; padding: 4px 10px; margin-bottom: 0; border-radius: 6px; border: 1px solid rgba(107, 69, 39, .35); background: rgba(255, 250, 235, .45); font-size: 13.5px; }
.tabs.wrap button.on { background: var(--parch); border-color: var(--seal); color: var(--seal); box-shadow: inset 0 0 0 1px var(--seal); }

.box { margin: 10px 0 14px; padding: 10px 12px; border: 1px solid rgba(120, 85, 40, .35); border-radius: 6px; background: rgba(255, 250, 235, .45); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .25); }
.kv { display: flex; align-items: center; gap: 10px; margin: 5px 0; flex-wrap: wrap; }
.kv > span:first-child { min-width: 92px; color: var(--ink2); font-size: 14px; }
.kv > b { margin-left: auto; }
.kvl { list-style: none; padding: 0; margin: 6px 0; }
.kvl li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted rgba(120, 85, 40, .35); padding: 4px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 input { width: 100%; display: block; margin-top: 3px; }

/* ---------- market ---------- */
.prodline { font-size: 13px; color: var(--ink2); margin: 4px 0 8px; line-height: 1.9; }
.pg { display: inline-flex; align-items: center; gap: 3px; margin-right: 8px; white-space: nowrap; }
.mctl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 6px 0; }
.mctl .lbl { font-size: 13.5px; }
.mctl label.lbl { display: flex; align-items: center; gap: 6px; margin: 0; }
.mctl label.lbl select { width: auto; margin: 0; }
.seg { display: inline-flex; border: 1px solid #8a6a3a; border-radius: 7px; overflow: hidden; margin: 4px 0; }
.seg button { border: 0; border-radius: 0; box-shadow: none; border-right: 1px solid #b0915a; padding: 4px 12px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: linear-gradient(180deg, #5a3a20, #3b2414); color: #fbe7bd; }
.seg.qty button { min-width: 46px; font-family: var(--num); font-weight: 600; }
.feedback { font-size: 14px; padding: 6px 10px; border-radius: 5px; margin: 4px 0 8px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(120, 85, 40, .3); }
.feedback.k-good { color: var(--good); }
.feedback.k-bad { color: var(--bad); border-color: rgba(163, 38, 29, .5); }

.mtable { margin: 4px 0; }
.mrow { display: grid; grid-template-columns: minmax(104px, 1.4fr) 80px 92px 92px 56px 50px; gap: 6px; align-items: center; padding: 4px 2px; border-bottom: 1px solid rgba(120, 85, 40, .2); }
.mrow.prod { background: linear-gradient(90deg, rgba(184, 137, 58, .16), transparent 60%); }
.mrow.mhead { font: bold 12px var(--num); color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--oak3); position: sticky; top: 44px; background: var(--parch2); z-index: 1; }
.mrow.mhead > div { text-align: center; }
.mrow.mhead .m-ware { text-align: left; }
.m-ware { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: bold; }
.m-ware .nm { overflow: hidden; text-overflow: ellipsis; }
.mk { font-style: normal; color: var(--brass); font-weight: normal; }
.m-stock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.m-stock b { font-size: 15px; }
.sc { font: 600 10.5px/1.4 var(--num); padding: 0 5px; border-radius: 7px; text-transform: uppercase; letter-spacing: .03em; }
.sc.s0 { background: var(--bad); color: #fff; }
.sc.s1 { background: #d9944a; color: #2a1404; }
.sc.s2 { background: rgba(90, 70, 48, .14); color: var(--ink2); }
.sc.s3 { background: #7fae6a; color: #10260b; }
.sc.s4 { background: var(--good); color: #fff; }
.tr { font: 600 11px var(--num); }
.tr.up { color: var(--bad); }
.tr.dn { color: var(--good); }
.tr.eq { color: #b0a080; font-size: 8px; }
.tb { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px 4px; min-height: 46px; line-height: 1.15; }
.tb b { font-size: 16px; }
.tb small { font-size: 11.5px; opacity: .85; white-space: nowrap; }
.tb.buy { border-color: #6a5a8a; }
.tb.sell.gain { background: linear-gradient(180deg, #eef6df, #c8dfa8); border-color: #5c8a3a; }
.tb.sell.loss { background: linear-gradient(180deg, #faeadc, #e9c4a8); border-color: #a86a4a; }
.tb.ro { border: 1px dashed rgba(120, 85, 40, .4); border-radius: 6px; }
.tb.steep small { color: #8a3a10; font-weight: 600; }
.tb.steep { box-shadow: inset 0 0 0 2px rgba(200, 110, 30, .45); }
.qnote { margin: 2px 0 6px; color: var(--ink2); }
.tb.mv b { font-family: var(--num); }
.m-hold, .m-kont { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.m-hold small { color: var(--ink2); }
.legend { font-size: 12.5px; color: var(--ink2); margin-top: 10px; }

/* ---------- tables, lists ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 6px 6px; border-bottom: 1px solid rgba(120, 85, 40, .22); text-align: left; vertical-align: middle; }

.tbl td:first-child { white-space: nowrap; }
.tbl th { font: bold 12px var(--num); color: var(--ink2); text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--oak3); }
.tbl .r { text-align: right; }
.tbl tfoot th { font-size: 14px; text-transform: none; border-top: 2px solid var(--oak3); border-bottom: 0; }
.tbl.prices tr.cheap td { background: rgba(47, 106, 42, .10); }
.tbl.prices tr.dear td { background: rgba(163, 38, 29, .08); }
.ruleform { margin: 10px 0; padding: 10px; border: 1px dashed var(--oak3); border-radius: 6px; background: rgba(255, 255, 255, .35); }
.bizlist, .bizbuild, .ships { display: flex; flex-direction: column; gap: 6px; }
.biz, .bb, .shipt, .contract, .fship { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid rgba(120, 85, 40, .3); border-radius: 6px; background: rgba(255, 252, 240, .5); }
.biz > div, .bb > div, .shipt > div, .contract > div, .fship > .fs-main { flex: 1; min-width: 0; }
.biz small, .bb small, .shipt small, .contract small, .fship small { display: block; color: var(--ink2); }
.bb button, .shipt button { min-width: 84px; line-height: 1.2; }
details.build summary, details.explain summary, details.rules summary { cursor: pointer; font-family: var(--serif); font-weight: bold; color: var(--seal); min-height: 40px; display: flex; align-items: center; }
details.build[open] summary { margin-bottom: 6px; }
.contract.accepted { border-color: var(--brass); background: rgba(224, 184, 96, .16); }
.contract .btns { margin: 6px 0 0; }

/* fleet */
.fship.sel { border-color: var(--seal); box-shadow: 0 0 0 2px rgba(156, 42, 32, .25); }
.fs-bars { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 12.5px var(--num); margin: 3px 0; }
.fs-bars .bar { width: 50px; }
.fs-btns { display: flex; flex-direction: column; gap: 5px; }
.rstat { padding: 8px 10px; border-radius: 6px; background: rgba(90, 70, 48, .1); margin: 8px 0; }
.rstat.on { background: rgba(47, 106, 42, .13); color: #1f4a1b; }
.rstat .btns { margin-bottom: 0; }
.stop { border: 1px solid var(--oak3); border-radius: 7px; padding: 8px; margin: 10px 0; background: rgba(255, 252, 240, .55); position: relative; }
.stop.cur { border-color: var(--good); box-shadow: 0 0 0 2px rgba(47, 106, 42, .25); }
.stop + .stop::before { content: "↓"; position: absolute; top: -17px; left: 18px; color: var(--oak3); font-weight: bold; }
.stop-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.stop-h select { font-weight: bold; flex: 0 1 180px; }
.sn { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; background: var(--seal); color: #fff; font: bold 14px var(--num); flex: none; }
.order { display: grid; grid-template-columns: 24px minmax(90px, 1fr) minmax(110px, 1.2fr) 90px 90px 40px; gap: 6px; align-items: end; padding: 6px 0; border-top: 1px dotted rgba(120, 85, 40, .35); }
.order > .ic { align-self: center; }
.order select { width: 100%; }
.nfield { margin: 0; font-size: 11.5px; color: var(--ink2); }
.nfield input { width: 100%; display: block; margin-top: 1px; }
.otext { grid-column: 2 / -1; color: var(--ink2); font-size: 12.5px; }
.explain ol { padding-left: 20px; margin: 4px 0; font-size: 14px; }
.explain li { margin: 4px 0; }

/* prices */
.gchips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.gchip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 4px; font-size: 13.5px; }
.gchip.on, .gchip.on:hover:not(:disabled), .seg button.on:hover:not(:disabled) { background: linear-gradient(180deg, #5a3a20, #3b2414); color: #fbe7bd; border-color: #2a1a0a; }
.gchip.on:hover:not(:disabled) { box-shadow: 0 0 0 2px var(--brass2); }
.best { font-size: 14px; padding: 6px 10px; background: rgba(255, 255, 255, .4); border-radius: 5px; }
.mxwrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid rgba(120, 85, 40, .35); border-radius: 5px; }
.mx { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.mx th, .mx td { padding: 4px 6px; border-bottom: 1px solid rgba(120, 85, 40, .18); white-space: nowrap; }
.mx thead th { position: sticky; top: 0; z-index: 2; background: var(--parch2); height: 92px; vertical-align: bottom; font: 600 12px var(--num); }
.mx thead th span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); }
.mx .sticky { position: sticky; left: 0; z-index: 1; background: var(--parch); text-align: left; font: bold 13px var(--text); }
.mx thead .sticky { z-index: 3; background: var(--parch2); }
.mx td { text-align: right; cursor: pointer; background: color-mix(in srgb, #4f9a45 calc((1 - var(--t)) * 30%), color-mix(in srgb, #c24a3a calc(var(--t) * 30%), transparent)); }
.mx td.lo { font-weight: 700; color: #10380c; outline: 2px solid var(--good); outline-offset: -2px; }
.mx td.hi { font-weight: 700; color: #5a0c06; outline: 2px solid var(--bad); outline-offset: -2px; }
.mx td.pr { text-decoration: underline; text-decoration-color: var(--brass); text-underline-offset: 2px; }

/* company */
.needs { list-style: none; padding: 0; margin: 4px 0; }
.needs li { padding: 4px 0; }
.needs li.ok { color: var(--good); }
.spark { position: relative; margin: 10px 0 4px; height: 76px; border: 1px solid rgba(120, 85, 40, .3); border-radius: 5px; background: repeating-linear-gradient(0deg, transparent 0 18px, rgba(120, 85, 40, .1) 18px 19px); }
.spark svg { width: 100%; height: 100%; display: block; }
.spark polyline { fill: none; stroke: var(--seal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.sp-l span { background: rgba(243, 230, 200, .85); padding: 0 3px; border-radius: 3px; }
.sp-l { position: absolute; top: 2px; bottom: 2px; right: 6px; display: flex; flex-direction: column; justify-content: space-between; font: 11px var(--num); color: var(--ink2); text-align: right; }
.chron .ce { padding: 6px 4px 6px 10px; border-left: 4px solid var(--info); margin: 4px 0; font-size: 14px; background: rgba(255, 255, 255, .25); }
.chron .ce small { color: var(--ink2); margin-right: 4px; }
.chron .ce.link { cursor: pointer; }
.k-good { border-left-color: var(--good) !important; }
.k-bad { border-left-color: var(--bad) !important; }
.k-event { border-left-color: var(--event) !important; }
.chron .k-bad { background: rgba(163, 38, 29, .07); }

/* ---------- map card ---------- */
#card {
  position: fixed; z-index: 14; left: 12px; bottom: 12px; width: 360px; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - var(--hud-h) - 24px); overflow: auto; overscroll-behavior: contain;
  padding: 8px 12px 6px; border-radius: 8px; border: 4px solid var(--oak);
  box-shadow: 0 0 0 1px var(--brass), 0 8px 22px rgba(0, 0, 0, .5);
}
.card-h { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(120, 85, 40, .35); padding-bottom: 6px; margin-bottom: 6px; }
.card-h b { font: bold 18px var(--serif); display: block; }
.card-h small { color: var(--ink2); }
.cstat { font-weight: bold; margin: 6px 0 2px; }
.cargo { display: flex; flex-wrap: wrap; gap: 4px 10px; font: 13px var(--num); margin: 6px 0; }
.cg { display: inline-flex; gap: 3px; align-items: center; }
#card .btns select { flex: 1 1 120px; }

/* ---------- toasts and alert ---------- */
#toasts { position: fixed; z-index: 16; left: 12px; top: calc(var(--hud-h) + 10px); width: 360px; max-width: calc(100vw - 24px); display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; pointer-events: none;
  max-height: calc(50vh - var(--hud-h)); overflow: hidden; }
.toast { flex: none; }
.toast { pointer-events: auto; padding: 7px 10px 7px 12px; border-radius: 5px; border-left: 5px solid var(--info); font-size: 14px; box-shadow: 0 3px 10px rgba(0, 0, 0, .4); animation: tin .25s ease-out; transition: opacity .3s, transform .3s; }
.toast small { display: block; color: var(--ink2); font-size: 11.5px; }
.toast.link { cursor: pointer; }
.toast.gone { opacity: 0; transform: translateX(-20px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
#alert { position: fixed; z-index: 30; top: calc(var(--hud-h) + 12px); left: 50%; transform: translateX(-50%); width: min(600px, calc(100vw - 24px));
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 3px solid var(--bad); border-radius: 8px; box-shadow: 0 0 0 4px rgba(163, 38, 29, .25), 0 10px 30px rgba(0, 0, 0, .6); animation: shake .5s; }
#alert .al-t { flex: 1; font-size: 15.5px; font-weight: bold; color: #5a1009; }
#alert .al-t small { display: block; font-weight: normal; color: var(--ink2); }
#alert .al-t em { display: block; font-size: 13px; font-weight: normal; color: var(--bad); }
#alert .al-b { display: flex; flex-direction: column; gap: 6px; }
.al-seal, .seal { flex: none; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: bold 26px var(--serif); color: #ffe6d8;
  background: radial-gradient(circle at 35% 30%, #d9604a, var(--seal) 55%, #5f140d); box-shadow: 0 2px 4px rgba(0, 0, 0, .4), inset 0 -3px 6px rgba(0, 0, 0, .3); }
body.has-panel #alert { left: calc((100vw - var(--panel-w)) / 2); width: min(560px, calc(100vw - var(--panel-w) - 24px)); }
body.has-panel.wide-panel #alert { left: 50%; width: min(600px, calc(100vw - 24px)); }
@keyframes shake { 0%, 100% { transform: translateX(-50%); } 20% { transform: translateX(calc(-50% - 8px)); } 40% { transform: translateX(calc(-50% + 8px)); } 60% { transform: translateX(calc(-50% - 4px)); } 80% { transform: translateX(calc(-50% + 4px)); } }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 40; background: rgba(15, 8, 3, .62); display: flex; align-items: center; justify-content: center; padding: 12px; }
.mbox { width: min(520px, 100%); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px 20px; border: 6px solid var(--oak); border-radius: 8px; box-shadow: 0 0 0 1px var(--brass), 0 16px 40px rgba(0, 0, 0, .6); }
.mbox h2 { margin: 0 0 8px; color: #3b2412; font-size: 22px; }
.mbox h3 { margin-top: 16px; border-bottom: 1px solid rgba(120, 85, 40, .35); }
#modal.victory .mbox { text-align: center; }
.seal.big { width: 76px; height: 76px; font-size: 40px; margin: 0 auto 8px; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: flex-start; padding: 24px 6vw; overflow: auto;
  background: radial-gradient(ellipse at 70% 50%, rgba(10, 20, 26, 0) 0%, rgba(10, 14, 18, .35) 60%), linear-gradient(90deg, rgba(20, 12, 6, .55), rgba(20, 12, 6, 0) 60%);
  background-size: cover; background-position: center; }
#title.art { background-color: #1d2f3a; }
.tcard { width: min(480px, 100%); margin: auto 0; padding: 24px 28px; border: 8px solid var(--oak); border-radius: 6px; box-shadow: 0 0 0 1px var(--brass), 0 0 0 4px var(--oak), 0 20px 50px rgba(0, 0, 0, .6); position: relative; }
.tcard h1 { margin: 2px 12px 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(184, 137, 58, .65); font: 400 64px/1 "Pirata One", var(--serif); color: #3b2412; letter-spacing: .03em; text-align: center; text-shadow: 0 2px 0 rgba(255, 248, 224, .85), 0 3px 8px rgba(46, 28, 16, .16); }
.tcard .sub { text-align: center; font-style: italic; color: var(--ink2); margin: 0 0 14px; }
.tcard .seal { margin: 0 auto; }
.tcard .flavour { font-size: 15.5px; }
.tcard .th { margin: 0 0 8px; font-size: 26px; color: #3b2412; }
.tcard .btns.col button { font-size: 17px; font-family: var(--serif); }
.tcard .orn { text-align: center; color: var(--brass); font-size: 22px; margin: 6px 0 0; }
.tcard.help { width: min(560px, 100%); }
.tcard.help ol { padding-left: 20px; }
.tcard.help li { margin: 7px 0; }
.help-quick { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; padding: 10px 12px; border: 1px solid var(--brass); border-radius: 6px; background: rgba(255, 250, 232, .65); }
.help-quick > div { display: flex; gap: 10px; align-items: flex-start; }
.help-quick b { display: block; color: #3b2412; font-family: var(--serif); }
.help-quick small { display: block; color: var(--ink2); line-height: 1.35; }
.helpsec { margin: 6px 0; border: 1px solid rgba(120, 85, 40, .35); border-radius: 6px; background: rgba(255, 252, 240, .42); padding: 2px 10px; }
.helpsec summary { cursor: pointer; font-family: var(--serif); font-weight: bold; color: #3b2412; min-height: 38px; display: flex; align-items: center; gap: 6px; }
.helpsec[open] summary { color: var(--seal); border-bottom: 1px solid rgba(120, 85, 40, .2); margin-bottom: 4px; }
.helpsec ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13.5px; line-height: 1.45; }
.helpsec li { margin: 5px 0; }
.tcard.help kbd { font: 600 11.5px var(--num); padding: 1px 5px; border: 1px solid #9c7c4a; border-radius: 4px; background: #fffaf0; color: var(--ink); box-shadow: 0 1px 0 rgba(60, 35, 10, .2); }
details.rules { margin: 10px 0; padding: 4px 10px; border: 1px solid rgba(120, 85, 40, .4); border-radius: 6px; background: rgba(255, 255, 255, .3); }
.homehint { margin-top: -4px; color: var(--ink2); }
.noscript { position: fixed; inset: 40% 10% auto; background: var(--parch); padding: 20px; text-align: center; }

/* ---------- medium widths ---------- */
@media (max-width: 1360px) {
  #nav .nl { display: none; }
  #nav button { padding: 4px 8px; min-width: 44px; justify-content: center; }
  .st-val { display: none; }
}
@media (max-width: 1500px) { body:not(.at-title) .brand { display: none; } }
@media (max-width: 1080px) { :root { --panel-w: 540px; } }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  :root { --hud-h: 90px; --nav-h: calc(58px + var(--safe-b)); }
  body { font-size: 15px; }
  #hud { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr 1fr; align-items: center; gap: 2px 8px; padding: 3px 8px; }
  #stats { display: contents; }
  .st-date { grid-column: 1; grid-row: 1; min-width: 0; font-size: 15px; }
  .st-gold { grid-column: 2; grid-row: 1; justify-self: end; font-size: 16px; }
  .st-rk { grid-column: 1; grid-row: 2; justify-self: start; max-width: 100%; }
  .st-goal { max-width: calc(100vw - 300px); }
  .st-val, .st-loan, .brand { display: none !important; }
  #speed { grid-column: 2; grid-row: 2; margin: 0; }
  #speed button { min-width: 46px; min-height: 40px; }
  #nav { position: fixed; z-index: 21; top: auto; bottom: 0; left: 0; right: 0; height: var(--nav-h); padding: 4px 4px var(--safe-b); justify-content: space-around; gap: 2px;
    background-color: var(--oak); background-image: linear-gradient(180deg, var(--oak2), var(--oak)); border-top: 3px solid #1a0f07; box-shadow: 0 -2px 0 var(--brass), 0 -4px 12px rgba(0, 0, 0, .4); }
  #nav button { flex: 1; flex-direction: column; gap: 1px; min-height: 50px; padding: 2px; background: transparent; border-color: transparent; }
  #nav .nl { display: block; font-size: 11px; }
  #nav .badge { right: 12%; top: 0; }
  #panel { top: var(--hud-h); bottom: var(--nav-h); width: 100%; border-left: 0; transform: translateY(105%); box-shadow: 0 -4px 18px rgba(0, 0, 0, .5); }
  #panel.wide { width: 100%; }
  #panel.open { transform: none; }
  #pbody { padding: 0 10px 20px; }
  .pic-wrap { margin: 0 -10px; }
  .chead { padding: 6px 0 0; }
  .cline { flex-wrap: nowrap; gap: 10px; font-size: 13px; white-space: nowrap; overflow: hidden; }
  .cline .sat { display: none; }
  .cline .cmeta { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .cline .rep .bar { width: 50px; }
  .tabs { margin: 8px -10px 10px; padding: 0 4px; }
  .tabs button { padding: 6px 8px; font-size: 14px; }
  .tabs.wrap { padding: 6px 8px; }
  .tabs.wrap button { min-height: 36px; padding: 4px 8px; font-size: 13px; }
  .seg.qty button { min-width: 44px; padding: 4px 6px; }
  #card { left: 6px; right: 6px; width: auto; max-width: none; bottom: calc(var(--nav-h) + 6px); max-height: calc(100dvh - var(--hud-h) - var(--nav-h) - 16px); overflow: auto; }
  body.has-panel #card { display: none; }
  #card .kv { margin: 1px 0; }
  #card .cardhint { display: none; }
  #card .card-h b { font-size: 17px; }
  #toasts { left: 6px; right: 6px; width: auto; top: calc(var(--hud-h) + 6px); }
  body.has-panel #toasts { display: none; }
  .stop-h select { flex: 1 1 100px; min-width: 0; }
  .stop-h .grow { display: none; }
  .gchips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin: 8px -10px; padding-left: 10px; padding-right: 10px; }
  .gchip { flex: none; }
  .fship { flex-wrap: wrap; }
  .fs-btns { flex-direction: row; width: 100%; }
  .fs-btns button { flex: 1; }
  .tbl { font-size: 13.5px; }
  .tbl th, .tbl td { padding: 6px 4px; }
  .grid2 { grid-template-columns: 1fr; }
  #title { padding: 10px; align-items: flex-start; justify-content: center; }
  .tcard { padding: 18px 16px; border-width: 6px; }
  .tcard h1 { font-size: 44px; }
  #alert, body.has-panel #alert, body.has-panel.wide-panel #alert { top: calc(var(--hud-h) + 6px); left: 50%; width: calc(100vw - 12px); flex-wrap: wrap; }
  #alert .al-b { flex-direction: row; width: 100%; justify-content: flex-end; }
  .mxwrap { max-height: calc(100dvh - 300px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- additions: top bar goal, compact layouts by panel width ---------- */
#stats > * { flex: none; }
#stats > .st-rk { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.st-goal { min-height: 0; padding: 1px 9px; font: 12.5px/1.5 var(--text); color: #ecd9b0; background: rgba(0, 0, 0, .22); border: 1px dashed rgba(224, 184, 96, .55); box-shadow: none; border-radius: 10px;
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.st-goal:hover:not(:disabled) { background: rgba(0, 0, 0, .35); color: #fff; }
.st-loan.warn b { color: #fff; background: var(--seal); padding: 0 5px; border-radius: 4px; }
#nav button[aria-pressed="true"], #nav button.on { background: linear-gradient(180deg, #6b4527, #4a2e1a); }
body.is-paused:not(.at-title) #speed button[data-v="0"] { animation: pz 1.6s ease-in-out infinite; }
@keyframes pz { 50% { box-shadow: 0 0 0 3px rgba(240, 208, 128, .55); } }

/* kontor goods list (replaces a table that clipped on phones) */
.klist { display: flex; flex-direction: column; }
.krow { display: grid; grid-template-columns: minmax(100px, 1.3fr) 56px 66px 66px minmax(90px, 1.6fr) auto; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(120, 85, 40, .22); font-size: 14px; }
.krow.khead { font: bold 11.5px var(--num); color: var(--ink2); text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--oak3); }
.krow .kw { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.krow .kb button { white-space: nowrap; }

.ores { display: block; grid-column: 2 / -1; font-size: 12.5px; }
.rround { font-size: 14px; margin: 4px 0 0; font-weight: bold; }
.rstat.loss { background: rgba(163, 38, 29, .12); color: #6d1912; }
.fship.loss { border-color: var(--bad); }
.fship.away { opacity: .8; background: repeating-linear-gradient(135deg, rgba(120, 150, 180, .12) 0 8px, transparent 8px 16px); }
.fship .inl { display: inline; }
.suggest { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--brass); border-radius: 6px; background: rgba(224, 184, 96, .14); }
.suggest .row { margin: 6px 0 2px; align-items: center; }
.suggest label.lbl { display: flex; align-items: center; gap: 6px; margin: 0; }
.suggest select { width: auto; max-width: 190px; margin: 0; }
.convoy { margin: 6px 0; font-size: 14px; }
.convoy.row { align-items: center; }
.convoy label.lbl { display: flex; align-items: center; gap: 6px; margin: 0; }
.convoy label.lbl select { width: auto; margin: 0; }
.convoy small { display: block; width: 100%; }
.skills { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 14px; }
.skills li { padding: 2px 0; }
.skills small { color: var(--ink2); }
.pips { font-family: var(--num); color: var(--seal); letter-spacing: 1px; }
.pips i { font-style: normal; color: #b9a27a; }
.captain { padding: 8px 10px; border: 1px solid rgba(120, 85, 40, .35); border-radius: 6px; background: rgba(255, 252, 240, .6); }
.captain .row { align-items: center; }
.captain label.lbl { display: flex; gap: 6px; align-items: center; margin: 0; }
.captain label.lbl select { width: auto; margin: 0; }
.expo { padding: 8px 0; border-top: 1px dotted rgba(120, 85, 40, .4); }
.expo > small { display: block; color: var(--ink2); }
.works { display: flex; flex-direction: column; gap: 6px; }
.work, .decree, .slot { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid rgba(120, 85, 40, .3); border-radius: 6px; background: rgba(255, 252, 240, .5); }
.work > div, .decree > small, .slot > div:first-child { flex: 1; min-width: 0; }
.work small, .slot small { display: block; color: var(--ink2); }
.work.built { background: rgba(47, 106, 42, .08); border-color: rgba(47, 106, 42, .4); }
.work button { min-width: 84px; line-height: 1.2; }
.decree { flex-wrap: wrap; }
.decree > b { width: 100%; }
.office { border-color: var(--brass); background: rgba(224, 184, 96, .14); }
.seg.tax button { min-width: 72px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot .btns { margin: 0; flex-wrap: nowrap; }
.steps { padding-left: 22px; }
.steps li { margin: 8px 0; }
.odds { font-size: 14px; padding: 6px 8px; border-radius: 5px; background: rgba(255, 255, 255, .45); }
.odds.ok b { color: var(--good); }
.odds.no b { color: var(--bad); }
#card.k-pirate { border-color: #2a1010; box-shadow: 0 0 0 1px var(--seal), 0 8px 22px rgba(0, 0, 0, .5); }
.goalbox { border-color: var(--brass); }
.biz.idle { border-color: var(--bad); background: rgba(163, 38, 29, .06); }
.shipt.na { opacity: .75; }
.ptop { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 8px 0 4px; }
.ptop .seg { margin: 0; }
label.search { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13.5px; flex: 1 1 180px; }
label.search input { flex: 1; min-width: 0; min-height: 36px; padding: 4px 8px; border: 1px solid #9c7c4a; border-radius: 5px; background: #fffaf0; }
.best { margin: 8px 0; line-height: 1.5; }
.prices .link { text-align: left; }
#pbody > .pic-wrap:first-child { margin-top: 0; }
.ptop + .pic-wrap { margin-top: 4px; }

/* Panel narrower than ~520px (phones, and the 540px panel at 1024px): the
   market table folds into two lines per good, other grids fold likewise. */
@container pb (max-width: 520px) {
  .mrow { grid-template-columns: 1fr 1fr 54px 44px; grid-template-areas: "ware ware stock stock" "buy sell hold kont"; gap: 4px 6px; padding: 6px 0; }
  .m-ware { grid-area: ware; }
  .m-stock { grid-area: stock; flex-direction: row; justify-content: flex-end; align-items: center; gap: 6px; }
  .mrow > .m-b { grid-area: buy; }
  .mrow > .m-s { grid-area: sell; }
  .m-hold { grid-area: hold; }
  .m-kont { grid-area: kont; }
  .mrow.mhead { grid-template-areas: "buy sell hold kont"; }
  .mrow.mhead .m-ware, .mrow.mhead .m-stock { display: none; }
  .tb { flex-direction: row; gap: 6px; min-height: 44px; }
  .tb small { font-size: 12px; }
  .order { grid-template-columns: 40px 1fr 1fr; grid-template-areas: "ic g a" "x q p" "t t t" "r r r"; }
  .order > .ic { grid-area: ic; }
  .order > .o-g { grid-area: g; }
  .order > .o-a { grid-area: a; }
  .order > .o-q { grid-area: q; }
  .order > .o-p { grid-area: p; }
  .order > .o-x { grid-area: x; align-self: end; }
  .order > .otext { grid-area: t; }
  .order > .ores { grid-area: r; }
  .krow { grid-template-columns: 1fr 1fr auto; grid-template-areas: "w q b" "a p b" "r r r"; gap: 2px 8px; }
  .krow.khead { display: none; }
  .krow > :nth-child(1) { grid-area: w; font-weight: bold; }
  .krow > :nth-child(2) { grid-area: q; }
  .krow > :nth-child(3) { grid-area: a; text-align: left; }
  .krow > :nth-child(4) { grid-area: p; }
  .krow > :nth-child(5) { grid-area: r; }
  .krow > :nth-child(6) { grid-area: b; }
  .krow > .num::before { color: var(--ink2); font: 11.5px var(--num); margin-right: 4px; }
  .krow > :nth-child(2)::before { content: "Menge"; }
  .krow > :nth-child(3)::before { content: "Ø Einkauf"; }
  .krow > :nth-child(4)::before { content: "Verkauf"; }
  .tbl.prices .c-st { display: none; }
  .suggest select { max-width: 140px; }
}
@container pb (max-width: 380px) {
  .suggest .row { flex-direction: column; align-items: stretch; }
  .suggest select { max-width: none; flex: 1; }
}

/* Desktop with a narrow window: keep the card beside the panel. */
@media (min-width: 761px) {
  body.has-panel #card { width: min(360px, calc(100vw - var(--panel-w) - 24px)); }
  body.has-panel.wide-panel #card { display: none; }
}
/* Landscape phones and short windows. */
@media (min-width: 761px) and (max-height: 520px) {
  :root { --hud-h: 46px; --panel-w: min(540px, 62vw); }
  #hud { gap: 8px; padding: 0 8px; }
  #speed button, #nav button { min-height: 36px; }
  #nav button { padding: 2px 6px; min-width: 40px; }
  #nav .nl { display: none; }
  .st-val { display: none; }
  .st-date { min-width: 0; }
  #card { bottom: 6px; left: 6px; padding: 6px 10px 4px; }
  #card .cardhint { display: none; }
  #card .kv { margin: 1px 0; }
  .card-h { padding-bottom: 4px; margin-bottom: 4px; }
  #panel .ph h2 { font-size: 17px; }
  #panel .ph { padding: 0 4px 0 10px; }
  .tabs button { min-height: 36px; padding: 4px 8px; }
  .chead { padding: 4px 0 0; }
  .cline .sat { display: none; }
  .mxwrap { max-height: calc(100dvh - 170px); }
  #pmsg { max-height: 30%; }
  #alert { top: calc(var(--hud-h) + 4px); padding: 6px 10px; }
  #toasts { left: auto; right: 8px; width: min(320px, calc(100vw - 400px)); max-height: calc(100vh - var(--hud-h) - 16px); }
  body.has-panel #toasts { display: none; }
}

/* ---------- round 3: quantity, compact market, routes, alerts, title ---------- */
.mctl { gap: 6px 10px; }
.qtyrow { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qstep { display: inline-flex; align-items: stretch; border: 1px solid #8a6a3a; border-radius: 7px; overflow: hidden; }
.qstep button { border: 0; border-radius: 0; box-shadow: none; min-width: 40px; padding: 0 8px; font: 600 18px var(--num); }
.qstep input[type=number] { width: 62px; border: 0; border-left: 1px solid #b0915a; border-right: 1px solid #b0915a; border-radius: 0; text-align: center; padding: 4px 2px; -moz-appearance: textfield; appearance: textfield; }
.qstep input::-webkit-outer-spin-button, .qstep input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qtyrow .seg { margin: 0; }
.seg.qty button.fill { min-width: 0; font-family: var(--text); font-weight: bold; }
select.modesel { width: auto; min-width: 96px; font-weight: bold; }
.pictog { position: absolute; right: 4px; bottom: 4px; min-height: 40px; min-width: 40px; padding: 0 8px; font-size: 13px; background: rgba(243, 230, 200, .85); z-index: 2; }
.pic-wrap.strip canvas { width: 100%; height: 56px; aspect-ratio: auto; }


.chead.compact .cline .rep .bar, .chead.compact .cline .sat { display: none; }

.chead.compact { padding-top: 4px; }

/* routes */
.box.auto { border-color: var(--good); background: rgba(47, 106, 42, .07); }
.box.auto label.chk { margin: 0; font-size: 16px; }
.box.auto .btns small { flex: 1 1 220px; }
.box.expert > .link { min-height: 40px; font-size: 15px; }
.rlast { font-size: 13px; margin-top: 4px; }
.fship small.flag { color: var(--bad); }
small.halfpay, .halfpay { display: block; font-size: 12px; }
h4.first { margin-top: 0; }
label.lbl.inl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
label.lbl.inl select { width: auto; display: inline-block; margin: 0; }
button.sq { min-width: 40px; min-height: 40px; }
.contract .cprof { color: var(--ink); }

/* alerts & toasts */
#alert .al-t .al-x { display: block; margin-top: 4px; font-size: 13.5px; font-weight: normal; color: var(--ink); }
body.has-alert #toasts { top: calc(var(--hud-h) + var(--alert-h, 0px) + 22px); max-height: calc(100dvh - var(--hud-h) - var(--alert-h, 0px) - var(--nav-h) - 40px); justify-content: flex-start; }
.toast.more { text-align: left; min-height: 40px; font: bold 13.5px var(--text); color: var(--ink2); border: 0; border-left: 5px solid var(--brass); cursor: pointer; }

/* touch targets */
.st-goal { min-height: 40px; display: inline-flex; align-items: center; line-height: 1.2; }
.prices .link, .mxdet .link, .contract .link { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; }
button.link { min-width: 0; }

/* price matrix: per-good overview */
.mx th.sticky .mxg { background: none; border: 0; box-shadow: none; padding: 0 4px; min-height: 40px; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-align: left; }
.mx tr.on th.sticky { background: var(--parch3); }
.mxdet { margin: 6px 0 10px; padding: 6px 10px; border: 1px solid var(--brass); border-radius: 6px; background: rgba(224, 184, 96, .14); }
.mxdet .row { margin: 0; align-items: center; }
.mxdet ol { margin: 2px 0; padding-left: 22px; font-size: 14px; }
.mxdet li b { margin-left: 4px; }

/* saves, mods */
.slot.broken { border-color: var(--bad); background: rgba(163, 38, 29, .06); }
.modex { font: 11.5px/1.35 ui-monospace, monospace; white-space: pre-wrap; background: rgba(255, 255, 255, .5); padding: 6px 8px; border-radius: 5px; margin: 6px 0; }
.moderr { font-size: 13.5px; margin: 6px 0; }
.moderr:empty { display: none; }
.moderr.k-bad { color: var(--bad); border-left: 4px solid var(--bad); padding-left: 8px; }
.moderr.k-good { color: var(--good); border-left: 4px solid var(--good); padding-left: 8px; }

/* title scene */
#titlecv { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 34; display: block; pointer-events: none; }
#title.art { background-color: transparent; background-image: linear-gradient(90deg, rgba(20, 12, 6, .5), rgba(20, 12, 6, 0) 60%); }

/* market rows in a narrow panel: one line per good (two text lines beside
   the buttons), so a phone shows many goods at once */
@container pb (max-width: 520px) {
  .mrow { grid-template-columns: minmax(0, 1fr) 82px 82px 50px; grid-template-areas: "ware buy sell hold" "stock buy sell kont"; gap: 0 5px; padding: 3px 0; align-items: center; }
  .m-ware { grid-area: ware; font-size: 14px; gap: 5px; align-self: end; }
  .m-ware .ic { width: 20px; height: 20px; font-size: 12px !important; }
  .m-ware .nm { white-space: nowrap; }
  .m-stock { grid-area: stock; flex-direction: row; justify-content: flex-start; align-items: center; gap: 4px; align-self: start; padding-left: 25px; }
  .m-stock b { font-size: 12.5px; }
  .m-stock .sc { font-size: 9.5px; }
  .mrow > .m-b { grid-area: buy; }
  .mrow > .m-s { grid-area: sell; }
  .m-hold { grid-area: hold; font-size: 13px; }
  .m-kont { grid-area: kont; font-size: 12px; }
  .m-hold small, .m-kont small { display: block; font-size: 10.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
  .tb { flex-direction: column; gap: 0; min-height: 46px; padding: 2px 3px; }
  .tb small { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .mrow.mhead { grid-template-areas: "ware buy sell hold"; padding: 2px 0; font-size: 10.5px; }
  .mrow.mhead .m-ware { display: block; }
  .mrow.mhead .m-stock, .mrow.mhead .m-kont { display: none; }
  .mctl { flex-wrap: nowrap; }
  .qtyrow { flex-wrap: nowrap; }
  .mctl label.lbl { min-width: 0; }
}
@media (max-width: 760px), (max-height: 520px) {
  .slot { flex-wrap: wrap; }
  .slot > div:first-child { flex: 1 1 100%; }
  .slot .btns { width: 100%; justify-content: flex-end; }
}
@media (max-width: 760px) {
  #title { align-items: flex-end; padding: 10px 10px calc(10px + var(--safe-b)); }
  #title.art { background-image: linear-gradient(180deg, rgba(20, 12, 6, 0) 52%, rgba(20, 12, 6, .48)); }
  .tcard.main { padding: 10px 14px; margin: auto 0 0; }
  .tcard.main .seal, .tcard.main .flavour, .tcard.main .orn { display: none; }
  .tcard.main h1 { font-size: 44px; padding-bottom: 5px; margin: 0 8px 5px; }
  .tcard.main .sub { font-size: 13px; margin-bottom: 6px; }
  .tcard.main .btns.col { gap: 5px; margin: 4px 0; }
  .tcard.main .btns.pair { gap: 6px; }
  .tcard.main .btns.pair button, .tcard.main .btns.col button { font-size: 15.5px; padding: 5px 8px; }
  .tcard.main .extline { margin: 4px 0 0; font-size: 12px; text-align: center; }
  .mx th.sticky { max-width: 118px; }
  .mx th.sticky .mxg span { overflow: hidden; text-overflow: ellipsis; }
  .qnote { font-size: 12px; }
}
@media (max-height: 520px) {
  .chead.compact .cline { display: none; }
  .chead.compact { padding: 0; }
  .tabbody[data-key="tab-markt"] .prodline, .tabbody[data-key="tab-markt"] .mrow.mhead { display: none; }
  .tabs { margin-top: 2px; margin-bottom: 4px; }
  .tabs.wrap { position: static; }
  .mctl { margin: 2px 0; }
  .qtyrow button, .qstep button, select.modesel { min-height: 40px; }
  #title { align-items: center; padding: 10px 4vw; }
  .tcard.main .flavour, .tcard.main .seal, .tcard.main .orn { display: none; }
  .tcard.main { padding: 12px 18px; }
  .tcard.main h1 { font-size: 48px; padding-bottom: 6px; margin-bottom: 8px; }
  .tcard.main .btns.col { gap: 5px; }
  .tcard.main .btns.col button { min-height: 40px; padding: 4px 10px; }
}

/* ---------- round 4: price knowledge, overdraft, bounties, sheets ---------- */
button.st-gold { min-height: 0; padding: 1px 8px; background: rgba(120, 20, 10, .35); border: 1px solid rgba(255, 138, 122, .6); box-shadow: none; border-radius: 10px; color: #ff8a7a; font: inherit; font-size: 16px; }
button.st-gold:hover:not(:disabled) { background: rgba(120, 20, 10, .55); color: #ffb0a4; }
.st-gold .odl { font-size: 11px; color: #f2c2b8; margin-left: 2px; }
.st-goal { max-width: none; overflow: visible; text-overflow: clip; white-space: nowrap; flex: none; }
#stats > .st-rk { flex: none; }
@media (max-width: 1240px) and (min-width: 761px) { .st-rank { display: none; } }
@media (max-width: 960px) and (min-width: 761px) { .st-gold .odl { display: none; } }

.newsage { font-size: 12.5px; color: #5a3d1c; background: rgba(184, 137, 58, .16); border-left: 4px solid var(--brass); padding: 2px 8px; margin: 2px 0 4px; border-radius: 0 4px 4px 0; }
.newsage.old2, .newsage.old3 { border-color: var(--bad); color: #6d1912; }
.tb.ro.old1, .m-stock.old1, .mx td.old1, tr.old1 td { opacity: .82; }
.tb.ro.old2, .m-stock.old2, .mx td.old2, tr.old2 td { opacity: .64; }
.tb.ro.old3, .m-stock.old3, .mx td.old3, tr.old3 td { opacity: .48; font-style: italic; }
.mx thead th.old2 span, .mx thead th.old3 span { opacity: .6; }
small.age { font: 11px var(--num); color: var(--ink2); }
small.age.old2, small.age.old3 { color: var(--bad); }
.tag.old { background: #d9c9a8; color: #4a3316; }
.tag.bad { background: var(--bad); color: #fff; }
.tag.only { background: #cfd9e6; color: #1d3a5a; white-space: normal; }
.hint.fog { font-size: 13px; margin: 4px 0 6px; }
.hint.fog small { display: block; color: var(--ink2); }
.tbl .c-age { white-space: nowrap; font-size: 12.5px; }
.shippick { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 4px 0 2px; }
.crewwarn { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 3px 0; }
.crewwarn small { flex: 1 1 200px; }
.rpause { color: #6d1912; }
.work.big { border-color: var(--brass); background: rgba(224, 184, 96, .12); }
.contract.relief { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.contract.bounty { border-color: #5a1b12; background: rgba(90, 27, 18, .06); }
.kv.opp b small { display: block; font-weight: normal; }
.kv.bty small { width: 100%; }
.moderr.k-info { color: var(--ink2); border-left: 4px solid var(--brass); padding-left: 8px; }

/* the quantity row may always wrap: it must never stick out of the panel */
.mctl { min-width: 0; max-width: 100%; }
.qtyrow { max-width: 100%; min-width: 0; flex-wrap: wrap; }
@container pb (max-width: 520px) {
  .mctl { flex-wrap: wrap; }
  .qtyrow { flex-wrap: wrap; }
}

/* toasts never cover the panel */
@media (min-width: 761px) {
  body.has-panel:not(.panel-min) #toasts { width: min(360px, calc(100vw - var(--panel-w) - 24px)); }
}
@media (min-width: 761px) and (max-width: 900px) {
  body.has-panel:not(.panel-min) #toasts { display: none; }
}

/* panel "Karte" button: fold the panel to its title bar */
#panel .ph .pmin { display: none; min-height: 36px; padding: 2px 10px; font-size: 14px; color: #fbe9c4; background: rgba(0, 0, 0, .25); border-color: rgba(224, 184, 96, .55); box-shadow: none; white-space: nowrap; }
@media (max-width: 760px), (max-height: 520px) { #panel .ph .pmin { display: inline-flex; align-items: center; } }
#panel.min #pbody, #panel.min #pmsg { display: none !important; }
#panel.min { bottom: auto; height: auto; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); }
@media (max-width: 760px) {
  #panel.min { top: auto; bottom: var(--nav-h); }
  body.has-panel.panel-min #card { display: block; bottom: calc(var(--nav-h) + 52px); }
  body.has-panel.panel-min #toasts { display: flex; }
  body.has-panel:not(.panel-min) #card { display: none; }
}
@media (min-width: 761px) and (max-height: 520px) {
  body.has-panel.panel-min #card { width: min(360px, calc(100vw - 24px)); }
}

/* ship card as a bottom sheet on small screens */
.card-h.mini { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; gap: 6px; }
.card-h .cmin-l { flex: 1; min-width: 0; text-align: left; background: none; border: 0; box-shadow: none; padding: 0 2px; display: block; color: inherit; min-height: 40px; }
.card-h .cmin-l b { font: bold 15px var(--serif); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-h .cmin-l small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.card-h .chev { min-width: 40px; min-height: 40px; padding: 0; font-size: 16px; }
#card:has(.card-h.mini) { padding: 2px 8px; }

/* "Die Welt entsteht …" */
#busy { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(15, 8, 3, .6); }
#busy[hidden] { display: none; }
#busy .busybox { padding: 18px 28px; border: 6px solid var(--oak); border-radius: 8px; background: var(--parch); text-align: center; box-shadow: 0 0 0 1px var(--brass), 0 16px 40px rgba(0, 0, 0, .6); }
#busy .busybox p { margin: 10px 0 0; font: bold 20px var(--serif); color: #3b2412; }
#busy .seal { margin: 0 auto; animation: pz 1.2s ease-in-out infinite; }
@media (max-width: 760px) {
  .st-rk .st-rank { display: none; }
  .st-goal { max-width: calc(100vw - 225px); white-space: normal; text-align: left; font-size: 12px; line-height: 1.2; padding: 2px 8px; min-height: 40px; overflow: hidden; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
}
#card .kv b i.wpn { font-style: normal; }
@media (max-width: 760px), (max-height: 520px) {
  #card .kvs { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 0 8px; margin: 2px 0; }
  #card .kvs .kv { flex-direction: column; align-items: flex-start; gap: 0; margin: 0; }
  #card .kvs .kv > span:first-child { min-width: 0; font-size: 11.5px; }
  #card .kvs .kv .bar { display: none; }
  #card .kvs .kv > b { margin: 0; font-size: 14px; }
  #card .kvs i.wpn { display: none; }
  #card .halfpay { display: none; }
  #card .cstat { margin: 2px 0; }
  #card p.small { margin: 2px 0; }
  #card .btns { margin: 4px 0 2px; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  .st-goal { white-space: normal; max-width: 150px; font-size: 11.5px; line-height: 1.15; text-align: left; padding: 1px 7px; word-break: keep-all; }
  .st-date { font-size: 14px; }
}
@media (min-width: 761px) and (max-width: 900px) {
  #hud { gap: 6px; padding: 0 6px; }
  #stats { gap: 8px; }
  #speed button { min-width: 36px; padding: 4px 3px; }
  #nav { gap: 2px; }
  #nav button { min-width: 38px; padding: 2px 5px; }
  .st-goal { max-width: 124px; }
  .st-gold { font-size: 15px; }
}
@media (max-width: 1500px) { .st-val { display: none; } }

/* ---------- fix round 5 ---------- */
/* Books: long item names wrap, amounts never do, nothing runs past the edge. */
.tbl.fin { table-layout: auto; }
.tbl.fin td:first-child, .tbl.fin th:first-child { white-space: normal; overflow-wrap: anywhere; }
.tbl.fin .r { white-space: nowrap; }
@media (max-width: 760px) { .tbl.fin th { font-size: 11px; letter-spacing: 0; } .tbl.fin th, .tbl.fin td { padding: 5px 3px; } }
/* First steps: the card scrolls inside, the start button always stays in view. */
#modal.intro .mbox { padding-bottom: 0; }
#modal.intro .mbox > .btns.foot { position: sticky; bottom: 0; z-index: 1; margin: 8px -20px 0; padding: 10px 20px calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(180deg, var(--parch2), var(--parch2)); border-top: 1px solid rgba(120, 85, 40, .35); box-shadow: 0 -6px 10px -8px rgba(60, 35, 10, .5); }
@media (max-height: 520px) { #modal.intro .mbox { padding-top: 10px; } #modal.intro .mbox h2 { font-size: 19px; margin-bottom: 4px; } #modal.intro .mbox > .btns.foot { padding-top: 6px; padding-bottom: 8px; } }
/* 1024 px and similar: a narrower panel leaves more of the map. */
@media (min-width: 761px) and (max-width: 1100px) and (min-height: 521px) { :root { --panel-w: 460px; } }
/* Rule explanations on the setup screen. */
.rhint { display: block; font-size: 12px; line-height: 1.3; color: var(--ink2); font-weight: normal; margin: 1px 0 2px; }
label.slider .rhint { grid-column: 1 / -1; }
/* Toast action ("Markt öffnen"). */
.toast .tact { display: inline-block; margin: 4px 0 0 8px; min-height: 30px; padding: 2px 10px; font-size: 13px; vertical-align: middle; }
/* Voyage estimate. */
.expcalc { margin: 6px 0; padding: 6px 8px; border: 1px dashed rgba(120, 85, 40, .5); border-radius: 6px; background: rgba(255, 255, 255, .25); }
.expcalc .kvl li.tot { border-top: 1px solid rgba(120, 85, 40, .45); margin-top: 2px; padding-top: 3px; font-weight: bold; }
/* Phone market strip: the toggle is a thin translucent tab at the far edge, not a block over the picture. */
.pic-wrap.strip .pictog { top: 0; right: 0; bottom: 0; width: 28px; min-width: 0; max-width: 28px; min-height: 0; padding: 0; border: 0; border-left: 1px solid rgba(246, 231, 184, .35); border-radius: 0; box-shadow: none; background: rgba(23, 16, 10, .42); color: #f6e7b8; font-size: 14px; line-height: 1; }
.pic-wrap.strip .pictog:hover, .pic-wrap.strip .pictog:focus-visible { background: rgba(23, 16, 10, .62); }
.expcalc .kvl b.num { white-space: nowrap; }

/* ---------- multiplayer ---------- */
.btns.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.tcard .btns.pair button { font-size: 17px; font-family: var(--serif); }
.tcard .btns.col > .btns.pair { width: 100%; }
.mpopts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.mpopt { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 4px; padding: 14px; min-height: 110px; }
.mpopt b { font: bold 19px var(--serif); }
.mpopt small { font-size: 13px; color: var(--ink2); font-weight: normal; }
.codein { font: bold 34px/1.1 var(--num); letter-spacing: .35em; text-transform: uppercase; text-align: center; padding: 8px 4px 8px .35em; width: 100%; }
.tcard.lobby { width: min(860px, 100%); margin: auto; }
.lobbygrid { display: grid; grid-template-columns: auto 1fr; gap: 18px 26px; align-items: start; }
.lobbyjoin { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.lobbycode { font: bold 64px/1 var(--num); letter-spacing: .18em; padding-left: .18em; color: #3b2412; text-align: center; user-select: all; }
.qrbox { background: #fff; padding: 6px; border-radius: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 3px 10px rgba(0, 0, 0, .25); line-height: 0; }
canvas.qr { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #fff; }
.lobbyhint { text-align: center; margin: 0; max-width: 300px; }
.joinlink { width: 100%; max-width: 320px; font: 13px var(--num); }
.lobbyjoin .btns { justify-content: center; }
.lobbyplayers h3 { margin: 4px 0 8px; }
.lobbyplayers h3 small { font-weight: normal; color: var(--ink2); font-size: 13px; }
.plist { list-style: none; margin: 0 0 10px; padding: 0; }
.plist li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 7px 4px; border-bottom: 1px solid rgba(120, 85, 40, .25); }
.plist li small { flex-basis: 100%; padding-left: 20px; color: var(--ink2); }
.plist li.off b { color: var(--ink2); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: #9a8a70; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .3); vertical-align: middle; margin-right: 4px; }
.plist li.on .dot, .dot.on { background: #3c9a35; }
.dot.off { background: #a59478; }
.waiting, .connecting { font-style: italic; color: var(--ink2); font-size: 17px; }
.connecting::after { content: ''; display: inline-block; width: 1em; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
#modal.lobby .mbox { width: min(820px, 100%); }
#modal.lobby .th { font-size: 24px; margin: 0 0 8px; }
.tag.mp { background: #2c4f7c; color: #fff; }
.tag.muted { background: rgba(0, 0, 0, .18); color: inherit; }
.st-mp { display: inline-flex; align-items: center; gap: 4px; min-height: 0; padding: 2px 9px; font: 13px/1.4 var(--num); color: #ecd9b0; background: rgba(0, 0, 0, .25); border: 1px solid rgba(224, 184, 96, .6); border-radius: 11px; box-shadow: none; }
.st-mp b { color: #fff; }
.st-mp small { opacity: .8; }
.st-mp.lost { border-color: var(--seal2); background: rgba(156, 42, 32, .45); }
#speed.locked button { opacity: .55; cursor: not-allowed; }
#speed.locked button.on { opacity: .9; }
#netbar { position: fixed; z-index: 40; left: 50%; top: calc(var(--hud-h) + 6px); transform: translateX(-50%); padding: 8px 16px; border-radius: 6px; background: var(--seal); color: #fff; font: bold 15px var(--num); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); animation: pz 1.6s ease-in-out infinite; max-width: calc(100vw - 32px); text-align: center; }
table.houses tr.me td { font-weight: bold; }
table.houses td.num { white-space: nowrap; }
tr.human td:first-child { font-weight: 600; }
.towncard .tcgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.towncard h4 { margin: 8px 0 4px; }
.towncard .tcl { list-style: none; margin: 0; padding: 0; }
.towncard .tcl li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.towncard .tcl li b { margin-left: auto; }
.contract.unseen { opacity: .85; }
@media (max-width: 760px) {
  .lobbygrid { grid-template-columns: 1fr; gap: 12px; }
  .lobbycode { font-size: 52px; }
  .st-mp { grid-column: 2; grid-row: 1; justify-self: start; }
  #speed button { min-width: 38px; padding: 4px 3px; }
  .mpopts { grid-template-columns: 1fr; }
  .mpopt { min-height: 0; }
}

/* ---------- event cards: a page from a chronicle ---------- */
#evcard { position: fixed; inset: 0; z-index: 26; display: flex; align-items: center; justify-content: center; padding: calc(var(--hud-h) + 10px) 16px 16px;
  background: radial-gradient(ellipse at 50% 45%, rgba(20, 12, 6, .48), rgba(10, 6, 3, .78)); animation: evfade .25s ease-out; }
.evcap { margin: 0 0 8px; text-align: center; font: italic 14px var(--serif); color: #6a3a1c; }
.evcap::before, .evcap::after { content: ' ❦ '; color: #9c2a20; font-style: normal; }
.evside .evtime { text-align: center; }
.evside .evtime .ic, .evside .evtime .icf { vertical-align: -2px; }
@keyframes evfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes evin { from { opacity: 0; transform: translateY(14px) scale(.985) rotate(-.4deg); } to { opacity: 1; transform: none; } }
#evcard .evbox { width: min(560px, 100%); max-height: calc(100dvh - var(--hud-h) - 26px); overflow: auto; overscroll-behavior: contain; border-radius: 4px; }
.evpage { position: relative; color: var(--ink); padding: 18px 20px 16px; border: 7px solid #2a170b; border-radius: 4px; animation: evin .32s ease-out;
  background-color: #f1e2c0;
  background-image:
    radial-gradient(ellipse at 50% 50%, rgba(255, 250, 230, .55) 0%, rgba(255, 250, 230, 0) 62%),
    radial-gradient(ellipse at 0% 0%, rgba(120, 75, 30, .28), transparent 38%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 75, 30, .30), transparent 42%),
    radial-gradient(ellipse at 100% 0%, rgba(120, 75, 30, .16), transparent 30%),
    repeating-linear-gradient(0deg, rgba(110, 75, 35, .04) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(110, 75, 35, .025) 0 1px, transparent 1px 7px),
    linear-gradient(175deg, #f6e9cb, #e6d1a4);
  box-shadow: 0 0 0 1px var(--brass), inset 0 0 0 5px rgba(241, 226, 192, .0), inset 0 0 0 6px rgba(140, 52, 30, .55), inset 0 0 0 8px rgba(241, 226, 192, .6), inset 0 0 0 9px rgba(140, 52, 30, .3), inset 0 0 70px rgba(110, 70, 25, .28), 0 22px 60px rgba(0, 0, 0, .65); }
.evpage .evx { position: absolute; top: 6px; right: 6px; z-index: 2; color: #5a3a1c; }
.evart { position: relative; aspect-ratio: 4 / 3; width: 100%; margin: 4px 0 12px; border: 2px solid #3b2412; outline: 1px solid rgba(140, 52, 30, .6); outline-offset: 3px; background: #e7d4a8; overflow: hidden; box-shadow: inset 0 0 18px rgba(80, 50, 20, .35); }
.evart canvas, .evart img { display: block; width: 100%; height: 100%; object-fit: cover; }
.evart .evini { display: none; }
.evart.noart canvas { visibility: hidden; position: absolute; inset: 0; }
.evart.noart { display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 46%, rgba(255, 248, 226, .9), rgba(231, 212, 168, .9) 46%, rgba(196, 160, 100, .9) 100%),
    repeating-conic-gradient(from 0deg at 50% 46%, rgba(140, 52, 30, .10) 0 6deg, transparent 6deg 12deg); }
.evart.noart .evini { display: flex; align-items: center; justify-content: center; width: 42%; aspect-ratio: 1; font: bold clamp(70px, 18vw, 150px)/1 var(--serif); color: #9c2a20;
  border: 3px double rgba(59, 36, 18, .7); border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff8e4, #ead6a8); text-shadow: 2px 2px 0 rgba(224, 184, 96, .7), 0 0 1px #3b2412; box-shadow: 0 0 0 8px rgba(231, 212, 168, .6), 0 0 0 9px rgba(59, 36, 18, .35); }
.evart.small { max-width: 220px; margin: 0 auto 10px; }
.evmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font: 12.5px var(--num); letter-spacing: .08em; text-transform: uppercase; color: #8a3a22; }
.evmeta .evkind { font-weight: 700; }
.evmeta .evdate { color: var(--ink2); letter-spacing: .02em; text-transform: none; font-style: italic; font-family: var(--text); }
.ki { display: inline-block; font: bold 10.5px/1.5 var(--num); letter-spacing: .06em; color: #fff; background: #2c4f7c; border-radius: 3px; padding: 0 5px; text-transform: none; vertical-align: middle; }
.evtitle { margin: 4px 0 8px; font: bold 25px/1.15 var(--serif); color: #3b2412; text-shadow: 0 1px 0 rgba(255, 250, 230, .8); padding-right: 30px; }
.evtext { margin: 0 0 10px; font-size: 16px; line-height: 1.5; }
.evtext.drop::first-letter { font-size: 3.3em; line-height: .82; padding: 4px 8px 0 0; color: #9c2a20; text-shadow: 1px 1px 0 rgba(224, 184, 96, .8); }
.evwhere { margin: 0 0 8px; font-size: 14px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.evchoices { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; border-top: 1px solid rgba(140, 52, 30, .35); padding-top: 12px; }
.evch { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 10px 14px; min-height: 54px; border: 1px solid #a88550; border-left: 5px solid #9c2a20; border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 251, 238, .92), rgba(238, 221, 182, .92)); box-shadow: 0 1px 2px rgba(60, 35, 10, .25); }
.evch b { font: bold 17px var(--serif); color: #3b2412; }
.evch .evhint { font-style: italic; color: var(--ink2); font-size: 13.5px; }
.evch .evsum { font: 13.5px/1.35 var(--num); color: #4a3620; }
.evch .evsum::before { content: '→ '; color: #9c2a20; }
.evch .evwhy { color: var(--bad); font-size: 13px; }
.evch:hover:not(:disabled) { background: linear-gradient(180deg, #fffaf0, #f1e1bb); border-left-color: #c2412f; }
.evch.last { border-left-color: #8a7a60; border-style: dashed; border-left-style: solid; }
.evch:disabled { opacity: .62; border-left-color: #999; }
.evtime { margin: 4px 0 0; font-size: 13px; font-style: italic; color: var(--ink2); }
.evtime.urgent { color: var(--bad); font-weight: bold; }
.evnav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; font: 13px var(--num); color: var(--ink2); }
.evpage.out { text-align: center; padding-top: 22px; }
.evpage.out .evmeta { justify-content: center; }
.evpage.out .evtitle { padding-right: 0; }
.evchose { margin: 6px 0; }
.evout { font-size: 16.5px; margin: 8px auto 14px; max-width: 32em; padding: 10px 14px; border-top: 1px solid rgba(140, 52, 30, .35); border-bottom: 1px solid rgba(140, 52, 30, .35); }
.evpage.out .btns { justify-content: center; }
.dealcard { margin: 6px 0 10px; padding: 8px 10px; border: 1px dashed #a88550; border-radius: 4px; background: rgba(255, 250, 235, .5); }
.dealcard .dquote { margin: 0 0 6px; font-style: italic; }
@media (min-width: 900px) and (min-height: 600px) {
  #evcard .evbox { width: min(940px, 100%); }
  .evpage:not(.out) { display: grid; grid-template-columns: minmax(300px, 44%) 1fr; gap: 0 22px; padding: 22px 24px 18px; }
  .evpage:not(.out) { grid-template-rows: auto 1fr; }
  .evpage:not(.out) .evart { grid-column: 1; grid-row: 1; align-self: start; margin-top: 6px; }
  .evpage:not(.out) .evside { grid-column: 1; grid-row: 2; }
  .evpage:not(.out) .evbody { grid-column: 2; grid-row: 1 / span 2; }
  #evcard .evbox:has(.out) { width: min(560px, 100%); }
}
@media (max-width: 760px) {
  #evcard { padding: calc(var(--hud-h) + 4px) 6px calc(var(--nav-h) + 6px); align-items: stretch; }
  #evcard .evbox { max-height: none; height: 100%; }
  .evpage { padding: 12px 12px 14px; border-width: 5px; min-height: 100%; }
  .evart { margin: 0 0 10px; }
  .evtitle { font-size: 22px; }
  .evtext { font-size: 15.5px; }
  .evch { padding: 9px 11px; }
}

/* waiting cards: wax seals at the edge of the screen */
#evchips { position: fixed; z-index: 17; right: 12px; top: calc(var(--hud-h) + 12px); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
body.has-panel #evchips { right: calc(var(--panel-w) + 14px); }
body.has-panel.wide-panel #evchips { right: auto; left: 12px; top: auto; bottom: 12px; }
body.has-alert #evchips { top: calc(var(--hud-h) + var(--alert-h, 0px) + 22px); }
#evchips.dim { opacity: .55; }
.evchip { display: flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; min-height: 0; border-radius: 26px; border: 1px solid rgba(224, 184, 96, .8); max-width: 260px;
  background: linear-gradient(180deg, rgba(246, 233, 203, .97), rgba(226, 206, 160, .97)); box-shadow: 0 3px 10px rgba(0, 0, 0, .45); color: var(--ink); }
.evchip .cl { font: bold 13.5px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wax { flex: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: bold 20px var(--serif); color: #ffe6d8;
  background: radial-gradient(circle at 35% 30%, #d9583f, #9c2a20 55%, #6a160f); box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .35), inset 0 2px 3px rgba(255, 190, 160, .4), 0 0 0 2px rgba(156, 42, 32, .35);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .45); clip-path: polygon(50% 0, 61% 5%, 73% 3%, 80% 12%, 92% 16%, 94% 28%, 100% 38%, 97% 50%, 100% 62%, 94% 72%, 92% 84%, 80% 88%, 73% 97%, 61% 95%, 50% 100%, 39% 95%, 27% 97%, 20% 88%, 8% 84%, 6% 72%, 0 62%, 3% 50%, 0 38%, 6% 28%, 8% 16%, 20% 12%, 27% 3%, 39% 5%); }
.wax.sm { width: 30px; height: 30px; font-size: 15px; }
.evchip.fresh .wax { animation: waxp 1.4s ease-in-out infinite; }
.evchip.urgent { border-color: var(--seal2); }
@keyframes waxp { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.evcount { position: absolute; top: -8px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; font: bold 12px/20px var(--num); text-align: center; color: #fff; background: #2a170b; border: 1px solid var(--brass2); }
@media (max-width: 1100px) { .evchip .cl { display: none; } .evchip { padding: 3px; } }
@media (max-width: 760px) {
  #evchips { top: auto; bottom: calc(var(--nav-h) + 10px); right: 8px; }
  body.has-panel #evchips { right: 8px; }
  body.has-panel:not(.panel-min) .evchip:not(:first-child) { display: none; }
  body.has-panel:not(.panel-min) #evchips .evcount { display: block; }
  body:not(.has-panel) #card:not([hidden]) ~ #evchips { bottom: auto; top: calc(var(--hud-h) + 8px); }
  body.has-evchips:not(.has-panel) #toasts { right: 60px; }
  .wax { width: 44px; height: 44px; }
}
/* chronicle list of cards */
.evrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(120, 85, 40, .2); }
.evrow b { display: block; font-family: var(--serif); }
.evrow small { display: block; color: var(--ink2); }
.evrow.past small i { color: var(--ink); }
.toast.k-say { border-left-color: #2c4f7c; }
.chron .k-say, .chron .k-card { border-left-color: #8a3a22 !important; }
.chron .k-say { border-left-color: #2c4f7c !important; }

/* roads and wagons */
.ic.wagon { vertical-align: middle; flex: none; }
p.roads { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fuhrhof h3 { display: flex; align-items: center; gap: 8px; }

/* dealings */
.merchant { padding: 8px 0; border-bottom: 1px solid rgba(120, 85, 40, .22); }
.merchant .mc-h small { display: block; color: var(--ink2); }
.merchant .btns { margin-top: 4px; }
.mood.mp { color: var(--good); } .mood.mn { color: var(--bad); }
#modal.deal .mbox { width: min(720px, 100%); }
.dealcols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.dcol { padding: 8px 10px; border: 1px solid #c4a36c; border-radius: 6px; background: rgba(255, 250, 235, .45); }
.dcol h3 { margin: 0 0 6px !important; border: 0 !important; font-size: 17px; }
.dcol.give { border-left: 4px solid var(--bad); } .dcol.want { border-left: 4px solid var(--good); }
.dcol .nfield input { width: 100%; }
.drow { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.drow input { width: 70px; }
.dcol select { width: 100%; margin-top: 4px; }
.dval { margin: 8px 0 0; font-size: 14px; }
.dealsum .dverdict { font-weight: bold; margin: 4px 0; }
.dresult { font-size: 16px; }
.cform { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.aiset input.aikey, .aiset input.aimodel { width: 100%; font-family: var(--num); }
.aistat { padding: 4px 8px; border-left: 4px solid var(--brass); background: rgba(255, 250, 235, .5); }
.aistat.no { border-left-color: var(--bad); } .aistat.ok { border-left-color: var(--good); }
.chatbox .row input { flex: 1; min-width: 0; }
@media (max-width: 760px) { .dealcols, .cform { grid-template-columns: 1fr; } }

/* phones: notifications are one slim ticker line under the HUD */
@media (max-width: 760px), (max-height: 520px) {
  #toasts, body.has-alert #toasts { flex-direction: row; align-items: stretch; justify-content: flex-start; gap: 4px; max-height: none; }
  .toast { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-left-width: 4px; font-size: 12.5px; line-height: 1.25; opacity: .94; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
  .toast small { display: inline; flex: none; font-size: 11px; }
  .toast .tt { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toast .tact { flex: none; min-height: 28px; padding: 2px 8px; font-size: 12px; }
  .toast.more { flex: none; order: 2; min-height: 0; padding: 3px 8px; font-size: 12.5px; }
}

/* market: favourites on top, own average purchase price always in view */
.favb { flex: none; margin-left: auto; min-width: 30px; min-height: 30px; padding: 0 4px; border: 0; background: none; box-shadow: none; font-size: 17px; line-height: 1; color: var(--ink2); opacity: .45; cursor: pointer; }
.favb.on { color: #b8791a; opacity: 1; }
.mrow.fav { box-shadow: inset 3px 0 0 #b8791a; }
.m-stock .ek { display: none; }
.m-kont small { color: var(--ink2); }
@container pb (max-width: 380px) {
  .mrow { grid-template-columns: minmax(0, 1fr) 74px 74px 46px; gap: 0 4px; }
  .m-hold small, .m-kont small { font-size: 10px; }
}
