/* Finjoy Life v2 — wood and cream UI (art guide 6). Dark brown on cream; never white text on light panels. */
/* "Digits": digits and number signs in a plain font, first in --pixel, so letters stay pixel but numbers read well.
   local() cannot see the Nunito webfont: without an installed Nunito the system fonts show. Self-host Nunito to fix that. */
@font-face { font-family: 'Digits'; font-weight: 100 599; src: local('Nunito'), local('Nunito Regular'), local('Segoe UI'), local('Arial'), local('Helvetica Neue'), local('Roboto');
  unicode-range: U+24-25, U+2B-2E, U+30-39, U+D7, U+2212, U+2192; }
@font-face { font-family: 'Digits'; font-weight: 600 900; src: local('Nunito Bold'), local('Nunito-Bold'), local('Segoe UI Bold'), local('Segoe UI-Bold'), local('Arial Bold'), local('Arial-BoldMT'), local('Helvetica Neue Bold'), local('Roboto Bold');
  unicode-range: U+24-25, U+2B-2E, U+30-39, U+D7, U+2212, U+2192; }
/* Pixelify Cyr: the Cyrillic of Pixelify Sans with ь and ы cut to x-height (the original draws them as tall as capitals). Self-hosted, SIL OFL, see assets/fonts/. Cyrillic only: Latin stays Pixelify Sans from Google Fonts. Made by tools/art/cyr_font.py. */
@font-face { font-family: 'Pixelify Cyr'; font-weight: 400; src: url(assets/fonts/PixelifyCyr-400.woff) format('woff'); unicode-range: U+400-4FF; }
@font-face { font-family: 'Pixelify Cyr'; font-weight: 500; src: url(assets/fonts/PixelifyCyr-500.woff) format('woff'); unicode-range: U+400-4FF; }
@font-face { font-family: 'Pixelify Cyr'; font-weight: 600; src: url(assets/fonts/PixelifyCyr-600.woff) format('woff'); unicode-range: U+400-4FF; }
@font-face { font-family: 'Pixelify Cyr'; font-weight: 700; src: url(assets/fonts/PixelifyCyr-700.woff) format('woff'); unicode-range: U+400-4FF; }
:root {
  --wood: #6B3F24; --wood-l: #8A5A38; --wood-d: #4E2C18; --cream: #F6E8CF; --cream-d: #EDD2A8; --ink: #5C4228;
  --apricot: #FFC878; --apricot-d: #F2A65A; --orange: #FFA066; --red: #D9544D; --green: #4F7A55; --green-l: #7FA070;
  --taupe: #9A9088; --purple: #4A3465; --teal: #4C9AA0;
  --font: 'Nunito', 'Trebuchet MS', system-ui, sans-serif; --pixel: 'Digits', 'Pixelify Cyr', 'Pixelify Sans', 'Nunito', sans-serif; --num: 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
#build { position: fixed; right: 8px; bottom: calc(4px + var(--safe-b)); z-index: 1; font-size: 11px; opacity: 0.5; color: var(--wood-d); pointer-events: none; }
@media (max-aspect-ratio: 1/1), (max-width: 760px) { #build { bottom: auto; top: calc(1px + var(--safe-t)); right: 50%; transform: translateX(50%); } } /* the phone action bar covers the corner */
html, body { margin: 0; height: 100%; overflow: hidden; background: #F4C9A8; color: var(--ink); font-family: var(--font); font-size: 18px; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
img { -webkit-user-drag: none; user-select: none; } /* no drag or "save image" on a long press */
[hidden] { display: none !important; }

html, body { touch-action: manipulation; } /* no double-tap zoom on iOS Safari; the board wrap sets none */
#app { position: fixed; inset: 0; user-select: none; }
#sky { position: absolute; inset: 0; background: linear-gradient(180deg, #BFE3EC 0%, #E9DCCB 38%, #F6CFB4 70%, #F2B9A0 100%); overflow: hidden; }
#sky::before, #sky::after { content: ''; position: absolute; border-radius: 50%; filter: blur(30px); opacity: .55; }
#sky::before { width: 60vw; height: 22vh; left: -10vw; top: 55vh; background: #FFE0C8; }
#sky::after { width: 50vw; height: 18vh; right: -8vw; top: 20vh; background: #FFF0E0; }
.leaf { position: absolute; width: 10px; height: 8px; background: #FF8050; border-radius: 60% 0; opacity: .7; animation: fall linear infinite; }
.leaf.big { width: 64px; height: 46px; animation: none; filter: blur(4px); opacity: .5; }
@keyframes fall { from { transform: translate(0, -5vh) rotate(0deg); } to { transform: translate(-12vw, 105vh) rotate(540deg); } }

/* panels and buttons */
.panel, .plate { background: var(--cream); border: 3px solid var(--wood); border-radius: 9px; box-shadow: inset 2px 2px 0 #FFF4E2, inset -2px -2px 0 var(--cream-d), 0 3px 0 var(--wood-d), 0 6px 14px rgba(74,52,101,.18); }
.plate { padding: 4px 12px; font-weight: 600; }
.wood-btn { background: var(--cream); border: 3px solid var(--wood); border-radius: 8px; padding: 6px 12px; font-size: 18px; font-weight: 600; box-shadow: inset 2px 2px 0 #FFF4E2, 0 3px 0 var(--wood-d); transition: transform .06s, background .1s; min-height: 44px; }
@media (hover: hover) { .wood-btn:hover { background: #FFF1DC; } } /* hover rules are for a mouse: on touch they stick after a tap */
.wood-btn:active, .wood-btn.down { transform: translateY(2px); box-shadow: inset 2px 2px 0 var(--cream-d), 0 1px 0 var(--wood-d); background: var(--cream-d); }
.wood-btn.primary { background: var(--apricot); box-shadow: inset 2px 2px 0 #FFE2B0, 0 3px 0 var(--wood-d); }
@media (hover: hover) { .wood-btn.primary:hover { background: #FFD394; } }
.wood-btn:disabled, .wood-btn.locked { background: #E4D8C4; color: #9A8A78; cursor: not-allowed; }
.pix { image-rendering: pixelated; width: 32px; height: 32px; vertical-align: middle; }
.pix.s { width: 16px; height: 16px; } .pix.m { width: 24px; height: 24px; }
/* icons are 32 art px: shown at 16, 24 and 28 px they shrink, and nearest-neighbour would drop outline rows */
.pix.s, .pix.m { image-rendering: auto; }

/* HUD (PRD 16.1-16.2) */
:root { --ui: 1; } /* UI scale on big desktop screens, set by layout() */
#hud { --hud-ui: min(var(--ui), 1.2); } /* the HUD grows less than the rest: it stays small on big screens */
#hud { position: absolute; left: 0; top: 0; width: calc(100% / var(--hud-ui)); transform: scale(var(--hud-ui)); transform-origin: top left; padding: calc(10px + var(--safe-t)) 16px 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.hud-who { display: flex; align-items: center; min-width: 0; width: fit-content; } /* as wide as picture + name card: the tip lights exactly this box */
.medal { width: 74px; height: 74px; border-radius: 50%; background: var(--cream); border: 4px solid var(--wood); box-shadow: inset 0 0 0 3px var(--wood-l), 0 3px 0 var(--wood-d); display: grid; place-items: center; overflow: hidden; position: relative; z-index: 1; }
.medal canvas { width: 60px; height: 60px; } /* portrait art is 60 px: 1x stays crisp */
.who-plate { margin-left: -12px; padding: 5px 14px 5px 20px; display: flex; flex-direction: column; line-height: 1.15; min-width: 0; max-width: 220px; }
.who-name { font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-plate small { font-size: 14px; font-weight: 600; color: #9A7A5A; white-space: nowrap; }
.hud-money { text-align: center; width: 210px; }
.money-plate { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 12px 4px 8px; cursor: pointer; white-space: nowrap; }
.money-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.money-plate .val { font-family: var(--num); font-size: 24px; font-weight: 800; }
.money-plate small { font-size: 12px; font-weight: 600; color: #9A7A5A; }
.freedom { margin-top: 5px; }
.freedom .bar { height: 10px; }
.bar { height: 14px; background: #7A5236; border: 2px solid var(--wood-d); border-radius: 8px; overflow: hidden; position: relative; box-shadow: inset 0 2px 0 rgba(0,0,0,.2); }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #FF8050, var(--apricot)); border-radius: 6px; transition: width .6s; }
.freedom label { display: table; margin: 2px auto 0; padding: 0 8px; font-size: 12px; background: rgba(246,232,207,.85); border-radius: 6px; cursor: help; }
.hud-right { justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; } /* mood and health, then buffs */
.vitals { display: flex; gap: 4px; }
.mood, .hearts { display: flex; gap: 2px; padding: 3px 8px; cursor: help; align-items: center; }
.mood img, .hearts img { width: 24px; height: 24px; image-rendering: auto; }
.buffs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 260px; }
.buff { width: 36px; height: 36px; background: var(--cream); border: 2px solid var(--wood); border-radius: 6px; display: grid; place-items: center; position: relative; cursor: help; box-shadow: 0 2px 0 var(--wood-d); }
.buff.bad { background: #F3D2C8; }
.buff img { width: 24px; height: 24px; image-rendering: pixelated; }
.pulse { animation: pulse .45s; }
@keyframes pulse { 30% { transform: scale(1.18); filter: brightness(1.15); } }

/* action bar */
#action-bar { position: absolute; left: 50%; transform: translateX(-50%) scale(var(--ui)); transform-origin: bottom center; bottom: calc(10px + var(--safe-b)); display: flex; gap: 8px; padding: 8px; background: var(--wood); border-color: var(--wood-d); z-index: 5; }
#action-bar .wood-btn { width: 104px; height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; font-size: 18px; position: relative; }
#action-bar .lock { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; }
.phase-board #action-bar { display: none; }

/* hub */
#hub-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#hub-canvas { display: block; cursor: pointer; }
#room-switcher { display: none; }
.switch-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.arrow { width: 48px; height: 48px; padding: 0; font-size: 18px; }
#room-name { min-width: 150px; text-align: center; font-size: 20px; padding: 8px 12px; }
.dots { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; background: #8A5A38; border: 2px solid var(--wood-d); }
.dots i.on { background: var(--apricot); }

/* board */
#board-screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: calc(110px * var(--ui)); padding-bottom: 20px; z-index: 3; }
/* Focus mode: with the board open the main HUD hides (it stays in the layout, so fly-to targets keep a position) and the home behind blurs and darkens. */
:root { --board-blur: 16px; /* blur radius of the home and sky behind the board */ --board-dim: .5; /* alpha of the dark layer behind the board: 0 none, 1 black */ }
#hud { transition: opacity .25s, visibility .25s; }
.phase-board #hud { opacity: 0; visibility: hidden; }
.phase-board #sky { filter: saturate(.8) blur(var(--board-blur)); }
.phase-board #hub-screen { filter: blur(var(--board-blur)) brightness(.9); }
#board-screen::before { content: ''; position: absolute; inset: 0; z-index: -1; background: rgba(40,26,16,var(--board-dim)); pointer-events: none; }
.board-layout { display: grid; grid-template-areas: '. hud .' 'goal frame rules'; grid-template-columns: auto auto auto; gap: 10px 16px; align-items: start; }
.board-center { display: contents; } /* its hud and frame sit in the grid, so the side panels line up with the board */
#board-goal { grid-area: goal; }
#board-legend { grid-area: rules; align-self: start; } /* as tall as its rows, not as the board */
.board-hud { grid-area: hud; justify-self: center; display: flex; gap: 16px; align-items: center; padding: 6px 14px; font-size: 18px; }
.board-hud .moves { font-size: 32px; font-weight: 700; min-width: 70px; text-align: center; line-height: 1; }
.board-hud .moves small { display: block; font-size: 14px; font-weight: 500; }
.board-hud .stat { display: flex; align-items: center; gap: 4px; }
.board-hud .exit { min-height: 36px; padding: 2px 10px; font-size: 15px; }
.board-frame { grid-area: frame; justify-self: center; /* as wide as the tiles, never stretched by a wider HUD */ padding: 10px; background: var(--wood); border-radius: 12px; border: 3px solid var(--wood-d); box-shadow: inset 2px 2px 0 var(--wood-l), 0 6px 18px rgba(74,52,101,.3); }
.board-wrap { position: relative; background: #C99A6E; border-radius: 4px; touch-action: none; }
.board-canvas { display: block; touch-action: none; } /* block: an inline canvas leaves a baseline gap under the tiles */
.fx-canvas { position: absolute; inset: 0; pointer-events: none; }
.board-side { width: 200px; padding: 10px; font-size: 16px; }
.board-side:empty { display: none; }
.board-side.right { width: auto; min-width: 200px; } /* as wide as its longest rule; wraps only when the window is too narrow */
.board-side h4 { margin: 0 0 6px; font-size: 17px; }
.legend-row { display: flex; align-items: flex-start; gap: 6px; margin: 4px 0; line-height: 24px; } /* icon and first text line share a top */
.goal { padding: 10px; }
.banners { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; pointer-events: none; z-index: 20; } /* centered on the board itself */
.banner { display: flex; align-items: center; gap: 12px; white-space: nowrap; background: var(--apricot); border: 4px solid var(--wood); border-radius: 12px; padding: 12px 28px; font-size: 34px; font-weight: 700; box-shadow: 0 6px 0 var(--wood-d); animation: banner 1.6s forwards; }
.banner.done { background: var(--orange); }
.banner .check { width: 14px; height: 26px; border: solid var(--wood-d); border-width: 0 6px 6px 0; transform: translateY(-4px) rotate(45deg); }
@keyframes banner { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.1); opacity: 1; } 25%, 80% { transform: scale(1); opacity: 1; } 100% { opacity: 0; } }
.float-text { position: absolute; transform: translate(-50%, -50%); pointer-events: none; font-weight: 700; font-size: 19px; text-align: center; white-space: nowrap; animation: rise 1.3s ease-out forwards; z-index: 10; text-shadow: 0 2px 0 rgba(92,66,40,.35); }
.float-text .good { color: #2F6B3A; -webkit-text-stroke: .4px #FFF4E2; } .float-text .bad { color: #B23A33; -webkit-text-stroke: .4px #FFF4E2; } .float-text .neutral { color: var(--ink); }
.float-text div { background: rgba(246,232,207,.88); border-radius: 6px; padding: 0 5px; margin: 1px 0; }
.float-text.big { font-size: 26px; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%,-30%) scale(.7); } 12% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-160%); } }
.shake { animation: shake .25s; } .shake-strong { animation: shake .35s 2; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.fly-chip { position: fixed; z-index: 60; pointer-events: none; background: var(--cream); border: 2px solid var(--wood); border-radius: 8px; padding: 2px 8px; font-weight: 700; font-size: 17px; box-shadow: 0 2px 0 var(--wood-d); }
.fly-chip.good { color: #2F6B3A; } .fly-chip.bad { color: #B23A33; }
.fly-chip.icon { background: none; border: 0; box-shadow: none; padding: 0; line-height: 0; }
.party { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 50; pointer-events: none; image-rendering: pixelated; }

/* modals */
#modal-root { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.modal-back { position: absolute; z-index: 0; /* own stacking context: a lower pop-up's z-indexed parts must not show through */ inset: 0; background: rgba(74,52,101,.35); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; pointer-events: auto; animation: fade .15s; padding: 12px; }
.modal-back > .modal { min-width: 0; }
.lines td:first-child { overflow-wrap: anywhere; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(1000px, 100%); max-height: calc(100% - 20px); overflow: auto; padding: 18px 56px 18px 20px; animation: slidein .22s cubic-bezier(.3,1.4,.6,1); position: relative; }
.modal.narrow { width: min(460px, 100%); } .modal.report { width: min(560px, 100%); } .modal.report .bar { height: 10px; margin: 2px 0 4px; } .modal.report h3 { margin-top: 16px; }
.modal h2 { margin: 0 0 6px; font-size: 24px; } .modal h3 { margin: 12px 0 6px; font-size: 18px; }
.modal p { margin: 6px 0; line-height: 1.35; }
.modal .close { position: absolute; top: 8px; right: 8px; min-height: 36px; width: 40px; padding: 0; }
@keyframes slidein { from { transform: translateY(24px) scale(.96); opacity: 0; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.muted { color: #9A7A5A; font-size: 14px; }
.good { color: #2F6B3A; } .bad { color: #B23A33; }
.tabs { display: flex; gap: 6px; margin: 6px 0 10px; flex-wrap: wrap; }
.tabs .wood-btn { min-height: 38px; padding: 4px 10px; font-size: 15px; }
.wood-btn.on { background: var(--apricot); }
.lines { width: 100%; border-collapse: collapse; font-size: 15px; }
.lines td { padding: 3px 4px; border-bottom: 1px dashed var(--cream-d); }
.lines td:last-child { text-align: right; white-space: nowrap; font-weight: 600; }
.lines tr.total td { border-top: 2px solid var(--wood); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card { background: #FFF4E2; border: 2px solid var(--wood-l); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.card.dim { opacity: .55; filter: grayscale(.5); }
.card h4 { margin: 0; font-size: 16px; }
/* shop cards: equal rows, the picture fills its box, the button sits at the card bottom */
.grid { grid-auto-rows: 1fr; }
.card > .wood-btn { margin-top: auto; }
.card .thumb { width: 100%; height: 130px; object-fit: contain; image-rendering: pixelated; background: #F6E8CF; border-radius: 6px; padding: 6px; box-sizing: border-box; }
.card .thumb.glyph { display: grid; place-items: center; font-size: 48px; }
.modal > .spread.head { padding-right: 48px; } /* keep the title row clear of the close button */
@media (max-aspect-ratio: 1/1), (max-width: 760px) { .card .thumb { height: 104px; } }
.pros .note { color: #8A6A4A; margin-top: 4px; }
.pros { font-size: 13px; } .pros .good::before { content: '＋ '; } .pros .bad::before { content: '－ '; }
input[type=range] { width: 100%; accent-color: var(--orange); }
input[type=text] { font-family: inherit; font-size: 18px; padding: 8px; border: 3px solid var(--wood); border-radius: 8px; background: #FFF8EC; color: var(--ink); width: 100%; }

/* event card */
/* Event card: the same padding on all 4 sides. Gaps: 4 px inside a group (title + story), 8 px between parts (label, title, choices), 16 px between groups
   (picture, text, choices); every gap is smaller than the padding (proximity rule, docs/ux-laws.md). Width = picture (4x: 400) + 2 x padding + 2 x 3 px border. */
.modal.event-card { width: min(446px, 100%); padding: 20px; display: flex; flex-direction: column; }
.event-card > * { margin: 0; }
.event-card > .illo { width: 400px; height: 224px; margin-bottom: 16px; align-self: center; border-radius: 10px; image-rendering: pixelated; } /* whole-number scale only */
.event-card > h2 { margin: 8px 0 0; }
.event-card > p { margin: 4px 0 0; }
.event-card > p.muted { margin-top: 8px; }
.event-card > .choice { margin: 8px 0 0; }
.event-card > p + .choice { margin-top: 16px; }
@media (max-width: 469px) { /* phone: 3x picture, padding 14 and group gaps 12, so a 360 px screen fits it */
  .modal.event-card { width: min(334px, 100%); padding: 14px; } .event-card > .illo { width: 300px; height: 168px; margin-bottom: 12px; } .event-card > p + .choice { margin-top: 12px; } }
@media (max-width: 357px) { .modal.event-card { width: 100%; } .event-card > .illo { width: 200px; height: 112px; } } /* shortcut: 2x picture with wider side gaps below 358 px, until such phones matter */
.event-card .tone { align-self: flex-start; display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 6px; border: 2px solid var(--wood-l); }
.tone.good { background: #DDEBC8; } .tone.bad { background: #F3D2C8; } .tone.neutral { background: #EFE4D2; }
.choice { display: block; width: 100%; text-align: left; margin: 8px 0; padding: 10px 12px; }
.choice small { display: block; font-weight: 500; font-size: 14px; color: #8A6A4A; margin-top: 2px; }
.choice.locked small { color: #9A8A78; }

/* knowledge tree and reader: see books.css */
.unlock { text-align: center; }
.unlock .big-icon { width: 96px; height: 96px; image-rendering: pixelated; animation: glow 1.5s infinite alternate; }
@keyframes glow { to { filter: drop-shadow(0 0 10px #FFE08A); } }

/* tooltips (the onboarding tips are in coach.css) */
.tip { position: fixed; z-index: 50; max-width: 280px; background: #FFF4E2; border: 2px solid var(--wood); border-radius: 8px; padding: 8px 10px; font-size: 14px; pointer-events: none; box-shadow: 0 3px 0 var(--wood-d); white-space: pre-line; }
.toast { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 45; }

/* phone portrait (PRD 16.2) */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  /* two columns: the player (avatar + name, mood, health and buffs in one line under it) and the money (cash, freedom bar) */
  #hud { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 6px; row-gap: 4px; padding: calc(8px + var(--safe-t)) 6px 0; }
  .hud-money { grid-column: 2; grid-row: 1 / 3; align-self: start; justify-self: end; width: fit-content; max-width: 100%; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; } /* as wide as the money card; its top lines up with the name card */
  .hud-right { grid-column: 1; grid-row: 2; align-items: flex-start; justify-self: start; gap: 4px; } /* mood and health in one line, the buffs under them */
  .buffs { justify-content: flex-start; gap: 4px; max-width: 220px; }
  .medal { width: 56px; height: 56px; border-width: 3px; } .medal canvas { width: 48px; height: 48px; image-rendering: auto; }
  .who-plate { padding: 3px 6px 3px 12px; margin-left: -10px; max-width: 110px; } .who-name { font-size: 12px; } .who-plate small { font-size: 9.5px; }
  .vitals { gap: 3px; }
  .mood, .hearts, .buff { height: 30px; box-sizing: border-box; } /* one height for every icon chip */
  .mood, .hearts { padding: 0 5px; gap: 1px; } .mood { width: 30px; justify-content: center; padding: 0; } .mood img, .hearts img { width: 18px; height: 18px; }
  .money-plate { padding: 2px 8px 2px 4px; gap: 3px; justify-content: flex-start; } .money-plate .val { font-size: 16px; }
  .money-plate small { font-size: 9.5px; }
  .freedom { margin: 0; }
  .freedom label { font-size: 11px; display: block; width: 0; min-width: 100%; box-sizing: border-box; text-align: center; } /* never wider than the card above; a long text wraps to a second row */
  .buff { width: 30px; } .buff img { width: 20px; height: 20px; }
  #hub-screen { justify-content: center; padding-top: calc(100px + var(--safe-t)); padding-bottom: calc(96px + var(--safe-b)); }
  #room-switcher { display: block; margin-top: 18px; }
  #action-bar { left: 8px; right: 8px; transform: none; gap: 4px; padding: 6px; justify-content: space-between; }
  #action-bar .wood-btn { flex: 1; width: auto; height: 62px; font-size: 12px; min-width: 0; white-space: nowrap; }
  .money-plate .pix { width: 22px; height: 22px; }
  #board-screen { padding: calc(8px + var(--safe-t)) 4px calc(8px + var(--safe-b)); } /* the main HUD and the action bar are hidden on the board: the screen is all board, layout() sizes the tiles from what is left */
  .board-layout { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .board-center { display: flex; flex-direction: column; align-items: center; gap: 10px; }
  /* legend under the board: two columns, small icons, the last row (run bonuses) across. Its width does not depend on the tile size. */
  #board-legend { align-self: center; display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; width: min(calc(100vw - 8px), 480px); padding: 4px 8px; font-size: 12px; }
  #board-legend h4 { display: none; }
  #board-legend .legend-row { margin: 2px 0; gap: 4px; line-height: 14px; min-width: 0; }
  #board-legend .legend-row:last-child { grid-column: 1 / -1; }
  #board-legend .pix { width: 16px; height: 16px; flex: none; }
  #board-legend .legend-row span { min-width: 0; } /* each line div stays its own block */
  .board-side.left:not(:empty) { display: block; width: auto; padding: 4px 8px; order: -1; }
  .goal { padding: 4px 8px; font-size: 13px; } .goal h4 { display: none; } .goal div { display: inline; margin-left: 6px; font-weight: bold; white-space: nowrap; } /* one short card: the board keeps its room */
  #app { bottom: auto; height: 100%; height: 100dvh; } /* the visible height: the browser bars must not hide the bottom of the board */
  #board-screen { overflow: hidden; overscroll-behavior: none; } /* nothing scrolls under the finger */
  .board-hud { gap: 8px; font-size: 13px; padding: 4px 8px; flex-wrap: wrap; justify-content: center; }
  .board-hud .moves { font-size: 24px; min-width: 50px; }
  .board-frame { padding: 5px; }
  .banner { font-size: 22px; padding: 8px 16px; gap: 8px; } .banner .check { width: 10px; height: 18px; border-width: 0 4px 4px 0; }
  .modal { padding: 14px 12px; }
}
/* phone held sideways or a short window: wide, but under 640 px high. The desktop board layout (goal | board | legend), tighter; it also overrides the phone rules above. fitBoard() uses the same query (isShort in main.js). */
@media (min-aspect-ratio: 1/1) and (max-height: 640px) {
  #board-screen { padding: 6px 8px; }
  .board-layout { display: grid; grid-template-areas: 'hud .' 'frame goal' 'frame rules'; grid-template-columns: auto auto; grid-template-rows: auto auto 1fr; align-items: start; gap: 4px 10px; } /* the goal sits above the legend: three columns do not fit a phone */
  .board-center { display: contents; }
  #board-legend { display: block; align-self: start; width: auto; min-width: 150px; padding: 4px 8px; font-size: 12px; }
  #board-legend .legend-row:last-child { grid-column: auto; }
  .board-side.left:not(:empty) { order: 0; width: auto; }
  .board-hud { flex-wrap: nowrap; gap: 8px; padding: 2px 8px; font-size: 13px; }
  .board-hud .moves { font-size: 22px; min-width: 50px; } .board-hud .moves small { font-size: 11px; }
  .board-hud .exit { min-height: 28px; font-size: 13px; }
  .board-frame { padding: 5px; }
  .board-side { width: 150px; padding: 4px 8px; font-size: 12px; }
  .board-side.right { width: auto; min-width: 150px; }
  .board-side h4 { display: none; }
  .legend-row { margin: 2px 0; gap: 4px; line-height: 14px; }
  .board-side .pix { width: 16px; height: 16px; flex: none; }
  .goal { padding: 4px 8px; }
}
.shot .modal, .shot .modal-back, .shot .coach { animation: none; } /* review screenshots: no half-faded panels */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } .leaf { display: none; } }
/* Start screen: every step has the same rows (head: title and progress; content; foot: Back left, primary action right). */
/* No game UI while the page boots (a saved game or the setup modal is not known yet) or while the player sets up a new character. */
body.booting :is(#hud, #action-bar, #room-switcher), body:has(.modal.start) :is(#hud, #action-bar, #room-switcher) { visibility: hidden; transition: none; }
.modal.start { width: min(540px, 100%); padding: 18px 22px 20px; display: flex; flex-direction: column; gap: 16px; }
.start-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.start-head h2 { margin: 0; font-size: 28px; }
.steps { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.steps i { width: 12px; height: 12px; border-radius: 50%; background: #FFF4E2; border: 2px solid var(--wood-l); }
.steps i.done { background: var(--wood-l); } .steps i.on { background: var(--apricot); border-color: var(--wood); box-shadow: 0 0 0 2px var(--apricot-d); }
.steps span { margin-left: 6px; color: #9A7A5A; font-size: calc(14px + var(--more)); }
.start p { margin: 0; line-height: 1.4; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px 10px; font: inherit; color: inherit; text-align: center; cursor: pointer; background: var(--cream); border: 3px solid var(--wood-l); border-radius: 10px; box-shadow: 0 3px 0 var(--wood-l); transition: transform .06s, background .1s; }
@media (hover: hover) { .pick:hover { background: #FFF1DC; } }
.pick.on { background: #FFE9BE; border-color: var(--wood); box-shadow: 0 0 0 3px var(--apricot), 0 3px 0 var(--wood-d); }
.pick b { font-family: var(--num); font-weight: 800; font-size: calc(18px + var(--more)); }
.pick.bg { align-items: flex-start; text-align: left; justify-content: flex-start; }
.pick.bg span { font-size: calc(15px + var(--more)); line-height: 1.35; }
.pf { width: 132px; height: 132px; display: grid; place-items: center; flex: none; } /* no frame or tile: the pick button has the only border */
.pf canvas { width: 120px; height: 120px; } /* portrait art is 60 px: 2x stays crisp */
.opt { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 10px; }
.opt .lbl { font-weight: 700; }
.privacy { font-size: 13px; line-height: 1.4; } /* small and muted; same gap as the other parts of the card */
.intro-art { display: block; width: 100%; height: auto; border: 3px solid var(--wood); border-radius: 10px; } /* 384x255 art px, full card width */
.grades { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; } /* the stars line up with the first line of text */
.tiers { display: flex; flex: none; } .tiers .pix { width: 32px; height: 32px; } .tier + .tier { margin-left: -6px; } /* 16 px stars at 2x; they overlap a little */
.summary { display: flex; align-items: center; gap: 14px; }
.summary .pf { width: 76px; height: 76px; border-radius: 10px; } .summary .pf canvas { width: 60px; height: 60px; }
.summary b { display: block; font-family: var(--num); font-weight: 800; font-size: calc(22px + var(--more)); }
.start-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.start-foot .wood-btn { min-width: 110px; } .start-foot .primary { min-width: 170px; } .start-foot .go { font-size: 20px; }
@media (max-width: 520px) {
  .modal.start { padding: 14px 14px 16px; gap: 12px; }
  .start-head h2 { font-size: 22px; } .steps span { display: none; }
  .choices.bgs { grid-template-columns: 1fr; }
  .pf { width: 116px; height: 116px; } .pf canvas { width: 104px; height: 104px; image-rendering: auto; }
  .start-foot .wood-btn { min-width: 90px; } .start-foot .primary { min-width: 0; flex: 1; }
}

/* Reading text (not the interface) is 2pt bigger: cards, lists, books, tips, board panels. */
:root { --more: 2pt; }
.modal { font-size: calc(16px + var(--more)); }
.muted { font-size: calc(14px + var(--more)); } .lines { font-size: calc(15px + var(--more)); } .pros { font-size: calc(13px + var(--more)); }
.card h4 { font-size: calc(16px + var(--more)); } .event-card .tone { font-size: calc(13px + var(--more)); } .choice small { font-size: calc(14px + var(--more)); }
.tip { font-size: calc(15px + var(--more)); } .board-side { font-size: calc(14px + var(--more)); } .board-side h4 { font-size: calc(15px + var(--more)); }
.float-text { font-size: calc(17px + var(--more)); } .float-text.big { font-size: calc(24px + var(--more)); }

/* pixel font for titles, buttons and big text (18px and up); small and body text stays in the clear font */
.modal h2, .modal h3, .card h4, .banner, .board-side h4, .wood-btn, .who-plate, .float-text, #room-name { font-family: var(--pixel); }
.wood-btn small, .choice small, .money-plate small, .who-plate small { font-family: var(--font); }

/* owned property: value on top, two equal buttons below */
.prop { display: grid; gap: 6px; padding: 8px 0; border-top: 2px dashed var(--cream-d); }
.prop-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* options: sections, rows (label left, control right), a separate danger zone */
.osec { margin: 14px 0 0; padding-top: 10px; border-top: 2px solid var(--cream-d); }
.osec:first-of-type { border-top: 0; padding-top: 0; }
.osec h3 { margin: 0 0 6px; font-size: 18px; color: var(--wood); }
.orow { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--cream-d); }
.orow:last-child { border-bottom: 0; }
.orow .olabel { flex: 1 1 0; min-width: 0; line-height: 1.3; }
.orow input[type=range] { flex: 0 0 min(220px, 48%); width: auto; }
.orow .toggle { flex: none; min-width: 84px; }
.start-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; } .start-top .langs { justify-content: flex-start; }
.wood-btn.snd { flex: none; min-width: 44px; padding-inline: 10px; font-size: 20px; line-height: 1; }
.langs { display: flex; gap: 8px; justify-content: center; } .osec .langs { justify-content: flex-start; } .langs .toggle { min-width: 110px; }
.osec.danger { margin-top: 20px; padding: 10px 12px; background: #F9E3D6; border: 2px solid #D9544D; border-radius: 8px; }
.osec.danger h3 { color: #B23A33; }
.osec.danger .orow { padding: 4px 0; }
.wood-btn.danger { background: #D9544D; border-color: #8E2B27; color: #FFF4E2; box-shadow: inset 2px 2px 0 #E77D77, 0 3px 0 #6E1F1B; }
@media (hover: hover) { .wood-btn.danger:hover { background: #E06A63; } }
.orow.muted .olabel { font-size: 15px; }

/* scrollbar: slim brown thumb, transparent track, fixed width (no layout shift); fades in on scroll or hover */
@supports not selector(::-webkit-scrollbar) { /* Firefox: colour only, fades by class */
  * { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  *:hover, .sb-on { scrollbar-color: var(--wood-l) transparent; }
}
::-webkit-scrollbar { width: 8px; height: 8px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background-color: transparent; border-radius: 4px; transition: background-color .5s; }
.sb-on::-webkit-scrollbar-thumb, *:hover::-webkit-scrollbar-thumb { background-color: var(--wood-l); }

/* life overview pop-up (the avatar) */
.hud-who .medal, .hud-who .who-plate { cursor: pointer; }
.modal.me { width: min(620px, 100%); }
.me .tabs .wood-btn, .end .tabs .wood-btn { flex: 1 1 0; min-height: 44px; }
.me .stats, .end .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.me .stat, .end .stat { background: #FFF4E2; border: 2px solid var(--wood-l); border-radius: 8px; padding: 6px 10px; display: flex; flex-direction: column; }
.me .stat small, .end .stat small { color: #9A7A5A; font-size: 13px; } .me .stat b, .end .stat b { font-size: 18px; }
.me .stat.bad b { color: #B23A33; }
.me-scroll { max-height: calc(100vh - 210px); overflow: auto; padding-right: 4px; }
.me .pill { display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0; border-radius: 10px; background: var(--c, #CDBEA8); border: 2px solid var(--wood-l); font-size: 14px; }
/* money tab: hero + grouped rows */
.me .wealth h3 { margin: 14px 0 4px; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: #9A7A5A; }
.me .hero { background: var(--wood); color: var(--cream); border-radius: 12px; padding: 12px 14px; box-shadow: inset 0 0 0 2px var(--wood-l); }
.me .hero small { font-size: 13px; opacity: .8; }
.me .hero .big { font-family: var(--num); font-size: 38px; font-weight: 800; line-height: 1.1; color: var(--apricot); margin-bottom: 8px; }
.me .hero .bar { height: 12px; } .me .hero-line { font-size: 14px; margin-top: 5px; } .me .hero-line b { font-size: 15px; }
.me .rows { background: #FFF4E2; border: 2px solid var(--wood-l); border-radius: 10px; padding: 2px 12px; }
.me .row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--cream-d); }
.me .row:last-child { border-bottom: 0; }
.me .row i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.me .row span { flex: 1; min-width: 0; color: #7A5A3A; }
.me .row b { font-family: var(--num); font-weight: 800; font-size: 18px; white-space: nowrap; }
.me .row.bad span, .me .row.bad b { color: #B23A33; } .me .row.zero { opacity: .55; }
.me .bar.thin { height: 8px; margin: 0 0 10px; }
/* end screen: hero (scene, stars, title), tabs, scrolling body, fixed foot */
.modal.end { width: min(640px, 100%); padding: 0 16px 14px; display: flex; flex-direction: column; overflow: hidden; }
.end-hero { margin: 0 -16px 8px; padding: 14px 16px 10px; text-align: center; border-bottom: 4px solid var(--wood); }
.end-hero.win { background: linear-gradient(#FFE2A8, #FFF1D2); }
.end-hero.lose { background: linear-gradient(#4A3465, #8A6A8E 70%, #D9A58A); color: #FFF4E2; }
.end-hero h2 { margin: 4px 0 0; font-size: 26px; }
.end-sub { margin: 2px 0 0; font-weight: 700; }
.end-scene { position: relative; height: 112px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.end-scene > .pix { width: 96px; height: 96px; }
.end-hero.lose .end-scene > .pix { filter: brightness(.7) saturate(.8); }
.end-who canvas { width: 72px; height: 72px; display: block; }
.end-hero.lose .end-who { opacity: .85; }
.end-stars { display: flex; justify-content: center; gap: 10px; margin-top: 6px; }
.estar .pix { width: 52px; height: 52px; }
.estar.on { animation: starpop .5s calc(.35s + var(--i) * .25s) cubic-bezier(.3,1.6,.6,1) backwards; }
:is(.estar, .tier).gold .pix { filter: drop-shadow(0 2px 0 var(--wood-d)); }
:is(.estar, .tier).silver .pix { filter: grayscale(1) brightness(1.25) drop-shadow(0 2px 0 var(--wood-d)); }
:is(.estar, .tier).bronze .pix { filter: sepia(.6) hue-rotate(-18deg) saturate(1.2) brightness(.7) drop-shadow(0 2px 0 var(--wood-d)); }
.estar:not(.on) .pix { filter: grayscale(1) brightness(.2); opacity: .55; }
.end-hero.lose .estar:not(.on) .pix { filter: grayscale(1) brightness(.55); opacity: .5; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.spark { position: absolute; width: 8px; height: 8px; background: #FFF8D8; box-shadow: 0 0 6px 2px #FFD66B; transform: rotate(45deg); animation: twinkle 1.8s infinite; }
.spark.s1 { left: 18%; top: 22%; } .spark.s2 { right: 20%; top: 12%; animation-delay: .5s; } .spark.s3 { left: 30%; top: 60%; animation-delay: 1s; } .spark.s4 { right: 28%; top: 50%; animation-delay: 1.4s; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: rotate(45deg) scale(.4); } 50% { opacity: 1; transform: rotate(45deg) scale(1.1); } }
.end-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding-right: 4px; }
.end-foot { padding-top: 10px; display: flex; justify-content: center; }
.end-foot .wood-btn { min-height: 44px; min-width: 200px; }
.chart svg { width: 100%; height: auto; display: block; background: #FFF4E2; border: 2px solid var(--wood-l); border-radius: 8px; }
.chart polygon { fill: rgba(79,122,85,.25); } .chart polyline { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linejoin: round; }
.chart .zero { stroke: var(--taupe); stroke-dasharray: 3 3; }
.moment { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--cream-d); } .moment b { min-width: 28px; color: var(--wood-l); }
@media (max-width: 600px) { .modal.end { padding: 0 12px 12px; } .end-hero { margin: 0 -12px 8px; } .end-hero h2 { font-size: 22px; } .estar .pix { width: 44px; height: 44px; } .end-foot .wood-btn { width: 100%; } }
