/* Play screen: header -> word chips -> grid -> footer. */

.play-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Native iPad / tablets: chrome (header + play nav) is full-bleed. Type and
 * chips scale up so a 13" display does not look like a stretched phone. The
 * board stays a readable column rather than edge-to-edge. */
@media (min-width: 600px) and (min-height: 600px) {
    html.native-shell .word-chips,
    html.native-shell .cascade-target {
        width: 100%;
        max-width: 960px;
        margin-inline: auto;
    }

    html.native-shell .grid-wrap {
        width: 100%;
        max-width: 920px;
        margin-inline: auto;
    }

    html.native-shell .play-header {
        min-height: 88px;
        gap: 16px;
        padding: 14px 24px 16px;
    }

    html.native-shell .play-back-btn {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    html.native-shell .play-back-btn svg {
        width: 24px;
        height: 24px;
    }

    html.native-shell .play-title {
        font-size: 24px;
    }

    html.native-shell .play-progress-count {
        font-size: 16px;
    }

    html.native-shell .play-stat-capsule {
        gap: 8px;
        padding: 10px 14px 10px 12px;
        border-radius: 16px;
    }

    html.native-shell .play-stat-value {
        font-size: 22px;
    }

    html.native-shell .play-stat-icon svg {
        width: 24px;
        height: 24px;
    }

    html.native-shell .word-chips {
        gap: 10px;
        padding: 8px 16px 12px;
        max-height: 28vh;
    }

    html.native-shell .chip {
        font-size: 17px;
        font-weight: 700;
        padding: 8px 14px;
        letter-spacing: 0.04em;
    }

    html.native-shell .cascade-target {
        gap: 6px;
        padding: 10px 16px 18px;
    }

    html.native-shell .cascade-target-label {
        font-size: 14px;
    }

    html.native-shell .cascade-target-word {
        font-size: 36px;
    }

    html.native-shell .play-directions-label {
        font-size: 1rem;
    }

    html.native-shell .play-selection-preview-text {
        font-size: 1.15rem;
        min-height: 1.6rem;
        padding: 0.15rem 0.75rem;
    }

    html.native-shell #screen-play .play-bottom-nav {
        justify-content: center;
        gap: clamp(40px, 8vw, 96px);
    }

    html.native-shell .play-bottom-nav .bottom-nav-item,
    html.native-shell .play-letter-scale-group {
        font-size: 14px;
        min-width: 104px;
        max-width: 200px;
        min-height: 60px;
    }

    html.native-shell .play-letter-step-a {
        font-size: 20px;
    }

    html.native-shell .play-letter-step-btn.is-larger .play-letter-step-a {
        font-size: 26px;
    }

    html.native-shell .play-letter-step-sign {
        font-size: 13px;
    }
}

/* Header */
.play-header {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 10px 14px 12px;
    flex-shrink: 0;
    position: relative;
    background: var(--play-header-bg);
    overflow: hidden;
}

.play-header::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: var(--play-header-star-opacity, 1);
    background-image:
        radial-gradient(1px 1px at 12% 28%, rgba(255, 255, 255, 0.22), transparent),
        radial-gradient(1px 1px at 78% 18%, rgba(255, 255, 255, 0.16), transparent),
        radial-gradient(1px 1px at 42% 62%, rgba(255, 255, 255, 0.12), transparent),
        radial-gradient(1px 1px at 88% 72%, rgba(255, 255, 255, 0.14), transparent);
    pointer-events: none;
}

.play-header > * {
    position: relative;
    z-index: 1;
}

.play-back-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 12px rgba(120, 90, 60, 0.12);
}

.play-back-btn svg {
    width: 20px;
    height: 20px;
}

.play-header-info {
    flex: 1;
    min-width: 0;
}

.play-header-main {
    display: flex;
    align-items: center;
    min-width: 0;
}

.play-header-text {
    min-width: 0;
    flex: 1;
}

.play-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.play-progress {
    margin-top: 4px;
}

.play-progress {
    min-width: 0;
    overflow: hidden;
}

.play-progress-count {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    line-height: 1.2;
}

/* Words found is a solved count, so it takes teal (SG 2.2), not the orange the
 * old progress fill used. */
