/* ===================================
   connections — design system
   =================================== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1c1c1c;
    --text-primary: #f5f5f5;
    --text-secondary: #9a9a9a;
    --text-tertiary: #5c5c5c;
    --accent: #f5f5f5;
    --accent-contrast: #0a0a0a;
    --border-color: #262626;
    --border-strong: #3a3a3a;

    --color-wrong: #e5484d;
    --color-selected: #f5f5f5;
    --color-selected-text: #0a0a0a;

    /* connections palette (muted, works on dark) */
    --category-1: #e3b53c;
    --category-2: #57a35e;
    --category-3: #5b8dd6;
    --category-4: #9a62c4;
    --category-text: #0d0d0d;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast: 150ms;
    --t-base: 280ms;
    --t-slow: 500ms;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
}

html.light-theme {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #efefef;
    --text-primary: #111111;
    --text-secondary: #555555;
    --text-tertiary: #999999;
    --accent: #111111;
    --accent-contrast: #fafafa;
    --border-color: #e2e2e2;
    --border-strong: #c8c8c8;
    --color-selected: #111111;
    --color-selected-text: #fafafa;
    --category-1: #efc94f;
    --category-2: #75c37d;
    --category-3: #7fa8e0;
    --category-4: #b07fd6;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
}

/* ===================================
   Base
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    transition: background-color var(--t-base), color var(--t-base);
    overflow-x: hidden;
}

button {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

/* dragging tiles near the top edge shouldn't pull-to-refresh mid-game */
html,
body {
    overscroll-behavior-y: contain;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(var(--space-md) + env(safe-area-inset-top))
        calc(var(--space-md) + env(safe-area-inset-right))
        calc(var(--space-md) + env(safe-area-inset-bottom))
        calc(var(--space-md) + env(safe-area-inset-left));
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ===================================
   Header
   =================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0 var(--space-lg);
}

.header-side {
    flex: 1;
    display: flex;
    gap: var(--space-xs);
}

.header-actions {
    justify-content: flex-end;
}

.header-library-btn {
    min-height: 44px;
    padding: 0.45rem 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.header-library-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.header-library-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.header-center {
    text-align: center;
    cursor: pointer; /* role=button — the wordmark is the way home */
    border-radius: var(--radius-sm);
}

.header-center:hover .title {
    opacity: 0.75;
}

.title {
    font-size: 2.2rem;
    font-weight: 250;
    letter-spacing: 0.08em;
    line-height: 1.15;
    animation: fadeInDown var(--t-slow) var(--ease-out);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.14em;
    animation: fadeInUp var(--t-slow) var(--ease-out) 80ms both;
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

/* ===================================
   Screens
   =================================== */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn var(--t-base) var(--ease-out);
}

/* ===================================
   Prompt screen
   =================================== */
.prompt-card {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    animation: scaleIn var(--t-slow) var(--ease-out);
}

.prompt-lead {
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.prompt-category {
    font-size: 2rem;
    font-weight: 350;
    margin: var(--space-xs) 0 var(--space-sm);
    letter-spacing: 0.01em;
}

.prompt-help {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    line-height: 1.7;
}

.library-picker {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.library-picker-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-sm);
}

.library-count {
    min-height: 1.3em;
    margin-top: var(--space-xs);
    color: var(--text-secondary);
    font-size: 0.72rem;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    position: relative;
    font-size: 0.95rem;
    min-height: 44px;
    padding: 0.7rem 1.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--t-fast) var(--ease-out);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-width: 110px;
    letter-spacing: 0.02em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

.btn-secondary {
    background: transparent;
}

.btn-lg {
    padding: 0.9rem 2rem;
    font-size: 1rem;
}

.btn-icon {
    width: 19px;
    height: 19px;
}

.ghost-btn {
    position: relative;
    background: transparent;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-size: 0.75rem;
    padding: 0.25rem 0.85rem;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: color var(--t-fast), border-color var(--t-fast);
    min-height: 44px;
}

.ghost-btn:hover:not(:disabled) {
    color: var(--text-secondary);
    border-color: var(--text-tertiary);
}

.ghost-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ===================================
   Preview screen
   =================================== */
.preview-card {
    max-width: 480px;
    margin: 0 auto;
    animation: scaleIn var(--t-slow) var(--ease-out);
}

.photo-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-lg);
}

.photo-preview img {
    width: 100%;
    max-height: 55vh;
    object-fit: cover;
    display: block;
}

.preview-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

.prompt-back-btn {
    margin-top: var(--space-sm);
}

/* ===================================
   Share toggle
   =================================== */
.share-toggle {
    margin: var(--space-md) auto 0;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    transition: color var(--t-fast);
    min-height: 44px;
}

.share-toggle-track {
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-strong);
    position: relative;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.share-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: transform var(--t-fast) var(--ease-out), background var(--t-fast);
}

.share-toggle[aria-checked="true"] {
    color: var(--text-secondary);
}

.share-toggle[aria-checked="true"] .share-toggle-track {
    background: var(--accent);
    border-color: var(--accent);
}

.share-toggle[aria-checked="true"] .share-toggle-thumb {
    transform: translateX(14px);
    background: var(--accent-contrast);
}

/* ===================================
   Generating screen
   =================================== */
.generating-card {
    text-align: center;
    padding: var(--space-xl) 0;
}

/* Mini board that solves itself row by row in the category colors —
   the game's own shape as the loading state. One shared keyframe set;
   each row is phase-offset by a negative delay so the loop is seamless. */
.tile-loader {
    display: grid;
    grid-template-columns: repeat(4, 24px);
    gap: 6px;
    justify-content: center;
    margin: 0 auto var(--space-md);
}

.tile-loader span {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    animation: tileSolve 3s var(--ease-out) infinite;
}

.tile-loader span:nth-child(-n+4)                     { --c: var(--category-1); animation-delay: 0s; }
.tile-loader span:nth-child(n+5):nth-child(-n+8)     { --c: var(--category-2); animation-delay: -2.55s; }
.tile-loader span:nth-child(n+9):nth-child(-n+12)    { --c: var(--category-3); animation-delay: -2.1s; }
.tile-loader span:nth-child(n+13)                    { --c: var(--category-4); animation-delay: -1.65s; }

@keyframes tileSolve {
    0%, 100% { background-color: var(--bg-tertiary); border-color: var(--border-color); transform: scale(1); }
    5%       { transform: scale(1.15); }
    8%, 78%  { background-color: var(--c); border-color: var(--c); }
    11%      { transform: scale(1); }
    88%      { background-color: var(--bg-tertiary); border-color: var(--border-color); transform: scale(1); }
}

.generating-status {
    color: var(--text-secondary);
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    animation: pulseText 1.8s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* ===================================
   Game screen
   =================================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
    flex-wrap: wrap; /* a long date + mistakes block must stack, not squeeze */
}

.game-menu-btn {
    align-self: center;
    flex-shrink: 0;
}

.game-info {
    flex: 1; /* takes the middle so the date hugs the back button, mistakes stay right */
    min-width: 0;
}

