/* Retro-modern Bullfrog-era UI: bronze & walnut panels, bevelled buttons, pixel type. */
:root {
  --ui: 1;
  --bg: #1b1410; --panel: #2a1f17; --panel2: #35281d; --edge: #6b5236; --edge2: #120c08; --hi: #a8845a;
  --text: #ecdcb8; --dim: #a8987a; --gold: #f0c860; --good: #7fd06a; --bad: #e0503c; --warn: #f0a040; --blue: #7cc4f0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font-family: 'TMI Pixel', 'Courier New', monospace; font-size: calc(18px * var(--ui)); -webkit-font-smoothing: none; font-smooth: never; text-rendering: optimizeSpeed; font-kerning: none; overflow: hidden; user-select: none; }
button { font-family: inherit; font-size: inherit; color: var(--text); background: linear-gradient(#4a3826, #2f2317); border: 2px solid; border-color: var(--hi) var(--edge2) var(--edge2) var(--hi); padding: 1px 8px; cursor: pointer; line-height: 1.1; }
button:hover { background: linear-gradient(#5d4630, #3a2b1d); color: #fff; }
button:active { border-color: var(--edge2) var(--hi) var(--hi) var(--edge2); }
button.on { background: linear-gradient(#7a5a2a, #4d3818); color: var(--gold); }
button.danger { color: #f7a08a; }
button.big { font-size: 1em; padding: 4px 16px; }
.hidden { display: none !important; }
.dim { color: var(--dim); } .small { font-size: 1em; } .warn { color: var(--warn); } .short { color: var(--bad); }
b { color: #fff3d0; font-weight: normal; }

#app { position: fixed; inset: 0; display: flex; }
#viewwrap { position: relative; flex: 1; overflow: hidden; }
#view { width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: default; touch-action: none; }
body.tooling #view { cursor: crosshair; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 40px; font-size: 1.5em; background: #0a0806; line-height: 1.3; }
#loading code { color: var(--gold); }

/* sidebar */
#side { width: calc(330px * var(--ui)); background: var(--panel); border-left: 3px solid var(--edge); box-shadow: inset 2px 0 0 var(--edge2); display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
#side > * { flex-shrink: 0; }
#side > div, #side > canvas { border-bottom: 2px solid var(--edge2); box-shadow: 0 1px 0 var(--edge); padding: 6px 8px; }
#hdr .h1 { font-size: 1.5em; color: var(--gold); letter-spacing: 1px; }
#hdr .h2 { color: var(--dim); }
.spdrow { display: flex; gap: 3px; margin-top: 4px; }
.spdrow button { flex: 1; padding: 0; }
.doom { margin-top: 4px; color: #ff7a40; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }
#minimap { width: 100%; image-rendering: pixelated; background: #05070c; cursor: pointer; padding: 4px !important; }
.rrow { display: flex; justify-content: space-between; font-size: 1em; }
.rgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px 4px; margin-top: 3px; }
.rgrid.food { border-top: 1px dashed var(--edge); padding-top: 2px; }
.rc { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
img.ric { width: calc(16px * var(--ui)); height: calc(16px * var(--ui)); object-fit: contain; image-rendering: pixelated; vertical-align: middle; }
img.gi { height: 16px; image-rendering: pixelated; vertical-align: -2px; margin-right: 3px; }
#mainbtns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
#mainbtns .mb { padding: 3px 2px; }
#selpanel { min-height: 80px; }
.selhead { display: flex; gap: 8px; align-items: flex-start; }
img.portrait { width: calc(64px * var(--ui)); height: calc(64px * var(--ui)); image-rendering: pixelated; border: 2px solid var(--edge); background: #3c3022; }
img.mini { width: 24px; height: 24px; image-rendering: pixelated; border: 1px solid var(--edge); }
.nm { font-size: 1em; color: var(--gold); }
.act { color: var(--blue); }
.bar { display: grid; grid-template-columns: 58px 1fr 28px; align-items: center; gap: 4px; margin: 1px 0; }
.bar i { height: 8px; background: #120c08; border: 1px solid var(--edge); display: block; }
.bar b { display: block; height: 100%; background: var(--good); }
.bar b.bad { background: var(--bad); } .bar b.food { background: #d8a040; } .bar b.energy { background: #6aa8e0; } .bar b.mor { background: #c080d8; }
.bar em { font-style: normal; color: var(--dim); text-align: right; }
.skills { display: grid; grid-template-columns: repeat(4, 1fr); color: var(--dim); font-size: 1em; margin: 3px 0; }
.btns { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.hint { color: #b8c890; font-size: 1em; margin-top: 4px; }
.cost { display: inline-flex; align-items: center; gap: 1px; margin-right: 5px; }
.costs { display: flex; flex-wrap: wrap; }
.recipe, .upg { border: 1px solid var(--edge); padding: 3px; margin: 4px 0; background: #231a13; }
.row { display: flex; align-items: center; gap: 4px; }
.multi { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 4px; }
.tab { padding: 0 6px; }
.blist { display: flex; flex-direction: column; gap: 2px; }
.bi { display: flex; gap: 6px; align-items: center; padding: 2px; border: 1px solid transparent; cursor: pointer; }
.bi:hover { border-color: var(--edge); background: var(--panel2); }
.bi.on { border-color: var(--gold); background: #3d2d18; }
.bi.locked { opacity: 0.55; cursor: default; }
.bimg { width: 64px; height: 44px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
img.bic { max-width: 64px; max-height: 44px; image-rendering: pixelated; }
.chk { display: block; margin: 6px 0; }
table.prio { width: 100%; border-collapse: collapse; }
table.prio td, table.prio th { padding: 0 2px; text-align: center; }
table.prio td:first-child { text-align: left; }
table.prio button { padding: 0 4px; }
table.prio td.pc { white-space: nowrap; }
.oat { color: var(--gold); cursor: pointer; padding: 0 4px; border: 1px solid var(--edge); } .oat:hover { background: var(--edge); }
.prioscroll { overflow-x: auto; max-width: 100%; }
table.prio.narrow td, table.prio.narrow th { padding: 0 1px; }
table.prio.narrow button { padding: 0 2px; }
table.prio.narrow img.mini { width: 20px; height: 20px; }
table.prio input[type=checkbox] { margin: 2px 0; }
.p5 { color: #ff7050; } .p4 { color: var(--gold); } .p1 { color: var(--dim); }
.crow { cursor: pointer; } .crow:hover { color: #fff; }

/* overlays on the view */
#objectives { position: absolute; left: 8px; top: 8px; max-width: calc(380px * var(--ui)); background: rgba(22, 16, 11, 0.82); border: 2px solid var(--edge); padding: 4px 8px; }
#objectives .ot { color: var(--gold); cursor: pointer; }
#objectives .o.done { color: var(--dim); text-decoration: line-through; }
#objectives .o.key { color: #fff0c8; }
#objectives .o.done.key { color: var(--dim); }
#objectives .oh { color: #b8c890; font-size: 1em; padding-left: 16px; margin-bottom: 2px; }
#alerts { position: absolute; left: 8px; bottom: 8px; display: flex; flex-direction: column-reverse; gap: 2px; max-width: 60%; }
.al { background: rgba(20, 14, 10, 0.85); border-left: 4px solid var(--dim); padding: 1px 8px; cursor: pointer; }
.al.danger { border-color: var(--bad); color: #ffb0a0; } .al.warn { border-color: var(--warn); } .al.good { border-color: var(--good); }
.al.research { border-color: var(--blue); } .al.discovery { border-color: var(--gold); color: #ffe8a0; } .al.mystery { border-color: #b070e0; color: #e0c0ff; } .al.build { border-color: #c09060; }
#msg { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: rgba(20, 14, 10, 0.9); border: 2px solid var(--edge); padding: 2px 12px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#msg.show { opacity: 1; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.plate { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; line-height: 0.9; font-size: 1em; color: #e8dcc0; text-shadow: 1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000; pointer-events: none; }
.plate span { font-size: 1em; color: #c8bca0; }
.plate.sel span { color: #bfe6ff; }
.plate i { font-style: normal; color: #9fc8ff; } .plate i.hurt { color: #ff7a6a; } .plate i.dr { color: #ffb050; }
.bubble { position: absolute; left: 0; top: 0; background: #f4ead0; color: #2a1c10; padding: 0 6px; border: 2px solid #2a1c10; font-size: 1em; white-space: nowrap; }
#maptip { position: fixed; display: none; min-width: 150px; max-width: 280px; background: rgba(18,12,8,0.94); border: 2px solid var(--edge); box-shadow: 3px 3px 0 #000; padding: 4px 8px; z-index: 45; pointer-events: none; line-height: 1.05; }
#maptip .tt { color: var(--gold); font-size: 1em; } #maptip .tt span { color: var(--dim); font-size: 1em; }
#maptip .ta { color: #b8c890; } #maptip .tn { color: var(--dim); } #maptip .tl { color: var(--dim); margin-top: 2px; }
#maptip .tr { display: flex; justify-content: space-between; gap: 12px; } #maptip .tr span { color: var(--dim); } #maptip .tr b i { color: var(--dim); font-style: normal; }
#maptip .bad { color: var(--bad); } #maptip .good { color: #9fe07a; } #maptip .tm { display: flex; flex-wrap: wrap; gap: 2px 8px; }
#tip { position: fixed; display: none; max-width: 260px; background: #120c08; border: 2px solid var(--gold); padding: 3px 7px; z-index: 50; pointer-events: none; }
#wide { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(1100px, 94%); max-height: 88%; overflow: auto; background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2), 0 10px 40px #000; padding: 8px 12px; z-index: 10; }
.whead { display: flex; justify-content: space-between; align-items: center; }
.whead h3 { margin: 0; color: var(--gold); font-weight: normal; font-size: 1.5em; }
.rcur { margin: 4px 0 8px; }
.tree { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.tier .tt { color: var(--gold); border-bottom: 1px solid var(--edge); margin-bottom: 4px; min-height: 3.2em; }
.tech { border: 2px solid var(--edge2); background: var(--panel2); padding: 2px 4px; margin-bottom: 4px; display: flex; flex-direction: column; font-size: 1em; }
.tech.available { cursor: pointer; border-color: var(--hi); }
.tech.available:hover { background: #4a3620; }
.tech.done { opacity: 0.6; border-color: #3a5a30; }
.tech.cur { border-color: var(--gold); background: #4a3818; }
.tech.locked, .tech.undiscovered, .tech.needchar { opacity: 0.6; }
.tech .why { color: var(--warn); font-size: 1em; }
.jbody { max-height: 70vh; overflow: auto; }
.je { border-bottom: 1px dashed var(--edge); padding: 3px 0; }
.je.mystery b { color: #e0c0ff; } .je.discovery b { color: #ffe8a0; } .je.unk { color: var(--dim); }
.help p { margin: 6px 0; line-height: 1.2; }

/* event card */
#card { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 30; }
.cardbox { width: min(620px, 92vw); max-height: 90vh; overflow: auto; background: #e9dcb8; color: #2c1d10; border: 4px double #5a4028; box-shadow: 0 0 0 3px #2a1c10, 0 20px 60px #000; padding: 14px 20px; position: relative; }
.cardbox h2 { margin: 0 0 6px; font-weight: normal; font-size: 2em; color: #4a2410; }
.cardbox p { margin: 6px 0; font-size: 1em; line-height: 1.15; }
.cardbox b { color: #000; }
canvas.cmap { display: block; width: 100%; image-rendering: pixelated; margin: 8px 0 2px; clear: both; }
.clegend { font-size: 0.9em; color: #4a3018; display: flex; gap: 12px; flex-wrap: wrap; }
img.cportrait { float: right; width: 144px; height: 144px; image-rendering: pixelated; border: 3px solid #5a4028; margin: 0 0 6px 10px; }
.cbtns { clear: both; text-align: right; margin-top: 8px; }
.cardbox.victory { background: #efe4c0; }
.cardbox.defeat { background: #d8c8b0; }

/* menu */
#menu { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 40; background: radial-gradient(ellipse at 50% 40%, rgba(10, 7, 5, 0.35), rgba(10, 7, 5, 0.88) 75%); overflow: auto; padding: 16px; }
#menu.ontitle { background: linear-gradient(180deg, rgba(8, 6, 4, 0.92) 0%, rgba(8, 6, 4, 0.55) 34%, rgba(8, 6, 4, 0.25) 55%, rgba(8, 6, 4, 0.85) 100%); justify-content: flex-start; padding-top: 4vh; }
.menubox { width: min(560px, 92vw); max-height: 60vh; overflow: auto; background: rgba(34, 25, 18, 0.94); border: 3px solid var(--edge); box-shadow: 0 0 0 2px var(--edge2), 0 12px 40px rgba(0, 0, 0, 0.7); padding: 12px 18px; flex-shrink: 0; }
#menu:not(.ontitle) .menubox { max-height: 76vh; }
/* title banner */
.banner { text-align: center; color: var(--gold); flex-shrink: 0; padding: 10px 40px 12px; position: relative;
  background: linear-gradient(90deg, transparent, rgba(20, 13, 8, 0.85) 18%, rgba(20, 13, 8, 0.85) 82%, transparent);
  border-top: 3px double #a8844a; border-bottom: 3px double #a8844a; border-image: linear-gradient(90deg, transparent, #c8a060 20%, #f0d088 50%, #c8a060 80%, transparent) 3; }
.banner h1 { margin: 0; font-weight: normal; font-size: calc(72px * var(--ui)); line-height: 1; letter-spacing: 6px; color: #f4cf6a;
  text-shadow: 0 3px 0 #b07a28, 0 6px 0 #6a4214, 0 9px 0 #2a1806, 6px 12px 0 rgba(0, 0, 0, 0.7); }
.banner .bn-rule { font-size: calc(18px * var(--ui)); color: #c8a060; letter-spacing: 10px; margin-bottom: 4px; }
.banner .bn-sub { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 14px; font-size: calc(36px * var(--ui)); letter-spacing: 14px; color: #ecdcb8; text-shadow: 3px 3px 0 #000; }
.banner .bn-sub i { display: block; width: 90px; height: 3px; background: linear-gradient(90deg, transparent, #c8a060); }
.banner .bn-sub i:last-child { background: linear-gradient(90deg, #c8a060, transparent); }
.banner .bn-tag { margin-top: 8px; color: var(--dim); font-size: calc(18px * var(--ui)); letter-spacing: 1px; }
.banner .bn-cast { display: flex; justify-content: center; gap: 12px; margin-top: 12px; }
.banner figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.banner img.bnp { width: calc(64px * var(--ui)); height: calc(64px * var(--ui)); image-rendering: pixelated; border: 3px solid #5a4028; box-shadow: 0 0 0 2px #1a120a, 0 0 0 3px #a8844a; background: #e9dcb8; filter: sepia(0.25); }
.banner figcaption { font-size: calc(18px * var(--ui)); color: var(--dim); white-space: nowrap; }
.banner.small { padding: 6px 30px 8px; }
.banner.small h1 { font-size: calc(36px * var(--ui)); letter-spacing: 3px; text-shadow: 0 2px 0 #b07a28, 0 4px 0 #4a2a0a, 3px 6px 0 rgba(0, 0, 0, 0.7); }
.banner.small .bn-rule { display: none; } .banner.small .bn-sub { font-size: calc(18px * var(--ui)); margin-top: 6px; letter-spacing: 8px; }
.banner.small .bn-sub i { width: 50px; height: 2px; }
.mmain { display: flex; flex-direction: column; gap: 5px; }
.mmain button { padding: 5px 12px; text-align: center; }
.mmain button.big { font-size: 1em; padding: 8px 12px; color: var(--gold); }
.diffs { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.dbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 10px; text-align: left; }
.dbtn span { font-size: 0.85em; opacity: 0.8; }
.mback { margin-top: 10px; }
.mh.dbg { color: #7cc4f0; border-bottom-color: #4080a0; margin-top: 12px; }
.vch.chartb { border-left-color: #c8a060; }
@media (max-height: 760px) { .banner .bn-cast { display: none; } .banner h1 { font-size: calc(54px * var(--ui)); } }
@media (max-width: 760px) { .banner h1 { font-size: calc(36px * var(--ui)); letter-spacing: 2px; } .banner .bn-sub { font-size: calc(18px * var(--ui)); letter-spacing: 6px; } .banner .bn-cast { gap: 4px; } .banner img.bnp { width: 40px; height: 40px; } .banner figcaption { display: none; } }
.mh { color: var(--gold); margin-top: 10px; border-bottom: 1px solid var(--edge); }
.slot { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
.slot span:first-child { width: 100px; } .slot .dim { flex: 1; font-size: 1em; }
.set label { display: flex; align-items: center; gap: 8px; }
.set input[type=range] { flex: 1; }
.foot { margin-top: 10px; }

/* developer panel */
#dev { position: fixed; right: calc(340px * var(--ui)); top: 10px; width: 420px; background: rgba(20, 16, 14, 0.95); border: 2px solid #4080a0; padding: 6px 10px; z-index: 20; }
#dev select { font-family: inherit; font-size: inherit; background: #222; color: #ddd; }

body.title #objectives, body.title #alerts, body.title #side, body.title #labels { display: none; }
input[type=range], input[type=checkbox] { accent-color: var(--gold); }

.eqs { margin: 3px 0; }
.eqr { display: grid; grid-template-columns: 52px 18px 1fr 34px; align-items: center; gap: 3px; margin: 1px 0; }
.eqr select, .gear select, #wide select { font-family: inherit; font-size: inherit; color: var(--text); background: #1a120c; border: 2px solid; border-color: var(--edge2) var(--hi) var(--hi) var(--edge2); min-width: 0; width: 100%; }
i.dur { display: inline-block; height: 6px; background: #120c08; border: 1px solid var(--edge); } i.dur b { display: block; height: 100%; }
i.dur b.good { background: var(--good); } i.dur b.food { background: var(--warn); } i.dur b.bad { background: var(--bad); }
table.gear, table.gmake { width: 100%; border-collapse: collapse; } table.gear td, table.gmake td { padding: 2px 4px; border-bottom: 1px solid var(--edge2); vertical-align: middle; }
table.gear .eqr { grid-template-columns: 0 18px 1fr 30px; } table.gear .eqr > span.dim { display: none; }
.pool { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-bottom: 6px; } .pit { display: flex; align-items: center; gap: 4px; } .pit i.dur { width: 24px; }

.expcard { border: 2px solid var(--edge); background: var(--panel2); padding: 3px 6px; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin: 2px 0 6px; } .chip { display: flex; align-items: center; gap: 3px; } .chip.on { background: linear-gradient(#7a5a2a, #4a3418); color: #fff3d0; }
.sup { margin-right: 10px; white-space: nowrap; } .rules { margin: 4px 0; } .rules .chk { display: inline-flex; margin-right: 8px; }
#objectives .o.side { color: #e6c8ff; } #objectives .o.exp { color: #ffd98a; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
.kgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 14px; margin: 6px 0; max-height: 60vh; overflow-y: auto; }
.krow { display: flex; justify-content: space-between; align-items: center; } .krow button { min-width: 70px; }
/* colour-blind friendly palette: blue for good, orange for bad, plus shape cues */
body.cb { --good: #5aa8ff; --bad: #ff9a2c; --warn: #ffe066; }
body.cb .cost.short::after { content: '✕'; margin-left: 1px; }
body.cb b.good, body.cb .bar b.good { background: #5aa8ff; } body.cb .bar b.bad { background: #ff9a2c; }
/* large text: 3x pixel font everywhere, wider sidebar */
body.bigtext { font-size: calc(27px * var(--ui)); }
body.bigtext #side { width: calc(430px * var(--ui)); }
body.bigtext #tip, body.bigtext #maptip { max-width: 380px; }
/* the Voyage South */
.spdrow .bell { flex: 0 0 26px; }
.spdrow .bell.on { background: #9a1c14; color: #fff; animation: pulse 0.6s infinite alternate; }
#hdr .h2 .cold { color: #9ad0ff; } #hdr .h2 .hot { color: #ffb070; }
.voy { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 6px 0 4px; }
.vch { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-left: 5px solid #888; }
.vch span { font-size: 0.78em; opacity: 0.8; line-height: 1.25; }
.vch.tropical { border-left-color: #3f9a3a; } .vch.arid { border-left-color: #d0902a; } .vch.temperate { border-left-color: #6a8a4a; }
.vch.subantarctic { border-left-color: #7a9ab0; } .vch.antarctic { border-left-color: #d8ecff; }
.cardbox .cbtns .big { font-weight: bold; }

/* caves: banner while the camera is inside */
#cavebar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; gap: 10px; align-items: center;
  background: rgba(20, 16, 12, 0.9); border: 1px solid #6a5438; color: #e8d4a0; padding: 5px 10px; font-size: 13px; border-radius: 3px; }
#cavebar button { font: inherit; background: #3a2e22; color: #e8d4a0; border: 1px solid #a8885a; padding: 2px 8px; cursor: pointer; }
#cavebar button:hover { background: #6a5438; }

/* map overlay toggles */
#ovbtns { display: flex; gap: 3px; padding: 2px 4px; flex-wrap: wrap; }
#ovbtns .ovb { flex: 1; font: inherit; font-size: 11px; background: #2a2219; color: #d8c49a; border: 1px solid #5a4a36; padding: 2px 4px; cursor: pointer; }
#ovbtns .ovb.on { background: #6a5438; color: #fff2cc; border-color: #c8a870; }
.doom.forecast { opacity: 0.85; }
#objectives .guide { background: rgba(70, 50, 20, 0.92); border: 1px solid #c8a870; color: #fff2cc; padding: 5px 7px; margin-bottom: 4px; font-size: 12px; line-height: 1.35; }
#objectives .guide b { color: #ffd77a; margin-right: 4px; }
#objectives .guide .gskip { float: right; color: #c8a870; cursor: pointer; text-decoration: underline; margin-left: 6px; }

/* between chapters: the hold and the sea chart */
.seamodal { position: fixed; inset: 0; background: rgba(6, 10, 14, 0.82); display: flex; align-items: center; justify-content: center; z-index: 25; }
.sbox { background: #e9dcb8; color: #2c1d10; border: 4px double #5a4028; box-shadow: 0 0 0 3px #2a1c10, 0 20px 60px #000; padding: 12px 18px; max-height: 94vh; overflow: auto; }
.sbox h2 { margin: 0 0 6px; font-weight: normal; font-size: 1.8em; color: #4a2410; }
.sbox .dim { color: #6a5434; } .sbox .small { font-size: 0.9em; margin: 4px 0; } .sbox b { color: #000; }
.sbox .warn { color: #a0400a; } .sbox .hint { font-size: 0.85em; color: #6a5434; margin-top: 6px; }
.sbox button { margin: 2px; }
.cargo { width: min(640px, 94vw); }
.capbar { position: relative; height: 18px; background: #c8b890; border: 2px solid #5a4028; margin: 6px 0; }
.capbar i { position: absolute; left: 0; top: 0; bottom: 0; background: #5a7a3a; } .capbar i.over { background: #a03020; }
.capbar span { position: absolute; inset: 0; text-align: center; font-size: 0.85em; line-height: 14px; color: #1a120a; }
.ctable { max-height: 46vh; overflow: auto; margin: 6px 0; border: 1px solid #a8946a; }
.ctable table { width: 100%; border-collapse: collapse; }
.ctable td { padding: 1px 6px; border-bottom: 1px dashed #c4b08a; white-space: nowrap; }
.ctable td:last-child { text-align: right; } .ctable td button { padding: 0 6px; }
.ctable img { vertical-align: middle; }
.chart { display: flex; gap: 14px; width: min(1100px, 98vw); align-items: flex-start; }
.chl { position: relative; flex: 0 1 auto; }
.chl canvas { display: block; max-width: min(728px, 64vw); width: 100%; height: auto; border: 3px solid #5a4028; cursor: crosshair; image-rendering: auto; }
.chtip { min-height: 2.4em; font-size: 0.85em; color: #4a3018; margin-top: 4px; }
.chr { flex: 1 1 280px; min-width: 240px; }
.chstat .row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.sbar { display: inline-block; width: 140px; height: 10px; background: #c8b890; border: 1px solid #5a4028; position: relative; }
.sbar b { position: absolute; left: 0; top: 0; bottom: 0; background: #5a7a3a; } .sbar b.bad { background: #a03020; } .sbar b.mor { background: #3a6a9a; }
.chbtns { margin: 8px 0; }
.chlog { font-size: 0.85em; max-height: 34vh; overflow: auto; border-top: 1px solid #a8946a; padding-top: 4px; }
.chlog .l { margin: 2px 0; } .chlog .l span { color: #8a7454; margin-right: 4px; }
.chlog .l.danger { color: #8a2010; } .chlog .l.good { color: #2e5a1e; } .chlog .l.hint { color: #2a4a7a; }
@media (max-width: 800px) { .chart { flex-direction: column; } .chl canvas { max-width: 94vw; } }
.chlog .l.story { color: #4a2410; font-style: italic; } .chlog .l.discovery { color: #6a3a8a; } .chlog .l.landfall { color: #2e5a1e; font-weight: bold; }
.banner figure { width: calc(100px * var(--ui)); }
.menubox input[type=number], .menubox select { font-family: inherit; font-size: inherit; color: var(--text); background: #1a120c; border: 2px solid; border-color: var(--edge2) var(--hi) var(--hi) var(--edge2); padding: 0 4px; }
.menubox .mh + .dim { margin-top: 4px; }

/* touch screens */
#touchbar { display: none; position: absolute; right: 8px; bottom: 8px; flex-direction: column; gap: 6px; z-index: 6; }
body.touch #touchbar { display: flex; }
#touchbar button { width: 48px; height: 48px; font-size: 1.3em; padding: 0; background: rgba(42, 31, 23, 0.9); }
#touchbar button.on { background: linear-gradient(#7a5a2a, #4d3818); color: var(--gold); }
body.touch #side button, body.touch .menubox button, body.touch .cardbox button { min-height: 36px; }
body.touch #alerts { max-width: calc(100% - 80px); }
/* compact layout: the side panel slides over the map (☰ on the touch bar, or the tab) */
#sidetab { display: none; }
@media (max-width: 900px), (max-height: 520px) {
  #side { position: fixed; right: 0; top: 0; bottom: 0; z-index: 12; transform: translateX(100%); transition: transform 0.18s; width: min(calc(330px * var(--ui)), 86vw); }
  body.sideopen #side { transform: none; }
  #sidetab { display: block; position: fixed; right: 0; top: 40%; z-index: 11; width: 26px; height: 64px; padding: 0; border-right: none; }
  body.sideopen #sidetab { right: min(calc(330px * var(--ui)), 86vw); }
  body.title #sidetab { display: none; }
  #objectives { max-width: calc(100% - 70px); max-height: 40vh; overflow: auto; }
}
/* engraved plates on story cards */
.cardbox.withplate { width: min(760px, 94vw); }
img.cplate { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 3px solid #5a4028; box-shadow: 0 0 0 1px #2a1c10; margin: 0 0 8px; background: #e9dcb8; }
/* first steps */
.guide.tut { border-color: #7cc4f0; }
.guide.tut b { color: #7cc4f0; }
#tutarrow { position: absolute; z-index: 5; color: #ffe08a; font-size: 30px; transform: translate(-50%, -100%); text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; pointer-events: none; animation: tutbob 0.8s ease-in-out infinite alternate; display: none; }
#tutarrow.off { opacity: 0.6; }
@keyframes tutbob { from { margin-top: -8px; } to { margin-top: 2px; } }
.tutpulse { animation: tutpulse 0.9s ease-in-out infinite alternate; }
@keyframes tutpulse { from { box-shadow: 0 0 0 2px #ffe08a; } to { box-shadow: 0 0 0 5px rgba(255, 224, 138, 0.2); } }
button.mb.locked { opacity: 0.35; cursor: default; }
/* choice cards */
.choices { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 2px; text-align: left; }
.choices button.choice { text-align: left; padding: 6px 10px; background: linear-gradient(#5a4430, #3a2b1d); }
.choices button.choice.mercy { border-left: 4px solid #6aa04a; } .choices button.choice.ruthless { border-left: 4px solid #b04030; }
.trait { display: inline-block; border: 1px solid var(--edge); padding: 0 4px; margin: 1px 2px 1px 0; color: var(--gold); }
.cardbox .score { clear: both; border-top: 1px dashed #8a6a40; margin-top: 8px; padding-top: 6px; }
.cardbox .score .sh { font-size: 1.2em; color: #4a2410; } .cardbox .score .sl { font-size: 0.85em; color: #5a4430; margin: 3px 0 5px; }
/* chart v2: date, trade, home, battle */
.chdate { margin: 2px 0 6px; } .chdate .good { color: #2e5a1e; }
.tcols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.tcols .crow { display: flex; justify-content: space-between; align-items: center; margin: 2px 0; }
.battle { width: min(700px, 96vw); } .battle canvas.bcv { width: 100%; border: 2px solid #5a4028; display: block; margin: 4px 0; }
.bbtns { text-align: center !important; } .bbtns button { min-width: 96px; }
.chl canvas { max-width: min(760px, 64vw) !important; }
@media (max-width: 700px) { .tcols { grid-template-columns: 1fr; } }
.achl { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; } .ach { opacity: 0.55; } .ach.on { opacity: 1; } .ach.on b { color: var(--gold); }

/* rising '+5 wood' numbers over the map */
.floatnum { position: absolute; left: 0; top: 0; pointer-events: none; font: bold 15px Georgia, serif; color: #f3e6b0; white-space: nowrap;
  text-shadow: 0 0 2px #000, 1px 1px 0 #000, -1px -1px 0 #1a120a; z-index: 3; }
