/* ============================================
   Components — Unified button system, modals,
   forms, cards.
   ============================================ */

/* === Card === */
.card {
    /* Track the theme surface (was hardcoded near-black, which broke the
       light Arctic theme). color-mix keeps the slight translucency. */
    background: color-mix(in srgb, var(--color-surface) 95%, transparent);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
    box-shadow: 0 10px 40px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

/* === Setup Logo === */
.setup-logo {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.setup-logo img {
    max-width: 280px;
    height: auto;
}

.card h1 {
    color: var(--color-primary);
    font-size: var(--font-2xl);
    margin-bottom: var(--space-xl);
    text-align: center;
    text-shadow: 0 0 20px color-mix(in srgb, var(--color-primary) 50%, transparent);
}

/* === Unified Button System === */
.btn {
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    text-align: center;
    line-height: 1.2;
    touch-action: manipulation;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    opacity: 0.86;
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
}

/* Button Sizes */
.btn--sm {
    padding: var(--btn-padding-sm);
    font-size: var(--font-sm);
}

.btn--md {
    padding: var(--btn-padding-md);
    font-size: var(--font-md);
}

.btn--lg {
    padding: var(--btn-padding-lg);
    font-size: var(--font-lg);
}

/* Button Variants */
.btn--primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.btn--primary-dark {
    background: var(--color-primary-dark);
    color: var(--color-on-primary);
}

.btn--success {
    background: var(--color-success);
    color: var(--color-on-success);
}

.btn--success-dark {
    background: var(--color-success-dark);
    color: var(--color-text);
}

.btn--danger {
    background: var(--color-danger);
    color: var(--color-text);
}

.btn--danger-light {
    background: var(--color-bust);
    color: var(--color-text);
}

.btn--miss {
    background: var(--color-miss);
    color: var(--color-text);
}

.btn--bust {
    background: var(--color-bust);
    color: var(--color-text);
}

.btn--warning {
    background: var(--color-warning);
    color: var(--color-text-dark);
}

.btn--undo {
    background: var(--color-undo);
    color: var(--color-text);
}

.btn--neutral {
    background: var(--color-border);
    color: var(--color-text);
}

.btn--ghost {
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border-light);
}

.btn--keypad {
    background: #ccc;
    color: var(--color-text-dark);
    border: 2px solid #999;
}

.btn--dimmed {
    background: #444;
    color: var(--color-text-dim);
}

.btn--block {
    display: block;
    width: 100%;
}

/* === Forms === */
.form-group {
    margin-bottom: var(--space-xl);
}

.form-group label {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
}

.form-group select,
.form-group input[type="text"] {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--font-md);
    font-family: var(--font-family);
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    color: var(--color-text);
    font-size: var(--font-md);
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-primary);
}

/* === Modals === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.50);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 100%;
    text-align: center;
    max-height: 90dvh;
    overflow-y: auto;
}

.modal-content h2 {
    font-size: var(--font-2xl);
    margin-bottom: var(--space-lg);
}

.modal-buttons {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--space-xl);
}

.winner-name {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: bold;
    margin: var(--space-2xl) 0;
    text-shadow: 0 0 30px color-mix(in srgb, var(--color-pending) 50%, transparent);
}

/* === Winner Modal === */
.winner-modal-content {
    background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-alt) 100%);
    border: 2px solid var(--color-pending);
    box-shadow: 0 0 60px color-mix(in srgb, var(--color-pending) 30%, transparent);
}

.winner-trophy {
    font-size: clamp(4rem, 12vw, 8rem);
    line-height: 1;
    margin-bottom: var(--space-md);
    animation: trophy-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes trophy-bounce {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* === Saved Configs List === */
.config-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.config-item span {
    flex: 1;
    color: var(--color-text);
}

/* === Roster manager (collapsible) === */
.roster-section {
    margin: 0 0 var(--space-lg);
    background: var(--color-surface-alt, var(--color-surface));
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.roster-section > summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--color-text);
    list-style: none;
    user-select: none;
}
.roster-section > summary::-webkit-details-marker { display: none; }
.roster-section > summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform var(--transition-normal);
}
.roster-section[open] > summary::before {
    transform: rotate(90deg);
}