.play-progress-count em {
    font-style: normal;
    font-weight: 800;
    color: var(--stat-teal);
}

.play-stat-capsule {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px 8px 9px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 12px rgba(120, 90, 60, 0.12);
    flex-shrink: 0;
}

/* The same wave band the icon wells carry, so these pills belong to the same
 * family as the wells and hero cards: a mask filled with currentColor, which
 * means each pill's own hue tints its own wave. */
.play-stat-capsule::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: currentColor;
    opacity: 0.18;
    pointer-events: none;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0,60 C22,45 38,47 55,59 C72,71 86,69 100,57 L100,100 L0,100 Z' fill='%23000'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0,60 C22,45 38,47 55,59 C72,71 86,69 100,57 L100,100 L0,100 Z' fill='%23000'/%3E%3C/svg%3E");
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.play-stat-capsule > * {
    position: relative;
    z-index: 1;
}

/* Score is teal, time is orange - SG 2.2. Set on the pill so the wave, the glyph
 * and the number all take one hue. */
#play-score-pill {
    color: var(--stat-teal);
}

#play-timer-pill {
    color: var(--accent-2);
}

.play-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.play-stat-icon svg {
    width: 19px;
    height: 19px;
}

/* Score is a solved value, so it is teal (SG 2.2). This carried the coin token,
 * which the guide reserves for currency - the coin is one object and nothing
 * else borrows its gold. */
.play-stat-icon--star {
    color: inherit;
}

.play-stat-icon--star svg {
    fill: currentColor;
    stroke: none;
}

.play-stat-icon--timer {
    color: inherit;
}

/* Icons.timer is a stroke glyph and its <circle> carries no fill="none", so SVG's
 * default black filled the dial solid. The star is the filled one; everything
 * else in this family strokes. */
.play-stat-icon--timer svg {
    fill: none;
    stroke: currentColor;
}

.play-stat-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.play-stat-value {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    color: inherit;
}

/* The label recedes; the number is the subject. */
.play-stat-label {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Cascade countdown — warn when under 30s remain. */
.play-timer-pill--urgent {
    background: color-mix(in srgb, var(--warning) 24%, rgba(255, 255, 255, 0.92));
    box-shadow:
        0 4px 14px color-mix(in srgb, var(--warning) 32%, transparent),
        0 0 0 1px color-mix(in srgb, var(--warning) 28%, transparent);
    animation: cascadeTimerUrgent 0.9s ease-in-out infinite;
}

.play-timer-pill--urgent .play-stat-icon--timer,
.play-timer-pill--urgent .play-stat-value {
    color: color-mix(in srgb, var(--warning) 82%, #8a3b00);
}

@keyframes cascadeTimerUrgent {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 4px 14px color-mix(in srgb, var(--warning) 32%, transparent),
            0 0 0 1px color-mix(in srgb, var(--warning) 28%, transparent);
    }
    50% {
        transform: scale(1.045);
        box-shadow:
            0 6px 20px color-mix(in srgb, var(--warning) 48%, transparent),
            0 0 0 2px color-mix(in srgb, var(--warning) 42%, transparent);
    }
}

/* Word chips — above the board; never shrink into the grid area. */
.word-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 6px 2px;
    max-height: 22vh;
    overflow-x: hidden;
    overflow-y: auto;
    flex-shrink: 0;
    flex-grow: 0;
    min-height: 0;
    justify-content: center;
    align-content: flex-start;
    position: relative;
    z-index: 2;
    -webkit-overflow-scrolling: touch;
}

.chip {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 5px 10px;
    border-radius: var(--radius-chip);
    background: var(--bg-surface);
    color: var(--text-primary);
    white-space: nowrap;
    transition: all 0.25s ease;
    line-height: 1.2;
}

.chip.found {
    color: var(--text-dim);
    text-decoration: line-through;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line);
}

.chip.hinted {
    letter-spacing: 0.08em;
    font-weight: 800;
    color: var(--accent-2);
}

/* Cascade Puzzles: single active target word instead of a word-chip list. */
.cascade-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px 14px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    text-align: center;
}

.cascade-target-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cascade-target-word {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--accent-2);
    line-height: 1.15;
}

.chip.pop {
    animation: chipPop 0.35s ease;
}

