/* The page around the game: a night sky that moves as you scroll, a bar that stays on top, a player that follows
   you down the page as a small window, and proposals dealt onto the page like slips of paper. The paper, ink and
   offset shadows of windows.css stay; this file only adds the room they lie in. Nothing here touches the game:
   the stage still fits itself to whatever room it is given. All motion stops under prefers-reduced-motion
   (app.js sets html.motion only when motion is welcome). */
:root { --bar:48px; --peek-gap:clamp(40px,5.5dvh,50px); --p:0; --night-top:#121027; --night-low:#2a2148; --cream:#fbf1dc; --paper:#f4ead3; --gold:#e3b55a; --ease:cubic-bezier(.2,.8,.2,1); }
body.docked { background:linear-gradient(180deg,var(--night-top) 0,#1b1838 46%,var(--night-low) 100%) fixed; }
body:not(.docked) :is(#site-bar, #sky, #peek, #ambient, #mini-back) { display:none; }
#sky { position:fixed; inset:0; width:100%; height:100%; z-index:0; pointer-events:none; }
body.docked :is(#watch, #next-story) { position:relative; z-index:1; }
body.docked #watch { z-index:2; } /* the small player belongs to it and lies over the proposals */

/* the bar */
#site-bar { position:sticky; top:0; z-index:30; height:var(--bar); display:flex; align-items:center; justify-content:space-between; gap:16px; padding:0 max(20px,calc((100vw - 1720px) / 2 + 20px)); background:linear-gradient(180deg,rgba(18,16,39,.9),rgba(18,16,39,0)); transition:background .3s, box-shadow .3s; }
#site-bar.scrolled { background:rgba(18,16,39,.82); backdrop-filter:blur(14px) saturate(1.3); box-shadow:0 1px 0 rgba(255,242,181,.14), 0 10px 30px rgba(8,6,20,.45); }
#wordmark { display:flex; align-items:center; gap:10px; color:var(--cream); text-decoration:none; font:600 16px/1 Georgia,"Iowan Old Style",serif; letter-spacing:.01em; white-space:nowrap; }
#wordmark span { color:var(--gold); }
#wordmark i { width:12px; height:12px; border-radius:50%; background:var(--gold); box-shadow:0 0 0 3px rgba(227,181,90,.22), 0 0 18px 4px rgba(246,196,83,.6); animation:lantern 3.2s ease-in-out infinite; }
@keyframes lantern { 50% { box-shadow:0 0 0 5px rgba(227,181,90,.12), 0 0 26px 8px rgba(246,196,83,.75); } }
#site-bar nav { display:flex; align-items:center; gap:18px; }
#to-proposals { color:#d8d1ea; text-decoration:none; font:700 11px/1 "Courier New",monospace; letter-spacing:.1em; text-transform:uppercase; padding:8px 2px; background:linear-gradient(var(--gold),var(--gold)) 0 100% / 0 2px no-repeat; transition:background-size .25s var(--ease), color .2s; }
#to-proposals:hover, #to-proposals.here { color:var(--cream); background-size:100% 2px; }
#to-proposals b:not(:empty) { margin-left:6px; padding:1px 7px; background:var(--gold); color:#2e231c; border-radius:999px; }
#bar-suggest { padding:8px 14px; border-radius:0; border:2px solid #0c0a16; background:var(--gold); color:#2e231c; box-shadow:3px 3px 0 rgba(0,0,0,.55); font:700 11px/1.3 "Courier New",monospace; white-space:nowrap; transition:translate .08s, box-shadow .08s, background .15s; }
#bar-suggest:hover { background:#f2cd7c; translate:-1px -1px; box-shadow:4px 4px 0 rgba(0,0,0,.55); }
#bar-suggest:active { translate:2px 2px; box-shadow:1px 1px 0 rgba(0,0,0,.55); }
#site-bar :focus-visible { outline:3px solid var(--gold); outline-offset:3px; }

/* the player: a glow of the picture's own colours behind it, and a small window when you scroll away */
body.docked #watch { padding-top:6px; }
#ambient { position:absolute; inset:-4%; width:108%; height:108%; z-index:0; filter:blur(48px) saturate(1.5); opacity:.55; pointer-events:none; transition:opacity 1s; }
#ambient.off { opacity:0; }
body.docked #player { z-index:1; border-color:#0c0a16; box-shadow:0 0 0 1px rgba(255,242,181,.1), 0 24px 60px rgba(6,4,18,.6); }
body.docked #community-rail { box-shadow:0 0 0 1px rgba(255,242,181,.1), 0 24px 60px rgba(6,4,18,.5); }
body.docked #player-slot::after { content:"Playing in the corner"; position:absolute; inset:0; display:grid; place-items:center; color:#8f88ad; font:12px/1 "Courier New",monospace; letter-spacing:.14em; text-transform:uppercase; border:1px dashed rgba(255,242,181,.16); opacity:0; pointer-events:none; }
body.docked.mini #player-slot::after { opacity:1; transition:opacity .4s .3s; }
body.docked.mini #ambient { opacity:0; }
body.docked.mini #player { position:fixed; inset:auto 18px 18px auto; width:clamp(240px,26vw,400px); aspect-ratio:16 / 9; height:auto; z-index:25; border:2px solid #0c0a16; box-shadow:0 0 0 1px rgba(255,242,181,.22), 6px 6px 0 rgba(0,0,0,.5), 0 20px 50px rgba(6,4,18,.7); transform-origin:100% 100%; }
body.docked.mini #player :is(.dock, .drawer, #pad) { display:none; }
#mini-back { position:absolute; top:8px; right:8px; z-index:9; width:30px; height:30px; padding:0; border-radius:0; border:2px solid #2e231c; background:var(--paper); color:#2e231c; box-shadow:2px 2px 0 rgba(0,0,0,.6); font:700 15px/1 "Courier New",monospace; opacity:.0; transition:opacity .2s; }
body.mini #player:hover #mini-back, #mini-back:focus-visible { opacity:1; }
@media (hover:none) { body.mini #mini-back { opacity:.9; } }

/* the way down */
#peek { grid-column:1 / -1; justify-self:center; display:inline-flex; justify-content:center; align-items:center; gap:12px; width:auto; max-width:100%; min-height:0; margin:var(--peek-gap) 0 0; padding:11px 20px; color:#2e231c; text-decoration:none; font:700 12px/1.35 "Courier New",monospace; letter-spacing:.06em; text-transform:uppercase; border:2px solid #2e231c; background:var(--gold); box-shadow:4px 4px 0 rgba(0,0,0,.55); transition:background .2s, box-shadow .2s, opacity .3s, translate .2s; opacity:calc(1 - var(--p) * 2.2); }
#peek:hover { background:#f2cd7c; translate:-2px -2px; box-shadow:7px 7px 0 rgba(0,0,0,.55); }
#peek:active { translate:3px 3px; box-shadow:2px 2px 0 rgba(0,0,0,.55); }
#peek b:not(:empty) { padding:3px 9px; background:#2e231c; color:var(--paper); border-radius:999px; }
#peek i { display:grid; place-items:center; flex:0 0 20px; width:20px; height:20px; color:#2e231c; }
#peek i svg { display:block; width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }
#peek:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }

/* the next story: said large, on the sky */
#next-story { scroll-margin-top:calc(var(--bar) + 4px); padding-top:clamp(56px,9vw,120px); overflow:clip; }
#moon { position:absolute; top:clamp(10px,4vw,60px); right:max(4vw,calc((100vw - 1720px) / 2)); width:clamp(180px,26vw,420px); aspect-ratio:1; border-radius:50%; pointer-events:none; background:radial-gradient(circle at 38% 36%,#fff7dc 0,#f6dc9c 34%,#e3b55a 62%,rgba(227,181,90,0) 71%); box-shadow:0 0 120px 40px rgba(246,196,83,.16); opacity:calc(.25 + var(--p) * .6); translate:0 calc((1 - var(--p)) * 160px); filter:saturate(.9); }
#moon::after { content:""; position:absolute; inset:0; border-radius:50%; background:radial-gradient(circle at 62% 30%,rgba(163,120,60,.28) 0 7%,transparent 8%), radial-gradient(circle at 30% 60%,rgba(163,120,60,.22) 0 10%,transparent 11%), radial-gradient(circle at 58% 66%,rgba(163,120,60,.18) 0 5%,transparent 6%); }
#cta { position:relative; display:block; padding:0; color:var(--cream); background:none; border:0; box-shadow:none; max-width:1100px; }
#cta .eyebrow { margin:0 0 14px; color:var(--gold); font:700 11px/1 "Courier New",monospace; letter-spacing:.22em; text-transform:uppercase; }
#cta .eyebrow::before { content:""; display:inline-block; width:34px; height:2px; margin-right:12px; vertical-align:middle; background:var(--gold); }
#tagline { margin:0 0 20px; max-width:15ch; font:600 clamp(36px,5.9vw,88px)/1.02 Georgia,"Iowan Old Style",serif; letter-spacing:-.015em; color:var(--cream); text-wrap:balance; text-shadow:0 2px 30px rgba(18,16,39,.6); }
#tagline em { position:relative; display:inline-block; font-style:italic; color:var(--gold); white-space:nowrap; }
#tagline svg { position:absolute; left:0; right:0; bottom:-.12em; width:100%; height:.2em; overflow:visible; }
#tagline path { fill:none; stroke:var(--gold); stroke-width:3; stroke-linecap:round; vector-effect:non-scaling-stroke; stroke-dasharray:320; stroke-dashoffset:0; }
#tagline .w { display:inline-block; }
#cta p.lede { max-width:52ch; margin:0 0 26px; color:#d8d1ea; font-size:clamp(15px,1.25vw,18px); line-height:1.55; }
#how { list-style:none; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; max-width:860px; margin:0 0 30px; padding:0; }
#how li { display:flex; gap:12px; align-items:flex-start; padding:14px; color:#e9e3f5; font-size:14px; line-height:1.45; border:1px solid rgba(255,242,181,.16); background:rgba(255,242,181,.045); backdrop-filter:blur(6px); }
#how b { flex-shrink:0; display:grid; place-items:center; width:26px; height:26px; background:var(--gold); color:#2e231c; border:2px solid #0c0a16; box-shadow:2px 2px 0 rgba(0,0,0,.5); font:700 13px/1 "Courier New",monospace; }
#how strong { color:var(--cream); }
#suggest-cta { position:relative; padding:14px 24px; font-size:15px; border-color:#0c0a16; box-shadow:5px 5px 0 rgba(0,0,0,.55); overflow:hidden; transition:translate .1s, box-shadow .1s, background .15s; }
#suggest-cta::after { content:""; position:absolute; inset:0; background:linear-gradient(105deg,transparent 35%,rgba(255,255,255,.55) 50%,transparent 65%); translate:-120% 0; }
#suggest-cta:hover { translate:-2px -2px; box-shadow:7px 7px 0 rgba(0,0,0,.55); }
#suggest-cta:hover::after { translate:120% 0; transition:translate .7s ease; }
#suggest-cta:active { translate:3px 3px; box-shadow:2px 2px 0 rgba(0,0,0,.55); }

/* the proposals: slips of paper, dealt as they come into view */
#proposal-browse { position:relative; margin-top:clamp(40px,6vw,84px); }
#proposal-browse-heading { display:flex; align-items:baseline; gap:14px; margin:0 0 6px; padding-bottom:12px; border-bottom:1px solid rgba(255,242,181,.2); font:600 clamp(22px,2.2vw,30px)/1.2 Georgia,serif; letter-spacing:0; text-transform:none; color:var(--cream); }
#proposal-browse-heading span { color:#a59fc0; font:700 11px/1 "Courier New",monospace; letter-spacing:.14em; text-transform:uppercase; }
#proposal-list { gap:22px; margin-top:22px; perspective:1400px; }
#proposal-list .story-idea { position:relative; padding:18px 18px 20px; border:2px solid #2e231c; border-left-width:6px; box-shadow:5px 5px 0 rgba(0,0,0,.45); transform:perspective(900px) rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)); transition:transform .25s var(--ease), box-shadow .25s var(--ease), translate .25s var(--ease); will-change:transform; }
#proposal-list .story-idea:hover { translate:-3px -4px; box-shadow:10px 12px 0 rgba(0,0,0,.4); z-index:2; }
#proposal-list .story-idea h3 { font-size:20px; padding-right:74px; }
#proposal-list .story-idea::after { content:""; position:absolute; left:0; bottom:0; height:5px; width:calc(var(--share,0) * 100%); background:linear-gradient(90deg,var(--blue),var(--gold)); transition:width .8s var(--ease) .2s; }
#proposal-list .story-idea.leading { border-left-color:var(--red); background:linear-gradient(160deg,#fff8e4,#f6e6b8); }
#proposal-list .story-idea.leading::before { content:"★ Leading"; position:absolute; top:14px; right:-8px; padding:4px 10px; background:var(--red); color:#fff6df; border:2px solid #2e231c; box-shadow:2px 2px 0 rgba(0,0,0,.45); font:700 10px/1.3 "Courier New",monospace; letter-spacing:.12em; text-transform:uppercase; rotate:3deg; }
#proposal-list .idea-footer { margin-top:14px; }
#proposal-list .vote { padding:8px 16px; font:700 14px/1 "Courier New",monospace; box-shadow:3px 3px 0 var(--shade); transition:translate .08s, box-shadow .08s, background .15s; }
#proposal-list .vote:hover { background:#fffaf0; translate:-1px -1px; box-shadow:4px 4px 0 var(--shade); }
#proposal-list .vote:active { translate:2px 2px; box-shadow:1px 1px 0 var(--shade); }
#proposal-list .vote[aria-pressed=true] { background:var(--gold); }
#proposal-list .vote.pop { animation:pop-vote .45s var(--ease); }
@keyframes pop-vote { 35% { scale:1.22; rotate:-4deg; } }
.spark { position:fixed; z-index:60; pointer-events:none; color:#f6c453; font-size:14px; text-shadow:0 0 8px rgba(246,196,83,.9); }

html.motion #proposal-list .story-idea:not(.in) { opacity:0; translate:0 70px; rotate:var(--tilt,-3deg); scale:.94; }
html.motion #proposal-list .story-idea.in { animation:deal .8s var(--ease) var(--d,0ms) backwards; }
@keyframes deal { from { opacity:0; translate:0 70px; rotate:var(--tilt,-3deg); scale:.94; } 60% { opacity:1; } }
html.motion :is(#cta .eyebrow, #cta .lede, #how li, #suggest-cta, #proposal-browse-heading):not(.in) { opacity:0; translate:0 26px; }
html.motion :is(#cta .eyebrow, #cta .lede, #how li, #suggest-cta, #proposal-browse-heading) { transition:opacity .7s var(--ease) var(--d,0ms), translate .7s var(--ease) var(--d,0ms), box-shadow .1s, background .15s; }
html.motion #tagline .w { opacity:0; translate:0 .5em; rotate:4deg; filter:blur(6px); transition:opacity .7s var(--ease) var(--d), translate .7s var(--ease) var(--d), rotate .7s var(--ease) var(--d), filter .7s var(--ease) var(--d); }
html.motion #tagline.in .w { opacity:1; translate:0; rotate:0deg; filter:none; }
html.motion #tagline path { stroke-dashoffset:320; transition:stroke-dashoffset 1s ease .9s; }
html.motion #tagline.in path { stroke-dashoffset:0; }
html.motion body.docked :is(#player-slot, #community-rail, #peek) { animation:arrive .9s var(--ease) backwards; }
html.motion body.docked #community-rail { animation-delay:.12s; }
html.motion body.docked #peek { animation-delay:.5s; }
@keyframes arrive { from { opacity:0; translate:0 22px; } }
html.motion #site-bar { animation:drop .7s var(--ease) backwards; }
@keyframes drop { from { translate:0 -100%; } }

/* the form that opens over the game, and signing in: they arrive instead of appearing */
html.motion :is(#panel-board, #auth-dialog)[open] { animation:sheet .35s var(--ease); }
html.motion :is(#panel-board, #auth-dialog)[open]::backdrop { animation:veil .35s ease; }
:is(#panel-board, #auth-dialog)::backdrop { background:rgba(12,10,26,.72); backdrop-filter:blur(6px); }
@keyframes sheet { from { opacity:0; translate:0 28px; scale:.97; } }
@keyframes veil { from { opacity:0; } }

@media (max-width:899px) {
  :root { --bar:46px; }
  #site-bar { padding:0 12px; }
  #wordmark { font-size:15px; }
  #to-proposals { display:none; }
  body.docked #watch { padding-top:0; }
  #ambient { display:none; }
  #peek { margin:var(--peek-gap) 12px 0; padding:11px 16px; gap:10px; }
  #how { grid-template-columns:1fr; }
  #moon { top:-30px; right:-70px; width:230px; opacity:calc(.12 + var(--p) * .28); }
  #site-bar { gap:8px; }
  #wordmark { min-width:0; overflow:hidden; }
  #bar-suggest { padding:6px 9px; font-size:11px; box-shadow:2px 2px 0 rgba(0,0,0,.55); }
  body.docked.mini #player { inset:auto 10px 10px auto; width:min(56vw,300px); }
  #proposal-list .story-idea:hover { translate:none; }
}
@media (prefers-reduced-motion:reduce) { #wordmark i, #peek i { animation:none; } }
/* room under the last proposals, so the small player never has to lie on them */
#next-story { padding-bottom:clamp(120px,22vw,280px); }

/* Account access belongs to the site, independently of whether comments are open. */
#site-account { display:flex; align-items:center; min-width:0; }
#site-account #account-button { max-width:190px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:8px 14px; border:2px solid #2e231c; border-radius:0; box-shadow:3px 3px 0 rgba(0,0,0,.55); background:var(--paper); color:#2e231c; font:700 11px/1.3 "Courier New",monospace; }
#site-account #account-button:hover { background:#fffaf0; }
#peek-block { grid-column:1 / -1; display:grid; justify-items:center; min-width:0; }
#peek-subtitle { margin:13px 12px 0; max-width:48ch; text-align:center; color:#c9c3dd; font-size:13px; line-height:1.45; opacity:calc(1 - var(--p) * 2.2); transition:opacity .3s; }
body:not(.docked) #peek-block { display:none; }
@media (max-width:600px) {
  #site-bar nav { gap:8px; flex-shrink:0; }
  #bar-suggest { display:none; }
  #site-account #account-button { max-width:120px; padding:7px 10px; font-size:11px; }
  #peek-subtitle { max-width:34ch; font-size:13px; }
}

/* Keep site typography compact without scaling the game or its speech. */
#community-rail { font-size:14px; }
#community-rail #comment-body { font-size:14px; }
#community-rail .comment-row p { font-size:13px; }
@media (max-width:899px) {
  /* Native input size prevents mobile browsers zooming the page on focus. */
  #community-rail #comment-body { font-size:16px; }
}

/* Phone controls stay in one row, leaving the picture readable. */
@media (max-width:850px) {
  body.docked #player .dock.right { flex-direction:row; gap:5px; }
  body.docked #player .dock button { width:38px; height:38px; font-size:14px; }
  body.docked #player .dock.left #now { max-width:min(175px,calc(100cqw - 195px)); }
  body.docked #player .top-actions #float { padding:5px 8px; font-size:10px; }
}
/* A short landscape phone needs a smaller player, rather than a clipped subtitle. */
@media (max-width:899px) and (max-height:500px) {
  :root { --peek-gap:28px; }
  body.docked #player-slot { --player-min-height:140px; min-height:140px; }
  #peek-subtitle { margin-top:10px; }
}

#community-rail[hidden] { display:none !important; }
#comments-dialog { width:min(440px,calc(100vw - 24px)); height:min(660px,calc(100dvh - 32px)); max-height:calc(100dvh - 32px); padding:0; border:0; background:#f4ead3; color:#2e231c; box-shadow:6px 6px 0 #0008; overflow:hidden; }
#comments-dialog::backdrop { background:rgba(12,10,26,.72); backdrop-filter:blur(4px); }
#comments-dialog #panel-chat { position:static; width:100%; height:100%; min-height:0; max-height:none; margin:0; box-sizing:border-box; box-shadow:none; animation:none; }
#comments-dialog #panel-chat[hidden] { display:none; }
#comments-dialog #panel-chat header { flex-shrink:0; margin-bottom:0; }
#comments-dialog #comment-scroll { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; }
#comments-dialog #comment-form { flex-shrink:0; }
#comments-dialog #comment-body { font-size:16px; }
@media (max-width:899px) { body.docked #community-rail { display:none; } }

@media (max-width:600px) and (orientation:portrait) {
  body.docked #player-slot { aspect-ratio:4 / 3; }
}

/* Browser-filling mode also works when iPhone Safari declines native full screen. */
html:has(body.immersive), body.immersive { height:100%; height:100dvh; overflow:hidden; overscroll-behavior:none; }
body.immersive #stage { position:fixed; inset:0; z-index:20; }
body.immersive :is(.dock,.drawer) { z-index:22; }
body.immersive .top-actions { display:none; }
@media (max-width:899px) {
  :root { --bar:calc(46px + env(safe-area-inset-top,0px)); }
  #site-bar { padding-top:env(safe-area-inset-top,0px); padding-left:max(12px,env(safe-area-inset-left,0px)); padding-right:max(12px,env(safe-area-inset-right,0px)); }
  #peek-block { padding-inline:max(12px,env(safe-area-inset-left,0px)) max(12px,env(safe-area-inset-right,0px)); }
  #comments-dialog { max-height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 24px); }
  :is(#proposal-form,#auth-dialog) :is(input,textarea,select) { font-size:16px; }
  /* Avoid a large animated filter layer and a per-frame canvas filter on phones. */
  #grain { animation:none; opacity:.04; }
  #canvas canvas { filter:none; }
  body:not(.docked) .dock.right { flex-direction:row; gap:5px; }
  body:not(.docked) #now { max-width:calc(100vw - 210px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)); }
}
@media (pointer:coarse) {
  .dock button, #pause { min-width:44px; min-height:44px; }
  body.docked #player .dock.left #now { max-width:calc(100cqw - 225px); }
  .drawer .close { width:36px; height:36px; }
}

@media (max-width:899px) {
  body.docked #player .dock.left { left:max(8px,env(safe-area-inset-left,0px)); }
  body.docked #player .dock.right { right:max(8px,env(safe-area-inset-right,0px)); }
}
@media (pointer:coarse) {
  body:not(.docked) .dock.left #now { max-width:calc(100vw - 225px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)); }
}

/* A landscape stage on portrait phones when Safari cannot lock physical orientation. */
body.landscape-game #player { position:fixed; left:50%; top:50%; width:100dvh; height:100dvw; transform:translate(-50%,-50%) rotate(90deg); z-index:20; overflow:hidden; background:#131124; }
body.landscape-game #stage { position:absolute; inset:0; }
body.landscape-game #player :is(.dock,.drawer) { position:absolute; }
body.landscape-game #player .dock { top:8px; }
body.landscape-game #player .dock.left { left:max(8px,env(safe-area-inset-top,0px)); }
body.landscape-game #player .dock.right { right:max(8px,env(safe-area-inset-bottom,0px)); flex-direction:row; }
body.landscape-game #player #now { display:none; }
body.landscape-game #player .drawer { top:60px; max-height:calc(100dvw - 72px); width:min(340px,calc(100dvh - 28px)); }
body.landscape-game #player #pad { position:absolute; bottom:8px; }
body.landscape-game #player .top-actions { display:none; }
@media (max-height:500px) { body:not(.docked) #now { display:none; } }

/* A quiet invitation to watch or take part, with room left for the voting CTA. */
#play-invitation { max-width:64ch; margin:56px 12px 0; color:#e7e0ef; text-align:center; text-wrap:pretty; font-size:14px; line-height:1.5; }
#peek-block #peek { margin-top:18px; }
@media (max-width:600px) { #play-invitation { margin-top:48px; font-size:13px; } }
@media (max-width:899px) and (max-height:500px) {
  #play-invitation { margin-top:28px; font-size:13px; }
  #peek-block #peek { margin-top:14px; }
}

#play-controls { max-width:64ch; margin:8px 16px 0; color:#bfb8d0; text-align:center; font-size:12px; line-height:1.5; text-wrap:pretty; }
.touch-controls, body.touch .keyboard-controls { display:none; }
body.touch .touch-controls { display:inline; }
@media (pointer:coarse) {
  #play-controls .keyboard-controls { display:none; }
  #play-controls .touch-controls { display:inline; }
}
@media (max-width:899px) and (max-height:500px) {
  #play-controls { font-size:11px; margin-top:6px; }
  #peek-block #peek { margin-top:8px; }
}

/* Keep the whole pane within its host; only the chapter list scrolls. */
body #panel-chapters { width:min(272px,calc(100% - 20px)); font-size:12px; overflow:hidden; top:58px; max-height:calc(100dvh - 68px); }
body.docked #player #panel-chapters { top:58px; max-height:calc(100% - 68px); }
body.landscape-game #player #panel-chapters { top:58px; max-height:calc(100dvw - 68px); }
#panel-chapters header { flex-shrink:0; padding:6px 8px; }
#panel-chapters h2 { font-size:11px; letter-spacing:.06em; }
#panel-chapters .close { width:24px; height:24px; min-height:0; font-size:18px; }
#panel-chapters .scroll { flex:0 1 auto; min-height:0; padding:6px 8px; overflow-y:auto; overscroll-behavior:contain; }
#panel-chapters #chapter-list { gap:3px; margin:0; }
#panel-chapters #chapter-list a { grid-template-columns:12px minmax(0,1fr) auto; gap:4px; min-height:30px; padding:5px; align-items:center; font-size:12px; line-height:1.25; }
#panel-chapters .chapter-title { min-width:0; }
#panel-chapters #chapter-list :is(.n,.m) { font-size:10px; white-space:nowrap; }
#panel-chapters footer { flex-shrink:0; padding:5px 8px 8px; border-top:1px solid var(--rule); }
#panel-chapters #restart { margin:0; width:100%; padding:6px 8px; min-height:30px; font-size:11px; }
@media (pointer:coarse) {
  #panel-chapters #chapter-list a, #panel-chapters #restart { min-height:44px; }
  #panel-chapters .close { width:32px; height:32px; }
}

@media (max-height:500px) {
  body.docked #player #panel-chapters { position:fixed; top:calc(var(--bar,46px) + 52px); max-height:calc(100dvh - var(--bar,46px) - 62px); z-index:40; }
}

/* A short introduction to the controls, over the picture rather than in the page layout. */
#frame #play-controls { position:absolute; z-index:4; left:50%; bottom:54px; transform:translateX(-50%); width:max-content; max-width:calc(100% - 24px); margin:0; padding:7px 12px; border-radius:12px; color:#fff9eb; background:rgba(30,25,40,.8); box-shadow:0 2px 10px #0002; font-size:12px; line-height:1.4; text-align:center; opacity:0; transition:opacity .25s ease; pointer-events:none; }
#frame #play-controls.visible { opacity:1; }
#frame #play-controls[hidden] { display:none; }
#frame:has(#replies:not([hidden])) #play-controls { visibility:hidden; }
@media (max-width:600px) { #frame #play-controls { font-size:11px; bottom:50px; padding:6px 10px; } }
@media (prefers-reduced-motion:reduce) { #frame #play-controls { transition:none; } }

/* A single paper control deck keeps the mobile picture clear. */
#mobile-toolbar[hidden] { display:none !important; }
#mobile-toolbar { position:absolute; top:100%; left:0; width:100%; display:flex; flex-wrap:wrap; align-items:center; gap:0; padding:8px 12px 10px; background:#f4ead3; color:#2e231c; border:1px solid #b3a284; border-top:0; box-shadow:0 3px 0 #0002; }
#mobile-toolbar .dock { position:static; display:flex; flex-direction:row; align-items:center; padding:0; }
#mobile-toolbar .dock.left { flex:1 0 100%; gap:9px; padding-bottom:8px; border-bottom:1px solid #b3a28488; }
#mobile-toolbar .dock.right { flex:1 0 100%; justify-content:space-between; gap:4px; margin:7px 0; }
#mobile-toolbar #now { min-width:0; margin:0; color:#2e231c; text-shadow:none; }
#mobile-toolbar #now-chapter { max-width:100%; font-size:13px; color:#2e231c; }
#mobile-toolbar #now-story, #mobile-toolbar .dock [data-panel=chat] { display:none; }
#mobile-toolbar .dock button, #mobile-toolbar #pause { position:static; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; flex:1; width:auto; min-width:44px; height:44px; min-height:44px; padding:3px; border:0; border-radius:3px; background:transparent; color:#2e231c; box-shadow:none; opacity:1; font-size:17px; translate:none; }
#mobile-toolbar .dock.left button { flex:none; width:32px; height:32px; min-height:32px; border:1px solid #b3a284; }
#mobile-toolbar .dock button::after { font:10px/1.1 "Courier New",monospace; }
#mobile-toolbar #pause::after { content:"Pause"; }
#mobile-toolbar #pause[aria-pressed=true]::after { content:"Play"; }
#mobile-toolbar #community-toggle::after { content:"Comments"; }
#mobile-toolbar #sound-button::after { content:"Sound"; }
#mobile-toolbar #full::after { content:"Full screen"; white-space:nowrap; }
#mobile-toolbar .dock button:hover { background:#e6d9bb; }
#mobile-toolbar #pad { position:static; display:flex; flex-basis:100%; justify-content:space-between; gap:8px; padding:2px 0 10px; margin:0 0 8px; border-bottom:1px solid #b3a28488; }
#mobile-toolbar #pad button { width:44px; height:44px; min-height:44px; border-radius:3px; font-size:17px; color:#2e231c; background:#e6d9bb; border:1px solid #b3a284; box-shadow:none; }
#mobile-toolbar #pad #right { margin:0 auto 0 0; }
#mobile-toolbar #pad #act { width:48px; height:44px; background:#e3b55a; }
#mobile-toolbar #pad button[hidden] { display:none; }
#chapter-settings:empty { display:none; }
body.mobile-player #clock, body.mobile-player #sound-wait { display:none; }
#mobile-toolbar .top-actions { position:static; transform:none; flex-basis:100%; width:100%; max-width:none; text-align:center; }
#mobile-toolbar #float { width:100%; min-height:36px; margin:0; padding:7px 10px; font-size:0; text-align:center; background:#fbf4e2; color:#2e231c; border:1px solid #b3a284; box-shadow:none; opacity:1; }
#mobile-toolbar #float::after { content:"⧉  Float the game over other windows"; font:700 11px/1.4 "Courier New",monospace; }
#mobile-toolbar #float[aria-expanded=true]::after { content:"↙  Bring the game back here"; }
#mobile-toolbar #float-error { position:static; margin:4px 0; }

body.mobile-player #player :is(#panel-chapters,#panel-sound) { position:fixed; top:calc(var(--bar,46px) + 8px); left:8px; right:auto; width:min(300px,calc(100vw - 16px)); max-height:calc(100dvh - var(--bar,46px) - 24px); z-index:40; }

#chapters-dialog { width:min(340px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); padding:0; border:0; background:var(--paper); color:var(--ink); overflow:hidden; box-shadow:6px 6px 0 #0008; }
#chapters-dialog::backdrop { background:rgba(12,10,26,.72); backdrop-filter:blur(4px); }
body #chapters-dialog #panel-chapters { position:static; width:100%; max-height:calc(100dvh - 32px); margin:0; box-shadow:none; animation:none; }

#sound-dialog { width:min(340px,calc(100vw - 24px)); max-height:calc(100dvh - 32px); padding:0; border:0; background:#f4ead3; color:#2e231c; overflow:auto; box-shadow:6px 6px 0 #0008; }
#sound-dialog::backdrop { background:rgba(12,10,26,.72); backdrop-filter:blur(4px); }
body #sound-dialog #panel-sound { position:static; width:100%; max-height:none; margin:0; box-shadow:none; animation:none; }
#mobile-toolbar .dock button[aria-expanded=true] { background:#e6d9bb; }

/* Fullscreen touch controls stay on the game, including before the first touch. */
body.mobile-fullscreen #player #pad { position:absolute; display:flex; inset:auto max(12px,env(safe-area-inset-right,0px)) max(12px,env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px)); gap:8px; padding:0; z-index:24; }
body.mobile-fullscreen #player #pad button { width:44px; height:44px; min-height:44px; border-radius:6px; background:rgba(244,234,211,.88); color:#2e231c; border:1px solid #b3a284; font-size:17px; box-shadow:0 2px 6px #0003; }
body.mobile-fullscreen #player #pad #right { margin:0 auto 0 0; }
body.mobile-fullscreen #player #pad #act { width:48px; height:44px; background:rgba(227,181,90,.94); }
body.mobile-fullscreen #player #pad button:disabled { opacity:.38; }
body.mobile-fullscreen #player .dock.left { display:flex; align-items:center; gap:7px; }
body.mobile-fullscreen #player #now { display:none; }
body.mobile-fullscreen #player .dock.left #pause { position:static; flex:none; width:44px; height:44px; min-height:44px; opacity:1; font-size:15px; }
body.mobile-fullscreen #player .dock.left #clock { position:static; margin:0; padding:4px 8px; font-size:11px; opacity:1; border-radius:3px; background:rgba(30,25,40,.75); color:#fbf1dc; }
#play-invitation { opacity:calc(1 - var(--p) * 2.2); transition:opacity .3s; }
html.motion body.docked #play-invitation { translate:0 calc(var(--p) * -12px); }
body.docked #next-story { margin-top:calc(-1 * var(--story-lift,0px) * var(--story-fold,0)); }
html:has(body.docked) { overflow-anchor:none; }
body.docked :is(#play-invitation,#peek,#peek-subtitle) { opacity:var(--intro-opacity,1); }

body.mobile-fullscreen #player :is(#sound-wait,#hint) { display:none; }

/* The makers' footer, in the same night sky, warm paper and typewriter palette. */
#site-footer { margin-top:clamp(64px,9vw,120px); border-top:2px solid #e3b55a; color:#e7e0ef; }
#site-footer .footer-grid { display:grid; grid-template-columns:1.6fr repeat(3,1fr); gap:32px; padding:40px 0; border-bottom:1px solid #fbf1dc26; }
#site-footer .footer-brand { display:inline-flex; flex-wrap:wrap; align-items:center; gap:5px; font:700 21px/1.3 Georgia,serif; color:#fbf1dc; text-decoration:none; }
#site-footer .footer-brand i { width:11px; height:11px; margin-right:4px; background:#e3b55a; border-radius:50%; box-shadow:0 0 16px #e3b55a88; }
#site-footer .footer-brand em { color:#e3b55a; font-style:normal; }
#site-footer .footer-about p { font-size:13px; line-height:1.8; color:#bfb8d0; margin:14px 0 20px; }
#site-footer .footer-by { display:inline-grid; gap:6px; text-decoration:none; }
#site-footer .footer-by span, #site-footer h2 { color:#a59fc0; font:700 10px/1.5 "Courier New",monospace; text-transform:uppercase; letter-spacing:.12em; }
#site-footer .footer-by strong { color:#fbf1dc; font:700 13px/1.5 "Courier New",monospace; }
#site-footer h2 { margin:2px 0 14px; }
#site-footer ul { list-style:none; padding:0; margin:0; display:grid; gap:7px; }
#site-footer li :is(a,button) { display:inline-block; padding:5px 0; color:#e7e0ef; font:13px/1.5 system-ui,sans-serif; text-decoration:none; background:none; border:0; box-shadow:none; text-align:left; }
#site-footer :is(a,button):hover { color:#e3b55a; }
#site-footer :is(a,button):focus-visible { outline:2px solid #e3b55a; outline-offset:4px; }
#site-footer .footer-bottom { display:flex; flex-wrap:wrap; justify-content:space-between; gap:12px; padding:20px 0 0; color:#a59fc0; font:10px/1.6 "Courier New",monospace; }
body.docked #next-story:has(#site-footer) { padding-bottom:36px; }
@media (max-width:899px) { #site-footer .footer-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:26px 18px; } #site-footer .footer-about { grid-column:1 / -1; } }
@media (max-width:480px) { #site-footer .footer-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } #site-footer nav:last-child { grid-column:1 / -1; } #site-footer .footer-bottom { display:grid; } }

body.docked #next-story { padding-inline:clamp(24px,4vw,48px); }
body.reading-footer.mini #player { visibility:hidden; pointer-events:none; }

#available-games { margin-top:clamp(64px,8vw,100px); scroll-margin-top:70px; }
.catalog-heading { display:flex; justify-content:space-between; gap:20px; align-items:end; border-bottom:1px solid #fbf1dc33; padding-bottom:16px; }
.catalog-eyebrow { margin:0 0 8px; color:#e3b55a; font:700 10px/1.5 "Courier New",monospace; text-transform:uppercase; letter-spacing:.12em; }
#available-games h2 { margin:0; color:#fbf1dc; font:600 clamp(28px,4vw,44px)/1.15 Georgia,serif; }
#game-count { margin:0; color:#bfb8d0; font:12px/1.5 "Courier New",monospace; white-space:nowrap; }
.catalog-intro { max-width:65ch; margin:18px 0 24px; color:#c9c3dd; font-size:14px; line-height:1.7; }
#game-filters { display:grid; grid-template-columns:1.6fr repeat(4,1fr); gap:12px; margin-bottom:24px; }
#game-filters label { min-width:0; color:#bfb8d0; font:700 10px/1.5 "Courier New",monospace; display:grid; gap:6px; }
#game-filters :is(input,select) { width:100%; min-width:0; min-height:42px; padding:9px; border:1px solid #b3a284; background:#f4ead3; color:#2e231c; border-radius:0; font-size:13px; }
#game-filters :is(input,select):focus-visible { outline:2px solid #e3b55a; outline-offset:3px; }
#game-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:22px; }
.game-card { overflow:hidden; color:#2e231c; background:#f4ead3; border:2px solid #2e231c; box-shadow:4px 4px 0 #0006; }
.game-preview { display:block; position:relative; aspect-ratio:16/9; overflow:hidden; border-bottom:2px solid #2e231c; text-decoration:none; }
.game-preview img { width:100%; height:100%; object-fit:cover; }
.game-placeholder { height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; color:#f4ead3; background:repeating-linear-gradient(0deg,#ffffff06 0 1px,transparent 1px 5px),#3a6462; font:11px/1.5 "Courier New",monospace; }
.game-placeholder-icon { font-size:40px; color:#e3b55a; }
.game-state { position:absolute; bottom:10px; left:10px; padding:6px 10px; background:#f4ead3; color:#2e231c; border:1px solid #2e231c; font:700 10px/1.5 "Courier New",monospace; }
.game-preview.ready .game-state { background:#e3b55a; }
.game-card-copy { padding:18px; }
.game-card .game-genres { margin:0 0 8px; color:#3a6462; font:700 10px/1.5 "Courier New",monospace; text-transform:uppercase; }
.game-card h3 { margin:0 0 10px; font:600 23px/1.2 Georgia,serif; }
.game-card h3 a { color:inherit; text-decoration:none; }
.game-card p { margin:0; font-size:13px; line-height:1.65; }
.game-card .game-facts { margin-top:18px; padding-top:12px; border-top:1px solid #b3a28488; color:#6a5b4d; font:11px/1.5 "Courier New",monospace; }
#game-empty { color:#c9c3dd; font-size:14px; }
#game-reset { margin-left:8px; color:#2e231c; background:#f4ead3; border:1px solid #b3a284; padding:8px; }
@media (max-width:1000px) { #game-list { grid-template-columns:repeat(2,minmax(0,1fr)); } #game-filters { grid-template-columns:repeat(4,minmax(0,1fr)); } #game-filters .game-search { grid-column:1 / -1; } }
@media (max-width:600px) { #game-list { grid-template-columns:1fr; } #game-filters { grid-template-columns:repeat(2,minmax(0,1fr)); } #game-filters :is(input,select) { font-size:16px; } .catalog-heading { align-items:center; } #game-count { font-size:11px; } }