.roster-status {
    color: var(--color-text-muted);
    font-weight: normal;
    font-size: var(--font-sm);
    margin-left: var(--space-xs);
}

.roster-body {
    margin-top: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.roster-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.roster-empty {
    color: var(--color-text-muted);
    font-style: italic;
    padding: var(--space-sm);
    text-align: center;
}

.roster-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.roster-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.roster-row-name {
    color: var(--color-text);
    font-weight: 600;
}

.roster-row-email {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roster-add-row {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.roster-add-row input {
    flex: 1 1 140px;
    min-width: 0;
}

.roster-hint {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    line-height: 1.3;
}

.roster-share-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-top: var(--space-sm);
}

.roster-share-status {
    color: var(--color-text-muted);
    font-size: var(--font-xs);
    word-break: break-all;
}

/* === Team builder (Phase 2) === */
.team-section-label {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    text-transform: uppercase;
    margin-bottom: var(--space-sm);
}

.team-tray-section {
    margin-bottom: var(--space-lg);
}

.team-tray {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    min-height: 56px;
    padding: var(--space-sm);
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.team-tray.drop-ready {
    border-style: solid;
    border-color: var(--color-primary);
}

.team-tray.drop-hover {
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    border-color: var(--color-primary);
}

.team-tray-empty,
.team-zone-empty {
    color: var(--color-text-muted);
    font-style: italic;
    font-size: var(--font-sm);
    padding: var(--space-sm);
    width: 100%;
    text-align: center;
}

.team-chip {
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-md);
    font-family: var(--font-family);
    font-weight: 600;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.team-chip-ghost {
    position: fixed;
    transform: translate(-50%, -50%) scale(1.05);
    pointer-events: none;
    z-index: 9999;
    opacity: 0.92;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    cursor: grabbing;
}

.team-chip:active {
    transform: scale(0.96);
}

.team-chip.selected {
    background: var(--color-primary);
    border-color: var(--color-primary-light, var(--color-primary));
    color: var(--color-on-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.team-chip.in-zone {
    background: var(--color-primary-dark, var(--color-primary));
    border-color: var(--color-primary);
}

.team-chip-order {
    color: var(--color-text-muted);
    font-weight: 400;
    margin-right: 4px;
}

.team-add-row {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.team-add-row input {
    flex: 1 1 180px;
    min-width: 0;
    padding: var(--space-md) var(--space-lg);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--font-md);
    font-family: var(--font-family);
}

.team-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.team-zone {
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    min-height: 180px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.team-zone.drop-ready {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.team-zone.drop-hover {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 22%, transparent);
}

.team-zone-label {
    color: var(--color-text);
    font-weight: bold;
    font-size: var(--font-lg);
    text-align: center;
    margin-bottom: var(--space-sm);
}

.team-zone-members {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.team-builder-hint {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    text-align: center;
    line-height: 1.4;
    margin-top: var(--space-sm);
}

/* === Setup credit footer === */
.setup-credit {
    margin-top: var(--space-xl);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-sm);
}

.setup-credit-by {
    font-size: var(--font-sm);
}

/* "Buy me a Monster" tip button — the Buy-Me-a-Coffee/Ko-fi convention, but
    energy-drink themed and pointed at Cash App. Deliberately keeps its own amber
   brand colours in every theme so it stays instantly recognisable. */
.support-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin: var(--space-md) auto var(--space-sm);
    padding: 9px var(--space-lg);
    min-height: 48px;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, #ffd75e 0%, #f5a623 100%);
    border: 1px solid rgba(0, 0, 0, 0.28);
    box-shadow: 0 4px 14px rgba(245, 166, 35, 0.38),
                inset 0 1px 0 rgba(255, 255, 255, 0.55);
    color: #241a04;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.support-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 20px rgba(245, 166, 35, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.55);
    text-decoration: none;
}

.support-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(245, 166, 35, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.support-btn-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.support-btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.support-btn-title {
    font-size: var(--font-md);
    font-weight: 800;
    letter-spacing: 0.02em;
}

.support-btn-sub {
    font-size: var(--font-xs);
    font-weight: 600;
    opacity: 0.78;
}

.setup-credit-links {
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.setup-credit-links a {
    color: var(--color-primary-light);
    text-decoration: none;
}
.setup-credit-links a:hover {
    text-decoration: underline;
}

.setup-credit-links .dot {
    color: var(--color-text-dim, var(--color-text-muted));
}

/* === Prod-app QR ===
   Sits at the visual bottom of the setup card. The bundled SVG paints its
   modules WHITE (it was drawn for the dark background photo), which made it
   invisible on the light Arctic theme's white card. So the tile is always a
   solid white plate and the image is inverted onto it: invert() leaves the
   transparent ground alone and turns the white modules black. That gives the
   canonical dark-on-light QR — the most scannable form — in every theme,
   rather than depending on whatever is behind it. */
.setup-qr {
    margin-top: var(--space-2xl, var(--space-xl));
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.setup-qr-label {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    text-align: center;
}

.setup-qr a {
    display: inline-block;
    background: #ffffff;
    padding: var(--space-md);
    border: 2px solid rgba(0, 0, 0, 0.18);
    border-radius: var(--radius-md);
    line-height: 0;
}

.setup-qr img {
    display: block;
    width: clamp(140px, 38vw, 200px);
    height: auto;
    image-rendering: pixelated;
    /* White modules -> black on the white plate above. */
    filter: invert(1);
}

.setup-qr-url {
    color: var(--color-text-dim, var(--color-text-muted));
    font-size: var(--font-xs, var(--font-sm));
    font-family: var(--font-mono, monospace);
}

/* ============================================
   Modernized Setup Screen
   ============================================ */

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%);
    border: 0; white-space: nowrap;
}

.setup-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg,
        var(--color-primary),
        color-mix(in srgb, var(--color-primary) 20%, transparent) 70%,
        transparent) 1;
}

.setup-header .setup-logo {
    margin: 0;
    width: 60px;
    height: 60px;
    display: grid;
    place-items: center;
    padding: 5px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-primary) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.setup-header .setup-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.setup-header-text {
    min-width: 0;
    text-align: left;
}

.setup-header-text h1 {
    margin: 0;
    font-family: var(--font-family);
    font-size: calc(var(--font-display-xl) * 0.62);
    line-height: 1;
    letter-spacing: 0.05em;
    font-weight: 900;
    text-align: left;
    color: var(--color-text);
    text-shadow: 0 2px 10px color-mix(in srgb, var(--color-primary) 45%, transparent);
}

.setup-subtitle {
    margin-top: 5px;
    color: var(--color-primary-light, var(--color-primary));
    font-size: var(--font-xs);
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Phones: keep the app bar on one line instead of wrapping the wordmark. */
@media (max-width: 600px) {
    .setup-header {
        gap: var(--space-sm);
        margin-bottom: var(--space-lg);
    }

    .setup-header .setup-logo {
        width: 46px;
        height: 46px;
    }

    .setup-header-text h1 {
        font-size: 1.45rem;
        letter-spacing: 0.03em;
    }

    .setup-subtitle {
        margin-top: 3px;
        font-size: 0.6rem;
        letter-spacing: 0.12em;
    }

    .setup-header-side .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: var(--font-sm);
    }
}

/* Theme picker */
.theme-picker {
    display: flex;
    gap: var(--space-xs);
}

.theme-swatch {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: var(--font-xs);
    line-height: 1;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.theme-swatch:hover {
    border-color: var(--color-border-light);
    color: var(--color-text);
}

.theme-swatch.active {
    background: var(--color-surface-elevated);
    border-color: var(--color-primary);
    color: var(--color-text);
    box-shadow: var(--shadow-glow);
}

.theme-swatch-dot {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.theme-swatch-label {
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* Sections */
.setup-section {
    margin-bottom: var(--space-lg);
}

.setup-panel {
    width: 100%;
    padding: clamp(12px, 2.2vw, var(--space-xl));
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--color-surface-elevated, var(--color-surface)) 30%, transparent),
            transparent 60%),
        color-mix(in srgb, var(--color-surface-alt) 94%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-border-light) 78%, transparent);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.setup-panel:focus-within {
    border-color: color-mix(in srgb, var(--color-primary) 55%, transparent);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.34);
}

.setup-section-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-primary-light, var(--color-primary));
    font-size: var(--font-sm);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin-bottom: var(--space-md);
    font-weight: 800;
}

/* Accent bar — skipped on <summary> labels, which already render a
   disclosure triangle in ::before. */
.setup-section-label:not(summary)::before {
    content: '';
    width: 4px;
    height: 1em;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    flex: 0 0 auto;
}

.setup-section-label::after {
    content: '';
    flex: 1;
    height: 2px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--color-primary) 70%, transparent),
        transparent);
}