.chip.tutorial-target {
    box-shadow: 0 0 0 2px #FDCB6E, 0 0 18px rgba(253, 203, 110, 0.45);
    animation: tutorialPulse 1.4s ease-in-out infinite;
}

@keyframes tutorialPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes chipPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

/* Grid area — board + directions pack to the top of leftover column space.
 * Growing/centering the canvas area in unused height left a large gap between
 * the word chips and the board (the leftover sat above a vertically centered
 * grid). Extra space now falls below the directions. */
.grid-wrap {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Headroom for the selection pill, which now sits entirely above the board.
     * This wrap clips (overflow: hidden below), so the padding has to cover the
     * full pill height plus its gap and drop shadow - not just the part that
     * used to poke out. */
    padding: 2.4rem 12px 12px;
    min-height: 0;
    overflow: hidden;
}

.grid-canvas-area {
    flex: 0 1 auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    min-height: 0;
    overflow: visible;
}

.grid-board {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

/* Live drag preview: letters the finger covers. Sits fully clear of the board:
 * it used to hang 40% of its height over the top row, so the pill covered the
 * very letters it was there to spell out. The 6px keeps it off the edge rather
 * than resting on it. */
.play-selection-preview {
    position: absolute;
    left: 50%;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 6px));
}

.play-selection-preview-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.35rem;
    padding: 0.1rem 0.55rem;
    border-radius: var(--radius-chip, 999px);
    font-size: 0.9375rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1;
    text-transform: uppercase;
    color: var(--text);
    background: var(--accent-soft);
    box-shadow:
        inset 0 0 0 1.5px color-mix(in srgb, var(--accent-2) 35%, transparent),
        0 2px 8px rgba(40, 74, 81, 0.12);
    opacity: 0;
    transform: translateY(2px) scale(0.98);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.play-selection-preview.is-active .play-selection-preview-text {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.grid-surface {
    position: relative;
    background: var(--bg-grid);
    border-radius: 18px;
    padding: 8px;
    box-shadow: 0 2px 5px rgba(120, 90, 60, 0.12);
    touch-action: none;
    overflow: hidden;
}

.grid-surface canvas {
    display: block;
    border-radius: 10px;
    touch-action: none;
}

.grid-surface.shake {
    animation: shake 0.3s ease;
}

.play-directions[hidden] {
    display: none !important;
}

.play-directions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    width: 100%;
    max-width: 360px;
    margin-top: 10px;
    flex-shrink: 0;
}

.play-directions-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-soft);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.play-directions-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.play-directions--many .play-direction-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
}

.play-directions--many .play-direction-icon .direction-svg {
    width: 17px;
    height: 17px;
}

.play-direction-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--text-soft);
    box-shadow: inset 0 0 0 1px rgba(40, 74, 81, 0.08);
}

.play-direction-icon .direction-svg {
    width: 20px;
    height: 20px;
    display: block;
}

.play-direction-icon[data-direction="horizontal"] .direction-svg { transform: rotate(0deg); }
.play-direction-icon[data-direction="vertical"] .direction-svg { transform: rotate(90deg); }
.play-direction-icon[data-direction="diagonal-down"] .direction-svg { transform: rotate(45deg); }
.play-direction-icon[data-direction="diagonal-up"] .direction-svg { transform: rotate(-45deg); }
.play-direction-icon[data-direction="horizontal-reverse"] .direction-svg { transform: rotate(180deg); }
.play-direction-icon[data-direction="vertical-reverse"] .direction-svg { transform: rotate(270deg); }
.play-direction-icon[data-direction="diagonal-down-reverse"] .direction-svg { transform: rotate(225deg); }
.play-direction-icon[data-direction="diagonal-up-reverse"] .direction-svg { transform: rotate(135deg); }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Play screen: header + chips + grid fill remaining space; nav in flex flow.
 * margin-top reserves space for .bottom-nav::before (wave crest above the bar). */
#screen-play .play-bottom-nav {
    position: relative;
    flex-shrink: 0;
    align-self: stretch;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 30;
    display: flex !important;
    margin-top: var(--bottom-nav-wave-height);
    margin-left: calc(-1 * var(--safe-left));
    margin-right: calc(-1 * var(--safe-right));
    margin-bottom: calc(-1 * var(--safe-bottom));
    padding: 0 8px calc(6px + var(--safe-bottom));
}

