/* Beauty Pageant UI (pageant-ui.js, pageant DESIGN §9). Every rule is scoped under #pageant-*, body.in-pageant or the
   Workshop session mounts (#build-session-strip, #build-session-panel inside #builder-panel[data-session]).
   Look: theme.css tokens, the battle HUD's ink-bordered navy plates with gilt hairlines, the 9-slice gilt frame for
   dialogs and a parchment score card after the UI kit's Pageant card (ui-kit/menus.css .cu-score v2). Text is 12px or
   larger everywhere (Pixelify Sans; small labels are bold uppercase Pixelify, Jacquard 12 only for 28px+ headings).
   Z ladder: HUD 10 · cascade 41 · card 42 · setup and results 40/43 · sheet 45 · refusal and toast 60 · pause 95 · help 96. */

/* ---------- the Aerie chrome gives way while a pageant runs (same list as body.in-conquest, plus the flight pad) ---------- */
body.in-pageant>header,body.in-pageant .telemetry,body.in-pageant .compass,body.in-pageant .travel,body.in-pageant .keys,body.in-pageant #message,body.in-pageant #target-cue,body.in-pageant footer{display:none!important}
body.in-pageant #look-panel,body.in-pageant #controls-panel,body.in-pageant #shell-confirm{z-index:96}