.setup-section--collapsible {
    background: color-mix(in srgb, var(--color-surface-alt) 94%, transparent);
}

.setup-section--collapsible > summary {
    cursor: pointer;
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-sm);
}

.setup-section--collapsible > summary::-webkit-details-marker {
    display: none;
}

.setup-section--collapsible > summary::before {
    content: '▸';
    display: inline-block;
    color: var(--color-primary);
    transition: transform var(--transition-fast);
}

.setup-section--collapsible[open] > summary::before {
    transform: rotate(90deg);
}

.setup-section--collapsible[open] > summary {
    margin-bottom: var(--space-md);
}

/* Game grid — auto-fits more columns as the card widens, and scrolls
   inside its own panel so 29 games can't push Start Game a screen-and-a-
   half down the page. */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 28%, 118px), 1fr));
    gap: var(--space-sm);
    max-height: min(46vh, 420px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 2px 4px 2px 2px;
    /* Fade the bottom edge so it reads as "more below". */
    mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 24px), transparent 100%);
    scrollbar-width: thin;
}

.game-grid::-webkit-scrollbar {
    width: 6px;
}

.game-grid::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--color-primary) 55%, transparent);
    border-radius: var(--radius-pill);
}

.game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--space-md) var(--space-sm);
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--color-surface-elevated, var(--color-surface)) 55%, var(--color-surface)),
        var(--color-surface));
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    min-height: 84px;
    line-height: 1.15;
    overflow-wrap: anywhere;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.game-card:hover {
    border-color: color-mix(in srgb, var(--color-primary) 60%, var(--color-border-light));
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.game-card.active {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--color-primary) 26%, var(--color-surface-elevated)),
        var(--color-surface-elevated));
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.game-card.active .game-card-label {
    color: var(--color-primary-light, var(--color-primary));
}