html.ios-browser-banner #screen-play .play-bottom-nav {
    margin-bottom: 0;
    padding-bottom: 6px;
}

/* Play bottom nav — same chrome as app nav, with hint + sound controls. */
.play-bottom-nav {
    display: flex;
    flex-shrink: 0;
    justify-content: space-evenly;
}

.play-bottom-nav .bottom-nav-item {
    flex: 0 1 auto;
    min-width: 76px;
    max-width: 140px;
}

.play-bottom-nav .play-letter-scale-group {
    flex: 0 1 auto;
    min-width: 88px;
    max-width: 140px;
}

.play-bottom-nav-icon-wrap,
.play-bottom-nav .bottom-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.play-bottom-nav .bottom-nav-icon[data-icon="hint"] svg {
    stroke: var(--accent-2);
}

.play-bottom-nav-hint.hidden {
    display: none !important;
}

.play-hint-count {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent-2);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 4px rgba(120, 90, 60, 0.22);
}

.play-letter-scale-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    min-width: 88px;
    max-width: 140px;
    min-height: 52px;
    padding: 6px 4px;
    gap: 3px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.play-letter-scale-group .bottom-nav-label {
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

/* Font-size stepper: two bare letters, each carrying a small sign at its
 * upper right. No fill, no ring, no divider - it sits between two 24px stroke
 * glyphs and is the least important of the three, so it gets the same
 * --text-muted and the same press feel as they do and nothing more. Earlier
 * passes wrapped it in a tinted pill; that made the quietest control the
 * loudest object in the bar.
 *
 * The row is pinned to 24px, matching those glyphs, so "Font Size" keeps the
 * same baseline as "Hints" and "Sounds On": the column is centre-justified, so
 * any other height shifts the label out of line. */
.play-letter-scale-icon-row {
    position: relative;
    display: inline-flex;
    flex-direction: row;
    align-items: stretch;
    /* 88px is two 44px halves. Not cosmetic - it is what puts the two tap
     * targets exactly edge to edge; see ::after below. */
    width: 88px;
    height: 24px;
    flex: 0 0 24px;
}

.play-letter-step-btn {
    position: relative;
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    padding: 0 0 3px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.12s ease, opacity 0.15s ease, transform 0.12s ease;
}

/* Sign rides at the top right of the A. It stays in flow rather than being
 * absolutely positioned, so the A-plus-sign pair centres in the 44px half as
 * one unit - positioned absolutely, the A alone would centre and the pair
 * would sit visibly left of centre. flex-start puts the sign's top on the A's
 * top; the wrapper's height stays the A's height, so the two halves still
 * bottom-align and the baselines hold. */
.play-letter-step-glyph {
    display: inline-flex;
    align-items: flex-start;
    gap: 1px;
    line-height: 1;
}

.play-letter-step-a {
    font-size: 16px;
    line-height: 1;
}

.play-letter-step-btn.is-larger .play-letter-step-a {
    font-size: 21px;
}

.play-letter-step-sign {
    font-size: 10px;
    line-height: 1;
    font-weight: 800;
}

/* A 24px-tall control is well under the 44pt iOS minimum. Grow the hit box
 * with a pseudo-element rather than the button, so each target reaches 44x44
 * while the glyphs stay 24px and the nav bar keeps its height - a 44px-tall
 * button would make this column taller than the two beside it and push the bar
 * up into the grid. */
.play-letter-step-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}

/* Press feedback is the letter itself going accent, plus the same scale as
 * .bottom-nav-item beside it. A background tint would need a shape to sit in,
 * and there is deliberately no longer one. */
.play-letter-step-btn:active:not(:disabled) {
    color: var(--accent-2);
    transform: scale(0.94);
}

.play-letter-step-btn:disabled {
    opacity: 0.32;
    cursor: not-allowed;
}

.play-letter-step-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Solved overlay */
/* Unlike the app's other three modals, this one lives inside .screen rather
 * than .app-shell - and screens are inset by the safe areas. With `inset: 0`
 * the scrim stopped at the Dynamic Island and the home indicator, leaving a
 * band of warm shell above and below a full-screen dim. Cancel the parent's
 * inset so the dimming is full-bleed like the others; .app-shell is
 * overflow: hidden, so the negative offsets clip to the frame.
 *
 * The scrim goes edge to edge, the CARD does not: the padding keeps it clear of
 * the island and the home indicator. Full-bleed dimming, safe-area content. */
