/* MiJigsaw: "the cozy puzzle club". Warm ivory paper, forest-green felt for
   structure, wood for the play area, amber only for "today". */
:root {
  --bg: #f7f5ef;
  --surface: #fffefa;
  --surface-2: #efeee6;
  --ink: #252b25;
  --muted: #646b60;
  --line: #e5e2d8;
  --felt: #244d3b;          /* header and footer */
  --felt-ink: #f7f5ef;
  --accent: #356b50;        /* links */
  --btn: #244d3b;
  --btn-hover: #193d2e;
  --btn-ink: #ffffff;
  --today: #d99a45;         /* fills and outlines only: too light for text */
  --today-soft: #f5e8d2;
  --today-ink: #8a5a12;     /* amber text, on --today-soft or --surface */
  --wood: #e8d9be;         /* frame around the game table */
  --wood-edge: #d3c1a2;
  --table: #2f5d47;         /* felt the pieces lie on, green in both themes */
  --table-ink: #f7f5ef;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-card: 14px;
  --radius-tile: 16px;
  --radius-hero: 20px;
  --shadow: 0 2px 8px rgb(35 45 35 / 0.05);
  --shadow-md: 0 8px 24px rgb(35 45 35 / 0.08);
  --shadow-lg: 0 18px 48px rgb(35 45 35 / 0.12);
  --shadow-hover: 0 14px 32px rgb(35 45 35 / 0.14);
  --f-display: "Bricolage Grotesque", system-ui, sans-serif;
  --f-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --container: 1240px;
  --gutter: 32px;
  --header-h: 72px;
  --section-gap: 72px;
  color-scheme: light;
}
/* Dark is "a puzzle room at night". The two blocks below must stay identical:
   one follows the OS setting, the other is the header toggle's override. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #202720; --surface: #29352c; --surface-2: #344337; --ink: #f1f0e7; --muted: #b8c0b5; --line: #435347;
    --felt: #18201a; --felt-ink: #f1f0e7; --accent: #83a98a;
    --btn: #477453; --btn-hover: #3e6849; --btn-ink: #ffffff;
    --today: #d8a65c; --today-soft: #493d2d; --today-ink: #d8a65c; --wood: #3a4a3d; --wood-edge: #4a5c4d; --table: #24432f;
    --shadow: 0 2px 8px rgb(0 0 0 / 0.12); --shadow-md: 0 8px 24px rgb(0 0 0 / 0.18); --shadow-lg: 0 18px 48px rgb(0 0 0 / 0.25); --shadow-hover: 0 14px 32px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #202720; --surface: #29352c; --surface-2: #344337; --ink: #f1f0e7; --muted: #b8c0b5; --line: #435347;
  --felt: #18201a; --felt-ink: #f1f0e7; --accent: #83a98a;
  --btn: #477453; --btn-hover: #3e6849; --btn-ink: #ffffff;
  --today: #d8a65c; --today-soft: #493d2d; --today-ink: #d8a65c; --wood: #3a4a3d; --wood-edge: #4a5c4d; --table: #24432f;
  --shadow: 0 2px 8px rgb(0 0 0 / 0.12); --shadow-md: 0 8px 24px rgb(0 0 0 / 0.18); --shadow-lg: 0 18px 48px rgb(0 0 0 / 0.25); --shadow-hover: 0 14px 32px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--f-body);
  transition: background-color 0.2s ease, color 0.2s ease;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--today); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 4vw, 2.625rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 2.4vw, 1.875rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); color: var(--ink); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-weight: 600; }
.skip-link:focus { top: 12px; }
/* In-page targets land below the sticky header. */
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto; padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px)); }
.stack { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* header */
.site-header { background: var(--felt); color: var(--felt-ink); position: sticky; top: 0; z-index: 40; }
.site-header .wrap { display: flex; align-items: center; gap: 12px 16px; min-height: var(--header-h); flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: var(--f-display); font-weight: 800; font-size: 1.4rem; letter-spacing: -0.02em; }
.logo svg { width: 32px; height: 32px; transition: transform 0.25s ease; }
.logo:hover svg { transform: rotate(-12deg); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav summary { color: var(--felt-ink); text-decoration: none; padding: 10px 14px; border-radius: var(--radius); font-weight: 500; font-size: 0.95rem; cursor: pointer; transition: background-color 0.15s ease; }
.nav a:hover, .nav summary:hover { background: rgb(255 255 255 / 0.1); }
.nav a[aria-current="page"] { background: rgb(255 255 255 / 0.14); font-weight: 600; }
.nav details { position: relative; }
.nav summary { list-style: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: " ▾"; font-size: 0.8em; }
.nav .menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-md); padding: 8px; min-width: 220px; display: grid; }
.nav .menu a { color: var(--ink); font-weight: 500; }
.nav .menu a:hover { background: var(--surface-2); }
.nav .menu .all { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin-top: 4px; }
.nav .daily-link { background: var(--today); color: #1d1405; font-weight: 600; }
.nav .daily-link:hover, .nav .daily-link[aria-current="page"] { background: var(--today); color: #1d1405; filter: brightness(1.06); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; flex: none; padding: 0; border-radius: var(--radius); background: transparent; color: var(--felt-ink); border: 1px solid rgb(255 255 255 / 0.2); cursor: pointer; transition: background-color 0.15s ease; }
.icon-btn:hover { background: rgb(255 255 255 / 0.1); }
.icon-btn svg { width: 22px; height: 22px; }
/* Shown as soon as the inline head script adds .js, so the nav never shifts. */
.theme-toggle { display: none; }
.js .theme-toggle { display: grid; }
.nav-toggle { display: none; }

/* breadcrumbs */
.crumbs { font-size: 0.8125rem; color: var(--muted); padding-block: 16px 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0; padding: 0; }
.crumbs li { min-width: 0; }
.crumbs li + li::before { content: "/"; margin-right: 8px; opacity: 0.5; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); }

main { padding-block: 24px 80px; display: grid; gap: var(--section-gap); }
section { display: grid; gap: 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head a { font-weight: 600; text-decoration: none; }

/* page intro */
.intro { display: grid; gap: 10px; max-width: 72ch; }
.intro p { color: var(--muted); }

/* cards */
/* Photo first: the image is the card, the title sits underneath on the page. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 28px 20px; }
.card { text-decoration: none; color: inherit; display: grid; gap: 10px; align-content: start; }
.card .ph { display: block; border-radius: var(--radius-card); overflow: hidden; background: var(--line); box-shadow: var(--shadow); transition: box-shadow 0.2s ease; }
.card img { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; transition: transform 0.2s ease; }
.card:hover .ph { box-shadow: var(--shadow-hover); }
.card:hover img { transform: scale(1.035); }
.card .meta { display: grid; gap: 2px; align-content: start; padding-inline: 2px; }
.card .t { font-weight: 600; font-size: 1.0625rem; line-height: 1.3; transition: color 0.15s ease; }
.card:hover .t { color: var(--accent); }
.card .s { font-size: 0.8125rem; color: var(--muted); }
.badge { display: inline-block; justify-self: start; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 9px; border-radius: var(--radius-sm); background: var(--today-soft); color: var(--today-ink); }

/* hero: today's daily. Text and buttons left, picture right; on phones the
   picture sits between the text and the buttons. */
.hero { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); grid-template-areas: "text media" "cta media"; column-gap: 56px; row-gap: 26px; padding-top: 16px; }
.hero-text { grid-area: text; display: grid; gap: 14px; align-self: end; }
.hero-cta { grid-area: cta; display: flex; flex-wrap: wrap; gap: 12px; align-self: start; }
.hero h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); line-height: 1.05; }
.tagline { font-family: var(--f-display); font-weight: 600; font-size: 1.1rem; color: var(--accent); }
.lede { color: var(--muted); font-size: 1.0625rem; max-width: 46ch; }
.lede strong { color: var(--ink); }
.hero > .hero-media { grid-area: media; }
.hero-media { position: relative; display: block; align-self: center; border-radius: var(--radius-hero); overflow: hidden; background: var(--line); box-shadow: var(--shadow-lg); }
.hero-media img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform 0.4s ease; }
.hero-media:hover img { transform: scale(1.02); }
.hero-tag { position: absolute; left: 16px; top: 16px; background: var(--today); color: #1d1405; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow-md); }
.page-top { display: grid; gap: 28px; }
.byline { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; justify-self: start; min-height: 48px; background: var(--btn); color: var(--btn-ink); padding: 0 22px; border-radius: var(--radius); font-weight: 600; text-decoration: none; border: 1px solid transparent; font: 600 1rem/1.2 var(--f-body); cursor: pointer; transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, filter 0.15s ease; }
.btn:hover { background: var(--btn-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn.today { background: var(--today); color: #1d1405; }
.btn.today:hover { background: var(--today); filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid currentColor; }
.btn.ghost:hover { background: var(--surface-2); }

/* this week's dailies, oldest first, today last */
.week { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; }
.week a { text-decoration: none; color: var(--muted); display: grid; gap: 8px; font-size: 0.85rem; }
.week .ph { display: block; border-radius: var(--radius-card); overflow: hidden; background: var(--line); box-shadow: var(--shadow); outline: 3px solid transparent; outline-offset: 2px; transition: box-shadow 0.2s ease; }
.week img { width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform 0.2s ease; }
.week a:hover .ph { box-shadow: var(--shadow-hover); }
.week a:hover img { transform: scale(1.05); }
.week .day strong { color: var(--ink); font-weight: 600; }
.week .is-today .ph { outline-color: var(--today); }
.week .is-today .day strong { color: var(--today-ink); }

/* daily page */
.daily-feature { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.daily-body { display: grid; gap: 14px; align-content: start; }
.daily-body h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.daily-body .daynav a { font-weight: 600; text-decoration: none; }
.challenge { display: grid; gap: 10px; margin-top: 4px; }
.challenge h3, .controls-label { font-family: var(--f-body); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.sizes a { display: grid; justify-items: center; min-width: 66px; padding: 7px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; line-height: 1.2; transition: border-color 0.15s ease, transform 0.15s ease; }
.sizes a strong { font-family: var(--f-display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.sizes a span { font-size: 0.75rem; color: var(--muted); }
.sizes a:hover { border-color: var(--accent); transform: translateY(-1px); }
.sizes a[aria-current="true"] { background: var(--today); border-color: var(--today); color: #1d1405; }
.sizes a[aria-current="true"] span { color: #3b2a0c; }
.archive { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 40px; align-items: start; }
.archive-text { display: grid; gap: 14px; }

/* category tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.tile { position: relative; border-radius: var(--radius-tile); overflow: hidden; color: #fff; text-decoration: none; box-shadow: var(--shadow); aspect-ratio: 5 / 4; display: grid; align-items: end; background: var(--felt); transition: box-shadow 0.2s ease; }
.tile:hover { box-shadow: var(--shadow-hover); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.tile:hover img { transform: scale(1.05); }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgb(15 24 18 / 0.85), rgb(15 24 18 / 0.35) 40%, rgb(15 24 18 / 0) 70%); }
.tile .label { position: relative; z-index: 1; padding: 16px 18px; display: grid; gap: 2px; }
.tile .label strong { font-family: var(--f-display); font-size: 1.375rem; letter-spacing: -0.02em; }
.tile .label span { font-size: 0.85rem; opacity: 0.92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 0.9rem; white-space: nowrap; transition: border-color 0.15s ease, color 0.15s ease; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip span { color: var(--muted); font-size: 0.82em; }
.chip[aria-current] { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.chip[aria-current] span { color: inherit; }

/* listing pages: collection header, subcategory chips, grid */
.collection-head { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.collection-head .intro { max-width: 64ch; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--accent); }
.intro .count { font-weight: 600; color: var(--accent); }
.collage { display: grid; grid-template-columns: 1.6fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; aspect-ratio: 16 / 10; }
.collage img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-card); box-shadow: var(--shadow); }
.collage img:first-child { grid-row: span 2; border-radius: var(--radius-hero); }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; }
.listing { display: grid; gap: 28px; }

/* explore: one card per collection */
.collections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.collection-card { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-tile); box-shadow: var(--shadow); overflow: hidden; transition: box-shadow 0.2s ease; }
.collection-card:hover { box-shadow: var(--shadow-hover); }
.collection-card .ph { display: block; background: var(--line); overflow: hidden; }
.collection-card .ph img { width: 100%; height: 100%; min-height: 220px; object-fit: cover; transition: transform 0.3s ease; }
.collection-card:hover .ph img { transform: scale(1.04); }
.collection-card .body { display: grid; gap: 12px; align-content: start; padding: 22px; }
.collection-card h2 { font-size: 1.4rem; }
.collection-card h2 a { color: var(--ink); text-decoration: none; }
.collection-card h2 a:hover { color: var(--accent); }
.collection-card .muted { font-size: 0.92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.collection-card .chip { min-height: 32px; padding: 4px 11px; font-size: 0.85rem; }
.collection-card .more { font-weight: 600; text-decoration: none; }

/* pagination */
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pager a, .pager span { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; transition: border-color 0.15s ease, color 0.15s ease; }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager [aria-current="page"] { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }
.pager .gap { background: transparent; border-color: transparent; min-width: 24px; padding: 0; color: var(--muted); }

/* ad slots: height reserved before the ad arrives */
.ad-slot { display: grid; gap: 6px; justify-items: center; min-height: 280px; align-content: start; }
.ad-slot.in-grid { grid-column: 1 / -1; }
.ad-slot > ins, .ad-preview { width: 100%; min-height: 250px; }
.ad-label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ad-preview { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: var(--radius-card); color: var(--muted); background: var(--surface-2); }

/* puzzle page */
.puzzle-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
/* The game sits on green felt inside a wooden frame, like a real puzzle table. */
.board { background: repeating-linear-gradient(100deg, rgb(255 255 255 / 0.05) 0 2px, transparent 2px 13px), var(--wood); border: 1px solid var(--wood-edge); border-radius: var(--radius-hero); padding: clamp(8px, 1.6vw, 16px); display: grid; gap: 14px; box-shadow: var(--shadow-md); }
.game-stage { position: relative; container-type: size; height: min(76vh, 760px); min-height: 360px; display: grid; place-items: center; overflow: hidden; border-radius: 12px; background: var(--table); box-shadow: inset 0 2px 12px rgb(0 0 0 / 0.3); }
.game-stage > img { border-radius: 6px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.35); width: min(100cqw - 32px, (100cqh - 32px) * var(--ar, 4 / 3)); height: auto; aspect-ratio: var(--ar, 4 / 3); }
.game-start { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: nowrap; font-size: 1.1rem; padding: 14px 26px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.35); }
.game-start:hover { transform: translate(-50%, calc(-50% - 1px)); }
.game-stage.playing { display: block; background: radial-gradient(circle at 50% 40%, rgb(255 255 255 / 0.07), transparent 70%), var(--table); }
.game-canvas { display: block; touch-action: none; cursor: grab; }
.game-canvas:active { cursor: grabbing; }
.game-hud { position: absolute; z-index: 2; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--table-ink); font-size: 0.85rem; pointer-events: none; }
.game-hud > * { pointer-events: auto; }
.game-progress, .game-time { background: rgb(12 20 15 / 0.55); padding: 6px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; font-weight: 500; }
.game-time::before { content: "⏱ "; }
.game-tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 12px; background: rgb(12 20 15 / 0.55); }
.game-tools button { background: transparent; color: var(--table-ink); border: 0; border-radius: 9px; min-height: 34px; padding: 4px 11px; font: 500 0.85rem/1 var(--f-body); cursor: pointer; transition: background-color 0.15s ease; }
.game-tools button:hover { background: rgb(255 255 255 / 0.12); }
.game-tools button[aria-pressed="true"] { background: var(--today); color: #1d1405; }
.game-done { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--surface); color: var(--ink); border-radius: var(--radius-hero); box-shadow: 0 20px 60px rgb(0 0 0 / 0.45); padding: 26px 28px; display: grid; gap: 10px; text-align: center; max-width: min(92%, 440px); animation: done-in 0.35s ease-out; }
.game-done:focus { outline: none; }
.game-done strong { font-family: var(--f-display); font-size: 1.75rem; }
.game-done strong::before { content: "🧩 "; }
.game-done-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.game-done .btn { justify-self: auto; }
@keyframes done-in { from { opacity: 0; transform: translate(-50%, -44%) scale(0.96); } }
.board:fullscreen, .board.pseudo-full { border-radius: 0; padding: 10px; }
.board:fullscreen .game-stage { height: calc(100vh - 90px); }
.board.pseudo-full { position: fixed; inset: 0; z-index: 50; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.board.pseudo-full .game-stage { height: calc(100dvh - 90px); }
.board .controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding-inline: 4px; }
.board .note { color: var(--ink); font-size: 0.85rem; }
.aside { display: grid; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 8px; }
.panel h2 { font-size: 1.35rem; }
.today-panel { text-decoration: none; color: inherit; transition: box-shadow 0.2s ease; }
.today-panel:hover { box-shadow: var(--shadow-hover); }
.today-panel img { border-radius: var(--radius); aspect-ratio: 4 / 3; object-fit: cover; }
.panel dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 0.9rem; }
.panel dt { color: var(--muted); }
.panel dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.daynav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* calendar */
.calendar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-tile); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 12px; }
.cal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cal-head h2, .cal-head h3 { font-size: 1.25rem; }
.cal-head a { color: var(--ink); text-decoration: none; }
.cal-head a:hover { text-decoration: underline; }
.calendar .grid7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar .dow { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; text-align: center; color: var(--muted); font-weight: 700; }
.calendar .cell { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--surface-2); text-decoration: none; position: relative; overflow: hidden; }
.calendar .cell.future { background: transparent; border: 1px dashed var(--line); }
.calendar a.cell { color: #fff; font-weight: 700; }
.calendar a.cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(0.68); transition: filter 0.2s ease, transform 0.2s ease; }
.calendar a.cell:hover img { filter: brightness(0.95); transform: scale(1.08); }
.calendar a.cell span { position: relative; text-shadow: 0 1px 3px rgb(0 0 0 / 0.6); }
.calendar .cell.today { outline: 3px solid var(--today); outline-offset: 1px; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.cal-legend .k { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.cal-legend .k.today { border: 2px solid var(--today); }
.cal-legend .k.has { background: var(--accent); margin-left: 10px; }
.calendars { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.months { display: flex; flex-wrap: wrap; gap: 8px; }

/* prose pages */
.prose { max-width: 70ch; display: grid; gap: 14px; }
.prose h2 { margin-top: 10px; }

/* footer */
.site-footer { background: var(--felt); color: var(--felt-ink); padding-block: 56px 28px; font-size: 0.92rem; }
.site-footer .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr); gap: 32px 48px; }
.site-footer .foot-brand { display: grid; gap: 12px; align-content: start; }
.site-footer .foot-brand p { opacity: 0.8; max-width: 34ch; }
.site-footer .logo { justify-self: start; }
.site-footer .cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.site-footer h2 { font-family: var(--f-body); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; margin-bottom: 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { color: var(--felt-ink); opacity: 0.88; text-decoration: none; }
.site-footer a:hover { opacity: 1; text-decoration: underline; }
.site-footer .small { grid-column: 1 / -1; padding-top: 22px; border-top: 1px solid rgb(255 255 255 / 0.14); opacity: 0.7; font-size: 0.82rem; }

@media (max-width: 1024px) {
  :root { --gutter: 24px; --section-gap: 56px; }
  .site-footer .wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .puzzle-layout, .daily-feature, .archive, .collection-head, .collections { grid-template-columns: 1fr; }
  .collage { aspect-ratio: 16 / 7; }
  .hero { grid-template-columns: 1fr; grid-template-areas: "text" "media" "cta"; row-gap: 20px; padding-top: 0; }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .week li:nth-last-child(n+5) { display: none; }
}
/* Mobile header: logo, theme and menu buttons on one row; the menu opens below.
   Without JS (.js missing) the nav simply wraps, so every link stays reachable. */
@media (max-width: 760px) {
  :root { --header-h: 60px; }
  .site-header { position: static; }
  [id] { scroll-margin-top: 8px; }
  .logo { font-size: 1.25rem; }
  .theme-toggle { margin-left: auto; }
  .js .nav-toggle { display: grid; }
  .js .nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; margin-left: 0; padding-bottom: 14px; }
  .js .nav.open { display: flex; }
  .js .nav a, .js .nav summary { padding: 12px 14px; font-size: 1rem; }
  .js .nav .menu { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; background: transparent; border: 0; box-shadow: none; padding: 0 0 0 8px; }
  .js .nav .menu a { color: var(--felt-ink); }
  .js .nav .menu a:hover { background: rgb(255 255 255 / 0.1); }
  .js .nav .menu .all { grid-column: 1 / -1; color: var(--felt-ink); border-top-color: rgb(255 255 255 / 0.14); }
  .site-footer .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
}
@media (max-width: 520px) {
  :root { --gutter: 16px; --section-gap: 44px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .card .t { font-size: 1rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { aspect-ratio: 1; }
  .tile .label { padding: 12px; }
  .tile .label strong { font-size: 1.1rem; }
  .tile .label span { font-size: 0.78rem; }
  .hero-cta .btn { flex: 1 1 100%; }
  .daily-body .btn { justify-self: stretch; }
  .collage { display: none; }
  /* chip rows scroll sideways instead of wrapping into a tall block */
  .subnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .subnav::-webkit-scrollbar { display: none; }
  .collection-card { grid-template-columns: 1fr; }
  .collection-card .ph img { min-height: 0; aspect-ratio: 16 / 9; }
  .pager .step { order: 1; flex: 1 1 calc(50% - 3px); }
  .sizes a { flex: 1 1 0; min-width: 0; padding-inline: 4px; }
  .game-stage { height: min(calc(100dvh - 150px), 640px); }
  /* Before play the table only needs to frame the picture; it grows to full height once a game starts. */
  .game-stage:not(.playing) { height: auto; min-height: 0; aspect-ratio: 1; }
  /* Phones: status on top, a thumb-reachable toolbar along the bottom of the table. */
  .game-hud { inset: 6px; align-content: start; gap: 4px 6px; font-size: 0.78rem; }
  .game-tools { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; flex-wrap: nowrap; }
  .game-tools button { flex: 1 1 auto; min-width: 32px; min-height: 44px; padding: 4px; white-space: nowrap; }
  .game-tools .long { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .card:hover img, .tile:hover img, .week a:hover img, .hero-media:hover img, .calendar a.cell:hover img, .btn:hover, .sizes a:hover { transform: none; }
  .game-done { animation: none; }
}
