/* ── Top Nav ─────────────────────────────────────────────────── */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    z-index: var(--z-nav);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}

/* The lockup itself is brand.css; the nav only sets its size. */
.nav-brand {
    font-size: 1.375rem;
    font-weight: 400;
}


.nav-spacer { flex: 1; }

.nav-account {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-right: var(--space-2);
    min-width: 0;
}

/* ── Account menu (top right, signed in) ─────────────────────── */

.account-menu {
    position: relative;
    min-width: 0;
}

.account-menu > summary { list-style: none; }
.account-menu > summary::-webkit-details-marker { display: none; }

.account-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: var(--font-size-ui);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.account-btn:hover,
.account-menu[open] > .account-btn {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.account-btn svg { flex-shrink: 0; }

.account-btn-name {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 15rem;
    display: grid;
    gap: 2px;
    padding: var(--space-2);
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: var(--z-popover);
}

.account-who {
    display: grid;
    padding: var(--space-1) var(--space-2) var(--space-2);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.account-who-name {
    font-weight: 600;
    color: var(--text-primary);
}

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

.account-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: 40px;
    padding: 0 var(--space-2);
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: var(--font-size-md);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.account-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.account-item svg { color: var(--text-muted); }
.account-item--out { color: var(--danger); }

/* The theme switch names the theme it switches to, with that theme's icon. */
.account-item .icon-sun  { display: none; }
[data-theme="dark"] .account-item .icon-sun  { display: flex; }
[data-theme="dark"] .account-item .icon-moon { display: none; }

/* Shared by the account menu and the table's options menu. */
.theme-label-light { display: none; }
[data-theme="dark"] .theme-label-light { display: inline; }
[data-theme="dark"] .theme-label-dark  { display: none; }

/* On a phone the account menu steps aside: the bottom bar's Menu drawer holds the
   same things (the theme, Admin, the email, Sign out). It stays on a wider screen,
   where there is no bottom bar and, off the game screens, no other way to them. */
@media (max-width: 700px) {
    .account-menu { display: none; }
}

.auth-message {
    max-width: 32rem;
    margin: var(--space-10) auto;
    padding: 0 var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
}

.auth-message p { color: var(--text-secondary); }

.auth-message .auth-error { color: var(--danger); }

.auth-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    width: 100%;
}

/* The widget is 300px wide at least, and flexible above that. */
.turnstile-slot { width: 100%; max-width: 400px; min-height: 65px; }

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: flex; }

[data-theme="dark"] .theme-toggle .icon-sun  { display: flex; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }


/* ── App Shell ───────────────────────────────────────────────── */

.app-shell {
    display: flex;
    margin-top: var(--nav-height);
    height: calc(100dvh - var(--nav-height));
    overflow: hidden;
}


/* ── Navigation Sidebar ──────────────────────────────────────── */

.app-nav-sidebar {
    width: var(--app-sidebar-width);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: width var(--app-shell-transition), border-color var(--transition),
                background var(--transition);
    z-index: var(--z-sidebar);
}

.app-nav-sidebar.collapsed {
    width: 0;
}

.app-nav-links {
    display: flex;
    flex-direction: column;
    padding: var(--space-4) var(--space-2);
    gap: 2px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-md);
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}

.app-nav-link:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.app-nav-link.active {
    background: var(--brand-dim);
    color: var(--brand);
}

.app-nav-link.stub {
    cursor: not-allowed;
    opacity: 0.45;
    pointer-events: none;
}

.app-nav-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.stub-badge {
    font-size: var(--font-size-2xs);
    font-family: var(--font-mono);
    background: var(--bg-surface-3);
    color: var(--text-muted);
    padding: 1px 5px;
    border-radius: var(--radius-pill);
    margin-left: auto;
    letter-spacing: 0.02em;
}


/* ── App Content ─────────────────────────────────────────────── */

.app-content {
    flex: 1;
    overflow: auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}


/* ── Bottom Nav (mobile) ─────────────────────────────────────── */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: var(--z-nav);
    box-shadow: var(--shadow-up);
    transition: background var(--transition), border-color var(--transition);
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--font-size-2xs);
    font-weight: 500;
    padding: var(--space-2) var(--space-1);
    transition: color var(--transition);
    cursor: pointer;
    white-space: nowrap;
    border: none;
    background: none;
}

