/* ============================================================
   Games — Playable client-side games (P017)
   Aurora glass design system; inherits tokens.css variables.
   All game logic is client-side; best score lives in localStorage.
   ============================================================ */

/* ── Shared ──────────────────────────────────────────────── */
.games-intro {
    max-width: 60ch;
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    line-height: 1.7;
}

/* ── Onboarding overlay (P020 Faz 3.7) ────────────────────── */
/* One-time welcome modal for Sudoku + Connections. Dismissed via
   localStorage so returning visitors aren't interrupted. */
.game-onboard {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 18, 0.78);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 1rem;
}

.game-onboard-panel {
    max-width: 440px;
    width: 100%;
    padding: 1.6rem 1.4rem 1.4rem;
    border-radius: 16px;
    border: 1px solid var(--color-border-accent);
    background: var(--color-bg-primary);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.4));
    color: var(--color-text-primary);
}

.game-onboard-title {
    margin: 0 0 .9rem;
    font-size: var(--text-lg);
    font-weight: 800;
    line-height: 1.3;
}

.game-onboard-list {
    list-style: none;
    margin: 0 0 1.2rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.game-onboard-list li {
    position: relative;
    padding-left: 1.6rem;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.game-onboard-list li::before {
    counter-increment: ob-step;
    content: counter(ob-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.2rem;
    height: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
    font-size: .75rem;
    font-weight: 800;
    line-height: 1;
}

.game-onboard-list {
    counter-reset: ob-step;
}

[dir="rtl"] .game-onboard-list li {
    padding-left: 0;
    padding-right: 1.6rem;
}

[dir="rtl"] .game-onboard-list li::before {
    left: auto;
    right: 0;
}

/* ── Accessibility bar (P020 Faz 3.6) ─────────────────────── */
.games-accessibility-bar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 1rem;
}

/* ── Colorblind mode dual-encoding (P020 Faz 3.6) ─────────── */
/* Activated by <html class="colorblind"> from games-core.js. Adds
   shape/icon/weight cues so signals are not conveyed by color alone
   (WCAG 1.4.1 belt-and-braces for the entire games hub).               */

/* Sudoku: red error → red + warning glyph in the cell corner */
html.colorblind .sudoku-cell.is-error::after {
    content: "⚠";
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: .7rem;
    line-height: 1;
    color: var(--color-warning);
    pointer-events: none;
}

/* 2048: tile values get bold + slight letter-spacing for higher
   non-color contrast between adjacent values. */
html.colorblind .g2048-tile {
    font-weight: 900;
    letter-spacing: .02em;
}

/* Minesweeper: flagged cells gain a bold border + pulsing ring so
   the red flag isn't the only signal. */
html.colorblind .ms-cell[data-flagged="1"] {
    outline: 2px dashed var(--color-text-primary);
    outline-offset: -3px;
}

/* Connections solved bands already carry shapes (Faz 1.2) but we
   bump weight here for stronger non-color distinction. */
html.colorblind .cn-band-shape {
    font-weight: 900;
    font-size: 1.55rem;
}

/* Word Guess key states: the green/yellow/grey is already strong,
   but colorblind users benefit from explicit borders on each state. */
html.colorblind .wg-key.wg-correct { box-shadow: inset 0 0 0 3px var(--color-success); }
html.colorblind .wg-key.wg-present { box-shadow: inset 0 0 0 3px var(--color-warning); }
html.colorblind .wg-key.wg-absent  { box-shadow: inset 0 0 0 3px var(--color-text-muted); }

html.colorblind .wg-tile.wg-correct { box-shadow: inset 0 0 0 3px var(--color-success); }
html.colorblind .wg-tile.wg-present { box-shadow: inset 0 0 0 3px var(--color-warning); }
html.colorblind .wg-tile.wg-absent  { box-shadow: inset 0 0 0 3px var(--color-text-muted); }

/* ── Daily streak bento panel (P020 Faz 3.3) ─────────────── */
/* 3-card panel above the games grid showing live daily streaks for
   Sudoku / Word Guess / Connections. Active streak cards glow accent;
   zero-streak cards stay quiet to encourage starting one. */
.games-streak-panel {
    margin: 0 0 1.6rem;
}

.games-streak-heading {
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 0 0 .8rem;
}

.games-streak-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .8rem;
}

.games-streak-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: .15rem .5rem;
    align-items: center;
    padding: .9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--color-border-default);
    background: var(--color-glass-surface);
    text-decoration: none !important;
    color: var(--color-text-secondary);
    transition: background var(--transition-base),
                border-color var(--transition-base),
                transform var(--transition-bounce);
}

.games-streak-card:hover,
.games-streak-card:focus-visible {
    background: var(--color-accent-cyan-dim);
    border-color: var(--color-border-accent);
    color: var(--color-text-primary);
    transform: translateY(-2px);
}

