/* CLOSED CASKET 3D prototype. Same paper/tape/stamp look as the 2D game. No inline styles anywhere
 * (CSP style-src 'self'). Fonts self-hosted (SIL OFL 1.1, see /fonts). Code: 0BSD. */
@font-face { font-family: "IM Fell English SC"; src: url("../fonts/IMFeENsc28P.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("../fonts/CourierPrime-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Courier Prime"; src: url("../fonts/CourierPrime-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bungee"; src: url("../fonts/Bungee-Regular.woff2") format("woff2"); font-display: swap; }
:root { --night: #0d1424; --deep: #080c17; --sodium: #ffb347; --teal: #3fd0c9; --pink: #ff6fae; --bone: #efe6d2; --paper2: #e6dcc4; --ink: #1b1b1f; --muted: #6b6560; --wine: #8c2f4b; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--deep); color: var(--bone); overflow: hidden; font-family: "Courier Prime", "Courier New", monospace; -webkit-tap-highlight-color: transparent; }
body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.title canvas#c { filter: blur(2px) brightness(.7); }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
[hidden] { display: none !important; }
.screen { position: absolute; inset: 0; display: none; overflow: auto; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen.on { display: flex; }
.screen > .card { margin: auto; }
#scr-title { background: radial-gradient(ellipse at 50% 120%, rgba(255,111,174,.18), transparent 60%), radial-gradient(ellipse at 20% -10%, rgba(63,208,201,.12), transparent 55%), linear-gradient(#080c17cc, #0d1424ee); }
h1, h2, h3 { font-family: "IM Fell English SC", Georgia, serif; font-weight: 400; margin: 0 0 .4em; }
h2 small { font-family: "Courier Prime", monospace; font-size: .55em; color: var(--muted); }
.card { position: relative; background: var(--bone); color: var(--ink); padding: 26px 30px 22px; max-width: 620px; width: 100%; border: 2px solid var(--ink);
  border-radius: 3px 5px 4px 6px / 6px 3px 5px 4px; box-shadow: 6px 7px 0 rgba(0,0,0,.55); transform: rotate(-.4deg); }
.card.wide { max-width: 900px; }
.card.memo { background-image: repeating-linear-gradient(transparent 0 31px, rgba(63,120,160,.18) 31px 32px); background-position: 0 14px; }
.small-card { max-width: 320px; text-align: center; }
.tape { position: absolute; top: -12px; left: 50%; width: 120px; height: 26px; margin-left: -60px; background: rgba(255,179,71,.6); transform: rotate(2deg); }
.title-card h1 { font-size: clamp(34px, 7vw, 58px); letter-spacing: .02em; margin-bottom: 0; }
.title-card .sub { margin: 0 0 18px; color: var(--muted); }
.title-card h2 { font-size: 20px; margin-top: 6px; }
.sticker { position: absolute; right: -14px; top: -18px; background: var(--pink); color: var(--ink); font: 700 12px/1.15 "Courier Prime", monospace; text-align: center;
  padding: 12px 10px; border: 2px solid var(--ink); border-radius: 50%; width: 92px; height: 92px; display: flex; align-items: center; justify-content: center; transform: rotate(12deg); box-shadow: 3px 3px 0 var(--ink); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 16px; }
.btn { font: 700 16px "Courier Prime", monospace; color: var(--ink); background: var(--paper2); border: 2px solid var(--ink); border-radius: 4px 2px 5px 3px;
  padding: 10px 16px; min-height: 44px; min-width: 44px; cursor: pointer; position: relative; box-shadow: 3px 3px 0 var(--ink); text-decoration: none; display: inline-block; }
.btn:hover, .btn:focus-visible { background: #fff6dd; outline: 3px solid var(--teal); outline-offset: 2px; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.big { background: var(--sodium); font-size: 19px; }
.btn.tiny { font-size: 12px; padding: 3px 8px; min-height: 34px; box-shadow: 2px 2px 0 var(--ink); }
.mode { font-family: "Bungee", sans-serif; font-size: 30px; text-align: left; padding: 14px 16px; }
.btn.mode { font-size: 30px; }
.mode small { display: block; font: 400 13px "Courier Prime", monospace; margin-top: 4px; }
#m-2d { transform: rotate(.5deg); } #m-3d { transform: rotate(-.6deg); }
.opts { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 15px; }
select { font: 700 15px "Courier Prime", monospace; background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; padding: 4px 6px; min-height: 36px; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; } .check input { width: 20px; height: 20px; accent-color: var(--wine); }
.line { display: flex; gap: 8px; align-items: center; margin: 6px 0; justify-content: space-between; }
.fine { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.hint { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.keys { border-collapse: collapse; font-size: 13px; width: 100%; } .keys td, .keys th { padding: 2px 6px; border-bottom: 1px dashed rgba(0,0,0,.2); text-align: left; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; } .row.center { justify-content: center; }
#scr-pause { background: rgba(8,12,23,.55); }
@media (max-width: 760px) { .cols, .modes { grid-template-columns: 1fr; } .card { padding: 18px 16px; } .btn.mode { font-size: 24px; } }
@media (max-height: 520px) { .title-card h1 { font-size: 30px; } .title-card .sub { margin-bottom: 6px; } .modes { grid-template-columns: 1fr 1fr; margin: 4px 0 8px; } .btn.mode { font-size: 20px; padding: 8px 12px; } .fine { margin-top: 8px; font-size: 12px; } .sticker { width: 70px; height: 70px; font-size: 10px; right: -6px; top: -10px; } }

/* ---------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#proto-tag { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); background: var(--pink); color: var(--ink); font: 700 12px "Courier Prime", monospace;
  padding: 4px 9px; border: 2px solid var(--ink); transform: rotate(-1.5deg); box-shadow: 2px 2px 0 var(--ink); }
#proto-tag span { font-weight: 400; margin-left: 4px; }
#place { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%) rotate(-1deg); font: 22px "IM Fell English SC", serif; color: var(--bone);
  text-shadow: 0 0 10px rgba(255,111,174,.6), 2px 2px 0 #000; opacity: 0; white-space: nowrap; }
#place.show { animation: place 3.6s ease forwards; }
@keyframes place { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
#prompt { position: absolute; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%) rotate(.6deg); background: var(--bone); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); padding: 8px 14px; font: 700 16px "Courier Prime", monospace; white-space: nowrap; }
#prompt kbd { display: inline-block; min-width: 26px; text-align: center; background: var(--sodium); border: 2px solid var(--ink); border-radius: 4px; padding: 0 5px; margin-right: 6px; font: inherit; }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%) rotate(-1deg); background: var(--ink); color: var(--sodium); border: 2px solid var(--sodium); padding: 6px 12px; font: 700 15px "Courier Prime", monospace; }
#lap { display: none !important; visibility: hidden !important; }
#speedo { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); width: 180px; transform: rotate(1.2deg); }
#speedo canvas { width: 180px; height: 180px; display: block; }
.jostle { margin-top: 4px; background: var(--bone); color: var(--ink); border: 2px solid var(--ink); padding: 3px 7px 4px; font: 700 11px "Courier Prime", monospace; box-shadow: 3px 3px 0 rgba(0,0,0,.6); }
.jostle span { letter-spacing: .08em; } .jostle b { display: block; font-weight: 400; font-size: 11px; }
.jostle .bar { height: 7px; border: 1.5px solid var(--ink); margin: 2px 0; background: #d9cfb8; }
.jostle .bar i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .15s; }
.jostle .bar i.warm { background: var(--sodium); } .jostle .bar i.hot { background: var(--pink); }
#dbg { position: absolute; left: max(10px, env(safe-area-inset-left)); top: 44px; margin: 0; font: 11px/1.35 "Courier Prime", monospace; color: var(--teal); background: rgba(8,12,23,.65); padding: 4px 6px; }
#pause-btn { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); pointer-events: auto; }

/* ---------- touch controls (only shown on touch devices) */
#touch { position: absolute; inset: 0; pointer-events: none; }
#t-look { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; touch-action: none; }
#t-stick { position: absolute; left: 0; top: 30%; bottom: 0; width: 42%; pointer-events: auto; touch-action: none; }
#t-base { position: absolute; left: 0; top: 0; width: 120px; height: 120px; border-radius: 50%; border: 2px dashed rgba(239,230,210,.45); background: rgba(8,12,23,.25);
  transform: translate(40px, 60px); opacity: .55; transition: opacity .15s; }
#t-base.on { opacity: 1; }
#t-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(239,230,210,.85); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
#t-btns { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 70px); grid-auto-rows: 56px; gap: 8px; pointer-events: none; direction: rtl; }
#t-act.tbtn {
  grid-column: 1 / -1; min-height: 72px; font-size: 18px; background: var(--sodium);
  box-shadow: 3px 3px 0 var(--ink); order: -1;
}
.tbtn { pointer-events: auto; touch-action: none; direction: ltr; font: 700 12px/1.05 "Courier Prime", monospace; color: var(--ink); background: rgba(239,230,210,.82); border: 2px solid var(--ink); border-radius: 12px 9px 13px 10px;
  box-shadow: 2px 3px 0 rgba(0,0,0,.6); padding: 2px; }
.tbtn.down { transform: translate(1px, 2px); box-shadow: 0 1px 0 rgba(0,0,0,.6); background: #fff6dd; }
.tbtn.lit { background: var(--teal); }
.tbtn.act { background: var(--sodium); }
.tbtn[data-act="gas"] { background: rgba(63,208,201,.9); } .tbtn[data-act="brake"] { background: rgba(255,111,174,.9); }
#touch .drive { display: none; } body.driving #touch .drive { display: block; } body.driving #touch .foot { display: none; }
body.touch #speedo { transform: scale(.72) rotate(1.2deg); transform-origin: right top; bottom: auto; top: max(44px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); }
body.touch #lap { display: none; }
body.touch #prompt { bottom: max(18px, env(safe-area-inset-bottom)); font-size: 14px; }
body.touch #place { top: max(44px, env(safe-area-inset-top)); font-size: 18px; }
@media (max-height: 430px) { #t-btns { grid-template-columns: repeat(3, 60px); grid-auto-rows: 50px; gap: 6px; } }

/* Phase C: contract card + dignity / heat */
#contract { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(44px, env(safe-area-inset-top)); width: min(280px, 46vw);
  background: var(--bone); color: var(--ink); border: 2px solid var(--ink); box-shadow: 4px 4px 0 rgba(0,0,0,.55);
  padding: 8px 10px 10px; font: 700 12px/1.25 "Courier Prime", monospace; transform: rotate(-1.1deg); }
#contract .stamp { display: inline-block; color: var(--wine); border: 2px solid var(--wine); padding: 1px 6px; letter-spacing: .12em; font-size: 10px; margin-bottom: 4px; transform: rotate(-2deg); }
#contract b { display: block; font: 18px "IM Fell English SC", serif; }
#contract span { display: block; color: #5a4a3a; margin: 2px 0 4px; }
#contract em { display: block; color: var(--wine); font-style: normal; letter-spacing: .04em; }
#contract p { margin: 6px 0 0; font-weight: 400; color: #3a3230; }
#carry-meter { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: 210px;
  background: var(--bone); color: var(--ink); border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(0,0,0,.55);
  padding: 8px 10px 8px; font: 700 11px/1.2 "Courier Prime", monospace; transform: rotate(.4deg); overflow: visible; }
#carry-meter .bar { position: relative; height: 10px; border: 1.5px solid var(--ink); margin: 20px 0 10px; background: #d9cfb8; overflow: visible; }
#carry-meter .bar span { position: absolute; left: 0; top: -15px; font-size: 9px; letter-spacing: .1em; color: var(--ink); background: var(--bone); padding: 0 4px; z-index: 2; line-height: 1; white-space: nowrap; }
#carry-meter .bar i { display: block; height: 100%; width: 100%; background: var(--teal); }
#carry-meter .bar i.warm { background: var(--sodium); } #carry-meter .bar i.hot { background: var(--pink); }
#carry-meter .heat i { background: var(--wine); width: 0; }
#carry-meter b { display: block; font-size: 12px; margin-top: 2px; }
#carry-meter .st { font-weight: 400; color: #5a4a3a; margin-top: 2px; }
body.touch #contract { width: min(220px, 50vw); font-size: 11px; top: max(40px, env(safe-area-inset-top)); }
body.touch #carry-meter { width: 160px; bottom: max(90px, env(safe-area-inset-bottom)); }

/* ---------- online / lobby (Phase D) */
#scr-note, #scr-online, #scr-lobby { background: rgba(8,12,23,.72); }
input#on-code { font: 700 18px "Courier Prime", monospace; letter-spacing: .18em; text-transform: uppercase;
  background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; padding: 6px 10px; width: 8em; color: var(--ink); }
.room-list { list-style: none; padding: 0; margin: 6px 0; max-height: 160px; overflow: auto; }
.room-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,.2); font-size: 14px; }
.room-list .mode-tag { background: var(--teal); color: var(--ink); font: 700 11px "Courier Prime", monospace; padding: 2px 6px; border: 1.5px solid var(--ink); }
.roster { list-style: none; padding: 0; margin: 10px 0; }
.roster li { padding: 6px 8px; margin: 4px 0; background: var(--paper2); border: 2px solid var(--ink); border-radius: 3px; display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.roster li.host::after { content: "HOST"; font: 700 11px "Courier Prime", monospace; background: var(--sodium); border: 1.5px solid var(--ink); padding: 1px 5px; }
.roster li.away { opacity: .55; }
.roster li .kick { font-size: 12px; padding: 2px 8px; min-height: 28px; }
#net-tag { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(36px, calc(env(safe-area-inset-top) + 28px));
  background: rgba(8,12,23,.75); color: var(--teal); font: 700 11px "Courier Prime", monospace; padding: 3px 8px; border: 1.5px solid var(--teal); }
#net-tag.warn { color: var(--sodium); border-color: var(--sodium); }
.card-foot { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bone) 30%); padding-top: 10px; margin-top: 8px; }


