:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2937;
  --muted: #5b6472;
  --line: #ddd8cc;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --bar: #1f2937;
  --bar-ink: #f3f4f6;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 18px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
.muted { color: var(--muted); }
.muted a { color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 60px; font-size: 1.2rem; padding: 0 32px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span, .chip-btn {
  display: inline-flex; align-items: center; min-height: 46px; min-width: 56px; justify-content: center;
  padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface);
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
}
.chip input:checked + span, .chip-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-weight: 500; cursor: pointer; }
.check input { width: 24px; height: 24px; }

/* ---------- Home ---------- */

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.site-header { background: var(--bar); color: var(--bar-ink); padding: 14px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 800; color: #fff; text-decoration: none; letter-spacing: -0.02em; }
.tagline { margin: 0; color: #cbd5e1; }

section { margin: 28px 0; }
section > h2 { font-size: 1.4rem; margin: 0 0 12px; }

.daily {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.daily-img img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; display: block; }
.daily-info h2 { font-size: 1.8rem; margin: 4px 0 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; font-weight: 700; color: var(--accent); margin: 0; }
@media (max-width: 720px) { .daily { grid-template-columns: 1fr; } }

.picker { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card { position: relative; display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.card img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; background: #e5e1d8; }
.card .cap { display: block; padding: 8px 12px 10px; font-weight: 600; font-size: 0.95rem; }
.card .done { position: absolute; top: 8px; right: 8px; background: #15803d; color: #fff; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; }

.site-footer { color: var(--muted); padding-bottom: 40px; font-size: 0.95rem; }
.prose { max-width: 720px; }

/* ---------- Puzzle page ---------- */

body.play { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: none; }
.toolbar {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--bar); color: var(--bar-ink); flex: none; overflow-x: auto;
}
.title-wrap { flex: 1; min-width: 0; padding: 0 8px; }
.title-wrap h1 { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.tool {
  flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 56px; min-height: 52px; padding: 4px 8px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; font: inherit; font-size: 0.75rem; text-decoration: none; cursor: pointer;
}
.tool:hover { background: rgba(255,255,255,0.1); }
.tool.on { background: rgba(255,255,255,0.2); }
.tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool.timer { font-size: 1.15rem; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 72px; }
.tool.timer.dim { color: transparent; text-shadow: 0 0 8px rgba(255,255,255,0.5); }
#btn-sound:not(.on) svg path:last-child { opacity: 0; }
@media (max-width: 640px) { .tool .label { display: none; } .tool { min-width: 46px; } }

#board { position: relative; flex: 1; min-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
#canvas { display: block; touch-action: none; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.3rem; text-shadow: 0 1px 3px #000; }
#preview { position: absolute; top: 12px; right: 12px; width: min(42%, 520px); border: 4px solid #fff; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,0.4); cursor: pointer; }
#preview img { display: block; width: 100%; }
#rotate-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.55); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 0.9rem; pointer-events: none; }
.table-controls { position: absolute; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; pointer-events: none; }
#swatches { display: flex; gap: 8px; pointer-events: auto; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.6); cursor: pointer; padding: 0; }
.swatch.on { outline: 3px solid #fbbf24; outline-offset: 1px; }
#zoom { order: 3; display: flex; gap: 6px; pointer-events: auto; }
#zoom button {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,0.88); color: #1f2937; font: 600 1.6rem/1 system-ui, sans-serif;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); display: grid; place-items: center;
}
#zoom button:disabled { opacity: 0.4; cursor: default; }
#zoom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#credit { flex: 1; font-size: 0.75rem; color: rgba(255,255,255,0.75); text-shadow: 0 1px 2px #000; text-align: right; pointer-events: auto; }
#credit a { color: inherit; }

dialog { border: 0; border-radius: 16px; padding: 24px; max-width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,0.4); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,0.5); }
dialog h2 { margin: 0 0 12px; font-size: 1.6rem; }
dialog h3 { margin: 18px 0 4px; font-size: 1rem; color: var(--muted); }
dialog .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }
dialog .note { color: var(--muted); font-size: 0.9rem; margin-bottom: 0; }
#win { text-align: center; }
#win img { width: 100%; max-height: 40vh; object-fit: contain; border-radius: 8px; }
#win .actions { justify-content: center; }

/* ---------- Navigation and shared page parts ---------- */

.site-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.site-nav a {
  color: #e5e7eb; text-decoration: none; font-weight: 600; padding: 10px 14px; border-radius: 999px; min-height: 44px;
  display: inline-flex; align-items: center;
}
.site-nav a:hover { background: rgba(255,255,255,0.1); }
.site-nav a[aria-current="page"] { background: #fff; color: var(--bar); }
@media (max-width: 720px) {
  .site-header { gap: 8px; }
  .site-nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .site-nav a { padding: 8px 12px; white-space: nowrap; }
}

main.wrap > h1 { font-size: 2rem; margin: 28px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 1.4rem; }
.section-head a { font-weight: 600; }
.daily-info h1 { font-size: 1.8rem; margin: 4px 0 8px; }
#months h2 { margin: 28px 0 12px; }

.promo {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius); padding: 20px;
}
.promo h2 { margin: 0 0 6px; }
.promo p { margin: 0; max-width: 60ch; }

.drop {
  text-align: center; border: 3px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; background: var(--surface);
}
.drop.over { border-color: var(--accent); background: #fff7ed; }
.drop label.btn { margin: 8px 0; }
.error { color: #b91c1c; font-weight: 600; }
.photo { display: flex; flex-direction: column; gap: 4px; }
.photo-tools { display: flex; gap: 16px; padding: 0 4px; }
.link { background: none; border: 0; padding: 6px 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; min-height: 40px; }
.link.danger { color: #b91c1c; }

.title-wrap p { margin: 0; font-size: 0.8rem; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-wrap p:empty { display: none; }
