/* Bowling. Lane-blue, so it sits apart from Memos' amber and the green of
   the landlording apps on the home screen. Layout borrowed from Memos. */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #1d2430;
  --ink-soft: #566173;
  --ink-faint: #8a94a5;
  --line: #dde3ec;
  --accent: #1d4f91;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecf8;
  --danger: #b3261e;
  --up: #2e7d4f;
  --down: #b3261e;
  --hi: #a15c00;
  /* Chart: blue nights, orange season line, grey single games. */
  --viz-night: #2f6fbf;
  --viz-season: #d9822b;
  --viz-game: #9aa5b5;
  --viz-grid: #e6eaf0;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1d232c;
    --ink: #e6ebf2;
    --ink-soft: #aab4c3;
    --ink-faint: #7a8596;
    --line: #2f3742;
    --accent: #6aa5ee;
    --accent-ink: #10141a;
    --accent-soft: #22324a;
    --danger: #ff8a80;
    --up: #7bd29c;
    --down: #ff8a80;
    --hi: #f0b860;
    --viz-night: #6aa5ee;
    --viz-season: #f0a35a;
    --viz-game: #5f6a7a;
    --viz-grid: #2a313b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--font); }
a { color: var(--accent); }
[hidden] { display: none !important; }
h2 { font-size: 19px; margin: 0 0 10px; }

/* --- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 21px; font-weight: 700;
  color: var(--ink); text-decoration: none; }
.brand img { border-radius: 6px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 10px; border-radius: 999px; text-decoration: none; color: var(--ink-soft); font-size: 15px; font-weight: 600; }
.tabs a.on { background: var(--accent-soft); color: var(--ink); }

.page { max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.page-title { font-size: 24px; margin: 4px 0 12px; }
.back { text-decoration: none; font-size: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 14px; }

/* --- Buttons & inputs --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.linkish.danger { color: var(--danger); }
form.inline { display: inline; }

.text-input, .score-input {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px;
}
.text-input:focus, .score-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 4px; }
.optional { color: var(--ink-faint); }
.wide-input { width: 100%; }

.entry { display: grid; gap: 12px; }
.date-row .text-input { width: 100%; max-width: 240px; }
.games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.score-input { width: 100%; font-size: 28px; font-weight: 700; text-align: center; padding: 8px 4px; min-height: 60px; }
.live-total { margin: 0; min-height: 1.5em; color: var(--ink-soft); font-size: 16px; }
.live-total.bad, .error-line { color: var(--danger); margin: 0; }
.done-line { margin: 0 0 8px; }
.other-date summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.other-date[open] summary { margin-bottom: 12px; }
.delete-row { text-align: center; margin: 18px 0; }

/* --- Numbers ------------------------------------------------------------- */
.result { border-color: var(--accent); background: var(--accent-soft); }
.result-head { margin: 0 0 6px; font-weight: 700; }
.result-games { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; font-size: 22px; font-weight: 700; }
.result-series { font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.result-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.result-pair > div, .stat { display: flex; flex-direction: column; }
.stat-n { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 13px; color: var(--ink-soft); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat .stat-n { font-size: 22px; }
.stat.big .stat-n { font-size: 30px; color: var(--accent); }
.stat-foot { margin: 10px 0 0; font-size: 14px; color: var(--ink-soft); }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.g.hi { color: var(--hi); }
.hint, .empty { color: var(--ink-soft); }
.empty { text-align: center; padding: 30px 10px; }

/* --- Lists of nights ------------------------------------------------------ */
.list-head { margin: 20px 2px 8px; }
.night-list { list-style: none; margin: 0; padding: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.night-list li + li { border-top: 1px solid var(--line); }
.night-row { display: grid; grid-template-columns: 1fr auto 56px; align-items: baseline; gap: 4px 12px;
  padding: 11px 14px; color: inherit; text-decoration: none; font-variant-numeric: tabular-nums; }
.night-row:hover, .night-row:focus-visible { background: var(--accent-soft); }
.night-date { color: var(--ink-soft); font-size: 15px; }
.night-games { display: flex; gap: 12px; }
.night-games .g { min-width: 2.2em; text-align: right; }
.night-avg { text-align: right; font-weight: 700; }
.night-note { grid-column: 1 / -1; font-size: 13px; color: var(--ink-faint); font-style: italic; }

/* --- Seasons table ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.season-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.season-table th, .season-table td { padding: 10px 10px; text-align: right; white-space: nowrap; }
.season-table th:first-child, .season-table td:first-child { text-align: left; }
.season-table th { font-size: 13px; color: var(--ink-soft); font-weight: 600; border-bottom: 1px solid var(--line); }
.season-table tbody tr + tr td { border-top: 1px solid var(--line); }
.season-table tfoot td { border-top: 2px solid var(--line); font-weight: 600; }
.season-table .strong { font-weight: 800; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 4px 0 12px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent); }

.page-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; font-size: 15px; color: var(--ink-soft); }

/* --- Charts ----------------------------------------------------------------- */
.viz-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.viz-head h2 { margin: 0; }
.range { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font: inherit; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 4px; font-size: 13px; color: var(--ink-soft); }
.legend span, .games-toggle { display: inline-flex; align-items: center; gap: 6px; }
.games-toggle { cursor: pointer; }
.key { display: inline-block; }
.key.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--viz-night); }
.key.bar { width: 18px; height: 4px; border-radius: 2px; background: var(--viz-season); }
.key.game { width: 6px; height: 6px; border-radius: 50%; background: var(--viz-game); }
.plot { width: 100%; touch-action: pan-y; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.tip { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); min-height: 2.6em; }
.tip strong { color: var(--ink); }
.muted { color: var(--ink-faint); }

.grid { stroke: var(--viz-grid); stroke-width: 1; }
.tick { stroke: var(--ink-faint); stroke-width: 1; }
.axis { fill: var(--ink-faint); font-size: 11px; font-family: var(--font); }
.night-line { fill: none; stroke: var(--viz-night); stroke-width: 1.5; stroke-opacity: .45; stroke-linejoin: round; }
.night-dot { fill: var(--viz-night); stroke: var(--surface); stroke-width: 2; }
.night-dot.on { r: 6.5; }
.game-dot { fill: var(--viz-game); fill-opacity: .7; }
.season-line { stroke: var(--viz-season); stroke-width: 4; stroke-linecap: round; }
.season-label { fill: var(--ink); font-size: 12px; font-weight: 700; font-family: var(--font);
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.season-bar { fill: var(--viz-night); }
.season-bar.on { fill: var(--accent); }
.bar-value { fill: var(--ink); font-size: 13px; font-weight: 700; font-family: var(--font); }
.cross { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.hit { fill: transparent; cursor: crosshair; }

/* --- Sign-in ------------------------------------------------------------- */
.login { max-width: 360px; margin: 0 auto; padding: 60px 20px; text-align: center; }
.login-icon { border-radius: 16px; }
.login h1 { margin: 12px 0 24px; }
.login form { text-align: left; display: grid; gap: 10px; }
.trust-row { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-soft); }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .page { padding: 10px 12px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tabs a { padding: 5px 8px; font-size: 14px; }
  .night-games { gap: 8px; }
}