.bottom-nav-btn:hover { color: var(--text-primary); }

.bottom-nav-btn.active { color: var(--brand); }

.bottom-nav-btn.stub {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}


/* ── Badges (templates/macros/badges.html; tokens --badge-* in variables.css) ──
   One height and shape for every small label: .badge--rule (what something is),
   --edge (what it costs the player: EV −0.67%), --plus (where the player can win:
   +EV possible), --link (a way somewhere), --stat (a number, no box). */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: none;
    height: var(--badge-h);
    padding: 0 var(--badge-pad-x);
    border: 1px solid var(--badge-rule-border);
    border-radius: var(--badge-radius);
    background: var(--badge-rule-bg);
    color: var(--badge-rule-fg);
    font-size: var(--badge-font-size);
    font-weight: var(--badge-font-weight);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    box-sizing: border-box;
}

.badge--edge { border-color: var(--badge-edge-border); background: var(--badge-edge-bg); color: var(--badge-edge-fg); }
.badge--plus { border-color: var(--badge-plus-border); background: var(--badge-plus-bg); color: var(--badge-plus-fg); }
.badge--link { border-color: var(--badge-link-border); background: var(--badge-link-bg); color: var(--badge-link-fg); }
.badge--link:hover { color: var(--badge-link-fg); filter: brightness(1.08); }
.badge--stat { padding: 0; border-color: transparent; background: none; color: var(--badge-stat-fg); font-weight: 500; }
.badge--stat strong { color: var(--text-primary); font-family: var(--font-mono); font-weight: 600; }
.badge--stat .is-up { color: var(--success); }
.badge--stat .is-down { color: var(--danger); }

.badges { display: flex; align-items: center; gap: var(--badge-gap); min-width: 0; }


/* ── Menu drawer (base.html, static/js/menu.js) ──────────────────
   Slides in from the left over any page, the games included: Home, the games, this
   game's options, the Library, the theme and the account. */

.menu-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--z-drawer);
}

.menu-drawer[hidden] { display: none; }

.menu-scrim {
    position: absolute;
    inset: 0;
    background: var(--scrim);
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease);
}

.menu-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: min(320px, 86vw);
    padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-3)
             calc(var(--space-4) + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease);
}

.menu-panel:focus { outline: none; }

.menu-drawer.is-open .menu-scrim { opacity: 1; }
.menu-drawer.is-open .menu-panel { transform: none; }

@media (prefers-reduced-motion: reduce) {
    .menu-scrim, .menu-panel { transition: none; }
}

.menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding-left: var(--space-1);
}

.menu-brand { font-size: var(--font-size-xl); }

.menu-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.menu-section {
    display: grid;
    gap: 2px;
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
}

.menu-head + .menu-section { border-top: 0; padding-top: 0; }

.menu-section--account { margin-top: auto; }

.menu-title {
    margin: 0 0 var(--space-1);
    padding: 0 var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    min-height: 44px;
    padding: 0 var(--space-2);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: var(--font-size-md);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }

/* The Casino games, under their own small heading in the Places list. */
.menu-title--sub { margin: var(--space-2) 0 0; }
.menu-item svg { flex: none; color: var(--text-muted); }
.menu-item.is-current { color: var(--brand); font-weight: 600; }
.menu-item.is-current svg { color: var(--brand); }
.menu-item--out { color: var(--danger); }

/* An item with what it is set to under its name (Play settings, Table settings). */
.menu-item--detail { align-items: flex-start; padding-top: var(--space-2); padding-bottom: var(--space-2); }
.menu-item--detail svg { margin-top: 2px; }
.menu-item-label { display: block; font-weight: 600; }
.menu-item-sub { display: block; font-size: var(--font-size-xs); color: var(--text-muted); }

.menu-item .icon-sun { display: none; }
[data-theme="dark"] .menu-item .icon-sun  { display: flex; }
[data-theme="dark"] .menu-item .icon-moon { display: none; }