.game-card:active {
    transform: scale(0.97);
}

.game-card-icon {
    font-size: 1.4em;
    line-height: 1;
}

.game-card-label {
    font-size: var(--font-sm);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.game-card-sub {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Player rows */
.player-order-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.player-order-hint {
    color: var(--color-text-muted);
    font-size: var(--font-xs);
    line-height: 1.3;
}

.player-order-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-sm);
}

.player-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 30px;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 5px var(--space-sm);
    min-width: 0;
    margin: 0;
    padding: var(--space-sm);
    background: color-mix(in srgb, var(--color-bg) 72%, transparent);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-border-light);
    border-radius: var(--radius-md);
    transition: opacity var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.player-row label {
    grid-column: 2;
    grid-row: 1;
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    font-weight: 600;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}

.player-row input {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    padding: var(--space-md);
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    font-size: var(--font-md);
    transition: border-color var(--transition-fast);
}

.player-row input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.player-order-drag {
    grid-column: 1;
    grid-row: 1;
    width: 36px;
    min-height: 42px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-size: var(--font-lg);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.player-order-drag:active {
    cursor: grabbing;
}

.player-order-stepper {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-order-stepper button {
    width: 30px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text);
    line-height: 1;
    cursor: pointer;
}

.player-order-stepper button:disabled {
    opacity: 0.28;
    cursor: default;
}

.player-row--dragging {
    opacity: 0.55;
    transform: scale(0.99);
}

.player-row--drop-target {
    border-color: var(--color-primary);
    border-left-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}

/* Portrait tablets have enough width to balance four players as 2×2 cards.
   Phones retain a single vertical list with the same full-width name field. */
@media (orientation: portrait) and (min-width: 600px) {
    .player-order-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Landscape tablets/desktop: the card is wide enough that a single column
   of player rows leaves a lot of dead space next to each name field. */
@media (min-width: 720px) {
    .player-order-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ui-scale-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* X01 / Cricket game-style picker (Settings) */
.score-skin-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--space-sm);
}

.score-skin-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: var(--space-md);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.score-skin-choice.active {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 18%, var(--color-surface));
}

