/* HD-2D rebuild: the 3D picture fills the window; the interface is HTML over it, in the pixel style of the 2D game (Pixelify Sans, 9-slice
   frames generated by code: --bi-panel, --bi-btn, --bi-btn2, --bi-slot set by src/main.js from src/art/framePaint.js).
   J7/J8: the in-game HUD (badge, hint, toast, catch card, touch controls) is measured in --px. J9-A: the screens of the shell (start, journal,
   settings, photo) and their buttons are measured in --u = 1/480 of the width of the largest 16:9 box that fits the window, exactly as the 2D game
   (src/styles.css), with the same pixel floors under every text size; <html data-fs> and --fs are the text size setting. */
@font-face {
  font-family: "Pixelify Sans";
  src: url("../vendor/fonts/pixelify-sans/pixelify-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: block;
}
:root { --fs: 1; --target: 44px; --u: min(calc(100vw / 480), calc(100vh / 270)); }
@supports (height: 100dvh) { :root { --u: min(calc(100vw / 480), calc(100dvh / 270)); } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e0a20; color: #fdf2dc; font-family: "Pixelify Sans", monospace; font-weight: 400; }
[hidden] { display: none !important; }
#app {
  position: fixed; inset: 0; --px: max(2px, min(0.22vw, 0.4vh));
  --t-body: max(calc(14px * var(--fs)), calc(var(--u) * 8.5 * var(--fs)));
  --t-msg: max(calc(14px * var(--fs)), calc(var(--u) * 10 * var(--fs)));
  --t-btn: max(calc(14px * var(--fs)), calc(var(--u) * 10 * var(--fs)));
  --t-h2: max(calc(18px * var(--fs)), calc(var(--u) * 14 * var(--fs)));
  --t-small: max(calc(12px * var(--fs)), calc(var(--u) * 7.4 * var(--fs)));
  --t-sub: max(calc(14px * var(--fs)), calc(var(--u) * 11 * var(--fs)));
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
canvas#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
canvas#scene:focus-visible { outline: 3px solid #ffd987; outline-offset: -3px; }
.vig { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, transparent 55%, #120c2a99 100%); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
button, input, label, select { font: inherit; }
:focus-visible { outline: max(2px, calc(var(--u) * 1)) dashed #fff; outline-offset: calc(var(--u) * 2); }

/* ---- the screens: one at a time (#app[data-screen]); the in-game interface (#hud) is the "game" screen ---- */
.scr { position: absolute; inset: 0; display: none; }
#app[data-screen="home"] .scr[data-ui="home"], #app[data-screen="game"] .scr[data-ui="game"], #app[data-screen="book"] .scr[data-ui="book"], #app[data-screen="settings"] .scr[data-ui="settings"], #app[data-screen="photo"] .scr[data-ui="photo"], #app[data-screen="shop"] .scr[data-ui="shop"], #app[data-screen="repair"] .scr[data-ui="repair"], #app[data-screen="quests"] .scr[data-ui="quests"], #app[data-screen="dialogue"] .scr[data-ui="dialogue"], #app[data-screen="bag"] .scr[data-ui="bag"] { display: block; }
#app[data-screen="photo"] .vig { display: none; }
.ui { font-size: var(--t-body); line-height: 1.2; text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; -webkit-font-smoothing: none; text-rendering: optimizeSpeed; }
#app, .ui { font-variant-ligatures: none; }
.sbody, .sheet, #page, .home-col, .card { scrollbar-width: thin; scrollbar-color: #ffd987 #2b2358; }
.dim { position: absolute; inset: 0; background: #130f2c99; }
#s-home .dim { background: radial-gradient(ellipse at 50% 52%, #130f2c8c 0%, #130f2c66 45%, #130f2c99 100%); } /* brief 33: a little darker behind the text (the sound note was 4.37 : 1 over the bright lake by day) */
#s-home .home-col > * { text-shadow: 0 calc(var(--u) * 1) calc(var(--u) * 3) #130f2c, calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; }

/* ---- J7/J8 HUD (in --px) ---- */
.panel { border-style: solid; border-width: calc(var(--px) * 4); border-image: var(--bi-panel) 4 fill / calc(var(--px) * 4) stretch; image-rendering: pixelated; padding: calc(var(--px) * 3) calc(var(--px) * 6); }
.btn { font: inherit; cursor: pointer; color: #2a1c30; text-shadow: none; background: none; border-style: solid; border-width: calc(var(--px) * 3); border-image: var(--bi-btn) 3 fill / calc(var(--px) * 3) stretch; image-rendering: pixelated; padding: calc(var(--px) * 1) calc(var(--px) * 6); min-height: 44px; min-width: 44px; text-decoration: none; display: inline-block; }
.btn.alt { color: #fdf2dc; border-image: var(--bi-btn2) 3 fill / calc(var(--px) * 3) stretch; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #ffd987; outline-offset: 2px; }
#hud { pointer-events: none; font-size: calc(clamp(14px, 1.9vh, 22px) * var(--fs)); text-shadow: none; }
#hud > * { pointer-events: auto; }
.card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; min-width: min(90vw, 340px); max-width: 92vw; max-height: 94%; overflow-y: auto; }
.card canvas { width: 160px; height: 96px; image-rendering: pixelated; display: block; margin: 0 auto; }
.card h3 { margin: 6px 0; font-size: 1.5em; color: #ffd987; font-weight: 400; }
#cardInfo { display: flex; gap: 0 14px; justify-content: center; flex-wrap: wrap; }
#cardInfo .new { color: #2a1c30; background: #ffd987; padding: 0 6px; }
#cardBook { opacity: .85; margin: 6px 0 10px; font-size: .9em; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid #fdf2dc88; background: #1b184055; pointer-events: none; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: #ffd987cc; border: 3px solid #2a1c30; }
#tags { position: absolute; inset: 0; pointer-events: none; }
.tag { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: .8em; color: #fdf2dc; background: #1b1840cc; border: 2px solid #fdf2dc99; padding: 1px 6px; }
.tag::before { content: "▾ "; }
#debug { position: absolute; left: 12px; bottom: 12px; margin: 0; font: 12px/1.3 monospace; background: #000a; color: #bfe; padding: 6px 8px; pointer-events: none; white-space: pre; }
canvas.ic { width: calc(var(--u) * 16.5); height: calc(var(--u) * 16.5); image-rendering: pixelated; flex: none; }
canvas.ic.s { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
#lost { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 80vw; text-align: center; }
#fallback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: min(92vw, 560px); text-align: center; }
#fallback h1 { font-size: 1.4em; font-weight: 400; color: #ffd987; }
#nojs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #2b2358; padding: 16px; }

/* ---- shell screens (in --u, as the 2D game) ---- */
.ui .panel { border-width: calc(var(--u) * 4); border-image: var(--bi-panel) 4 fill / calc(var(--u) * 4) stretch; padding: calc(var(--u) * 4) calc(var(--u) * 6); }
.ui .btn { font-size: var(--t-btn); border-width: calc(var(--u) * 3); border-image: var(--bi-btn) 3 fill / calc(var(--u) * 3) stretch; padding: calc(var(--u) * 3) calc(var(--u) * 12); min-height: var(--target); min-width: var(--target); }
.ui .btn.alt { color: #fdf2dc; text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; border-image: var(--bi-btn2) 3 fill / calc(var(--u) * 3) stretch; }
.ui .btn:active { transform: translateY(calc(var(--u) * 1)); }
.home-lang { position: absolute; top: max(8px, calc(var(--u) * 8)); right: max(8px, calc(var(--u) * 10)); }
.home-col { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 7); padding: calc(var(--u) * 10) calc(var(--u) * 10); text-align: center; overflow-y: auto; }
#title { margin: 0; font-weight: 400; font-size: calc(var(--u) * 46); line-height: 1; color: #ffd987; letter-spacing: calc(var(--u) * 1); text-shadow: 0 calc(var(--u) * 3) 0 #a8523e, calc(var(--u) * 1) calc(var(--u) * 4) 0 #130f2c, 0 0 calc(var(--u) * 18) #f2896f; }
#sub { margin: 0; font-size: var(--t-sub); max-width: calc(var(--u) * 340); }
#snd { margin: 0; display: flex; justify-content: center; align-items: center; gap: calc(var(--u) * 5); opacity: .92; max-width: calc(var(--u) * 350); }
.home-btns { display: flex; gap: calc(var(--u) * 8); justify-content: center; flex-wrap: wrap; }
#offer { max-width: calc(var(--u) * 340); display: flex; flex-direction: column; gap: calc(var(--u) * 4); }
#offer h2 { margin: 0; font-size: var(--t-h2); font-weight: 400; color: #ffd987; }
#offer p { margin: 0; font-size: var(--t-body); }
#loadWrap { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 4); }
#loadMsg { margin: 0; }
#loadBar { width: calc(var(--u) * 150); height: calc(var(--u) * 6); background: #3b2f6e; box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c, inset 0 0 0 calc(var(--u) * 1) #6b5aa8; }
#loadBar i { display: block; height: 100%; width: 0; background: #ffd987; }

/* sheets (journal, settings): the 480 x 270 design box, centred */
.sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: calc(var(--u) * 436); height: calc(var(--u) * 250); overflow-y: auto; overflow-x: hidden; }
#s-settings .sheet { width: calc(var(--u) * 380); height: calc(var(--u) * 242); overflow: hidden; }
.sbody { height: 100%; overflow-y: auto; overflow-x: hidden; padding: calc(var(--u) * 3); }
.hd { display: flex; align-items: center; gap: calc(var(--u) * 8); margin-bottom: calc(var(--u) * 9); color: #ffd987; padding-right: max(var(--target), calc(var(--u) * 24)); }
.hd h2 { margin: 0; font-size: var(--t-h2); font-weight: 400; }
.pips { display: flex; gap: calc(var(--u) * 1); margin-left: auto; align-items: center; font-size: var(--t-body); color: #fdf2dc; flex-wrap: wrap; justify-content: flex-end; }
.pip { width: calc(var(--u) * 5); height: calc(var(--u) * 5); background: #3b2f6e; box-shadow: inset 0 0 0 calc(var(--u) * 1) #130f2c; }
.pip.on { background: #ffd987; }
.pips .cnt { margin-left: calc(var(--u) * 6); }
.closeb { position: absolute; right: calc(var(--u) * 4); top: calc(var(--u) * 4); width: max(var(--target), calc(var(--u) * 20)); height: max(var(--target), calc(var(--u) * 20)); padding: 0 !important; display: grid; place-items: center; }
.slot { height: max(var(--target), calc(var(--u) * 30)); display: grid; place-items: center; cursor: pointer; position: relative; padding: 0; background: none; color: #fdf2dc; border-style: solid; border-width: calc(var(--u) * 3); border-image: var(--bi-slot) 3 fill / calc(var(--u) * 3) stretch; image-rendering: pixelated; }
.slot canvas { width: 80%; image-rendering: pixelated; }
.slot.sel { filter: brightness(1.35); }
.slot small { position: absolute; right: calc(var(--u) * 4); bottom: calc(var(--u) * 1); font-size: var(--t-small); opacity: .85; }
#page .pg-head { display: flex; align-items: center; gap: calc(var(--u) * 6); margin-bottom: calc(var(--u) * 3); }
#page canvas { width: calc(var(--u) * 40 * 2); height: calc(var(--u) * 24 * 2); flex: none; image-rendering: pixelated; }
#page .pg-title { flex: 1; min-width: 0; }
#page h3 { margin: 0 0 calc(var(--u) * 1); font-size: max(calc(16px * var(--fs)), calc(var(--u) * 12 * var(--fs))); color: #ffd987; text-align: left; font-weight: 400; overflow-wrap: anywhere; line-height: 1.15; }
#page .d { text-align: left; margin: 0 0 calc(var(--u) * 3); }
#page .row { display: flex; justify-content: space-between; gap: calc(var(--u) * 4); border-top: calc(var(--u) * 1) dotted #6b5aa8; padding: calc(var(--u) * 1.6) 0; align-items: center; }
#page .row.hours { justify-content: flex-start; align-items: flex-start; gap: calc(var(--u) * 5); }
#page .row.hours > span:last-child { min-width: 0; flex: 1; }
#page .row.hours canvas.ic { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
.ics { display: inline-flex; gap: calc(var(--u) * 2); flex: none; align-items: center; min-height: 1.2em; }
.rar { display: inline-flex; align-items: center; gap: calc(var(--u) * 4); flex-wrap: wrap; }
.rp { display: inline-flex; gap: calc(var(--u) * 2); }
.rp i { width: calc(var(--u) * 5); height: calc(var(--u) * 5); background: #3b2f6e; box-shadow: inset 0 0 0 calc(var(--u) * 1) #130f2c; display: inline-block; }
.rp i.on { background: #ffd987; }
html[data-fs="1.25"] .slot, html[data-fs="1.5"] .slot { height: max(var(--target), calc(var(--u) * 24)); }
html[data-fs="1.25"] .hd, html[data-fs="1.5"] .hd { margin-bottom: calc(var(--u) * 4); }
html[data-fs="1.5"] .pip { width: calc(var(--u) * 4); height: calc(var(--u) * 4); }
html[data-fs="1.5"] .pips .cnt { margin-left: calc(var(--u) * 3); }
html[data-fs="1.25"] .slot canvas, html[data-fs="1.5"] .slot canvas { width: 76%; margin-top: -9%; margin-right: 6%; }
html[data-fs="1.25"] .slot small, html[data-fs="1.5"] .slot small { right: calc(var(--u) * 3); bottom: 0; line-height: 1; }

/* settings */
.set { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 3) calc(var(--u) * 8); margin: calc(var(--u) * 3) 0; }
.set .lbl { min-width: calc(var(--u) * 86); }
.seg { display: inline-flex; flex-wrap: wrap; gap: calc(var(--u) * 3); }
.seg button { font-size: var(--t-body); background: #3b2f6e; color: #fdf2dc; border: 0; padding: calc(var(--u) * 3) calc(var(--u) * 8); box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c; cursor: pointer; min-height: var(--target); min-width: var(--target); }
.seg button[aria-pressed="true"] { background: #ffd987; color: #2a1c30; text-shadow: none; }
.set select { font-size: var(--t-body); background: #3b2f6e; color: #fdf2dc; border: 0; box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c; padding: calc(var(--u) * 3) calc(var(--u) * 6); min-height: var(--target); cursor: pointer; }
.chk { display: flex; align-items: center; gap: calc(var(--u) * 7); min-height: var(--target); cursor: pointer; line-height: 1.15; }
.chk input { -webkit-appearance: none; appearance: none; flex: none; width: max(24px, calc(var(--u) * 13)); height: max(24px, calc(var(--u) * 13)); margin: 0; background: #3b2f6e; box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c, inset 0 0 0 calc(var(--u) * 1.5) #6b5aa8; cursor: pointer; }
.chk input:checked { background: #ffd987 radial-gradient(circle at center, #7a4a2e 0 calc(var(--u) * 3), transparent calc(var(--u) * 3.3)); }
.vol { display: flex; align-items: center; gap: calc(var(--u) * 8); min-height: var(--target); margin: calc(var(--u) * 1) 0; }
.vol .lbl { min-width: calc(var(--u) * 86); }
.vol input[type=range] { flex: 1 1 auto; min-width: calc(var(--u) * 70); max-width: calc(var(--u) * 150); height: var(--target); margin: 0; accent-color: #ffd987; background: transparent; cursor: pointer; }
.vol output { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.note { font-size: var(--t-small); opacity: .88; margin: calc(var(--u) * 6) 0 0; line-height: 1.35; }
.note.warn { color: #ffd987; opacity: 1; margin: 0 0 calc(var(--u) * 3); }
.note.warn::before { content: "⚠ "; }
#saveState { color: #ffd987; }
.photo-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, calc(var(--u) * 10)); width: 92%; display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 6); }
.photo-bar .note { margin: 0; padding: calc(var(--u) * 2) calc(var(--u) * 8); }
.photo-bar .row { display: flex; gap: calc(var(--u) * 8); flex-wrap: wrap; justify-content: center; }
#photoMsg { color: #ffd987; max-width: 92%; overflow-wrap: anywhere; }
#saveNote { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--t-body) * 2.5 + var(--u) * 24); max-width: 84%; width: max-content; font-size: var(--t-body); pointer-events: none; z-index: 4; text-align: center; text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; }
#app:not([data-screen="game"]):not([data-screen="home"]) #saveNote { display: none; }
#app:has(#card:not([hidden])) #saveNote { visibility: hidden; }
#fade { position: absolute; inset: 0; background: #0b0a16; opacity: 0; pointer-events: none; z-index: 5; transition: opacity 350ms linear; }
#fade.on { opacity: 1; }
body.rm #fade { transition-duration: 120ms; }
#app[data-inside="1"] #zoneText { display: block !important; max-width: 24vw; font-size: var(--t-small); }
@media (max-width: 760px) { html[data-fs="1.5"] #app[data-inside="1"] #zoneText { max-width: 15vw; } }
#app[data-inside="1"] #fishBtn, #app[data-inside="1"] #turnL, #app[data-inside="1"] #turnR { display: none !important; }
#shutter { position: absolute; inset: 0; background: #fff; pointer-events: none; z-index: 6; opacity: 0; }
#shutter.go { animation: shutter .28s steps(4) 1; }
@keyframes shutter { 0% { opacity: .85; } 100% { opacity: 0; } }
body.rm * { animation: none !important; }

/* portrait phone: a message, CSS only (no script); "Play anyway" turns the page a quarter turn (html[data-rot], shell/shell.js) */
#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: #1d1830; color: #fdf2dc; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; font-size: 20px; padding: 24px; line-height: 1.3; }
#rotate p { margin: 0; }
#rotate .rot-tip { font-size: 15px; opacity: .8; }
#rotateAnyway { font: inherit; font-size: 18px; color: #2a1c30; background: #ffd987; border: 3px solid #a8523e; border-radius: 6px; padding: 12px 18px; min-height: 48px; cursor: pointer; }
.phone { width: 44px; height: 76px; border: 4px solid #ffd987; border-radius: 8px; animation: turn 2.4s steps(8) infinite; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 600px) { #rotate { display: flex; } }
html[data-rot="1"] #rotate { display: none !important; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 600px) {
  html[data-rot="1"] { --u: min(calc(100vh / 480), calc(100vw / 270)); }
  html[data-rot="1"] #app { inset: auto; top: 0; left: 100%; width: 100vh; width: 100dvh; height: 100vw; transform-origin: 0 0; transform: rotate(90deg); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } .phone { animation: none; transform: rotate(90deg); } }
body.rm .phone { animation: none; transform: rotate(90deg); }

/* ---- J10: money in the HUD, the shop ---- */
.shopsheet { display: flex; flex-direction: column; overflow: hidden; padding-bottom: calc(var(--u) * 4); }
.shopsheet .hd { margin-bottom: calc(var(--u) * 3); flex: none; }
#shopKeeper { display: flex; align-items: center; gap: calc(var(--u) * 6); flex: none; font-size: var(--t-small); line-height: 1.25; margin-bottom: calc(var(--u) * 2); }
#shopKeeper p { margin: 0; display: flex; flex-direction: column; text-align: left; }
#shopKeeper b { font-weight: 400; color: #ffd987; }
.folkface { width: calc(var(--u) * 18); height: calc(var(--u) * 24); image-rendering: pixelated; flex: none; }
#shopPurse { margin: 0 0 calc(var(--u) * 3); flex: none; color: #ffd987; opacity: 1; }
#shopTabs { flex: none; margin-bottom: calc(var(--u) * 3); }
#shopList { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: calc(var(--u) * 2) calc(var(--u) * 3) calc(var(--u) * 2) calc(var(--u) * 2); scrollbar-width: thin; scrollbar-color: #ffd987 #2b2358; }
.sempty { margin: calc(var(--u) * 8); text-align: center; }
.srow { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 2) calc(var(--u) * 6); width: 100%; margin: 0 0 calc(var(--u) * 3); padding: calc(var(--u) * 3) calc(var(--u) * 6); min-height: var(--target); text-align: left; font: inherit; font-size: var(--t-body); color: #fdf2dc; text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; background: #3b2f6e; border: 0; box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c, inset 0 0 0 calc(var(--u) * 1) #6b5aa8; cursor: pointer; }
.srow:hover { filter: brightness(1.12); }
.srow:focus-visible { outline: max(2px, calc(var(--u) * 1.5)) solid #ffd987; outline-offset: calc(var(--u) * 1); }
.srow canvas.ic { width: calc(var(--u) * 16); height: calc(var(--u) * 16); flex: none; }
.srow .sact canvas.ic.s { width: calc(var(--u) * 10); height: calc(var(--u) * 10); }
.sfish { width: calc(var(--u) * 30); height: calc(var(--u) * 18); image-rendering: pixelated; flex: none; }
.sbody2 { flex: 1 1 40%; min-width: 0; display: flex; flex-direction: column; }
.sname { color: #ffd987; overflow-wrap: anywhere; }
.sline { font-size: var(--t-small); opacity: .92; overflow-wrap: anywhere; }
.sact { flex: 0 1 auto; display: inline-flex; align-items: center; gap: calc(var(--u) * 3); font-size: var(--t-small); text-align: right; margin-left: auto; }
.srow[aria-disabled="true"] { background: #2b2358; cursor: default; }
.srow.s-poor .sact, .srow.s-locked .sact { opacity: .85; }
.srow.s-ok { box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c, inset 0 0 0 calc(var(--u) * 1.5) #ffd987; }
#shopBulk { flex: none; display: flex; gap: calc(var(--u) * 6); flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: calc(var(--u) * 3); }
#shopBulk .btn { padding-top: calc(var(--u) * 2); padding-bottom: calc(var(--u) * 2); }
#shopConfirm { flex: none; margin-top: calc(var(--u) * 3); }
#shopConfirm .sq { margin: 0 0 calc(var(--u) * 3); text-align: center; }
#shopConfirm .srow2 { display: flex; gap: calc(var(--u) * 6); justify-content: center; flex-wrap: wrap; }
.shopsheet .closeb { z-index: 2; }
html[data-fs="1.5"] .folkface, html[data-fs="1.25"] .folkface { display: none; }
@media (max-height: 420px) { html[data-fs="1.25"] #shopKeeper, html[data-fs="1.5"] #shopKeeper { display: none; } } /* a short screen with big text: the list gets the room, the shopkeeper's greeting waits for a taller one */
#shopMsg { margin: 0 0 calc(var(--u) * 3); flex: none; color: #fdf2dc; min-height: 0; }
#shopMsg:empty { display: none; }

/* ---- J11: the fight, the condition line, the Atelier, the board ---- */
#fight { position: absolute; right: calc(var(--u) * 5); top: max(64px, calc(var(--u) * 30)); bottom: auto; max-height: calc(100% - max(64px, calc(var(--u) * 30)) - 10px); overflow-y: auto; overflow-x: hidden; width: calc(var(--u) * 150); max-width: 52vw; font-size: var(--t-body); color: #fdf2dc; text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 #130f2c; z-index: 2; padding: calc(var(--u) * 4) calc(var(--u) * 6); }
#fight[hidden] { display: none; }
#fight p { margin: 0; }
#fightTitle { color: #ffd987; font-size: var(--t-msg); margin-bottom: calc(var(--u) * 3) !important; }
.fight-row { display: flex; gap: calc(var(--u) * 7); align-items: stretch; }
#fightBar { position: relative; flex: none; width: calc(var(--u) * 22); height: calc(var(--u) * 100); background: #130f2c; box-shadow: 0 0 0 calc(var(--u) * 1.5) #fdf2dc, inset 0 0 0 calc(var(--u) * 1) #3b2f6e; background-image: repeating-linear-gradient(to top, transparent 0 calc(var(--u) * 9), #3b2f6e calc(var(--u) * 9) calc(var(--u) * 10)); }
#fightBand { position: absolute; left: calc(var(--u) * 2); right: calc(var(--u) * 2); background: rgba(255, 217, 135, .38); transition: none; }
#fightBand .bk { position: absolute; left: 0; width: 100%; height: calc(var(--u) * 5); border: calc(var(--u) * 2) solid #ffd987; box-sizing: border-box; }
#fightBand .bt { top: 0; border-bottom: 0; }
#fightBand .bb { bottom: 0; border-top: 0; }
#fightMark { position: absolute; left: 0; width: 100%; height: 0; }
#fightMark b { position: absolute; left: calc(var(--u) * -5); top: calc(var(--u) * -5); width: calc(var(--u) * 32); height: calc(var(--u) * 10); background: linear-gradient(to right, #fdf2dc 0 calc(var(--u) * 5), transparent calc(var(--u) * 5)); border: calc(var(--u) * 1.5) solid #fdf2dc; box-sizing: border-box; background-color: transparent; }
#fightMark b::after { content: ""; position: absolute; right: calc(var(--u) * -3.5); top: calc(var(--u) * -1.5); width: calc(var(--u) * 7); height: calc(var(--u) * 7); background: #fdf2dc; transform: rotate(45deg) scale(.9); }
#fight[data-cue="in"] #fightMark b { background-color: #ffd987; border-color: #ffd987; }
#fight[data-cue="in"] #fightMark b::after { background: #ffd987; }
.fight-side { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 3); }
#fightCue { font-size: var(--t-msg); color: #ffd987; min-height: 1.2em; overflow-wrap: anywhere; line-height: 1.1; }
#fight[data-cue="high"] #fightCue::before { content: "▲ "; }
#fight[data-cue="low"] #fightCue::before { content: "▼ "; }
#fight[data-cue="in"] #fightCue::before { content: "◆ "; }
#fightProg { height: calc(var(--u) * 7); background: #130f2c; box-shadow: 0 0 0 calc(var(--u) * 1.5) #fdf2dc; }
#fightProg i { display: block; height: 100%; width: 0; background: #ffd987; }
#fightPct { font-size: var(--t-small); }
#fightHelp { font-size: var(--t-small); opacity: .9; line-height: 1.25; }
#fightHold { width: 100%; margin-top: calc(var(--u) * 4); min-height: max(var(--target), calc(var(--u) * 26)); touch-action: none; user-select: none; -webkit-user-select: none; }
#fightHold.down { filter: brightness(1.2); transform: translateY(calc(var(--u) * 1)); }
.fight-acts { display: flex; gap: calc(var(--u) * 4); margin-top: calc(var(--u) * 3); flex-wrap: wrap; }
.fight-acts .btn { flex: 1 1 auto; min-width: 0; padding-left: calc(var(--u) * 5) !important; padding-right: calc(var(--u) * 5) !important; font-size: var(--t-small) !important; }
@media (max-height: 430px) {
  #fightBar { height: calc(var(--u) * 62); }
  #fightHelp, #fightTitle { display: none; }
  #fight { width: calc(var(--u) * 196); max-width: 62vw; padding: calc(var(--u) * 3) calc(var(--u) * 5); top: max(58px, calc(var(--u) * 28)); }
  #fightHold { margin-top: calc(var(--u) * 2); }
  .fight-acts { margin-top: calc(var(--u) * 2); gap: calc(var(--u) * 3); }
}
html[data-fs="1.25"] #fightHelp, html[data-fs="1.5"] #fightHelp { display: none; }
html[data-fs="1.5"] #fightBar { height: calc(var(--u) * 66); }
.srow.mrow { cursor: default; background-color: #2b2358; }
.srow.mrow.s-ok { box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c; }
.qh { margin: calc(var(--u) * 4) 0 calc(var(--u) * 2); font-size: var(--t-body); font-weight: 400; color: #ffd987; }
.meter { display: block; height: calc(var(--u) * 5); width: 100%; max-width: calc(var(--u) * 120); background: #130f2c; box-shadow: 0 0 0 calc(var(--u) * 1) #fdf2dc; margin-top: calc(var(--u) * 1); }
.meter i { display: block; height: 100%; background: repeating-linear-gradient(to right, #ffd987 0 calc(var(--u) * 3), #c9a45a calc(var(--u) * 3) calc(var(--u) * 4)); }
.keeper { display: flex; align-items: center; gap: calc(var(--u) * 6); flex: none; font-size: var(--t-small); line-height: 1.25; margin-bottom: calc(var(--u) * 2); }
.keeper p { margin: 0; display: flex; flex-direction: column; text-align: left; }
.keeper b { font-weight: 400; color: #ffd987; }
#repPurse, #qNote { margin: 0 0 calc(var(--u) * 3); flex: none; color: #ffd987; opacity: 1; }
#repMsg, #qMsg { margin: 0 0 calc(var(--u) * 3); flex: none; min-height: 0; }
#repMsg:empty, #qMsg:empty { display: none; }
#repList, #qList { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: calc(var(--u) * 2) calc(var(--u) * 3) calc(var(--u) * 2) calc(var(--u) * 2); scrollbar-width: thin; scrollbar-color: #ffd987 #2b2358; }
@media (max-height: 420px) { html[data-fs="1.25"] #repKeeper, html[data-fs="1.5"] #repKeeper { display: none; } }

/* ---- J12-A: the story: the dialogue box, the journal's dream and letters pages, the glow of a dream fish, the floating line of Le Dormeur ---- */
#s-dialogue .dim { display: none; }
#dlgBox { position: absolute; left: 50%; bottom: max(8px, calc(var(--u) * 8)); transform: translateX(-50%); width: min(96vw, calc(var(--u) * 400)); max-height: calc(100% - 16px); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: calc(var(--u) * 3); outline: none; scrollbar-width: thin; scrollbar-color: #ffd987 #2b2358; }
#dlgHead { display: flex; align-items: center; gap: calc(var(--u) * 6); min-height: calc(var(--u) * 4); }
#dlgHead .folkface { width: calc(var(--u) * 15); height: calc(var(--u) * 20); }
#dlgHead canvas.ic { width: calc(var(--u) * 14); height: calc(var(--u) * 14); }
#dlgName { font-weight: 400; color: #ffd987; font-size: var(--t-msg); }
#dlgName[hidden] { display: none; }
#dlgText { margin: 0; font-size: var(--t-msg); line-height: 1.25; min-height: 2.5em; overflow-wrap: anywhere; }
#dlgRest { visibility: hidden; }
#dlgChoices { display: flex; flex-direction: column; gap: calc(var(--u) * 2); }
#dlgChoices[hidden] { display: none; }
.dlg-choice { text-align: left; width: 100%; font-size: var(--t-body) !important; }
.dlg-choice::before { content: "▸ "; }
#dlgCtl { display: flex; gap: calc(var(--u) * 4); justify-content: flex-end; flex-wrap: wrap; }
#dlgCtl .btn { font-size: var(--t-small) !important; padding-top: calc(var(--u) * 1.5) !important; padding-bottom: calc(var(--u) * 1.5) !important; }
#dlgCtl .btn[hidden] { display: none; }
#dlgNext { font-size: var(--t-body) !important; }
#dlgHelp { margin: 0; text-align: right; font-size: var(--t-small); opacity: .8; }
@media (max-height: 430px) { #dlgHelp { display: none; } }
html[data-fs="1.5"] #dlgHelp { display: none; }
#dlgHistory { position: absolute; left: 50%; top: max(8px, calc(var(--u) * 8)); transform: translateX(-50%); width: min(96vw, calc(var(--u) * 360)); max-height: 40%; min-height: calc(var(--u) * 40); display: flex; flex-direction: column; gap: calc(var(--u) * 3); }
#dlgHistory[hidden] { display: none; }
#dlgHistory h3 { margin: 0; font-weight: 400; color: #ffd987; font-size: var(--t-body); }
#dlgHistList { overflow-y: auto; flex: 1 1 auto; min-height: 0; font-size: var(--t-small); line-height: 1.3; scrollbar-width: thin; scrollbar-color: #ffd987 #2b2358; }
.dlg-h { margin: 0 0 calc(var(--u) * 2); }
.dlg-h b { font-weight: 400; color: #ffd987; }
#dlgHistory .btn { align-self: flex-end; font-size: var(--t-small) !important; }
#app[data-screen="dialogue"] #saveNote { display: none; }

/* journal pages (fish | dreams | letters) */
#s-book:not([data-page="dreams"]) #dreamGrid, #s-book:not([data-page="dreams"]) #dreamTitles, #s-book:not([data-page="dreams"]) #dreamPage, #s-book:not([data-page="dreams"]) #dreamPips,
#s-book:not([data-page="letters"]) #letterList, #s-book:not([data-page="letters"]) #letterPage, #s-book:not([data-page="letters"]) #letterCount,
#s-book:not([data-page="fish"]) #grid, #s-book:not([data-page="fish"]) #page, #s-book:not([data-page="fish"]) #pips { display: none; }
#dreamPage .pg-head { display: flex; align-items: center; gap: calc(var(--u) * 6); margin-bottom: calc(var(--u) * 3); }
#dreamPage canvas { width: calc(var(--u) * 40 * 2); height: calc(var(--u) * 24 * 2); flex: none; image-rendering: pixelated; }
#dreamPage .pg-title { flex: 1; min-width: 0; }
#dreamPage h3 { margin: 0 0 calc(var(--u) * 1); font-size: max(calc(16px * var(--fs)), calc(var(--u) * 12 * var(--fs))); color: #ffd987; text-align: left; font-weight: 400; overflow-wrap: anywhere; line-height: 1.15; }
#dreamPage .d { text-align: left; margin: 0 0 calc(var(--u) * 3); }
#dreamPage .row { display: flex; justify-content: space-between; gap: calc(var(--u) * 4); border-top: calc(var(--u) * 1) dotted #6b5aa8; padding: calc(var(--u) * 1.6) 0; align-items: center; }
#dreamPage .row.hours { justify-content: flex-start; align-items: flex-start; gap: calc(var(--u) * 5); }
#dreamPage .row.hours canvas.ic { width: calc(var(--u) * 11); height: calc(var(--u) * 11); }
#dreamPage .glowrow { color: #ffd987; }
#dreamPage canvas.dreamglow { filter: drop-shadow(0 0 calc(var(--u) * 3) #ffd987aa); }
body.rm #dreamPage canvas.dreamglow { filter: none; }
.slot.dreamslot { box-shadow: 0 0 calc(var(--u) * 4) #ffd98766; }
/* J12-B: the titles of the lake (finale, gift), under the grid of dream fish */
.lrow.sel { box-shadow: 0 0 0 calc(var(--u) * 1.5) #130f2c, inset 0 0 0 calc(var(--u) * 1.5) #ffd987; }
.lnew { color: #ffd987; }
#bookTabs button { font-size: var(--t-small); padding-left: calc(var(--u) * 5); padding-right: calc(var(--u) * 5); }
/* the paper of Grandma's letter: painted by CSS (a warm sheet, ruled lines, a pixel quill) */
.paper { background-color: #f3e6c4; color: #3a2a30; text-shadow: none; padding: calc(var(--u) * 5) calc(var(--u) * 7); border: calc(var(--u) * 2) solid #b8a070; box-shadow: calc(var(--u) * 2) calc(var(--u) * 2) 0 #130f2c; text-align: left; }
.paper-head { display: flex; align-items: center; gap: calc(var(--u) * 4); margin-bottom: calc(var(--u) * 3); }
.paper-head h3 { margin: 0; font-size: var(--t-body); font-weight: 400; color: #6a3a2a; overflow-wrap: anywhere; line-height: 1.15; }
.paper-head canvas.ic { width: calc(var(--u) * 12); height: calc(var(--u) * 12); }
.paper-body p { margin: 0 0 calc(var(--u) * 3); line-height: 1.35; font-size: var(--t-small); }
.srow .verse { white-space: pre-line; color: #fdf2dc; }
.storyrow .sline { display: block; }
/* a dream fish on the catch card: a soft light AND a line of text (never the light alone) */
#card.dream { box-shadow: 0 0 calc(var(--px) * 12) #ffd987aa; }
body.rm #card.dream { box-shadow: none; }
#cardInfo .glow { color: #ffd987; flex-basis: 100%; }
.tag.dormeur { color: #ffd987; background: #130f2ccc; border-color: #ffd98799; white-space: normal; max-width: 40vw; text-align: center; font-size: .9em; }
.tag.dormeur::before { content: "✦ "; }

/* =====================================================================================================================================================================
   UI redesign (brief 27): one coherent pixel-art system for the whole game.
   Tokens (the palette is repeated in src/shell/ui/tokens.js, which a unit test compares with the values below and measures for contrast), a spacing grid in --u (1/480 of the
   16:9 box, with pixel floors), a type scale (--t-small / --t-body / --t-msg / --t-h2 on Pixelify Sans), ONE frame family (.panel = the 9-slice frame; .cap = the same frame, small),
   buttons (.btn, .btn.alt, .seg button, .mi, .srow) with idle / hover / focus / active / disabled / selected states where "selected" is always a SHAPE (a filled square marker)
   and not only a colour, tabs, sticky group headings, tooltips, toasts, "nouveau" badges, progress bars with a number. Motion is a gentle press and a four-step fade: all of it is
   off in reduced motion (body.rm, or the system preference). Everything is measured in --u so it follows the three text sizes with no overflow.
   ===================================================================================================================================================================== */
#app {
  --c-text: #fdf2dc; --c-dim: #d6ccef; --c-ink: #130f2c; --c-panel: #2b2358; --c-raised: #3b2f6e; --c-line: #8f7fd0; --c-accent: #ffd987; --c-on-accent: #2a1c30;
  --c-capsule: #1b1840; --c-paper: #f3e6c4; --c-on-paper: #3a2a30;
  --sl: max(10px, env(safe-area-inset-left)); --sr: max(10px, env(safe-area-inset-right)); --st: max(8px, env(safe-area-inset-top)); --sb: max(10px, env(safe-area-inset-bottom));
  --row: max(var(--target), calc(var(--t-body) * 2.1)); /* height of the top row (capsules, Menu button) */
  --bar: calc(var(--st) + var(--row) + 8px); /* where the top row ends: panels on the right start under it */
  --cw: max(96px, calc(var(--u) * 58)); --ch: max(72px, calc(var(--u) * 40)); --tb: max(48px, calc(var(--u) * 28)); /* the thumb cluster: big button, turn buttons */
  touch-action: manipulation; overscroll-behavior: none;
}
#app[data-phase="night"] { --c-capsule: #100c26; }
:focus-visible { outline: max(3px, calc(var(--u) * 1.6)) solid var(--c-accent); outline-offset: max(2px, calc(var(--u) * 1.2)); }
body.rm *, body.rm *::before, body.rm *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- frames, buttons, states ---- */
.cap { display: inline-flex; align-items: center; gap: calc(var(--u) * 4); min-height: var(--row); margin: 0; color: var(--c-text); font: inherit; text-shadow: none; white-space: nowrap; border-style: solid; border-width: calc(var(--u) * 3); border-image: var(--bi-panel) 4 fill / calc(var(--u) * 3) stretch; image-rendering: pixelated; padding: 0 calc(var(--u) * 4); }
.cap canvas.ic { width: calc(var(--t-body) * 1.15); height: calc(var(--t-body) * 1.15); }
button.cap { cursor: pointer; background: none; }
.cap:hover, .btn:hover, .mi:hover, .seg button:hover, .srow:hover { filter: brightness(1.12); }
.btn:active, .mi:active, .seg button:active, .srow:active, button.cap:active { transform: translateY(calc(var(--u) * 1)); }
.btn.sm { min-height: var(--target); font-size: var(--t-small) !important; padding: calc(var(--u) * 1.5) calc(var(--u) * 6) !important; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .6; }
.seg button { position: relative; }
.seg button::before { content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .45em; vertical-align: -0.02em; box-shadow: inset 0 0 0 calc(var(--u) * 1.2) currentColor; }
.seg button[aria-pressed="true"]::before, .seg button[aria-selected="true"]::before { background: currentColor; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--c-accent); color: var(--c-on-accent); }
.note { color: var(--c-dim); opacity: 1; }
.note.warn, #saveState { color: var(--c-accent); }
.new, .isnew { color: var(--c-on-accent); background: var(--c-accent); padding: 0 calc(var(--u) * 3); }
kbd { font: inherit; font-size: var(--t-small); color: var(--c-dim); border: calc(var(--u) * 1) solid var(--c-line); padding: 0 calc(var(--u) * 3); min-width: 1.6em; text-align: center; }

/* ---- the HUD (in play) ---- */
#hud { pointer-events: none; font-size: var(--t-body); line-height: 1.2; text-shadow: none; }
#hud > *, #topL > *, #topR > * { pointer-events: auto; }
#topL { position: absolute; left: var(--sl); top: var(--st); display: flex; flex-direction: column; align-items: flex-start; gap: calc(var(--u) * 3); max-width: min(46vw, calc(var(--u) * 190)); pointer-events: none; }
#topR { position: absolute; right: var(--sr); top: var(--st); display: flex; flex-direction: column; align-items: flex-end; gap: calc(var(--u) * 3); max-width: min(50vw, calc(var(--u) * 230)); pointer-events: none; }
#topR .rowR { display: flex; align-items: center; gap: calc(var(--u) * 4); pointer-events: none; }
#topR .rowR > * { pointer-events: auto; }
#clock, #purse { cursor: help; }
#clockText, #pearlNum, #bucketNum { font-variant-numeric: tabular-nums; }
#purse canvas.ic + span { margin-right: calc(var(--u) * 3); }
#icPhase { color: var(--c-accent); }
.menubtn { display: inline-flex; align-items: center; gap: calc(var(--u) * 4); min-height: var(--row); padding: 0 calc(var(--u) * 7) !important; font-size: var(--t-body) !important; border-width: calc(var(--u) * 3) !important; }
.menubtn canvas.ic.s { width: calc(var(--t-body) * 1.1); height: calc(var(--t-body) * 1.1); }
.trk { max-width: min(44vw, calc(var(--u) * 180)); white-space: normal; text-align: left; font-size: var(--t-small); min-height: max(var(--target), calc(var(--t-small) * 2.2)); line-height: 1.2; }
#orderShort { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
#trkChev { flex: none; color: var(--c-accent); }
#app[data-trk="fold"] #orderShort { display: none; }
.cap.warn { font-size: var(--t-small); color: var(--c-accent); white-space: normal; }
#condText { overflow-wrap: anywhere; }
#zoneText { position: fixed; left: 50%; top: var(--st); transform: translateX(-50%); margin: 0; max-width: 34vw; text-align: center; font-size: var(--t-msg); color: var(--c-accent); background: var(--c-capsule); border: calc(var(--u) * 1.5) solid var(--c-line); box-shadow: 0 calc(var(--u) * 1.5) 0 var(--c-ink); padding: calc(var(--u) * 2) calc(var(--u) * 7); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .5s steps(5), visibility 0s .5s; overflow-wrap: anywhere; }
#zoneText.on { opacity: 1; visibility: visible; transition: opacity .35s steps(4), visibility 0s; }
#zoneText:empty { display: none; }
#tip { position: absolute; z-index: 9; max-width: min(60vw, calc(var(--u) * 200)); padding: calc(var(--u) * 2) calc(var(--u) * 5); background: var(--c-capsule); color: var(--c-text); border: calc(var(--u) * 1.5) solid var(--c-line); box-shadow: 0 calc(var(--u) * 1.5) 0 var(--c-ink); font-size: var(--t-small); pointer-events: none; overflow-wrap: anywhere; }
/* ONE message slot at the bottom: a toast or the context hint, never both (hud.js decides; both sit on the same grid cell) */
#msg { position: absolute; left: var(--sl); right: var(--sr); bottom: var(--sb); display: grid; justify-items: center; pointer-events: none; }
#msg > p { grid-area: 1 / 1; margin: 0; max-width: min(100%, calc(var(--u) * 330)); text-align: center; transition: opacity .3s steps(4); }
#msg > p.off { opacity: 0; visibility: hidden; transition: none; }
#hint { padding: calc(var(--u) * 2.5) calc(var(--u) * 7); font-size: var(--t-body); color: var(--c-text); background: var(--c-capsule); border: calc(var(--u) * 1.5) solid var(--c-line); box-shadow: 0 calc(var(--u) * 1.5) 0 var(--c-ink); border-image: none; }
#toast { color: var(--c-text); font-size: var(--t-msg); }
#app[data-touch] #msg { right: calc(var(--sr) + var(--cw) + 2 * var(--tb) + 34px); }
#app[data-fight] #hint { display: none !important; }
#app[data-calm="1"] #tracker, #app[data-calm="1"] #condCap, #app[data-calm="1"] #zoneText, #app[data-calm="1"] #coach { display: none !important; }
/* the tags near people and doors: a flat chip with a mark, like the hint */
.tag { background: var(--c-capsule); border: calc(var(--u) * 1.2) solid var(--c-line); font-size: var(--t-small); color: var(--c-text); }
#tags { z-index: 1; }

/* ---- the menu ---- */
#menuWrap { position: absolute; inset: 0; z-index: 7; }
#menuBackdrop { position: absolute; inset: 0; background: #130f2c88; }
#menu { position: absolute; right: var(--sr); top: calc(var(--bar) + 2px); width: min(calc(var(--u) * 176), calc(100% - var(--sl) - var(--sr))); max-height: calc(100% - var(--bar) - var(--sb)); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: calc(var(--u) * 2); font-size: var(--t-body); text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 var(--c-ink); animation: menuIn .18s steps(4) 1; scrollbar-width: thin; scrollbar-color: var(--c-accent) var(--c-panel); }
@keyframes menuIn { 0% { transform: translateY(calc(var(--u) * -6)); opacity: 0; } 100% { transform: none; opacity: 1; } }
#menu h2 { margin: 0 0 calc(var(--u) * 2); font-size: var(--t-h2); font-weight: 400; color: var(--c-accent); }
.mi { display: flex; align-items: center; gap: calc(var(--u) * 6); width: 100%; min-height: var(--row); padding: calc(var(--u) * 2) calc(var(--u) * 6); text-align: left; font: inherit; color: var(--c-text); background: var(--c-raised); border: 0; box-shadow: 0 0 0 calc(var(--u) * 1.5) var(--c-ink), inset 0 0 0 calc(var(--u) * 1) var(--c-line); cursor: pointer; }
.mi canvas.ic { width: calc(var(--t-body) * 1.2); height: calc(var(--t-body) * 1.2); }
.mi-t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.mi-n { flex: none; font-size: var(--t-small); color: var(--c-dim); }
.mi-n:empty { display: none; }
.mi-n.isnew { color: var(--c-on-accent); }
.mi:focus-visible { background: #4a3c86; }
.mi:focus-visible::before { content: "▸"; color: var(--c-accent); margin-right: calc(var(--u) * -3); }
.mi-close { align-self: stretch; margin-top: calc(var(--u) * 2); }

/* ---- the first-time coach: small, dismissible, never blocking ---- */
#coach { position: relative; align-self: flex-end; width: min(calc(var(--u) * 150), 100%); display: flex; flex-direction: column; gap: calc(var(--u) * 2); font-size: var(--t-small); line-height: 1.3; color: var(--c-text); text-shadow: none; animation: menuIn .25s steps(5) 1; }
#coach p { margin: 0; }
#coachTitle { display: flex; align-items: center; gap: calc(var(--u) * 3); color: var(--c-accent); }
#coachOk { align-self: flex-end; }
#coach[hidden] { display: none; }
#app[data-fight] #coach { display: none; }

/* ---- the touch cluster: thumb-friendly, bottom right; menu top right; safe areas ---- */
#fishBtn, #ctxBtn { position: absolute; right: var(--sr); touch-action: none; }
#fishBtn { bottom: var(--sb); width: var(--cw); height: var(--ch); font-size: var(--t-msg) !important; padding: 0 !important; border-width: calc(var(--u) * 4) !important; }
#ctxBtn { bottom: calc(var(--sb) + var(--ch) + 10px); width: var(--cw); min-height: max(52px, calc(var(--u) * 30)); font-size: var(--t-small) !important; padding: 0 calc(var(--u) * 3) !important; line-height: 1.15; }
#ctxBtn:empty, #app:not([data-touch]) #ctxBtn { display: none; }
#fishBtn:active, #ctxBtn:active { transform: translateY(calc(var(--u) * 1.5)); }
#turnL, #turnR { position: absolute; bottom: var(--sb); width: var(--tb); height: var(--tb); min-width: 0; padding: 0; font-size: var(--t-msg); text-align: center; }
#turnR { right: calc(var(--sr) + var(--cw) + 10px); }
#turnL { right: calc(var(--sr) + var(--cw) + 10px + var(--tb) + 8px); }
#app[data-fight] #fishBtn, #app[data-fight] #ctxBtn, #app[data-fight] #turnL, #app[data-fight] #turnR, #app[data-fight] #stick { display: none !important; }
#stick { z-index: 1; }

/* ---- screens: shared pieces ---- */
.sheet { text-shadow: calc(var(--u) * 1) calc(var(--u) * 1) 0 var(--c-ink); }
.hd { color: var(--c-accent); }
.srow { background: var(--c-raised); color: var(--c-text); }
.srow:focus-visible { outline: max(3px, calc(var(--u) * 1.6)) solid var(--c-accent); outline-offset: calc(var(--u) * -1); }
.srow[aria-disabled="true"] { background: var(--c-panel); }
.sline { color: var(--c-dim); opacity: 1; }
.sname { color: var(--c-accent); }
.slot small { color: var(--c-text); opacity: 1; }
.meter { box-shadow: 0 0 0 calc(var(--u) * 1) var(--c-text); }

/* settings: five groups with sticky headings, a live preview of the text size */
.grp { margin: 0 0 calc(var(--u) * 5); }
.gh { position: sticky; top: calc(var(--u) * -3); z-index: 1; margin: 0 0 calc(var(--u) * 2); padding: calc(var(--u) * 2) 0 calc(var(--u) * 1.5); background: var(--c-panel); color: var(--c-accent); font-size: var(--t-body); font-weight: 400; border-bottom: calc(var(--u) * 1) dotted var(--c-line); }
.preview { margin: calc(var(--u) * 2) 0 0; padding: calc(var(--u) * 3) calc(var(--u) * 5); background: var(--c-raised); box-shadow: inset 0 0 0 calc(var(--u) * 1) var(--c-line); font-size: var(--t-body); line-height: 1.25; overflow-wrap: anywhere; }
.set .note { margin: 0; }

/* the bag */
#bagBody { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--u) * 170), 1fr)); gap: 0 calc(var(--u) * 6); align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 calc(var(--u) * 3) calc(var(--u) * 2) calc(var(--u) * 2); scrollbar-width: thin; scrollbar-color: var(--c-accent) var(--c-panel); }
.bsec { margin: 0 0 calc(var(--u) * 3); }
.bcol { min-width: 0; }
.brow { display: flex; align-items: center; flex-wrap: wrap; gap: calc(var(--u) * 2) calc(var(--u) * 6); margin: 0 0 calc(var(--u) * 2); padding: calc(var(--u) * 2.5) calc(var(--u) * 6); min-height: var(--target); background: var(--c-raised); box-shadow: 0 0 0 calc(var(--u) * 1.5) var(--c-ink), inset 0 0 0 calc(var(--u) * 1) var(--c-line); }
.brow canvas.ic { flex: none; }
.blabel { color: var(--c-dim); min-width: calc(var(--u) * 62); }
.bval { flex: 1 1 30%; min-width: 0; overflow-wrap: anywhere; color: var(--c-text); }
.bwear .meter { flex: 1 1 100%; max-width: none; }
#s-bag .note { margin-top: calc(var(--u) * 3); }

/* the shop: sort and quick actions with their value */
.sortb { flex: none; align-self: flex-start; margin-bottom: calc(var(--u) * 2); }
#shopPurse { color: var(--c-accent); }

/* the catch card */
#card h3 { color: var(--c-accent); }
#cardInfo span { white-space: nowrap; }

#hud .panel { border-width: calc(var(--u) * 3); border-image: var(--bi-panel) 4 fill / calc(var(--u) * 3) stretch; padding: calc(var(--u) * 3) calc(var(--u) * 6); }
#hud #hint.panel { border-width: calc(var(--u) * 1.5); border-image: none; padding: calc(var(--u) * 2.5) calc(var(--u) * 7); }

#shopBulk .sortb { margin: 0 auto 0 0; align-self: center; }
#bagBody .note { grid-column: 1 / -1; }

/* ---- the journal, one flex layout (brief 27): header / [ grid or list | detail panel ] / [ orders button | the three pages ] ---- */
.bksheet { display: flex; flex-direction: column; overflow: hidden; padding-bottom: calc(var(--u) * 4); }
.bksheet .hd { flex: none; margin-bottom: calc(var(--u) * 4); }
.bk-main { flex: 1 1 auto; min-height: 0; display: flex; gap: calc(var(--u) * 6); }
.bk-left { flex: 0 1 54%; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: calc(var(--u) * 2); scrollbar-width: thin; scrollbar-color: var(--c-accent) var(--c-panel); }
.bk-right { flex: 1 1 46%; min-width: 0; min-height: 0; display: flex; }
.bk-right > .panel { flex: 1 1 auto; position: static; width: auto; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; font-size: var(--t-small); line-height: 1.3; padding: calc(var(--u) * 4) calc(var(--u) * 6); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 33), 1fr)); gap: calc(var(--u) * 3); width: auto; }
#letterList { width: auto; }
#dreamTitles { position: static; max-width: none; margin-top: calc(var(--u) * 4); }
#letterPage { width: auto; }
.bk-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 4); flex-wrap: wrap; margin-top: calc(var(--u) * 4); }
.bk-foot .questb { position: static; }
#bookTabs { position: static; flex-wrap: nowrap; }
#bookTabs button { font-size: var(--t-small); padding-left: calc(var(--u) * 5); padding-right: calc(var(--u) * 5); }
.slot.isnew::after { content: "✦"; position: absolute; left: calc(var(--u) * 3); top: 0; color: var(--c-accent); font-size: var(--t-small); line-height: 1; }

/* ---- the fight, aligned with the system: under the top row, a big hold zone at the bottom right on touch, the auto switch always labelled with its state ---- */
#fight { right: var(--sr); top: calc(var(--bar) + 4px); max-height: calc(100% - var(--bar) - var(--sb) - 4px); border-width: calc(var(--u) * 3); border-image: var(--bi-panel) 4 fill / calc(var(--u) * 3) stretch; }
.fight-acts .btn[aria-pressed]::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-right: .4em; box-shadow: inset 0 0 0 calc(var(--u) * 1.2) currentColor; }
.fight-acts .btn[aria-pressed="true"]::before { background: currentColor; }
#fightHold { font-size: var(--t-msg) !important; }
#app[data-touch] #fightHold { position: fixed; right: var(--sr); bottom: var(--sb); width: calc(var(--cw) * 1.7); height: calc(var(--ch) * 1.3); margin: 0; z-index: 3; }
#app[data-touch] #fight { padding-bottom: calc(var(--u) * 3); }
/* the dialogue box and the catch card keep their place; the card sits above the message slot */
#card { max-height: calc(100% - 2 * var(--st) - var(--sb)); }
@media (max-height: 430px) { #dlgBox { max-height: calc(100% - var(--st) - var(--sb)); } }

#hud > #tags, #hud > #stick, #hud > #debug, #hud > #topL, #hud > #topR { pointer-events: none; }
#topL > *, #topR .rowR > *, #topR > #coach { pointer-events: auto; }

/* ---- brief 33 (accessibility and phone): the selected journal slot is a SHAPE too (an inner accent frame), never the brightness alone ---- */
.slot.sel { box-shadow: inset 0 0 0 max(2px, calc(var(--u) * 1.5)) var(--c-accent); }
.slot.dreamslot.sel { box-shadow: inset 0 0 0 max(2px, calc(var(--u) * 1.5)) var(--c-accent), 0 0 calc(var(--u) * 4) #ffd98766; }
/* a menu entry with a badge ("✦ nouveau") keeps its words whole on a small screen with big text: the label never shrinks below its longest word, the badge
   wraps on two lines instead (667 x 375 at the largest size squeezed "Carnet" into 9 px); an entry never shrinks in the scrolling menu */
.mi { flex-shrink: 0; flex-wrap: wrap; row-gap: 0; }
.mi-t { min-width: min-content; overflow-wrap: normal; }
.mi-n { flex: 0 1 auto; min-width: min-content; overflow-wrap: normal; text-align: right; line-height: 1.1; margin-left: auto; }
#menu { width: min(max(calc(var(--u) * 176), 14em), calc(100% - var(--sl) - var(--sr))); }
/* the big "Pêcher" button: its word always fits inside it (1024 x 768 at the largest text size spilled by 3 px) */
#fishBtn { font-size: min(var(--t-msg), calc((var(--cw) - var(--u) * 10) / 3.6)) !important; }
