/**
 * Noos Solitaire — game styles
 * assets/css/games/solitaire.css (card faces live in assets/css/cards.css)
 */
        :root {
            /* Fits 7 tableau columns + gaps within the narrowest common phone
               viewports (320-375px) without horizontal overflow — verified
               against .solitaire-board's own 12px side padding. The original
               canvas version had no floor at all (it just shrunk to fit); a
               46px floor here would overflow on exactly that width range, so
               32px is the safe minimum rather than an arbitrary touch-target
               number. */
            --card-w: clamp(32px, 11.5vw, 130px);
            --card-h: calc(var(--card-w) * 1.4);
            --slate: #334155;
            --accent-orange: #b45309;
        }
        body, html {
            margin: 0; padding: 0;
            background: #f1f5f9;
            font-family: 'Quicksand', sans-serif;
            user-select: none;
            -webkit-user-select: none;
            /* NOTE: touch-action is intentionally NOT set to none here anymore —
               that blocked all scrolling on the entire page, which is exactly
               why there was no way to scroll to the parts of the tableau that
               don't fit in a short landscape viewport. It's scoped to
               .noos-card below instead, so cards still don't trigger the
               browser's native scroll/zoom gesture while being dragged, but
               the page itself remains scrollable everywhere else. */
        }

        .game-meta {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            max-width: 1100px;
            margin: 5px auto;
            padding: 0 15px;
            gap: 10px;
            box-sizing: border-box;
        }
        .tier-actions {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            flex-wrap: wrap;
            gap: 10px;
        }
        .ui-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 8px 16px;
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 20px;
            text-decoration: none;
            color: #64748b;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.02);
            font-family: 'Quicksand', sans-serif;
            white-space: nowrap;
        }
        .ui-btn:hover { border-color: #b45309; color: #b45309; transform: translateY(-1px); }
        .ui-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: #e2e8f0; color: #94a3b8; }
        .ui-btn:disabled:hover { transform: none; color: #94a3b8; border-color: #e2e8f0; }
        .stats-group { display: flex; gap: 15px; background: white; padding: 8px 15px; border-radius: 15px; border: 1px solid #e2e8f0; flex-wrap: wrap; justify-content: center; }
        .stat-text { font-weight: 800; color: #334155; font-size: 0.9rem; }

        /* ─── Board layout ─────────────────────────────────────────── */
        .solitaire-board {
            /* exactly the width of the 7 tableau columns, so stock/waste and foundations line up with them */
            width: calc(7 * var(--card-w) + 6 * var(--card-w) * 0.12 + 24px);
            max-width: 100%;
            margin: 10px auto 40px;
            padding: 0 12px;
            box-sizing: border-box;
        }

        .top-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            margin-bottom: calc(var(--card-h) * 0.22);
            flex-wrap: nowrap;
        }

        .stock-waste-group { display: flex; gap: calc(var(--card-w) * 0.12); }

        .pile-slot {
            width: var(--card-w);
            height: var(--card-h);
            position: relative;
            border-radius: var(--radius-card, 10px);
            /* Permanent frame, independent of whatever card is currently
               rendered inside — without this, the slot had zero visual
               presence of its own, so swapping its top card (e.g. every
               ~260ms during Auto Complete) made the whole slot look like it
               blinked out of existence for an instant rather than just the
               card changing on top of a stable, persistent pile. */
            background: rgba(255, 255, 255, 0.5);
            box-shadow: inset 0 0 0 1.5px rgba(51, 65, 85, 0.07);
        }

        /* Empty-slot placeholder (matches Spider's completed-slot dashed treatment) */
        .pile-slot.is-empty::before {
            content: attr(data-empty-label);
            position: absolute;
            inset: 0;
            border: 2px dashed #cbd5e1;
            border-radius: var(--radius-card, 10px);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.6rem;
            font-weight: 700;
            text-transform: uppercase;
            color: #94a3b8;
            background: rgba(255,255,255,0.4);
        }

        #stockSlot {
            cursor: pointer;
            /* Isolates stock's paint/layout from its sibling (waste) and
               from the drag/fly system's frequent getBoundingClientRect()
               calls nearby — stock's own content genuinely never changes
               on a waste-card interaction (confirmed: nothing touches its
               DOM outside renderPile's own diff-check), but a browser can
               still repaint an untouched sibling when a flex row reflows
               or is read from repeatedly. Purely a rendering hint — this
               changes nothing about how the slot looks or behaves. */
            contain: layout style paint;
        }
        #stockSlot.is-empty::before { content: "↻"; font-size: 1.4rem; }

        .foundation-row { display: flex; gap: calc(var(--card-w) * 0.12); }

        .tableau-row {
            display: grid;
            grid-template-columns: repeat(7, var(--card-w));
            justify-content: start;
            gap: calc(var(--card-w) * 0.12);
        }

        .tableau-col {
            position: relative;
            min-height: var(--card-h);
        }
        .tableau-col.is-empty::before {
            content: "K";
            position: absolute;
            inset: 0;
            border: 2px dashed #cbd5e1;
            border-radius: var(--radius-card, 10px);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            font-weight: 800;
            color: #cbd5e1;
        }

        .pile-slot .noos-card,
        .tableau-col .noos-card {
            width: var(--card-w) !important;
            height: var(--card-h) !important;
            position: absolute;
            left: 0;
            top: 0;
            touch-action: none;
        }

        /* Drag layer: lifted cards render here, above everything, unaffected by
           column overflow/stacking so they can visually cross pile boundaries. */
        #dragLayer {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 9000;
        }
        #dragLayer .noos-card {
            position: fixed;
            width: var(--card-w);
            height: var(--card-h);
            pointer-events: none;
        }
        #dragLayer .noos-card.is-dragging-live {
            filter: drop-shadow(0 10px 14px rgba(15,23,42,0.25));
        }

        /* Cascade celebration layer */
        #cascadeLayer {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 16000;
            overflow: hidden;
        }
        #cascadeLayer .noos-card {
            position: absolute;
            width: 76px;
            height: calc(76px * 1.4);
        }

        /* Gentle, unobtrusive floating pill — fades/slides in only once the
           board is genuinely safe to auto-finish (see checkAutoCompleteAvailability) */
        #autoCompleteBtn {
            position: fixed;
            bottom: calc(28px + env(safe-area-inset-bottom, 0px));
            left: 50%;
            transform: translateX(-50%) translateY(16px);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.35s ease, transform 0.35s ease;
            background: linear-gradient(135deg, #b45309, #d97706);
            color: white;
            padding: 13px 26px;
            border-radius: 30px;
            border: none;
            font-weight: 700;
            font-family: 'Quicksand', sans-serif;
            font-size: 0.95rem;
            cursor: pointer;
            box-shadow: 0 10px 25px rgba(180, 83, 9, 0.3);
            z-index: 5000;
            animation: autoCompletePulse 2.6s ease-in-out infinite;
        }
        #autoCompleteBtn.visible {
            opacity: 1;
            pointer-events: auto;
            transform: translateX(-50%) translateY(0);
        }
        @keyframes autoCompletePulse {
            0%, 100% { box-shadow: 0 10px 25px rgba(180, 83, 9, 0.3); }
            50%      { box-shadow: 0 10px 32px rgba(180, 83, 9, 0.5); }
        }

        @media(max-width: 768px) {
            .tier-actions { flex-direction: column; gap: 10px; }
            .top-row { gap: 8px; }
        }

        /* Portrait specifically: as Moves/Foundations/Best grow wider digits
           (e.g. single- to double- to triple-digit), the stats bar's wrap
           point shifts between fitting on one line and needing two — a
           visible height "jump" mid-game. Reserving space for the worst
           case (2 lines) up front means it never needs to jump, whether
           it's actually using one line or two at any given moment. Scoped
           to portrait only: landscape's more compact stats styling reliably
           fits one line already, and reserving 2-line height there would
           waste some of the vertical space freed up for the board earlier. */
        @media (max-width: 768px) and (orientation: portrait) {
            .stats-group { min-height: 70px; box-sizing: border-box; }
        }

        /* Short landscape phones: layout tweaks that are still worth keeping
           (tighter margin, row-direction toolbar) — but --card-w itself is
           no longer set here. A fixed formula can't account for how much
           width is actually available (a wide landscape phone has plenty)
           or how deep the tableau's stacks currently are (dynamic, changes
           as the game progresses), so it's computed in JS instead — see
           computeResponsiveCardSize(). */
        @media (orientation: landscape) and (max-height: 500px) {
            .game-meta { margin: 2px auto; gap: 6px; }
            .tier-actions { flex-direction: row; flex-wrap: nowrap; gap: 8px; }
            /* The buttons + stats bar together were too wide to fit one row
               at their normal size, so they wrapped to a second line —
               costing vertical space that could otherwise go to the board.
               Compacting both (smaller padding/gaps/font, smaller icons)
               is what actually makes one row possible, not just requesting
               it — computeResponsiveCardSize() then picks up the shorter
               toolbar automatically, since it measures the real rendered
               height rather than assuming one. */
            .ui-btn { padding: 6px 10px; font-size: 0.72rem; gap: 4px; white-space: nowrap; }
            .ui-btn svg { width: 11px; height: 11px; }
            .stats-group { padding: 6px 10px; gap: 8px; }
            .stat-text { font-size: 0.72rem; }
        }