.games-streak-card[data-active="1"] {
    border-color: var(--color-border-accent);
    background: linear-gradient(135deg, var(--color-glass-surface), var(--color-accent-cyan-dim));
}

.games-streak-game {
    grid-column: 1;
    grid-row: 1;
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--color-text-primary);
}

.games-streak-flame {
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: 1.6rem;
    line-height: 1;
    opacity: .55;
    transition: opacity var(--transition-base);
}

.games-streak-card[data-active="1"] .games-streak-flame {
    opacity: 1;
}

.games-streak-num {
    grid-column: 1;
    grid-row: 2;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-accent-cyan);
    font-variant-numeric: tabular-nums;
}

.games-streak-card:not([data-active="1"]) .games-streak-num {
    display: none;
}

.games-streak-meta {
    grid-column: 1 / span 2;
    grid-row: 3;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.games-streak-card[data-active="1"] .games-streak-meta {
    color: var(--color-accent-cyan);
    font-weight: 600;
}

/* Reduced-motion respect */
@media (prefers-reduced-motion: reduce) {
    .games-streak-card,
    .games-streak-card:hover,
    .games-streak-card:focus-visible {
        transition: none;
        transform: none;
    }
}

/* ── Games hub grid ──────────────────────────────────────── */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
    margin: 0;
    padding: 0;
}

.games-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: 1.5rem 1.4rem;
    border: 1px solid var(--color-border-default);
    border-radius: 16px;
    background: var(--color-glass-surface);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.games-card:hover,
.games-card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--color-border-accent);
    background: var(--color-glass-hover);
    outline: none;
}

.games-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
}

.games-card-icon svg {
    width: 22px;
    height: 22px;
}

.games-card-badge {
    position: absolute;
    top: 1.1rem;
    inset-inline-end: 1.1rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    background: var(--color-accent-teal-dim);
    color: var(--color-accent-teal);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: .3px;
}

.games-card-title {
    color: var(--color-text-primary);
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1.35;
}

.games-card-desc {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.6;
}

/* ── Game stage (shared shell for all games) ─────────────── */
.game-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* HUD — score / best / new-game row */
.game-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    width: 100%;
    max-width: 460px;
}

.game-score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    min-width: 92px;
    padding: .55rem .9rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    background: var(--color-bg-secondary);
}

.game-score-label {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
}

.game-score-value {
    color: var(--color-accent-cyan);
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.1;
}

.game-new-btn {
    margin-inline-start: auto;
}

@media (max-width: 520px) {
    .game-new-btn {
        margin-inline-start: 0;
        flex: 1 1 100%;
    }
}

/* ── HUD tools row — sound / undo / hint / pause (P017 upgrade) ──── */
.game-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    max-width: 460px;
}

.game-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .8rem;
    min-height: 44px;
    border: 1px solid var(--color-border-default);
    border-radius: 999px;
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.game-tool-btn svg {
    flex: none;
}

.game-tool-btn:hover:not(:disabled) {
    border-color: var(--color-border-accent);
    color: var(--color-text-primary);
    background: var(--color-glass-hover);
}

.game-tool-btn:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

.game-tool-btn:disabled {
    opacity: .42;
    cursor: not-allowed;
}

/* Remaining-uses pill (e.g. undo count) */
.game-tool-count {
    min-width: 1.25em;
    padding: 0 .35em;
    border-radius: 999px;
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Sound toggle — "on" state lights up; icon swaps via data-on */
.game-sound-btn[data-on="1"] {
    border-color: var(--color-border-accent);
    background: var(--color-accent-teal-dim);
    color: var(--color-accent-teal);
}

.game-sound-btn .game-sound-on { display: none; }
.game-sound-btn .game-sound-off { display: inline; }
.game-sound-btn[data-on="1"] .game-sound-on { display: inline; }
.game-sound-btn[data-on="1"] .game-sound-off { display: none; }

/* Snake pause button — icon swaps to a play glyph while paused */
#snake-pause .game-pause-icon { display: inline; }
#snake-pause .game-resume-icon { display: none; }
#snake-pause[data-paused="1"] .game-pause-icon { display: none; }
#snake-pause[data-paused="1"] .game-resume-icon { display: inline; }
#snake-pause[data-paused="1"] {
    border-color: var(--color-border-accent);
    color: var(--color-accent-teal);
}

/* Board wrapper — anchors the game-over overlay */
.game-board-wrap {
    position: relative;
    width: 100%;
    max-width: 460px;
}

.game-controls-hint {
    max-width: 46ch;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    line-height: 1.6;
    text-align: center;
}

/* ── Game-over / win overlay ─────────────────────────────── */
.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.2rem;
    border-radius: 16px;
    /* Glass scrim over the board — works in both themes */
    background: color-mix(in srgb, var(--color-bg-primary) 78%, transparent);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    text-align: center;
}

