﻿:root {
    color-scheme: light dark;
    --accent: #b8203b;
    --accent-strong: #95182f;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #edf1f6;
    --text: #192333;
    --muted: #525f71;
    --border: #d8e0ea;
    --ball-bg: var(--surface-2);
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;
    --radius: var(--r-md);
    --control-radius: var(--r-md);
    --fs-xs: .75rem;
    --fs-sm: .875rem;
    --fs-md: 1rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.6rem;
    --page-content-max: 48.75rem;
    --header-content-max: var(--page-content-max);
    --page-gutter: clamp(.8rem, 3vw, 2rem);
    --section-gap: .75rem;
    --control-height: 2.125rem;
    --control-font-size: var(--fs-sm);
    --action: #b8203b;
    --action-hover: #95182f;
    --warn: #f5a623;
    --highlight: #8a6100;
    --above: #b8203b;
    --below: #1f6fbf;
    --chart-actual: #b8203b;
    --chart-expected: #525f71;
    --chart-compare: #1f6fbf;
    --cell-text-mid: #000;
    --cell-text-hi: #000;
    --cell-text-top: #fff;
    --shadow: 0 .25rem .5rem -.125rem rgb(25 35 51 / .07);
    --shadow-raised: 0 .375rem .875rem -.125rem rgb(25 35 51 / .14);
    --ease-premium: cubic-bezier(.2, .75, .25, 1);
}

/* Theme: follows the system unless the visitor picks Light or Dark (html[data-theme], set by the
   header theme button and by a small script in App.razor before first paint). The dark values are
   listed twice because CSS has no way to share them between a media query and an attribute selector. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #ff6178;
        --accent-strong: #ff8192;
        --bg: #0d1015;
        --surface: #151a21;
        --surface-2: #1d242d;
        --text: #f0f2f5;
        --muted: #a1aab6;
        --border: #2a323d;
        --ball-bg: #202630;
        --highlight: #f4cc55;
        --above: #ff4d63;
        --below: #4096e6;
        --chart-actual: #ff6178;
        --chart-expected: #9aa5b4;
        --chart-compare: #4096e6;
        --cell-text-mid: #fff;
        --cell-text-hi: #000;
        --cell-text-top: #000;
        --shadow: 0 .25rem .5rem -.125rem rgb(0 0 0 / .22);
        --shadow-raised: 0 .375rem .875rem -.125rem rgb(0 0 0 / .35);    }
}

:root[data-theme="dark"] {
        --accent: #ff6178;
        --accent-strong: #ff8192;
        --bg: #0d1015;
        --surface: #151a21;
        --surface-2: #1d242d;
        --text: #f0f2f5;
        --muted: #a1aab6;
        --border: #2a323d;
        --ball-bg: #202630;
        --highlight: #f4cc55;
        --above: #ff4d63;
        --below: #4096e6;
        --chart-actual: #ff6178;
        --chart-expected: #9aa5b4;
        --chart-compare: #4096e6;
        --cell-text-mid: #fff;
        --cell-text-hi: #000;
        --cell-text-top: #000;
        --shadow: 0 .25rem .5rem -.125rem rgb(0 0 0 / .22);
        --shadow-raised: 0 .375rem .875rem -.125rem rgb(0 0 0 / .35);}

*, *::before, *::after { box-sizing: border-box; }

html { font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

a { color: var(--accent); }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); line-height: 1.12; letter-spacing: -.045em; margin: 0; font-weight: 760; }
h2 { font-size: var(--fs-lg); line-height: 1.25; letter-spacing: -.025em; margin: 0; font-weight: 700; }
h3 { font-size: var(--fs-md); line-height: 1.35; letter-spacing: -.01em; margin: 0 0 .5rem; font-weight: 680; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); line-height: 1.65; }
p { margin: .25rem 0 .75rem; }

/* Layout */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.skip-link { position: fixed; inset: .65rem auto auto 1rem; z-index: 20; padding: .45rem .75rem; border-radius: var(--r-sm); background: var(--surface); transform: translateY(-200%); }
.skip-link:focus { transform: none; }
#main-content { scroll-margin-top: 5rem; }

