:root { color-scheme: dark; --sea: #0b1320; --ink: #2b2116; --paper: #f1e6c8; --paper2: #e6d6ad; --gold: #ffd34d; --dim: #7f9bb3; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: radial-gradient(120% 90% at 50% -10%, #12233a 0%, var(--sea) 60%); color: #cfe3f0; min-height: 100vh;
  font: 15px/1.5 system-ui, sans-serif; padding: 12px 16px 40px; }
a { color: #9cc7ea; }
.top { display: flex; align-items: center; gap: 14px; max-width: 1240px; margin: 0 auto 8px; flex-wrap: wrap; }
.crumb { color: var(--dim); font-size: 13px; text-decoration: none; }
.crumb:hover { color: #fff; }
.top h1 { margin: 0; font: 600 18px/1.2 Georgia, serif; letter-spacing: .12em; color: #f4ead2; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top { flex-wrap: nowrap; }
.top h1 span { color: var(--dim); font-style: italic; letter-spacing: .02em; }
.seedtag { color: var(--dim); font-size: 12px; font-family: ui-monospace, monospace; }
.iconbtn { background: #16263b; color: #f4ead2; border: 1px solid #2c4a6b; border-radius: 8px; min-width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
.iconbtn:hover { background: #1e3550; }
.hud { max-width: 1240px; margin: 0 auto 10px; display: flex; gap: 6px; flex-wrap: wrap; min-height: 34px; }
.stat { background: #101d2e; border: 1px solid #22384f; border-radius: 999px; padding: 4px 11px; font-size: 13px; font-variant-numeric: tabular-nums; position: relative; }
.stat .ic { margin-right: 4px; opacity: .85; }
.stat .lb { color: var(--dim); }
.stat b { color: #f4ead2; }
.stat.warn { border-color: #d0603f; background: #2a1414; }
.stat.warn b { color: #ffb199; }
.stat .delta { font-style: normal; font-size: 11px; margin-left: 5px; }
.stat.up { animation: up .9s ease-out; } .stat.up .delta { color: #7ee2a0; }
.stat.down { animation: down .9s ease-out; } .stat.down .delta { color: #ff9a7a; }
.coin-gold { color: #ffd34d; } .coin-silver { color: #d6e2ee; } .coin-copper { color: #d98a52; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@keyframes up { from { box-shadow: 0 0 0 3px #7ee2a088; } }
@keyframes down { from { box-shadow: 0 0 0 3px #ff7a5a88; } }
.layout { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 768px) minmax(320px, 1fr); gap: 16px; align-items: start; }
.mapwrap { position: sticky; top: 12px; }
#map { width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 8px; box-shadow: 0 10px 40px #000a; background: #163460; touch-action: manipulation; }
.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.scene { background: linear-gradient(var(--paper), var(--paper2)); color: var(--ink); border-radius: 10px; padding: 16px 18px 14px;
  box-shadow: 0 8px 30px #0008, inset 0 0 40px #b8995a44; font-family: Georgia, 'Iowan Old Style', serif; border-left: 5px solid #b8995a; }
.scene.mood-good { border-left-color: #3f8f55; } .scene.mood-bad { border-left-color: #b8432a; }
.scene h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.scene p { margin: 0 0 9px; font-size: 16px; line-height: 1.55; }
.scene a { color: #6a3b12; }
.scene .dim { color: #7a6a50; font-size: 13px; }
.choices { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.choice { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: #fbf4e0; border: 1px solid #c7b07a; border-radius: 8px; padding: 9px 12px; min-height: 46px;
  transition: transform .08s ease, background .1s ease, border-color .1s ease; }
.choice:hover:not(:disabled), .choice:focus-visible { background: #fffaf0; border-color: #6a3b12; transform: translateX(3px); outline: none; box-shadow: 0 0 0 2px #6a3b1244; }
.choice:active:not(:disabled) { transform: translateX(3px) scale(.99); }
.choice:disabled { opacity: .55; cursor: not-allowed; background: #ece1c4; }
.choice .num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center;
  font: 700 12px system-ui; }
.choice.primary .num { background: #a4581a; }
.choice.risky .num { background: #8a2b1d; }
.choice.back { background: transparent; }
.choice .body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.choice .lbl { font-size: 16px; }
.choice .hint { font: 12.5px/1.35 system-ui; color: #6b5a3e; }
.choice .odds { flex: none; font: 600 12px system-ui; background: #e3d2a3; border-radius: 999px; padding: 2px 8px; color: #4a3a20; }
.sailbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; font: 13px system-ui; }
.sailbar button { font: inherit; border: 1px solid #c7b07a; background: #fbf4e0; color: var(--ink); border-radius: 6px; padding: 6px 10px; cursor: pointer; min-height: 36px; }
.sailbar button[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.sailbar .speeds { display: inline-flex; gap: 4px; }
.drawer { background: #101d2e; border: 1px solid #22384f; border-radius: 10px; padding: 8px 14px; font-size: 13.5px; }
.drawer summary { cursor: pointer; color: #f4ead2; font-weight: 600; padding: 3px 0; }
.drawer ul, .drawer ol { margin: 6px 0 4px; padding-left: 1.3em; }
#orders-list { list-style: none; padding: 0; }
#orders-list li { padding: 4px 0; border-bottom: 1px solid #1b2c40; }
#orders-list li small { display: block; color: var(--dim); margin-left: 1.7em; }
#orders-list .mi { display: inline-block; width: 1.5em; }
#orders-list .hold { color: var(--dim); border: 0; }
#orders-list .none { color: var(--dim); }
.log { font: 13px/1.5 Georgia, serif; color: #e9dcc0; max-height: 260px; overflow: auto; list-style: none; padding: 0 !important; }
.log li { padding: 2px 0; }
.menu { background: var(--paper); color: var(--ink); border: 0; border-radius: 12px; padding: 18px 20px; width: min(460px, 94vw); font-family: Georgia, serif; }
.menu::backdrop { background: #0009; }
.menu h2 { margin: 0 0 8px; }
.menu fieldset { border: 1px solid #c7b07a; border-radius: 8px; margin: 0 0 10px; padding: 8px 12px; }
.menu legend { font-weight: 600; padding: 0 4px; }
.menu label { margin-right: 12px; display: inline-flex; gap: 5px; align-items: center; min-height: 32px; }
.menu input[type=text], .menu input:not([type]) { font: 15px ui-monospace, monospace; padding: 5px 8px; border: 1px solid #c7b07a; border-radius: 6px; background: #fffaf0; color: var(--ink); }
.menu button { font: 14px system-ui; border: 1px solid #6a3b12; background: #fbf4e0; color: var(--ink); border-radius: 6px; padding: 7px 12px; cursor: pointer; min-height: 38px; }
.menu button:hover { background: #fff; }
.menu .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.menu .row.end { justify-content: flex-end; }
.menu .dim { color: #7a6a50; font-size: 12.5px; margin: 6px 0 0; }
.keys { list-style: none; margin: 0; padding: 0; font: 13px system-ui; }
.keys li { padding: 2px 0; }
kbd { display: inline-block; min-width: 3.6em; text-align: center; border: 1px solid #a8925f; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin-right: 6px; font: 11.5px ui-monospace, monospace; background: #fffaf0; }
/* dialogue */
.say { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 10px; }
.say .face { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: color-mix(in srgb, var(--c) 22%, #fbf4e0); border: 2px solid var(--c); }
.say > div { background: #fffaf0; border: 1px solid color-mix(in srgb, var(--c) 45%, #c7b07a); border-radius: 4px 12px 12px 12px; padding: 6px 11px; min-width: 0; }
.say b { color: var(--c); font: 700 12.5px system-ui; letter-spacing: .02em; filter: brightness(.75); }
.say p { margin: 1px 0 0; font-style: italic; }
/* cast drawer */
.cast { list-style: none; padding: 0 !important; margin: 6px 0; display: flex; flex-direction: column; gap: 8px; }
.cast li { display: flex; gap: 10px; align-items: flex-start; }
.cast .face { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; background: #182a40; border: 2px solid var(--c); }
.cast b { color: #f4ead2; } .cast small { color: var(--dim); }
.cast .blurb { display: block; font-size: 12px; }
.cast .rel { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #cfe3f0; }
.cast .rel.gone { opacity: .5; }
.pips { display: inline-flex; gap: 2px; } .pips i { width: 7px; height: 9px; border-radius: 2px; background: #22384f; }
.pips i.on { background: var(--c); }
/* settings dialog */
.config { width: min(860px, 96vw); max-height: 92vh; padding: 0; display: none; flex-direction: column; overflow: hidden; }
.config[open] { display: flex; }
.cfg-head { padding: 16px 20px 6px; border-bottom: 1px solid #c7b07a; }
.cfg-head p { margin: 4px 0 8px; font-size: 13.5px; }
.cfg-body { overflow: auto; padding: 10px 20px; flex: 1; }
.cfg-foot { padding: 10px 20px 14px; border-top: 1px solid #c7b07a; margin: 0; background: var(--paper2); }
.config .summary { font: 13px system-ui; margin: 4px 0; color: #4a3a20; }
.config .notes { font: 13px system-ui; color: #8a3a12; margin: 0; padding: 0 20px; min-height: 0; }
.config .notes:not(:empty) { padding: 6px 20px; }
.config .grp { margin-bottom: 12px; }
.config .grp > .dim { margin: 0 0 6px; }
.config h4 { margin: 8px 0 4px; font: 600 11px system-ui; text-transform: uppercase; letter-spacing: .12em; color: #7a6a50; }
.config .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.config .f { display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 2px; margin: 0; min-height: 0; font: 13.5px system-ui; padding: 5px 8px; border-radius: 6px; border-left: 3px solid transparent; }
.config .f.ch { border-left-color: #a4581a; background: #fff6e2; }
.config .f > span { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.config .f small { color: #7a6a50; font-size: 11.5px; }
.config .f input[type=number] { font: 14px ui-monospace, monospace; padding: 4px 6px; border: 1px solid #c7b07a; border-radius: 5px; background: #fffaf0; color: var(--ink); width: 100%; }
.config .f input[type=range] { width: 100%; accent-color: #a4581a; }
.config output { font: 600 12.5px ui-monospace, monospace; color: #6a3b12; }
.config .sched { grid-column: 1 / -1; }
.config .sched ol { margin: 4px 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 4px; }
.config .sched li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font: 13.5px system-ui; }
.config .sched input { width: 6.5em !important; }
.config .x { min-height: 30px; padding: 2px 9px; }
.config .small { min-height: 30px; padding: 3px 10px; align-self: flex-start; }
.config .row { align-items: center; }
.config .grow { flex: 1; min-width: 0; }
.config .col { display: flex; flex-direction: column; align-items: stretch; margin: 6px 0 0; font: 13px system-ui; gap: 3px; }
.config .col .row { margin: 0; }
.config input#cfg-code, .config input#cfg-import-code, .config input#cfg-name { font: 13px ui-monospace, monospace; padding: 6px 8px; border: 1px solid #c7b07a; border-radius: 6px; background: #fffaf0; color: var(--ink); }
.config select { font: 14px system-ui; padding: 5px; border-radius: 6px; border: 1px solid #c7b07a; background: #fffaf0; color: var(--ink); max-width: 60vw; }
.menu button.primary { background: #a4581a; color: #fff; border-color: #6a3b12; }
.menu button.danger { border-color: #8a2b1d; color: #8a2b1d; }
.menu button.wide { width: 100%; }
@media (max-width: 560px) { .cfg-head, .cfg-body, .cfg-foot { padding-left: 12px; padding-right: 12px; } .cfg-foot .grow { display: none; } .config .sched input { width: 4.6em !important; } .config .sched li { gap: 4px; } }
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .mapwrap { position: static; }
}
@media (max-width: 560px) {
  body { padding: 8px 8px 30px; }
  .top { gap: 8px; }
  .top h1 { font-size: 14px; letter-spacing: .06em; }
  .top h1 span, .seedtag { display: none; }
  .crumb { font-size: 12px; white-space: nowrap; }
  .stat .lb { display: none; }
  .scene { padding: 12px 13px; }
  .scene p { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .stat.up, .stat.down { animation: none; } .choice { transition: none; } }