/* A line of text in the drawer: the hand on the table. */
.menu-note {
    margin: 0;
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* A game screen's Menu button in its corner, for screens with no bottom bar. */
.game-menu-btn {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 700px) {
    .menu-item--wide { display: none; }
}

@media (min-width: 701px) {
    .game-menu-btn { display: grid; }
}


/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.45rem var(--space-4);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition),
                border-color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.btn-primary {
    background: var(--brand);
    color: var(--text-on-brand);
    border-color: var(--brand);
}
.btn-primary:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-sm {
    padding: 0.3rem var(--space-3);
    font-size: var(--font-size-ui);
}


/* ── Cards ───────────────────────────────────────────────────── */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}

.card-body {
    padding: var(--space-6);
}


/* ── Landing Hero ────────────────────────────────────────────── */

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-16) var(--space-6) var(--space-12);
    gap: var(--space-4);
}

.hero-logo {
    width: 96px;
    height: auto;
    margin-bottom: var(--space-4);
    filter: drop-shadow(0 4px 16px var(--brand-glow));
}

/* The wordmark (brand.css) at hero size. */
.hero-title {
    font-size: var(--font-size-5xl);
    font-weight: inherit;
    line-height: 1;
    color: var(--text-primary);
}

.hero-tagline {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    max-width: 480px;
    line-height: 1.65;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-5);
    padding: 0 var(--space-6) var(--space-12);
    max-width: 960px;
    margin: 0 auto;
}

.tool-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition),
                border-color var(--transition), background var(--transition);
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand);
    color: inherit;
}

.tool-card-icon {
    width: 40px;
    height: 40px;
    background: var(--brand-dim);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card-icon svg {
    width: 22px;
    height: 22px;
    color: var(--brand);
}

.tool-card h3 {
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.tool-card p {
    font-size: var(--font-size-md);
    color: var(--text-muted);
    line-height: 1.55;
}


/* ── Range Painter Layout ────────────────────────────────────── */

.painter-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.painter-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    transition: background var(--transition), border-color var(--transition);
}

.painter-main {
    flex: 1;
    min-width: 0;
    container-type: inline-size;   /* the grid sizes its cells to this width */
    overflow: hidden;
    padding: var(--space-2) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.painter-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.painter-toolbar h2 {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--text-primary);
}

.vpip-stat {
    font-family: var(--font-mono);
    font-size: var(--font-size-ui);
    color: var(--text-muted);
    margin-right: auto;
}

.painter-panel-toggle {
    display: none;
}

.painter-file {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.painter-file .load-range-select { max-width: 12rem; }


.range-name-input {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-ui);
    padding: 0.25rem 0.5rem;
    width: 14rem;
}

.load-range-select {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-ui);
    padding: 0.25rem 0.5rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.sidebar-label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--border);
}


/* ── Action Palette ──────────────────────────────────────────── */

.action-palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-2) var(--space-1);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--on-action);
    transition: opacity var(--transition), border-color var(--transition),
                box-shadow var(--transition);
    user-select: none;
    min-height: 44px;
}

.action-btn .action-size {
    font-family: var(--font-mono);
    font-size: var(--font-size-2xs);
    font-weight: 500;
    opacity: 0.9;
    letter-spacing: 0;
}

.action-btn:hover { opacity: 0.85; }

.action-btn.active {
    border-color: var(--action-selected);
    box-shadow: 0 0 0 2px var(--action-selected-ring);
}

.action-btn[data-action="fold"] { background: var(--action-fold); }
.action-btn[data-action="call"] { background: var(--action-call); }
.action-btn[data-action="r1"]   { background: var(--action-raise-1); color: var(--on-action-light); }
.action-btn[data-action="r2"]   { background: var(--action-raise-2); color: var(--on-action-light); }
.action-btn[data-action="r3"]   { background: var(--action-raise-3); }
.action-btn[data-action="r4"]   { background: var(--action-raise-4); }
.action-btn[data-action="r5"]   { background: var(--action-raise-5); }
.action-btn[data-action="ai"]   { background: var(--action-allin); }

.action-btn[data-action="r1"].active,
.action-btn[data-action="r2"].active {
    border-color: var(--action-selected-light);
    box-shadow: 0 0 0 2px var(--action-selected-ring-light);
}


/* ── Frequency Control ───────────────────────────────────────── */

.freq-control {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.freq-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.freq-label {
    font-size: var(--font-size-ui);
    color: var(--text-secondary);
    white-space: nowrap;
}

.freq-input {
    width: 58px;
    padding: 4px var(--space-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-2);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-md);
    text-align: right;
    transition: border-color var(--transition), background var(--transition);
}

