/* Namedle shared visual system. Page CSS owns game layout, never these primitives. */
:root {
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text-caption: 12px; --text-control: 13px; --text-body: 14px; --text-title: 20px;
  --weight-regular: 400; --weight-medium: 500; --weight-emphasis: 600; --weight-heading: 700;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px;
  --radius-small: 6px; --radius-control: 8px; --radius-surface: 16px; --radius-pill: 999px;
  --control-height: 40px; --icon-size: 16px; --icon-stroke: 1.75;
  --motion-press: 100ms; --motion-feedback: 150ms;

  /* Architectural warm neutrals, crisp 1px hairlines, subtle natural elevation, and one cobalt
     accent for closeness and data. Green/red reserved strictly for right/wrong. Keep decoration restrained. */
  --bg: #f7f7f5; --surface: #ffffff; --fill: #efefec;
  --ink: #18181b; --ink-2: #52525b; --muted: #71717a;
  --faint: #e4e4e0; --line: #d1d1cb;
  --accent: #175cd3; --accent-soft: #eff6ff; --on-accent: #ffffff;
  --success: #15803d; --error: #b42318;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .04), 0 2px 6px rgb(0 0 0 / .02);
  --shadow-md: 0 2px 4px -1px rgb(0 0 0 / .05), 0 8px 20px -4px rgb(0 0 0 / .04);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110; --surface: #1a1a18; --fill: #242421;
    --ink: #f4f4f2; --ink-2: #c8c7c1; --muted: #94938d;
    --faint: #2b2b28; --line: #3d3d38;
    --accent: #6da8ff; --accent-soft: #17253b; --on-accent: #0d1b2e;
    --success: #7cc49a; --error: #e8857a;
    --shadow-sm: 0 1px 3px rgb(0 0 0 / .35);
    --shadow-md: 0 6px 20px -2px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}


#top-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; margin-bottom: 16px;
}
header { display: contents; }
.brand { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; column-gap: 8px; row-gap: 1px; flex-shrink: 0; order: 1; }
/* The mascot spans the title and the date: its feet stand on the date's baseline and its body reaches
   the top of the N. It sits in the date's row, aligned on that baseline, so the feet stay put in any font;
   its 51px box has 10px empty under the feet. The negative margin keeps it from making the header grow. */
.brand-mark { grid-row: 2; display: block; margin-top: -39px; transform: translateY(9.99px); }
.brand > :not(.brand-mark) { grid-column: 2; }
h1 { margin: 0; font-size: var(--text-title); line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap; }
#date {
  margin: 0; min-height: 16px; color: var(--muted); font-size: 12.5px; line-height: 1.25; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer;
  transition: color .15s;
}
#date:hover { color: var(--ink); }
.icons { display: flex; align-items: center; gap: 5px; flex-shrink: 0; order: 2; margin-left: auto; }
.icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink-2); font-size: 15px; font-weight: 600;
  transition: background-color .15s, color .15s, transform .1s;
}
.icon:hover { background: var(--fill); color: var(--ink); }
.icon:active { background: var(--faint); transform: scale(.95); }


/* The game switcher is a plain tab row on the page's hairline: the current game is marked by an ink
   bar on that line, not by a filled pill, so the switcher stays quieter than the board below it. */
#games-nav {
  order: 3; width: 100%;
  display: flex; align-items: stretch; gap: 0;
  border-bottom: 1px solid var(--faint);
}
#games-nav a {
  flex: 1 1 auto;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 40px; padding: 0 8px;
  color: var(--ink-2); font-size: var(--text-control); font-weight: 600; letter-spacing: -0.01em;
  text-decoration: none; white-space: nowrap;
  transition: color .18s var(--ease-out);
}
#games-nav .nav-fg {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 5px;
}
@media (min-width: 860px) {
  /* One row: the tabs sit centered on the header's hairline. */
  #top-bar {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    border-bottom: 1px solid var(--faint); margin-bottom: 20px;
  }
  #games-nav {
    order: 2; display: inline-flex; width: auto; justify-self: center; align-self: stretch;
    border-bottom: 0; margin-bottom: -1px;
  }
  #games-nav a { flex: 0 0 auto; min-height: 56px; padding: 0 14px; }
  .icons {
    order: 3; justify-self: end; margin-left: 0;
  }
}
#games-nav a:hover { color: var(--ink); }
#games-nav a[aria-current="page"] {
  color: var(--ink);
}
#games-nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--ink);
  z-index: 0;
}
#games-nav a > * { position: relative; z-index: 1; }
#games-nav .nav-st {
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 1px 5px; border-radius: var(--radius-pill); background: rgb(0 0 0 / .05); color: var(--muted);
}
@media (prefers-color-scheme: dark) { #games-nav .nav-st { background: rgb(255 255 255 / .08); } }
#games-nav .nav-st.won { color: var(--success); background: rgb(21 128 61 / .1); }
#games-nav .nav-st.lost { color: var(--error); background: rgb(180 35 24 / .1); }
#games-nav .nav-st.score { color: var(--ink); }
/* On phones a played game's pill has two centered lines, the game and its status (1/10, ✓). Every
   pill keeps the same height and progress never moves the page. Desktop keeps the badge inline. */
@media (max-width: 859px) {
  #games-nav a { min-height: 44px; }
  #games-nav .nav-fg { flex-direction: column; gap: 2px; }
  #games-nav .nav-st, #games-nav .nav-st.won, #games-nav .nav-st.lost {
    font-size: 11px; line-height: 14px; padding: 0; background: none;
  }
}
@media (max-width: 400px) {
  #games-nav a { font-size: 12px; padding: 0 5px; }
}


