/* Daily Games shared base styles. Each game may override --accent. */
:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #222631;
  --border: #2e3340;
  --text: #eef0f4;
  --muted: #9aa1b1;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --good: #3ecf8e;
  --ok: #f5c451;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef0f5;
    --border: #dde1ea;
    --text: #151821;
    --muted: #5d6475;
    --shadow: 0 10px 30px rgba(20, 24, 40, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }

.dg-main { max-width: 560px; margin: 0 auto; padding: 12px 16px 48px; }
.dg-muted { color: var(--muted); font-size: 14px; }

/* header */
.dg-header {
  display: flex; align-items: center; gap: 8px;
  max-width: 560px; margin: 0 auto; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.dg-title { flex: 1; text-align: center; min-width: 0; }
.dg-title h1 { margin: 0; font-size: 22px; letter-spacing: .5px; font-weight: 800; }
.dg-sub { font-size: 12px; color: var(--muted); }
.dg-actions { display: flex; gap: 6px; }
.dg-icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.dg-icon-btn:hover { background: var(--surface-2); }
.dg-banner {
  max-width: 560px; margin: 8px auto 0; padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center;
}

/* buttons */
.dg-btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 16px;
  transition: transform .06s ease, background .15s ease, opacity .15s;
}
.dg-btn:hover { background: var(--surface-2); }
.dg-btn:active { transform: scale(.97); }
.dg-btn:disabled { opacity: .45; cursor: default; transform: none; }
.dg-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dg-btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.dg-wide { width: 100%; margin-top: 14px; }

.dg-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* modal */
.dg-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50; opacity: 0; transition: opacity .15s;
}
.dg-backdrop.show { opacity: 1; }
.dg-modal {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; padding: 22px 20px 20px; box-shadow: var(--shadow);
}
.dg-modal h2 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.dg-modal h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.dg-modal-x {
  position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted);
}
.dg-modal-body p { margin: 8px 0; }
.dg-modal-body ul { padding-left: 20px; margin: 8px 0; }
.dg-modal-body li { margin: 4px 0; }

.dg-result { text-align: center; }
.dg-result-head { font-size: 28px; font-weight: 800; margin: 4px 0; }
.dg-result-detail { color: var(--muted); margin-bottom: 8px; }
.dg-share-preview {
  text-align: left; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; white-space: pre-wrap;
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; margin: 10px 0 0;
}

.dg-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 16px; text-align: center; }
.dg-stat-n { font-size: 26px; font-weight: 800; }
.dg-stat-l { font-size: 11px; color: var(--muted); }

.dg-dist-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.dg-dist-k { width: 64px; text-align: right; color: var(--muted); flex: none; }
.dg-dist-bar {
  background: var(--surface-2); color: var(--text); padding: 2px 6px; border-radius: 4px; text-align: right; font-weight: 700; min-width: 22px;
}
.dg-dist-bar.hit { background: var(--accent); color: var(--accent-ink); }

.dg-next { text-align: center; margin-top: 16px; color: var(--muted); }
.dg-next strong { color: var(--text); font-variant-numeric: tabular-nums; }

.dg-archive-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dg-archive-day {
  display: block; text-align: center; padding: 8px 0; border-radius: 8px; background: var(--surface-2);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px;
}
.dg-archive-day.done { background: color-mix(in srgb, var(--good) 30%, var(--surface-2)); }
.dg-archive-day.current { outline: 2px solid var(--accent); }

/* toast */
.dg-toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw; text-align: center;
}
.dg-toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes dg-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.dg-shake { animation: dg-shake .35s; }
@keyframes dg-pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.dg-pop { animation: dg-pop .25s ease-out; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Accent colours (e.g. yellow) can be unreadable as text in light mode; keep banner links neutral. */
.dg-banner a { color: var(--text); font-weight: 700; }

.dg-icon-spacer { width: 38px; height: 38px; flex: none; }
.dg-more-game {
  display: flex; gap: 12px; align-items: center; padding: 10px; margin: 6px 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.dg-more-game:hover { filter: brightness(1.05); }
.dg-more-icon { font-size: 26px; flex: none; }
.dg-more-body { display: flex; flex-direction: column; min-width: 0; }
.dg-more-body .dg-muted { font-size: 13px; }

/* community distribution ("Today's players") */
.dg-community { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--border); }
.dg-community-line { margin: 4px 0 10px; font-size: 16px; text-align: center; }
.dg-community-line strong { font-size: 20px; color: var(--accent); }
.dg-community-foot { margin: 8px 0 0; font-size: 12px; text-align: center; }
.dg-cchart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 18px; }
.dg-ccol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.dg-cbar-wrap { position: relative; flex: 1; width: 100%; display: flex; align-items: flex-end; }
.dg-cbar { position: relative; width: 100%; background: var(--surface-2); border-radius: 4px 4px 0 0; transition: height .4s ease; }
.dg-ccol.you .dg-cbar { background: var(--accent); }
.dg-cyou { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100% + 2px); font-size: 11px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.dg-clabel { font-size: 10px; color: var(--muted); margin-top: 3px; white-space: nowrap; }

