/* MONSOON LINE — Tactile 16-Bit Brass, Teakwood & Ledger Parchment Game UI
   Zero web-app cards, zero border-radius SaaS styling, crisp integer pixel-font sizes throughout.
   Bitmap font rule: PressStart strictly at 8px / 16px / 24px; Sembako at 14px / 16px;
   Fusion Pixel ZH (OFL-1.1) at native 12px / 14px / 16px for Simplified Chinese. */

@font-face {
  font-family: 'PressStart';
  src: url('fonts/press-start-2p.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Sembako';
  src: url('fonts/sembako-pixel-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Sembako';
  src: url('fonts/sembako-pixel-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Fusion Pixel Latin';
  src: url('fonts/fusion-pixel-latin.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+00A0-024F, U+2000-2BFF;
}
@font-face {
  font-family: 'Fusion Pixel ZH';
  src: url('fonts/fusion-pixel-zh.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+2E80-9FFF, U+3000-303F, U+FF00-FFEF;
}

:root {
  --abyss: #110c09;
  --wood-dk: #24140c;
  --wood-mid: #402415;
  --wood-lt: #623b23;
  --wood-hi: #805232;
  --brass-dk: #714a14;
  --brass: #c49235;
  --brass-hi: #f3d57a;
  --paper: #efe1be;
  --paper-dk: #d9c597;
  --paper-line: #c6af7e;
  --ink: #291810;
  --ink-soft: #5c402c;
  --seal: #a82e24;
  --seal-hi: #db4e3f;
  --sea: #276e72;
  --sea-hi: #56b5b2;
  --good: #2d7a47;
  --warn: #b5661a;
  --cjk: 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'Sembako', 'Fusion Pixel Latin', var(--cjk), monospace;
  --font-px: 'PressStart', var(--cjk), monospace;
}

html[data-lang="zh"] {
  --cjk: 'Fusion Pixel ZH', 'PingFang SC', 'Noto Sans CJK SC', sans-serif;
}
html[data-lang="zh"] * {
  line-break: strict;
  word-break: normal;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

/* Form controls don't inherit fonts by default; without this, any button without its own
   font-family (e.g. the save-slot cards) falls back to the browser's system sans. */
button, input, select, textarea { font-family: inherit; }

button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brass-hi);
  outline-offset: 1px;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--abyss);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  image-rendering: pixelated;
}

.hidden { display: none !important; }

/* FULL 16:9 GAME CABINET FRAME */
#cabinet {
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
  /* dvh = the visible viewport (excludes mobile browser toolbars); vh is the fallback */
  width: min(100vw, 177.78dvh);
  height: min(100dvh, 56.25vw);
  max-width: 1440px;
  max-height: 810px;
  background: var(--wood-dk);
  border: 4px solid var(--brass-dk);
  box-shadow:
    inset 0 0 0 3px var(--wood-lt),
    inset 0 0 0 5px #170d08;
  display: grid;
  grid-template-rows: 40px 1fr 224px;
  padding: 5px;
  gap: 5px;
  position: relative;
}

/* TOP BRASS INSTRUMENT STRIP */
#hud {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 4px;
  background: var(--wood-mid);
  border: 2px solid #160c07;
  box-shadow: inset 0 2px 0 var(--wood-hi), inset 0 -2px 0 var(--wood-dk);
  padding: 3px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.hud-plate {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1c120c;
  border: 2px solid var(--brass-dk);
  box-shadow: inset 0 0 0 1px #0d0805;
  padding: 2px 5px;
  height: 30px;
  white-space: nowrap;
}

.lbl {
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--brass);
}

#hud strong {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--brass-hi);
  line-height: 1;
}