/* CSP-safe meter fills (no element.style.width) */
#carry-meter .bar i, .jostle .bar i { width: 0; }
.fill-0 { width: 0% !important; }
.fill-5 { width: 5% !important; }
.fill-10 { width: 10% !important; }
.fill-15 { width: 15% !important; }
.fill-20 { width: 20% !important; }
.fill-25 { width: 25% !important; }
.fill-30 { width: 30% !important; }
.fill-35 { width: 35% !important; }
.fill-40 { width: 40% !important; }
.fill-45 { width: 45% !important; }
.fill-50 { width: 50% !important; }
.fill-55 { width: 55% !important; }
.fill-60 { width: 60% !important; }
.fill-65 { width: 65% !important; }
.fill-70 { width: 70% !important; }
.fill-75 { width: 75% !important; }
.fill-80 { width: 80% !important; }
.fill-85 { width: 85% !important; }
.fill-90 { width: 90% !important; }
.fill-95 { width: 95% !important; }
.fill-100 { width: 100% !important; }
#carry-meter .bar i.hot, .jostle .bar i.hot { background: var(--pink); }
#carry-meter .bar i.warm, .jostle .bar i.warm { background: var(--sodium); }
#carry-meter .heat i { background: var(--wine); }

/* Job checklist (no waypoint / minimap — players read building names) */
#contract ol.job-list { list-style: none; padding: 0; margin: 6px 0 0; }
#contract ol.job-list li { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; border-bottom: 1px dashed rgba(0,0,0,.12); font-weight: 700; }
#contract ol.job-list li i { flex: 0 0 14px; color: var(--wine); font-style: normal; }
#contract ol.job-list li.done { opacity: .55; text-decoration: line-through; }
#contract ol.job-list li.done i { color: #1f4a3a; }
#contract em { display: block; color: var(--wine); font-style: normal; letter-spacing: .04em; margin-bottom: 2px; }