.app-header {
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: saturate(145%) blur(18px);
    -webkit-backdrop-filter: saturate(145%) blur(18px);
}

.app-header-inner, .app-main { width: calc(100% - 2 * var(--page-gutter)); margin: 0 auto; min-width: 0; }
.app-header-inner {
    max-width: var(--header-content-max);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: .6rem;
}

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.025em; font-size: var(--fs-md); transition: opacity .2s var(--ease-premium), transform .2s var(--ease-premium); }
.brand:hover { opacity: .84; transform: translateY(-1px); }
.app-header nav { display: flex; gap: .3rem; }
.app-header nav a {
    padding: .55rem .95rem; border-radius: var(--r-pill);
    color: var(--muted); text-decoration: none; font-weight: 620; font-size: var(--fs-sm);
    transition: color .22s var(--ease-premium), background .22s var(--ease-premium), transform .22s var(--ease-premium);
}
.app-header nav a:hover { background: color-mix(in srgb, var(--surface-2) 78%, transparent); color: var(--text); transform: translateY(-1px); }
.app-header nav a.active { background: var(--surface-2); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent); }

.app-main { flex: 1; max-width: var(--page-content-max); padding-block: clamp(.9rem, 2vw, 1.5rem) 2rem; }
.app-footer { padding: 1.25rem 1.25rem 1.5rem; text-align: center; font-size: var(--fs-sm); line-height: 1.7; color: var(--muted); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 58%, transparent); }
.footer-note { max-width: 76ch; margin: .5rem auto 0; }
.footer-brand { color: var(--text); margin-bottom: .25rem; }
.footer-brand strong { font-weight: 700; }
.footer-links { margin: .35rem 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .65rem 1rem; margin-bottom: var(--section-gap); }
.page-intro { margin: .3rem 0 .55rem; max-width: 60ch; font-size: var(--fs-md); line-height: 1.65; }
.page-intro:last-child { margin-bottom: 0; }
.status-summary { display: inline-flex; align-items: center; gap: .45rem; margin: 0; padding: .2rem .6rem; border: 1px solid var(--border); border-radius: var(--r-pill); background: color-mix(in srgb, var(--surface) 76%, transparent); font-size: var(--fs-sm); font-weight: 650; font-variant-numeric: tabular-nums; }
.source-timing { display: flex; flex-wrap: wrap; gap: .1rem .7rem; margin-top: .35rem; }
.status-detail { margin: 0; font-size: var(--fs-sm); line-height: 1.6; }
.toolbar { display: flex; align-items: center; gap: 1rem; }
.source-bar { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin-bottom: 1rem; }
.source-settings { margin: 0 0 var(--section-gap); border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--surface) 83%, transparent); box-shadow: 0 4px 16px rgba(0,0,0,.025); overflow: clip; }
.source-settings > summary { cursor: pointer; padding: .6rem .9rem; font-size: var(--fs-sm); color: var(--text); font-weight: 620; transition: background .2s var(--ease-premium); }
.source-settings > summary:hover { background: var(--surface-2); }
.source-settings .source-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; padding: .5rem 1rem 1rem; margin: 0; }
.source-settings .field { display: grid; gap: .3rem; min-width: 0; }
.source-settings select { width: 100%; min-width: 0; }
.latest-draw .balls { margin-top: .75rem; }
.saved-tickets-fold { margin-top: 1rem; }
.saved-tickets-fold > summary { padding: .5rem 0; cursor: pointer; font-weight: 700; font-size: var(--fs-md); }
.saved-tickets-fold[open] > summary { margin-bottom: .35rem; }
.ticket-notice { color: var(--text); }
.ticket-comparison { margin-top: .75rem; }
.ticket-comparison > summary { padding: .65rem 0; cursor: pointer; color: var(--accent); font-weight: 600; }
.ticket-comparison[open] > summary { margin-bottom: .5rem; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(.85rem, 2vw, 1.15rem);
    margin-bottom: var(--section-gap);
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; margin-bottom: .4rem; }
.prose p, .prose ul, .prose ol { max-width: 68ch; line-height: 1.6; margin-block: .45rem .65rem; }
.prose ul, .prose ol { padding-inline-start: 1.3rem; }
.prose li + li { margin-top: .35rem; }
.prose h3 { margin-top: 1rem; }
.card > p:last-child, .prose > :is(ul, ol):last-child { margin-bottom: 0; }
.card > p { max-width: 100ch; }