.sub-warn { font-size: 14px; color: #f08a6d; }
.sub-dim { font-size: 14px; color: #c7b18a; }

.pill {
  font-family: var(--font-px);
  font-size: 8px;
  padding: 3px 4px;
  border: 1px solid #140b06;
  white-space: nowrap;
  line-height: 1;
}
.pill-dry { background: #8f5c1a; color: #fff0c4; }
.pill-monsoon { background: #294e6e; color: #d6ecff; }
.pill-act { background: #4f2a1d; color: #f3d57a; }
.pill-ok { background: #26593a; color: #ccf2d4; }
.pill-warn { background: #945214; color: #fff0c8; }
.pill-risk { background: #8e2820; color: #ffdad4; }

.hud-gauges { justify-content: space-around; gap: 5px; }
.gauge { display: flex; align-items: center; gap: 3px; font-size: 14px; color: #d9c597; }
.gauge span { font-family: var(--font-px); font-size: 8px; color: var(--brass); }
.gauge b { font-family: var(--font-body); font-size: 14px; color: var(--paper); min-width: 28px; text-align: right; }
.bar {
  width: 28px;
  height: 10px;
  background: #0f0906;
  border: 2px solid #6b4920;
  padding: 1px;
}
.bar i { display: block; height: 100%; width: 50%; }
.fill-fuel { background: #d6852a; }
.fill-hull { background: #4aa36c; }
.fill-hold { background: #4ea5b5; }

.hud-tools { display: flex; gap: 3px; }

.brass-mini {
  font-family: var(--font-px);
  font-size: 8px;
  background: var(--brass);
  color: #1f1108;
  border: 2px solid #221309;
  box-shadow: inset 0 2px 0 var(--brass-hi), inset 0 -2px 0 var(--brass-dk);
  padding: 5px 5px;
  cursor: pointer;
  line-height: 1;
}
.brass-mini:hover:not(:disabled) { background: #dba94a; }
.brass-mini:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 2px 0 var(--brass-dk); }
.brass-mini.off { background: #5a4028; color: #b9a482; box-shadow: inset 0 2px 0 #705134; }
.brass-mini:disabled { opacity: 0.4; cursor: not-allowed; }

/* MIDDLE COCKPIT: EXACT 16:9 LIVING STAGE + RIGHT BRIDGE PANEL */
#mid-deck {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px;
  min-height: 0;
  height: 100%;
}

#stage-wrap {
  position: relative;
  height: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  background: #0d1d24;
  border: 3px solid #160c07;
  box-shadow: inset 0 0 0 2px var(--brass-dk);
  overflow: hidden;
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* RIGHT WHEELHOUSE BRIDGE SIDEBAR (LIVE STATUS + CAPTAIN'S BRIEF) */
#bridge-side {
  background: var(--wood-mid);
  border: 3px solid #160c07;
  box-shadow:
    inset 0 0 0 2px var(--brass-dk),
    inset 0 2px 0 var(--wood-hi);
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

.bridge-box {
  background: #21130b;
  border: 2px solid #6b4920;
  padding: 6px 8px;
}
.bridge-box.paper {
  background: var(--paper);
  color: var(--ink);
  border-color: #7d5b2d;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bridge-title {
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--brass-hi);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.bridge-box.paper .bridge-title {
  color: var(--wood-mid);
  border-bottom: 2px solid #9d7d4d;
  padding-bottom: 3px;
}

.bridge-port-name {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--brass-hi);
  margin-bottom: 2px;
  letter-spacing: 0.4px;
}
.bridge-desc {
  font-size: 14px;
  color: #dbc89e;
  line-height: 1.28;
}
.bridge-radio {
  font-size: 14px;
  color: #a8e4de;
  line-height: 1.28;
  background: #132227;
  border: 2px solid #305b60;
  padding: 5px 7px;
}

/* STAGE DISPLAY SCALING (SHARP-BILINEAR & ANALOG SHADER RENDERED VIA WEBGL) */
#stage-wrap[data-display="raw"] #stage { image-rendering: pixelated; }
#stage-wrap:not([data-display="raw"]) #stage { image-rendering: auto; }

/* FLOATING TOAST RIBBON */
#toast-bar {
  position: absolute;
  top: 7px;
  right: 8px;
  background: #22130b;
  border: 2px solid var(--brass);
  box-shadow: inset 0 0 0 1px #110804;
  color: var(--brass-hi);
  font-size: 14px;
  padding: 4px 8px;
  max-width: 72%;
  z-index: 6;
}

/* CLASSIC 16-BIT TEAKWOOD DIALOGUE BOX */
#dialogue {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 12;
}

.dlg-frame {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  background: rgba(56, 31, 18, 0.96);
  border: 3px solid #150b06;
  box-shadow:
    inset 0 0 0 2px var(--brass),
    inset 0 0 0 4px var(--wood-dk);
  padding: 8px 10px;
}

.dlg-portrait-wrap {
  width: 72px;
  height: 72px;
  background: #1f333a;
  border: 3px solid var(--brass-dk);
  box-shadow: inset 0 0 0 2px #140b06;
  display: grid;
  place-items: center;
}
#dlg-face { width: 68px; height: 68px; image-rendering: pixelated; }

.dlg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
  border-bottom: 2px solid var(--wood-dk);
  padding-bottom: 3px;
}
.dlg-name {
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--brass-hi);
}
.dlg-tag {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  color: #f0b56c;
}

#dlg-body {
  font-size: 16px;
  line-height: 1.3;
  color: var(--paper);
  margin-bottom: 6px;
  min-height: 40px;
  cursor: pointer;
}

#dlg-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.choice-btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid #1b0e08;
  box-shadow: inset 0 2px 0 #fff7df, inset 0 -2px 0 var(--paper-dk);
  padding: 4px 9px;
  cursor: pointer;
  text-align: left;
}
.choice-btn:hover:not(:disabled) { background: #fff3cf; }
.choice-btn:active:not(:disabled) { transform: translateY(1px); }
.choice-btn:disabled { opacity: 0.48; cursor: not-allowed; }
.choice-btn.confirm-armed {
  background: var(--seal);
  color: #fff2d8;
  box-shadow: inset 0 2px 0 var(--seal-hi), inset 0 -2px 0 #6b1a14;
}

/* FULL-CABINET TITLE SCREEN OVER LIVE HARBOUR */
/* TACTILE BRASS LANGUAGE SELECTOR (EN / ID / 中文) */
.lang-strip {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}
.lang-pill {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  background: #23130b;
  color: #cbb690;
  border: 2px solid #784f14;
  padding: 3px 11px;
  cursor: pointer;
}
.lang-pill:hover { border-color: var(--brass-hi); color: var(--paper); }
.lang-pill.active {
  background: var(--brass);
  color: #1c1007;
  border-color: #1c1007;
  box-shadow: inset 0 2px 0 var(--brass-hi), inset 0 -2px 0 var(--brass-dk);
}



.slot-confirm {
  background: #3d1812;
  border: 2px solid var(--seal-hi);
  color: #ffebd2;
  padding: 6px 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  text-align: left;
}

.wood-btn {
  font-family: var(--font-px);
  font-size: 8px;
  background: var(--wood-lt);
  color: var(--paper);
  border: 2px solid #160b06;
  box-shadow: inset 0 2px 0 var(--wood-hi), inset 0 -2px 0 var(--wood-dk);
  padding: 9px 12px;
  cursor: pointer;
}
.wood-btn.primary {
  background: var(--brass);
  color: #1c1007;
  box-shadow: inset 0 2px 0 var(--brass-hi), inset 0 -2px 0 var(--brass-dk);
}
.wood-btn:hover { filter: brightness(1.08); }
.wood-btn:active { transform: translateY(2px); }

/* LOWER SHIP'S DESK & BRASS FOLIO TABS */
#desk {
  display: grid;
  grid-template-rows: 28px 1fr;
  gap: 0;
  min-height: 0;
}

#desk-tabs {
  display: flex;
  gap: 4px;
  padding-left: 4px;
}

.desk-tab {
  font-family: var(--font-px);
  font-size: 8px;
  background: #2f1b10;
  color: #bfa67e;
  border: 2px solid #160c07;
  border-bottom: none;
  padding: 3px 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.desk-tab i {
  font-style: normal;
  background: #1b0f08;
  color: var(--brass);
  padding: 2px 4px;
}
.desk-tab em {
  font-style: normal;
  background: var(--seal);
  color: #fff2d6;
  padding: 2px 4px;
  font-size: 8px;
}
.desk-tab em:empty { display: none; }
.desk-tab.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 2px 0 #fff7df;
}
.desk-tab.active i { background: var(--wood-mid); color: var(--brass-hi); }

#desk-pane {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid #180d07;
  box-shadow:
    inset 0 0 0 2px var(--brass-dk),
    inset 0 2px 0 #fff7df;
  padding: 7px 9px;
  overflow: hidden;
  display: grid;
}

/* SHARED FOLIO LAYOUTS */
.split-2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 8px; height: 100%; min-height: 0; }
.split-even { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; height: 100%; min-height: 0; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; height: 100%; min-height: 0; }

.folio-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #e7d6ae;
  border: 2px solid #8c6d41;
  padding: 5px 7px;
}

.folio-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--wood-mid);
  border-bottom: 2px solid #9d7d4d;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.scroll-y {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 3px;
}
.scroll-y::-webkit-scrollbar { width: 8px; }
.scroll-y::-webkit-scrollbar-track { background: #cdb584; border-left: 1px solid #9c7e4e; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--wood-lt); border: 1px solid #2b180e; }

/* LEDGER ROWS & STAMPED BUTTONS */
.ledger-row {
  display: grid;
  align-items: center;
  gap: 5px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--paper-line);
  font-size: 14px;
}
.ledger-row:nth-child(even) { background: rgba(155, 122, 68, 0.12); }