/* CSP-safe touch stick offsets via CSS variables + classes */
#t-base, #t-knob { --stx: 0px; --sty: 0px; transform: translate(var(--stx), var(--sty)); }
#t-base.xn80, #t-knob.xn80 { --stx: -80px; }
#t-base.yn80, #t-knob.yn80 { --sty: -80px; }
#t-base.xn72, #t-knob.xn72 { --stx: -72px; }
#t-base.yn72, #t-knob.yn72 { --sty: -72px; }
#t-base.xn64, #t-knob.xn64 { --stx: -64px; }
#t-base.yn64, #t-knob.yn64 { --sty: -64px; }
#t-base.xn56, #t-knob.xn56 { --stx: -56px; }
#t-base.yn56, #t-knob.yn56 { --sty: -56px; }
#t-base.xn48, #t-knob.xn48 { --stx: -48px; }
#t-base.yn48, #t-knob.yn48 { --sty: -48px; }
#t-base.xn40, #t-knob.xn40 { --stx: -40px; }
#t-base.yn40, #t-knob.yn40 { --sty: -40px; }
#t-base.xn32, #t-knob.xn32 { --stx: -32px; }
#t-base.yn32, #t-knob.yn32 { --sty: -32px; }
#t-base.xn24, #t-knob.xn24 { --stx: -24px; }
#t-base.yn24, #t-knob.yn24 { --sty: -24px; }
#t-base.xn16, #t-knob.xn16 { --stx: -16px; }
#t-base.yn16, #t-knob.yn16 { --sty: -16px; }
#t-base.xn8, #t-knob.xn8 { --stx: -8px; }
#t-base.yn8, #t-knob.yn8 { --sty: -8px; }
#t-base.x0, #t-knob.x0 { --stx: 0px; }
#t-base.y0, #t-knob.y0 { --sty: 0px; }
#t-base.x8, #t-knob.x8 { --stx: 8px; }
#t-base.y8, #t-knob.y8 { --sty: 8px; }
#t-base.x16, #t-knob.x16 { --stx: 16px; }
#t-base.y16, #t-knob.y16 { --sty: 16px; }
#t-base.x24, #t-knob.x24 { --stx: 24px; }
#t-base.y24, #t-knob.y24 { --sty: 24px; }
#t-base.x32, #t-knob.x32 { --stx: 32px; }
#t-base.y32, #t-knob.y32 { --sty: 32px; }
#t-base.x40, #t-knob.x40 { --stx: 40px; }
#t-base.y40, #t-knob.y40 { --sty: 40px; }
#t-base.x48, #t-knob.x48 { --stx: 48px; }
#t-base.y48, #t-knob.y48 { --sty: 48px; }
#t-base.x56, #t-knob.x56 { --stx: 56px; }
#t-base.y56, #t-knob.y56 { --sty: 56px; }
#t-base.x64, #t-knob.x64 { --stx: 64px; }
#t-base.y64, #t-knob.y64 { --sty: 64px; }
#t-base.x72, #t-knob.x72 { --stx: 72px; }
#t-base.y72, #t-knob.y72 { --sty: 72px; }
#t-base.x80, #t-knob.x80 { --stx: 80px; }
#t-base.y80, #t-knob.y80 { --sty: 80px; }


