/* HD-2D engine: the storyteller's look (pages typed over a scene). Theme from :root: --ink --gold --gold2 --font-title --font-body. */
.story { position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: radial-gradient(ellipse at 50% 38%, color-mix(in srgb, var(--panel-top) 92%, transparent), color-mix(in srgb, var(--bg) 98%, transparent) 70%); padding: 24px 16px; transition: opacity 0.6s; }
.story.out { opacity: 0; pointer-events: none; }
.story .st-scene { height: min(42vh, 360px); display: flex; align-items: flex-end; justify-content: center; }
.story .st-pic { height: 100%; image-rendering: pixelated; filter: drop-shadow(0 0 18px rgba(255, 170, 80, 0.25)); animation: st-float 5s ease-in-out infinite; }
.story.turn .st-pic, .story.turn .st-card { animation: st-in 0.7s ease-out both, st-float 5s ease-in-out 0.7s infinite; }
.story.turn .st-card { animation: st-in 0.7s ease-out both; }
.story .st-card { width: min(760px, 100%); padding: 18px 26px 14px; border: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); border-radius: calc(var(--radius) + 2px); background: linear-gradient(180deg, color-mix(in srgb, var(--panel-top) 85%, transparent), color-mix(in srgb, var(--panel-base) 85%, transparent)); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.story .st-title { font: 600 26px var(--font-title); color: var(--gold2); text-align: center; margin-bottom: 8px; letter-spacing: 0.05em; }
.story .st-title:empty { display: none; }
.story .st-text { font: 500 21px/1.5 var(--font-body); color: var(--ink); min-height: 3em; white-space: pre-wrap; }
.story .st-hint { margin-top: 10px; text-align: right; font-size: 12px; color: var(--gold); opacity: 0.7; }
@keyframes st-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes st-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
/* talking: a dialogue box at the bottom (portrait, name, typed words, choices); barks sit higher and fade by themselves */
.talk { position: fixed; left: 0; right: 0; margin: 0 auto; bottom: 112px; z-index: 22;   /* (centred by margins: the slide-in animation owns transform, and ended it at none, so translateX(-50%) was lost) */
   width: min(760px, calc(100vw - 32px)); box-sizing: border-box; display: flex; gap: 14px; padding: 12px 16px 10px 12px; border: 1px solid color-mix(in srgb, var(--edge) 70%, transparent); border-radius: calc(var(--radius) + 2px); background: linear-gradient(180deg, color-mix(in srgb, var(--panel-top) 94%, transparent), color-mix(in srgb, var(--panel-base) 94%, transparent)); box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6); animation: st-in 0.25s ease-out both; transition: opacity 0.3s; }