.market-row { grid-template-columns: 1.3fr 48px 1.15fr auto; }
.hold-row { grid-template-columns: 1.2fr 56px 60px auto; }
.isle-row { grid-template-columns: 1.35fr 66px 46px auto; }

.slot-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.slot-card {
  background: #23130b;
  border: 2px solid #784f14;
  color: #e6d5ad;
  padding: 6px 7px;
  font-size: 14px;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
}
.slot-card.active { border-color: var(--brass-hi); background: #361e11; }
.slot-card b {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--brass-hi);
  margin-bottom: 3px;
}
.queue-strip {
  background: #e6d3a3;
  border: 1px solid #8c6d41;
  padding: 3px 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.stamp-btn {
  font-family: var(--font-px);
  font-size: 8px;
  background: var(--wood-lt);
  color: var(--paper);
  border: 2px solid #221209;
  box-shadow: inset 0 2px 0 var(--wood-hi);
  padding: 4px 6px;
  cursor: pointer;
  line-height: 1;
}
.stamp-btn.gold { background: var(--brass); color: #1f1107; box-shadow: inset 0 2px 0 var(--brass-hi); }
.stamp-btn.sea { background: var(--sea); color: #e4fbf8; box-shadow: inset 0 2px 0 var(--sea-hi); }
.stamp-btn.seal { background: var(--seal); color: #ffeed9; box-shadow: inset 0 2px 0 var(--seal-hi); }
.stamp-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stamp-btn:active:not(:disabled) { transform: translateY(1px); }

.btn-group { display: flex; gap: 3px; justify-content: flex-end; }

/* Tags use crisp body pixel font (14px) so Latin & CJK stay sharp */
.tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 4px;
  border: 1px solid #2a180d;
  vertical-align: middle;
}
.tag-outer { background: #8a5618; color: #fff0c7; }
.tag-inner { background: #2c656c; color: #daf8f6; }
.tag-seal { background: var(--seal); color: #ffebd2; }
.tag-good { background: var(--good); color: #ddfae4; }
.tag-warn { background: var(--warn); color: #fff1d4; }

.voucher {
  background: #f6ebd0;
  border: 2px solid #8a693b;
  border-left: 5px solid var(--seal);
  padding: 4px 6px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.voucher.active { border-left-color: var(--sea); }
.voucher-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.voucher-sub { font-size: 14px; color: var(--ink-soft); line-height: 1.25; }

.route-box {
  background: #f5e8c8;
  border: 2px solid #7d5b2d;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}
.route-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  font-size: 14px;
  margin: 4px 0;
}
.route-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.sail-lever {
  font-family: var(--font-px);
  font-size: 8px;
  background: var(--brass);
  color: #1c0f06;
  border: 2px solid #1d1008;
  box-shadow: inset 0 2px 0 var(--brass-hi), inset 0 -2px 0 var(--brass-dk);
  padding: 7px 10px;
  cursor: pointer;
  flex: 1;
}
.sail-lever.stop {
  background: var(--seal);
  color: #ffeed9;
  box-shadow: inset 0 2px 0 var(--seal-hi), inset 0 -2px 0 #661712;
}
.sail-lever:disabled { opacity: 0.4; cursor: not-allowed; }
.sail-lever:active:not(:disabled) { transform: translateY(2px); }

.up-card {
  background: #f5e9cb;
  border: 2px solid #8c6d41;
  padding: 4px 6px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.up-card.owned { background: #dce7d3; border-color: #4b7856; }

/* VOYAGE LOGBOOK & SCORELESS REMEMBERED OVERLAY */
#review-overlay {
  position: absolute;
  inset: 8px;
  z-index: 25;
  background: var(--wood-mid);
  border: 4px solid var(--brass);
  box-shadow: inset 0 0 0 3px var(--wood-dk), 0 0 0 4px #110905;
  display: flex;
  flex-direction: column;
  padding: 7px;
}
.book-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.book-tabs { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.book-tab {
  font-family: var(--font-px);
  font-size: 8px;
  background: var(--wood-dk);
  color: #ccb38a;
  border: 2px solid #140a05;
  padding: 6px 9px;
  cursor: pointer;
}
.book-tab.active { background: var(--paper); color: var(--ink); }
#book-close { margin-left: auto; }
.book-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid #7d5b2d;
  padding: 10px 14px;
}
.stamp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 6px; }
.stamp-tile {
  border: 2px dashed #9d7d4d;
  padding: 4px 6px;
  background: #e6d5ad;
  opacity: 0.56;
}
.stamp-tile.earned {
  border-style: solid;
  border-color: var(--seal);
  background: #f9eed2;
  opacity: 1;
}
.remembered-page {
  max-width: 580px;
  margin: 4px auto;
  text-align: center;
}
.remembered-page h2 {
  font-family: var(--font-px);
  font-size: 16px;
  color: var(--wood-mid);
  margin-bottom: 10px;
}
.mem-item {
  font-size: 16px;
  line-height: 1.45;
  padding: 6px 0;
  border-bottom: 1px solid var(--paper-line);
  color: var(--ink);
}
.mem-day { font-family: var(--font-px); font-size: 8px; color: var(--seal); display: block; margin-bottom: 2px; }
.mem-poem {
  margin-top: 12px;
  font-size: 16px;
  font-style: italic;
  color: var(--wood-mid);
  line-height: 1.55;
}

/* WHEELHOUSE OPTIONS DRAWER (ANALOG DISPLAY, AUDIO CHANNELS, QOL PACING) */
#opts-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  background: rgba(14, 9, 6, 0.62);
  display: grid;
  place-items: center;
}
.opts-frame {
  width: min(620px, 92%);
  max-height: 88%;
  background: var(--wood-mid);
  border: 4px solid var(--brass);
  box-shadow: inset 0 0 0 3px var(--wood-dk), 0 0 0 4px #110905;
  padding: 8px;
  display: flex;
  flex-direction: column;
}
.opts-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--brass-hi);
  padding: 2px 4px 7px;
}
.opts-body {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid #7d5b2d;
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.opt-group {
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 8px;
}
.opt-group:last-child { border-bottom: none; padding-bottom: 0; }
.opt-lbl {
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--wood-mid);
  margin-bottom: 5px;
}
.opt-desc {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.seg-btn {
  font-family: var(--font-px);
  font-size: 8px;
  background: #d9c597;
  color: var(--ink);
  border: 2px solid #5c3f1d;
  padding: 5px 8px;
  cursor: pointer;
}
.seg-btn:hover { background: #f6e7c3; }
.seg-btn.active {
  background: var(--wood-mid);
  color: var(--brass-hi);
  border-color: #1c0f08;
  box-shadow: inset 0 2px 0 var(--wood-hi);
}
.opt-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.opt-import-bar {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}
.opt-import-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14px;
  background: #fbf3df;
  color: var(--ink);
  border: 2px solid #7d5b2d;
  padding: 3px 6px;
  user-select: text;
}
.opt-keys {
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
  background: #e6d5ad;
  border: 1px solid #9d7d4d;
  padding: 4px 6px;
}

/* NATIVE 12PX PIXEL TYPOGRAPHY TUNING FOR SIMPLIFIED CHINESE (FUSION PIXEL ZH 1:1 GRID!) */
html[data-lang="zh"] .lbl,
html[data-lang="zh"] .pill,
html[data-lang="zh"] .gauge span,
html[data-lang="zh"] .brass-mini,
html[data-lang="zh"] .bridge-title,
html[data-lang="zh"] .dlg-name,
html[data-lang="zh"] .title-crest,
html[data-lang="zh"] .wood-btn,
html[data-lang="zh"] .desk-tab,
html[data-lang="zh"] .folio-head,
html[data-lang="zh"] .slot-card b,
html[data-lang="zh"] .stamp-btn,
html[data-lang="zh"] .sail-lever,
html[data-lang="zh"] .book-tab,
html[data-lang="zh"] .mem-day,
html[data-lang="zh"] .opts-head,
html[data-lang="zh"] .opt-lbl,
html[data-lang="zh"] .seg-btn {
  font-size: 12px;
}
html[data-lang="zh"] .brass-mini { padding: 3px 5px; }
html[data-lang="zh"] .pill { padding: 2px 4px; }
html[data-lang="zh"] .desk-tab { padding: 2px 8px; }
html[data-lang="zh"] .stamp-btn { padding: 3px 6px; }
html[data-lang="zh"] .wood-btn { padding: 7px 12px; }
html[data-lang="zh"] .seg-btn { padding: 4px 8px; }
html[data-lang="zh"] .title-plaque h1 { font-size: 24px; letter-spacing: 3px; }
html[data-lang="zh"] .tag { font-size: 12px; padding: 2px 4px; }

/* RESPONSIVE SAFEGUARDS FOR COMPACT LAPTOPS (< 1140px) */
@media (max-width: 1140px) {
  #cabinet { grid-template-rows: 38px 1fr 206px; }
  .hud-plate { gap: 3px; padding: 2px 4px; }
  .bar { width: 22px; }
  .desk-tab { padding: 3px 6px; gap: 4px; }
}
/* Compact HUD (laptops < 1140px and fit mode, which lays out at 960px): drop the plate
   captions and the language button (it lives in Options) so the tool buttons stay visible. */
@media (max-width: 1140px) {
  .hud-plate > .lbl, #btn-lang { display: none; }
}
html.fit .hud-plate { gap: 3px; padding: 2px 4px; }
html.fit .bar { width: 22px; }
html.fit .desk-tab { padding: 3px 6px; gap: 4px; }
html.fit .hud-plate > .lbl, html.fit #btn-lang { display: none; }

/* FIT MODE (phones in landscape, small windows): below 960x540 the fixed-pixel rows stop
   working, so lay the cabinet out at 960x540 and scale it uniformly to the visible
   viewport. --fit is set from window.visualViewport in main.js, so the iOS Safari tab
   bar / toolbars are excluded and the frame re-fits when they collapse. */
html.fit #cabinet {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 960px;
  height: 540px;
  max-width: none;
  max-height: none;
  grid-template-rows: 38px 1fr 206px;
  transform: translate(-50%, -50%) scale(var(--fit, 1));
  transform-origin: center center;
}

/* ROTATE PROMPT: phones held in portrait */
#rotate-prompt { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  #rotate-prompt {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background: var(--abyss);
    color: var(--paper);
  }
  #cabinet { visibility: hidden; }
}
#rotate-prompt .rotate-icon {
  width: 46px;
  height: 76px;
  border: 4px solid var(--brass-hi);
  border-radius: 8px;
  box-shadow: inset 0 0 0 3px var(--wood-dk);
  animation: rotate-hint 2.4s ease-in-out infinite;
}
#rotate-prompt h2 {
  font-family: var(--font-px);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--brass-hi);
  line-height: 1.6;
}
#rotate-prompt p { font-size: 16px; line-height: 1.4; max-width: 280px; }
@keyframes rotate-hint {
  0%, 25% { transform: rotate(0deg); }
  50%, 80% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  #rotate-prompt .rotate-icon { animation: none; transform: rotate(-90deg); }
}

/* Daily sprint: today's best result on the title plaque */
.sprint-best {
  margin-top: -2px;
  font-size: 14px;
  color: #c8b07a;
  text-align: center;
}
.sprint-best b { color: var(--brass-hi); }

.stamp-btn.confirm-armed {
  background: #a82e24;
  border-color: #f0a684;
  color: #fff3cf;
}
html.fit #hud-audit { display: none; } /* audit countdown is also in the Captain's Brief */
html.fit #hud { gap: 2px; padding: 3px 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================ BOOT / LOADER */
#boot {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(240, 180, 90, 0.10), transparent 60%),
    linear-gradient(#170e09, #0d0806);
  transition: opacity 0.45s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
#boot.ready { cursor: pointer; }
.boot-inner { width: min(360px, 86%); text-align: center; }
.boot-studio {
  font-family: var(--font-px);
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--brass-hi);
  text-shadow: 0 3px 0 #5a3410, 0 0 18px rgba(245, 184, 85, 0.25);
}
.boot-presents { margin: 6px 0 14px; color: #c9b48d; font-size: 16px; letter-spacing: 2px; }
.boot-sea {
  position: relative;
  height: 96px;
  margin: 0 auto 14px;
  overflow: hidden;
  background: linear-gradient(transparent 0 66%, #1f6f70 66% 70%, #2a8c88 70% 100%);
  border-bottom: 2px solid #12403f;
}
.boot-sea::after {
  /* little pixel wave crests sliding under the boat */
  content: '';
  position: absolute;
  left: 0; right: -32px; bottom: 6px; height: 4px;
  background: repeating-linear-gradient(90deg, #9fe7dc 0 6px, transparent 6px 16px);
  animation: boot-waves 1.6s steps(8) infinite;
  opacity: 0.6;
}
.boot-boat {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 152px;
  height: auto;
  image-rendering: pixelated;
  transform-origin: 50% 90%;
  animation: boot-bob 2.4s ease-in-out infinite;
}
@keyframes boot-bob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1.2deg); }
  50% { transform: translateX(-50%) translateY(3px) rotate(1.2deg); }
}
@keyframes boot-waves { to { transform: translateX(-16px); } }
.boot-bar {
  height: 14px;
  padding: 2px;
  background: #1c120c;
  box-shadow: 0 0 0 2px var(--brass-dk), 0 3px 0 2px #0b0604;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--brass-hi) 0 10px, var(--brass) 10px 12px);
  transition: width 0.15s steps(4);
}
.boot-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 14px;
  color: #c9b48d;
  min-height: 18px;
}
.boot-start {
  visibility: hidden;
  margin: 16px auto 10px;
  display: block;
  background: none;
  border: 0;
  color: var(--brass-hi);
  cursor: pointer;
}
.boot-start b { font-family: var(--font-px); font-size: 14px; letter-spacing: 1px; display: block; }
.boot-start small { display: block; margin-top: 6px; font-size: 14px; color: #c9b48d; }
#boot.ready .boot-start { visibility: visible; animation: boot-pulse 1.4s ease-in-out infinite; }
.boot-caret { font-size: 10px; }
@keyframes boot-pulse { 50% { opacity: 0.55; } }
.boot-retry { display: none; margin: 14px auto 8px; }
#boot.slow .boot-retry, #boot.failed .boot-retry { display: inline-block; }
#boot.failed .boot-start { display: none; }
#boot .lang-strip { margin-top: 6px; }

/* ============================================================ TITLE */
#title-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  background: #120a06 url('src/gfx/art/title_lqip.webp') center / cover no-repeat;
}
.title-art { position: absolute; inset: 0; }
#title-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.title-langs {
  position: absolute;
  top: 10px;
  right: 12px;
  margin: 0;
  z-index: 2;
}
.title-band {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 26px 18px 8px;
  background: linear-gradient(to bottom, transparent, rgba(16, 9, 5, 0.78) 22%, rgba(16, 9, 5, 0.92));
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.title-band.in { opacity: 1; transform: none; pointer-events: auto; }
.title-langs { opacity: 0; transition: opacity 0.5s ease 0.2s; }
#title-overlay.revealed .title-langs { opacity: 1; }
.title-sub {
  text-align: center;
  font-size: 16px;
  color: var(--paper);
  text-shadow: 0 2px 0 #1c0e07;
  margin-bottom: 8px;
}
.title-cols {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
  gap: 12px;
  align-items: start;
  max-width: 980px;
  margin: 0 auto;
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.title-actions .wood-btn { width: 100%; }
.title-right .slot-strip { margin-bottom: 4px; }
.title-right .slot-confirm { margin-bottom: 6px; }
.title-foot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  max-width: 980px;
  margin: 8px auto 0;
}
.title-foot { font-size: 14px; color: #c9b48d; }
.title-links { display: flex; gap: 6px; flex-shrink: 0; }
.title-links a {
  font-size: 14px;
  color: var(--paper);
  text-decoration: none;
  background: #1c120c;
  border: 2px solid #784f14;
  padding: 2px 8px;
}
.title-links a:hover { border-color: var(--brass-hi); }
.title-links a.kofi { background: #8c2a2a; border-color: #c25a4a; }
.title-credits { text-align: center; font-size: 12px; color: #8f7a58; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  .boot-boat, .boot-sea::after, #boot.ready .boot-start, .title-band {
    animation: none;
  }
}