.freq-input:focus {
    outline: none;
    border-color: var(--brand);
}

.freq-unit {
    font-size: var(--font-size-ui);
    color: var(--text-muted);
}


/* ── Raise Slots Config ──────────────────────────────────────── */

.raise-slots {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.raise-slot-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.slot-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.slot-swatch[data-action="r1"] { background: var(--action-raise-1); }
.slot-swatch[data-action="r2"] { background: var(--action-raise-2); }
.slot-swatch[data-action="r3"] { background: var(--action-raise-3); }
.slot-swatch[data-action="r4"] { background: var(--action-raise-4); }
.slot-swatch[data-action="r5"] { background: var(--action-raise-5); }
.slot-swatch[data-action="ai"] { background: var(--action-allin); }

.slot-name {
    font-size: var(--font-size-sm);
    font-family: var(--font-mono);
    color: var(--text-muted);
    width: 20px;
    flex-shrink: 0;
}

.slot-input {
    flex: 1;
    min-width: 0;
    padding: 3px var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface-2);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-size-ui);
    transition: border-color var(--transition), background var(--transition);
}

.slot-input:focus {
    outline: none;
    border-color: var(--brand);
}

.slot-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ── Range Grid ──────────────────────────────────────────────── */

.range-grid-wrap {
    display: inline-block;
    user-select: none;
}

.range-grid {
    display: grid;
    grid-template-columns: var(--cell-header-size) repeat(13, var(--cell-size));
    grid-template-rows: var(--cell-header-size) repeat(13, var(--cell-size));
    gap: var(--cell-gap);
}

.grid-corner { /* empty top-left cell */ }

.grid-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
}

.range-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: crosshair;
    position: relative;
    overflow: hidden;
    transition: border-color var(--duration-fast), transform var(--duration-fast);
    background: var(--cell-empty);
}

.range-cell:hover {
    border-color: var(--cell-hover-border);
    transform: scale(1.06);
    z-index: var(--z-raised);
}

.cell-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: var(--cell-label-size);
    font-weight: 500;
    color: var(--cell-label-on-fill);
    pointer-events: none;
    text-shadow: var(--cell-label-shadow);
    z-index: 1;
    letter-spacing: -0.02em;
}

/* The painter's grid fits its column: 44px cells at most, smaller when the column is
   narrower (100cqi is its width) or the window is short. */
.painter-main .range-grid {
    --cell-size: min(44px,
                     calc((100cqi - var(--cell-header-size) - 13 * var(--cell-gap)) / 13),
                     calc((100dvh - 150px) / 14));
    touch-action: none;   /* a drag paints rather than scrolls */
}

.range-cell.unassigned .cell-label {
    color: var(--text-muted);
    text-shadow: none;
}


/* ── Tooltip ─────────────────────────────────────────────────── */

.range-tooltip {
    position: fixed;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-ui);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    z-index: var(--z-tooltip);
    min-width: 160px;
    display: none;
}

.range-tooltip.visible { display: block; }

.tooltip-combo {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.tooltip-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 2px 0;
}