.talk.out { opacity: 0; }
.talk.bark { bottom: auto; top: 96px; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.talk .tk-face canvas { width: 72px; height: 72px; image-rendering: pixelated; border: 1px solid color-mix(in srgb, var(--edge) 50%, transparent); border-radius: 5px; background: radial-gradient(var(--face1), var(--face2)); display: block; }
.talk .tk-body { flex: 1; min-width: 0; }
.talk .tk-name { font: 600 16px var(--font-title); color: var(--gold2); letter-spacing: 0.04em; margin-bottom: 2px; }
.talk .tk-text { font: 500 18px/1.45 var(--font-body); color: var(--ink); min-height: 2.9em; white-space: pre-wrap; }
.talk.bark .tk-text { min-height: 0; font-size: 17px; }
.talk .tk-choices { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
/* the box never taller than the screen: the portrait and words stay, the choices scroll inside it */
.talk:not(.bark) { max-height: calc(100dvh - 112px - 16px); }
.talk .tk-body { display: flex; flex-direction: column; min-height: 0; }
.talk .tk-body > * { flex: none; } .talk .tk-choices { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
/* a long list (a keeper's wares): compact rows, two columns where there is room, filters above that stay put */
.talk .tk-choices.many { display: grid; grid-template-columns: 1fr; gap: 3px; }
@media (min-width: 900px) { .talk .tk-choices.many { grid-template-columns: 1fr 1fr; } .talk:has(.tk-choices.many) { width: min(980px, calc(100vw - 32px)); } }
.talk .tk-choices.many > button { padding: 3px 8px; font-size: 14px; line-height: 1.3; }
.talk .tk-filt { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; position: sticky; top: 0; z-index: 1; padding: 0 0 4px; background: var(--panel-top); }
.talk .tk-filt button { all: unset; cursor: pointer; padding: 2px 10px; border-radius: 12px; font: 600 13px var(--font-body); color: var(--ink); border: 1px solid color-mix(in srgb, var(--edge) 40%, transparent); }
.talk .tk-filt button.on { background: color-mix(in srgb, var(--gold) 30%, transparent); border-color: var(--gold); }
/* a phone held sideways: the box from near the bottom edge, a smaller face, smaller words */
@media (max-height: 520px) { .talk:not(.bark) { bottom: 6px; max-height: calc(100dvh - 12px); padding: 8px 12px 6px 8px; gap: 10px; } .talk .tk-face canvas { width: 48px; height: 48px; } .talk .tk-text { font-size: 15px; min-height: 0; } .talk .tk-name { font-size: 14px; }
  html.touch .talk .tk-choices button { box-sizing: border-box; min-height: 38px; padding: 6px 10px; font-size: 14px; } html.touch .talk .tk-filt button { min-height: 32px; } }
.talk .tk-choices button { all: unset; cursor: pointer; padding: 4px 10px; border-radius: 4px; font: 600 15px var(--font-body); color: var(--ink); border: 1px solid color-mix(in srgb, var(--edge) 35%, transparent); }
.talk .tk-choices button:hover { background: color-mix(in srgb, var(--edge) 22%, transparent); color: var(--gold2); }
.talk .tk-hint { text-align: right; font-size: 12px; color: var(--gold); opacity: 0.7; min-height: 14px; }
.talk .tk-choices button[disabled], .talk .tk-choices button.locked { opacity: 0.45; cursor: default; } .talk .tk-choices small { color: var(--gold); font-size: 12px; }
/* the end: a last card after the ending story */
.theend { position: fixed; inset: 0; z-index: 26; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--panel-top) 94%, transparent), color-mix(in srgb, var(--bg) 99%, transparent) 70%); animation: st-in 1.2s ease-out both; padding: 16px; }
.theend .te-card { text-align: center; max-width: 720px; }
.theend .te-kicker { font: 600 14px var(--font-title, serif); letter-spacing: 0.3em; text-transform: uppercase; color: var(--dim); }
.theend h1 { font: 600 clamp(44px, 8vw, 92px) var(--font-title, serif); color: var(--title); margin: 6px 0 22px; text-shadow: 0 0 24px color-mix(in srgb, var(--glow) 45%, transparent), 0 4px 0 #2a1608; }
.theend .te-party { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-bottom: 18px; }
.theend .te-party > div { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink); font-size: 15px; }
.theend .te-party canvas { width: 56px; height: 56px; image-rendering: pixelated; border: 1px solid color-mix(in srgb, var(--edge) 50%, transparent); border-radius: 6px; background: radial-gradient(var(--face1), var(--face2)); }
.theend .te-party small { color: var(--dim); font-size: 12px; }
.theend .te-sum { color: var(--dim); margin-bottom: 22px; }
.theend button { font: 600 16px var(--font-title, serif); padding: 8px 22px; background: color-mix(in srgb, var(--panel-base) 80%, transparent); color: var(--gold2); border: 1px solid color-mix(in srgb, var(--edge) 60%, transparent); border-radius: 6px; cursor: pointer; }

/* Low and Medium: the picture floats without its glow (a filter on a moving picture is redrawn every frame) */
:root[data-q="low"] .story .st-pic, :root[data-q="medium"] .story .st-pic { filter: none; }
.story.cine { background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.55)); justify-content: flex-end; padding-bottom: 4vh; } .story.cine .st-scene { display: none; }   /* (a scene the game plays: the words over it, at the foot) */
/* a scene painted for the page: kept still, framed softly, not pixel-scaled (Jon, 2026-11-01) */
.story .st-pic.st-paint, .story.turn .st-pic.st-paint { image-rendering: auto; max-width: 92vw; object-fit: contain; border-radius: 6px; box-shadow: 0 6px 30px rgba(0, 0, 0, 0.45); filter: none; animation: st-in 0.7s ease-out both; }
.story .st-pic.st-real, .story.turn .st-pic.st-real { image-rendering: auto; filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.55)); }   /* a real person rendered from their body (bodies.js figure): smooth, not pixelated */
/* a toast (#msg) never over a speech box: while a foe or friend speaks at the top (.talk.bark, top 96px, ~110px tall), the toast drops below it (Jon, 2026-11-08: "You catch the attendant unawares!" covered the words) */
html body:has(.talk.bark:not(.out)) #msg, html body:has(.talk.bark:not(.out)) #hud.battle #msg { top: 222px; }
html.touch body:has(.talk.bark:not(.out)) #msg { top: calc(222px + env(safe-area-inset-top)); }
