/* PLAY ENGINE · the stage (assets/js/play/stage.js; specs/play_engine.md). Kit tokens (play/kit.css). From the TS
   caption / title / outcome styles (T-136/T-140), made one engine. The picture IS the screen (Overlord #1210). */
.ps { position: relative; height: calc(100dvh - var(--header-h, 56px)); min-height: 420px; overflow: hidden; background: var(--k-bg); color: var(--k-text); }
.ps-bg { position: absolute; inset: -3%; background: center / cover no-repeat; image-rendering: pixelated; }
.ps-bg::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, color-mix(in srgb, var(--k-black) 35%, transparent) 0%, transparent 28%, color-mix(in srgb, var(--k-black) 18%, transparent) 55%, color-mix(in srgb, var(--k-black) 92%, transparent) 100%); }
html[data-motion="full"] .ps-bg { animation: ps-drift 48s ease-in-out infinite alternate; }
@keyframes ps-drift { from { transform: scale(1.02) translate(-1%, -0.6%); } to { transform: scale(1.1) translate(1%, 0.8%); } }

/* who you are: one small chip in the corner (tap for the full stats) */
.ps-chip { position: absolute; top: 12px; left: 12px; z-index: 6; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 5px 12px 5px 5px; border: 1px solid var(--k-line); border-radius: var(--k-pill); background: color-mix(in srgb, var(--k-black) 78%, transparent); color: var(--k-text); font: inherit; text-align: left; cursor: pointer; }
.ps-chip[hidden] { display: none; }
.ps-chip img.px { image-rendering: pixelated; }
.ps-chip img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 1px solid var(--k-line); }

/* the film caption, above the hand */
.ps-cine { position: absolute; left: 50%; bottom: 220px; z-index: 3; width: min(900px, calc(100% - 32px)); transform: translateX(-50%); text-align: center; cursor: default; }
.ps-cine[hidden] { display: none; }
.ps-cine.story { overflow-y: auto; scrollbar-width: thin; padding: 4px 6px; } /* the reading column (lines: …) */
.ps-cine.story .cine-line { font-size: clamp(17px, 1.1vw + 11px, 27px); margin: 0 0 12px; }
.ps-cine .cine-line.old { color: color-mix(in srgb, var(--k-text) 72%, transparent); }
.ps-cine .cine-line.old.before { font-size: clamp(14px, 0.6vw + 11px, 19px); color: color-mix(in srgb, var(--k-text) 55%, transparent); }
.ps-cine.typing .cine-line.old { animation: none; }
.ps-cine .cine-head { font: 700 12px var(--k-mono); letter-spacing: 0.3em; color: var(--k-cyan); text-transform: uppercase; text-shadow: 0 1px 3px var(--k-black); }
.ps-cine .cine-sep { width: min(240px, 50%); height: 1px; margin: 8px auto 10px; background: color-mix(in srgb, var(--k-white) 70%, transparent); }
.ps-cine .cine-line { margin: 0; font-family: var(--k-display); font-size: clamp(20px, 1.6vw + 12px, 36px); line-height: 1.32; letter-spacing: 0.015em; color: var(--k-text); text-shadow: 0 2px 3px color-mix(in srgb, var(--k-black) 95%, transparent), 0 0 18px color-mix(in srgb, var(--k-black) 85%, transparent), 0 0 46px color-mix(in srgb, var(--k-black) 60%, transparent); text-wrap: balance; }
.ps-cine .cw { white-space: nowrap; display: inline-block; }
.ps-cine.typing .cc { opacity: 0; filter: blur(3px); animation: cine-in 0.6s ease-out var(--d) forwards; display: inline-block; }
.ps-cine.fading .cine-line { animation: k-fade 0.45s ease-out both; }
@keyframes cine-in { from { opacity: 0; filter: blur(3px); transform: translateY(5px); } to { opacity: 1; filter: none; transform: none; } }

/* the hand's place (PlayKit.hand mounts here); it waits for the caption */
.ps-hand { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 12px 10px; transition: opacity 0.25s, transform 0.25s; }
.ps-hand.cine-wait { opacity: 0; transform: translateY(10px); pointer-events: none; }
.ps-hand.cine-wait * { pointer-events: none !important; }

/* the outcome: what changed as chips, the book math behind "details" (Overlord #1210) */
.ps-out { position: absolute; left: 50%; bottom: 200px; z-index: 4; display: grid; justify-items: center; gap: 8px; width: min(760px, calc(100% - 32px)); transform: translateX(-50%); }
.ps-out[hidden] { display: none; }
.ps-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ps-pill { padding: 4px 12px; border: 1px solid var(--k-line); border-radius: var(--k-pill); font: 13px var(--k-mono); color: var(--k-muted); background: color-mix(in srgb, var(--k-black) 75%, transparent); }
.ps-pill.good { border-color: var(--k-grn); color: var(--k-grn); }
.ps-pill.bad { border-color: var(--k-red); color: var(--k-red); }
.ps-pill.meh { border-color: var(--k-yel); color: var(--k-yel); }
.ps-det { font-size: 12px; color: var(--k-muted); text-align: left; max-width: 100%; }
.ps-det summary { display: flex; align-items: center; justify-content: center; min-height: 32px; color: var(--k-cyan); cursor: pointer; }
.ps-det ul { margin: 6px 0 0; padding-left: 18px; }
.ps-next { min-height: 44px; }