.score-skin-label {
    font-size: var(--font-md);
    font-weight: 800;
}

.score-skin-choice.active .score-skin-label {
    color: var(--color-primary-light, var(--color-primary));
}

.score-skin-desc {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
    line-height: 1.25;
}

.ui-scale-row input[type="range"] {
    flex: 1;
}

.config-row {
    display: flex;
    gap: var(--space-md);
}

.config-row .btn {
    flex: 1;
}

.setup-action-row {
    margin-top: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.setup-play-panel .setup-action-row {
    margin-top: 0;
}

/* Play is the point of the screen — give it the success accent so the eye
   lands on it after the game/player choices. */
.setup-play-panel {
    border-left-color: var(--color-success);
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--color-success) 14%, transparent),
            transparent 70%),
        color-mix(in srgb, var(--color-surface-alt) 94%, transparent);
}

.setup-play-panel .setup-section-label {
    color: var(--color-success);
}

.setup-play-panel .setup-section-label::before {
    background: var(--color-success);
}

.setup-play-panel .setup-section-label::after {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--color-success) 70%, transparent),
        transparent);
}

.setup-maintenance-panel {
    border-left-color: var(--color-border-light);
}

.btn--hero {
    font-size: calc(var(--font-lg) * 1.05);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: var(--shadow-md);
}

/* === Form hint (used by 121/Baseball/Bermuda explanations) === */
.form-hint {
    margin-top: var(--space-sm);
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    line-height: 1.4;
    background: var(--color-surface-alt);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary);
}

/* === Target-Game main area (Baseball + Bermuda Triangle) === */
.target-game-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    gap: var(--space-md);
    overflow: hidden;
}

.target-stage {
    color: var(--color-text-muted);
    font-size: calc(var(--font-lg) * var(--ui-scale));
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.target-value {
    color: var(--color-text);
    font-size: calc(var(--font-score) * var(--ui-scale) * 0.85);
    font-weight: 900;
    line-height: 1;
    background: var(--color-primary);
    padding: var(--space-md) var(--space-2xl);
    border-radius: var(--radius-lg);
    min-width: 30vw;
    text-align: center;
    letter-spacing: -0.02em;
}

.target-hint {
    color: var(--color-text-muted);
    font-size: calc(var(--font-md) * var(--ui-scale));
    text-align: center;
    max-width: 80%;
    line-height: 1.3;
}

/* === Target-Game controls === */
.target-turn-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.target-turn-label {
    color: var(--color-text-muted);
    font-size: var(--font-md);
}

.target-turn-score {
    color: var(--color-pending);
    font-size: calc(var(--font-2xl) * var(--ui-scale));
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.target-hit-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.target-hit-buttons.has-miss {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 600px) {
    .target-hit-buttons.has-miss {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.target-hit-buttons .btn:disabled {
    opacity: 0.35;
    pointer-events: none;
}

.target-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: var(--space-sm);
}

/* === Tic Tac Toe Darts === */
.tic-tac-toe-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-md);
    overflow-y: auto;
}

.tic-game-hint,
.tic-pending {
    color: var(--color-text-muted);
    font-size: calc(var(--font-md) * var(--ui-scale));
    text-align: center;
}

.tic-grid {
    width: min(72dvh, 88vw, 680px);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(4px, 1vw, 10px);
}

.tic-cell {
    position: relative;
    min-width: 0;
    border: 3px solid var(--color-border-light);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-family);
    cursor: pointer;
    touch-action: none;
    overflow: hidden;
}