/* ---------- shared pieces ---------- */
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#pageant-refusal,#pageant-toast,#build-session-strip,#build-session-panel) [hidden]{display:none!important}
#pageant-hud[hidden],#pageant-cascade[hidden]{display:none!important}
:is(#pageant-panel,#pageant-sheet,#pageant-results,#pageant-pause,#pageant-help)[hidden]:not(.shell-out){display:none!important}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#build-session-strip,#build-session-panel){font-family:var(--ui-body);color:var(--ui-parchment);font-variant-ligatures:none;font-variant-numeric:tabular-nums;-webkit-tap-highlight-color:transparent;box-sizing:border-box}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#build-session-strip,#build-session-panel) *{box-sizing:border-box}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help) :is(h2,h3,h4,p,ul,ol,figure){margin:0}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#build-session-strip,#build-session-panel) :is(ul,ol){list-style:none;padding:0}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#build-session-strip,#build-session-panel) small{font-size:12px}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results,#pageant-pause,#pageant-help,#build-session-strip,#build-session-panel) .pg-gl{display:block;flex:none;width:var(--gl,16px);height:var(--gl,16px)}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) :focus-visible{outline:3px solid var(--ui-gold-hi);outline-offset:2px}
/* style.css styles every <header> as the Aerie's fixed top bar: ours are ordinary blocks. */
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) header{display:block;position:static;top:auto;left:auto;right:auto;justify-content:normal;pointer-events:auto;background:none;border:0;box-shadow:none;padding:0;height:auto}
.pg-frame{border:12px solid transparent;border-image:var(--ui-frame) 6 fill/12px/0 stretch;background:none;box-shadow:var(--ui-drop)}
:is(#pageant-panel,#pageant-results,#pageant-pause,#pageant-help,#pageant-cascade) .pg-eyebrow{display:flex;align-items:center;gap:6px;font:700 12px/1.3 var(--ui-body);letter-spacing:.12em;text-transform:uppercase;color:var(--ui-gold);--gl:14px}
:is(#pageant-panel,#pageant-results,#pageant-pause,#pageant-help) h2{margin:2px 0 6px;font:400 40px/1 var(--ui-display);letter-spacing:.02em;color:var(--ui-gold-hi);text-shadow:3px 3px 0 var(--ui-ink)}
/* Plated buttons (raised navy, ink border, gilt on hover) and the gold primary. */
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:36px;padding:7px 12px;font:14px/1.1 var(--ui-body);color:var(--ui-parchment);border:2px solid var(--ui-ink);border-radius:0;background:linear-gradient(var(--ui-raise) 0 50%,var(--ui-raise-lo) 50%);box-shadow:inset 0 1px 0 #ffffff22,2px 2px 0 var(--ui-ink);text-shadow:1px 1px 0 var(--ui-ink);cursor:pointer;touch-action:manipulation}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) button:hover:not(:disabled){border-color:var(--ui-gold);color:var(--ui-gold-hi);background:linear-gradient(#34497a 0 50%,#2a3b63 50%)}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) button:active:not(:disabled){transform:translate(1px,1px);box-shadow:inset 0 2px 0 #0000002e,1px 1px 0 var(--ui-ink)}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) .pg-primary,:is(#pageant-hud,#pageant-panel) .pg-seg button[aria-pressed=true],#pageant-hud .pg-done[aria-pressed=true]{color:var(--ui-ink);font-weight:700;text-shadow:1px 1px 0 #fff3cd80;background:linear-gradient(var(--ui-gold-hi) 0 3px,var(--ui-gold) 3px 60%,#e3b066 60% calc(100% - 3px),var(--ui-gold-lo) calc(100% - 3px))}
:is(#pageant-hud,#pageant-panel,#pageant-sheet,#pageant-card,#pageant-results,#pageant-pause,#pageant-help) .pg-primary:hover:not(:disabled),#pageant-panel .pg-seg button[aria-pressed=true]:hover{color:var(--ui-ink);border-color:var(--ui-parchment);background:linear-gradient(#fff3cd 0 3px,var(--ui-gold-hi) 3px 60%,var(--ui-gold) 60% calc(100% - 3px),var(--ui-gold-lo) calc(100% - 3px))}
:is(#pageant-hud,#pageant-card) .pg-key{display:inline-block;flex:none;font:700 12px/1 var(--ui-body);color:var(--ui-ink);background:var(--ui-parchment);padding:1px 4px;box-shadow:1px 1px 0 var(--ui-ink);text-shadow:none;margin-left:2px}
:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-cascade,#pageant-results) .pg-dot{display:block;flex:none;width:12px;height:12px;background:var(--c,#f4c67b);border:2px solid var(--ui-ink);box-shadow:0 0 0 1px #fff3cd55}
:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-results,#build-session-strip) .pg-chip{position:relative;display:inline-grid;place-items:center;flex:none;width:var(--chip,30px);height:var(--chip,30px);background:#1b2442;border:2px solid var(--ui-ink);color:var(--ui-gold);box-shadow:inset 0 0 0 1px #f4c67b44}
:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-results,#build-session-strip) .pg-chip-ico{display:block;width:62%;height:62%}
:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-results,#build-session-strip,#build-session-panel) .pg-chip-ico .pg-gl,:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-results,#build-session-strip,#build-session-panel) .pg-tk .pg-gl{width:100%;height:100%}
:is(#pageant-hud,#pageant-sheet,#pageant-card,#pageant-results,#build-session-strip) .pg-chip .pg-tk{position:absolute;right:-5px;bottom:-5px;width:14px;height:14px;padding:1px;background:var(--ui-ink);border-radius:50%}
.pg-chip[data-state=met]{border-color:var(--ui-ink)!important;box-shadow:inset 0 0 0 2px var(--ui-good)!important}.pg-chip[data-state=met] .pg-tk{color:var(--ui-good)}
.pg-chip[data-state=partial] .pg-tk{color:var(--ui-gold)}.pg-chip[data-state=missing]{color:var(--ui-parchment-dim)!important}.pg-chip[data-state=missing] .pg-tk{color:#8e8aa8}
/* theme rows (checklist card, sheet, Judge's notes) */
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme{display:grid;grid-template-columns:24px minmax(0,1fr) 16px;column-gap:8px;align-items:center;padding:5px 0;border-bottom:1px solid #f4c67b26}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme-ico{grid-row:span 2;align-self:start;width:24px;height:24px;color:var(--ui-gold)}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme>b{font-size:14px;line-height:1.2;min-width:0}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme>.pg-tk{width:16px;height:16px}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme>small{grid-column:2/4;font-size:12px;line-height:1.3;color:var(--ui-parchment-dim)}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme[data-state=met] .pg-tk{color:var(--ui-good)}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme[data-state=partial] .pg-tk{color:var(--ui-gold)}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme[data-state=missing] .pg-tk{color:#8e8aa8}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-theme.fresh{animation:pg-fresh 1.4s ease-out}
@keyframes pg-fresh{0%{background:#f4c67b66}100%{background:transparent}}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-basics li{display:flex;gap:6px;align-items:flex-start;padding:2px 0;font-size:13px;line-height:1.3}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-basics .pg-tk{width:14px;height:14px;margin-top:1px;flex:none;color:#8e8aa8}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-basics li[data-ok=true] .pg-tk{color:var(--ui-good)}
:is(#pageant-hud,#pageant-sheet,#build-session-panel) .pg-basics li[data-ok=false]{color:var(--ui-parchment-dim)}
:is(#pageant-hud,#pageant-sheet) .pg-pbar,#pageant-hud .pg-peek .pg-pbar{display:block;height:6px;background:#1b2442;border:1px solid var(--ui-ink);overflow:hidden}
:is(#pageant-hud,#pageant-sheet) .pg-pbar em{display:block;height:100%;background:var(--ui-gold);transition:width .4s}
/* roster rows (desktop panel and the Plots sheet) */
:is(#pageant-hud,#pageant-sheet) .pg-rows button{width:100%;min-height:26px;display:grid;grid-template-columns:12px minmax(0,1fr) 48px 14px;gap:8px;align-items:center;padding:3px 6px;text-align:left;background:none;border:0;border-bottom:1px solid #f4c67b1f;box-shadow:none;font-size:13px}
:is(#pageant-hud,#pageant-sheet) .pg-rows button>b{font-weight:400;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
:is(#pageant-hud,#pageant-sheet) .pg-rows button[aria-current=true]{background:#f4c67b2e;box-shadow:inset 3px 0 0 var(--ui-gold)}
:is(#pageant-hud,#pageant-sheet) .pg-rows .pg-ok{width:14px;height:14px;color:var(--ui-good)}

/* ---------- SETUP (#pageant-panel) ---------- */
#pageant-panel{position:fixed;inset:0;z-index:40;display:grid;place-items:center;padding:calc(12px + env(safe-area-inset-top,0px)) calc(12px + env(safe-area-inset-right,0px)) calc(12px + env(safe-area-inset-bottom,0px)) calc(12px + env(safe-area-inset-left,0px));background:linear-gradient(#1b244255,#1b2442aa)}
#pageant-panel .pageant-dialog{display:grid;grid-template-columns:minmax(150px,220px) minmax(0,1fr);gap:20px;align-items:start;width:min(900px,100%);max-height:calc(100dvh - 24px);overflow:auto;overscroll-behavior:contain;background:var(--ui-panel-solid)}
#pageant-panel .pg-art{position:sticky;top:0;border:3px solid var(--ui-ink);box-shadow:inset 0 0 0 2px var(--ui-gold-lo),var(--ui-drop);transform:rotate(-1.2deg);background:#1b2442;line-height:0}
#pageant-panel .pg-art img{display:block;width:100%;height:auto;aspect-ratio:3/4}
#pageant-panel .pg-pitch{max-width:72ch;font-size:14px;line-height:1.4;color:var(--ui-parchment-dim);margin-bottom:12px}
#pageant-panel .pg-setup-body{display:flex;flex-direction:column;gap:12px}
#pageant-panel .pg-setup-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
#pageant-panel .pg-label{display:block;margin:0 0 5px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold)}
#pageant-panel .pg-seg{display:flex;flex-wrap:wrap;gap:6px}
#pageant-panel .pg-seg button{flex:1 1 0;min-width:0;min-height:44px;flex-direction:column;gap:2px;padding:6px 8px}
#pageant-panel .pg-seg button small{font-size:12px;opacity:.85;font-weight:400}
#pageant-panel .pg-seed-row{display:flex;gap:8px;align-items:stretch}
#pageant-panel #pg-seed{width:140px;min-height:44px;padding:6px 10px;font:16px var(--ui-body);color:var(--ui-parchment);background:#16203b;border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px #f4c67b55;border-radius:0}
#pageant-panel #pg-dice{--gl:18px;min-height:44px}
#pageant-panel #pg-dice.roll .pg-gl{animation:pg-roll .5s}
@keyframes pg-roll{50%{transform:rotate(180deg) scale(1.2)}}
#pageant-panel .pg-setup-summary{font-size:13px;line-height:1.35;color:var(--ui-parchment-dim);padding:8px 10px;border:2px solid var(--ui-ink);background:#16203bcc}
#pageant-panel .pg-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:14px}
#pageant-panel .pg-actions button{min-height:48px;padding:10px 20px;font-size:16px}
@media(max-width:760px){#pageant-panel .pageant-dialog{grid-template-columns:1fr;gap:10px}#pageant-panel .pg-art{display:none}}
@media(max-width:600px){#pageant-panel h2{font-size:32px}#pageant-panel .pg-setup-grid{grid-template-columns:1fr}#pageant-panel .pg-pitch{font-size:13px}#pageant-panel .pg-actions{position:sticky;bottom:-12px;margin:10px -12px -12px;padding:10px 12px;background:var(--ui-panel-solid);border-top:2px solid var(--ui-ink)}#pageant-panel .pg-actions button{flex:1}}
@media(max-height:500px){#pageant-panel .pageant-dialog{grid-template-columns:150px minmax(0,1fr)}#pageant-panel .pg-art{display:block}#pageant-panel h2{font-size:30px}#pageant-panel .pg-pitch{display:none}#pageant-panel .pg-setup-grid{grid-template-columns:repeat(2,minmax(0,1fr))}#pageant-panel .pg-actions{position:sticky;bottom:-12px;margin:8px 0 -12px;padding:8px 0;background:var(--ui-panel-solid)}}

/* ---------- HUD (#pageant-hud) ---------- */
#pageant-hud{position:fixed;inset:0;z-index:10;pointer-events:none;opacity:0;transition:opacity .6s cubic-bezier(.2,.8,.2,1);--top:calc(env(safe-area-inset-top,0px) + 12px);--edge-l:calc(16px + env(safe-area-inset-left,0px));--edge-r:calc(16px + env(safe-area-inset-right,0px));--bottom:calc(16px + env(safe-area-inset-bottom,0px))}
#pageant-hud.in{opacity:1}
#pageant-hud>*{position:absolute;pointer-events:auto}
#pageant-hud :is(.pg-clock,.pg-check,.pg-roster,.pg-peek,.pg-wait,.pg-ready,.pg-bar){background:var(--ui-panel);border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px #f4c67b55,3px 3px 0 #231a2e88}
#pageant-hud h3{display:flex;align-items:center;gap:6px;margin:0 0 4px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold);--gl:14px}
#pageant-hud h3 small,#pageant-hud h3 b{margin-left:auto;letter-spacing:0;text-transform:none;color:var(--ui-parchment-dim);font-weight:400}
/* clock pill: phase, mm:ss, thin progress bar; red pulse in the last minute */
#pageant-hud .pg-clock{top:var(--top);left:50%;transform:translateX(-50%);width:220px;height:44px;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 14px;overflow:hidden}
#pageant-hud .pg-phase{font:700 12px/1 var(--ui-body);letter-spacing:.12em;text-transform:uppercase;color:var(--ui-gold);white-space:nowrap}
#pageant-hud .pg-time{font:700 26px/1 var(--ui-body);letter-spacing:.02em;color:var(--ui-parchment);text-shadow:2px 2px 0 var(--ui-ink)}
#pageant-hud .pg-prog{position:absolute;left:0;right:0;bottom:0;height:3px;background:#1b2442}
#pageant-hud .pg-prog em{display:block;height:100%;background:var(--ui-gold);transition:width .5s linear}
#pageant-hud.late .pg-clock{box-shadow:inset 0 0 0 1px var(--ui-bad),3px 3px 0 #231a2e88}
#pageant-hud.late .pg-time,#pageant-hud.late .pg-phase{color:var(--ui-bad)}
#pageant-hud.late .pg-prog em{background:var(--ui-bad)}
@media(prefers-reduced-motion:no-preference){#pageant-hud.late .pg-clock{animation:pg-pulse 1s steps(2,end) infinite}#pageant-hud.final .pg-clock{animation-duration:.5s}}
@keyframes pg-pulse{50%{background:#6b2430f2}}
#pageant-hud .pg-pause{top:var(--top);right:var(--edge-r);width:44px;height:44px;min-height:44px;padding:0;font-weight:700;letter-spacing:-.1em}
/* checklist card (top left) */
#pageant-hud .pg-check{top:var(--top);left:var(--edge-l);width:280px;max-height:calc(100% - 200px);overflow:auto;padding:8px 10px 10px}
#pageant-hud .pg-basics-h{margin-top:8px}
#pageant-hud .pg-chips{display:none}
/* roster (right) */
#pageant-hud .pg-roster{top:calc(var(--top) + 54px);right:var(--edge-r);width:220px;max-height:calc(100% - 160px);overflow:auto;padding:8px 6px}
#pageant-hud .pg-roster h3{padding:0 4px}
/* peek: the builder you are watching (bottom left, above the bar row) */
#pageant-hud .pg-peek{left:var(--edge-l);bottom:calc(var(--bottom) + 64px);width:290px;padding:10px 12px;display:flex;flex-direction:column;gap:6px}
#pageant-hud .pg-peek header{display:flex;align-items:center;gap:8px}
#pageant-hud .pg-peek header>div{display:flex;flex-direction:column;min-width:0}
#pageant-hud .pg-peek header b{font-size:16px}
#pageant-hud .pg-peek header small{color:var(--ui-parchment-dim)}
#pageant-hud .pg-peek .pg-badge{margin-left:auto;display:flex;align-items:center;gap:4px;font-size:12px;color:var(--ui-good);--gl:14px}
#pageant-hud .pg-castle-name{font:400 28px/1 var(--ui-display);color:var(--ui-gold-hi);text-shadow:2px 2px 0 var(--ui-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#pageant-hud .pg-peek-stats{display:flex;justify-content:space-between;font-size:13px;color:var(--ui-parchment-dim)}
#pageant-hud .pg-peek-ticks{display:flex;gap:8px;--chip:28px}
#pageant-hud .pg-peek-home{align-self:flex-start;min-height:36px}
/* judging wait + all-done offer */
#pageant-hud :is(.pg-wait,.pg-ready){top:calc(var(--top) + 56px);left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:10px;padding:8px 14px;white-space:nowrap}
#pageant-hud .pg-wait small{color:var(--ui-parchment-dim)}
#pageant-hud .pg-spin{width:14px;height:14px;border:3px solid var(--ui-gold);border-right-color:transparent;border-radius:50%;animation:pg-spin 1s linear infinite}
@keyframes pg-spin{to{transform:rotate(360deg)}}
/* action bar */
#pageant-hud .pg-bar{bottom:var(--bottom);left:50%;transform:translateX(-50%);display:flex;gap:6px;padding:6px}
#pageant-hud .pg-bar button{min-height:44px;padding:8px 14px;white-space:nowrap}
#pageant-hud .pg-phone{display:none!important}
#pageant-hud.carding .pg-bar{display:none}
/* phases */
#pageant-hud .pg-bar [data-k]{display:none}
#pageant-hud[data-phase=build] .pg-bar [data-k=build],#pageant-hud[data-phase=reveal] .pg-bar [data-k=reveal]{display:inline-flex}
#pageant-hud:not([data-phase=build]):not([data-phase=reveal]) .pg-bar,#pageant-hud:not([data-phase=build]):not([data-phase=intro]) :is(.pg-check,.pg-chips),#pageant-hud:not([data-phase=build]) .pg-roster,#pageant-hud:is([data-phase=podium],[data-phase=results]) :is(.pg-clock,.pg-pause){display:none!important}

/* ---------- sheets (#pageant-sheet: theme cards, plots, more actions) ---------- */
#pageant-sheet{position:fixed;inset:0;z-index:45;display:flex;align-items:center;justify-content:center;background:#1b244266;padding:calc(12px + env(safe-area-inset-top,0px)) 12px calc(12px + env(safe-area-inset-bottom,0px))}
#pageant-sheet .pg-sheet-card{width:min(420px,100%);max-height:100%;overflow:auto;padding:12px 14px 14px;background:var(--ui-panel-solid);border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px #f4c67b66,var(--ui-drop)}
#pageant-sheet header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
#pageant-sheet h3{font:400 30px/1 var(--ui-display);color:var(--ui-gold-hi);text-shadow:2px 2px 0 var(--ui-ink)}
#pageant-sheet h4{margin:10px 0 4px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold)}
#pageant-sheet .pg-close{width:44px;height:44px;padding:0;font-size:22px}
#pageant-sheet .pg-rows button{min-height:44px;font-size:14px}
#pageant-sheet .pg-more{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#pageant-sheet .pg-more button{min-height:48px;font-size:15px}
@media(max-width:960px) and (min-height:501px){#pageant-sheet{align-items:flex-end;padding:0}#pageant-sheet .pg-sheet-card{width:100%;max-height:72dvh;padding-bottom:calc(14px + env(safe-area-inset-bottom,0px));animation:pg-sheet-up .28s cubic-bezier(.2,.8,.2,1)}}
@media(max-height:500px){#pageant-sheet{justify-content:flex-end;align-items:stretch;padding:0}#pageant-sheet .pg-sheet-card{width:min(400px,60vw);max-height:none;height:100%;padding-right:calc(14px + env(safe-area-inset-right,0px));animation:pg-sheet-in .28s cubic-bezier(.2,.8,.2,1)}}
@keyframes pg-sheet-up{from{transform:translateY(40px);opacity:0}}
@keyframes pg-sheet-in{from{transform:translateX(40px);opacity:0}}

/* ---------- SCORE CARD (#pageant-card): parchment, after the UI kit's .cu-score ---------- */
#pageant-card{position:fixed;z-index:42;right:calc(24px + env(safe-area-inset-right,0px));top:50%;transform:translateY(-50%);width:360px;max-height:calc(100dvh - 136px);display:flex;flex-direction:column;gap:8px;perspective:900px}
#pageant-card .pg-score{--accent:var(--ui-stone);position:relative;display:flex;flex-direction:column;min-height:0;overflow:auto;color:var(--ui-ink);background:var(--ui-parchment);border:3px solid var(--ui-ink);box-shadow:inset 0 0 0 3px var(--accent),6px 6px 0 #231a2e99;transform-origin:50% 100%}
#pageant-card .pg-score[data-rank="1"]{--accent:var(--ui-gold)}#pageant-card .pg-score[data-rank="2"]{--accent:#bcc8cc}#pageant-card .pg-score[data-rank="3"]{--accent:#d49a6a}
#pageant-card .pg-score.pre{opacity:0;transform:rotateY(80deg) translateY(10px)}
#pageant-card .pg-score.flip{transition:transform .6s cubic-bezier(.2,.9,.3,1.2),opacity .3s}
#pageant-card .pg-ribbon{display:flex;align-items:baseline;gap:8px;padding:6px 12px;background:var(--accent);border-bottom:3px solid var(--ui-ink);font:700 12px/1 var(--ui-body);letter-spacing:.12em;text-transform:uppercase}
#pageant-card .pg-rank{font:400 32px/.9 var(--ui-display);letter-spacing:0;text-transform:none}
#pageant-card .pg-of{margin-left:auto;font-size:12px;letter-spacing:.06em}
#pageant-card .pg-who{display:flex;align-items:center;gap:10px;padding:10px 12px 4px}
#pageant-card .pg-who .pg-dot{width:20px;height:20px}
#pageant-card .pg-who>div{display:flex;flex-direction:column;min-width:0}
#pageant-card .pg-castle{font:400 30px/1 var(--ui-display);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#pageant-card .pg-builder{font-size:13px;color:#5d4a5f}
#pageant-card .pg-total{display:flex;align-items:baseline;gap:6px;padding:2px 12px 6px;border-bottom:2px dashed #23192e33}
#pageant-card .pg-total>span{margin-right:auto;font:700 12px/1 var(--ui-body);letter-spacing:.12em;text-transform:uppercase}
#pageant-card .pg-total-v{font:700 36px/1 var(--ui-body)}
#pageant-card .pg-total small{font-size:13px;color:#5d4a5f}
#pageant-card .pg-grade{font:700 12px/1 var(--ui-body);font-style:normal;letter-spacing:.08em;text-transform:uppercase;color:#7a4b14;margin-left:6px}
/* r34pre4 (ja reveal card at 390x844: '17.5/20' broke over two lines in its 6.6ch column, the ch of the Japanese font): one grid
   for the four rows (subgrid), the score column as wide as its widest score (at least 6.6ch), scores never wrap; the bars stay
   the same length; a browser without subgrid keeps the old per-row columns */
#pageant-card .pg-crit{display:grid;grid-template-columns:20px minmax(0,1fr) minmax(6.6ch,max-content);gap:7px 8px;padding:8px 12px}
#pageant-card .pg-crit li{grid-column:1/-1;display:grid;grid-template-columns:20px minmax(0,1fr) 6.6ch;grid-template-columns:subgrid;gap:8px;align-items:center;font-size:13px}
#pageant-card .pg-crit-ico{width:20px;height:20px;color:#a65a86}
#pageant-card .pg-lab{display:flex;flex-direction:column;gap:3px;min-width:0}
#pageant-card .pg-meter{display:block;height:9px;background:#d9cba8;border:1px solid #23192e88}
#pageant-card .pg-meter em{display:block;width:0;height:100%;background:var(--pip,#4f7048)}
#pageant-card .pg-crit li[data-cat=feasibility]{--pip:#4f7048}#pageant-card .pg-crit li[data-cat=pathfinding]{--pip:#267e8a}#pageant-card .pg-crit li[data-cat=beauty]{--pip:#a65a86}#pageant-card .pg-crit li[data-cat=themes]{--pip:#b98a45}
#pageant-card .pg-num{text-align:right;font-weight:700;white-space:nowrap}
#pageant-card .pg-hl{display:flex;flex-direction:column;gap:3px;padding:2px 12px 6px;font-size:13px;line-height:1.3;color:#4a3d52}
#pageant-card .pg-hl li{display:grid;grid-template-columns:1.4ch minmax(0,1fr);gap:4px}
#pageant-card .pg-hl li[data-m="✓"] b{color:#3f7a3c}#pageant-card .pg-hl li[data-m="✗"] b{color:#b03a3a}
#pageant-card .pg-ticks{display:flex;gap:10px;padding:2px 12px 8px;--chip:28px}
#pageant-card .pg-why{flex:none;padding:4px 12px 6px;font-size:13px}#pageant-card .pg-why h4{margin:0 0 4px;font:700 12px/1 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:#5d4a5f}#pageant-card .pg-why li{display:flex;gap:8px;padding:2px 0;line-height:1.3}#pageant-card .pg-why li>b{min-width:3.2em;text-align:right;color:#b03a3a}#pageant-card .pg-why li[data-kind=won]>b{color:#2f7a3a}#pageant-card .pg-why small{display:block;font-size:12px;color:#5d4a5f}#pageant-card .pg-why .pg-tip{font-style:italic;color:#3d5a73;padding-left:2px}#pageant-card .pg-why .pg-tip>i{font-style:normal;font-weight:700;color:#2f6a8a;margin-right:2px}
#pageant-card .pg-details{padding:0 12px 10px;font-size:13px}
#pageant-card .pg-details summary{cursor:pointer;min-height:32px;display:flex;align-items:center;font:700 12px/1 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:#5d4a5f}
#pageant-card .pg-details h4{margin:8px 0 2px;font-size:13px;display:flex;justify-content:space-between}
#pageant-card .pg-details li{padding:2px 0;line-height:1.3}
#pageant-card .pg-details li span{display:block;font-size:12px;color:#5d4a5f}
/* r34pre4: a Why line whose reason is not in the language reads "name · Tip …" on one line; in Details the tip under a name whose
   reason is not in the language is styled as advice like the Why tips */
#pageant-card .pg-why .pg-tip.pg-tip-in{display:inline;padding-left:0}#pageant-card .pg-why .pg-tip.pg-tip-in::before{content:" · ";font-style:normal;color:#5d4a5f}
#pageant-card .pg-details li .pg-tip{font-style:italic;color:#3d5a73}#pageant-card .pg-details li .pg-tip>i{font-style:normal;font-weight:700;color:#2f6a8a;margin-right:2px}
#pageant-card .pg-details li[data-state=fail]>b{color:#b03a3a}
#pageant-card .pg-stamp{position:absolute;right:10px;top:46px;transform:rotate(12deg) scale(2.4);opacity:0;font:700 13px/1 var(--ui-body);letter-spacing:.12em;text-transform:uppercase;padding:6px 8px;color:#a3263a;border:3px double #a3263a;background:#fff3cdcc;pointer-events:none}
#pageant-card .pg-score.stamped .pg-stamp{opacity:1;transform:rotate(12deg) scale(1);transition:transform .28s cubic-bezier(.5,1.8,.5,1),opacity .1s}
#pageant-card .pg-card-actions{display:flex;gap:8px;justify-content:flex-end}
#pageant-card .pg-card-actions button{min-height:44px}
@media(prefers-reduced-motion:reduce){#pageant-card .pg-score.pre{transform:none}#pageant-card .pg-score.flip{transition:opacity .2s}}
/* The sheet's own box stays unpainted (its children paint it): an opaque fixed box over the lower 58 % of the WebGL canvas made
 the compositor drop the canvas above it (blank world during the reveal). */
@media(max-width:960px) and (min-height:501px){#pageant-card{left:0;right:0;top:auto;bottom:0;transform:none;width:auto;height:58dvh;max-height:none;padding:0;gap:0;background:none;border-top:2px solid var(--ui-ink)}
 #pageant-card .pg-score{flex:1;border-width:3px 0 0;box-shadow:inset 0 3px 0 var(--accent)}#pageant-card .pg-card-actions{padding:8px 16px calc(8px + env(safe-area-inset-bottom,0px));background:var(--ui-panel-solid)}#pageant-card .pg-card-actions button{flex:1}
 #pageant-card .pg-castle{font-size:28px}#pageant-card .pg-total-v{font-size:30px}}
@media(max-height:500px){#pageant-card{right:calc(8px + env(safe-area-inset-right,0px));top:calc(env(safe-area-inset-top,0px) + 48px);bottom:8px;transform:none;width:46vw;max-height:none}#pageant-card .pg-score{flex:1}
 #pageant-card .pg-who{padding:6px 10px 2px}#pageant-card .pg-crit{gap:4px 8px;padding:4px 10px}#pageant-card .pg-castle{font-size:28px}#pageant-card .pg-total-v{font-size:28px}}

/* ---------- Top-3 cascade (#pageant-cascade) ---------- */
#pageant-cascade{position:fixed;z-index:41;left:calc(16px + env(safe-area-inset-left,0px));top:calc(env(safe-area-inset-top,0px) + 68px);width:300px;max-height:calc(100dvh - 160px);overflow:auto;padding:10px 12px;font-family:var(--ui-body);color:var(--ui-parchment);background:var(--ui-panel);border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px #f4c67b55,3px 3px 0 #231a2e88}
#pageant-cascade h3{display:flex;align-items:center;gap:6px;margin:0 0 6px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold);--gl:14px}
#pageant-cascade ol{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
#pageant-cascade .pg-crow{display:grid;grid-template-columns:3.4ch 12px minmax(0,1fr) auto;gap:8px;align-items:center;padding:4px 6px;background:#1b2442cc;border:1px solid #f4c67b33;animation:pg-drop .35s cubic-bezier(.2,.9,.3,1.3)}
#pageant-cascade .pg-crow[data-you=true]{box-shadow:inset 3px 0 0 var(--ui-you)}
#pageant-cascade .pg-crow span{display:flex;flex-direction:column;min-width:0}#pageant-cascade .pg-crow span b{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#pageant-cascade .pg-crow small{font-size:12px;color:var(--ui-parchment-dim)}
#pageant-cascade .pg-crow em{font-style:normal;font-weight:700;font-size:16px}
#pageant-cascade .pg-crank{font-size:13px;color:var(--ui-gold)}
@keyframes pg-drop{from{transform:translateY(-14px);opacity:0}}
@media(prefers-reduced-motion:reduce){#pageant-cascade .pg-crow{animation:none}}
@media(max-width:960px) and (min-height:501px){#pageant-cascade{left:16px;right:16px;width:auto;top:calc(env(safe-area-inset-top,0px) + 60px);max-height:calc(42dvh - 72px)}}
@media(max-height:500px){#pageant-cascade{top:calc(env(safe-area-inset-top,0px) + 48px);width:calc(54vw - 40px);max-height:calc(100dvh - 56px)}}

/* ---------- RESULTS (#pageant-results) ---------- */
#pageant-results{position:fixed;inset:0;z-index:43;display:grid;place-items:center;padding:calc(12px + env(safe-area-inset-top,0px)) calc(12px + env(safe-area-inset-right,0px)) calc(12px + env(safe-area-inset-bottom,0px)) calc(12px + env(safe-area-inset-left,0px));background:linear-gradient(#1b244244,#1b2442aa)}
#pageant-results .pg-results-card{width:min(880px,100%);max-height:calc(100dvh - 24px);overflow:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:12px;background:var(--ui-panel-solid)}
#pageant-results .pg-res-sub{font-size:14px;color:var(--ui-parchment-dim)}
#pageant-results .pg-ribbons{display:flex;flex-wrap:wrap;gap:8px}
#pageant-results .pg-ribbons li{flex:1 1 180px;display:flex;align-items:center;gap:8px;padding:6px 10px 6px 6px;background:#1b2442d9;border:2px solid var(--ui-ink)}
#pageant-results .pg-rb{width:26px;height:26px;color:var(--rb);flex:none}#pageant-results .pg-rb .pg-gl{width:100%;height:100%}
#pageant-results .pg-ribbons span{display:flex;flex-direction:column;min-width:0}#pageant-results .pg-ribbons b{font-size:13px}#pageant-results .pg-ribbons small{color:var(--ui-parchment-dim)}
#pageant-results .pg-table{display:flex;flex-direction:column;gap:4px}
#pageant-results .pg-table button{width:100%;min-height:44px;display:grid;grid-template-columns:3.4ch 12px minmax(0,1fr) auto auto 5ch;gap:10px;align-items:center;padding:6px 10px;text-align:left;font-size:14px}
#pageant-results .pg-table button[data-you=true]{box-shadow:inset 4px 0 0 var(--ui-you),2px 2px 0 var(--ui-ink);border-color:var(--ui-gold)}
#pageant-results .pg-crank{color:var(--ui-gold)}
#pageant-results .pg-rname{display:flex;flex-direction:column;min-width:0}#pageant-results .pg-rname b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#pageant-results .pg-rname small{color:var(--ui-parchment-dim)}
#pageant-results .pg-cols{display:flex;gap:8px}
#pageant-results .pg-c{display:flex;align-items:center;gap:3px;min-width:4.4ch;font-size:13px;--gl:14px}#pageant-results .pg-c i{color:var(--ui-gold);width:14px;height:14px}
#pageant-results .pg-rticks{display:flex;gap:6px;--chip:24px}
#pageant-results .pg-rtotal{font-style:normal;font-weight:700;font-size:18px;text-align:right}
#pageant-results .pg-gallery h3{font:400 30px/1 var(--ui-display);color:var(--ui-gold-hi);margin-bottom:8px}
#pageant-results .pg-gallery li{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:6px 0;border-bottom:1px solid #f4c67b26}
#pageant-results .pg-gallery li span{display:flex;flex-direction:column}#pageant-results .pg-gallery small{color:var(--ui-parchment-dim)}
#pageant-results .pg-gallery li span.pg-gallery-acts{flex-direction:row;flex-wrap:wrap;justify-content:flex-end;gap:6px}
#pageant-results .pg-gallery p{font-size:14px;color:var(--ui-parchment-dim)}
#pageant-results .pg-actions{position:sticky;bottom:-12px;z-index:1;display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end;margin:0 -12px -12px;padding:10px 12px;background:var(--ui-panel-solid);border-top:2px solid var(--ui-ink)}
#pageant-results .pg-actions button{min-height:44px}
@media(max-width:760px){#pageant-results .pg-ribbons li{flex-basis:150px}#pageant-results .pg-table button{grid-template-columns:3.4ch 12px minmax(0,1fr) 5ch;row-gap:6px}#pageant-results .pg-cols{grid-column:3/5;grid-row:2}#pageant-results .pg-rticks{grid-column:3/5;grid-row:3}#pageant-results .pg-rtotal{grid-column:4;grid-row:1}
 #pageant-results h2{font-size:32px}#pageant-results .pg-actions button{flex:1 1 40%}}
@media(max-height:500px){#pageant-results h2{font-size:30px}}

/* ---------- PAUSE + HELP ---------- */
:is(#pageant-pause,#pageant-help){position:fixed;inset:0;display:grid;place-items:center;padding:12px;background:#1b2442aa}
#pageant-help{z-index:96}
#pageant-help .pg-help-card{width:min(720px,100%);max-height:calc(100dvh - 24px);overflow:auto;background:var(--ui-panel-solid)}
#pageant-help header{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
#pageant-help .pg-close{width:44px;height:44px;padding:0;font-size:22px}
#pageant-help h3{margin:12px 0 6px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold)}
#pageant-help :is(.pg-help-cats,.pg-help-themes) li{display:grid;grid-template-columns:24px minmax(0,1fr);column-gap:10px;padding:5px 0;border-bottom:1px solid #f4c67b1f}
#pageant-help :is(.pg-help-cats,.pg-help-themes) i{grid-row:span 2;width:24px;height:24px;color:var(--ui-gold)}#pageant-help li i .pg-gl{width:100%;height:100%}
#pageant-help li b{font-size:15px}#pageant-help li b small{color:var(--ui-gold);font-weight:400;margin-left:6px}
#pageant-help li span{font-size:13px;line-height:1.35;color:var(--ui-parchment-dim)}
#pageant-help .pg-help-themes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:16px}
#pageant-help .pg-help-keys li{display:grid;grid-template-columns:minmax(120px,30%) minmax(0,1fr);column-gap:10px;padding:4px 0;border-bottom:1px solid #f4c67b1f}
#pageant-help .pg-help-keys li b{font-size:14px;color:var(--ui-gold-hi,#ffe2a3)}
#pageant-help .pg-help-foot{margin-top:10px;font-size:13px;color:var(--ui-parchment-dim)}
@media(max-width:600px){#pageant-help .pg-help-themes{grid-template-columns:1fr}#pageant-help h2{font-size:30px}}

/* ---------- refusal (red, shakes) and toast (gold) ---------- */
:is(#pageant-refusal,#pageant-toast){position:fixed;z-index:60;left:50%;top:calc(env(safe-area-inset-top,0px) + 124px);transform:translateX(-50%);max-width:min(520px,calc(100vw - 32px));box-sizing:border-box;padding:7px 14px;font:700 14px/1.35 var(--ui-body);text-align:center;border:2px solid var(--ui-ink);opacity:0;visibility:hidden;pointer-events:none;text-shadow:1px 1px 0 var(--ui-ink)}
@media(min-width:961px) and (min-height:501px){:is(#pageant-refusal,#pageant-toast){max-width:min(520px,calc(100vw - 640px))}}
#pageant-refusal{color:#fff3cd;background:#6b2430f2;box-shadow:inset 0 0 0 1px var(--ui-bad),3px 3px 0 #231a2e88}
body:not(.pg-placing) :is(#pageant-refusal,#pageant-toast){margin-top:var(--pg-card-push,0px)}
#pageant-toast{color:var(--ui-parchment);background:#5b4214f2;box-shadow:inset 0 0 0 1px var(--ui-gold-hi),3px 3px 0 #231a2e88}
:is(#pageant-refusal,#pageant-toast).show{opacity:1;visibility:visible;transition:opacity .08s steps(2)}
@media(prefers-reduced-motion:no-preference){#pageant-refusal.shake{animation:pg-shake .42s cubic-bezier(.36,.07,.19,.97)}#pageant-toast.pop{animation:pg-pop .3s cubic-bezier(.2,.9,.3,1.4)}}
@keyframes pg-shake{10%,90%{transform:translateX(calc(-50% - 2px))}20%,80%{transform:translateX(calc(-50% + 4px))}30%,50%,70%{transform:translateX(calc(-50% - 7px))}40%,60%{transform:translateX(calc(-50% + 7px))}}
@keyframes pg-pop{from{transform:translateX(-50%) scale(.85)}}
.pg-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

/* ---------- Workshop session: strip in the header, Judge's notes on top of the progress column ---------- */
#build-session-strip .pg-strip{display:flex;align-items:center;gap:12px;min-width:0;padding:4px 8px;background:#16203b;border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px var(--ui-gold-lo)}
#build-session-strip .pg-sclock{display:flex;align-items:baseline;gap:6px;white-space:nowrap}
#build-session-strip .pg-sclock small{font:700 12px/1 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold)}
#build-session-strip .pg-sclock b{font:700 22px/1 var(--ui-body);color:var(--ui-parchment)}
#build-session-strip .pg-strip.late .pg-sclock :is(b,small){color:var(--ui-bad)}
@media(prefers-reduced-motion:no-preference){#build-session-strip .pg-strip.late{animation:pg-pulse 1s steps(2,end) infinite}}
#build-session-strip .pg-sthemes{display:flex;gap:8px;--chip:28px}
#build-session-strip .pg-sbasics{font-size:13px;color:var(--ui-parchment-dim);white-space:nowrap}
#build-session-panel{padding:0 0 10px;border-bottom:2px solid var(--ui-ink)}
#builder-panel #build-session-panel h3{display:flex;align-items:center;gap:6px;color:var(--ui-gold);--gl:14px}
#build-session-panel h4{margin:10px 0 4px;font:700 12px/1.3 var(--ui-body);letter-spacing:.1em;text-transform:uppercase;color:var(--ui-gold)}
#build-session-panel .pg-sealed{margin:2px 0 6px;font-size:12px;color:var(--ui-parchment-dim)}
#build-session-panel .pg-tips li{position:relative;padding:2px 0 2px 12px;font-size:13px;line-height:1.3}
#build-session-panel .pg-tips li:before{content:"";position:absolute;left:0;top:8px;width:5px;height:5px;background:var(--ui-gold)}
#build-session-panel .pg-nhint{margin:8px 0;font-size:12px;color:var(--ui-dawn)}
#builder-panel #build-session-panel .pg-name{display:flex;flex-direction:column;gap:4px}
#build-session-panel .pg-name input{min-height:40px;padding:6px 10px;font:16px var(--ui-body);color:var(--ui-parchment);background:#16203b;border:2px solid var(--ui-ink);box-shadow:inset 0 0 0 1px #f4c67b55;border-radius:0;text-transform:none;letter-spacing:0}
@media(max-width:600px){#build-session-strip .pg-strip{justify-content:space-between;gap:8px;width:100%}#build-session-strip .pg-sclock b{font-size:20px}}
@media(max-height:500px){#build-session-strip .pg-sbasics{display:none}#build-session-strip .pg-sclock b{font-size:18px}#build-session-strip .pg-sthemes{--chip:24px;gap:6px}}

/* ---------- phones, portrait (390x844, 360x640): full-width clock, theme chips, bottom bar 56 px, sheets ---------- */
@media(max-width:960px) and (min-height:501px){
 #pageant-hud{--top:calc(env(safe-area-inset-top,0px) + 8px)}
 #pageant-hud .pg-clock{left:var(--edge-l);right:var(--edge-r);width:auto;transform:none;height:40px}
 #pageant-hud .pg-time{font-size:24px}
 #pageant-hud :is(.pg-pause,.pg-check,.pg-roster,.pg-desk){display:none!important}
 #pageant-hud .pg-phone{display:inline-flex!important}
 #pageant-hud .pg-chips{display:flex;top:calc(var(--top) + 46px);left:var(--edge-l);right:var(--edge-r);justify-content:center;gap:6px;pointer-events:none}
 #pageant-hud .pg-chipbtn{pointer-events:auto;width:44px;height:44px;min-height:44px;padding:0;background:none;border:0;box-shadow:none;--chip:36px}
 #pageant-hud .pg-chipbtn.fresh .pg-chip{animation:pg-pop .5s}
 #pageant-hud .pg-bar{left:var(--edge-l);right:var(--edge-r);transform:none;height:56px;padding:4px;gap:4px}
 #pageant-hud .pg-bar button{flex:1 1 0;min-height:46px;padding:4px 6px;font-size:16px}
 #pageant-hud .pg-wide,#pageant-hud .pg-key{display:none}
 #pageant-hud .pg-peek{left:var(--edge-l);right:var(--edge-r);width:auto;bottom:calc(var(--bottom) + 64px)}
 #pageant-hud :is(.pg-wait,.pg-ready){top:calc(var(--top) + 98px);max-width:calc(100vw - 32px);white-space:normal}
 :is(#pageant-refusal,#pageant-toast){top:calc(env(safe-area-inset-top,0px) + 180px)}
}
/* ---------- phones, landscape (844x390): small clock, chips as a left column, compact bar bottom right ---------- */
@media(max-height:500px){
 #pageant-hud{--top:calc(env(safe-area-inset-top,0px) + 6px);--bottom:calc(8px + env(safe-area-inset-bottom,0px))}
 #pageant-hud .pg-clock{height:36px;width:200px;left:50%;right:auto;transform:translateX(-50%)}
 #pageant-hud .pg-time{font-size:22px}
 #pageant-hud :is(.pg-pause,.pg-check,.pg-roster,.pg-desk){display:none!important}
 #pageant-hud .pg-phone{display:inline-flex!important}
 #pageant-hud .pg-chips{display:flex;flex-direction:column;top:var(--top);left:var(--edge-l);gap:4px;pointer-events:none}
 #pageant-hud .pg-chipbtn{pointer-events:auto;width:44px;height:44px;min-height:44px;padding:0;background:none;border:0;box-shadow:none;--chip:36px}
 #pageant-hud .pg-bar{left:auto;right:var(--edge-r);transform:none;padding:4px;gap:4px}
 #pageant-hud .pg-bar button{min-width:52px;min-height:44px;padding:4px 10px}
 #pageant-hud .pg-wide,#pageant-hud .pg-key{display:none}
 #pageant-hud .pg-peek{left:calc(var(--edge-l) + 56px);bottom:var(--bottom);width:min(300px,calc(100vw - 420px));min-width:220px;padding:6px 10px;gap:4px}
 #pageant-hud .pg-peek .pg-castle-name{font-size:28px}
 #pageant-hud .pg-peek-home{display:none}
 #pageant-hud :is(.pg-wait,.pg-ready){top:calc(var(--top) + 44px)}
 :is(#pageant-refusal,#pageant-toast){top:calc(env(safe-area-inset-top,0px) + 122px)}
}
@media(pointer:coarse){#pageant-hud .pg-key,#pageant-card .pg-key{display:none}#pageant-hud .pg-peek-home{min-height:44px}#pageant-hud button{min-height:44px}/* the pageant dialogs are .cu-touch (kit N20-04) */}
/* each rival row's options button (plaza-safety.js: Mute; Block and Report for real players), beside its score row */
#pageant-results .pg-table li{display:flex;gap:4px;align-items:stretch}#pageant-results .pg-table li>button[data-seat]:first-child{flex:1 1 auto;min-width:0}
#pageant-results .pg-table button.pg-safety{flex:0 0 44px;width:44px;display:block;padding:0;font-size:18px;text-align:center}
#pageant-results .pg-gallery-note{margin:0 0 8px;font-size:13px;color:var(--ui-parchment-dim)}

/* Castle Editor (pageant.js openEditor, owner 2026-11-07): the Pageant build ground with no clock, judges or rounds. The
   match HUD (clock plate, theme cards, roster, Mark done) is hidden; the catalog dock stays; a top bar carries Save / Pause / Exit. */
body.pg-editor #pageant-hud .pg-h2host,body.pg-editor #pageant-hud .pg-clock,body.pg-editor #pageant-hud .pg-pause,body.pg-editor #pageant-hud .pg-check,
body.pg-editor #pageant-hud .pg-chips,body.pg-editor #pageant-hud .pg-roster,body.pg-editor #pageant-hud .pg-bar,body.pg-editor #pageant-hud .pg-ready,
body.pg-editor #pageant-hud .pg-wait,body.pg-editor #pageant-hud .pg-peek{display:none!important}
#pg-editor-bar{position:fixed;z-index:40;top:max(10px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:8px;max-width:calc(100vw - 32px);
 padding:6px 8px 6px 14px;border-radius:12px;background:var(--pg-panel,rgba(28,22,40,.88));color:var(--pg-ink,#f6eedc);box-shadow:0 4px 16px rgba(0,0,0,.35);font:600 14px/1.2 system-ui,sans-serif}
#pg-editor-bar .pg-ed-title{white-space:nowrap}
#pg-editor-bar .pg-ed-state{opacity:.75;font-weight:400;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
#pg-editor-bar button{min-height:40px;min-width:44px;padding:0 14px;border-radius:9px;border:1px solid rgba(255,255,255,.25);background:rgba(255,255,255,.1);color:inherit;font:inherit;cursor:pointer}
#pg-editor-bar button.pg-primary{background:#e2b649;color:#231a2e;border-color:#e2b649}
#pg-editor-bar button:focus-visible{outline:3px solid #ffd76a;outline-offset:2px}
@media (max-width:520px){#pg-editor-bar .pg-ed-title{display:none}#pg-editor-bar{padding-left:10px}}
/* r33 My Castle / Free Build: the mode toggle, the Materials chip and Yard (home), and a second line (next floor, keep
   upgrade, debt or read-only note, Buy chip) and the first-use card under the buttons; the bar wraps on narrow screens */
#pg-editor-bar [hidden]{display:none!important}
#pg-editor-bar .pg-ed-info{flex:1 1 100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 10px;font-weight:400;font-size:13px}
#pg-editor-bar .pg-ed-info:not(:has(> :not([hidden]):not(:empty))){display:none}
/* r34pre3 show fire: the owner's switch (aria-pressed) carries a tick while the defences fire */
#pg-editor-bar #pg-editor-fire[aria-pressed=true]::before{content:"\2713\00a0"}#pg-editor-bar #pg-editor-fire[aria-pressed=false]{opacity:.75}
#pg-editor-bar .pg-ed-note{color:#ffd28a;font-weight:600}
#pg-editor-bar.pg-ed-debt{box-shadow:0 0 0 2px #e0a040,0 4px 16px rgba(0,0,0,.35)}
#pg-editor-bar .pg-ed-chip .yard-chip{min-height:40px;border-radius:9px}
#pg-editor-bar .pg-ed-card{flex:1 1 100%;max-width:440px;font-weight:400;font-size:13px;line-height:1.35;padding:6px 4px 2px;border-top:1px solid rgba(255,255,255,.18)}
#pg-editor-bar .pg-ed-card p{margin:0 0 4px}#pg-editor-bar .pg-ed-card ol{margin:0 0 6px;padding-left:20px}
#pg-editor-bar .pg-ed-cardacts{display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end}
/* r33 Free Build: the More menu (Use as battle castle), the banner and the My Castle readiness pill */
#pg-editor-bar .pg-ed-more{position:relative;display:inline-flex}
#pg-editor-bar .pg-ed-menu{position:absolute;top:calc(100% + 6px);right:0;z-index:2;display:flex;flex-direction:column;gap:4px;min-width:200px;padding:6px;border-radius:10px;background:var(--pg-panel,rgba(28,22,40,.96));box-shadow:0 4px 16px rgba(0,0,0,.4)}
#pg-editor-bar .pg-ed-menu button{text-align:left;white-space:nowrap}
#pg-editor-bar .pg-ed-banner{opacity:.85}
#pg-editor-bar .pg-ed-pill{min-height:32px;border-radius:16px;padding:0 12px;font-size:13px;background:rgba(224,160,64,.22);border-color:#e0a040}
#pg-editor-bar .pg-ed-pill.pg-ed-ok{background:rgba(120,200,120,.2);border-color:#7cc47c}
#pg-editor-bar button:disabled{opacity:.5;cursor:default}
/* r33pre2: the keep upgrade the stock cannot pay for yet: greyed, still focusable (pressing it says what is missing) */
#pg-editor-bar button.pg-ed-off{opacity:.55;border-style:dashed}
/* r33: the bar wraps, so it takes the screen's width less the gutters and centres itself (left:50% with translateX(-50%) held
   its shrink-to-fit width to half the screen: a tall column over the plot on a phone). On a phone the title stays (the mode
   toggle names the other mode) and the buttons are tighter, so the bar is two or three short rows. */
#pg-editor-bar{left:16px;right:16px;margin-inline:auto;width:fit-content;transform:none;box-sizing:border-box;flex-direction:column;align-items:stretch;gap:6px}
#pg-editor-bar .pg-ed-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 8px;min-width:0}
#pg-editor-bar .pg-ed-info,#pg-editor-bar .pg-ed-card{flex:none}#pg-editor-bar .pg-ed-card{align-self:center;box-sizing:border-box;width:100%}
@media (max-width:520px){
 #pg-editor-bar{left:8px;right:8px;max-width:calc(100vw - 16px);gap:4px;padding:4px 6px 4px 10px;font-size:13px}
 #pg-editor-bar .pg-ed-row{gap:4px 6px}
 #pg-editor-bar .pg-ed-title{display:inline}
 #pg-editor-bar button{padding:0 9px}
 #pg-editor-bar .pg-ed-info{font-size:12px;gap:4px 8px}
 #pg-editor-bar .pg-ed-info button{min-height:44px}
}
/* r34pre2 (r34pre1 browser check LOW): the second line's buttons (Defence fire, the keep Upgrade) were 34 px tall on phones; a
   touch screen gets the 44 px target there, phone or not */
@media (pointer:coarse){#pg-editor-bar .pg-ed-info button{min-height:44px}}
/* r34pre5: the bar's own buttons too (Free Build / My Castle, Materials, Yard, Save, II, Exit, Leave): 44 px on a touch screen; the
   rows wrap as before, a few px taller (checked at 390x844 and 844x390 by castle-visits-layout-browser.cjs) */
@media (pointer:coarse){#pg-editor-bar .pg-ed-row button,#pg-editor-bar .pg-ed-row .pg-ed-chip .yard-chip{min-height:44px}}
/* r34pre6 (r34pre5 known issue): the welcome card's buttons (Build My Castle / Try Free Build, then the onboarding steps' OK)
   were 40 px on a phone: 44 px on a touch screen or a narrow one (castle-visits-layout-browser.cjs checks 390x844;
   castle-social-360-browser.cjs checks 360x640 and 640x360 on touch) */
@media (pointer:coarse),(max-width:520px){#pg-editor-bar .pg-ed-card button{min-height:44px}}
/* r34pre6 (360 px layouts): on a short screen the welcome / first-use card with the room status made the bar taller than the
   screen (402 px at 640x360) and Start building sat off the bottom, out of reach. While a card is up the bar scrolls inside the
   screen, as it does with the Visits notice (castle-visits-ui.js); the bar is then the screen's height, so the Yard pop-up under
   its chip stays inside it (checked at 640x360) */
@media (max-height:560px){
 #pg-editor-bar:has(.pg-ed-card:not([hidden])){max-height:calc(100vh - max(10px,env(safe-area-inset-top)) - 10px);max-height:calc(100dvh - max(10px,env(safe-area-inset-top)) - 10px);overflow-y:auto;overscroll-behavior:contain}
}
/* r33: the touch UI's More button sits under the editor bar, whatever its height (pageant.js sets --pg-bar-bottom) */
html.mt-phone body.pg-editor #mt-more:not([hidden]){top:calc(var(--pg-bar-bottom,194px) + 10px)}
#pg-pad-cursor{position:fixed;left:-11px;top:-11px;width:22px;height:22px;border:3px solid #ffd76a;border-radius:50%;box-shadow:0 0 0 2px rgba(0,0,0,.5);pointer-events:none;z-index:39}