.overlay {
    position: absolute;
    top: calc(-1 * var(--safe-top));
    right: calc(-1 * var(--safe-right));
    bottom: calc(-1 * var(--safe-bottom));
    left: calc(-1 * var(--safe-left));
    background: var(--overlay-scrim);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
    z-index: 40;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

.overlay-card {
    width: 100%;
    max-width: 340px;
    /* The warm cream that opens --app-bg, so the card sits in the same light as
     * the rest of the app rather than reading as cold white glass. */
    background: #fff6ec;
    backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-card);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-card);
    transform: scale(0.92);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.show .overlay-card {
    transform: scale(1);
}

/* Same construction as the achievement icon well: a rounded square with a soft
 * tinted ground and the shared wave band (joined in components.css), not a solid
 * gradient disc. Teal rather than the achievement gold: the puzzle itself is a
 * statement of fact, not an action, so it sits in the same register as the Daily
 * hero (STYLE_GUIDE §2.1). The wave band paints in currentColor, so the hue is
 * set once here. No .icon-seal and no .ach-tier - neither is generated by the
 * well, so this gets the band only. */
.overlay-card .trophy {
    width: 68px;
    height: 68px;
    margin: 0 auto 14px;
    border-radius: 20px;
    background: var(--stat-teal-soft);
    color: var(--stat-teal);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The glyph lives in its own span so the well can carry a corner seal:
 * renderIcons() assigns innerHTML to every [data-icon] node, so a well holding
 * data-icon itself would wipe the seal out on every render.
 * currentColor, not a hardcoded #fff - the glyph tracks the well's hue. */
.overlay-card .trophy-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
}

.overlay-card .trophy-glyph svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

/* The same .icon-seal component the achievement cards use, scaled for this
 * 68px well (theirs is 42px) and orange instead of teal. The ring punches
 * through this card's cream rather than --bg-surface-strong. */
.overlay-card .trophy-seal {
    width: 24px;
    height: 24px;
    left: -6px;
    bottom: -6px;
    background: var(--stat-teal);
    box-shadow: 0 0 0 3px #fff6ec;
}

.overlay-card .trophy-seal svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.4;
}

.overlay-card h2 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 16px;
}

.overlay-card .result-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}

/* Badges, not a stacked column. Icon beside its number so the two read as one
 * object - stacked, the glyph and the value looked like separate things. Same
 * construction as the reward chip on the achievement and quest banners: soft
 * tinted pill, solid disc, mono tabular value. */
.overlay-card .r-stat {
    display: inline-flex;
    align-items: center;
    /* The coin's box is smaller than the flat discs (its ring makes up the
     * difference), so pin the height or the coins pill would sit shorter. */
    min-height: 34px;
    gap: 7px;
    padding: 5px 12px 5px 5px;
    border-radius: var(--radius-chip);
    background: var(--accent-soft);
}

/* .hidden is (0,1,0) and would lose to the rule above - cascade mode toggles
 * whole cells, so it has to be restated at this specificity. */
.overlay-card .r-stat.hidden {
    display: none;
}

.overlay-card .r-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-2);
    color: #fff;
    flex-shrink: 0;
}

.overlay-card .r-icon svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}

.overlay-card .r-value {
    font-family: var(--font-grid);
    font-size: 15px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--accent-2);
}

/* Visually gone, still announced. The glyph carries the meaning now, but a
 * screen reader would otherwise read three bare numbers - and this keeps the
 * data-i18n binding wired rather than orphaning four locale keys. */
.overlay-card .r-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* One hue per stat; Time keeps the accent from the base rules above. */
.overlay-card .r-stat--score {
    background: var(--stat-teal-soft);
}

.overlay-card .r-stat--score .r-icon {
    background: var(--stat-teal);
}

.overlay-card .r-stat--score .r-value {
    color: var(--stat-teal);
}

.overlay-card .r-stat--coins {
    background: var(--stat-gold-soft);
}