.stat-label { color: var(--muted); }

.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; }
.three-col .card { margin-bottom: 0; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: .75rem; }
.field { display: flex; align-items: center; gap: .4rem; font-size: var(--control-font-size); color: var(--muted); }
select, input[type="number"], .ticket-name {
    min-height: var(--control-height); font: inherit; font-size: var(--control-font-size); color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
    padding: .2rem .55rem;
    transition: border-color .2s var(--ease-premium), box-shadow .2s var(--ease-premium), background .2s var(--ease-premium);
}
input[type="number"] { width: 5rem; }
.switch { display: flex; align-items: center; gap: .4rem; min-height: var(--control-height); font-size: var(--control-font-size); cursor: pointer; }

.btn {
    min-height: var(--control-height); font: inherit; font-size: var(--control-font-size); font-weight: 650; cursor: pointer;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--control-radius);
    padding: .2rem .65rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: color .2s var(--ease-premium), background .2s var(--ease-premium), border-color .2s var(--ease-premium), box-shadow .2s var(--ease-premium), transform .2s var(--ease-premium);
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow-raised); transform: translateY(-1px); }
.btn.primary { background: var(--action); border-color: var(--action); color: #fff; box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--action-hover); }
.btn.primary:disabled { background: var(--surface-2); border-color: var(--border); color: var(--muted); opacity: 1; }
.btn:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.banner { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.banner.warn { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); border-color: var(--warn); }

/* Number balls */
.balls { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.ball {
    display: inline-grid; place-items: center;
    min-width: 2rem; height: 2rem; padding: 0 .2rem; border-radius: var(--r-pill);
    background: var(--ball-bg); border: 1px solid var(--border);
    font-size: var(--fs-sm); font-weight: 650; font-variant-numeric: tabular-nums;
}
.ball.hit { background: var(--action); border-color: var(--action); color: #fff; }
/* Matching draws: ten numbers per line, shrinking to fit narrow phones. */
.match-list .balls, .latest-draw .balls { display: grid; grid-template-columns: repeat(10, minmax(0, 2rem)); gap: .3rem; }
.match-list .ball, .latest-draw .ball { min-width: 0; padding: 0; }
@media (max-width: 420px) {
    .match-list .balls, .latest-draw .balls { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: .2rem; }
    .match-list .ball, .latest-draw .ball { height: auto; aspect-ratio: 1; font-size: var(--fs-xs, .75rem); }
}

/* Frequency legend uses the same accent-to-surface mixing as the cells.
   The low end represents the least frequent number in the selected window. */
.frequency-legend { display: flex; align-items: center; gap: .65rem; margin: .3rem 0 .55rem; color: var(--muted); font-size: var(--fs-xs); }
.frequency-legend-bar { flex: 1; max-width: 260px; height: .75rem; border-radius: var(--r-pill); border: 1px solid var(--border); background: linear-gradient(to right, var(--surface-2), color-mix(in srgb, var(--accent) 42.5%, var(--surface-2)), color-mix(in srgb, var(--accent) 85%, var(--surface-2))); }
@media (max-width: 600px) { .frequency-legend { gap: .35rem; font-size: var(--fs-xs); } }

/* Keep the 80-number board visually balanced on wide layouts and compact on phones. */
.grid80 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: clamp(.25rem, .55vw, .45rem); }
.cell {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    aspect-ratio: 1; min-width: 0; min-height: 0; padding: .2rem;
    font: inherit; color: var(--text); cursor: pointer;
    background: color-mix(in srgb, var(--accent) calc(var(--heat, 0) * 85%), var(--surface-2));
    border: 1px solid var(--border); border-radius: var(--r-sm);
    transition: transform .18s var(--ease-premium), box-shadow .18s var(--ease-premium), border-color .18s var(--ease-premium), filter .18s var(--ease-premium);
}
.cell:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 72%, var(--border)); box-shadow: 0 5px 12px rgba(0,0,0,.12); filter: saturate(1.08); }
.cell:active { transform: scale(.96); }
/* Number text on heat-coloured cells. The fill gets lighter as heat rises, so the text colour flips at the points
   where each theme still keeps 4.5:1 contrast (light: black, then white at the very top; dark: white, then black). */