.tooltip-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.tooltip-action {
    flex: 1;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.tooltip-freq {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
}


/* ── Save Status ─────────────────────────────────────────────── */

.save-status {
    font-size: var(--font-size-ui);
    font-family: var(--font-mono);
    color: var(--text-muted);
    transition: color var(--transition);
}

.save-status.saved  { color: var(--brand-strong); }
.save-status.saving { color: var(--text-secondary); }
.save-status.error  { color: var(--danger); }


/* ── Footer ──────────────────────────────────────────────────── */

.footer {
    border-top: 1px solid var(--border);
    padding: var(--space-6);
    text-align: center;
    font-size: var(--font-size-ui);
    color: var(--text-muted);
    margin-top: auto;
    transition: border-color var(--transition);
}


/* ── Mobile breakpoint ───────────────────────────────────────── */

@media (max-width: 700px) {
    .app-nav-sidebar { display: none; }
    .sidebar-toggle  { display: none; }

    .bottom-nav {
        display: flex;
    }

    .app-shell {
        height: calc(100dvh - var(--nav-height) - var(--bottom-nav-height));
    }

    .app-content {
        padding-bottom: 0;
    }

    /* Phone painter: the palette is a strip under the grid, within reach of a thumb;
       the page scrolls as one; the raise sizes open under the Sizes button. */
    .painter-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .painter-sidebar {
        order: 1;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
        overflow: visible;
        scrollbar-gutter: auto;
    }

    .painter-main {
        order: 0;
        overflow: visible;
        padding: var(--space-2) var(--space-3) 0;
    }

    .painter-sidebar .sidebar-label { display: none; }

    .action-palette {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: var(--space-1);
        padding: 3px;            /* room for the active ring */
    }

    .action-btn {
        min-height: 40px;
        padding: var(--space-1);
    }

    .freq-control {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .raise-sizes-section { display: none; }
    .painter-layout.mobile-sizes-open .raise-sizes-section { display: flex; }

    .raise-slots {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: var(--space-4);
    }

    .painter-panel-toggle {
        display: inline-flex;
    }

    .painter-toolbar { gap: var(--space-2); }
    .painter-toolbar h2 { font-size: var(--font-size-md); }
    .range-name-input { width: auto; flex: 1 1 8rem; min-width: 0; }

    .painter-main .range-grid {
        --cell-header-size: 16px;
        --cell-label-size: 8px;
        --cell-size: min(44px, calc((100cqi - var(--cell-header-size) - 13 * var(--cell-gap)) / 13));
    }

    .range-cell:hover { transform: none; }
}

/* ── Notices (templates/partials/flashes.html): the Library admin, the account ── */

.notices { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }

.notice {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--success-border);
    background: var(--success-bg);
    color: var(--text-primary);
    font-size: var(--font-size-md);
}

.notice--error { border-color: var(--danger-border); background: var(--danger-bg); }
.notice--preview { border-color: var(--warning-border); background: var(--warning-bg); margin-bottom: var(--space-4); }

/* ── The public pages' links (templates/partials/info_links.html) ── */

.footer-line { margin: 0 0 var(--space-2); }

.info-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-1) var(--space-4);
    font-size: var(--font-size-sm);
}
.info-links a { color: var(--text-muted); text-decoration: none; }
.info-links a:hover { color: var(--text-primary); text-decoration: underline; }

.menu-section--info .info-links { justify-content: flex-start; padding: var(--space-2) var(--space-2) 0; gap: var(--space-1) var(--space-3); font-size: var(--font-size-xs); }

/* ── Save and play, and Back, on the game settings pages (blackjack, roulette,
   craps, poker's Play settings): in the page's actions on a wide screen; on a phone a
   matched pair of pills floating above the bottom bar, so a long settings page can be
   left either way without scrolling to its end. Back (to the page the settings
   were opened from) is grey, bottom-left, its chevron pointing left; Save and play green, bottom-right, pointing right; under
   360px wide they stack on the right. The pages leave room under their last part. ── */

.settings-go,
.settings-back { display: inline-flex; align-items: center; gap: var(--space-2); }

@media (max-width: 700px) {
    .settings-go,
    .settings-back {
        position: fixed;
        bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom));
        z-index: var(--z-popover);
        min-height: 48px;
        border: 0;
        border-radius: var(--radius-pill);
        font-size: var(--font-size-md);
        box-shadow: var(--shadow-lg);
    }
    .settings-go {
        right: var(--space-4);
        padding: 0 var(--space-5) 0 var(--space-4);
        background: var(--brand-hover);
        color: var(--text-on-brand);
    }
    .settings-back {
        left: var(--space-4);
        padding: 0 var(--space-5) 0 var(--space-4);
        background: var(--bg-surface-3);
        border: 1px solid var(--border-strong);
        color: var(--text-primary);
    }
    form.bj-settings,
    form.hands { padding-bottom: calc(var(--space-8) + 64px); }
}

/* Too narrow for the pair side by side (under 360px): stacked on the right, Back
   above Save and play. */
@media (max-width: 359px) {
    .settings-back {
        left: auto;
        right: var(--space-4);
        bottom: calc(var(--bottom-nav-height) + var(--space-4) + 48px + var(--space-2) + env(safe-area-inset-bottom));
    }
    form.bj-settings,
    form.hands { padding-bottom: calc(var(--space-8) + 120px); }
}