/* Diegetic board / shop close-up (still paper HUD, opened only at the physical board) */
#scr-board {
  background: #080c17; /* fully opaque — no 3D cork bleeding through */
  overflow: auto;
  align-items: center;
  justify-content: center;
}
#scr-board .board-card {
  max-width: min(560px, 94vw);
  overflow: visible;
  padding: 40px 28px 22px;
  transform: none; /* no rotate — was clipping the title and first letters */
  z-index: 5;
  background: var(--bone);
  box-shadow: 8px 10px 0 rgba(0,0,0,.55);
}
#scr-board .board-card > .tape {
  top: -10px;
  width: 88px;
  height: 18px;
  margin-left: -44px;
  z-index: 0; /* under the title */
  opacity: .75;
}
#scr-board #bd-h {
  margin: 10px 0 8px;
  padding-top: 8px;
  font-size: clamp(28px, 4.5vw, 36px);
  letter-spacing: .04em;
  line-height: 1.2;
  overflow: visible;
  position: relative;
  z-index: 2; /* above tape */
}
.board-list {
  list-style: none;
  padding: 4px 6px 4px 10px;
  margin: 10px 0;
  max-height: min(52vh, 420px);
  overflow-x: visible;
  overflow-y: auto;
}
.board-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px 12px 10px 14px;
  margin: 10px 4px;
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 2px;
  /* light skew via box-shadow only — transforms clipped text against overflow parents */
  box-shadow: 2px 2px 0 rgba(0,0,0,.2);
}
.board-list li:nth-child(even) { background: #e8deC6; }
.board-list li b {
  font: 16px/1.25 "IM Fell English SC", serif;
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding-left: 2px;
}
.board-list li .meta { color: var(--wine); font-weight: 700; padding-left: 2px; }
.board-list li .body { grid-column: 1 / -1; font-weight: 400; color: #3a3230; padding-left: 2px; overflow-wrap: anywhere; word-break: break-word; line-height: 1.35; }
.board-list li button { grid-column: 2; grid-row: 2; justify-self: end; }
#bd-cash { font: 700 16px "Bungee", sans-serif; color: var(--wine); }
/* While the board UI is open, tuck the world HUD so it does not fight the paper */
body.board-open #contract,
body.board-open #carry-meter,
body.board-open #prompt,
body.board-open #proto-tag { visibility: hidden; }
/* While paused, tuck the job list so it does not overlap Pause > Settings (left column) */
body.pause-open #contract,
body.pause-open #carry-meter,
body.pause-open #prompt,
body.pause-open #proto-tag { visibility: hidden; }


/* ---- Mobile / phone landscape priority ---- */
#rotate-hint {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(8,12,23,.94); color: var(--bone);
  align-items: center; justify-content: center; text-align: center;
  padding: 24px; font: 700 18px/1.35 "Courier Prime", monospace;
}
#rotate-hint b { display: block; font: 28px "Bungee", sans-serif; color: var(--sodium); margin-bottom: 10px; }
@media (orientation: portrait) and (max-width: 520px) {
  body.touch-device #rotate-hint { display: flex; }
  body.touch-device #touch, body.touch-device #hud { visibility: hidden; }
}
@media (orientation: landscape) {
  #rotate-hint { display: none !important; }
}
body.touch #scr-board {
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
body.touch #scr-board .board-card {
  max-width: min(640px, 96vw);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 28px 14px 14px;
  margin: 0 auto;
}
body.touch #scr-board #bd-h { font-size: 22px; margin-bottom: 4px; }
body.touch #scr-board #bd-hint { font-size: 12px; margin: 0 0 6px; }
body.touch .board-list {
  max-height: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  margin: 6px 0;
}
body.touch .board-list li {
  margin: 0;
  padding: 8px 10px;
  min-height: 88px;
  align-content: start;
}
body.touch .board-list li b { font-size: 14px; }
body.touch .board-list li button {
  min-height: 44px; min-width: 72px; font-size: 14px;
  background: var(--sodium);
}
body.touch #scr-board .card-foot {
  position: sticky; bottom: 0; padding-top: 8px; margin-top: 4px;
}
body.touch #scr-board .card-foot .btn {
  min-height: 48px; width: 100%; font-size: 16px;
}
/* Checklist compact on phones — top strip, never covers ACT */
body.touch #contract {
  top: max(6px, env(safe-area-inset-top));
  left: max(6px, env(safe-area-inset-left));
  width: min(240px, 42vw);
  max-height: 38vh;
  overflow: auto;
  font-size: 10px;
  padding: 6px 8px;
  z-index: 3;
}
body.touch #contract ol.job-list li { padding: 2px 0; gap: 4px; }
body.touch #contract p { display: none; } /* brief off-screen on phones — checklist steps are enough */
body.touch #prompt {
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 78px));
  left: 50%;
  right: auto;
  transform: translateX(-50%) rotate(.4deg);
  max-width: min(70vw, 360px);
  z-index: 4;
}
body.touch #carry-meter {
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 78px));
  width: min(150px, 32vw);
}
body.touch #proto-tag { font-size: 9px; padding: 2px 6px; }
@media (pointer: coarse) and (orientation: landscape) and (max-height: 430px) {
  body.touch .board-list { grid-template-columns: 1fr 1fr 1fr; }
  body.touch #scr-board .board-card { padding: 22px 12px 10px; }
  body.touch #contract { max-height: 48vh; width: min(200px, 36vw); }
  #t-btns { grid-template-columns: repeat(3, 58px); grid-auto-rows: 48px; gap: 6px; }
  #t-act.tbtn { min-height: 56px; font-size: 15px; }
}