.cell.on-accent { color: var(--cell-text-mid); }
.cell.on-accent-hi { color: var(--cell-text-hi); }
.cell.on-accent-top { color: var(--cell-text-top); }
.cell-n, .cell-c { line-height: 1; font-variant-numeric: tabular-nums; }
.cell-n { font-size: var(--fs-md); font-weight: 700; }
.cell-c { font-size: .72rem; font-weight: 600; opacity: .9; margin-top: .12rem; }

/* Rankings */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.rank .ball { min-width: 1.65rem; height: 1.65rem; }
.rank li { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: var(--fs-sm); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ticket { margin: .5rem 0 .75rem; }
.disclaimer { text-align: center; }

@media (max-width: 720px) {
    .three-col { grid-template-columns: 1fr; }
    .app-header-inner { flex-wrap: wrap; gap: .45rem; }
    .app-header nav { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem; }
    .app-header nav a { text-align: center; padding: .45rem .2rem; font-size: var(--fs-sm); line-height: 1.35; align-content: center; }
    .app-main #ticket-checker, .app-main #ticket-comparison, .app-main #number-frequency { scroll-margin-top: 9rem; }
}


@media (prefers-reduced-motion: reduce) {
    .cell { transition: none; }
}

/* Blazor error UI */
#blazor-error-ui {
    background: #fff4c2; color: #1b1f24;
    bottom: 0; left: 0; width: 100%;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none; padding: .6rem 1.25rem .7rem; position: fixed; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: #fff; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Compact phone layout */
@media (max-width: 600px) {
    .app-main { padding-block: .9rem 2rem; }
    .page-head { align-items: stretch; }
    .toolbar { flex-wrap: wrap; }
    .three-col { grid-template-columns: 1fr; }
    .grid80 { gap: .2rem; }
    .card { min-width: 0; padding: 1rem; }
    .cell { min-width: 0; min-height: 0; padding: .05rem 0; }
    .table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; }
    .source-settings .source-bar { grid-template-columns: 1fr; }
}

/* Blazor route navigation can focus the page heading. Do not outline non-interactive headings. */
h1:focus-visible, h2:focus-visible, h3:focus-visible { outline: none; }

/* Branded header icon */
.brand-icon {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    border-radius: var(--r-md);
    flex-shrink: 0;
}