.game-date {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
}

.game-status {
    font-size: 0.95rem;
}

.mistakes-container {
    text-align: right;
    flex-shrink: 0; /* the dots keep their size — let the date side wrap instead */
}

.mistakes-label {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.mistakes-dots {
    display: flex;
    gap: 7px;
    justify-content: flex-end;
}

.mdot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-primary);
    transition: transform var(--t-base) var(--ease-spring), background var(--t-base);
}

.mdot.used {
    background: var(--border-strong);
    transform: scale(0.7);
}

.hint-btn {
    margin-top: 6px;
    animation: fadeIn var(--t-slow) var(--ease-out);
}

/* ===================================
   Solved groups
   =================================== */
.solved-groups {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs);
}

.solved-groups:empty {
    margin-bottom: 0;
}

.solved-group {
    padding: 0.8rem var(--space-sm);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--category-text);
}

.solved-group.reveal {
    animation: groupIn var(--t-slow) var(--ease-spring);
}

.solved-group.category-1 { background: var(--category-1); }
.solved-group.category-2 { background: var(--category-2); }
.solved-group.category-3 { background: var(--category-3); }
.solved-group.category-4 { background: var(--category-4); }

.solved-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
}

.solved-group-title .icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
}

.solved-group-words {
    font-size: 0.9rem;
    font-weight: 400;
}

/* ===================================
   Word grid
   =================================== */
.word-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-xs);
    margin: var(--space-xs) 0 var(--space-md);
}

.word-tile {
    position: relative;
    aspect-ratio: 3 / 2;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.4rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 550;
    letter-spacing: 0.02em;
    word-break: break-word;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
        transform var(--t-fast) var(--ease-out);
    animation: tileIn var(--t-base) var(--ease-out) var(--enter-delay, 0ms) both;
}

.word-tile.long-word {
    font-size: 0.68rem;
    letter-spacing: 0;
}

@media (hover: hover) {
    .word-tile:hover:not(.selected) {
        border-color: var(--border-strong);
        transform: translateY(-2px);
    }
}

.word-tile.selected {
    background: var(--color-selected);
    border-color: var(--color-selected);
    color: var(--color-selected-text);
}

.word-tile.pop {
    animation: pop 200ms var(--ease-spring);
}

.word-tile.bounce {
    animation: tileBounce 420ms var(--ease-spring);
}

.word-tile.solving {
    animation: solveOut 380ms var(--ease-out) forwards;
}

.word-tile.shake {
    animation: shake 480ms;
}

.word-tile.hint-dim {
    animation: none; /* clear tileIn's forwards fill so opacity applies */
    opacity: 0.55;
}

.word-tile.hint-glow {
    border-color: var(--category-1);
    animation: hintPulse 1.6s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 1px var(--category-1), 0 0 4px rgba(227, 181, 60, 0.25); }
    50% { box-shadow: 0 0 0 1px var(--category-1), 0 0 14px rgba(227, 181, 60, 0.45); }
}

/* ===================================
   Controls
   =================================== */
.game-controls {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
    flex-wrap: wrap;
}

.puzzle-source {
    margin-top: var(--space-md);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.jam-entry {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1.2;
    min-height: 44px;
    width: fit-content;
    margin: var(--space-md) auto 0;
    text-align: center;
}

/* ===================================
   More puzzles
   =================================== */
.more-puzzles {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
    text-align: center;
    animation: fadeIn var(--t-base) var(--ease-out);
}

.more-puzzles-title {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    margin-bottom: var(--space-sm);
}

.more-puzzles-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}

.choose-theme-btn {
    margin-bottom: var(--space-sm);
}

/* ===================================
   Modals
   =================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.72);
    color: inherit;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal[open] {
    display: flex;
    animation: fadeIn var(--t-base);
}

.modal::backdrop {
    background: transparent;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    max-width: 420px;
    max-height: 100%;
    width: 100%;
    overflow-y: auto;
    text-align: center;
    animation: modalIn var(--t-slow) var(--ease-spring);
    box-shadow: var(--shadow-lg);
}

.library-modal-content {
    max-width: 440px;
    padding: var(--space-md);
    text-align: left;
}

.library-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.library-modal-header .modal-title {
    margin-bottom: 0;
}

.library-modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.genre-list {
    display: grid;
    gap: 0.55rem;
}

.genre-option {
    width: 100%;
    min-height: 58px;
    padding: 0.5rem 0.65rem;
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--t-fast), transform var(--t-fast);
}

.genre-option:hover,
.genre-option[aria-pressed="true"] {
    border-color: var(--border-strong);
}

.genre-option[aria-pressed="true"] {
    box-shadow: inset 0 0 0 1px var(--text-tertiary);
}

.genre-option:hover {
    transform: translateY(-1px);
}

.genre-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: var(--border-strong);
    color: var(--category-text);
    font-size: 0.9rem;
    font-weight: 700;
}

.genre-icon .icon {
    width: 20px;
    height: 20px;
}

.genre-icon-0 { color: var(--text-primary); }
.genre-icon-1 { background: var(--category-1); }
.genre-icon-2 { background: var(--category-4); }
.genre-icon-3 { background: var(--category-2); }
.genre-icon-4 { background: var(--color-wrong); }
.genre-icon-5 { background: var(--category-3); }
.genre-icon-6 { background: var(--category-4); }

.genre-option-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.genre-option-name {
    font-size: 0.92rem;
}

.genre-option-count {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.genre-option-arrow {
    color: var(--text-secondary);
    font-size: 1.5rem;
}

.modal-title {
    font-size: 1.6rem;
    font-weight: 350;
    margin-bottom: var(--space-xs);
}

.modal-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.share-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
    margin-bottom: var(--space-md);
    font-size: 1.25rem;
    line-height: 1.35;
}

.share-grid:empty {
    display: none;
}

.modal-stats {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.88rem;
}

.stat-label { color: var(--text-secondary); }
.stat-value { font-weight: 600; }

.modal-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
    flex-wrap: wrap; /* buttons too wide for the row drop whole, never split */
}

.modal-actions .btn {
    flex: 1 1 auto;
    white-space: nowrap;
}

.modal-actions-secondary {
    margin-top: var(--space-xs);
}