/* Friends, challenges, unlimited. Colours come from each game's --accent. */
.dg-label { display: block; margin: 10px 0 4px; font-size: 12px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.dg-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.dg-code { margin: 8px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: 3px; text-align: center; }
.dg-tabs { display: flex; gap: 6px; margin: 8px 0; }
.dg-tab { flex: 1; margin-top: 0; padding: 8px 10px; }
.dg-tab.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dg-board { display: flex; flex-direction: column; gap: 4px; }
.dg-board-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.dg-board-row.you { background: var(--surface-2); }
.dg-board-rank { width: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.dg-board-nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-board-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.dg-h2h, .dg-challenge, .dg-unlimited { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--border); }
.dg-share { margin-top: 12px; }
.dg-share-split {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px 10px; align-items: stretch;
}
.dg-share > .dg-btn { margin-top: 0; width: 100%; }
.dg-share > .dg-btn-primary { font-size: 17px; min-height: 50px; }
.dg-share-split > .dg-btn { min-height: 50px; }
.dg-share-help, .dg-name { grid-column: 1 / -1; margin: 2px 0 0; font-size: 13px; line-height: 1.4; text-align: center; }
.dg-name .dg-linkbtn { font-size: 13px; font-weight: 700; }
.dg-name-edit { display: flex; gap: 8px; align-items: center; text-align: left; }
.dg-name-edit .dg-input { flex: 1; width: auto; min-width: 0; margin: 0; }
.dg-name-edit .dg-btn { margin: 0; padding: 10px 12px; min-height: 44px; width: auto; font-size: 15px; }
.dg-h2h-line { text-align: center; font-size: 18px; font-weight: 800; margin: 4px 0 8px; }
.dg-h2h-scores { display: flex; justify-content: center; gap: 28px; text-align: center; }
.dg-h2h-score { font-size: 28px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.dg-linkbtn { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }
.dg-friends .dg-btn { margin-top: 8px; }

/* Crawlable how-to under the game. Class names match Guess the Year's guide.
   Rules here are the shared floor; yearly/guide.css still refines that page. */
.yr-guide {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 72px;
  color: var(--text);
}
.yr-guide h2 { font-size: 22px; line-height: 1.25; margin: 28px 0 8px; }
.yr-guide h3 { font-size: 17px; line-height: 1.3; margin: 20px 0 6px; }
.yr-guide p, .yr-guide li { font-size: 16px; line-height: 1.55; }
.yr-guide .lede { font-size: 18px; line-height: 1.45; }
.yr-guide a { font-weight: 650; }
.yr-guide a:focus-visible, .yr-foot a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.yr-foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
}
.yr-foot a { font-weight: 650; }

/* ---------- "Try other games" footer (core.js mountOtherGames) ---------- */
.dg-others { max-width: 560px; margin: 8px auto 0; padding: 18px 16px calc(32px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.dg-others h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.dg-others-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dg-others-game {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
  transition: transform .12s ease, border-color .12s ease;
}
.dg-others-game:hover { border-color: var(--accent); transform: translateY(-1px); }
.dg-others-game:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.dg-others-icon { font-size: 24px; flex: none; line-height: 1; }
.dg-others-body { display: flex; flex-direction: column; min-width: 0; }
.dg-others-body strong { font-size: 14.5px; line-height: 1.25; }
.dg-others-body .dg-muted { font-size: 12px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dg-others-all { display: block; margin-top: 12px; text-align: center; font-weight: 700; color: var(--text); }
@media (max-width: 340px) { .dg-others-grid { grid-template-columns: 1fr; } }