button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

dialog {
  width: min(400px, calc(100vw - 32px)); max-height: 82vh; padding: 22px;
  border: 1px solid var(--faint); border-radius: var(--radius-surface); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-md);
}

dialog::backdrop { background: rgb(0 0 0 / .4); backdrop-filter: blur(2px); }

/* Dialogs ease in and out instead of popping: a short fade and rise (the backdrop fades with it).
   Browsers without @starting-style or allow-discrete just show and hide them as before. */
dialog {
  opacity: 0; transform: translateY(8px) scale(.985);
  transition: opacity .18s ease-out, transform .2s cubic-bezier(.2, .8, .2, 1), overlay .2s allow-discrete, display .2s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: translateY(8px) scale(.985); } }
dialog::backdrop { opacity: 0; transition: opacity .2s ease-out, overlay .2s allow-discrete, display .2s allow-discrete; }
dialog[open]::backdrop { opacity: 1; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog, dialog::backdrop { transition: none; } }

.dlg-head { display: flex; align-items: center; margin-bottom: 16px; }

.dlg-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-bottom: 22px; }

.totals div { padding: 10px 4px; border-radius: 12px; background: var(--fill); }

.totals b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.totals span { font-size: 11.5px; font-weight: 500; color: var(--muted); }

.dist h3 { margin: 0 0 10px; font-size: var(--text-control); font-weight: 600; color: var(--ink-2); }

.dist li { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 6px; margin-bottom: 5px; font-size: var(--text-control); font-variant-numeric: tabular-nums; }

.dist .fill { min-width: 24px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--fill); text-align: right; line-height: 22px; font-size: 12px; font-weight: 600; }

.dist .fill.today { background: var(--accent); color: var(--on-accent); }

[hidden] { display: none !important; }


.ui-button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-height); padding: 0 var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius-control);
  background: var(--fill); color: var(--ink); font-size: var(--text-control);
  font-weight: var(--weight-medium); line-height: 20px; text-decoration: none; white-space: nowrap;
  transition: background-color var(--motion-feedback), border-color var(--motion-feedback), transform var(--motion-press);
}
.ui-button:hover, .ui-button.confirm { background: var(--surface); border-color: var(--muted); }
.ui-button:active { transform: scale(.98); }
.ui-button:disabled { cursor: default; opacity: .6; }
.ui-button--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: var(--weight-emphasis); }
.ui-button--primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(.95); }
.ui-button--quiet { color: var(--ink-2); }
.ui-icon { width: var(--icon-size); height: var(--icon-size); display: block; flex: none; fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.ui-icon--down { transform: rotate(90deg); }
.ui-icon--up { transform: rotate(-90deg); }
.ui-surface { background: var(--surface); border: 1px solid var(--faint); border-radius: var(--radius-surface); }
.ui-clue { padding: 10px var(--space-3); border-radius: var(--radius-control); background: var(--accent-soft); color: var(--ink); font-size: var(--text-control); line-height: 18px; }
@media (pointer: coarse) { :root { --control-height: 44px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.ui-button--suggested { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ui-button--suggested:hover { background: var(--accent-soft); border-color: var(--accent); }
.next-row .ui-button { padding-inline: var(--space-3); }

.dlg-head .icon { margin-left: auto; }