.game-overlay-msg {
    margin: 0;
    color: var(--color-text-primary);
    font-size: var(--text-xl);
    font-weight: 700;
}

.game-overlay-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .6rem;
}

/* ── 2048 board ──────────────────────────────────────────── */
.g2048-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2.6%;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 2.6%;
    border: 1px solid var(--color-border-default);
    border-radius: 16px;
    background: var(--color-bg-tertiary);
    /* Numbers are Latin even on RTL pages */
    direction: ltr;
    touch-action: none;
}

.g2048-board:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 3px;
}

.g2048-cell {
    border-radius: 9px;
    background: var(--color-bg-secondary);
}

.g2048-tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--color-accent-cyan-dim);
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-weight: 700;
    /* --g2048-font-scale (default 1) shrinks long-digit tiles; set by 2048.js. */
    font-size: calc(clamp(1.1rem, 5.5vw, 2rem) * var(--g2048-font-scale, 1));
    line-height: 1;
    transition: transform .12s ease;
}

.g2048-tile[data-new="1"] {
    animation: g2048-pop .14s ease;
}

.g2048-tile[data-merged="1"] {
    animation: g2048-merge .14s ease;
}

@keyframes g2048-pop {
    from { transform: scale(.4); }
    to   { transform: scale(1); }
}

@keyframes g2048-merge {
    0%   { transform: scale(1); }
    55%  { transform: scale(1.16); }
    100% { transform: scale(1); }
}