/* The coin keeps its ring wherever it appears - it is one object across the
 * whole app (topbar balance, quest row, reward chips), and a flat disc here made
 * it read as a different token. It is fine that it no longer matches the flat
 * star and clock discs beside it: the coin is a thing, they are glyphs.
 *
 * The ring is a box-shadow, so it takes no layout width. The pill absorbs it in
 * padding-left and gap instead, which keeps the coin's VISUAL edges aligned with
 * the flat discs rather than letting it crowd the pill. */
/* 19px box + 2.5px ring = 24px on screen, the same as the flat discs beside it.
 * The ring takes no layout width, so padding-left and gap are each raised by
 * 2.5px to put the coin's VISUAL edges exactly where theirs are. */
.overlay-card .r-stat--coins {
    padding-left: 7.5px;
    gap: 9.5px;
}

.overlay-card .r-stat--coins .r-icon {
    width: 19px;
    height: 19px;
    background: var(--topbar-coin-bg);
    box-shadow: 0 0 0 2.5px var(--topbar-coin-ring);
}

.overlay-card .r-stat--coins .r-value {
    color: var(--stat-gold);
}

/* Words Found takes the base accent - no override at all - so it renders
 * exactly like Time does on a campaign result. Cascade hides the Time pill, so
 * the orange third slot is vacant, and the cascade overlay ends up mirroring
 * the campaign one position for position: teal score, gold coins, orange
 * right-hand figure.
 *
 * Note this leaves --stat-blue / --stat-blue-soft with no remaining users. */

.overlay-card .result-medal {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: -8px 0 18px;
}

.overlay-card .result-medal.hidden {
    display: none;
}

/* The medal is the same badge as the stats above it - soft tinted pill, solid
 * disc, one hue per tier. It used to be a metallic gradient (#ffe08a -> #f0b429
 * and friends): the only gradient surfaces on this card apart from the primary
 * button, and they read as chrome borrowed from another app. The type stays in
 * --font-ui rather than the stats' mono, because this is a word, not a number. */
.overlay-card .result-medal-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 5px;
    border-radius: var(--radius-chip);
    background: var(--medal-gold-soft);
    color: var(--medal-gold);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Same chip the briefing rows carry, so the reward reads identically whether
 * the player is looking at what a tier pays or at what they just earned. */
.overlay-card .result-medal-coins {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 2px;
    padding: 3px 9px 3px 4px;
    border-radius: var(--radius-chip);
    background: var(--stat-gold-soft);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--stat-gold);
}

.overlay-card .result-medal-coin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--topbar-coin-bg);
    box-shadow: 0 0 0 2px var(--topbar-coin-ring);
    color: #fff;
    box-sizing: content-box;
}

.overlay-card .result-medal-coin svg {
    width: 10px;
    height: 10px;
}

.overlay-card .result-medal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--topbar-coin-bg);
    color: #fff;
    flex-shrink: 0;
}

/* `medal` paints with fill on its child paths, so it survives a wrapper that
 * sets fill: none - but state it, since this disc has no stroke to fall back on. */
.overlay-card .result-medal-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    stroke: none;
}

.overlay-card .result-medal-badge.silver {
    background: var(--medal-silver-soft);
    color: var(--medal-silver);
}

.overlay-card .result-medal-badge.silver .result-medal-icon {
    background: var(--medal-silver);
}

.overlay-card .result-medal-badge.bronze {
    background: var(--medal-bronze-soft);
    color: var(--medal-bronze);
}

.overlay-card .result-medal-badge.bronze .result-medal-icon {
    background: var(--medal-bronze);
}

/* The wrap carried no margins at all, so the last row butted against the
 * primary button and the section title inherited an 18px top from .section-title.
 * Own the spacing here instead. */
.overlay-card .result-leaderboard {
    margin: 0 0 18px;
}

.overlay-card .result-leaderboard .section-title {
    margin: 0 0 10px;
}

.overlay-card .result-medal-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
}

.overlay-card .actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.overlay-card .actions .row {
    display: flex;
    gap: 10px;
}

.overlay-card .actions .row .btn {
    flex: 1;
}

/* .btn.secondary is --bg-surface (white at 72%), which all but vanished once
 * the card became warm cream. The soft accent fill is the same treatment
 * .stat-highlight-play uses for a secondary orange action. */
