/* ZizzoLabs shared styles.
   System font stack only — no web fonts — to keep first paint fast.
   Colors live in custom properties so widgets can reuse them; dark mode
   follows the OS via prefers-color-scheme (no JS, no stored preference). */

:root {
  --bg: #f2f6fc;
  --surface: #ffffff;
  --ink: #1b2740;
  --muted: #5a6a86;
  --line: #dfe7f2;
  --accent: #3f8cff;
  --accent-ink: #1d5fd6;      /* link/text-safe accent: >= 4.5:1 on --bg */
  --accent-soft: #e4eeff;
  --violet: #7b5bf2;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(27, 39, 64, 0.08);
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --surface: #182132;
    --ink: #e8eef8;
    --muted: #9fb0c9;
    --line: #253349;
    --accent: #4f95ff;
    --accent-ink: #8db9ff;
    --accent-soft: #1c2c49;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--accent-ink);
}

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

/* --- Header / footer ------------------------------------------------------ */

.site-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand svg {
  width: 30px;
  height: 30px;
  display: block;
}

.site-nav a {
  text-decoration: none;
  font-weight: 600;
  padding: 10px 8px; /* comfortable tap target */
}

.site-nav a:hover {
  text-decoration: underline;
}

.site-footer {
  max-width: var(--maxw);
  margin: 40px auto 0;
  padding: 24px 20px 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.site-footer a {
  color: inherit;
}

/* --- Page shell ----------------------------------------------------------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 20px 0;
}

.tagline {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 4px 0 26px;
  max-width: 44ch;
}

.prose {
  max-width: 62ch;
}

.prose h1 {
  letter-spacing: -0.02em;
}

/* --- Widget card grid ----------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}

.card-body {
  padding: 14px 16px 16px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(27, 39, 64, 0.14);
  }
}

.grid-note {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--muted);
}

/* --- Ad slots -------------------------------------------------------------
   Empty until real AdSense tags are pasted in; :empty keeps them from
   reserving space or drawing anything in the meantime. Inside the grid an
   ad spans the full row so it sits between card rows, never over them. */

.ad-slot {
  grid-column: 1 / -1;
}

.ad-slot:empty {
  display: none;
}

/* --- Buttons / inputs ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.ghost {
  background: transparent;
  color: var(--accent-ink);
  border: 2px solid var(--accent);
}

.text-input {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  width: 100%;
}

/* --- Widget chrome ----------------------------------------------------------
   Shared skeleton every widget page uses: HUD chips, play arena, start/end
   overlays, score form, leaderboard list. Widget-local CSS supplies the arena
   background and the game's own visuals. */

:root {
  --zz-overlay: rgba(242, 246, 252, 0.94);
}

@media (prefers-color-scheme: dark) {
  :root {
    --zz-overlay: rgba(14, 20, 32, 0.93);
  }
}

.widget-page h1 {
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.howto {
  color: var(--muted);
  margin: 0 0 14px;
  max-width: 60ch;
}

kbd {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  font-size: 0.85em;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.95rem;
  color: var(--muted);
}

.hud-chip strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}

/* touch-action: manipulation keeps taps snappy (no double-tap zoom) while
   still allowing page scroll from outside the arena. */
.arena {
  position: relative;
  height: min(62vh, 540px);
  min-height: 340px;
  background: var(--accent-soft); /* widgets normally override */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: var(--zz-overlay);
  overflow-y: auto;
}

.overlay[hidden] {
  display: none; /* the flex rule above would otherwise defeat [hidden] */
}

.overlay h2 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.overlay h2:focus {
  outline: none; /* focused programmatically for screen readers only */
}

.overlay p {
  margin: 0;
  color: var(--muted);
}

.final {
  font-size: 1.05rem;
}

.final strong {
  color: var(--ink);
  font-size: 1.3em;
}

.score-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, 100%);
  text-align: left;
}

.score-form label {
  font-size: 0.9rem;
  color: var(--muted);
}

.status-msg {
  min-height: 1.3em;
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.board-wrap {
  width: min(320px, 100%);
}

.board-wrap h3 {
  margin: 6px 0;
  font-size: 1rem;
}

.board {
  margin: 0;
  padding: 0 0 0 1.6em;
  text-align: left;
}

.board li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.board .board-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