.tic-cell.owner-0 {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 28%, var(--color-surface));
}

.tic-cell.owner-1 {
    border-color: var(--color-success);
    background: color-mix(in srgb, var(--color-success) 24%, var(--color-surface));
}

.tic-target {
    display: block;
    font-size: calc(clamp(1.5rem, 6vmin, 3.5rem) * var(--ui-scale));
    font-weight: 900;
    line-height: 1;
}

.tic-owner {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    font-size: calc(clamp(4rem, 14vmin, 9rem) * var(--ui-scale));
    font-weight: 900;
    opacity: 0.32;
    line-height: 1;
}

.tic-marks {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    font-size: calc(var(--font-sm) * var(--ui-scale));
    font-weight: 700;
}

.tic-x { color: var(--color-primary-light); }
.tic-o { color: var(--color-success); }

.tic-controls {
    min-height: auto;
    gap: var(--space-sm);
}

.tic-multiplier-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-sm);
}

.tic-multiplier-row .active {
    outline: 3px solid var(--color-pending);
    box-shadow: var(--shadow-glow);
}

.tic-bottom-row {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: var(--space-sm);
}

@media (max-width: 600px) {
    .tic-grid { width: min(60dvh, 94vw); }
    .tic-multiplier-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* === Double Down Cricket === */
.double-down-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    overflow-y: auto;
}

.double-down-phase {
    color: var(--color-pending);
    font-size: calc(var(--font-2xl) * var(--ui-scale));
    font-weight: 900;
    letter-spacing: 0.12em;
}

.double-down-hint,
.double-down-pending {
    color: var(--color-text-muted);
    font-size: calc(var(--font-md) * var(--ui-scale));
    text-align: center;
}

.double-down-board {
    width: min(90vw, 680px);
}

.double-down-targets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md);
}

.double-down-target {
    min-height: clamp(100px, 18dvh, 190px);
    border: 3px solid var(--color-primary);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-family);
    touch-action: none;
}

.double-down-target span {
    display: block;
    font-size: calc(clamp(3rem, 10vmin, 6rem) * var(--ui-scale));
    font-weight: 900;
}

.double-down-target small { color: var(--color-text-muted); }
.double-down-target.complete { border-color: var(--color-success); opacity: 0.7; }
.double-one-target { grid-column: 1 / -1; }

.double-down-cricket-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.double-down-cricket-row {
    display: grid;
    grid-template-columns: 70px 70px 1fr;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
}

.double-down-cricket-row.complete { border-color: var(--color-success); }
.double-down-number { font-size: var(--font-xl); font-weight: 900; text-align: center; }
.double-down-marks { color: var(--color-pending); font-weight: 800; text-align: center; }

.double-down-hit-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-xs);
}

.double-down-hit-buttons button {
    min-height: 42px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: var(--font-lg);
    font-weight: 900;
    touch-action: none;
}

.double-down-players {
    width: min(90vw, 760px);
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: var(--space-sm);
}

.double-down-player {
    display: grid;
    grid-template-columns: 1.2fr 1.4fr 1fr 0.7fr;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-size: var(--font-sm);
}

.double-down-player.active {
    background: color-mix(in srgb, var(--color-primary) 28%, var(--color-surface));
    color: var(--color-text);
}

.double-down-controls { min-height: auto; gap: var(--space-sm); }
.double-down-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: var(--space-sm);
}

@media (max-width: 600px) {
    .double-down-cricket-row { grid-template-columns: 45px 48px 1fr; }
    .double-down-player { grid-template-columns: 1fr 1fr; }
}

/* === Team Cricket / 400 === */
.team-cricket-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-xs);
    overflow-y: auto;
}

.team-cricket-rules-label,
.team-cricket-pending {
    color: var(--color-text-muted);
    font-size: calc(var(--font-sm) * var(--ui-scale));
    text-align: center;
    padding: var(--space-xs);
}