/* Milestone 2 — job board polish */
#scr-board .board-card {
  max-width: min(720px, 96vw);
  padding: 28px 22px 16px;
  overflow: hidden;
}
#scr-board .board-card > .tape {
  top: -10px;
  width: 100px;
  height: 22px;
  margin-left: -50px;
  z-index: 1;
  pointer-events: none;
}
#scr-board #bd-h {
  position: relative;
  z-index: 3;
  margin: 4px 0 6px;
  padding-top: 4px;
  font-size: clamp(22px, 3.2vw, 30px);
  line-height: 1.15;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}
#scr-board #bd-hint {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.35;
  max-width: 100%;
}
.board-list li {
  gap: 6px 10px;
  padding: 10px 12px;
  align-items: start;
}
.board-list li b {
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.board-list li .meta {
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}
.board-list li .body {
  font-size: 13px;
  max-width: 100%;
}
.board-list li button {
  min-height: 36px;
  padding: 6px 14px;
  white-space: nowrap;
}
/* Dignity / Heat labels clear of bars */
#carry-meter .bar span {
  top: -16px;
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border: 1px solid rgba(40,30,20,0.15);
}
#carry-meter .bar { margin: 22px 0 12px; }

/* Dispatcher VO subtitles — match 2D */
#vosub {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 74px;
  max-width: min(760px, 76vw); z-index: 16; pointer-events: none;
  background: rgba(20, 18, 24, 0.88); color: var(--bone);
  border: 2px solid var(--ink); border-left: 6px solid var(--teal);
  padding: 8px 14px; font-weight: 700; font-size: 15px; line-height: 1.35;
}
#vosub b { color: var(--teal); margin-right: 8px; font-size: 0.82em; letter-spacing: 0.08em; }
#walkie:empty { display: none; }
#walkie {
  position: absolute; right: 16px; bottom: 120px; display: flex; flex-direction: column;
  gap: 6px; align-items: flex-end; pointer-events: none; z-index: 15;
}
#walkie .w {
  background: var(--ink); color: var(--bone); padding: 6px 10px; border: 2px solid var(--teal);
  font-weight: 700; font-size: 14px; max-width: min(360px, 42vw);
}
#walkie .w b { color: var(--teal); margin-right: 6px; letter-spacing: 0.06em; font-size: 0.85em; }
body.touch #vosub { bottom: max(100px, env(safe-area-inset-bottom)); font-size: 13px; max-width: 70vw; }