.modal-solve-rate {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.modal-hint-note {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
}

.flag-btn {
    margin-top: var(--space-sm);
}

.modal-footnote {
    margin-top: var(--space-md);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
}

/* stats modal */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.stat-tile {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-xs);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-big {
    font-size: 1.5rem;
    font-weight: 300;
}

.stat-small {
    font-size: 0.68rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* shortcuts modal */
.shortcut-list {
    list-style: none;
    margin: 0 0 var(--space-md);
    padding: 0;
    text-align: left;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 6px 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.shortcut-keys {
    display: flex;
    gap: 4px;
}

.shortcut-row kbd {
    display: inline-block;
    min-width: 1.9rem;
    padding: 2px 7px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--text-primary);
    text-align: center;
}

/* ===================================
   Toasts
   =================================== */
.toast-container {
    position: fixed;
    top: calc(var(--space-md) + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: center;
    pointer-events: none;
}

.toast {
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity var(--t-base), transform var(--t-base) var(--ease-spring);
    box-shadow: var(--shadow-md);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   Confetti
   =================================== */
.confetti {
    position: fixed;
    top: -12px;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    z-index: 3000;
    pointer-events: none;
    animation: confettiFall 2.6s var(--ease-out) var(--fall-delay, 0ms) forwards;
}

@keyframes confettiFall {
    to {
        transform: translate(var(--drift, 0), 105vh) rotate(var(--spin, 360deg));
        opacity: 0.8;
    }
}

/* ===================================
   Footer
   =================================== */
.footer {
    margin-top: var(--space-xl);
    padding: var(--space-md) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

/* ===================================
   Animations
   =================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes groupIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes tileIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop {
    50% { transform: scale(1.08); }
}

@keyframes tileBounce {
    0% { transform: translateY(0); }
    35% { transform: translateY(-10px); }
    70% { transform: translateY(2px); }
    100% { transform: translateY(0); }
}

@keyframes solveOut {
    to { opacity: 0; transform: scale(0.7); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-5px); }
    30%, 60%, 90% { transform: translateX(5px); }
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 480px) {
    .container {
        padding-left: calc(var(--space-sm) + env(safe-area-inset-left));
        padding-right: calc(var(--space-sm) + env(safe-area-inset-right));
    }

    .title {
        font-size: 1.55rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .header {
        gap: 0.35rem;
        padding-bottom: var(--space-md);
    }

    .header-library-btn {
        padding: 0.45rem;
    }

    .header-library-btn span {
        display: none;
    }

    /* keep 44px icon-btn hit targets — the header fits because the library
       button collapses to icon-only and the title shrinks */

    .word-tile {
        font-size: 0.72rem;
        aspect-ratio: 4 / 3;
    }

    .word-tile.long-word {
        /* 12-char words were still wrapping mid-word — shrink further and
           free up the padding so the whole word fits on one line */
        font-size: 0.55rem;
        padding: 0.15rem;
        line-height: 1.1;
    }

    /* 3 × min-width 110px + gaps is wider than a phone board — equal
       thirds keeps submit on the row instead of dropping it alone */
    .game-controls {
        flex-wrap: nowrap;
    }

    .game-controls .btn {
        flex: 1;
        min-width: 0;
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }

    .prompt-category {
        font-size: 1.6rem;
    }
}

@media (max-width: 350px) {
    .header {
        flex-wrap: wrap;
        padding-top: 0;
    }

    /* ~100px per control at this width — keep the labels on one line */
    .game-controls .btn {
        font-size: 0.85rem;
    }

    /* ~57px of tile text area — 12-char words need one more step down */
    .word-tile.long-word {
        font-size: 0.5rem;
    }

    .header-center {
        order: -1;
        width: 100%;
        margin-bottom: var(--space-xs);
    }

    .header-side {
        align-items: center;
    }

    .modal {
        padding: 0.75rem;
    }
}

/* ===================================
   Category blurbs (solver-verified generation)
   =================================== */
.solved-group-blurb {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.82;
    margin-top: 0.15rem;
    letter-spacing: 0.01em;
}

/* ===================================
   Streak calendar (stats modal)
   =================================== */
.streak-calendar {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 3px;
    margin: var(--space-md) 0 var(--space-sm);
}

.cal-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.cal-cell.cal-win {
    background: var(--category-2);
    border-color: var(--category-2);
}

.cal-cell.cal-loss {
    /* hatched fill — a loss must read as a loss even when the hue can't (CVD) */
    background: repeating-linear-gradient(45deg, var(--color-wrong), var(--color-wrong) 2px, transparent 2px, transparent 5px);
    border-color: var(--color-wrong);
    opacity: 0.65;
}

.cal-cell.cal-today {
    box-shadow: 0 0 0 2px var(--text-primary);
}

/* ===================================
   Community rating
   =================================== */
.rate-row {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.rate-btn .icon {
    width: 20px;
    height: 20px;
    display: block;
}

/* ===================================
   Accessible palette (colorblind-safe)
   Okabe–Ito-inspired: keeps 4 visually distinct category colors for
   deuteranopia/protanopia where green/yellow or blue/purple collapse.
   =================================== */
html.cvd {
    --category-1: #e69f00;
    --category-2: #009e73;
    --category-3: #0072b2;
    --category-4: #cc79a7;
}

/* ===================================
   Screen-reader-only content
   The sr-status live region — rendered (so aria-live fires) but invisible.
   =================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ===================================
   Reduced motion
   =================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .confetti {
        display: none;
    }

    /* the loader's wave can't play — show the solved board instead */
    .tile-loader span {
        background-color: var(--c);
        border-color: var(--c);
    }
}

/* Multiplayer adds presence and annotations to the original game screen. */
.jam-roombar { margin: -0.4rem 0 var(--space-xs); }
.jam-presence { display: grid; grid-template-columns: minmax(0, 1fr) 44px 44px; align-items: center; gap: 4px; }
.jam-players { grid-column: 1; grid-row: 1; display: flex; gap: 4px; min-width: 0; }
.jam-avatar-btn { position: relative; flex: 1; min-width: 44px; max-width: 104px; min-height: 56px; padding: 4px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid transparent; background: none; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; }
.jam-avatar { display: block; width: 28px; height: 28px; flex-shrink: 0; }
.jam-avatar-btn[aria-pressed="true"] { border-color: var(--text-secondary); background: var(--bg-tertiary); color: var(--text-primary); }
.jam-avatar-btn.offline { opacity: 0.5; }
.jam-avatar-btn.transmitting .jam-avatar { outline: 2px solid var(--text-primary); border-radius: 9px; outline-offset: 1px; }
.jam-player-name { display: block; width: 100%; font-size: 11px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.jam-new-ideas { position: absolute; top: -5px; right: -2px; padding: 1px 3px; border-radius: 3px; background: var(--text-primary); color: var(--bg-primary); font-size: 9px; line-height: 12px; }
#jam-invite-btn { grid-column: 2; grid-row: 1; font: inherit; font-size: 0.65rem; }
#jam-room-btn { grid-column: 3; grid-row: 1; }
#jam-connection { grid-column: 1 / -1; grid-row: 2; font-size: 10px; line-height: 16px; color: var(--text-secondary); min-width: 0; padding-top: 2px; }
.jam-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; min-height: 44px; gap: 0 8px; font-size: 0.7rem; color: var(--text-secondary); }
.jam-legend .ghost-btn { min-height: 44px; padding: 0 6px; font-size: inherit; margin: 0; white-space: nowrap; }
#jam-note-context { min-width: 0; line-height: 1.5; overflow-wrap: anywhere; flex: 1; }
.jam-note-controls, .jam-note-tools { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.jam-note-tools[hidden] { display: none; }
.jam-tool { min-width: 44px; min-height: 44px; padding: 0 7px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font: inherit; font-size: 11px; cursor: pointer; }
.jam-board-key { display: flex; flex-wrap: wrap; gap: 6px 14px; min-height: 24px; padding-bottom: 5px; font-size: 10px; color: var(--text-secondary); }
.jam-board-key > span { display: inline-flex; align-items: center; gap: 5px; }
.jam-board-key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.jam-key-fill { background: var(--color-selected); }
.jam-key-solid { border: 2px solid var(--jam-player); }
.jam-key-dashed { border: 2px dashed var(--jam-player); }
.jam-tool[aria-pressed="true"] { border-color: var(--border-strong); background: var(--bg-tertiary); color: var(--text-primary); }
.jam-tool:disabled { opacity: 0.35; cursor: not-allowed; }
.jam-mic { flex: 0 0 44px; border-color: var(--border-color); }
.jam-mic[aria-pressed="true"] { background: var(--accent); color: var(--accent-contrast); }
.jam-mic.listening { border-style: dashed; }
.jam-mic svg { pointer-events: none; }
.jam-avatar-field { padding: 0; border: 0; margin: var(--space-sm) 0; }
.jam-avatar-field legend, .jam-field-label { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: var(--space-xs); }
.jam-avatar-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); }
.jam-avatar-option { position: relative; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-secondary); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 3px; cursor: pointer; font: inherit; font-size: 0.7rem; min-width: 0; }
.jam-avatar-option .jam-avatar { width: 42px; height: 42px; }
.jam-avatar-option[aria-pressed="true"] { border-color: var(--text-primary); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--text-primary); }
.jam-avatar-option[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 1px; right: 4px; font-size: 0.65rem; }
.jam-name { width: 100%; min-width: 0; font: inherit; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.7rem; margin-bottom: var(--space-xs); }
.jam-dialog-note { font-size: 0.73rem; line-height: 1.6; color: var(--text-secondary); margin: var(--space-xs) 0; }
.jam-dialog-status { font-size: 0.75rem; color: var(--text-secondary); margin-top: var(--space-xs); }
.jam-dialog-status:empty { display: none; }
.jam-member { display: flex; align-items: center; gap: var(--space-xs); padding: var(--space-xs) 0; border-bottom: 1px solid var(--border-color); }
.jam-member-copy { flex: 1; min-width: 0; font-size: 0.78rem; overflow-wrap: anywhere; }
.jam-member-copy small { display: block; font-size: 0.67rem; color: var(--text-secondary); }
.jam-member .ghost-btn { font-size: 0.68rem; }
.jam-note-actions { flex-wrap: wrap; }
.jam-note-actions .btn { min-width: 0; padding: 0.6rem; font-size: 0.7rem; }
.jam-active .word-tile { touch-action: manipulation; min-width: 0; min-height: 76px; aspect-ratio: auto; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px 6px; }
.jam-active .word-label { position: relative; display: flex; align-items: center; justify-content: center; min-height: 24px; width: 100%; pointer-events: none; line-height: 1.15; overflow-wrap: anywhere; }
.jam-tile-captions { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; width: 100%; min-height: 26px; font-size: 11px; font-weight: 400; line-height: 13px; letter-spacing: -0.2px; color: var(--text-secondary); pointer-events: none; }
.jam-tile-captions > span { max-width: 100%; overflow-wrap: normal; }
.jam-tile-captions > span:empty { display: none; }
.jam-active .word-tile.selected .jam-tile-captions { color: var(--color-selected-text); }
.jam-own-caption { font-style: italic; }
.jam-player-border { position: absolute; inset: -1px; pointer-events: none; border: 2px solid var(--jam-player); border-radius: inherit; }
.jam-player-border[data-intent^="note-"] { border-style: dashed; }
.jam-active .word-tile.selected .jam-player-border { box-shadow: inset 0 0 0 2px var(--bg-primary); }
.jam-active .word-tile:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; }
[data-player-slot="0"] { --jam-player: #f1cb68; }
[data-player-slot="1"] { --jam-player: #8bd1d6; }
[data-player-slot="2"] { --jam-player: #9bc99a; }
[data-player-slot="3"] { --jam-player: #c7afe6; }
html.light-theme [data-player-slot="0"] { --jam-player: #795700; }
html.light-theme [data-player-slot="1"] { --jam-player: #226269; }
html.light-theme [data-player-slot="2"] { --jam-player: #32633b; }
html.light-theme [data-player-slot="3"] { --jam-player: #69438b; }
.jam-marking #jam-note-context { color: var(--text-primary); flex-basis: 100%; padding-top: 5px; }
.jam-marking .jam-note-controls { width: 100%; justify-content: space-between; }
.jam-marking #jam-notes-btn { border-style: solid; color: var(--text-primary); min-width: 44px; }
@media (max-width: 420px) {
    .jam-avatar-btn .jam-avatar { width: 25px; height: 25px; }
    .jam-active .game-controls { gap: var(--space-xs); }
    .jam-board-key { gap: 6px 10px; }
}
@media (max-width: 350px) {
    :is(.game-active, .jam-active) .game-header { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 6px 8px; }
    :is(.game-active, .jam-active) .game-menu-btn { grid-column: 1; grid-row: 1; }
    :is(.game-active, .jam-active) .game-info { grid-column: 2; grid-row: 1; }
    :is(.game-active, .jam-active) .mistakes-container { grid-column: 2; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; text-align: left; }
    :is(.game-active, .jam-active) .mistakes-label { margin-bottom: 0; font-size: 0.7rem; }
    .jam-presence { grid-template-columns: minmax(0, 1fr) 44px 44px; gap: 2px; }
    .jam-players { gap: 2px; }
    .jam-avatar-btn { min-width: 44px; padding-inline: 2px; }
    .jam-active .word-grid { gap: 6px; }
    .jam-active .word-tile { padding-inline: 3px; }
    .jam-active .game-controls { gap: 5px; }
    .jam-active .game-controls .btn { min-width: 0; padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .jam-player-border { animation: none !important; transition: none !important; }
}

/* Keep the shared board close to the top on phones. */
@media (max-width: 480px) {
    :is(.game-active, .jam-active) .container { padding-top: calc(8px + env(safe-area-inset-top)); }
    :is(.game-active, .jam-active) .header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 132px; gap: 4px; padding: 0 0 8px; }
    :is(.game-active, .jam-active) .header-side { gap: 0; min-width: 0; }
    :is(.game-active, .jam-active) .header-library-btn { width: 44px; padding: 0; justify-content: center; }
    :is(.game-active, .jam-active) .header-center { order: 0; width: auto; min-width: 0; min-height: 44px; margin: 0; display: grid; align-items: center; }
    :is(.game-active, .jam-active) .title { font-size: 1.35rem; letter-spacing: 0.025em; white-space: nowrap; }
    :is(.game-active, .jam-active) .subtitle { display: none; }
    :is(.game-active, .jam-active) .game-area { justify-content: flex-start; }
    :is(.game-active, .jam-active) .game-header { margin-bottom: 4px; gap: 4px 8px; align-items: center; }
    :is(.game-active, .jam-active) .game-date { display: none; }
    :is(.game-active, .jam-active) .game-status { font-size: 0.85rem; }
    :is(.game-active, .jam-active) .mistakes-label { font-size: 0.65rem; letter-spacing: 0.025em; margin-bottom: 3px; }
    :is(.game-active, .jam-active) .jam-roombar { display: grid; grid-template-columns: minmax(0, 1fr) 44px; margin: 0; column-gap: 4px; }
    :is(.game-active, .jam-active) .jam-presence { grid-column: 1 / -1; grid-row: 1; gap: 0 4px; }
    :is(.game-active, .jam-active) .jam-avatar-btn { min-height: 44px; max-width: none; flex-direction: row; gap: 5px; padding: 3px 5px; }
    :is(.game-active, .jam-active) .jam-avatar-btn .jam-avatar { width: 24px; height: 24px; }
    :is(.game-active, .jam-active) .jam-player-name { width: auto; min-width: 0; text-align: left; }
    :is(.game-active, .jam-active) .jam-players:has(> :nth-child(3)) .jam-avatar-btn { flex-direction: column; gap: 1px; padding: 2px; }
    :is(.game-active, .jam-active) .jam-players:has(> :nth-child(3)) .jam-avatar { width: 22px; height: 22px; }
    :is(.game-active, .jam-active) .jam-players:has(> :nth-child(3)) .jam-player-name { width: 100%; text-align: center; font-size: 10px; line-height: 12px; }
    :is(.game-active, .jam-active) #jam-connection[data-connected="true"],
    :is(.game-active, .jam-active):not(.jam-marking) #jam-note-context { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    :is(.game-active, .jam-active) .jam-legend { grid-column: 2; grid-row: 2; min-height: 44px; justify-content: flex-end; }
    :is(.game-active, .jam-active) .jam-legend .ghost-btn { min-width: 44px; padding: 0 2px; }
    :is(.game-active, .jam-active) .jam-board-key { grid-column: 1; grid-row: 2; min-height: 44px; align-items: center; align-content: center; gap: 3px 10px; padding: 0; font-size: 11px; }
    :is(.game-active, .jam-active) .jam-board-key > span { gap: 4px; }
    :is(.game-active, .jam-active) .jam-board-key i { width: 10px; height: 10px; }
    .jam-marking .jam-legend { grid-column: 1 / -1; grid-row: 2; }
    .jam-marking #jam-note-context { padding-top: 2px; font-size: 11px; }
    .jam-marking .jam-board-key { grid-column: 1 / -1; grid-row: 3; min-height: 22px; }
    :is(.game-active, .jam-active) .word-grid { margin-top: 4px; }
    /* Spend taller phone viewports on readable words; keep controls in view. */
    :is(.game-active, .jam-active) .word-tile {
        min-height: clamp(80px, calc((100dvh - 388px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 4), 110px);
        padding: 5px 4px;
        gap: 2px;
        aspect-ratio: auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        font-size: 15.5px;
        font-weight: 600;
        letter-spacing: 0;
        line-height: 1.16;
        word-break: normal;
    }
    :is(.game-active, .jam-active) .word-tile.jam-medium-word { font-size: 14px; }
    :is(.game-active, .jam-active) .word-tile.long-word { font-size: 13px; padding: 5px 4px; line-height: 1.16; }
    :is(.game-active, .jam-active) .word-label { display: block; width: 100%; min-height: 36px; align-content: center; line-height: 1.16; overflow-wrap: anywhere; }
    :is(.game-active, .jam-active) .jam-tile-captions { flex-shrink: 0; }
    :is(.game-active, .jam-active) .jam-tile-captions:not(:has(> span:not(:empty))) { display: none; }
    .jam-marking .word-tile {
        min-height: clamp(80px, calc((100dvh - 430px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 4), 100px);
    }
}
@media (max-width: 350px) {
    :is(.game-active, .jam-active) .container { padding-left: calc(10px + env(safe-area-inset-left)); padding-right: calc(10px + env(safe-area-inset-right)); }
    :is(.game-active, .jam-active) .word-grid { gap: 4px; }
    :is(.game-active, .jam-active) .word-tile { padding-inline: 2px; font-size: 14px; }
    :is(.game-active, .jam-active) .word-tile.jam-medium-word,
    :is(.game-active, .jam-active) .word-tile.long-word { padding-inline: 2px; font-size: 13px; }
    :is(.game-active, .jam-active) .word-label { text-wrap: balance; hyphens: auto; }
    :is(.game-active, .jam-active) .title { font-size: 1.05rem; letter-spacing: 0.015em; }
    :is(.game-active, .jam-active) .game-header { grid-template-columns: 44px minmax(0, 1fr); }
    :is(.game-active, .jam-active) .mistakes-container { gap: 2px 8px; }
    :is(.game-active, .jam-active) .mistakes-label { margin-bottom: 0; }
    :is(.game-active, .jam-active) .jam-presence { column-gap: 2px; }
    :is(.game-active, .jam-active) .jam-board-key { gap: 3px 7px; font-size: 10px; }
}

/* Short phone viewports keep the complete board and 44px controls visible. */
@media (max-width: 480px) and (max-height: 620px) {
    :is(.game-active, .jam-active) .word-tile,
    :is(.game-active, .jam-active) .word-tile.long-word { min-height: 68px; padding: 2px; gap: 2px; }
    :is(.game-active, .jam-active) .word-label { min-height: 30px; }
    :is(.game-active, .jam-active) .word-grid { margin-bottom: 12px; gap: 4px; }
    :is(.game-active, .jam-active).jam-marking #jam-note-context { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
    :is(.game-active, .jam-active).jam-marking .jam-board-key { display: none; }
    :is(.game-active, .jam-active).jam-marking .jam-legend { grid-column: 1 / -1; min-height: 44px; }
    :is(.game-active, .jam-active).jam-marking .jam-note-controls { min-height: 44px; }
}
@media (max-width: 350px) and (max-height: 620px) {
    :is(.game-active, .jam-active) .game-header { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px; }
    :is(.game-active, .jam-active) .mistakes-container { grid-column: 3; grid-row: 1; }
    :is(.game-active, .jam-active) .mistakes-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
}

/* Soft group notes stay distinct from full-contrast submission picks. */
:root {
    --tag-1-fill: #e58e7b; --tag-1-border: #e58e7b;
    --tag-2-fill: #dca15e; --tag-2-border: #dca15e;
    --tag-3-fill: #d79bad; --tag-3-border: #d79bad;
    --tag-4-fill: #aeb6bd; --tag-4-border: #aeb6bd;
}
html.light-theme { --tag-1-border: #a64f3d; --tag-2-border: #985c20; --tag-3-border: #97536a; --tag-4-border: #57636d; }
[data-pattern="0"] { --tag-fill: var(--text-primary); --tag-color: var(--text-primary); }
[data-pattern="1"] { --tag-fill: var(--tag-1-fill); --tag-color: var(--tag-1-border); }
[data-pattern="2"] { --tag-fill: var(--tag-2-fill); --tag-color: var(--tag-2-border); }
[data-pattern="3"] { --tag-fill: var(--tag-3-fill); --tag-color: var(--tag-3-border); }
[data-pattern="4"] { --tag-fill: var(--tag-4-fill); --tag-color: var(--tag-4-border); }
.word-tile[data-own-tag="1"] { --own-tag-fill: var(--tag-1-fill); }
.word-tile[data-own-tag="2"] { --own-tag-fill: var(--tag-2-fill); }
.word-tile[data-own-tag="3"] { --own-tag-fill: var(--tag-3-fill); }
.word-tile[data-own-tag="4"] { --own-tag-fill: var(--tag-4-fill); }
.word-tile[data-own-tag]:not([data-own-tag=""]) { background: color-mix(in srgb, var(--own-tag-fill) 20%, var(--bg-secondary)); border-color: color-mix(in srgb, var(--own-tag-fill) 42%, var(--border-color)); color: var(--text-primary); }
.word-tile[data-own-tag]:not([data-own-tag=""]).selected { background: var(--color-selected); border-color: var(--color-selected); color: var(--color-selected-text); }
#pattern-tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
#pattern-tools button { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 5px; border: 1px solid var(--tag-color); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--tag-fill) 20%, var(--bg-secondary)); color: var(--text-primary); font: inherit; font-weight: 500; cursor: pointer; }
#pattern-tools button[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--text-primary); border-color: var(--text-primary); }
#pattern-tools button:hover { border-color: var(--text-primary); }
#pattern-tools button:disabled { opacity: 1; cursor: default; }
#pattern-tools .pick-mode-btn { background: var(--bg-secondary); border-color: var(--border-strong); }
.pattern-name { font-size: 11px; line-height: 1.2; }
.pattern-sample { display: block; width: 16px; height: 10px; flex-shrink: 0; background: var(--tag-color); border: 0; border-radius: 3px; font-size: 0; }
#pattern-tools .pick-mode-btn .pattern-sample { background: var(--color-selected); color: var(--color-selected-text); display: grid; place-items: center; font-size: 9px; }
.word-tags { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.word-tags[data-peer-tags="true"]::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; opacity: 0.65; background: var(--tag-border); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask-composite: exclude; }
.word-tag-pattern { display: none; }
[data-player-slot="0"] { --player-print: linear-gradient(currentColor, currentColor); }
[data-player-slot="1"] { --player-print: radial-gradient(circle at 1px 1px, currentColor 1px, transparent 1.4px); --player-print-size: 4px 4px; }
[data-player-slot="2"] { --player-print: repeating-linear-gradient(135deg, currentColor 0 2px, transparent 2px 4px); }
[data-player-slot="3"] { --player-print: linear-gradient(135deg, currentColor 25%, transparent 25%), linear-gradient(225deg, currentColor 25%, transparent 25%), linear-gradient(315deg, currentColor 25%, transparent 25%), linear-gradient(45deg, currentColor 25%, transparent 25%); --player-print-size: 6px 6px; }
.word-tag-owners { position: absolute; bottom: 4px; left: 3px; right: 3px; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 2px; height: 16px; min-height: 0; margin: 0; pointer-events: none; }
.word-tag-owner, .jam-player-print { position: relative; display: inline-block; flex: 0 0 16px; width: 16px; height: 16px; padding: 0; border: 1px solid currentColor; border-radius: 3px; color: var(--tag-color, var(--text-primary)); background: var(--bg-secondary); }
.word-tag-owner::before, .jam-player-print::before { content: ""; position: absolute; inset: 2px; border-radius: 1px; background-image: var(--player-print, linear-gradient(currentColor, currentColor)); background-size: var(--player-print-size, auto); }
.jam-player-print { color: var(--text-primary); vertical-align: middle; }
.tag-owner-avatar, .tag-owner-name, .tag-owner-group { display: none; }
.tag-owner-choice { position: absolute; right: -3px; bottom: -2px; z-index: 1; display: grid; place-items: center; min-width: 9px; height: 9px; padding: 0 1px; border: 1px solid var(--text-primary); border-radius: 3px; background: var(--bg-primary); color: var(--text-primary); font-size: 8px; font-weight: 700; line-height: 1; }
.word-tag-owner[data-pattern="0"] { color: var(--text-primary); }
.word-tile.selected .word-tag-owner { background: var(--color-selected); }
.word-tile.selected .word-tag-owner[data-pattern="0"] { color: var(--color-selected-text); }
.word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 23px; }
.word-tile .word-label { white-space: normal; word-break: normal; overflow-wrap: normal; hyphens: none; text-wrap: wrap; }
.jam-active .jam-player-border, .jam-active .jam-tile-captions { display: none; }
.word-pick-check { position: absolute; z-index: 1; top: 3px; right: 3px; display: grid; place-items: center; width: 12px; height: 12px; border: 1px solid #fff; border-radius: 50%; background: #171717; color: #fff; font-size: 9px; font-weight: 700; line-height: 1; pointer-events: none; }
#game-jam-link { display: flex; justify-content: center; align-items: center; width: fit-content; min-height: 44px; margin-left: auto; margin-right: auto; text-align: center; }
#define-modal .modal-content { max-width: 380px; text-align: left; }
#define-title { overflow-wrap: anywhere; font-size: 20px; font-weight: 400; line-height: 1.3; margin: 0; }
#define-pos { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0; }
#define-pos:empty { display: none; }
#define-text { font-size: 16px; line-height: 1.5; color: var(--text-primary); margin: 16px 0 0; max-height: 45dvh; overflow-y: auto; overflow-wrap: normal; word-break: normal; }
#define-tags { border-top: 1px solid var(--border-color); padding-top: 12px; margin: 16px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.compact-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; }
.compact-modal-header > div { min-width: 0; }
.compact-modal-header .modal-title { margin: 0; font-size: 20px; font-weight: 400; }
.compact-modal-header .icon-btn { flex: 0 0 44px; font-size: 24px; font-weight: 400; }

@media (max-width: 480px) {
    :is(.game-active, .jam-active) .puzzle-source { margin-top: 8px; }
    :is(.game-active, .jam-active) #game-jam-link { margin-top: 8px; }
    #pattern-tools { gap: 4px; margin-top: 4px; }
    #pattern-tools button { flex-direction: column; gap: 3px; padding: 3px; }
    .pattern-sample { width: 16px; height: 16px; font-size: 10px; }
    :is(.game-active, .jam-active) .word-tile { min-height: clamp(76px, calc((100dvh - 432px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 4), 102px); }
    .jam-marking .word-tile { min-height: clamp(76px, calc((100dvh - 474px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 4), 94px); }
}
@media (max-width: 480px) and (max-height: 620px) {
    :is(.game-active, .jam-active) .word-tile,
    :is(.game-active, .jam-active) .word-tile.long-word { min-height: 60px; padding: 2px; gap: 2px; }
    :is(.game-active, .jam-active) .word-label { min-height: 26px; }
    .jam-tile-captions { min-height: 24px; line-height: 12px; }
    #pattern-tools { margin-top: 4px; }
}

.jam-board-key .jam-key-fill { display: inline-grid; place-items: center; width: 12px; height: 12px; border: 1px solid var(--color-selected); background: var(--color-selected); color: var(--color-selected-text); font-size: 9px; font-style: normal; font-weight: 700; line-height: 1; }
@media (max-width: 480px) {
    :is(.game-active, .jam-active) .word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 23px; }
    :is(.game-active, .jam-active) .word-label { min-height: 30px; white-space: normal; word-break: normal; overflow-wrap: normal; hyphens: none; text-wrap: wrap; }
    #pattern-tools .pattern-sample { width: 16px; height: 10px; font-size: 0; }
    #pattern-tools .pick-mode-btn .pattern-sample { font-size: 9px; }
}
@media (max-width: 350px) {
    .word-tag-owner { width: 14px; height: 14px; flex-basis: 14px; }
    .word-tag-owners { height: 14px; gap: 1px; }
    :is(.game-active, .jam-active) .word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 21px; }
}
@media (max-width: 480px) and (max-height: 620px) {
    :is(.game-active, .jam-active) .word-label { min-height: 26px; }
}
.game-active:not(.jam-active) .word-tag-owners { display: none; }
@media (max-width: 480px) {
    .game-active:not(.jam-active) .word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 5px; }
}
@media (max-width: 480px) and (max-height: 620px) {
    .game-active:not(.jam-active) .word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 2px; }
}

.jam-board-key i:is(.jam-key-solid, .jam-key-dashed) { display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--text-primary); font-style: normal; font-size: 10px; font-weight: 600; line-height: 1; }

.word-tag-owner[data-self="true"] .tag-owner-choice { display: none; }
.jam-key-choice { display: inline-grid; place-items: center; width: 12px; height: 12px; color: var(--text-primary); font-size: 11px; font-style: normal; font-weight: 600; }

/* Keep the player key one control tall even with all four seats occupied. */
@media (max-width: 480px) {
    :is(.game-active, .jam-active) .jam-players:has(> :nth-child(3)) .jam-avatar-btn {
        display: grid;
        grid-template-columns: 24px 16px;
        grid-template-rows: 24px 12px;
        justify-content: center;
        gap: 1px;
        min-height: 44px;
    }
    .jam-players:has(> :nth-child(3)) .jam-avatar { grid-column: 1; grid-row: 1; }
    .jam-players:has(> :nth-child(3)) .jam-player-print { grid-column: 2; grid-row: 1; }
    .jam-players:has(> :nth-child(3)) .jam-player-name { grid-column: 1 / -1; grid-row: 2; }
}

/* Equal cards share the available height; four plain swatches tag ideas. */
#pattern-tools { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#pattern-tools .pattern-name,
#pattern-tools .pattern-sample { display: none; }
#pattern-tools button { background: color-mix(in srgb, var(--tag-fill) 20%, var(--bg-secondary)); }
#pattern-tools button[aria-pressed="true"] { border-color: var(--text-primary); box-shadow: inset 0 0 0 2px var(--text-primary); }
@media (max-width: 480px) {
    :is(.game-active, .jam-active) .container { padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
    :is(.game-active, .jam-active) .word-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-flow: row;
        gap: 4px;
        grid-auto-rows: max(44px, calc((var(--board-height, 432px) - (var(--board-rows, 4) - 1) * 4px) / var(--board-rows, 4)));
    }
    :is(.game-active, .jam-active) .word-grid .word-tile {
        grid-column: auto;
        min-height: 44px;
        height: 100%;
        padding: 2px;
        gap: 0;
        font-size: 16px;
        line-height: 1.15;
        letter-spacing: 0;
        align-self: stretch;
    }
    :is(.game-active, .jam-active) .word-grid .word-label { min-height: 20px; line-height: 1.15; white-space: normal; word-break: normal; overflow-wrap: normal; hyphens: none; }
    .jam-active .word-grid .word-tile:has(.word-tag-owners:not([hidden])) { padding: 2px 2px 18px; }
    .game-active:not(.jam-active) .word-grid .word-tile:has(.word-tag-owners:not([hidden])) { padding: 2px; }
    .word-tag-owners { height: 14px; bottom: 2px; gap: 1px; }
    .word-tag-owner { width: 14px; height: 14px; flex-basis: 14px; }
}
@media (max-width: 350px) {
    :is(.game-active, .jam-active) .word-grid .word-tile { font-size: 15px; }
}
@media (max-width: 480px) and (max-height: 620px) {
    :is(.game-active, .jam-active) .container { padding-left: calc(6px + env(safe-area-inset-left)); padding-right: calc(6px + env(safe-area-inset-right)); }
    :is(.game-active, .jam-active) .word-grid { grid-auto-rows: max(44px, calc((var(--board-height, 252px) - (var(--board-rows, 4) - 1) * 4px) / var(--board-rows, 4))); }
    :is(.game-active, .jam-active).dense-word-board .header { display: none; }
}

@media (max-width: 480px) and (max-height: 620px) {
    /* The room menu retains notes when a word-heavy board needs this row. */
    .jam-active.dense-word-board .jam-board-key,
    .jam-active.dense-word-board:not(.jam-marking) .jam-legend { display: none; }
    .jam-active.dense-word-board.jam-marking .jam-presence { display: none; }
    .jam-active.dense-word-board.jam-marking .jam-legend { grid-row: 1; }
}

@media (max-width: 480px) and (max-height: 620px) {
    /* An unusually word-heavy shuffle uses the remaining height for eight rows. */
    .jam-active.very-dense-word-board .word-grid { grid-auto-rows: max(40px, calc((var(--board-height, 352px) - (var(--board-rows, 8) - 1) * 4px) / var(--board-rows, 8))); }
    .jam-active.very-dense-word-board .word-grid .word-tile { min-height: 40px; }
    .jam-active.very-dense-word-board .word-grid .word-tile:has(.word-tag-owners:not([hidden])) { padding-bottom: 16px; }
}

@media (max-width: 480px) and (max-height: 620px) {
    .game-active:not(.jam-active).dense-word-board #game-jam-link { display: none; }
}

/* Use the app’s original system typeface consistently on the board. */
@media (max-width: 480px) {
    :is(.game-active, .jam-active) .word-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    :is(.game-active, .jam-active) .word-grid .word-tile { grid-column: auto; }
    :is(.game-active, .jam-active) .word-grid .word-label {
        font-family: var(--font);
        font-size: 16px;
        font-weight: 400;
        letter-spacing: 0;
        line-height: 1.05;
        hyphens: none;
        overflow-wrap: normal;
        word-break: normal;
    }
}
@media (max-width: 350px) {
    :is(.game-active, .jam-active) .word-grid .word-label { font-size: 15px; }
}

/* Tile words stay light on desktop as well as phones. */
.word-tile { font-weight: 400; }
#submit-btn { white-space: normal; line-height: 1.1; }


/* Counts distinguish a complete group from the currently active color brush. */
#pattern-tools button {
    position: relative;
    flex-direction: row;
    min-height: 44px;
    gap: 4px;
}
#pattern-tools .tag-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
#pattern-tools button:is([data-state="ready"], [data-count-state="ready"]) {
    box-shadow: inset 0 0 0 1px var(--tag-color);
}
#pattern-tools button:is([data-state="ready"], [data-count-state="ready"]) .tag-count::after {
    content: "✓";
    font-size: 12px;
    font-weight: 600;
}
#pattern-tools button:is([data-state="overfull"], [data-count-state="overfull"]) .tag-count {
    text-decoration: underline;
    text-decoration-style: double;
    text-underline-offset: 3px;
}
#pattern-tools button[aria-pressed="true"] {
    border-color: var(--tag-color);
    box-shadow: none;
    outline: 2px solid var(--text-primary);
    outline-offset: 1px;
}
#pattern-tools button[aria-pressed="true"]:is([data-state="ready"], [data-count-state="ready"]) {
    box-shadow: inset 0 0 0 1px var(--tag-color);
}
#pattern-tools button:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 3px;
}

/* Batch feedback stays in the board flow, with a separate result for each color. */
#batch-results {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 8px;
    margin-top: 6px;
    color: var(--text-primary);
}
.batch-results-title,
.batch-results-summary {
    margin: 0;
    font-size: 11px;
    font-weight: 400;
    line-height: 14px;
}
.batch-results-title { color: var(--text-secondary); }
.batch-results-summary { text-align: right; }
.batch-results-list {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
}
.batch-result {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    min-height: 22px;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
}
.batch-result-chip {
    flex: 0 0 9px;
    width: 9px;
    height: 9px;
    border: 1px solid var(--tag-color);
    border-radius: 2px;
    background: var(--tag-fill);
}
.batch-result-status {
    flex: 0 0 12px;
    width: 12px;
    text-align: center;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
}
.batch-result-label { min-width: 0; overflow-wrap: normal; }
.batch-result[data-result="repeated"] { border-style: dashed; }