/* Tile value tiers — each uses tokenized accents so both themes hold up */
.g2048-tile[data-val="2"]    { background: var(--color-accent-cyan-dim); color: var(--color-text-secondary); }
.g2048-tile[data-val="4"]    { background: var(--color-accent-teal-dim); color: var(--color-text-secondary); }
.g2048-tile[data-val="8"]    { background: var(--color-accent-cyan); color: var(--color-bg-primary); }
.g2048-tile[data-val="16"]   { background: var(--color-accent-teal); color: var(--color-bg-primary); }
.g2048-tile[data-val="32"]   { background: var(--color-accent-purple); color: var(--color-bg-primary); }
.g2048-tile[data-val="64"]   { background: var(--color-accent-purple); color: #ffffff; }
.g2048-tile[data-val="128"]  { background: var(--color-warning); color: #1a1207; font-size: calc(clamp(1rem, 4.6vw, 1.7rem) * var(--g2048-font-scale, 1)); }
.g2048-tile[data-val="256"]  { background: var(--color-warning); color: #1a1207; font-size: calc(clamp(1rem, 4.6vw, 1.7rem) * var(--g2048-font-scale, 1)); }
.g2048-tile[data-val="512"]  { background: var(--color-warning); color: #1a1207; font-size: calc(clamp(1rem, 4.6vw, 1.7rem) * var(--g2048-font-scale, 1)); }
.g2048-tile[data-val="1024"] { background: var(--color-success); color: #07210f; font-size: calc(clamp(.9rem, 4vw, 1.45rem) * var(--g2048-font-scale, 1)); }
.g2048-tile[data-val="2048"] { background: var(--color-success); color: #07210f; font-size: calc(clamp(.9rem, 4vw, 1.45rem) * var(--g2048-font-scale, 1)); }
.g2048-tile[data-val="big"]  { background: var(--color-accent-cyan); color: var(--color-bg-primary); font-size: calc(clamp(.85rem, 3.6vw, 1.3rem) * var(--g2048-font-scale, 1)); }

/* ── Block Puzzle board + tray ───────────────────────────── */
.bp-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 6px;
    border: 1px solid var(--color-border-default);
    border-radius: 16px;
    background: var(--color-bg-tertiary);
    direction: ltr;
    touch-action: none;
}

.bp-cell {
    border-radius: 5px;
    background: var(--color-bg-secondary);
    transition: background .1s ease;
}

.bp-cell[data-filled="1"] {
    background: var(--color-accent-cyan);
}

.bp-cell[data-preview="ok"] {
    background: var(--color-accent-teal-dim);
    box-shadow: inset 0 0 0 2px var(--color-accent-teal);
}

.bp-cell[data-preview="bad"] {
    background: color-mix(in srgb, var(--color-error) 22%, transparent);
}

.bp-cell[data-clear="1"] {
    animation: bp-clear .22s ease;
}

@keyframes bp-clear {
    0%   { transform: scale(1); }
    50%  { transform: scale(.6); opacity: .4; }
    100% { transform: scale(1); }
}

.bp-tray {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
    width: 100%;
    max-width: 460px;
}

.bp-piece {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    padding: .55rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: 12px;
    background: var(--color-bg-secondary);
    cursor: grab;
    touch-action: none;
}

.bp-piece[data-used="1"] {
    opacity: .28;
    cursor: default;
}

.bp-piece[data-dragging="1"] {
    cursor: grabbing;
    opacity: .55;
}

.bp-piece-grid {
    display: grid;
    gap: 3px;
}

.bp-piece-cell {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.bp-piece-cell[data-on="1"] {
    background: var(--color-accent-cyan);
}

/* Floating piece that follows the pointer while dragging */
.bp-drag-ghost {
    position: fixed;
    z-index: 60;
    display: grid;
    gap: 4px;
    padding: 4px;
    pointer-events: none;
    opacity: .9;
}

.bp-drag-ghost .bp-ghost-cell {
    border-radius: 4px;
    background: var(--color-accent-teal);
}

/* ── Snake canvas ────────────────────────────────────────── */
.snake-canvas {
    width: 100%;
    max-width: 460px;
    height: auto;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--color-border-default);
    border-radius: 16px;
    background: var(--color-bg-tertiary);
    touch-action: none;
}

.snake-canvas:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 3px;
}

/* ── How-to-play list ────────────────────────────────────── */
.game-howto {
    margin-top: 2.4rem;
}

.game-section-title {
    margin: 0 0 1rem;
    color: var(--color-text-primary);
    font-size: var(--text-xl);
    font-weight: 700;
}

.game-howto-list {
    margin: 0;
    padding-inline-start: 1.3rem;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.8;
}

.game-howto-list li {
    margin-bottom: .35rem;
}

/* ── FAQ ─────────────────────────────────────────────────── */
.game-faq {
    margin-top: 2.4rem;
}

.game-faq-item {
    border-bottom: 1px solid var(--color-border-subtle);
}

.game-faq-q {
    padding: .9rem 0;
    color: var(--color-text-primary);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.game-faq-q::-webkit-details-marker {
    display: none;
}

.game-faq-q::before {
    content: "+";
    display: inline-block;
    width: 1.1em;
    color: var(--color-accent-cyan);
    font-weight: 700;
}

.game-faq-item[open] .game-faq-q::before {
    content: "\2212"; /* minus */
}

.game-faq-a {
    margin: 0 0 1rem;
    padding-inline-start: 1.1em;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.7;
}

/* ── Global leaderboard panel (P017) ─────────────────────── */
.game-leaderboard {
    margin-top: 2.5rem;
}

.game-lb-subtitle {
    margin: -0.4rem 0 1rem;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

/* Nickname box — prominent surface card; players name themselves on the board.
   The Save button + status line are injected by games-core.js. */
.game-lb-nick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .55rem;
    max-width: 27rem;
    margin-bottom: 1.1rem;
    padding: .85rem 1rem;
    border: 1px solid var(--color-border-default);
    border-radius: 14px;
    background: var(--color-glass-surface);
}

.game-lb-nick label {
    flex-basis: 100%;
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
}

.game-lb-nick-input {
    flex: 1 1 9rem;
    min-width: 0;
    padding: .55rem .8rem;
    border: 1px solid var(--color-border-default);
    border-radius: 10px;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-size: var(--text-sm);
}

.game-lb-nick-input:focus-visible {
    border-color: var(--color-border-accent);
    outline: none;
}

/* Save button — reuses .btn-glass-primary look, sized compact for the row */
.game-lb-nick-save {
    flex: 0 0 auto;
    padding: .5rem 1.1rem;
    font-size: var(--text-sm);
}

/* Confirmation line — fades in briefly after a successful save */
.game-lb-nick-status {
    flex-basis: 100%;
    min-height: 1.1em;
    margin: 0;
    color: var(--color-success);
    font-size: var(--text-xs);
    font-weight: 600;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 280ms ease, transform 280ms ease;
}

.game-lb-nick-status.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .game-lb-nick-status {
        transition: none;
    }
}

/* Period toggle — fieldset reset, pill buttons */
.game-lb-periods {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
}

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

.game-lb-period {
    padding: .35rem .85rem;
    border: 1px solid var(--color-border-default);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.game-lb-period:hover {
    border-color: var(--color-border-accent);
    color: var(--color-text-primary);
}

.game-lb-period[aria-pressed="true"] {
    border-color: var(--color-border-accent);
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
}

.game-lb-period:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

/* Leaderboard table */
.game-lb-list {
    border: 1px solid var(--color-border-default);
    border-radius: 14px;
    background: var(--color-glass-surface);
    overflow: hidden;
}

.game-lb-empty {
    margin: 0;
    padding: 1.4rem 1.2rem;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    text-align: center;
}

.game-lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.game-lb-table th {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--color-border-default);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 600;
    text-align: start;
}

.game-lb-table td {
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--color-border-subtle, var(--color-border-default));
    color: var(--color-text-primary);
}

.game-lb-table tbody tr:last-child td {
    border-bottom: 0;
}

.game-lb-num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.game-lb-me {
    background: var(--color-accent-cyan-dim);
}

.game-lb-me td {
    color: var(--color-accent-cyan);
    font-weight: 600;
}

.game-lb-youtag {
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    font-weight: 400;
}

/* ── Related internal-link CTA ───────────────────────────── */
.game-related {
    margin-top: 2rem;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

/* ── 2048 — slide animation, font scaling, milestone burst ───────── */
/* A tile mid-slide is layered above the rest; transform is set inline by JS.
   Dynamic font scaling lives on the tile-tier rules above via the
   --g2048-font-scale custom property (set per tile by 2048.js). */
.g2048-tile[data-sliding="1"] {
    z-index: 2;
    transition: none;
    will-change: transform;
}

/* Milestone celebration — a short particle burst over the tile. */
.g2048-burst {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.g2048-spark {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-warning);
    animation: g2048-spark-fly .6s ease-out forwards;
}

@keyframes g2048-spark-fly {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

/* ── Block Puzzle — score popup, hint, line-clear sparks ─────────── */
/* Floating "+points" popup anchored at the placement. */
.bp-popup {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    pointer-events: none;
    animation: bp-popup-rise 1s ease-out forwards;
}

.bp-popup-amt {
    color: var(--color-accent-teal);
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: 700;
    text-shadow: 0 1px 4px var(--color-bg-primary);
}

.bp-popup-streak {
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--color-accent-purple);
    color: #ffffff;
    font-size: var(--text-xs);
    font-weight: 700;
}

@keyframes bp-popup-rise {
    0%   { transform: translate(-50%, -40%) scale(.7); opacity: 0; }
    20%  { transform: translate(-50%, -55%) scale(1); opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* Line-clear sparks emitted from each cleared cell. */
.bp-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent-cyan);
    pointer-events: none;
    animation: bp-spark-fly .55s ease-out forwards;
}

@keyframes bp-spark-fly {
    0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; }
}

/* Hint highlight — pulses a valid placement + the matching tray piece. */
.bp-cell[data-hint="1"] {
    background: var(--color-accent-teal-dim);
    box-shadow: inset 0 0 0 2px var(--color-accent-teal);
    animation: bp-hint-pulse 1s ease-in-out infinite;
}

.bp-piece[data-hint="1"] {
    border-color: var(--color-border-accent);
    animation: bp-hint-pulse 1s ease-in-out infinite;
}

@keyframes bp-hint-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}

/* ── Reduced motion ──────────────────────────────────────── */
/* Animations off, but every game stays fully playable (instant moves). */
@media (prefers-reduced-motion: reduce) {
    .games-card,
    .g2048-tile,
    .g2048-tile[data-sliding="1"],
    .bp-cell,
    .game-tool-btn {
        transition: none;
    }
    .games-card:hover,
    .games-card:focus-visible {
        transform: none;
    }
    .g2048-tile[data-new="1"],
    .g2048-tile[data-merged="1"],
    .g2048-spark,
    .bp-cell[data-clear="1"],
    .bp-spark,
    .bp-popup,
    .bp-cell[data-hint="1"],
    .bp-piece[data-hint="1"] {
        animation: none;
    }
    /* The popup still needs to fade out so it does not linger forever. */
    .bp-popup {
        animation: bp-popup-fade .9s ease forwards;
    }
    .g2048-burst {
        display: none;
    }
    .game-overlay {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

@keyframes bp-popup-fade {
    0%, 70% { opacity: 1; }
    100%    { opacity: 0; }
}

/* ── Sudoku ──────────────────────────────────────────────── */
/* Difficulty selector — pill buttons (shared pattern with the period toggle) */
.game-difficulty {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .9rem;
    padding: 0;
    border: 0;
}

.game-difficulty-legend {
    margin-inline-end: .35rem;
    padding: 0;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

.game-difficulty-btn {
    padding: .4rem 1rem;
    border: 1px solid var(--color-border-default);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.game-difficulty-btn:hover {
    border-color: var(--color-border-accent);
    color: var(--color-text-primary);
}

.game-difficulty-btn[aria-pressed="true"] {
    border-color: var(--color-border-accent);
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
    font-weight: 600;
}

.game-difficulty-btn:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

/* 9x9 board — 1px gap shows grid lines; 2px insets mark the 3x3 boxes */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 1px;
    width: 100%;
    max-width: 460px;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--color-text-primary);
    border-radius: 8px;
    background: var(--color-border-default);
    overflow: hidden;
    touch-action: manipulation;
}

.sudoku-board:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

.sudoku-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    color: var(--color-accent-cyan);
    font-size: clamp(1rem, 5vw, 1.6rem);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.sudoku-box-r { box-shadow: inset -2px 0 0 0 var(--color-text-primary); }
.sudoku-box-b { box-shadow: inset 0 -2px 0 0 var(--color-text-primary); }
.sudoku-box-r.sudoku-box-b {
    box-shadow: inset -2px 0 0 0 var(--color-text-primary),
                inset 0 -2px 0 0 var(--color-text-primary);
}

.sudoku-given {
    color: var(--color-text-primary);
    cursor: default;
}

.sudoku-cell.is-peer { background: var(--color-accent-cyan-dim); }
.sudoku-cell.is-same {
    background: color-mix(in srgb, var(--color-accent-teal) 26%, transparent);
}
.sudoku-cell.is-selected {
    background: color-mix(in srgb, var(--color-accent-cyan) 34%, transparent);
}
.sudoku-cell.is-error { color: var(--color-error); }
.sudoku-cell.is-error.is-selected {
    background: color-mix(in srgb, var(--color-error) 26%, transparent);
}

.sudoku-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 1px;
}

.sudoku-notes span {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: clamp(.4rem, 1.9vw, .64rem);
    font-weight: 500;
}

.sudoku-pop { animation: sudoku-pop .22s ease; }
.sudoku-shake { animation: sudoku-shake .3s ease; }

@keyframes sudoku-pop {
    0%   { transform: scale(.6); }
    60%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

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

/* Number pad — mobile-friendly in-app keypad (1-9 + erase) */
.sudoku-pad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .4rem;
    width: 100%;
    max-width: 460px;
}

.sudoku-pad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .7rem 0;
    border: 1px solid var(--color-border-default);
    border-radius: 10px;
    background: var(--color-glass-surface);
    color: var(--color-text-primary);
    font-size: clamp(1.05rem, 4vw, 1.35rem);
    font-weight: 600;
    cursor: pointer;
    transition: border-color .14s ease, background .14s ease, opacity .14s ease;
}

.sudoku-pad-btn:hover {
    border-color: var(--color-border-accent);
    background: var(--color-accent-cyan-dim);
}

.sudoku-pad-btn:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

.sudoku-pad-btn.is-done {
    opacity: .3;
    pointer-events: none;
}

.sudoku-pad-erase { color: var(--color-text-secondary); }

@media (prefers-reduced-motion: reduce) {
    .sudoku-pop,
    .sudoku-shake { animation: none; }
}

/* ── Minesweeper ─────────────────────────────────────────── */
.minesweeper-status {
    min-height: 1.2em;
    margin: 0 0 .6rem;
    color: var(--color-accent-cyan);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Expert boards are wide — the wrap scrolls horizontally on narrow screens */
.minesweeper-board-wrap {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
}

.minesweeper-board {
    --ms-cell: clamp(20px, 4.6vw, 32px);
    display: grid;
    gap: 2px;
    width: max-content;
    margin-inline: auto;
    padding: 4px;
    border-radius: 8px;
    background: var(--color-border-default);
    touch-action: manipulation;
}

.minesweeper-board:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

.ms-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ms-cell);
    height: var(--ms-cell);
    border-radius: 3px;
    background: var(--color-glass-surface);
    color: var(--color-text-primary);
    font-size: calc(var(--ms-cell) * .56);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.ms-cell:hover { background: var(--color-accent-cyan-dim); }

.ms-cell.is-revealed {
    background: var(--color-bg-primary);
    cursor: default;
}

.ms-cell.is-revealed:hover { background: var(--color-bg-primary); }

.ms-cell.is-flagged {
    background: var(--color-accent-cyan-dim);
    color: var(--color-error);
}

.ms-cell.is-mine {
    background: color-mix(in srgb, var(--color-error) 30%, transparent);
    color: var(--color-error);
}

.ms-cell.is-wrongflag {
    background: color-mix(in srgb, var(--color-warning) 28%, transparent);
}

/* Iconic Minesweeper number colours — deliberately fixed (theme-independent),
   like the 2048 tile palette above; they read on both light and dark cells. */
.ms-cell[data-num="1"] { color: #3b6fe0; }
.ms-cell[data-num="2"] { color: #2f9e44; }
.ms-cell[data-num="3"] { color: #e8590c; }
.ms-cell[data-num="4"] { color: #7048e8; }
.ms-cell[data-num="5"] { color: #c92a2a; }
.ms-cell[data-num="6"] { color: #0c8599; }
.ms-cell[data-num="7"] { color: var(--color-text-primary); }
.ms-cell[data-num="8"] { color: var(--color-text-secondary); }

/* ── Solitaire ───────────────────────────────────────────── */
.solitaire-board-wrap {
    position: relative;
    width: 100%;
    overflow-x: auto;
}

.solitaire-board {
    --sol-card-w: clamp(38px, 12.2vw, 74px);
    --sol-card-h: calc(var(--sol-card-w) * 1.4);
    --sol-fan: calc(var(--sol-card-h) * 0.3);
    --sol-gap: clamp(4px, 1.4vw, 9px);
    width: max-content;
    min-width: 100%;
}

.sol-top,
.sol-tableau {
    display: grid;
    grid-template-columns: repeat(7, var(--sol-card-w));
    gap: var(--sol-gap);
    justify-content: center;
}

.sol-top { margin-bottom: calc(var(--sol-gap) * 2); }

.sol-pile {
    width: var(--sol-card-w);
    height: var(--sol-card-h);
    border-radius: 7px;
    border: 1.5px dashed var(--color-border-default);
}

.sol-gap { visibility: hidden; }

.sol-stock { cursor: pointer; }

.sol-stock.is-recycle::after {
    content: "\21BB";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--color-text-secondary);
    font-size: calc(var(--sol-card-w) * .5);
}

.sol-col {
    display: flex;
    flex-direction: column;
    min-height: var(--sol-card-h);
    border-radius: 7px;
}

.sol-col:empty {
    box-shadow: inset 0 0 0 1.5px var(--color-border-default);
}

.sol-col .sol-card + .sol-card {
    margin-top: calc(var(--sol-fan) - var(--sol-card-h));
}

/* Cards keep a paper look in both themes (like the 2048 tile palette) */
.sol-card {
    position: relative;
    width: var(--sol-card-w);
    height: var(--sol-card-h);
    flex: 0 0 auto;
    border-radius: 7px;
    background: #f7f5ee;
    color: #1a1a1a;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .28);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.sol-card.is-red { color: #c92a2a; }

.sol-card.is-down {
    background:
        repeating-linear-gradient(45deg, #2f6f9f 0 6px, #3a82b8 6px 12px);
}

.sol-card-corner {
    position: absolute;
    top: 3px;
    inset-inline-start: 4px;
    font-size: calc(var(--sol-card-w) * .26);
    font-weight: 700;
    line-height: 1;
}

.sol-card-pip {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--sol-card-w) * .54);
}

.sol-card.is-selected {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: -1px;
}

.sol-pile.is-target,
.sol-col.is-target {
    box-shadow: inset 0 0 0 2px var(--color-accent-teal);
}

/* Waste fans the last few drawn cards (relevant in draw-3) */
.sol-waste { position: relative; }

.sol-waste-card {
    position: absolute;
    top: 0;
    inset-inline-start: calc(var(--wi) * 0.34 * var(--sol-card-w));
}

/* ── Word Guess — daily 5-letter word puzzle (P017 Faz 4A) ───── */
.wg-game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* "Coming soon" notice — shown when the game is not yet live in a language */
.wg-comingsoon {
    display: block;
    max-width: 52ch;
    margin: .6rem 0 1.4rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--color-border-accent);
    border-radius: 14px;
    background: var(--color-accent-teal-dim);
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    line-height: 1.65;
}

/* HUD: mode toggle + streak + sound */
.wg-hud {
    justify-content: space-between;
}

.wg-modes {
    display: inline-flex;
    gap: .2rem;
    margin: 0;
    padding: .25rem;
    border: 1px solid var(--color-border-default);
    border-radius: 999px;
    background: var(--color-bg-secondary);
}

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

.wg-mode-btn {
    padding: .4rem 1rem;
    min-height: 44px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background .16s ease, color .16s ease;
}

.wg-mode-btn[aria-pressed="true"] {
    background: var(--color-accent-cyan-dim);
    color: var(--color-accent-cyan);
}

.wg-mode-btn:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

.wg-streak-box {
    min-width: 76px;
}

/* Board — six rows of five tiles */
.wg-board {
    display: flex;
    flex-direction: column;
    gap: .38rem;
    width: 100%;
    max-width: 330px;
    /* Letters read left-to-right even on RTL pages */
    direction: ltr;
}

.wg-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .38rem;
}

.wg-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--color-border-default);
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-size: clamp(1.3rem, 7vw, 2rem);
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    -webkit-user-select: none;
    user-select: none;
}

.wg-tile.wg-filled {
    border-color: var(--color-border-accent);
}

.wg-tile.wg-correct {
    border-color: transparent;
    background: var(--color-success);
    color: #07210f;
}

.wg-tile.wg-present {
    border-color: transparent;
    background: var(--color-warning);
    color: #1a1207;
}

.wg-tile.wg-absent {
    border-color: transparent;
    background: color-mix(in srgb, var(--color-text-muted) 52%, var(--color-bg-tertiary));
    color: var(--color-bg-primary);
}

.wg-tile.wg-flip {
    animation: wg-flip .5s ease;
}

@keyframes wg-flip {
    0%   { transform: rotateX(0); }
    50%  { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

.wg-row.wg-shake {
    animation: wg-shake .4s ease;
}

@keyframes wg-shake {
    0%, 100%   { transform: translateX(0); }
    20%, 60%   { transform: translateX(-5px); }
    40%, 80%   { transform: translateX(5px); }
}

/* Status message line */
.wg-message {
    min-height: 1.5rem;
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    text-align: center;
}

.wg-message-good { color: var(--color-success); }
.wg-message-bad  { color: var(--color-text-primary); }
.wg-message-warn { color: var(--color-warning); }

.wg-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    min-height: 1.2rem;
}

.wg-countdown {
    margin: 0;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

/* On-screen keyboard */
.wg-keyboard {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    width: 100%;
    max-width: 480px;
}

.wg-kb-row {
    display: flex;
    justify-content: center;
    gap: .3rem;
}

.wg-key {
    flex: 1 1 auto;
    min-width: 0;
    height: 48px;
    padding: 0 .15rem;
    border: 1px solid var(--color-border-default);
    border-radius: 7px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.wg-key-action {
    flex: 1.6 1 auto;
    font-size: var(--text-base);
}

.wg-key:hover {
    border-color: var(--color-border-accent);
    background: var(--color-glass-hover);
}

.wg-key:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 1px;
}

.wg-key.wg-correct {
    border-color: transparent;
    background: var(--color-success);
    color: #07210f;
}

.wg-key.wg-present {
    border-color: transparent;
    background: var(--color-warning);
    color: #1a1207;
}

.wg-key.wg-absent {
    border-color: transparent;
    background: color-mix(in srgb, var(--color-text-muted) 52%, var(--color-bg-tertiary));
    color: var(--color-bg-primary);
}

@media (max-width: 420px) {
    .wg-key { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .wg-tile.wg-flip,
    .wg-row.wg-shake {
        animation: none;
    }
}

/* ── Grouping — daily 16-word grouping puzzle (P017 Faz 4B) ─────── */
.cn-game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.cn-hud {
    justify-content: space-between;
}

/* Mistakes — four dots that deplete */
.cn-mistakes-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
}

.cn-mistakes {
    display: inline-flex;
    gap: .35rem;
}

.cn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-border-default);
}

.cn-dot-used {
    background: var(--color-warning);
}

.cn-streak-box {
    min-width: 72px;
}

/* Solved-group bands */
.cn-solved {
    display: flex;
    flex-direction: column;
    gap: .42rem;
    width: 100%;
    max-width: 460px;
}

.cn-band {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: .6rem .8rem;
    border-radius: 10px;
    text-align: center;
}

.cn-band-name {
    font-size: var(--text-sm);
    font-weight: 800;
    letter-spacing: .4px;
    text-transform: uppercase;
}

/* P020 Faz 1.2 — Colorblind-safe shape prefix (WCAG 1.4.1).
   Square / circle / triangle / diamond, visually distinct regardless of palette. */
.cn-band-shape {
    font-size: 1.35rem;
    line-height: 1;
    margin-bottom: 4px;
    display: inline-block;
    -webkit-user-select: none;
    user-select: none;
}

.cn-band-words {
    font-size: var(--text-xs);
    font-weight: 600;
}

/* Group colours — easy (yellow) to hard (purple) */
.cn-g0 { background: var(--color-warning);      color: #1a1207; }
.cn-g1 { background: var(--color-success);      color: #07210f; }
.cn-g2 { background: var(--color-accent-cyan);  color: #06222a; }
.cn-g3 { background: var(--color-accent-purple); color: #ffffff; }

/* Word grid */
.cn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .42rem;
    width: 100%;
    max-width: 460px;
}

.cn-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 62px;
    padding: .3rem .25rem;
    border: 1px solid var(--color-border-default);
    border-radius: 9px;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-size: clamp(.6rem, 2.5vw, .8rem);
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    text-transform: uppercase;
    word-break: break-word;
    cursor: pointer;
    transition: background .14s ease, color .14s ease, transform .1s ease;
}

.cn-tile:hover:not(:disabled) {
    border-color: var(--color-border-accent);
    background: var(--color-glass-hover);
}

.cn-tile:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 1px;
}

.cn-tile.is-selected {
    border-color: transparent;
    background: var(--color-text-primary);
    color: var(--color-bg-primary);
}

.cn-tile:disabled {
    cursor: default;
}

.cn-tile.cn-shake {
    animation: wg-shake .4s ease;
}

/* Status message */
.cn-message {
    min-height: 1.5rem;
    margin: 0;
    font-size: var(--text-sm);
    font-weight: 600;
    text-align: center;
}

.cn-message-good { color: var(--color-success); }
.cn-message-bad  { color: var(--color-text-primary); }
.cn-message-warn { color: var(--color-warning); }

/* Control row — shuffle / deselect / submit */
.cn-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

@media (prefers-reduced-motion: reduce) {
    .cn-tile.cn-shake {
        animation: none;
    }
}