#vosub[data-sticky="1"] { bottom: 110px; z-index: 40; font-size: 16px; max-width: min(820px, 86vw); }

/* trailer vosub sole */
#vosub { z-index: 35; }
#walkie { bottom: 210px; max-width: min(320px, 36vw); }
body.driving #vosub { bottom: 100px; }

body.driving #walkie { display: none !important; }

/* Trailer clean-frame (test hook cleanHud): keep subtitles, toasts, prompts and gauges; drop the checklist + proto tag */
body.cc-clean #contract, body.cc-clean #proto-tag { display: none !important; }

/* Sunrise → "Night over" card (fades in over the brightened street, garage reset happens behind it) */
#nightover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; pointer-events: none;
  background: radial-gradient(ellipse at 50% 75%, rgba(255,176,112,0.92), rgba(200,106,138,0.94) 55%, rgba(58,58,122,0.97)); opacity: 0; transition: opacity 0.9s ease; }
#nightover.on { opacity: 1; }
#nightover .no-card { background: #f3ead8; color: #1b1a22; border: 3px solid #1b1a22; padding: 22px 36px 18px; transform: rotate(-1.2deg); text-align: center; box-shadow: 8px 8px 0 rgba(0,0,0,0.35); max-width: 80vw; }
#nightover small { font: 700 12px "Courier Prime", monospace; letter-spacing: 0.18em; color: #7a3b4e; }
#nightover h2 { font: 700 46px "Courier Prime", monospace; margin: 6px 0 8px; letter-spacing: 0.06em; }
#nightover #no-stats { font: 700 17px "Courier Prime", monospace; margin: 0 0 8px; }
#nightover .no-hint { font: 14px "Courier Prime", monospace; margin: 0; opacity: 0.75; }
body.touch #nightover h2 { font-size: 32px; }

