/* Unauthorized Fun Department. Palette and type: docs/DESIGN.md (the three-part permit form, defaced). */
@font-face { font-family: 'Plex Mono'; src: url('fonts/ibmplexmono/IBMPlexMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url('fonts/ibmplexmono/IBMPlexMono-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Kalam'; src: url('fonts/kalam/Kalam-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Kalam'; src: url('fonts/kalam/Kalam-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bar-h: 84px; /* the sticky action bar plus its border; scrolled-to items stop above it */
  --carbon: #1c2140; --carbon-2: #2a3160; --carbon-3: #3a4378;
  --white: #f3efe4; --canary: #f1d564; --pink: #ef9fb0; --red: #c62f3a; --ink: #2a3480; --teal: #17a08c;
  --brass: #c39a45; --brass-hi: #e0bd6a; --brass-lo: #8a6a2a; --engrave: #3b2a10;
  --mono: 'Plex Mono', ui-monospace, monospace; --hand: 'Kalam', 'Comic Sans MS', cursive;
  --hdr: 52px; --side: 340px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100%; background: var(--carbon); color: var(--white); font: 16px/1.45 var(--mono); overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
h1, h2, h3, h4 { font-family: var(--hand); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; }
h2 { font-size: 30px; } h3 { font-size: 22px; } h4 { font-size: 18px; margin-top: .6em; }
p { margin: 0 0 .6em; }
.sub { color: #c9c6d8; font-size: 15px; }
.offscreen { position: fixed; left: -9999px; top: 0; }
button { font: inherit; color: inherit; }
a { color: var(--canary); }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: var(--hdr); padding: 4px 12px; background: var(--carbon-2); border-bottom: 3px solid var(--canary); }
.brand { font: 700 22px/1 var(--hand); color: var(--canary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.spacer { flex: 1; }
.wallet { display: flex; gap: 8px; }
.coin { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; padding: 2px 8px; border-radius: 3px; min-height: 30px; }
.coin.stamp { background: var(--red); color: var(--white); }
.coin.stamp::before { content: 'Stamps'; font-weight: 400; font-size: 12px; }
.coin.res { background: var(--ink); color: var(--white); }
.coin.res::before { content: 'Research'; font-weight: 400; font-size: 12px; }
a.jam { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 12px; font: 700 15px var(--mono); color: var(--carbon); background: var(--canary); text-decoration: none; border-radius: 3px; white-space: nowrap; }
a.jam:focus-visible, .btn:focus-visible, .plaque:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* buttons: paper slips; primary = marker teal (the workshop's own colour) */
.btn { min-height: 44px; padding: 8px 14px; border: 2px solid var(--white); background: transparent; color: var(--white); border-radius: 3px; cursor: pointer; font: 700 16px var(--mono); touch-action: manipulation; }
.btn.hdr { min-height: 44px; padding: 4px 10px; font-size: 14px; border-color: #8f93b8; }
.btn.small { min-height: 44px; padding: 4px 10px; font-size: 14px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--white); font-family: var(--hand); font-size: 20px; }
.btn.big { min-height: 54px; padding: 10px 22px; font-size: 21px; font-family: var(--hand); }
.btn.danger { border-color: var(--red); color: #ffb3b9; }
.btn.armed, .btn.end.armed { background: var(--canary); border-color: var(--canary); color: var(--carbon); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.choice { display: block; width: 100%; text-align: left; background: var(--white); color: var(--ink); border-color: var(--white); margin-bottom: 8px; font-family: var(--mono); }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; }

/* paper sheets */
.sheet { max-width: 640px; margin: 24px auto; padding: 22px 24px; background: var(--white); color: var(--ink); border-radius: 2px; box-shadow: 6px 6px 0 #0d1030; }
.sheet h2, .sheet h3 { color: var(--ink); }
.sheet .sub { color: #5a5f86; }
.sheet .btn { border-color: var(--ink); color: var(--ink); }
.sheet .btn.primary { color: var(--white); border-color: var(--teal); }
.form-no { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--red); border-bottom: 1px solid currentColor; padding-bottom: 4px; }
.bark { font-family: var(--hand); font-size: 20px; color: var(--ink); }
.credit { font-weight: 700; }
.error { border-left: 8px solid var(--red); }

/* title */
.title-card { max-width: 760px; margin: 6vh auto 24px; padding: 28px; background: var(--white); color: var(--ink); box-shadow: 8px 8px 0 #0d1030; position: relative; }
.title-card::after { content: 'DENIED'; position: absolute; right: 18px; top: 18px; transform: rotate(9deg); border: 4px double var(--red); color: var(--red); font: 700 26px var(--mono); padding: 2px 10px; opacity: .85; }
/* the stamp keeps its corner; the form line above the title stops short of it */
.title-card .form-no { padding-right: 150px; }
.title-card h1 { font-size: clamp(40px, 8vw, 72px); color: var(--teal); transform: rotate(-1.5deg); margin: 12px 0 14px; }
.goal { font-size: 19px; max-width: 34em; }
.title-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.title-actions .btn:not(.primary) { border-color: var(--ink); color: var(--ink); }
.jam-line a.jam { margin-top: 4px; }

/* workshop */
.workshop { display: grid; grid-template-columns: 1fr 380px; gap: 18px; padding: 16px; max-width: 1400px; margin: 0 auto; }
.ws-main > section, .ws-side > section { background: var(--carbon-2); padding: 14px 16px; border-radius: 3px; margin-bottom: 16px; }
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.rcard { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px; background: var(--white); color: var(--ink); border: 0; border-radius: 2px; text-align: left; cursor: pointer; box-shadow: 4px 4px 0 #0d1030; min-height: 44px; }
.rcard:nth-child(3n+1) { transform: rotate(-.6deg); } .rcard:nth-child(3n+2) { transform: rotate(.5deg); }
.rcard.locked { background: transparent; border: 2px dashed #6d72a0; color: #9ea2c6; box-shadow: none; cursor: default; }
.rc-pic { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: top; background: #e3dccb; display: block; }
.rc-pic.unknown { display: grid; place-items: center; font: 700 40px var(--hand); background: transparent; }
.rc-name { font: 700 19px/1.1 var(--hand); }
.rc-role, .rc-proj { font-size: 13px; overflow-wrap: break-word; hyphens: auto; }
.rc-voucher { font-size: 13px; background: var(--canary); padding: 0 4px; align-self: start; }
.res-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-top: 1px dashed #5d639a; align-items: center; }
.res-name { font-weight: 700; } .res-text { grid-column: 1; font-size: 14px; color: #c9c6d8; } .res-row .btn, .res-done { grid-row: 1 / span 2; grid-column: 2; }
.res-done { color: var(--teal); font-weight: 700; }
.machine { position: relative; }
.machine-body { position: relative; height: 230px; display: flex; justify-content: center; scroll-margin-top: 70px; }
.machine-art { height: 100%; width: auto; max-width: 70%; object-fit: contain; }
.machine-art.drawn { width: 150px; background: linear-gradient(var(--brass-hi), var(--brass) 40%, var(--brass-lo)); border-radius: 60px 60px 6px 6px; display: grid; place-items: center; border: 3px solid var(--engrave); }
.tube { position: absolute; right: 12%; top: 0; bottom: 0; width: 34px; border: 3px solid #b8c7d6; border-radius: 17px; background: rgba(184,199,214,.15); overflow: hidden; }
.capsule { position: absolute; left: 3px; right: 3px; height: 46px; top: -60px; border-radius: 14px; background: linear-gradient(90deg, var(--brass-lo), var(--brass-hi), var(--brass-lo)); box-shadow: inset 0 18px 0 -14px #6b3f1d, inset 0 -18px 0 -14px #6b3f1d; }
.tube.fire .capsule { animation: drop .9s cubic-bezier(.5,0,.8,1) forwards; }
@keyframes drop { 0% { top: -60px; } 80% { top: calc(100% - 50px); } 88% { top: calc(100% - 60px); } 100% { top: calc(100% - 50px); } }
.gauge { position: relative; height: 30px; margin: 10px 0; background: var(--carbon); border: 2px solid var(--brass); border-radius: 15px; overflow: hidden; }
.gauge-fill { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(-45deg, var(--red) 0 8px, #a42530 8px 16px); }
.gauge-text { position: relative; display: block; text-align: center; font-size: 14px; font-weight: 700; line-height: 26px; }
.specs { display: grid; gap: 6px; margin-bottom: 12px; }
.spec { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; min-height: 44px; padding: 6px 8px; background: var(--carbon-3); border-radius: 3px; cursor: pointer; }
.spec input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--teal); flex: none; }
.spec select { font: inherit; min-height: 44px; min-width: 56px; margin-left: 6px; }
.reveal { scroll-margin-bottom: var(--bar-h); scroll-margin-top: 70px; display: flex; gap: 12px; margin-top: 12px; padding: 12px; background: var(--white); color: var(--ink); animation: slip .35s ease-out; }
.reveal.rare { box-shadow: 0 0 0 4px var(--canary); }
.reveal .sub { color: #4d4a63; }
.rv-pic { width: 110px; height: 110px; object-fit: cover; object-position: top; background: #e3dccb; flex: none; }
.rv-kind { font-size: 13px; text-transform: uppercase; color: var(--red); margin: 0; }
@keyframes slip { from { transform: translateY(-30px) rotate(-4deg); opacity: 0; } }
.guarantee { margin-top: 14px; padding: 10px; border: 2px solid var(--canary); }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(13,16,48,.75); overflow-y: auto; padding: 16px; }
.woman-head { display: flex; gap: 14px; align-items: flex-start; }
.wm-pic { width: 140px; height: 140px; object-fit: cover; object-position: top; flex: none; background: #e3dccb; }
.friends { list-style: none; padding: 0; } .friend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.bar { display: inline-flex; gap: 3px; } .bar i { width: 22px; height: 12px; border: 2px solid var(--ink); } .bar i.on { background: var(--teal); border-color: var(--teal); }
.joint { font-size: 14px; color: var(--red); }

/* departments */
.departments, .map { max-width: 1100px; margin: 0 auto; padding: 16px; }
.folders { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.folder { position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 30px 14px 14px; border: 0; border-radius: 0 6px 4px 4px; background: #d9c38f; color: var(--engrave); cursor: pointer; min-height: 150px; box-shadow: 5px 5px 0 #0d1030; }
.folder.d2 { background: #d8a9b3; } .folder.d3 { background: #a9bad3; }
.folder.sel { outline: 4px solid var(--teal); outline-offset: 3px; }
.folder.locked { filter: grayscale(.8) brightness(.7); cursor: default; }
.f-tab { position: absolute; top: -16px; left: 0; padding: 2px 12px; background: inherit; border-radius: 6px 6px 0 0; font-size: 13px; font-weight: 700; }
.f-name { font: 700 22px/1.1 var(--hand); } .f-blurb, .f-boss { font-size: 14px; }
.party-pick { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 112px; padding: 6px; background: var(--carbon-2); border: 3px solid transparent; border-radius: 3px; cursor: pointer; font-family: var(--hand); font-size: 16px; }
.pick.on { border-color: var(--teal); background: var(--carbon-3); }
.pk-pic { width: 92px; height: 92px; object-fit: cover; object-position: top; background: #e3dccb; }
.departments > .btn { margin-top: 16px; }

/* map */
.map-party { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.mp { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; background: var(--carbon-2); font-family: var(--hand); }
.sheet .mp { background: #e3dccb; }
.mp-pic { width: 40px; height: 40px; object-fit: cover; object-position: top; background: #e3dccb; }
.mp .hp { font: 700 14px var(--mono); }
.map-grid { position: relative; display: flex; flex-direction: column; gap: 34px; padding: 22px 10px; background: var(--white); color: var(--ink); background-image: repeating-linear-gradient(transparent 0 31px, #c9d3e6 31px 32px); box-shadow: 6px 6px 0 #0d1030; }
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-row { position: relative; display: flex; justify-content: center; gap: clamp(16px, 8vw, 90px); }
.node { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 88px; min-height: 64px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 50%; background: var(--white); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 700; }
.node:disabled { opacity: .5; cursor: default; }
.node.open { border-color: var(--red); color: var(--red); transform: rotate(-3deg); box-shadow: 0 0 0 4px var(--canary); }
.node.visited { background: #dfe4f0; }
.node.here { background: var(--canary); opacity: 1; }
.node.k-boss { border-style: double; border-width: 6px; background: #fbe3e6; min-width: 120px; }
.node .boss-badge { padding: 1px 6px; background: var(--red); color: var(--white); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }

/* battle */
.battle { display: grid; grid-template-columns: minmax(0, 1fr) var(--side); gap: 14px; padding: 10px 12px; height: calc(100dvh - var(--hdr) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 520px; }
.board-col { display: flex; flex-direction: column; min-height: 0; }
.objective { font-size: 16px; color: #c9c6d8; margin: 0 0 4px; }
.round-bar { font-size: 14px; color: #c9c6d8; margin: 0 0 4px; }
.round-bar.ot { padding: 4px 10px; background: var(--red); color: var(--white); font-weight: 700; border-radius: 2px; }
.board-wrap { position: relative; flex: 1; min-height: 240px; background: var(--carbon-2); border-radius: 3px; touch-action: manipulation; }
.board-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
.note { min-height: 52px; margin: 8px 0 0; padding: 8px 12px; background: var(--white); color: var(--ink); font-size: 16px; border-left: 6px solid var(--canary); }
.battle-side { overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; }
.rule-panel { background: var(--carbon-2); padding: 10px; border-radius: 3px; }
.rule-panel h3 { font-size: 19px; color: var(--canary); }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px; padding: 8px; background: var(--canary); border-radius: 2px; }
/* a rule firing: the posted rule shakes once and both plaques thump in their slots */
.rule.pulse { animation: ruleshake .36s ease-out; }
.rule.pulse .plaque { animation: thump .3s ease-out; }
@keyframes ruleshake { 0% { box-shadow: 0 0 0 6px var(--white); } 20% { transform: translateX(-5px) rotate(-1deg); } 45% { transform: translateX(4px) rotate(.6deg); } 70% { transform: translateX(-2px); } 100% { transform: none; box-shadow: none; } }
@keyframes thump { 0% { transform: translateY(-4px) scale(1.1); } 40% { transform: translateY(1px) scale(.96); } 100% { transform: none; } }
.rule-arrow { font: 700 26px var(--mono); color: var(--engrave); }
.plaque { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 76px; padding: 6px 12px 8px; text-align: left; cursor: pointer;
  color: var(--engrave); border: 2px solid var(--brass-lo); border-radius: 3px;
  background:
    radial-gradient(circle at 7px 7px, #6e5422 2px, transparent 3px), radial-gradient(circle at calc(100% - 7px) 7px, #6e5422 2px, transparent 3px),
    radial-gradient(circle at 7px calc(100% - 7px), #6e5422 2px, transparent 3px), radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), #6e5422 2px, transparent 3px),
    linear-gradient(160deg, var(--brass-hi), var(--brass) 45%, #a8822f);
  box-shadow: inset 0 1px 0 #f2d58e, inset 0 -2px 0 var(--brass-lo), 2px 3px 0 rgba(13,16,48,.5); }
.plaque.loose { background: linear-gradient(160deg, var(--brass-hi), var(--brass) 45%, #a8822f); transform: rotate(-2deg); }
.plaque.loose:nth-child(2n) { transform: rotate(1.5deg); }
.plaque.armed { outline: 4px solid var(--teal); outline-offset: 2px; }
.plaque.spent { opacity: .55; }
.pl-slot { font-size: 12px; font-weight: 700; letter-spacing: .14em; }
.pl-body { display: flex; align-items: center; gap: 8px; }
.pl-name { font: 700 15px/1.2 var(--mono); overflow-wrap: break-word; min-width: 0; }
.rule .plaque { padding: 6px 8px 8px; }
.rule .pl-name { font-size: 14px; overflow-wrap: normal; }
.hand { display: flex; flex-wrap: wrap; gap: 8px; }
.hand .plaque { flex: 1 1 112px; min-height: 48px; padding: 4px 8px 6px; }
.hand .pl-name { font-size: 13px; }
.hand .pl-slot { font-size: 12px; letter-spacing: .08em; }
.empty, .hint { font-size: 14px; color: #c9c6d8; margin: 0; }
.party-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pcard { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto auto; gap: 0 6px; align-items: center; padding: 5px; min-height: 44px; background: var(--white); color: var(--ink); border: 3px solid transparent; border-radius: 2px; text-align: left; cursor: pointer; }
.pcard.sel { border-color: var(--canary); box-shadow: 0 0 0 2px var(--carbon); }
.pcard.done { opacity: .6; }
.pc-pic { grid-row: 1 / span 3; width: 40px; height: 52px; object-fit: cover; object-position: top; background: #e3dccb; }
.pc-name { font: 700 15px/1.05 var(--hand); overflow-wrap: anywhere; min-width: 0; }
.pc-hp { font-size: 13px; font-weight: 700; } .pc-state { font-size: 12px; color: #5a5f86; }
.abilities { display: grid; gap: 6px; }
.ability { display: grid; gap: 2px; text-align: left; padding: 8px 10px; min-height: 44px; background: var(--carbon-3); color: var(--white); border: 2px solid #6d72a0; border-radius: 3px; cursor: pointer; }
.ability.armed { border-color: var(--canary); background: #4a4f86; }
.ability.joint { border-color: var(--pink); }
.ability:disabled { opacity: .45; cursor: default; }
.ab-name { font: 700 18px/1.1 var(--hand); } .ab-text { font-size: 14px; } .ab-meta { font-size: 12px; color: #c9c6d8; }
.btn.end { min-height: 52px; font-family: var(--hand); font-size: 21px; }
/* under the board: what is armed, and End round */
.act-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.arm-chip { flex: 1; min-width: 0; font-size: 14px; line-height: 1.25; color: #c9c6d8; }
.arm-chip.on { color: var(--canary); font-weight: 700; }
.act-bar .btn.end { flex: none; padding: 6px 18px; }
.speed-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.speed-label { flex: 1; font-size: 14px; color: #c9c6d8; }
.btn.small.on { background: var(--canary); border-color: var(--canary); color: var(--carbon); }
/* rulebook: a side sheet over the controls column, never over the board */
.rulebook-sheet { position: fixed; z-index: 40; top: calc(var(--hdr) + 3px + env(safe-area-inset-top)); right: 0; bottom: 0; width: calc(var(--side) + 26px); display: flex; flex-direction: column; background: var(--white); color: var(--ink); box-shadow: -6px 0 0 #0d1030; }
.rb-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 2px solid var(--ink); }
.rb-head h2 { flex: 1; margin: 0; color: var(--ink); font-size: 26px; }
.rb-body { overflow-y: auto; padding: 10px 14px 16px; font-size: 15px; }
.rb-body h3 { color: var(--ink); font-size: 19px; }
.rb-body dl { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 4px 10px; margin: 0 0 10px; }
.rb-body dt { font-weight: 700; } .rb-body dd { margin: 0; }
.rb-body ul { padding-left: 18px; }
/* the main button of a screen stays in reach at the foot of the window */
.action-bar { position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--carbon-2); border-top: 3px solid var(--canary); }
html:has(.action-bar) { scroll-padding-bottom: var(--bar-h); }
.workshop > .action-bar { grid-column: 1 / -1; order: 9; }
.bar-note { flex: 1 1 220px; min-width: 0; font-size: 15px; }
.log { background: var(--white); color: var(--ink); padding: 8px 10px; border-radius: 2px; }
.log-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.log-head h3 { flex: 1; font-size: 18px; color: var(--ink); margin: 0; }
.log .btn { border-color: var(--ink); color: var(--ink); }
.log.hidden .log-list, .log.hidden #replay { display: none; }
.log-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 300px; overflow-y: auto; }
.chain { padding: 6px 0; border-top: 1px dashed #9aa3c6; }
.chain:first-child { border-top: 0; }
.chain:not(:first-child) { opacity: .7; }
.ln { margin: 0; font-size: 15px; }
.ln.d1 { padding-left: 14px; } .ln.d2 { padding-left: 28px; } .ln.d3 { padding-left: 42px; } .ln.d4, .ln.d5, .ln.d6 { padding-left: 56px; }
.ln.d1::before, .ln.d2::before, .ln.d3::before, .ln.d4::before, .ln.d5::before, .ln.d6::before { content: '\2514 '; color: #8c93bb; }
.ln.rl { background: linear-gradient(90deg, rgba(241,213,100,.7), transparent); font-weight: 700; }

.ln.grade { margin-top: 4px; font-family: var(--hand); font-size: 16px; color: var(--red); }
.chain.empty .ln { color: #5a5f86; }
.rp-head { display: flex; align-items: center; gap: 8px; } .rp-head h3 { flex: 1; margin: 0; }
.rule-panel .btn.small { border-color: #8f93b8; }
.ability-row { display: grid; grid-template-columns: 1fr 44px; gap: 4px; }
.btn.info { min-height: 44px; padding: 0; font-weight: 700; font-size: 18px; border-color: #6d72a0; }
.tutorial { padding: 10px 12px; background: var(--canary); color: var(--carbon); border-radius: 2px; box-shadow: 4px 4px 0 var(--carbon-3); transform: rotate(-.4deg); }
.tutorial .btn { border-color: var(--carbon); color: var(--carbon); }
.tutorial .btn.primary { background: var(--ink); border-color: var(--ink); color: var(--white); }
.tut-head { display: flex; gap: 10px; align-items: center; }
.tut-pic { width: 48px; height: 48px; object-fit: cover; object-position: top; background: #e3dccb; flex: none; }
.tut-step { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tut-speaker { margin: 0; font: 700 19px/1.1 var(--hand); }
.tut-text { margin: 6px 0 8px; font-size: 16px; }
.tut-hi { outline: 4px dashed var(--canary); outline-offset: 3px; }
.meter { display: inline-flex; gap: 3px; } .meter i { width: 18px; height: 8px; border: 2px solid var(--ink); }
.meter i.on { background: var(--teal); border-color: var(--teal); }
.meter.big i { width: 34px; height: 14px; }
.patter { font-family: var(--hand); font-size: 17px; color: var(--canary); margin: 10px 0 0; }
.btn.choice { display: flex; flex-direction: column; gap: 2px; }
.outcome { font-size: 14px; color: var(--red); font-weight: 700; }
.changes { padding-left: 18px; } .changes li { margin: 2px 0; }
.warn { padding: 8px 10px; border-left: 6px solid var(--red); background: #f7dfe2; color: var(--ink); }
.mp.down { opacity: .5; }

/* phones and narrow tablets: board on top, controls below, the page scrolls */
@media (max-width: 600px), (orientation: portrait) {
  :root { --hdr: 48px; }
  .brand { font-size: 18px; }
  .coin.stamp::before, .coin.res::before { content: none; }
  .workshop { display: flex; flex-direction: column; padding: 10px; gap: 0; }
  .ws-main, .ws-side { display: contents; }
  .roster { order: 1; } .machine { order: 2; } .challenges { order: 3; } .research { order: 4; } .files { order: 5; }
  .action-bar { flex-wrap: nowrap; gap: 8px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .action-bar .btn.big { flex: 1 1 0; min-width: 0; padding: 6px 8px; font-size: 18px; }
  .departments .action-bar { flex-wrap: wrap; } .departments .action-bar .btn.big { flex: 1 1 100%; }
  .bar-note { font-size: 14px; }
  .battle { display: block; height: auto; min-height: 0; padding: 8px; }
  .board-wrap { flex: none; aspect-ratio: 1.38; min-height: 0; }
  .battle-side { overflow: visible; margin-top: 10px; }
  /* the board and its note stay in view while the controls scroll beneath them, so a plaque or ability preview
     is always visible where it lands (55 px: the sticky header with its 44 px buttons and canary rule) */
  .board-col { position: sticky; top: 55px; z-index: 10; background: var(--carbon); padding-bottom: 4px; }
  .board-col .note { max-height: 76px; min-height: 0; overflow-y: auto; margin-top: 6px; padding: 6px 10px; font-size: 15px; }
  .board-col .objective { display: none; }
  .rulebook-sheet { top: auto; left: 0; width: auto; max-height: 40dvh; box-shadow: 0 -6px 0 #0d1030; }
  body.rb-open .battle { padding-bottom: 42dvh; }
  .title-card .form-no { padding-right: 112px; }
  .roster-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .sheet { margin: 12px 8px; padding: 16px; }
  .title-card { margin: 16px 8px; padding: 18px; }
  .title-card::after { font-size: 18px; right: 10px; top: 10px; }
  h2 { font-size: 26px; }
}
/* phone held sideways: keep board and controls side by side, the board fills the height */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --hdr: 48px; --side: 300px; }
  .battle { min-height: 0; gap: 8px; padding: 6px 8px; }
  .objective { display: none; }
  .note { min-height: 0; margin-top: 4px; padding: 4px 8px; font-size: 14px; }
  .board-wrap { min-height: 0; }
  .workshop { grid-template-columns: 1fr 300px; }
}
@media (max-width: 420px) {
  .top { gap: 6px; padding: 4px 8px; }
  .btn.hdr { padding: 4px 8px; font-size: 13px; min-height: 44px; }
  .brand { display: none; }
  .plaque { padding: 6px 8px 8px; }
  /* three cards a row leave about 90 px; the handwritten face fits "horticulturist," whole where the mono split it */
  .rc-role { font: 15px/1.15 var(--hand); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; scroll-behavior: auto !important; }
}

/* enemy-set-off rule lines: the tower's pink, so "they did it to themselves" reads at a glance */
.ln.rl.foe { background: linear-gradient(90deg, rgba(239,159,176,.8), transparent); }
/* daily blueprint and inspection levels on the departments screen */
.daily-mod { margin: 8px 0 4px; max-width: 46em; }
.daily-mod b { color: var(--canary); }
.insp-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; margin-bottom: 6px; }
.insp { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 10px; text-align: left; font-size: 14px; background: var(--carbon-3); border: 2px solid transparent; border-radius: 3px; cursor: pointer; }
.insp.sel { border-color: var(--teal); background: var(--carbon-2); }
.insp.locked { color: #b9bcd6; background: transparent; border: 2px dashed #5d639a; cursor: default; }
.insp:disabled { opacity: 1; }
.insp-no { flex: none; display: grid; place-items: center; width: 28px; height: 28px; font-weight: 700; background: var(--white); color: var(--ink); border-radius: 50%; }
.insp.sel .insp-no { background: var(--teal); color: var(--white); }
/* invention challenges in the workshop */
.chal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chal { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px dashed #5d639a; }
.chal.done .chal-step { color: var(--teal); }
.ch-pic { width: 56px; height: 56px; object-fit: cover; object-position: top; background: #e3dccb; display: block; }
.chal-head { margin: 0 0 2px; } .chal-step { font-size: 14px; color: var(--canary); white-space: nowrap; }
.chal-goal { font-size: 14px; margin: 0 0 4px; }
.chal .meter i { border-color: #8f93b8; }
/* the notice when a won battle completes a challenge step */
.notice { max-width: 640px; margin: 0 0 12px; padding: 10px 14px; background: var(--white); color: var(--ink); box-shadow: 4px 4px 0 #0d1030; transform: rotate(-.4deg); }
.notice p { margin: 0 0 4px; } .notice .sub { color: #5a5f86; }
.kept { font-weight: 700; }

/* title poster: the three starters standing on the first posted rule, beside the permit form */
.title-wrap { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 700px); justify-content: center; align-items: center; gap: 28px; padding: 4vh 16px 24px; }
.title-wrap .title-card { margin: 0; }
.poster { position: relative; padding: 18px 14px 14px; background: var(--carbon-2); border: 3px solid var(--canary); box-shadow: 8px 8px 0 #0d1030; transform: rotate(-1deg); }
.poster::before { content: 'WANTED FOR IMPROVISATION'; display: block; text-align: center; font: 700 15px var(--mono); letter-spacing: .12em; color: var(--pink); margin-bottom: 6px; }
.poster-figs { display: flex; justify-content: center; align-items: flex-end; height: 250px; }
/* square pictures with air around the figure: each is wider than a third and they overlap like pinned cut-outs */
.pf { position: relative; display: flex; flex-direction: column; align-items: center; flex: none; width: 220px; margin: 0 -50px; }
.pf-pic { height: 226px; width: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(3px 0 0 var(--white)) drop-shadow(-3px 0 0 var(--white)) drop-shadow(0 -3px 0 var(--white)) drop-shadow(5px 5px 0 #0d1030); }
.pf0 { transform: rotate(-3deg); } .pf1 { z-index: 1; } .pf2 { transform: rotate(3deg); }
.pf-name { font: 700 16px/1.1 var(--hand); color: var(--canary); text-align: center; white-space: nowrap; }
.poster-rule { margin-top: 8px; pointer-events: none; }
.poster-rule .plaque { cursor: default; }
.btn.start { min-width: 200px; font-size: 26px; min-height: 62px; }
@media (max-width: 900px) {
  .title-wrap { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 12px 8px; }
  .poster { max-width: 460px; width: 100%; justify-self: center; padding: 8px 10px 10px; }
  .poster::before { font-size: 13px; margin-bottom: 0; }
  .poster-figs { height: 150px; } .pf { width: 140px; margin: 0 -26px; } .pf-pic { height: 136px; }
  .pf-name { font-size: 14px; }
  .poster-rule .plaque { min-height: 54px; }
  .title-wrap .title-card { margin: 0; }
}

/* boss intro card: over the board until begun; the board behind stays as it is */
.boss-card { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 10px; background: rgba(13,16,48,.72); overflow-y: auto; }
.bc-sheet { display: flex; gap: 16px; align-items: center; max-width: 620px; padding: 16px 18px; background: var(--white); color: var(--ink); border-left: 10px solid var(--red); box-shadow: 8px 8px 0 #0d1030; transform: rotate(-1deg); animation: bcdrop .36s cubic-bezier(.2,1.4,.5,1); }
.boss-card.still .bc-sheet { animation: none; }
@keyframes bcdrop { from { transform: translateY(-40px) rotate(-6deg) scale(1.15); opacity: 0; } }
.bc-pic { width: 150px; height: 190px; object-fit: contain; object-position: bottom; flex: none; }
.bc-text h2 { color: var(--red); font-size: 34px; margin: 2px 0 6px; }
.bc-text .bark { font-size: 19px; }
.bc-rule { font-size: 15px; } .bc-text .sub { color: #5a5f86; font-size: 14px; }
@media (max-width: 600px), (orientation: portrait) {
  .bc-sheet { gap: 10px; padding: 10px 12px; }
  .bc-pic { width: 70px; height: 96px; }
  .bc-text h2 { font-size: 24px; } .bc-text .bark { font-size: 16px; margin-bottom: 4px; } .bc-rule { font-size: 13px; margin-bottom: 4px; }
  .bc-text .sub { display: none; }
  .bc-text .btn.big { min-height: 46px; font-size: 18px; padding: 4px 14px; }
  .bc-text .form-no { display: none; }
}

/* pull reveal: the portrait slides out of the tube; the first pull and a rare woman get the long version */
.reveal .rv-pic { animation: rvslide .45s cubic-bezier(.2,1.3,.5,1) both; }
@keyframes rvslide { from { transform: translateX(60px) rotate(6deg); opacity: 0; } }
.reveal.big { padding: 16px; border: 4px solid var(--red); }
.reveal.big .rv-pic { width: 150px; height: 150px; animation-duration: .7s; }
.reveal.big h3 { font-size: 30px; }
.reveal.big .bark { font-size: 22px; }
.reveal.rare.big { box-shadow: 0 0 0 5px var(--canary), 8px 8px 0 #0d1030; }
.reveal.settled, .reveal.settled .rv-pic { animation: none; }
.machine.rolling .machine-body { animation: rattle .12s linear infinite; }
@keyframes rattle { 0%, 100% { transform: none; } 25% { transform: translate(-2px, 1px); } 75% { transform: translate(2px, -1px); } }
.patter.drum { color: var(--pink); }

/* a cleared department: a stamped card above the results sheet */
.cleared-card { position: relative; max-width: 640px; margin: 24px auto 0; padding: 18px 24px; background: var(--canary); color: var(--carbon); box-shadow: 6px 6px 0 #0d1030; transform: rotate(-.8deg); animation: bcdrop .4s cubic-bezier(.2,1.4,.5,1); }
.cleared-card h2 { color: var(--carbon); font-size: 34px; }
.cc-stamp { position: absolute; right: 16px; top: 12px; padding: 2px 12px; border: 5px double var(--red); color: var(--red); font: 700 30px var(--mono); text-transform: uppercase; transform: rotate(10deg); animation: ccslam .3s .25s cubic-bezier(.3,1.6,.6,1) both; }
@keyframes ccslam { from { transform: rotate(10deg) scale(2.4); opacity: 0; } }
.cleared-card + .sheet { margin-top: 14px; }

/* the ending */
.ending { max-width: 980px; margin: 0 auto; padding: 18px 12px 30px; }
.end-head { text-align: center; padding: 10px; }
.end-head .form-no { display: inline-block; }
.end-head h1 { font-size: clamp(34px, 6vw, 60px); color: var(--canary); margin: 10px 0; }
.end-clause { font: 700 18px var(--mono); color: var(--pink); }
.end-clause::after { content: '_'; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.end-party { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 8px 0 16px; }
.ep { margin: 0; width: 220px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ep-pic { height: 240px; width: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(3px 0 0 var(--white)) drop-shadow(-3px 0 0 var(--white)) drop-shadow(5px 5px 0 #0d1030); }
.ep figcaption { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.ep b { font: 700 20px var(--hand); color: var(--canary); }
.end-sheet { max-width: 720px; }