#batch-results[hidden] { display: none; }

/* Keep completed groups compact when short-screen batch feedback needs room. */
@media (max-width: 480px) and (max-height: 620px) {
    .dense-word-board:has(#batch-results:not([hidden])) .solved-group {
        padding: 6px 8px;
    }
    .dense-word-board:has(#batch-results:not([hidden])) .solved-group-title {
        font-size: 11px;
        line-height: 1.25;
        letter-spacing: 0.04em;
    }
    .dense-word-board:has(#batch-results:not([hidden])) .solved-group-words {
        font-size: 12px;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: normal;
        word-break: normal;
    }
    .dense-word-board:has(#batch-results:not([hidden])) .solved-group-blurb {
        font-size: 11px;
        line-height: 1.25;
    }
}

/* Painting lives in the header options; the board keeps its playing controls. */
#game-options-btn { position: relative; flex: 0 0 44px; }
#game-options-btn:is([data-pattern="1"], [data-pattern="2"], [data-pattern="3"], [data-pattern="4"])::after {
    content: "";
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 8px;
    height: 8px;
    border: 1px solid var(--bg-primary);
    border-radius: 50%;
    background: var(--tag-fill);
    box-shadow: 0 0 0 1px var(--tag-color);
}
#game-options-modal .modal-content { max-width: 380px; }
#game-options-modal .game-options-note {
    margin: 8px 0 16px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}
