body{overscroll-behavior:none}
.login{display:flex;flex-direction:column;gap:8px;max-width:440px}
.login .mark{width:150px;margin:8px auto}
.login form{display:flex;flex-direction:column;gap:8px}
.login label{font-weight:600;font-size:17px;margin-top:6px}
.login input{width:100%;font-size:20px;padding:14px 16px;border-radius:12px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);outline:none}
.login .at{display:flex;align-items:center;border:1px solid var(--line);border-radius:12px;background:#0b0f15}
.login .at span{padding-left:16px;font-size:20px;color:var(--muted)}
.login .at input{border:0}
.login .btn{min-height:56px;margin-top:10px}
.loading{display:flex;flex-direction:column;align-items:center;gap:12px;max-width:440px;text-align:center;padding-top:48px}
.loading .mark{width:150px;margin:8px auto}
.loading p{margin:0}
.loading .btn{min-height:56px;min-width:180px;margin-top:6px}
.err{color:#ff7a8a;min-height:1.2em;margin:4px 0 0;font-size:15px}
.deck{display:flex;flex-direction:column;gap:10px;padding:max(10px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom));max-width:1100px;margin:0 auto;min-height:100dvh}
.dtop{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.who{display:flex;align-items:center;gap:8px;min-width:0;flex:1}
.who b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.who span{color:var(--a2,#1AA5E8);font-size:13px;font-weight:600}
.who{justify-content:flex-start;text-align:left}.who>div:last-child{min-width:0;flex:1}
.badge{width:40px;height:40px;flex:none;border-radius:10px;background:var(--a1) center/contain no-repeat;display:grid;place-items:center;font-weight:800;color:#001018}
.badge.selfie{border-radius:50%;background-size:cover}.badge.img{background-color:transparent}
.pill{display:flex;align-items:center;gap:6px;min-height:44px;padding:0 14px;border-radius:22px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);font:600 14px system-ui,sans-serif;cursor:pointer;max-width:48vw}
.pill span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill i{width:9px;height:9px;border-radius:50%;background:var(--muted);flex:none}
.pill.local i,.pill.room i{background:#3CF0B4;box-shadow:0 0 8px #3CF0B4}
.pill.warn i{background:#FFB020}
.pill.lost i{background:#FF4D5E}
.sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.icon{min-width:44px;min-height:44px;border-radius:12px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);font-size:20px;cursor:pointer}
#grid .key{font-size:12.5px;border-radius:12px}
/* Phone: the deck is exactly one screen tall and the grid takes the height that is left (8 rows of 4), so all 32 keys
   are on screen with no scrolling, with or without the stream bar. Keys never go under 44 px: on a very short screen
   (an iPhone SE with Safari's bars) the grid itself scrolls while the header and hint stay put. */
@media (max-width:640px){.dtop .pill{order:3;flex:1 0 100%;max-width:none;justify-content:center}.deck{height:100dvh;min-height:0}#grid{--cols:4!important;flex:1 1 auto;min-height:0;grid-auto-rows:minmax(44px,1fr);overflow-y:auto;overscroll-behavior:contain}#grid .key{aspect-ratio:auto;min-height:0}.stale:not([hidden])~.hint{display:none}}
@media (min-width:641px){#grid .key{font-size:15px}#grid .key small{font-size:11px}}
/* A phone on its side (over 640 px wide, at most 500 px tall): one screen tall too, 8 keys a row, so all 32 keys, the
   pill and the stream bar are on screen at once; the grid scrolls inside only when 44 px keys do not fit (Safari's bars
   on air). The sides keep clear of the notch. */
@media (min-width:641px) and (max-height:500px){.deck{height:100dvh;min-height:0;gap:6px;padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}#grid{flex:1 1 auto;min-height:0;grid-auto-rows:minmax(44px,1fr);overflow-y:auto;overscroll-behavior:contain}#grid .key{aspect-ratio:auto;min-height:0}.stale:not([hidden])~.hint{display:none}}
.hint{text-align:center;font-size:13px;margin:0}
.toast{position:fixed;z-index:60;left:50%;bottom:max(20px,env(safe-area-inset-bottom));transform:translate(-50%,30px);opacity:0;background:#151b24;border:1px solid var(--line);padding:12px 18px;border-radius:12px;font-weight:600;transition:.2s;pointer-events:none;max-width:90vw;text-align:center}
.toast.on{opacity:1;transform:translate(-50%,0)}
.toast.bad{border-color:#ff7a8a;background:#2a1419}
#grid .load{grid-column:1/-1;display:flex;flex-direction:column;align-items:center;gap:12px;text-align:center;padding:28px 8px;margin:0}
#grid .load .btn{min-width:160px}
.sheet{border:1px solid var(--line);border-radius:16px;background:var(--card);color:var(--ink);width:min(520px,calc(100vw - 24px));padding:16px}
.sheet::backdrop{background:rgba(0,0,0,.6)}
.sheethead{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.row{display:flex;align-items:center;width:100%;min-height:56px;padding:0 14px;margin:6px 0;border-radius:12px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);text-decoration:none;font:600 16px system-ui,sans-serif;cursor:pointer;text-align:left}
.room{border:1px solid var(--line);border-radius:12px;padding:12px;margin:8px 0;display:flex;align-items:center;gap:10px}
.room.mine{border-color:var(--a1,#35D0FE)}
.room.hi{box-shadow:0 0 0 2px var(--a2,#1AA5E8)}
.room div{flex:1;min-width:0}.room b{display:block}.room span{color:var(--muted);font-size:14px}
.room .btn{min-height:48px;padding:0 16px}
.room .btn.ghost{background:none;border:1px solid var(--line);color:var(--ink)}
#roomList .load{display:flex;flex-direction:column;align-items:center;gap:12px;text-align:center;padding:20px 8px}
.small{font-size:14px}
.done{text-align:center}
.done h2{margin:6px 0}
.done .btn{width:100%;min-height:56px;margin-top:8px}
.done .row{justify-content:center}
.editf{display:flex;flex-direction:column;gap:6px;max-height:75dvh;overflow:auto}
.editf label{font-weight:600;font-size:15px;margin-top:6px}
.editf input:not([type=color]):not([type=file]){width:100%;font-size:17px;padding:12px 14px;border-radius:12px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);min-height:48px}
.editf #eSegs{display:flex;flex-direction:column;gap:6px}
.ecol{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.ecol input[type=color]{width:100%;height:52px;border:1px solid var(--line);border-radius:12px;background:none;padding:4px}
.pickbtn{margin:0!important;min-height:52px;display:grid;place-items:center;border:1px dashed var(--c2);border-radius:12px;background:#0b0f15;cursor:pointer;font-weight:600}
.pickbtn input{position:absolute;width:1px;height:1px;opacity:0}
.editf .btn{min-height:56px;margin-top:10px}
.editf .keep{display:flex;align-items:center;gap:10px;min-height:44px;font-weight:500;cursor:pointer}
.editf .keep input[type=checkbox]{width:22px;height:22px;min-height:0;padding:0;margin:0;accent-color:var(--a1)}

.streambar{display:flex;align-items:center;gap:10px;margin:0;padding:10px 14px;border-radius:12px;border:1px solid var(--line);background:#0b0f15;font-weight:600;font-size:15px}
.streambar i{width:10px;height:10px;border-radius:50%;flex:none;background:#FFB020;animation:blink 1s infinite}
.streambar.onair{border-color:#ff2d55;background:color-mix(in srgb,#ff2d55 14%,#0b0f15)}
.streambar.onair i{background:#ff2d55;animation:none;box-shadow:0 0 10px #ff2d55}
.streambar.error,.streambar.login{border-color:#ff7a8a}
.streambar.error i,.streambar.login i{background:#ff7a8a;animation:none}
.stale{display:flex;align-items:center;gap:10px;margin:0;padding:8px 10px 8px 14px;border-radius:12px;border:1px solid #ff7a8a;background:#2a1419;font-size:14px;font-weight:600}
.stale span{flex:1 1 auto}
.stale .btn{flex:none;min-height:40px;padding:0 14px;font-size:14px}
#grid .key[data-id=stream].onair{box-shadow:inset 0 0 0 3px #ff2d55}
/* Live faces from the room PC's state (renderLive): the active key glows in its colour, a live / recording / muted key
   has a red frame, a moving moment a bar along the bottom, and a red line under the strips when the controller is down. */
#grid .key.on{box-shadow:inset 0 0 0 2px var(--k);background:linear-gradient(160deg,color-mix(in srgb,var(--k) 48%,#0b0f15),color-mix(in srgb,var(--k) 16%,#0b0f15) 75%)}
#grid .key.on small{color:var(--k);font-weight:700}
#grid .key.hot{box-shadow:inset 0 0 0 3px #FF4D5E}
#grid .key.hot b,#grid .key.hot small{color:#FF4D5E;font-weight:700}
#grid .key.airbar::after{content:"";position:absolute;left:0;bottom:0;height:4px;width:calc(var(--bar,0) * 100%);background:#3CF0B4}
#grid.nolink .key::before{box-shadow:0 3px 0 #FF4D5E}
/* The Stream Deck look: the canvas is the face (keyface.js drawLive); the words stay for screen readers. */
#grid.sd .key{padding:0;border:0;background:#070B12;box-shadow:none;overflow:hidden}
#grid.sd .key::before,#grid.sd .key::after{display:none}
#grid.sd .key canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
#grid.sd .key b,#grid.sd .key small{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
#grid.sd .key.nocam{animation:none}   /* the face flashes itself (paintFaces) */
#grid .key.endhold::after,#grid.sd .key.endhold::after{display:block;content:"";position:absolute;left:0;right:0;bottom:0;width:auto;height:8px;background:#ff2d55;transform-origin:left;animation:endhold 1.5s linear forwards;pointer-events:none}   /* Stream held on air: the bar fills as the live's end comes */
@keyframes endhold{from{transform:scaleX(0)}to{transform:scaleX(1)}}
#grid .key[data-id=question],#grid .key[data-id=gift],#grid .key[data-id=stream].copywait{touch-action:none}   /* their 3-second holds must not turn into a scroll */
#grid .key.longhold::after,#grid.sd .key.longhold::after{display:block;content:"";position:absolute;left:0;right:0;bottom:0;width:auto;height:8px;background:#FFB020;transform-origin:left;animation:endhold 2.3s linear forwards;pointer-events:none}   /* Question and Gift held (and Stream while the copy flow waits): full at 3 s */
#grid .key.pending{outline:3px dashed #FFB020;outline-offset:-5px}   /* an on/off key waiting for the room PC to show the press */
#grid.sd .key.pending::before{display:block;content:"";position:absolute;inset:3px;height:auto;z-index:1;background:none;border:3px dashed #FFB020;border-radius:inherit;pointer-events:none}   /* the canvas face covers the outline: over it */
#grid .key.miss,#grid .key.miss.on,#grid .key.miss.hot{box-shadow:inset 0 0 0 3px #ff7a8a}   /* Not delivered: over the live faces */
#grid.sd .key.miss::after{display:block;content:"";position:absolute;inset:0;width:auto;height:auto;background:none;border-radius:inherit;box-shadow:inset 0 0 0 3px #ff7a8a;pointer-events:none}   /* after the canvas, so over the face */
/* The pre-show guard: the stream bar shows the seconds to the cut to camera for the whole stay on the card (amber from a
   minute out), the Pre-show / Break key joins in from a minute out, and both go red with NO CAMERA when the room PC has
   no camera picture to cut to. */
#grid .key.cut{box-shadow:inset 0 0 0 3px #FFB020}
#grid .key.cut small{color:#FFB020;font-weight:700}
#grid .key.nocam{box-shadow:inset 0 0 0 3px #ff2d55;animation:flash 1s steps(2,jump-none) infinite}
#grid .key.nocam small{color:#ff7a8a;font-weight:700}
.streambar.cut{border-color:#FFB020}
.streambar.cut i{background:#FFB020;box-shadow:none;animation:blink 1s infinite}
.streambar.nocam{border-color:#ff2d55;background:#2a1419}
.streambar.nocam i{background:#ff2d55;box-shadow:none;animation:blink .6s infinite}
@keyframes blink{50%{opacity:.25}}
@keyframes flash{50%{background:#3a0e16}}
@media (prefers-reduced-motion:reduce){.streambar i,.streambar.cut i,.streambar.nocam i,#grid .key.nocam{animation:none}}
/* The Program monitor: the show as OBS puts it out (monitor.js). On a phone a strip above the keys, the picture on the
   left and the scene, ON AIR and REC beside it; from 760 px a column beside the keys. Tap ⤢ for full screen. */
.pgm{display:grid;grid-template-columns:auto minmax(0,1fr);gap:10px;align-items:start;flex:none}
.pgmbox{position:relative;height:clamp(150px,26dvh,260px);aspect-ratio:9/16;border-radius:10px;overflow:hidden;border:1px solid var(--line);background:#07060D}
@media (max-width:640px){.deck:has(#streamBar:not([hidden]),#stale:not([hidden])) .pgm:not(.full) .pgmbox{height:clamp(120px,20dvh,260px)}}   /* a phone with the stream bar or a notice up: the 32 keys keep 44 px without scrolling */
.pgmbox canvas,.pgmbox iframe{position:absolute;left:0;top:0;border:0;pointer-events:none}
.pgmbox canvas{width:100%;height:100%}
.pgmbox iframe{width:1080px;height:1920px;transform-origin:0 0;background:transparent}
.pgmshot{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#000}
.pgm.real .pgmbg,.pgm.real .pgmov,.pgm.real .pgmintro{visibility:hidden}
.pgm.cover .pgmov{visibility:hidden}   /* the opener and the We're back card: OBS shows no graphics over them */
.pgmback{position:absolute;left:0;right:0;top:44%;margin:0;text-align:center;font-weight:700;font-size:clamp(15px,4.5vmin,44px);line-height:1;color:#fff;text-shadow:0 2px 12px rgba(0,0,0,.6)}
.pgmmic{position:relative;display:inline-flex;align-items:center;width:84px;height:12px;border-radius:3px;background:#10161f;border:1px solid var(--line);overflow:hidden}
.pgmmic i{position:absolute;left:0;top:0;bottom:0;width:0;background:linear-gradient(90deg,#3CF0B4 0 70%,#F5C84B 70% 88%,#FF4D5E 88%);background-size:84px 100%;transition:width .15s}
.pgmmic em{position:relative;width:100%;text-align:center;font:700 9px/1 ui-monospace,monospace;font-style:normal;letter-spacing:.06em;color:#FF4D5E}
.pgmnote{position:absolute;left:8px;right:8px;bottom:8px;margin:0;padding:6px 8px;border-radius:8px;background:rgba(3,5,9,.7);font-size:12px;text-align:center}
.pgmhead{display:flex;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;order:2}
.pgmscene{font-size:16px}
.pgmbadge{font:700 12px/1 ui-monospace,monospace;letter-spacing:.08em;padding:5px 8px;border-radius:6px;background:#FF4D5E;color:#fff}
.pgmbadge.rec{background:#2a1419;color:#FF4D5E;border:1px solid #FF4D5E}
.pgmfull{min-width:44px;min-height:44px;border-radius:12px;border:1px solid var(--line);background:#0b0f15;color:var(--ink);font-size:20px;cursor:pointer}
.pgm.full{position:fixed;inset:0;z-index:50;background:#000;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:max(10px,env(safe-area-inset-top)) 10px max(10px,env(safe-area-inset-bottom))}
.pgm.full .pgmhead{order:0;flex-direction:row;align-items:center;flex-wrap:wrap}
.pgm.full .pgmbox{height:auto;width:min(100%,calc((100dvh - 90px) * 9 / 16));cursor:zoom-out}
/* Full screen keeps the stream bar (the pre-show countdown, NO CAMERA) in view under the picture. */
html.pgmfull #streamBar:not([hidden]){position:fixed;z-index:55;left:12px;right:12px;bottom:max(12px,env(safe-area-inset-bottom));margin:0}
html.pgmfull .deck:has(#streamBar:not([hidden])) .pgm.full{padding-bottom:calc(78px + env(safe-area-inset-bottom))}
html.pgmfull .deck:has(#streamBar:not([hidden])) .pgm.full .pgmbox{width:min(100%,calc((100dvh - 160px) * 9 / 16))}
#pgmBtn[aria-pressed=true]{border-color:var(--a1,#35D0FE);color:var(--a1,#35D0FE)}
@media (min-width:760px) and (min-height:501px){
  .deck.haspgm{display:grid;grid-template-columns:minmax(220px,28%) minmax(0,1fr);grid-template-areas:"top top" "bar bar" "stale stale" "pgm grid" "hint hint";column-gap:16px;align-content:start}
  .deck.haspgm>.dtop{grid-area:top}.deck.haspgm>#streamBar{grid-area:bar}.deck.haspgm>#stale{grid-area:stale}.deck.haspgm>#grid{grid-area:grid;align-content:start}.deck.haspgm>.hint{grid-area:hint}
  .deck.haspgm>.pgm:not(.full){grid-area:pgm;display:flex;flex-direction:column;position:sticky;top:10px}
  .deck.haspgm>.pgm:not(.full) .pgmhead{order:0;flex-direction:row;align-items:center;flex-wrap:wrap;width:100%}
  .deck.haspgm>.pgm:not(.full) .pgmbox{height:auto;width:100%}
  .deck.haspgm>.pgm:not(.full) .pgmfull{margin-left:auto}
}
/* A phone on its side: the picture as tall as the keys, its scene and badges beside it, in a column left of the keys
   (the stream bar's row and the notice's take no room while hidden). */
@media (min-width:641px) and (max-height:500px){
  .deck.haspgm{display:grid;grid-template-columns:clamp(200px,30vw,320px) minmax(0,1fr);grid-template-rows:auto auto auto minmax(0,1fr) auto;grid-template-areas:"top top" "bar bar" "stale stale" "pgm grid" "hint hint";gap:0 12px}
  .deck.haspgm>:is(#streamBar,#stale,.pgm,#grid,.hint){margin-top:6px}
  .deck.haspgm>.dtop{grid-area:top}.deck.haspgm>#streamBar{grid-area:bar}.deck.haspgm>#stale{grid-area:stale}.deck.haspgm>#grid{grid-area:grid}.deck.haspgm>.hint{grid-area:hint}
  .deck.haspgm>.pgm:not(.full){grid-area:pgm;container-type:size;min-height:0}
  .deck.haspgm>.pgm:not(.full) .pgmbox{height:min(100cqh,(100cqw - 96px) * 16 / 9)}
}