.overlay-card .actions .btn.secondary {
    background: var(--accent-soft);
    color: var(--accent-2);
}

/* There is no `.btn svg` rule anywhere in the app, so a glyph inside a button
 * falls back to the UA default fill (black). Harmless while Share was white;
 * obvious against the accent fill. Paint it from the button's own colour. */
.overlay-card .actions .btn svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
}

/* Home is icon-only now, reusing .icon-btn - the same component the play footer
 * already uses for Home. Sized to the 52px button row and rounded to a circle so
 * it sits with the pill buttons; .icon-btn is not .btn, so the flex: 1 above
 * leaves it fixed while Share stretches.
 *
 * Its white fill and float shadow are right on the app background, where the
 * button has to lift off the shell. Inside this card nothing else is raised -
 * every surface is a flat tint on cream - so the white puck read as chrome
 * borrowed from another screen. Flat neutral fill, no shadow: Home stays
 * quieter than Share without needing an outline (cards do not outline). */
.overlay-card .actions .row .icon-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-chip);
    background: var(--fill-quiet);
    color: var(--text-soft);
    box-shadow: none;
}

/* .icon-btn:hover paints solid #fff, which would bring the puck straight back.
 * Hold the flat fill; the :active scale is the press feedback either way. */
.overlay-card .actions .row .icon-btn:hover {
    background: var(--fill-quiet);
}

/* --- Accessibility: honor prefers-reduced-motion (STYLE_GUIDE §1.5) --- */
@keyframes shakeReduced {
    0%, 100% { box-shadow: var(--shadow-card), 0 0 0 0 transparent; }
    50%      { box-shadow: var(--shadow-card), 0 0 0 3px var(--error); }
}

@media (prefers-reduced-motion: reduce) {
    .chip {
        transition: none;
    }

    /* Decorative attention motion: remove outright. The tutorial target keeps
     * its box-shadow ring, so the affordance survives without the pulse. */
    .chip.pop,
    .chip.tutorial-target {
        animation: none;
    }

    .play-timer-pill--urgent {
        animation: none;
    }

    /* Invalid selection: replace the translating shake with a non-moving error
     * flash, so the feedback survives without vestibular motion. */
    .grid-surface.shake {
        animation: shakeReduced 0.3s ease;
    }

    /* Solved overlay: keep the opacity fade (not vestibular), drop the spring
     * scale so the card simply appears at its final size. */
    .overlay-card,
    .overlay.show .overlay-card {
        transform: none;
        transition: none;
    }
}

/* --- Pre-game briefing ---------------------------------------------------
 * Shown before every puzzle: what directions words run, what times win which
 * medal, and how to trace a word. Reuses .overlay / .overlay-card, so it
 * inherits the scrim and the safe-area cancellation §7.13 describes. */
.brief-card {
    position: relative;
    text-align: center;
    padding: 24px 22px 22px;
}

/* The briefing covers the play screen's own back button, so without this the
 * puzzle could only be entered, never left. Same construction as .alert-close;
 * fill is pinned off because these are stroked paths (a filled close glyph
 * renders as a solid blob). */
.brief-close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--text-dim);
    cursor: pointer;
}

.brief-close svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
}

.brief-card .brief-head {
    text-align: center;
    margin-bottom: 20px;
}

.brief-card .brief-theme {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    text-transform: capitalize;
}

.brief-card .brief-sub {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.brief-section + .brief-section {
    margin-top: 18px;
}

.brief-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 9px;
}

/* Struck on the same raised-chrome disc as the medals below, so the two rule
 * sections read as one family. This is the opposite of how these arrows are
 * treated elsewhere - in the list header they are deliberately bare, because
 * there they sit beside a real back button and a disc would read as tappable.
 * Inside the briefing there is exactly one control, so the ambiguity is gone
 * and matching the medal discs is worth more than the caution. */
/* Wrapping flex capped at four discs wide, not a four-column grid: a fixed
 * grid parks a short row in the leftmost tracks, so Easy - which allows only
 * two directions - hung left of a centred heading. The cap keeps the 4-per-row
 * wrap the eight-direction modes need while any shorter row centres itself. */
.brief-directions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 152px; /* 4 discs * 32px + 3 gaps * 8px */
    margin-inline: auto;
}