.team-cricket-headings,
.team-cricket-row {
    display: grid;
    grid-template-columns: 1fr 1fr minmax(120px, 24vw) 1fr 1fr;
    align-items: center;
    gap: 2px;
}

.team-cricket-member-heading {
    min-width: 0;
    padding: var(--space-xs) 2px;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    text-align: center;
    overflow: hidden;
}

.team-cricket-member-heading.active {
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.team-cricket-member-heading span,
.team-cricket-member-heading small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.team-cricket-member-heading span { font-weight: 800; }
.team-cricket-member-heading small { font-size: var(--font-xs); opacity: 0.75; }
.team-cricket-center-heading { text-align: center; color: var(--color-text-muted); font-size: var(--font-xs); }

.team-cricket-grid {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.team-cricket-row {
    flex: 1 1 0;
    min-height: clamp(54px, 8dvh, 92px);
    border-bottom: 1px solid var(--color-border);
}

.team-cricket-mark-cell {
    position: relative;
    height: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: color-mix(in srgb, var(--color-surface) 55%, transparent);
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
}

.team-cricket-mark-cell.active {
    background: color-mix(in srgb, var(--color-primary) 20%, transparent);
    box-shadow: inset 3px 0 var(--color-primary), inset -3px 0 var(--color-primary);
}

.team-cricket-mark-cell .mark {
    width: min(calc(clamp(48px, 8dvh, 82px) * var(--ui-scale)), calc(100% - 4px));
    height: auto;
    aspect-ratio: 1;
}

.team-cricket-target-buttons {
    display: grid;
    grid-template-columns: 0.7fr 1fr 0.7fr;
    align-items: center;
    gap: 2px;
    padding: 0 2px;
}

.team-cricket-target-buttons button {
    min-width: 0;
    min-height: clamp(38px, 5dvh, 58px);
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: calc(var(--font-lg) * var(--ui-scale));
    font-weight: 900;
    touch-action: none;
}

.team-cricket-button-spacer { display: block; }
.team-cricket-controls { min-height: auto; gap: var(--space-xs); }
.team-cricket-bottom-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: var(--space-sm);
}

@media (max-width: 600px) {
    .team-cricket-headings,
    .team-cricket-row {
        grid-template-columns: 1fr 1fr minmax(96px, 26vw) 1fr 1fr;
    }
    .team-cricket-member-heading { font-size: 0.72rem; }
    .team-cricket-mark-cell .mark { width: min(52px, calc(100% - 2px)); }
    .team-cricket-target-buttons button { font-size: 0.9rem; }
}

/* === Team-builder additions: first-team badge, reorder buttons === */
.team-zone-first-badge {
    display: none;
    align-self: center;
    margin-bottom: var(--space-xs);
    padding: 2px var(--space-sm);
    background: var(--color-success-dark, var(--color-success));
    color: var(--color-text);
    font-size: var(--font-xs, 0.7rem);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
}

.team-zone.first .team-zone-first-badge {
    display: inline-block;
}

.team-zone-member {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: var(--space-xs);
    background: var(--color-primary-dark, var(--color-primary));
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text);
    touch-action: none;
    user-select: none;
}

.team-zone-member.drop-before {
    box-shadow: 0 -4px 0 var(--color-success);
}

.team-zone-member.drop-after {
    box-shadow: 0 4px 0 var(--color-success);
}

.team-zone-member-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-zone-member-order-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.team-zone-member-order-btns button {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--color-border-light);
    color: var(--color-text);
    font-size: var(--font-sm);
    width: 28px;
    height: 22px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.team-zone-member-order-btns button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.team-zone-member-swap-btn {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--color-border-light);
    color: var(--color-text);
    font-size: var(--font-sm);
    padding: 4px var(--space-sm);
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.team-builder-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    flex-wrap: wrap;
}

.team-builder-actions .btn {
    flex: 1 1 auto;
}

/* === Bermuda face-value picker grid === */
.face-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

.face-picker-grid button {
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md) 0;
    font-size: var(--font-lg);
    font-weight: 700;
    cursor: pointer;
}