#game-options-modal #pattern-tools { gap: 8px; margin: 12px 0 16px; }
#game-options-modal #pattern-tools button { min-height: 44px; }
#game-options-modal .btn { width: 100%; min-height: 44px; }
#game-options-modal .modal-actions { margin-top: 0; }

@media (max-width: 480px) {
    :is(.game-active, .jam-active) .header {
        grid-template-columns: 44px minmax(0, 1fr) 176px;
        gap: 2px;
    }
    :is(.game-active, .jam-active) .header-actions { gap: 0; }
    :is(.game-active, .jam-active) .header-actions .icon-btn { flex: 0 0 44px; }
    :is(.game-active, .jam-active) .title { font-size: 20px; letter-spacing: 0; }
}
@media (max-width: 350px) {
    :is(.game-active, .jam-active) .header { grid-template-columns: 44px minmax(0, 1fr); row-gap: 0; }
    :is(.game-active, .jam-active) .header-center { grid-column: 1 / -1; grid-row: 1; min-height: 44px; }
    :is(.game-active, .jam-active) .header > .header-side:not(.header-actions) { grid-column: 1; grid-row: 2; }
    :is(.game-active, .jam-active) .header-actions { grid-column: 2; grid-row: 2; }
}
@media (max-width: 480px) and (max-height: 620px) {
    /* Keep options reachable when the short-screen layout needs a single row. */
    :is(.game-active, .jam-active).dense-word-board .header {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-rows: 44px;
        gap: 0;
    }
    :is(.game-active, .jam-active).dense-word-board .header-center { display: none; }
    :is(.game-active, .jam-active).dense-word-board .header > .header-side:not(.header-actions) { grid-column: 1; grid-row: 1; }
    :is(.game-active, .jam-active).dense-word-board .header-actions { grid-column: 2; grid-row: 1; }
}

