/* ══════════════════════════════════════════════════════════════════════
   WAIT GAME — snake on the generating screens.

   Sits inside the existing wait screens rather than floating over them, so
   the page never gains a second layer competing with the progress copy.
   Flat violet on the app's own surfaces; no new palette, no glow.
   ══════════════════════════════════════════════════════════════════════ */
.waitgame {
    --wg-grid: rgba(91, 80, 232, .06);
    --wg-snake: #5b50e8;
    --wg-head: #3a30ad;
    --wg-food: #f0a500;
    margin-top: 20px;
    /* The offer was sitting flush against the question skeleton below it —
       margin-top alone gave it space above and none beneath, so it read as
       stuck to the card under it rather than as its own thing. */
    margin-bottom: 22px;
    text-align: center;
}

/* The offer: quiet, and absent entirely until the wait has earned it. */
.waitgame-open {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 15px;
    min-height: 40px;
    background: rgba(91, 80, 232, .08);
    border: none;
    border-radius: 999px;
    color: var(--violet, #5b50e8);
    font-family: var(--font-ui, 'Plus Jakarta Sans', sans-serif);
    font-size: .8rem;
    font-weight: 700;
    cursor: var(--cur-point, pointer);
    opacity: 0;
    transition: opacity .45s ease, background .18s ease;
}
.waitgame-open.is-in { opacity: 1; }
/* An author `display` beats the UA's [hidden] rule, so say it explicitly:
   without this the offer is present and clickable from the first frame,
   merely transparent. */
.waitgame [hidden] { display: none !important; }
.waitgame-open:hover { background: rgba(91, 80, 232, .16); }
.waitgame-open:focus-visible { outline: 3px solid rgba(91, 80, 232, .45); outline-offset: 2px; }

.waitgame-board {
    /* A column that is sized by the board, never by the prose under it. */
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: var(--card-bg, #fff);
    border: 1.5px solid rgba(91, 80, 232, .14);
    border-radius: var(--r, 16px);
}

.waitgame-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: stretch;
    margin-bottom: 10px;
    font-family: var(--font-ui, 'Plus Jakarta Sans', sans-serif);
    font-size: .74rem;
    color: var(--text-muted, #6b6890);
}
.waitgame-bar b { color: var(--text-primary, #111827); font-weight: 800; }
.waitgame-best { margin-right: auto; }
.waitgame-close {
    padding: 4px 10px;
    min-height: 32px;
    background: none;
    border: none;
    color: var(--violet, #5b50e8);
    font-family: inherit;
    font-size: .74rem;
    font-weight: 700;
    cursor: var(--cur-point, pointer);
}
.waitgame-close:hover { text-decoration: underline; }

.waitgame-stage { position: relative; line-height: 0; }
.waitgame-canvas {
    display: block;
    border-radius: 10px;
    background: rgba(91, 80, 232, .03);
    touch-action: none;   /* swipes steer the snake, they do not scroll the page */
}

.waitgame-over {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--card-bg, #fff) 86%, transparent);
    font-family: var(--font-ui, 'Plus Jakarta Sans', sans-serif);
    line-height: 1.4;
}
.waitgame-over-title { margin: 0; font-size: .9rem; font-weight: 800; color: var(--text-primary, #111827); }
.waitgame-over-score { margin: 0; font-size: .78rem; color: var(--text-muted, #6b6890); }
.waitgame-again {
    margin-top: 4px;
    padding: 8px 16px;
    min-height: 36px;
    background: var(--violet, #5b50e8);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    cursor: var(--cur-point, pointer);
}

.waitgame-hint {
    /* The card is shrink-to-fit, so a long hint would otherwise set its width
       and strand the board at the left edge. Zero width keeps this line out of
       the max-content calculation; min-width paints it at the board's width. */
    width: 0;
    min-width: 100%;
    margin: 9px 0 0;
    font-family: var(--font-ui, 'Plus Jakarta Sans', sans-serif);
    font-size: .7rem;
    color: var(--text-muted, #6b6890);
    line-height: 1.4;
}

.waitgame-live {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

[data-dark] .waitgame {
    --wg-grid: rgba(157, 148, 255, .08);
    --wg-snake: #b6a6ff;
    --wg-head: #cdc7ff;
    --wg-food: #ffc861;
}
[data-dark] .waitgame-open { background: rgba(157, 148, 255, .14); color: #b5adff; }
[data-dark] .waitgame-open:hover { background: rgba(157, 148, 255, .22); }
[data-dark] .waitgame-board { border-color: rgba(157, 148, 255, .2); }
[data-dark] .waitgame-close { color: #b5adff; }

/* The game is user-initiated, so it stays playable; only the decorative
   fade of the offer is dropped. */
@media (prefers-reduced-motion: reduce) {
    .waitgame-open { transition: none; }
}

@media (max-width: 600px) {
    .waitgame { margin-top: 16px; }
    .waitgame-hint { max-width: 260px; margin-left: auto; margin-right: auto; }
}

/* The board is focusable so the arrows have an owner. The app's global ring is
   3px of full-strength violet that also squares the corners to 8px, which on a
   small dark board reads as an error state; this is the same signal, quieter
   and cut to the board's own shape. */
.waitgame-canvas:focus-visible {
    outline: 2px solid rgba(91, 80, 232, .32);
    outline-offset: 2px;
    border-radius: 10px;
}
[data-dark] .waitgame-canvas:focus-visible { outline-color: rgba(157, 148, 255, .34); }