/* Accessible, viewport-bound help dialogs. Only one is open per user session. */
.help-tip-wrap { display: inline-flex; align-items: center; vertical-align: middle; text-transform: none; letter-spacing: normal; }
.help-tip-trigger { display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; padding: 0; border-radius: 50%; border: 1px solid var(--accent); background: transparent; color: var(--accent); font: 700 .8rem/1 system-ui, sans-serif; cursor: pointer; }
.help-tip-trigger:hover, .help-tip-trigger[aria-expanded="true"] { background: var(--accent); color: #fff; }
.help-tip-trigger:focus-visible, .help-tip-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.help-tip-backdrop { position: fixed; inset: 0; z-index: 9998; background: transparent; }
/* Help popover: anchored next to its "?" button. kenoHelp.open (keno-preferences.js) sets left/top, the arrow
   position, and a max-height so it stays fully inside the screen; it flips above the button when there is no room below. */
.help-tip-content { position: fixed; left: 0; top: 0; z-index: 9999; display: flex; flex-direction: column; gap: .6rem; width: min(25rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0,0,0,.4); font-size: var(--fs-md); font-weight: 400; line-height: 1.65; white-space: normal; text-align: left; }
.help-tip-content::before { content: ""; position: absolute; left: var(--arrow-x, 50%); width: .75rem; height: .75rem; background: var(--surface); border: 1px solid var(--border); transform: translateX(-50%) rotate(45deg); }
.help-tip-content[data-placement="below"]::before { top: -.4rem; border-width: 1px 0 0 1px; }
.help-tip-content[data-placement="above"]::before { bottom: -.4rem; border-width: 0 1px 1px 0; }
.help-tip-topline { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.help-tip-topline strong { font-weight: 700; color: var(--text); }
.help-tip-close { display: grid; place-items: center; flex: 0 0 2rem; width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.help-tip-description { display: block; color: var(--text); min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.heading-help { display: inline-flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.metric-explain { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-right: .8rem; margin-bottom: .25rem; }

/* Expected-frequency comparison view */
.deviation-legend-bar {
    flex: 1; max-width: 260px; height: .75rem; border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: linear-gradient(to right, var(--below), var(--surface-2) 50%, var(--above));
}
.cell.deviation-cell { color: var(--text); }

/* Insights, tickets, history, status */
.insight-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem 1rem; padding: .7rem; margin: .6rem 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.quick-pick { align-items: center; margin: .5rem 0 .8rem; }
.saved-tickets { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.trend-chart { display: block; width: 100%; height: auto; max-height: 300px; color: var(--muted); }
/* One scroll area (the page): a nested scroller made opened rows jump when another row collapsed. */
.recent-list { display: grid; gap: .35rem; }
.recent-list.match-list { margin-bottom: .75rem; }
.recent-item { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; padding: .3rem .55rem; border: 1px solid var(--border); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface) 76%, transparent); }
.recent-item-head { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; cursor: pointer; background: none; border: 0; padding: .1rem 0; font: inherit; color: inherit; text-align: left; border-radius: var(--r-md); }
.recent-item-head:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.recent-item-head.selected strong { text-decoration: underline; text-underline-offset: 3px; }
.recent-item-head .chevron { flex: none; transition: transform .15s; }
.recent-item-head[aria-expanded="true"] .chevron { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .recent-item-head .chevron { transition: none; } }
.recent-draw-details { flex-basis: 100%; min-width: 0; }
.recent-draw-details > .btn { margin-top: .5rem; }
.health-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; margin: 1rem 0; }
.health-grid > div { display: grid; gap: .25rem; }
.prob-table { min-width: 0; }
.prob-table th, .prob-table td { padding-inline: .4rem; }
@media(max-width:600px) { .health-grid { grid-template-columns: 1fr; } .insight-strip { align-items: flex-start; flex-direction: column; } }

/* A corner dot (a shape, not just a colour) marks numbers in the selected draw, separate from the picked ring. */
.cell { position: relative; }
.cell.draw-highlight::after { content: ""; position: absolute; top: 3px; right: 3px; width: .45rem; height: .45rem; border-radius: 50%; background: var(--highlight); box-shadow: 0 0 0 1.5px var(--surface); }

/* Ticket controls, collapsible sections, recent mini-grid */
.dashboard-fold { margin: 0 0 var(--section-gap); }
.dashboard-fold > summary { list-style-position: inside; padding: .6rem .9rem; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); font-weight: 700; cursor: pointer; }
.dashboard-fold .card { margin-bottom: .5rem; }
.ticket-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .35rem .75rem;
    margin-bottom: .5rem;
    font-size: var(--fs-sm);
    color: var(--muted);
}
.ticket-selection-count strong { color: var(--text); font-variant-numeric: tabular-nums; }
.ticket-selection .btn { white-space: nowrap; }
.ticket-name { max-width: 10rem; }
.saved-ticket-item { display: flex; align-items: center; gap: .25rem; max-width: 100%; }
.saved-ticket-item .btn:first-child { max-width: min(100%, 25rem); text-overflow: ellipsis; overflow: hidden; }
.recent-mini-grid { width: 100%; max-width: 19rem; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.recent-mini-cell { display: grid; place-items: center; aspect-ratio: 1; min-width: 0; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); line-height: 1; font-variant-numeric: tabular-nums; }
.recent-mini-cell.hit { background: var(--action); color: #fff; font-weight: 700; }
.recent-mini-cell.repeat { outline: 1px dashed currentColor; outline-offset: -2px; }
.recent-draw-legend { display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.recent-draw-legend .recent-mini-cell { width: 1rem; }
#ticket-checker, #ticket-comparison, #number-frequency { scroll-margin-top: 6rem; }

.trend-scrubber { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.trend-scrubber input { min-width: 10rem; flex: 1; accent-color: var(--accent); }

/* Premium surface, hierarchy, and interaction refinements */
.page-head > div:first-child { flex: 1 1 20rem; min-width: 0; }
.page-head .toolbar { align-self: flex-end; flex-wrap: wrap; gap: .6rem; }
.status-summary { box-shadow: inset 0 1px rgba(255,255,255,.35); }
.toolbar .switch { padding: .2rem .65rem; border: 1px solid var(--border); border-radius: var(--control-radius); background: color-mix(in srgb, var(--surface) 76%, transparent); }
.toolbar input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--accent); }

.card-head h2 { letter-spacing: -.03em; }
.card#number-frequency { padding-inline: clamp(1rem, 3vw, 2rem); }
.prose a { text-decoration-thickness: .08em; text-underline-offset: .18em; }

.cell { aspect-ratio: 1; min-height: 0; border-radius: var(--r-md); box-shadow: inset 0 1px rgba(255,255,255,.12); }
.cell.picked { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text), 0 6px 12px rgba(0,0,0,.25); transform: scale(1.06); z-index: 1; }
.cell.picked:hover { transform: scale(1.06); }
.cell:focus-visible { outline-color: var(--text); }
.frequency-legend-bar, .deviation-legend-bar { box-shadow: inset 0 1px rgba(255,255,255,.22), 0 2px 5px rgba(0,0,0,.08); }

.btn:not(.primary):active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent); transform: translateY(-2px); }
select:hover, input[type="number"]:hover, .ticket-name:hover { border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); }
select:focus-visible, input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }

