/* tan game shell: a 1024x576 logical screen, integer-scaled, with a DOM layer for text windows. */
@font-face { font-family: "Press Start 2P"; src: url("../../assets/fonts/pressstart2p/PressStart2P-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "VT323"; src: url("../../assets/fonts/vt323/VT323-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("../../assets/fonts/pixelifysans/PixelifySans[wght].ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "DejaVu Sans Mono"; src: url("../../assets/fonts/dejavusansmono/DejaVuSansMono.ttf") format("truetype"); font-display: swap; }
/* the World Chart's serif (2026-09-26): IBM Plex Serif, Open Font License */
@font-face { font-family: "IBM Plex Serif"; src: url("../../assets/fonts/ibmplexserif/IBMPlexSerif-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../../assets/fonts/ibmplexserif/IBMPlexSerif-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../../assets/fonts/ibmplexserif/IBMPlexSerif-Italic.ttf") format("truetype"); font-style: italic; font-weight: 500; font-display: swap; }

html, body { margin: 0; height: 100%; background: #0c0c14; overflow: hidden; }
#game { position: fixed; inset: 0; display: grid; place-items: center; background: #0c0c14; --s: 1; }
.stage { position: relative; width: calc(1024px * var(--s)); height: calc(576px * var(--s)); overflow: hidden; background: #0c0c14; }
.stage canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.stage canvas.fx { position: absolute; left: 0; top: 0; pointer-events: none; image-rendering: auto; }   /* battle effects, above the UI (2026-09-27) */

/* Everything in .ui is laid out in logical pixels (1024x576) and scaled with the canvas. */
.ui {
  position: absolute; left: 0; top: 0; width: 1024px; height: 576px;
  transform: scale(var(--s)); transform-origin: 0 0; pointer-events: none; overflow: hidden;
  --win-url: none; --win-inset: 16; --font: "Pixelify Sans", sans-serif; --font-size: 26px;
  color: #fff; font-family: var(--font); font-size: var(--font-size); line-height: 1.25;
}
.win {
  position: absolute; box-sizing: border-box; padding: 4px 10px; color: #fff;
  border: 16px solid transparent; border-image-source: var(--win-url); border-image-slice: var(--win-inset) fill;
  border-image-width: 16px; border-image-repeat: stretch; image-rendering: pixelated;
  text-shadow: 2px 2px 0 #000; white-space: pre-wrap; overflow: hidden;
}
.win .title { opacity: .8; font-size: .8em; margin-bottom: 2px; }
.dialog { left: 64px; top: 400px; width: 896px; height: 160px; overflow: visible; }   /* the speaker name sits above the frame */
.dialog .text { height: 100%; overflow: hidden; }
.dialog.opening { top: 184px; height: calc(var(--font-size) * 6.25 + 40px); }   /* the opening story, mid-screen on the dark, five lines a page (2026-09-29) */
.dialog .name { position: absolute; left: 16px; top: -34px; padding: 0 12px; background: #0c0c14; }
/* the World Chart (2026-09-26): a parchment window drawn on its own canvas, no pixel frame */
.win.chart { border: 0; padding: 0; background: #efe1c2; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); }
.win.chart canvas { display: block; }
/* the title screen's choice of hero (2026-09-26) */
.menu.hero-pick .item .icon { width: 32px; height: 48px; object-fit: contain; object-position: top; image-rendering: pixelated; margin-right: 8px; }
.hero-preview { text-align: center; font-size: .8em; }
.hero-preview .art { display: flex; justify-content: center; align-items: flex-end; column-gap: 12px; margin: 4px 0; }
.hero-preview .portrait { width: 112px; height: 112px; }
.hero-preview .sprite { width: 64px; height: 96px; image-rendering: pixelated; }
.hero-preview .name { margin-top: 2px; }
/* the choice of hero (2026-09-28): full screen in two steps; a card per record, a strip of tones */
.hero-preview .hero-card .art { display: flex; justify-content: center; align-items: flex-end; column-gap: 20px; margin: 6px 0; }
.hero-preview .hero-card .portrait { width: 192px; height: 192px; }
.hero-preview .hero-card .sprite { width: 128px; height: 192px; image-rendering: pixelated; }
.hero-preview .hero-card .name { margin-top: 8px; }
.hero-preview .hero-card .sub { margin-top: 4px; }
.hero-preview .hero-card.wide { display: flex; align-items: center; column-gap: 24px; text-align: left; padding: 4px 8px; }
.hero-preview .hero-card.wide .art { flex: 0 0 auto; margin: 0; }
.hero-preview .hero-card.wide .portrait { width: 160px; height: 160px; }
.hero-preview .hero-card.wide .sprite { display: none; }
.hero-preview .hero-card.wide .text { min-width: 0; }
.menu.columns.skin-pick .items { justify-content: center; column-gap: 14px; }   /* above .menu.columns in weight, or its 12 px gap won (reviewed 2026-09-28) */
.menu.skin-pick .item { padding: 30px 0 4px; justify-content: center; }
.menu.skin-pick .item .label { display: none; }
.menu.skin-pick .item .icon { width: 64px; height: 96px; margin: 0; }
.menu.skin-pick .item .cursor { left: 50%; top: 0; margin: 0 0 0 -16px; transform: rotate(90deg); }
/* portraits (2026-09-25): smooth drawings, not pixel art */
.portrait { image-rendering: auto; object-fit: cover; }
.dialog.with-portrait { padding-left: 132px; }
.dialog.with-portrait > .portrait { position: absolute; left: 6px; top: 6px; width: 112px; height: 112px; }
.cursor { position: absolute; width: 32px; height: 32px; image-rendering: pixelated; }
.dialog-cursor { right: 4px; bottom: -4px; }
.menu .item { position: relative; padding-left: 40px; white-space: nowrap; line-height: 1.3; }
.menu .item.disabled { opacity: .45; }
.menu .item .cursor { left: 0; top: 50%; margin-top: -16px; }
.menu.columns .items { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.menu .item { display: flex; align-items: center; }
.menu .item[hidden] { display: none; }            /* display:flex would otherwise show rows scrolled out of view */
.menu .item .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* a very long name shortens; the right-hand text stays whole */
.menu .item .right { margin-left: auto; padding-left: 16px; opacity: .85; font-size: .8em; flex-shrink: 0; }
/* a menu whose right-hand text can be long (the store's "Equip on", 2026-10-06): the name keeps its room, the text shortens */
.menu.split .item .label { flex-shrink: 0; max-width: 55%; }
.menu.split .item .right { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu .item .icon { width: 32px; height: 32px; margin-right: 8px; vertical-align: middle; image-rendering: pixelated; }
.emblem { width: 24px; height: 24px; margin-right: 6px; vertical-align: middle; image-rendering: pixelated; }   /* class emblems (2026-09-24) */
.menu .more { text-align: right; font-size: .7em; opacity: .7; white-space: pre; }
.party.gear { margin-top: 8px; font-size: 20px; }
.party.gear .slot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party.gear .slot.empty { opacity: .45; }
/* the Status panel (reviewed 2026-09-28): with three or four heroes it ran past the bottom of the screen and cut the hint */
.party.gear .cls, .party.gear .nums { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party.gear.many { font-size: 18px; }
.status-panel .hint { font-size: .8em; }
.item-info { left: 264px; top: 412px; width: 728px; height: 148px; font-size: .85em; }   /* four lines; longer text scrolls (2026-09-27) */
.item-info .sub { opacity: .8; }
.battle-skill-info { left: 64px; top: calc(var(--font-size) * 3.75 + 64px); width: 896px; height: auto; }   /* in battle, under the message window */
.gold { text-align: right; }
.banner { left: 262px; top: 36px; width: 500px; text-align: center; opacity: 0; transition: opacity .35s; pointer-events: none; }
.banner.show { opacity: 1; }
/* danger pips under the place name (2026-09-26): 1 well below the party ... 5 deadly */
.banner .danger { display: block; font-size: .6em; opacity: .9; margin-top: 2px; }
.banner .danger .label { margin-right: 8px; }
.banner .pip { display: inline-block; width: 18px; height: 10px; margin: 0 2px; background: #3a3a4a; border: 2px solid #0c0c14; vertical-align: middle; }
.banner .d1 .pip.on { background: #8be08b; }
.banner .d2 .pip.on { background: #b8e08b; }
.banner .d3 .pip.on { background: #f0d060; }
.banner .d4 .pip.on { background: #f0a050; }
.banner .d5 .pip.on { background: #f08a8a; }
.quantity .num { text-align: center; white-space: pre; }
.quantity .sub { text-align: center; opacity: .8; font-size: .85em; }
.text-entry input { display: block; box-sizing: border-box; width: 100%; margin: 8px 0; padding: 2px 8px; pointer-events: auto;
                    font: inherit; color: #fff; text-shadow: inherit; background: #1a1a2a; border: 2px solid #9494a8; border-radius: 0; outline: none; }
.text-entry input::selection { background: #3f86e0; color: #fff; }
.text-entry .hint { opacity: .7; font-size: .7em; white-space: pre; }
.shop-party { left: 696px; top: 32px; width: 296px; font-size: .8em; }
.shop-party .owned { opacity: .8; margin-bottom: 4px; }
.shop-party .row { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 8px; white-space: nowrap; }
/* the name keeps its place; a long change (the King's Signet: six stats) goes to the next line, right-aligned, instead of
   squeezing every name to nothing (Robin's play test, 2026-09-28) */
.shop-party .row span:first-child { flex: 0 1 auto; min-width: 4em; overflow: hidden; text-overflow: ellipsis; }
.shop-party .row span:last-child { margin-left: auto; white-space: normal; text-align: right; }
.shop-party .up { color: #8be08b; }
.shop-party.many { font-size: 18px; }   /* a company of more than six (2026-10-06) */
.shop-party.many .row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the wagon's 24 (2026-10-07): only those who can use the piece, and past fourteen rows a tighter line, so 24 still fit */
.shop-party.tight { font-size: 14px; line-height: 1.2; }
.shop-party .down { color: #f08a8a; }
.shop-party .no { opacity: .45; }
.equip-stats table { border-collapse: collapse; width: 100%; }
.equip-stats td { padding: 0 8px 0 0; white-space: nowrap; }
.equip-stats td.num { text-align: right; }
.equip-stats .up { color: #8be08b; }
.equip-stats .down { color: #f08a8a; }
.equip-stats .note { font-size: .8em; opacity: .8; }

.panel table { border-collapse: collapse; }
.panel td { padding: 0 10px 0 0; vertical-align: middle; white-space: nowrap; }
.bar { position: relative; display: inline-block; width: 128px; height: 24px; vertical-align: middle;
       background: var(--bar-empty) 0 0 / 128px 24px no-repeat; image-rendering: pixelated; }
.bar .fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--bar-img) 0 0 / 128px 24px no-repeat; image-rendering: pixelated; }
.party { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 18px; font-size: 22px; }
.party .hero { line-height: 1.2; }
.party .hero.down { opacity: .5; }
.party .hero .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A hero box (2026-09-26): the head row (portrait, name and level) spans the columns, so does the status row when there
   is one; the HP and MP rows below are label, bar, numbers, and the bar takes what the numbers leave (wide font,
   3-digit HP, 4 heroes). */
.party:not(.gear) .hero { display: grid; grid-template-columns: auto minmax(24px, 1fr) auto; align-items: center; column-gap: 6px; min-width: 0; }
.party:not(.gear) .hero .head { grid-column: 1 / -1; display: flex; align-items: center; column-gap: 8px; min-width: 0; }
.party:not(.gear) .hero .portrait { flex: none; width: 64px; height: 64px; }
.party:not(.gear) .hero .title { min-width: 0; flex: 1; }
.party:not(.gear) .hero .n { min-width: 0; }
.party:not(.gear) .hero .sub { font-size: .7em; opacity: .85; display: flex; align-items: center; column-gap: 6px; white-space: nowrap; overflow: hidden; }
.party .hero .stat { display: contents; font-size: 20px; }
.party .hero .bar { width: 100%; height: 18px; background-size: 100% 100%; container-type: inline-size; }
.party .hero .bar .fill { background-size: 100cqw 100%; }
.party .st { display: inline-flex; align-items: center; column-gap: 2px; }
.party .st b { font-weight: normal; font-size: .85em; }
.sicon { width: 16px; height: 16px; image-rendering: pixelated; }
/* the battle panel (640 x 160, taller when statuses wrap): smaller portraits, and with four in the party (2026-09-24) a smaller font too */
.party.compact .hero .portrait { width: 48px; height: 48px; }
.party.four { font-size: 18px; column-gap: 12px; }
.party.four .hero .stat { font-size: 16px; }
.party.four .hero .portrait { width: 40px; height: 40px; }
.battle-msg { left: 64px; top: 16px; width: 896px; height: calc(var(--font-size) * 3.75 + 40px); }   /* three lines at the dialog font's size: 1.25 line height, 32 px frame, 8 px padding (120 px held 2.5, reviewed 2026-09-28) */

.loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px;
           color: #c4c4d4; font: 20px system-ui, sans-serif; background: #0c0c14; }
.loading-bar { width: 320px; height: 16px; border: 2px solid #6b6b80; }
.loading-fill { width: 0; height: 100%; background: #3f86e0; transition: width .1s; }

/* the bestiary (2026-09-27) */
.panel .bestiary > div { margin: 0 0 12px 0; }
.panel .bestiary-head { display: flex; align-items: center; }
.panel .bestiary-desc { white-space: normal; line-height: 1.4; }

/* floating feedback (2026-09-27 the damage over a hero's box; 2026-09-30 one style for numbers and words on both sides, for
   people watching): every float lives in the .floats layer over the whole screen, placed over a monster's head or a hero's
   box by the battle scene; it rises and fades, the kind picks the colour, and floats that land together on one target are
   stacked by the scene */
.party .hero { position: relative; }
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.flt { position: absolute; transform: translateX(-50%); color: #ffe066; font-size: 28px; font-weight: bold; text-shadow: 2px 2px 0 #000;
       white-space: nowrap; pointer-events: none; animation: dmg-up 0.9s ease-out forwards; }
.flt-hero { font-size: 20px; }   /* over a box, which is narrower than a monster's stage */
.flt-heal, .flt-up { color: #a0ffb0; }
.flt-mp { color: #8fd0ff; }
.flt-bad, .flt-down { color: #ff7070; }
.flt-weak { color: #ffb347; }
.flt-resist { color: #c8d8ff; }
.flt-name { color: #ffffff; }
.flt-note { color: #c8e8ff; }
.flt-gold { color: #f8dc6a; }
/* full for the first half, then the fade (2026-09-30: with ease-out from the start a word was half gone at a quarter second) */
@keyframes dmg-up { 0% { opacity: 1; transform: translate(-50%, 0); } 55% { opacity: 1; transform: translate(-50%, -18px); } 100% { opacity: 0; transform: translate(-50%, -34px); } }

/* the party panel on a TV (2026-09-27): bigger status icons, a flash on the box that was hit */
.party .st img.sicon { width: 24px; height: 24px; image-rendering: pixelated; filter: drop-shadow(1px 1px 0 #000); }
/* the statuses on a row of their own (2026-09-30, Robin: too small on a TV): 32 px icons, the turns left at the size of the
   HP numbers; two fit a four-hero box, a third wraps and the battle panel grows to hold the line. The row takes the slack
   of the box, so the HP and MP rows of the party stay level while one hero's statuses wrap */
.party.compact .hero { grid-template-rows: auto minmax(32px, 1fr) auto auto; }
.party:not(.gear) .hero .sts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; align-self: start; column-gap: 8px; row-gap: 2px;
                               font-size: 20px; line-height: 1; }
.party.four .hero .sts { font-size: 16px; }
.party .sts .st img.sicon { width: 32px; height: 32px; }
.party .sts .st b { font-size: 1em; text-shadow: 1px 1px 0 #000; }
.party .hero.hit { animation: hero-hit .35s ease-out; }
@keyframes hero-hit { from { background: rgba(255, 90, 90, .6); } to { background: transparent; } }
/* the acting hero's box steps up and back (2026-09-30, Robin: people watching need to see who acts, as a monster steps
   toward the party), and the box of the hero choosing a command is lit */
.party .hero.acting { animation: hero-act .32s ease-out; }
.party .hero.hit.acting { animation: hero-hit .35s ease-out, hero-act .32s ease-out; }
@keyframes hero-act { 0% { transform: translateY(0); } 40% { transform: translateY(-10px); } 100% { transform: translateY(0); } }
.party .hero.choosing { background: rgba(255, 224, 102, .16); box-shadow: 0 0 0 3px rgba(255, 224, 102, .55); border-radius: 4px; }

/* Touch controls (js/core/touch.js, 2026-10-08). #game keeps the room Display.setReserve() asks for, so the stage centres
   in the rest; held upright, the stage goes to the top and the controls sit under it. */
#game { box-sizing: border-box; padding: 0 var(--touch-side, 0px) var(--touch-below, 0px); }
#game.touch-upright { place-items: start center; }
/* the page never scrolls, selects, pops a long-press menu or zooms on a double tap under a finger; the name box still
   takes typing. A pinch still zooms, so a page zoomed some other way can always be pinched back out: it was 'none'
   until Robin's iPhone, zoomed by a double tap, could not be unzoomed (2026-10-08) */
html, body { overscroll-behavior: none; touch-action: manipulation; }
#game { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#game input, #game textarea { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
.touch { position: fixed; inset: 0; z-index: 10; pointer-events: none; color: #fff; font-family: "Press Start 2P", monospace; }
.touch[hidden], .touch-turn[hidden] { display: none; }
.touch-pad, .touch-btn { position: absolute; box-sizing: border-box; pointer-events: auto; touch-action: none; }
.touch-pad { width: var(--pad); height: var(--pad); }
.touch-pad i, .touch-pad::after { position: absolute; box-sizing: border-box; background: rgba(255, 255, 255, .14); }
.touch-pad i { border: 2px solid rgba(255, 255, 255, .5); }
.touch-pad .up, .touch-pad .down { left: 33%; width: 34%; height: 36%; }
.touch-pad .left, .touch-pad .right { top: 33%; width: 36%; height: 34%; }
.touch-pad .up { top: 0; border-bottom: 0; border-radius: 10px 10px 0 0; }
.touch-pad .down { bottom: 0; border-top: 0; border-radius: 0 0 10px 10px; }
.touch-pad .left { left: 0; border-right: 0; border-radius: 10px 0 0 10px; }
.touch-pad .right { right: 0; border-left: 0; border-radius: 0 10px 10px 0; }
.touch-pad::after { content: ""; left: 33%; top: 33%; width: 34%; height: 34%; }   /* the middle of the cross */
.touch-btn { display: grid; place-items: center; width: var(--btn); height: var(--btn); border-radius: 50%;
             border: 2px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .14);
             font-size: calc(var(--btn) * .3); text-shadow: 2px 2px 0 #000; }
.touch-map { width: auto; height: auto; padding: 10px 12px; border-radius: 10px; font-size: 11px; }
.touch-pad i.on, .touch-btn.on { background: rgba(255, 214, 102, .6); }
/* held sideways: the D-pad in the left column, A over B in the right one, Map at its top */
.touch:not(.upright) .touch-pad { left: calc((var(--col) - var(--pad)) / 2); top: calc(58% - var(--pad) / 2); }
.touch:not(.upright) .touch-a { right: calc(var(--col) * .06); top: calc(58% - var(--btn)); }
.touch:not(.upright) .touch-b { right: calc(var(--col) * .06 + var(--btn) * .66); top: calc(58% + var(--btn) * .1); }
.touch:not(.upright) .touch-map { right: 10px; top: 12px; }
/* held upright: under the screen, the D-pad left, A and B right, Map between them */
.touch.upright .touch-pad { left: 7vw; bottom: calc((var(--panel) - var(--pad)) / 2); }
.touch.upright .touch-a { right: 7vw; bottom: calc(var(--panel) / 2); }
.touch.upright .touch-b { right: calc(7vw + var(--btn) * .95); bottom: calc(var(--panel) / 2 - var(--btn) * 1.05); }
.touch.upright .touch-map { left: 50%; transform: translateX(-50%); bottom: calc(var(--panel) - 52px); }
/* a phone held upright: the note to turn it, over everything, until the player chooses to play upright anyway */
.touch-turn { position: absolute; inset: 0; display: grid; place-content: center; gap: 28px; padding: 24px; pointer-events: auto; touch-action: manipulation;
              background: rgba(12, 12, 20, .95); text-align: center; font-size: 13px; line-height: 2; }
.touch-turn p { margin: 0; }
.touch-turn button { justify-self: center; padding: 12px 18px; border: 2px solid #fff; border-radius: 8px; background: #08145a;
                     color: #fff; font: inherit; font-size: 11px; }