/* title cards: NEW JOB / JOB DONE */
.ps-title { position: fixed; inset: 0; z-index: 125; display: grid; place-items: center; align-content: center; gap: 10px; padding: 24px; border: 0; background: color-mix(in srgb, var(--k-black) 72%, transparent); color: var(--k-text); text-align: center; cursor: pointer; font: inherit; }
.ps-title.has-bg { background: linear-gradient(180deg, color-mix(in srgb, var(--k-black) 40%, transparent), color-mix(in srgb, var(--k-black) 82%, transparent)), var(--poster) center / cover no-repeat, var(--k-bg); image-rendering: pixelated; }
.ps-title .tt-k { font: 700 13px var(--k-mono); letter-spacing: 0.4em; color: var(--k-cyan); }
.ps-title .tt-h { margin: 0; font: 400 clamp(30px, 5vw + 8px, 64px)/1.15 var(--k-display); text-shadow: 0 0 30px color-mix(in srgb, var(--k-black) 90%, transparent); text-wrap: balance; }
.ps-title .tt-s { color: var(--k-muted); }
.ps-title.good .tt-h { color: var(--k-grn); }
.ps-title.bad .tt-h { color: var(--k-red); }
html[data-motion="full"] .ps-title .tt-h { animation: tt-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
html[data-motion="full"] .ps-title .tt-k { animation: tt-in 0.45s ease-out both; }
html[data-motion="reduced"] .ps-title { animation: k-fade 0.25s ease-out; }
@keyframes tt-in { from { opacity: 0; transform: scale(1.12); letter-spacing: 0.3em; } }

/* toasts */
.ps-toasts { position: fixed; z-index: 130; left: 50%; top: calc(var(--header-h, 56px) + 12px); transform: translateX(-50%); display: grid; gap: 6px; pointer-events: none; }
.ps-toast { box-shadow: 0 10px 24px var(--k-shade); background: var(--k-panel-hi); border: 1px solid var(--k-yel); color: var(--k-text); padding: 8px 14px; border-radius: var(--k-r-s); max-width: calc(100vw - 32px); }
.ps-toast.bad { border-color: var(--k-red); }
.ps-toast.good { border-color: var(--k-grn); }

@media (max-width: 640px) {
  .ps-cine { bottom: 190px; }
  .ps-out { bottom: 170px; }
  .ps-chip img { width: 36px; height: 36px; }
}

/* the HUD slot: the game's top line(s), right of the chip */
.ps-hud { position: absolute; top: 12px; left: 50%; z-index: 6; width: min(640px, calc(100% - 24px)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.ps-hud > * { pointer-events: auto; }
.ps-hud:empty { display: none; }
@media (max-width: 760px) { .ps-hud { top: 64px; } }

/* the title screen: logo, a pulsing tap, the game's pixel poster */
.ps-tap { background: linear-gradient(180deg, color-mix(in srgb, var(--k-black) 35%, transparent), color-mix(in srgb, var(--k-black) 82%, transparent)), var(--poster, none) center / cover no-repeat, var(--k-bg); image-rendering: pixelated; gap: 14px; }
.ps-tap .tt-logo { font: 900 clamp(34px, 7vw, 84px)/1 var(--k-mono); letter-spacing: 0.18em; color: var(--k-cyan); text-shadow: 0 0 22px color-mix(in srgb, var(--k-cyan) 70%, transparent), 0 4px 0 color-mix(in srgb, var(--k-mag) 70%, transparent); }
.ps-tap .tt-sub { font: 700 clamp(12px, 1.4vw, 16px) var(--k-mono); letter-spacing: 0.5em; color: var(--k-mag); }
.ps-tap .tt-go { margin-top: 18px; padding: 8px 18px; border: 1px solid var(--k-yel); border-radius: var(--k-pill); background: color-mix(in srgb, var(--k-black) 60%, transparent); font: 800 15px var(--k-mono); letter-spacing: 0.3em; color: var(--k-yel); text-shadow: 0 0 14px color-mix(in srgb, var(--k-yel) 70%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--k-yel) 30%, transparent); }
.ps-tap small { color: var(--k-muted); max-width: 420px; }
html[data-motion="full"] .ps-tap .tt-go { animation: tt-pulse 1.4s ease-in-out infinite; }
@keyframes tt-pulse { 50% { opacity: 0.65; } }
body.roll-on .ps-hud, body.roll-on .ps-out { opacity: 0; pointer-events: none; transition: opacity 0.2s; }