.dashboard-fold > summary { transition: background .2s var(--ease-premium), border-color .2s var(--ease-premium), color .2s var(--ease-premium); }
.dashboard-fold > summary:hover { background: color-mix(in srgb, var(--surface) 82%, var(--accent) 18%); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.dashboard-fold[open] > summary { margin-bottom: .55rem; }
.insight-strip { border-radius: var(--r-lg); padding: .55rem .8rem; background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface-2)); }
.source-settings[open] { box-shadow: var(--shadow); }
.saved-tickets { gap: .55rem; }
.saved-ticket-item .btn:first-child { border-radius: var(--r-pill); }
.saved-ticket-item .btn:last-child { width: var(--control-height); padding-inline: .4rem; border-radius: 50%; }
th { text-transform: uppercase; letter-spacing: .065em; font-size: var(--fs-xs); }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 62%, transparent); }
.stat-label { text-transform: uppercase; letter-spacing: .07em; font-size: var(--fs-xs); font-weight: 650; }
.health-grid > div { padding: .9rem; border: 1px solid var(--border); border-radius: var(--r-md); background: color-mix(in srgb, var(--surface) 76%, transparent); }
.banner { border-radius: var(--r-lg); box-shadow: var(--shadow); }
.help-tip-trigger { min-width: 2rem; min-height: 2rem; transition: color .2s var(--ease-premium), background .2s var(--ease-premium), transform .2s var(--ease-premium); }
.help-tip-trigger:hover { transform: scale(1.06); }
@media (max-width: 720px) {
    #main-content { scroll-margin-top: 8rem; }
    .brand-icon { width: 2.25rem; height: 2.25rem; }
    .app-header nav a { border-radius: var(--r-md); }
    .page-head .toolbar { align-self: stretch; justify-content: flex-start; }
    .card#number-frequency { padding: clamp(.65rem, 2.5vw, 1rem); }
    .grid80, .ticket-selection, .board-controls .frequency-legend { width: 100%; }
    .grid80 { gap: .24rem; }
    .cell { width: 100%; border-radius: var(--r-sm); padding: .05rem 0; }
    .cell:hover { transform: none; }
    .app-footer { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
}

@media (pointer: coarse) {
    :root { --control-height: 2.75rem; }
    .source-settings > summary, .dashboard-fold > summary { min-height: var(--control-height); }
    select, input[type="number"], .ticket-name { font-size: var(--fs-md); }
}

/* Give the board a compact square grid and place its controls alongside it. */
@media (min-width: 721px) {
    #number-frequency {
        display: grid;
        grid-template-columns: minmax(0, 1fr) min(56%, clamp(20rem, 56svh, 27rem));
        align-items: start;
        gap: clamp(1rem, 3vw, 2rem);
    }
    .board-controls .card-head { flex-direction: column; align-items: flex-start; }
    .board-controls .frequency-legend { gap: .35rem; }
    .ticket-selection { margin-bottom: 0; }
    .grid80 { gap: .25rem; }
    .cell { border-radius: var(--r-sm); padding: .1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 380px) {
    .grid80 { gap: .12rem; }
    .cell-n { font-size: var(--fs-sm); line-height: 1.05; }
    .cell-c { font-size: .65rem; line-height: 1.05; }
}

/* Section titles are real headings inside their disclosure summaries. */
summary > h2 { display: inline; font-size: inherit; letter-spacing: inherit; font-weight: inherit; }
.filter-summary { font-weight: 500; color: var(--muted); }
.field-with-help { display: inline-flex; align-items: center; gap: .4rem; }
.ticket-backup { margin-top: .5rem; }
.ticket-notice .btn { margin-left: .5rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Matched numbers get a ring and heavier text as well as the fill colour. */
.ball.hit { font-weight: 800; box-shadow: inset 0 0 0 2px rgb(255 255 255 / .55); }

/* Trend chart colours follow the theme. */
.trend-actual { stroke: var(--chart-actual); }
.trend-expected { stroke: var(--chart-expected); }
.trend-band { stroke: var(--chart-expected); opacity: .8; }
.trend-compare { stroke: var(--chart-compare); }

/* Larger hit areas for touch without changing how the controls look. */
.help-tip-trigger { position: relative; }
@media (pointer: coarse) {
    .help-tip-trigger::after { content: ""; position: absolute; inset: -.55rem; }
    .toolbar input[type="checkbox"], .switch input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }
}
/* Header actions and the theme button */
.header-actions { display: flex; align-items: center; gap: .3rem; }
.theme-toggle { position: relative; }
.theme-trigger { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); cursor: pointer; transition: border-color .2s var(--ease-premium), background .2s var(--ease-premium); }
.theme-trigger:hover, .theme-trigger[aria-expanded="true"] { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.theme-trigger svg { width: 1.3rem; height: 1.3rem; }
.theme-backdrop { position: fixed; inset: 0; z-index: 11; }
.theme-panel { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 12; min-width: 10rem; padding: .35rem; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-raised); }
.theme-panel fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.theme-panel legend { padding: .35rem .6rem .25rem; font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.theme-option { display: flex; align-items: center; gap: .6rem; min-height: var(--control-height); padding: .2rem .6rem; border-radius: var(--r-sm); font-size: var(--fs-sm); cursor: pointer; }
.theme-option:hover { background: var(--surface-2); }
.theme-option input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
@media (max-width: 720px) {
    .app-header-inner { display: grid; grid-template-columns: 1fr auto; align-items: center; }
    .header-actions { display: contents; }
    .app-header .brand { grid-column: 1; grid-row: 1; }
    .app-header .theme-toggle { grid-column: 2; grid-row: 1; }
    .app-header nav { grid-column: 1 / -1; grid-row: 2; }
}