/* Pay-on-set-down moment: stamp slams, cash counts up and floats, breakdown line */
#paypop { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); z-index: 30; pointer-events: none; text-align: center; }
#paypop .pp-stamp { display: inline-block; font: 700 22px "Courier Prime", monospace; letter-spacing: 0.2em; color: #c8304a; border: 4px solid #c8304a; padding: 2px 14px; transform: rotate(-6deg); background: rgba(243,234,216,0.92); }
#paypop .pp-cash { font: 700 64px "Courier Prime", monospace; color: #ffd66b; text-shadow: 0 3px 0 #5a3a10, 0 0 18px rgba(255,190,90,0.7); margin-top: 6px; }
#paypop .pp-line { font: 700 15px "Courier Prime", monospace; color: #f3ead8; background: rgba(8,12,23,0.75); display: inline-block; padding: 4px 10px; margin-top: 2px; }
#paypop.on .pp-stamp { animation: ppStamp 0.35s cubic-bezier(.2,1.6,.4,1) both; }
#paypop.on .pp-cash { animation: ppCash 3.6s ease both; }
#paypop.on .pp-line { animation: ppLine 3.6s ease both; }
#paypop.out { opacity: 0; transition: opacity 0.6s ease; }
@keyframes ppStamp { 0% { transform: rotate(-6deg) scale(2.4); opacity: 0; } 100% { transform: rotate(-6deg) scale(1); opacity: 1; } }
@keyframes ppCash { 0% { transform: translateY(18px) scale(0.6); opacity: 0; } 12% { transform: translateY(0) scale(1.12); opacity: 1; } 22% { transform: scale(1); } 80% { transform: translateY(-6px); opacity: 1; } 100% { transform: translateY(-34px); opacity: 0.85; } }
@keyframes ppLine { 0%, 15% { opacity: 0; } 25%, 100% { opacity: 1; } }
body.touch #paypop .pp-cash { font-size: 44px; }

