/* Lazy Games — shared design system. Every page links this; game-specific styles live inline in each game. */

:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #efebe2;
  --ink: #1d1b17;
  --muted: #6c675d;
  --line: #e2ddd1;
  --brand: #0f9d8f;
  --brand-strong: #0b7f74;
  --brand-ink: #ffffff;
  --accent: #ff5a3c;
  --accent-soft: #ffe3dc;
  --focus: #2f6fed;

  --tile-correct: #6aaa64;
  --tile-present: #c9b458;
  --tile-absent: #787c7e;
  --tile-empty: #d3d6da;
  --tile-ink: #ffffff;
  --key-bg: #dcd8ce;
  --key-ink: #1d1b17;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 6px 20px rgb(0 0 0 / .06);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / .18);

  --font-display: "Baloo 2", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;

  --topbar-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1c1e22;
  --surface-2: #26292e;
  --ink: #f1efe9;
  --muted: #a19d95;
  --line: #30333a;
  --brand: #2cc5b4;
  --brand-strong: #52d6c7;
  --brand-ink: #06201d;
  --accent: #ff7458;
  --accent-soft: #3a211b;
  --focus: #7aa7ff;
  --tile-correct: #538d4e;
  --tile-present: #b59f3b;
  --tile-absent: #3a3a3c;
  --tile-empty: #3a3a3c;
  --key-bg: #4a4d53;
  --key-ink: #f1efe9;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --surface: #1c1e22;
    --surface-2: #26292e;
    --ink: #f1efe9;
    --muted: #a19d95;
    --line: #30333a;
    --brand: #2cc5b4;
    --brand-strong: #52d6c7;
    --brand-ink: #06201d;
    --accent: #ff7458;
    --accent-soft: #3a211b;
    --focus: #7aa7ff;
    --tile-correct: #538d4e;
    --tile-present: #b59f3b;
    --tile-absent: #3a3a3c;
    --tile-empty: #3a3a3c;
    --key-bg: #4a4d53;
    --key-ink: #f1efe9;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
a { color: var(--brand-strong); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }

/* ---------- Top bar (shared by every game) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; text-align: center; white-space: nowrap; }
@media (max-width: 420px) { .topbar-title { font-size: 1.3rem; } }
.topbar-actions { display: flex; justify-content: flex-end; gap: 4px; }
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
  justify-self: start; border-radius: var(--radius-sm); padding: 4px 6px 4px 2px;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand .back { width: 20px; height: 20px; color: var(--muted); }
@media (max-width: 420px) { .brand-text { display: none; } }

.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink);
  font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:hover { background: var(--brand-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Inputs ---------- */
.field {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 1rem;
}
.field:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.label { display: block; font-weight: 600; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: .9rem; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Modal (<dialog class="modal">) ---------- */
.modal {
  width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgb(0 0 0 / .45); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .18s ease-out; }
.modal-body { padding: 24px 22px 22px; }
.modal-body:focus { outline: none; }
.modal-close { position: absolute; top: 10px; right: 10px; }
.modal h2 { font-size: 1.6rem; margin-bottom: 12px; padding-right: 36px; }
.modal h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
.modal p, .modal li { color: var(--ink); }
.modal ul { padding-left: 1.2em; margin: 8px 0; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Stats (shared by daily games) ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--muted); }
.dist { display: grid; gap: 4px; }
.dist-row { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; font-size: .9rem; font-weight: 700; }
.dist-bar { min-width: 26px; padding: 1px 8px; background: var(--tile-absent); color: #fff; text-align: right; border-radius: 4px; }
.dist-bar.hl { background: var(--tile-correct); }
.countdown { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%);
  z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow-lg);
  animation: toast-in .15s ease-out;
}
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Page shell ---------- */
.page { width: min(1080px, 100%); margin: 0 auto; padding: 24px 16px 48px; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 32px; }
.footer a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
