/* ==========================================================================
   Who Plays First? — /who-goes-first, on who-goes-first-engine.js (Player Select)
   A player-select screen picks the whole turn order; an optional turn timer
   runs the hand-off. The stage is a dark "screen" in EVERY site theme — it is a
   scene, not a themed surface. Page chrome is theme-aware (var(--theme-*)).
   🧒 Kids' page: animal avatars, nothing scary. No real game's menu, logo or
   characters — the look is the generic arcade player-select trope.
   ========================================================================== */
.page-who-goes-first {
    --wgf-gold: #ffd23f;
    --wgf-scr: #141a3a;
    --wgf-scr-2: #1f2752;
    --wgf-scr-ink: #e8ecff;
    --wgf-scr-dim: #a3aee9;
    --wgf-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
    --wgf-ink: var(--theme-text, #1f2430);
    /* ⚠️ --theme-muted, NOT --theme-text-muted — the latter is undefined. */
    --wgf-muted: var(--theme-muted, #6b7280);
    --wgf-surface: var(--theme-surface, #ffffff);
    --wgf-border: var(--theme-border, #e5e7eb);
    --wgf-primary: #3a56c8;
}

/* ---- Stage: the screen ---------------------------------------------------- */
.page-who-goes-first .wgf-stage {
    --wgf-cols: 4;
    position: relative; overflow: hidden; border-radius: 16px;
    padding: 18px 18px 22px; max-width: 760px; margin: 0 auto;
    color: var(--wgf-scr-ink);
    background: radial-gradient(120% 90% at 50% 0%, #2a3478 0%, var(--wgf-scr) 62%), var(--wgf-scr);
    box-shadow: inset 0 0 0 3px #0b0f26, inset 0 0 40px rgba(0, 0, 0, .45), 0 14px 34px -14px rgba(11, 15, 38, .55);
}
/* scanlines — decoration only, never in the way of a tap */
.page-who-goes-first .wgf-stage::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18; z-index: 1;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 4px);
}
.page-who-goes-first .wgf-title {
    text-align: center; margin: 4px 0 30px;
    font: 900 1.35rem/1 var(--wgf-mono); letter-spacing: .28em; color: var(--wgf-gold);
    text-shadow: 0 0 12px rgba(255, 210, 63, .45), 0 3px 0 #8a5a00;
}
.page-who-goes-first .wgf-title small {
    display: block; margin-top: 8px; font-size: .68rem; letter-spacing: .2em; font-weight: 700;
    color: var(--wgf-scr-dim); text-shadow: none; text-transform: uppercase;
}

/* tiles */
.page-who-goes-first .wgf-tiles,
.page-who-goes-first .wgf-slots {
    display: grid; grid-template-columns: repeat(var(--wgf-cols), minmax(0, 1fr));
    max-width: 600px; margin: 0 auto;
}
.page-who-goes-first .wgf-tiles { gap: 22px 14px; }
.page-who-goes-first .wgf-tile {
    position: relative; text-align: center; border-radius: 12px; padding: 14px 8px 10px;
    background: var(--wgf-scr-2); box-shadow: inset 0 0 0 2px #2f3a78, 0 4px 0 #0b0f26;
    transition: transform .12s ease, box-shadow .12s ease, opacity .25s ease;
}
.page-who-goes-first .wgf-av {
    width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 8px;
    display: grid; place-items: center; font-size: 36px; line-height: 1;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .22), transparent 60%), var(--c);
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2);
}
.page-who-goes-first .wgf-nm {
    display: block; font-weight: 800; font-size: .95rem; color: var(--wgf-scr-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-who-goes-first .wgf-band { display: block; height: 5px; border-radius: 3px; background: var(--c); margin: 8px 12px 0; }
.page-who-goes-first .wgf-tile.is-cur {
    transform: translateY(-4px) scale(1.04);
    box-shadow: inset 0 0 0 3px var(--wgf-gold), 0 0 22px rgba(255, 210, 63, .55), 0 8px 0 #0b0f26;
}
.page-who-goes-first .wgf-tile.is-cur::before {
    content: "\25BC"; position: absolute; top: -21px; left: 50%; transform: translateX(-50%);
    color: var(--wgf-gold); font-size: 15px; line-height: 1; text-shadow: 0 0 8px rgba(255, 210, 63, .7);
    animation: wgfBob .5s ease-in-out infinite alternate;
}
@keyframes wgfBob { to { transform: translate(-50%, -4px); } }
.page-who-goes-first .wgf-tile.is-taken { opacity: .38; }
.page-who-goes-first .wgf-pbadge {
    position: absolute; top: 6px; right: 7px; border-radius: 5px; padding: 3px 5px;
    font: 900 .7rem/1 var(--wgf-mono); background: var(--wgf-gold); color: #3a2a00;
}
.page-who-goes-first .wgf-pbadge[hidden] { display: none; }

/* slots P1…Pn, and the start button sitting over them before the draw */
.page-who-goes-first .wgf-slotwrap { position: relative; max-width: 600px; margin: 26px auto 0; }
.page-who-goes-first .wgf-slots { gap: 10px; }
.page-who-goes-first .wgf-slot {
    display: flex; align-items: center; gap: 7px; min-height: 46px; min-width: 0;
    border: 2px dashed #3a4690; border-radius: 10px; padding: 6px 8px;
}
.page-who-goes-first .wgf-pn { flex: none; font: 900 .8rem/1 var(--wgf-mono); color: var(--wgf-scr-dim); }
.page-who-goes-first .wgf-sem { flex: none; font-size: 1rem; line-height: 1; }
.page-who-goes-first .wgf-who { min-width: 0; font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-who-goes-first .wgf-empty { color: var(--wgf-scr-dim); opacity: .6; letter-spacing: .1em; }
.page-who-goes-first .wgf-slot.is-full { border: 2px solid var(--c); background: rgba(255, 255, 255, .05); }
.page-who-goes-first .wgf-slot.is-full .wgf-pn { color: var(--wgf-gold); }
.page-who-goes-first .wgf-slot.is-now { box-shadow: 0 0 0 2px var(--wgf-gold), 0 0 16px rgba(255, 210, 63, .45); }
.page-who-goes-first .wgf-slot.is-now::after {
    content: "NOW"; margin-left: auto; flex: none; border-radius: 4px; padding: 3px 4px;
    font: 900 .62rem/1 var(--wgf-mono); color: #3a2a00; background: var(--wgf-gold);
}

.page-who-goes-first .wgf-start-overlay {
    position: absolute; left: 50%; top: 50%; z-index: 3; transform: translate(-50%, -50%);
    display: inline-flex; align-items: center; gap: .55rem; border: 0; border-radius: 999px; cursor: pointer;
    padding: .85rem 2rem; font: 900 1.05rem/1 var(--wgf-mono); letter-spacing: .12em; text-transform: uppercase;
    color: #3a2a00; background: linear-gradient(180deg, #ffe27a, #ffbf1f);
    box-shadow: 0 6px 0 #a86f00, 0 10px 28px rgba(0, 0, 0, .45);
    animation: wgfPulse 1.4s ease-in-out infinite;
}
.page-who-goes-first .wgf-start-overlay:hover { filter: brightness(1.06); }
.page-who-goes-first .wgf-start-overlay:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.page-who-goes-first .wgf-start-overlay[hidden] { display: none; }
@keyframes wgfPulse { 50% { transform: translate(-50%, -50%) scale(1.05); } }

.page-who-goes-first .wgf-neworder {
    position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border-radius: 50%;
    border: 0; cursor: pointer; display: grid; place-items: center; font-size: 1rem;
    color: #3a2a00; background: linear-gradient(180deg, #ffe27a, #ffbf1f); box-shadow: 0 3px 0 #a86f00;
}
.page-who-goes-first .wgf-neworder:hover { filter: brightness(1.06); }
.page-who-goes-first .wgf-neworder:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.page-who-goes-first .wgf-neworder[hidden] { display: none; }

.page-who-goes-first .wgf-flash {
    position: absolute; left: 50%; top: 42%; z-index: 4; pointer-events: none; white-space: nowrap;
    transform: translate(-50%, -50%) scale(.6); opacity: 0;
    font: 900 2rem/1 var(--wgf-mono); letter-spacing: .08em; color: var(--wgf-gold);
    text-shadow: 0 0 18px rgba(255, 210, 63, .7), 0 4px 0 #8a5a00;
    transition: opacity .15s ease, transform .25s ease;
}
.page-who-goes-first .wgf-flash.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---- Turn timer (in the stage, so fullscreen on a TV shows the clock) ----- */
.page-who-goes-first .wgf-hud {
    position: relative; z-index: 2; max-width: 600px; margin: 18px auto 0; min-height: 76px;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px 14px;
    padding: 10px 14px 14px; border-radius: 12px; background: rgba(255, 255, 255, .06);
    box-shadow: inset 0 0 0 1px rgba(163, 174, 233, .25);
}
/* Reserved from page load (the reveal must not move the stage): before the draw
   the row shows a hint and its live contents keep their space, invisibly. */
.page-who-goes-first .wgf-hud:not(.is-live) > :not(.wgf-hud-idle) { visibility: hidden; }
.page-who-goes-first .wgf-hud-idle {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0 12px;
    text-align: center; font-size: .85rem; font-weight: 700; color: var(--wgf-scr-dim);
}
.page-who-goes-first .wgf-hud.is-live > .wgf-hud-idle { display: none; }
.page-who-goes-first .wgf-hud[hidden] { display: none; }
.page-who-goes-first .wgf-hav,
.page-who-goes-first .wgf-hud-av {
    width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
    font-size: 24px; line-height: 1; background: var(--c, #3a4690);
}
.page-who-goes-first .wgf-hud-txt { min-width: 0; }
.page-who-goes-first .wgf-hud-who { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-who-goes-first .wgf-hud-next { display: block; font-size: .8rem; color: var(--wgf-scr-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-who-goes-first .wgf-hud-clock { font: 900 1.9rem/1 var(--wgf-mono); color: var(--wgf-gold); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.page-who-goes-first .wgf-hud.is-paused .wgf-hud-clock { opacity: .5; }
.page-who-goes-first .wgf-hud-btns { display: flex; gap: 6px; }
.page-who-goes-first .wgf-hud-btn {
    border: 0; border-radius: 8px; padding: .45rem .7rem; font-weight: 700; font-size: .85rem; cursor: pointer; white-space: nowrap;
    color: var(--wgf-scr-ink); background: rgba(255, 255, 255, .12);
}
.page-who-goes-first .wgf-hud-btn:hover { background: rgba(255, 255, 255, .2); }
.page-who-goes-first .wgf-hud-btn:focus-visible { outline: 2px solid var(--wgf-gold); outline-offset: 2px; }
.page-who-goes-first .wgf-hud-prog { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.page-who-goes-first .wgf-hud-prog > span { display: block; height: 100%; width: 100%; border-radius: 99px; background: var(--wgf-gold); }

/* ---- Time's up: the hand-off card over the whole stage --------------------- */
.page-who-goes-first .wgf-handoff {
    position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; text-align: center; padding: 20px;
    background: rgba(9, 12, 32, .9);
}
.page-who-goes-first .wgf-handoff[hidden] { display: none; }
.page-who-goes-first .wgf-handoff-k { font: 900 1.6rem/1 var(--wgf-mono); color: var(--wgf-gold); letter-spacing: .1em; text-shadow: 0 0 16px rgba(255, 210, 63, .6); }
.page-who-goes-first .wgf-handoff-l { margin: 14px 0 8px; color: var(--wgf-scr-dim); font-weight: 700; }
.page-who-goes-first .wgf-handoff-who { display: inline-flex; align-items: center; gap: 12px; font-size: 2rem; font-weight: 900; color: #fff; }
.page-who-goes-first .wgf-handoff-who .wgf-hav { width: 60px; height: 60px; font-size: 34px; }
.page-who-goes-first .wgf-handoff-go {
    display: inline-flex; align-items: center; gap: .45rem; margin-top: 18px; border: 0; border-radius: 999px; cursor: pointer;
    padding: .75rem 1.5rem; font-weight: 800; color: #3a2a00; background: linear-gradient(180deg, #ffe27a, #ffbf1f);
    box-shadow: 0 5px 0 #a86f00;
}
.page-who-goes-first .wgf-handoff-go:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.page-who-goes-first .wgf-count { text-align: center; margin: .6rem 0 0; font-size: .85rem; color: var(--wgf-muted); min-height: 1.3em; }

/* winner bar glyph: the player's avatar disc */
.page-who-goes-first .wgf-rglyph {
    display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
    background: var(--c); font-size: 1.6em; line-height: 1;
}

/* ---- Panel: players on the sofa -------------------------------------------- */
.page-who-goes-first .wgf-prow { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.page-who-goes-first .wgf-avb {
    flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
    display: grid; place-items: center; font-size: 22px; line-height: 1; background: var(--c);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.page-who-goes-first .wgf-avb:hover { transform: scale(1.06); }
.page-who-goes-first .wgf-pname,
.page-who-goes-first .wgf-addname {
    flex: 1 1 auto; min-width: 0; border: 1px solid var(--wgf-border); border-radius: 8px;
    padding: .5rem .65rem; font-size: .95rem; background: var(--wgf-surface); color: var(--wgf-ink);
}
.page-who-goes-first .wgf-addname { border-style: dashed; }
.page-who-goes-first .wgf-px {
    flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; cursor: pointer;
    background: transparent; color: var(--wgf-muted);
}
.page-who-goes-first .wgf-px:hover:not(:disabled) { background: rgba(127, 127, 127, .14); color: var(--wgf-ink); }
.page-who-goes-first .wgf-px:disabled { opacity: .3; cursor: not-allowed; }
.page-who-goes-first .wgf-addrow { display: flex; gap: .5rem; margin-top: .15rem; }
.page-who-goes-first .wgf-addrow[hidden] { display: none; }
.page-who-goes-first .wgf-pcount { font-size: .78rem; color: var(--wgf-muted); margin: .45rem 0 1rem; }
.page-who-goes-first .wgf-lbl { font-size: .85rem; font-weight: 800; margin: 0 0 .4rem; color: var(--wgf-ink); }
.page-who-goes-first .wgf-seg { display: flex; border: 1px solid var(--wgf-border); border-radius: 9px; overflow: hidden; }
.page-who-goes-first .wgf-seg button {
    flex: 1 1 0; border: 0; border-right: 1px solid var(--wgf-border); padding: .5rem 0; cursor: pointer;
    font-weight: 700; font-size: .88rem; background: var(--wgf-surface); color: var(--wgf-ink);
}
.page-who-goes-first .wgf-seg button:last-child { border-right: 0; }
.page-who-goes-first .wgf-seg button[aria-pressed="true"] { background: var(--wgf-primary); color: #fff; }
.page-who-goes-first .wgf-hint { font-size: .78rem; line-height: 1.45; color: var(--wgf-muted); margin: .4rem 0 0; }
.page-who-goes-first #wgfAddBtn .bi { margin-right: .2rem; }

/* ---- Narrow screens --------------------------------------------------------- */
@media (max-width: 575.98px) {
    .page-who-goes-first .wgf-stage { padding: 14px 10px 16px; }
    .page-who-goes-first .wgf-title { font-size: 1.05rem; letter-spacing: .2em; margin-bottom: 26px; }
    .page-who-goes-first .wgf-tiles { gap: 20px 8px; }
    .page-who-goes-first .wgf-tile { padding: 10px 4px 8px; }
    .page-who-goes-first .wgf-av { width: 44px; height: 44px; font-size: 25px; margin-bottom: 6px; }
    .page-who-goes-first .wgf-nm { font-size: .8rem; }
    .page-who-goes-first .wgf-band { margin: 6px 8px 0; }
    .page-who-goes-first .wgf-slots { gap: 6px; }
    .page-who-goes-first .wgf-slot { padding: 5px 5px; gap: 4px; min-height: 40px; }
    .page-who-goes-first .wgf-sem { display: none; }
    .page-who-goes-first .wgf-who { font-size: .76rem; }
    .page-who-goes-first .wgf-slot.is-now::after { content: ""; width: 8px; height: 8px; padding: 0; border-radius: 50%; }
    .page-who-goes-first .wgf-start-overlay { padding: .75rem 1.4rem; font-size: .92rem; }
    .page-who-goes-first .wgf-flash { font-size: 1.45rem; }
    .page-who-goes-first .wgf-hud { grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px; }
    .page-who-goes-first .wgf-hud-btns { grid-column: 1 / -1; }
    .page-who-goes-first .wgf-hud-btn { flex: 1 1 0; }
    .page-who-goes-first .wgf-hud-clock { font-size: 1.5rem; }
    .page-who-goes-first .wgf-handoff-who { font-size: 1.5rem; }
}

/* ---- SEO content --------------------------------------------------------------
   Colour + accents ONLY. The type scale comes from the shared .content-guide
   class on the wrapper — never re-declare heading font sizes here. */
.page-who-goes-first .wgf-content {
    color: var(--wgf-ink); padding: 3.5rem 0 3.75rem; margin-top: 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f1f4ff 100%);
    border-top: 1px solid var(--wgf-border);
}
body[data-theme].page-who-goes-first .wgf-content { background: var(--theme-bg); }
.page-who-goes-first .wgf-inner { max-width: 860px; margin: 0 auto; padding: 0 1rem; }
.page-who-goes-first .wgf-content h2,
.page-who-goes-first .wgf-content h3,
.page-who-goes-first .wgf-content strong { color: var(--wgf-ink); }
.page-who-goes-first .wgf-content p,
.page-who-goes-first .wgf-content li { color: var(--wgf-muted); }
.page-who-goes-first .wgf-content a { color: var(--wgf-primary); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
body[data-theme="dark"].page-who-goes-first .wgf-content a,
body[data-theme="high-contrast"].page-who-goes-first .wgf-content a { color: #b9c6ff; }
.page-who-goes-first .wgf-kicker {
    display: inline-block; margin-bottom: .85rem; border-radius: 999px; padding: .3rem .85rem;
    font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
    color: #3a2a00; background: linear-gradient(180deg, #ffe27a, #ffbf1f);
}
.page-who-goes-first .wgf-lead { font-size: 1.2rem; line-height: 1.7; color: var(--wgf-ink); }
.page-who-goes-first .wgf-section { margin-top: 3rem; }
.page-who-goes-first .wgf-list { margin: .4rem 0 0; padding-left: 1.15rem; }
.page-who-goes-first .wgf-beats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; margin-top: 1.4rem; counter-reset: beat;
}
.page-who-goes-first .wgf-beat {
    background: var(--wgf-surface); border: 1px solid var(--wgf-border); border-top: 3px solid var(--wgf-gold);
    border-radius: 12px; padding: .9rem 1rem 1rem; counter-increment: beat;
}
.page-who-goes-first .wgf-beat::before {
    content: counter(beat); display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-bottom: .45rem;
    border-radius: 50%; background: var(--wgf-scr); color: var(--wgf-gold); font-weight: 800; font-size: .85rem;
}
.page-who-goes-first .wgf-beat h3 { margin: 0 0 .3rem !important; font-size: 1.02rem !important; }
.page-who-goes-first .wgf-beat p { margin: 0; font-size: .9rem; }
.page-who-goes-first .wgf-callout {
    margin-top: 1.4rem; border-left: 4px solid var(--wgf-primary); border-radius: 0 12px 12px 0;
    background: rgba(58, 86, 200, .08); padding: 1rem 1.15rem;
}
.page-who-goes-first .wgf-callout p { margin: 0; }
@media (max-width: 767.98px) {
    .page-who-goes-first .wgf-content { padding: 2.5rem 0 2.75rem; }
}