/* Caption size (Pause > Settings), same as 2D s-capsize: Normal / Large / Huge */
body { --cap: 1; }
body.cap-125 { --cap: 1.25; }
body.cap-150 { --cap: 1.5; }
#vosub { font-size: calc(15px * var(--cap)); }
body.touch #vosub { font-size: calc(13px * var(--cap)); }
#vosub[data-sticky="1"] { font-size: calc(16px * var(--cap)); }
#walkie .w { font-size: calc(14px * var(--cap)); }
#toast { font-size: calc(15px * var(--cap)); }

/* High-contrast text (Pause > Settings), same as 2D s-hc: solid black boxes, white text, brighter names */
body.hc #vosub, body.hc #walkie .w { background: #000 !important; color: #fff !important; border: 2px solid #fff; border-left-width: 6px; }
body.hc #vosub b, body.hc #walkie .w b { color: #8ff7f1 !important; }
body.hc #toast { background: #fff; color: #000; border-color: #000; }
body.hc #prompt { background: #fff; color: #000; border-color: #000; }
body.hc #contract { background: #fff; color: #000; }
body.hc #contract span, body.hc #contract p { color: #000; }

/* "Menu text size" (2D s-uiscale parity): scales the menu/pause/board cards, not the HUD */
body { --ui: 1; }
body.ui-115 { --ui: 1.15; }
body.ui-130 { --ui: 1.3; }
body.ui-115 .screen .card, body.ui-130 .screen .card { zoom: var(--ui); }
body.touch.ui-115 #scr-board .board-card, body.touch.ui-130 #scr-board .board-card { max-height: calc((100dvh - 16px) / var(--ui)); }