.face-picker-grid button:active {
    background: var(--color-primary);
    color: var(--color-on-primary);
    border-color: var(--color-primary-light);
}

/* === 121 summary table === */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
    font-size: var(--font-md);
}

.summary-table th,
.summary-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.summary-table th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.summary-section-label {
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--space-lg);
    margin-bottom: var(--space-xs);
}

.summary-leaderboard-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    color: var(--color-text);
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: var(--font-sm);
}

.summary-leaderboard-row.new-record {
    background: var(--color-success-dark, var(--color-success));
    color: var(--color-text);
    font-weight: 700;
}

/* ============================================
   Game Picker (search / chips / recents / favs)
   ============================================ */

.picker-toolbar {
    margin-bottom: var(--space-sm);
}

.picker-search {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: var(--font-md);
    font-family: inherit;
    outline: none;
}

.picker-search:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.picker-search::placeholder {
    color: var(--color-text-dim);
}

.picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.picker-chip {
    padding: 5px 12px;
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text-muted);
    font-size: var(--font-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.picker-chip:hover {
    border-color: var(--color-border-light);
    color: var(--color-text);
}

.picker-chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
}

.picker-recents {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.picker-recents-label {
    color: var(--color-text-dim);
    font-size: var(--font-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-right: 2px;
}

.picker-recent-chip {
    padding: 5px 10px;
    background: var(--color-surface);
    border: 1.5px dashed var(--color-border-light);
    border-radius: var(--radius-pill);
    color: var(--color-text);
    font-size: var(--font-xs);
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.picker-recent-chip:hover {
    border-color: var(--color-primary);
}

.picker-quickstart {
    border-style: solid;
    border-color: var(--color-success);
    color: var(--color-success);
}

.picker-description {
    margin-top: var(--space-sm);
    color: var(--color-text-muted);
    font-size: var(--font-xs);
    line-height: 1.4;
    min-height: 1.4em;
}

.picker-empty {
    grid-column: 1 / -1;
    padding: var(--space-xl);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-sm);
}

/* Card + favorite star wrapper */
.game-card-wrap {
    position: relative;
}

.game-card-wrap .game-card {
    width: 100%;
    height: 100%;
}

.game-card-fav {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-dim);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    opacity: 0.7;
}

.game-card-fav.faved {
    color: var(--color-warning);
    opacity: 1;
}

/* ⓘ rules badge — bottom-right of each card */
.game-card-info {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-dim);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    opacity: 0.7;
}

/* Rules popover — anchored to the viewport (the grid scrolls, so an
   absolutely-positioned popover would be clipped). picker.js sets left/top. */
.game-rules-pop {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, 78vw);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface-alt);
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    line-height: 1.4;
    text-align: left;
    z-index: var(--z-modal);
}

.game-rules-pop strong {
    display: block;
    color: var(--color-text);
    margin-bottom: 3px;
}

.game-card-new {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 1px 5px;
    background: var(--color-success);
    color: var(--color-on-success);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 3px;
    pointer-events: none;
}

/* ============================================
   Setup header side column (theme picker)
   ============================================ */

.setup-header-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-xs);
    min-width: 0;
}

/* 12 themes — wrap into rows, right-aligned, capped width */
.theme-picker {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 240px;
}

/* ============================================
   Unified Settings modal
   ============================================ */

.settings-modal-content {
    max-width: 420px;
    text-align: left;
}

.settings-section {
    margin-top: var(--space-lg);
}

.settings-section-label {
    font-size: var(--font-sm);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

/* Inside the modal the picker can spread out */
.settings-modal-content .theme-picker {
    max-width: none;
    justify-content: flex-start;
}

.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.wallpaper-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-xs);
    background: transparent;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.wallpaper-choice.active {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.wallpaper-thumb {
    display: block;
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
    background-position: center;
}

.wallpaper-label {
    font-size: var(--font-xs);
    color: var(--color-text-muted);
}

.wallpaper-upload-btn {
    display: inline-block;
    cursor: pointer;
}