/* Prompt and preview use the same four-action header as the playing board. */
@media (max-width: 480px) {
    body:not(.game-active):not(.jam-active) .header {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 176px;
        gap: 2px;
    }
    body:not(.game-active):not(.jam-active) .header-side { gap: 0; min-width: 0; }
    body:not(.game-active):not(.jam-active) .header-library-btn { width: 44px; padding: 0; justify-content: center; }
    body:not(.game-active):not(.jam-active) .header-center {
        order: 0;
        width: auto;
        min-width: 0;
        min-height: 44px;
        margin: 0;
        display: grid;
        align-items: center;
    }
    body:not(.game-active):not(.jam-active) .header-actions .icon-btn { flex: 0 0 44px; }
    body:not(.game-active):not(.jam-active) .title { font-size: 20px; letter-spacing: 0; white-space: nowrap; }
    body:not(.game-active):not(.jam-active) .subtitle { display: none; }
}
@media (max-width: 350px) {
    body:not(.game-active):not(.jam-active) .header { grid-template-columns: 44px minmax(0, 1fr); row-gap: 0; }
    body:not(.game-active):not(.jam-active) .header-center { grid-column: 1 / -1; grid-row: 1; }
    body:not(.game-active):not(.jam-active) .header > .header-side:not(.header-actions) { grid-column: 1; grid-row: 2; }
    body:not(.game-active):not(.jam-active) .header-actions { grid-column: 2; grid-row: 2; }
}

/* The middle control returns to picks while a colour brush is active. */
.tag-painting #deselect-btn { border-color: var(--text-secondary); color: var(--text-primary); }