.brief-directions .play-direction-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--podium-medal-face);
    box-shadow: 0 1px 4px rgba(120, 90, 60, 0.18);
    color: var(--text-soft);
}

.brief-directions .play-direction-icon .direction-svg {
    width: 18px;
    height: 18px;
}

.brief-medals {
    display: flex;
    flex-direction: column;
    gap: 7px;
    text-align: left;
}

/* Tier colour comes from the --medal-* family, which §2.2 keeps as a separate
 * axis from the coin gold: a medal tier is a rank, not a currency. */
/* Each tier is a little pedestal: its own metal as a soft ground, the wave
 * motif tinted within that hue (§2.6), and the medal struck on a white disc -
 * the same construction as the leaderboard podium, where the medallion is the
 * constant and the tier is carried by what it sits on. */
.brief-medal {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-btn);
    background: var(--bg-surface);
}

.brief-medal-waves {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.brief-medal > *:not(.brief-medal-waves) {
    position: relative;
    z-index: 1;
}

/* The medal glyph in the tier's own metal, with no disc behind it. A medal
 * icon inside a medal-coloured circle was saying the same thing twice - and
 * forcing fill on it flattened the ribbon-and-disc shape into a blob, because
 * the icon draws its ribbons filled and its disc stroked. Let the icon decide. */
/* Struck on the raised-chrome face, like .podium-medal. */
.brief-medal-disc {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--podium-medal-face);
    box-shadow: 0 1px 4px rgba(120, 90, 60, 0.18);
}

.brief-medal-disc svg {
    width: 19px;
    height: 19px;
}

.brief-medal-pct {
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1;
}

.brief-medal--gold .brief-medal-disc { color: var(--medal-gold); }
.brief-medal--silver .brief-medal-disc { color: var(--medal-silver); }
.brief-medal--bronze .brief-medal-disc { color: var(--medal-bronze); }
.brief-medal--steel .brief-medal-disc { color: var(--text-muted); }

.brief-medal--gold { background: var(--medal-gold-soft); }
.brief-medal--silver { background: var(--medal-silver-soft); }
.brief-medal--bronze { background: var(--medal-bronze-soft); }
/* Lowest cascade tier: off-white ground, soft grey waves (not a medal metal). */
.brief-medal--steel { background: #F7F3EE; }

/* Waves within the row's own metal, never a generic white (§2.6). */
.brief-medal--gold .wave-1 { fill: color-mix(in srgb, var(--medal-gold) 10%, transparent); }
.brief-medal--gold .wave-2 { fill: color-mix(in srgb, var(--medal-gold) 16%, transparent); }
.brief-medal--silver .wave-1 { fill: color-mix(in srgb, var(--medal-silver) 10%, transparent); }
.brief-medal--silver .wave-2 { fill: color-mix(in srgb, var(--medal-silver) 16%, transparent); }
.brief-medal--bronze .wave-1 { fill: color-mix(in srgb, var(--medal-bronze) 10%, transparent); }
.brief-medal--bronze .wave-2 { fill: color-mix(in srgb, var(--medal-bronze) 16%, transparent); }
.brief-medal--steel .wave-1 { fill: rgba(130, 120, 110, 0.10); }
.brief-medal--steel .wave-2 { fill: rgba(130, 120, 110, 0.16); }

.brief-medal-tier {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    flex: 0 0 auto;
}

.brief-medal-time {
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* The coin keeps its ring here as everywhere else (§2.2). */
.brief-medal-coins {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px 3px 4px;
    border-radius: var(--radius-chip);
    background: var(--stat-gold-soft);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    font-weight: 800;
    color: var(--stat-gold);
}

.brief-medal-coin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--topbar-coin-bg);
    box-shadow: 0 0 0 2px var(--topbar-coin-ring);
    color: #fff;
    box-sizing: content-box;
}

.brief-medal-coin svg {
    width: 100%;
    height: 100%;
}

.brief-howto {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text-soft);
}

.brief-card .actions {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.brief-skip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-soft);
    cursor: pointer;
    user-select: none;
    text-align: center;
}

.brief-skip input {
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--accent, #e8875c);
}

.brief-card .actions .btn {
    width: 100%;
}
