/* The family shell (option B): what every Slopday game shares. Each game
   loads this first, at /shared/css/family.css, then its own app.css for what
   is its own. Every name here starts with sd- so it can't collide with an
   app's own tokens or classes. A page sets its game on the root element,
   <html data-game="chart|map|pay|dot|hub">, and gets that game's color. */

/* ---------- fonts (self-hosted, Latin subset) ---------- */
@font-face { font-family: "Libre Franklin"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("/shared/fonts/libre-franklin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Zilla Slab"; font-style: normal; font-weight: 700; font-display: swap; src: url("/shared/fonts/zilla-slab-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- tokens ---------- */
:root {
  --sd-page: #fff; --sd-ink: #121212; --sd-ink-2: #5a5e64; --sd-ink-3: #6b7076;
  --sd-hair: #dcdcdc; --sd-line: #c7cbd0; --sd-soft: #f4f5f6; --sd-pressed: #33363b;
  --sd-link: #326891;
  --sd-yellow: #ffe135; --sd-yellow-soft: #fff3a6;
  --sd-hit: #5fd06e; --sd-miss: #d3d6da; --sd-wrong: #ff5a52;
  /* One color per game. Each is light enough for ink text on top (all > 10:1). */
  --sd-chart: #ffe135; --sd-chart-soft: #fff3a6;
  --sd-map: #8fc9ff; --sd-map-soft: #ddefff;
  --sd-pay: #c9b3ff; --sd-pay-soft: #eee6ff;
  --sd-dot: #ffb15e; --sd-dot-soft: #ffe6cc;
  --sd-game: var(--sd-yellow); --sd-game-soft: var(--sd-yellow-soft);
  --sd-slab: "Zilla Slab", Rockwell, Georgia, serif;
  --sd-text: "Libre Franklin", "Franklin Gothic Book", Arial, sans-serif;
  --sd-masthead-w: 1040px;
  --sd-ease-out: cubic-bezier(.16, 1, .3, 1);
}
[data-game="chart"] { --sd-game: var(--sd-chart); --sd-game-soft: var(--sd-chart-soft); }
[data-game="map"] { --sd-game: var(--sd-map); --sd-game-soft: var(--sd-map-soft); }
[data-game="pay"] { --sd-game: var(--sd-pay); --sd-game-soft: var(--sd-pay-soft); }
[data-game="dot"] { --sd-game: var(--sd-dot); --sd-game-soft: var(--sd-dot-soft); }

::selection { background: var(--sd-yellow); color: var(--sd-ink); }
.sd-masthead :where(p, h1, h2, h3), .sd-dialog :where(p, h2, h3), .sd-verdict :where(p, h1, h2), .sd-actions :where(p), .sd-more :where(p, h3) { margin: 0; }
:focus-visible { outline: 2px solid var(--sd-ink); outline-offset: 3px; }

/* ---------- masthead: wordmark with its game's word in a color tile, issue, three buttons ---------- */
.sd-masthead { position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top); background: var(--sd-page); border-bottom: 1px solid var(--sd-hair); }
.sd-masthead-in { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: var(--sd-masthead-w); height: 52px; margin: 0 auto; padding: 0 max(6px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.sd-brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
.sd-wordmark { font: 700 20px/1 var(--sd-slab); letter-spacing: -.005em; color: var(--sd-ink); text-decoration: none; }
.sd-wordmark b { font-weight: 700; background: var(--sd-game); border-radius: 4px; padding: 2px 5px 3px; margin-left: 1px; }
.sd-issue { font: 500 12px/1 var(--sd-text); color: var(--sd-ink-2); overflow: hidden; text-overflow: ellipsis; }
.sd-nav { display: flex; flex: none; }
.sd-nav button, .sd-nav a { display: grid; place-items: center; width: 38px; height: 44px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--sd-ink); cursor: pointer; }
.sd-nav button:hover, .sd-nav a:hover { background: var(--sd-soft); }
.sd-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 600px) { .sd-wordmark { font-size: 22px; } .sd-issue { font-size: 12.5px; } .sd-nav button, .sd-nav a { width: 42px; } }
/* The date drops out of the issue line on the narrowest phones; the number stays. */
@media (max-width: 370px) { .sd-issue-date { display: none; } }

/* ---------- the tile row: progress while playing, the result grid when done ---------- */
.sd-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.sd-tiles { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.sd-tiles li { display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--sd-line); border-radius: 4px; color: var(--sd-ink-3); font: 700 13px/1 var(--sd-text); font-variant-numeric: tabular-nums; }
.sd-tiles li.is-now { background: var(--sd-game); border-color: var(--sd-ink); color: var(--sd-ink); }
.sd-tiles li.is-hit, .sd-tiles li.is-star { background: var(--sd-hit); border-color: var(--sd-hit); color: var(--sd-ink); }
.sd-tiles li.is-miss { background: var(--sd-miss); border-color: var(--sd-miss); color: var(--sd-ink); }
.sd-tiles li.is-wrong { background: var(--sd-wrong); border-color: var(--sd-wrong); color: var(--sd-ink); }
.sd-tiles li.is-closer { border-style: dashed; }
.sd-tiles li.is-unused { border-color: var(--sd-hair); color: transparent; }
.sd-tiles svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sd-tiles svg.sd-fill { fill: currentColor; stroke: none; }
.sd-status-label { font: 800 11.5px/1 var(--sd-text); letter-spacing: .06em; text-transform: uppercase; color: var(--sd-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Six tiles and a label need about 320px; the narrowest phones get smaller tiles. */
@media (max-width: 359px) { .sd-tiles { gap: 4px; } .sd-tiles li { width: 26px; height: 26px; } }

/* ---------- buttons ---------- */
.sd-pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--sd-ink); color: #fff; font: 700 16px/1 var(--sd-text); text-decoration: none; cursor: pointer; transition: background-color .15s; }
.sd-pill:hover { background: var(--sd-pressed); }
.sd-pill.is-wide { display: flex; width: 100%; }
.sd-pill.is-ghost { background: #fff; color: var(--sd-ink); box-shadow: inset 0 0 0 1.5px var(--sd-ink); }
.sd-pill.is-ghost:hover { background: var(--sd-game-soft); }
.sd-pill.is-small { height: 36px; padding: 0 16px; font-size: 14px; }
.sd-pill:disabled, .sd-pill.is-off { background: #e2e4e7; color: #6b7076; box-shadow: none; cursor: default; }
.sd-pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the guess bar: a field and its button in a frame of the game's color ---------- */
.sd-guessbar { display: flex; gap: 6px; padding: 5px; border-radius: 10px; background: var(--sd-game); }
.sd-guessbar input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1.5px solid var(--sd-ink); border-radius: 6px; background: #fff; color: var(--sd-ink); font: 400 16px var(--sd-text); }
.sd-guessbar input::placeholder { color: var(--sd-ink-3); }
.sd-guessbar input:focus-visible { outline-offset: 1px; }
.sd-guessbar button { height: 44px; padding: 0 18px; border: 0; border-radius: 6px; background: var(--sd-ink); color: #fff; font: 700 15px/1 var(--sd-text); cursor: pointer; }
.sd-guessbar button:hover { background: var(--sd-pressed); }
.sd-guessbar button:disabled { background: #6b7076; cursor: default; }

/* ---------- chips ---------- */
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.sd-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: var(--sd-game-soft); color: var(--sd-ink); font: 600 13px/1 var(--sd-text); white-space: nowrap; }
.sd-chip.is-next { background: none; border: 1.5px dashed var(--sd-line); color: var(--sd-ink-2); font-weight: 500; }
.sd-chip.is-answer { background: var(--sd-game); }

/* ---------- dialogs: how to play, stats, past days ---------- */
/* The browser's own max-width for modals is narrower than ours on a phone, so it's set here too. */
dialog.sd-dialog { width: min(420px, calc(100% - 28px)); max-width: calc(100% - 28px); max-height: calc(100% - 40px); margin: auto; padding: 0; border: 0; border-radius: 12px; background: #fff; color: var(--sd-ink); box-shadow: 0 2px 6px rgba(18, 18, 18, .08), 0 16px 40px rgba(18, 18, 18, .16); overflow: auto; }
/* How to play opens by itself on a first visit with focus on the dialog itself
   (each game calls dialog.focus(); the dialog has tabindex="-1"), so no ring
   shows before anyone has touched the page. Tab still reaches its buttons. */
dialog.sd-dialog:focus-visible { outline: none; }
dialog.sd-dialog::backdrop { background: rgba(255, 255, 255, .76); }
.sd-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 12px 18px 20px; background: var(--sd-game); }
.sd-dialog-head h2 { margin: 0; font: 700 30px/1 var(--sd-slab); letter-spacing: -.01em; }
.sd-dialog-head button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--sd-ink); cursor: pointer; }
.sd-dialog-head button:hover { background: rgba(255, 255, 255, .45); }
.sd-dialog-head svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sd-dialog-body { padding: 4px 20px 0; }
.sd-dialog-foot { padding: 12px 20px 20px; }
.sd-dialog .sd-dialog-foot p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.45; color: var(--sd-ink-2); }
.sd-steps { margin: 0; padding: 0; list-style: none; }
.sd-steps li { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--sd-hair); font: 400 15px/1.42 var(--sd-text); }
.sd-steps li > b:first-child { flex: none; width: 14px; font: 700 19px/1.1 var(--sd-slab); }
.sd-steps strong { font-weight: 700; }
.sd-steps p { margin: 0; }

/* Stats: three numbers, then how your results spread. */
.sd-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 6px; text-align: center; }
.sd-numbers b { display: block; font: 700 34px/1 var(--sd-slab); font-variant-numeric: tabular-nums; }
.sd-numbers span { display: block; margin-top: 6px; font: 800 10.5px/1.2 var(--sd-text); letter-spacing: .06em; text-transform: uppercase; color: var(--sd-ink-2); }
.sd-dist { margin: 16px 0 4px; }
.sd-dist h3 { margin: 0 0 8px; font: 800 11px/1 var(--sd-text); letter-spacing: .06em; text-transform: uppercase; color: var(--sd-ink-2); }
.sd-dist ol { margin: 0; padding: 0; list-style: none; }
.sd-dist li { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; margin: 4px 0; font: 700 13px/1 var(--sd-text); font-variant-numeric: tabular-nums; }
.sd-dist li i { display: block; min-width: 44px; width: var(--w, 0%); height: 22px; padding: 0 7px; border-radius: 3px; background: var(--sd-miss); font: 700 12px/22px var(--sd-text); font-style: normal; text-align: right; box-sizing: border-box; }
.sd-dist li.is-you i { background: var(--sd-game); }
/* How everyone did, on the finished screen after the game's own details. */
.sd-everyone { margin-top: 24px; }

/* Past days: a grid of tiles, today's in the game's color. */
.sd-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 14px 0 4px; padding: 0; list-style: none; }
.sd-days a, .sd-days span { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px 9px; border: 1.5px solid var(--sd-line); border-radius: 6px; color: var(--sd-ink); text-decoration: none; font-variant-numeric: tabular-nums; }
.sd-days a:hover { border-color: var(--sd-ink); }
.sd-days b { font: 700 18px/1 var(--sd-slab); }
.sd-days small { font: 600 11.5px/1 var(--sd-text); color: var(--sd-ink-2); }
.sd-days em { font: 800 11px/1 var(--sd-text); font-style: normal; letter-spacing: .04em; }
.sd-days .is-today { background: var(--sd-game); border-color: var(--sd-ink); }
.sd-days .is-done { border-color: var(--sd-ink); }
.sd-note { margin: 12px 0 0; font-size: 13.5px; color: var(--sd-ink-2); }

/* ---------- the finished screen: verdict panel, Share, the countdown ---------- */
.sd-verdict { padding: 24px 16px 22px; background: var(--sd-game); color: var(--sd-ink); }
.sd-answer { margin: 0; font: 700 34px/1.08 var(--sd-slab); letter-spacing: -.01em; }
.sd-sub { margin: 4px 0 0; font-size: 14.5px; color: #2b2d31; }
.sd-score { display: flex; align-items: baseline; gap: 12px; margin: 16px 0 0; }
.sd-score b { font: 700 56px/.9 var(--sd-slab); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sd-score span { font: 600 15px/1.3 var(--sd-text); }
.sd-score small { display: block; font-weight: 400; font-size: 14px; color: #2b2d31; }
.sd-actions { padding: 18px 16px 0; }
.sd-next { margin: 12px 0 0; text-align: center; font-size: 14px; color: var(--sd-ink-2); font-variant-numeric: tabular-nums; }
.sd-next a { color: var(--sd-link); text-decoration: underline; text-underline-offset: 3px; }
.sd-share-note { margin: 8px 0 0; font-size: 13.5px; color: var(--sd-ink-2); }
.sd-share-note:empty { display: none; }

/* ---------- More games: the other three, and the hub ---------- */
.sd-more { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--sd-hair); }
.sd-more h3 { margin: 0 0 6px; font: 700 20px/1.1 var(--sd-slab); }
.sd-more ul { margin: 0; padding: 0; list-style: none; }
.sd-more li a { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--sd-hair); color: var(--sd-ink); text-decoration: none; }
.sd-more li:last-child a { border-bottom: 0; }
.sd-more li a:hover .sd-more-name { text-decoration: underline; text-underline-offset: 3px; }
.sd-more li div { flex: 1; }
.sd-more-name { font: 700 18px/1.15 var(--sd-slab); }
.sd-more-name b { border-radius: 4px; padding: 1px 5px 2px; }
.sd-more-tag { margin-top: 1px; font-size: 13.5px; color: var(--sd-ink-2); }
.sd-more svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sd-more-hub { display: inline-block; margin-top: 10px; font: 600 14px/1.4 var(--sd-text); color: var(--sd-link); text-underline-offset: 3px; }
[data-swatch="chart"] { background: var(--sd-chart); }
[data-swatch="map"] { background: var(--sd-map); }
[data-swatch="pay"] { background: var(--sd-pay); }
[data-swatch="dot"] { background: var(--sd-dot); }

@media (prefers-reduced-motion: reduce) {
  .sd-pill { transition: none; }
}
