/* The site (docs/CONCEPT.md, section 9): squared notebook paper and ink, calm, for adults; dark theme for the evening.
   Taken from docs/prototype/nonogram.html. Fonts are our own files (no requests to Google): Golos Text, JetBrains Mono,
   Unbounded (OFL, portal/static/fonts/): latin, latin-ext (Estonian š ž) and cyrillic, each loaded only when a page needs it. */
@font-face { font-family:"Golos Text"; src:url("fonts/golos-latin.woff2") format("woff2"); font-weight:400 600; font-display:swap;
  unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family:"Golos Text"; src:url("fonts/golos-cyrillic.woff2") format("woff2"); font-weight:400 600; font-display:swap;
  unicode-range:U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family:"JetBrains Mono"; src:url("fonts/jetbrains-latin.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family:"JetBrains Mono"; src:url("fonts/jetbrains-cyrillic.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family:Unbounded; src:url("fonts/unbounded-latin.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family:Unbounded; src:url("fonts/unbounded-cyrillic.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

@font-face { font-family:"Golos Text"; src:url("fonts/golos-latin-ext.woff2") format("woff2"); font-weight:400 600; font-display:swap;
  unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family:"JetBrains Mono"; src:url("fonts/jetbrains-latin-ext.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family:Unbounded; src:url("fonts/unbounded-latin-ext.woff2") format("woff2"); font-weight:500 700; font-display:swap;
  unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg:#e9eef3; --sheet:#fbfcfd; --ink:#1d2838; --muted:#586679; --line:#cdd6df; --line-strong:#6f8096;
  --accent:#2c4bb0; --accent-soft:#e3e9fb; --good:#23784a; --bad:#c03d12; --cross:#9aa7b6; --hi:rgba(44, 75, 176, .07);
  --f-display:Unbounded, "Golos Text", system-ui, sans-serif;
  --f-body:"Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono:"JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --c:30px; color-scheme:light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg:#11161d; --sheet:#19202a; --ink:#e4eaf1; --muted:#93a1b3; --line:#2b3542; --line-strong:#63748a;
  --accent:#94abf2; --accent-soft:#232d45; --good:#5cc08a; --bad:#f08a5d; --cross:#5f6d7f; --hi:rgba(148, 171, 242, .08); color-scheme:dark; } }
:root[data-theme="dark"] {
  --bg:#11161d; --sheet:#19202a; --ink:#e4eaf1; --muted:#93a1b3; --line:#2b3542; --line-strong:#63748a;
  --accent:#94abf2; --accent-soft:#232d45; --good:#5cc08a; --bad:#f08a5d; --cross:#5f6d7f; --hi:rgba(148, 171, 242, .08); color-scheme:dark; }

* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; background-color:var(--bg); color:var(--ink); font:15px/1.55 var(--f-body);
  background-image:linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size:24px 24px; background-position:-1px -1px; }
a { color:inherit; }
.wrap { max-width:1100px; margin:0 auto; padding:0 max(16px, env(safe-area-inset-left, 0px)); }
h1, h2, h3 { font-family:var(--f-display); font-weight:700; letter-spacing:-.01em; line-height:1.15; text-wrap:balance; }
h1 { font-size:clamp(24px, 4.2vw, 40px); margin:0 0 12px; }
h1 span, h2 span { color:var(--accent); }
h2 { font-size:clamp(18px, 2.6vw, 24px); margin:0 0 14px; font-weight:500; }
.lead { color:var(--muted); font-size:17px; margin:0 0 20px; max-width:640px; }
.muted { color:var(--muted); }
.mono { font-family:var(--f-mono); font-variant-numeric:tabular-nums; }

/* header and footer */
header { background:var(--sheet); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; }
header .wrap { display:flex; align-items:center; gap:18px; min-height:60px; flex-wrap:wrap; }
.logo { display:flex; align-items:center; gap:10px; text-decoration:none; font:700 18px var(--f-display); }
.logo img { width:30px; height:30px; display:block; }
.logo small { display:block; font:500 11px var(--f-mono); color:var(--muted); letter-spacing:.02em; }
nav.main { display:flex; gap:2px; flex-wrap:wrap; }
nav.main a { white-space:nowrap; text-decoration:none; padding:6px 10px; border-radius:5px; color:var(--muted); font-weight:500; }
nav.main a:hover, nav.main a[aria-current] { color:var(--ink); background:var(--accent-soft); }
.tools { margin-left:auto; display:flex; gap:8px; align-items:center; }
.langs { display:flex; border:1px solid var(--line); border-radius:6px; overflow:hidden; }
.langs a { text-decoration:none; padding:4px 9px; font:700 12px var(--f-mono); color:var(--muted); }
.langs a.on { background:var(--ink); color:var(--sheet); }
.icon-btn { width:34px; height:34px; border:1px solid var(--line); border-radius:6px; background:transparent; color:var(--ink); cursor:pointer; font-size:16px; }
footer { color:var(--muted); font-size:13px; padding:28px 0 46px; }
footer .wrap { display:flex; gap:10px 22px; flex-wrap:wrap; }
.suggest { background:var(--ink); color:var(--sheet); font-size:14px; }
.suggest-in { display:flex; align-items:center; gap:14px; min-height:42px; }
.suggest-in span { flex:1; }
.suggest a { color:var(--sheet); font-weight:600; }
.suggest button { background:none; border:0; color:inherit; font-size:22px; cursor:pointer; opacity:.7; }

/* sheets of paper and buttons */
.sheet { background:var(--sheet); border:1px solid var(--line); border-radius:6px; padding:22px clamp(14px, 3vw, 28px) 26px;
  box-shadow:0 1px 0 var(--line), 0 10px 30px -18px rgba(20, 30, 50, .35); }
main section { margin:26px 0; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; font:500 15px var(--f-body); color:var(--ink);
  background:var(--sheet); border:1px solid var(--line-strong); border-radius:5px; padding:9px 16px; cursor:pointer; text-decoration:none; min-height:40px; }
.btn:hover { background:var(--accent-soft); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:var(--sheet); font-weight:600; }
.btn.primary:hover { filter:brightness(1.08); }
.badges { display:flex; gap:6px; flex-wrap:wrap; font:500 12.5px var(--f-mono); color:var(--muted); }
.badge { border:1px solid var(--line); border-radius:4px; padding:2px 8px; background:var(--sheet); }
.crumbs { font-size:13px; color:var(--muted); margin:18px 0 6px; }
.crumbs a { color:var(--muted); }

/* home */
.hero { display:grid; grid-template-columns:1.2fr 1fr; gap:28px; align-items:center; margin-top:26px; }
.cta { display:flex; gap:10px; flex-wrap:wrap; }
.streak { font:600 14px var(--f-mono); color:var(--good); margin:14px 0 0; }
.today { display:block; text-decoration:none; }
.today .label { font:500 12px var(--f-mono); text-transform:uppercase; letter-spacing:.06em; color:var(--accent); margin-bottom:10px; }
.today .mini { max-width:320px; margin:0 auto; }
.today-meta { font:600 14px var(--f-mono); margin-top:12px; text-align:center; }
.today .next { font:500 12.5px var(--f-mono); color:var(--muted); text-align:center; margin-top:4px; }
.learn-box { display:grid; grid-template-columns:1fr 1fr; gap:26px; align-items:start; }
.rules-list { margin:0; padding-left:20px; }
.rules-list li { margin:0 0 10px; }
.sizes, .themes { display:flex; gap:10px; flex-wrap:wrap; }
.size-chip, .theme-chip { text-decoration:none; background:var(--sheet); border:1px solid var(--line); border-radius:6px; padding:12px 16px; min-width:120px; }
.size-chip:hover, .theme-chip:hover { border-color:var(--line-strong); }
.size-chip b { display:block; font:700 20px var(--f-mono); }
.size-chip small, .theme-chip small { color:var(--muted); font-size:12.5px; }
.theme-chip b { display:block; font-weight:600; }
.features { display:grid; grid-template-columns:repeat(4, 1fr); gap:14px; }
.feature b { display:block; font-family:var(--f-display); font-weight:500; font-size:14px; margin:6px 0 4px; }
.feature p { margin:0; color:var(--muted); font-size:14px; }
.soon .chips span { border-style:dashed; }

/* cards */
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(190px, 1fr)); gap:14px; }
.pcard { display:block; text-decoration:none; background:var(--sheet); border:1px solid var(--line); border-radius:6px; padding:12px; transition:border-color .15s; }
.pcard:hover { border-color:var(--line-strong); }
.mini { aspect-ratio:1; display:grid; place-items:center; }
.mini svg { max-width:100%; max-height:100%; display:block; }
.pmeta { display:flex; gap:8px; align-items:baseline; flex-wrap:wrap; margin-top:8px; font:500 12.5px var(--f-mono); color:var(--muted); }
.pmeta b { color:var(--ink); font-size:14px; }
.pmeta .lvl { margin-left:auto; }
.ptitle { font-weight:600; margin-top:4px; }
.pcard.is-solved .pmeta b::after { content:" ✓"; color:var(--good); }
.empty { color:var(--muted); padding:20px 0; }
.filters { display:flex; flex-direction:column; gap:8px; margin:14px 0 18px; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip-f, .chips span { font:500 13px var(--f-body); border:1px solid var(--line); background:var(--sheet); color:var(--ink); border-radius:999px; padding:5px 12px; cursor:pointer; }
.chips .chip.on { background:var(--ink); color:var(--sheet); border-color:var(--ink); }

/* daily archive */
.days { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:8px; }
.day { display:flex; gap:10px; align-items:baseline; text-decoration:none; background:var(--sheet); border:1px solid var(--line); border-radius:5px; padding:8px 12px; }
.day b { font:600 13px var(--f-mono); }
.day span { color:var(--muted); font:500 12.5px var(--f-mono); }

/* text pages */
.text { max-width:760px; }
.text h2 { margin-top:28px; }
.text p, .text li { font-size:16px; }

/* ---- the game (from the prototype) */
.game { position:relative; }
.stats { display:flex; gap:18px; justify-content:flex-end; font:500 13px var(--f-mono); color:var(--muted); font-variant-numeric:tabular-nums; margin-bottom:8px; }
.stats b { color:var(--ink); font-weight:700; }
.board-box { overflow-x:auto; padding-bottom:4px; }
.board { display:grid; margin:0 auto; width:max-content; user-select:none; -webkit-user-select:none; touch-action:none; }
.cc, .rc { display:flex; font-family:var(--f-mono); font-weight:700; transition:opacity .25s; }
.cc { flex-direction:column; justify-content:flex-end; align-items:center; gap:2px; padding-bottom:5px; }
.rc { justify-content:flex-end; align-items:center; gap:2px; padding-right:6px; }
.chip { min-width:calc(var(--c) * .62); height:calc(var(--c) * .62); padding:0 2px; border-radius:3px; font-size:calc(var(--c) * .4);
  display:flex; align-items:center; justify-content:center; line-height:1; font-variant-numeric:tabular-nums; }
.chips .chip { min-width:0; height:auto; font-size:13px; padding:5px 12px; border-radius:999px; }
.cc.ok, .rc.ok { opacity:.28; }
.cc.hi, .rc.hi { background:var(--hi); }
.cell { width:var(--c); height:var(--c); background:var(--sheet); border-right:1px solid var(--line); border-bottom:1px solid var(--line);
  position:relative; cursor:pointer; transition:background-color .08s; }
.cell.hi { box-shadow:inset 0 0 0 999px var(--hi); }
.cell.top { border-top:2px solid var(--line-strong); }
.cell.left { border-left:2px solid var(--line-strong); }
.cell.r5 { border-right:2px solid var(--line-strong); }
.cell.b5 { border-bottom:2px solid var(--line-strong); }
.cell.x::before, .cell.x::after { content:""; position:absolute; left:28%; right:28%; top:50%; height:1.5px; background:var(--cross); border-radius:1px; }
.cell.x::before { transform:rotate(45deg); } .cell.x::after { transform:rotate(-45deg); }
.cell.bad { box-shadow:inset 0 0 0 2px var(--bad); }
.cell.bad.x::before, .cell.bad.x::after { background:var(--bad); }
.cell.hinted { box-shadow:inset 0 0 0 2px var(--accent); }
.board.won .cell { border-color:transparent; transition:border-color .9s, background-color .9s; }
.board.won .cell.x::before, .board.won .cell.x::after { opacity:0; }
.board.won .cc, .board.won .rc { opacity:0; }
.len { position:fixed; z-index:20; pointer-events:none; background:var(--ink); color:var(--sheet); font:700 14px var(--f-mono);
  padding:3px 9px; border-radius:999px; opacity:0; transition:opacity .1s; }
.len.on { opacity:1; }
.tray { display:flex; justify-content:center; align-items:center; gap:10px; flex-wrap:wrap; margin:20px 0 14px; }
.tool { width:44px; height:44px; border-radius:50%; border:1px solid var(--line-strong); cursor:pointer; padding:0; position:relative;
  background:var(--sheet); color:var(--muted); font:700 12px var(--f-mono); }
.tool .k { position:absolute; right:-4px; bottom:-4px; min-width:16px; height:16px; border-radius:8px; background:var(--sheet);
  border:1px solid var(--line); font-size:10px; line-height:14px; color:var(--muted); }
.tool[aria-pressed="true"] { outline:2px solid var(--ink); outline-offset:3px; }
.tool.xt::before, .tool.xt::after { content:""; position:absolute; left:30%; right:30%; top:50%; height:2px; background:var(--muted); }
.tool.xt::before { transform:rotate(45deg); } .tool.xt::after { transform:rotate(-45deg); }
.sep { width:1px; height:30px; background:var(--line); margin:0 4px; }
.actions { display:flex; justify-content:center; gap:8px; flex-wrap:wrap; }
button.act { font:500 14px var(--f-body); color:var(--ink); background:transparent; border:1px solid var(--line-strong); border-radius:5px;
  padding:7px 14px; cursor:pointer; min-height:38px; }
button.act:hover { background:var(--accent-soft); }
button.act.warn { border-color:var(--bad); color:var(--bad); }
button:focus-visible, .cell:focus-visible, a:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.msg { text-align:center; min-height:24px; margin:12px 0 0; font-size:14px; color:var(--muted); }
.msg.good { color:var(--good); } .msg.bad { color:var(--bad); }
.win { text-align:center; margin-top:16px; }
.win h2 { font-weight:500; font-size:20px; margin:0 0 4px; color:var(--good); }
.win p { margin:6px 0 0; color:var(--muted); font-size:14px; }
.win-acts { display:flex; gap:8px; justify-content:center; flex-wrap:wrap; }
.play-head { display:flex; justify-content:space-between; align-items:flex-end; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.play-head h1 { margin:0; }
.play-tools { display:flex; gap:8px; flex-wrap:wrap; margin-top:18px; justify-content:center; }
.rules { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:14px 24px; margin-top:22px; padding-top:18px; border-top:1px dashed var(--line); }
.rules h3 { font-weight:500; font-size:13px; letter-spacing:.02em; margin:0 0 4px; }
.rules p { margin:0; font-size:13.5px; color:var(--muted); }
.rules kbd { font-family:var(--f-mono); font-size:11.5px; border:1px solid var(--line); border-bottom-width:2px; border-radius:3px; padding:0 4px; color:var(--ink); }
.play-wrap { max-width:900px; margin:0 auto; }
#print-sheet { display:none; }

@media (max-width: 860px) {
  .hero, .learn-box { grid-template-columns:1fr; }
  .features { grid-template-columns:1fr 1fr; }
  nav.main { order:3; width:100%; overflow-x:auto; flex-wrap:nowrap; padding-bottom:6px; }
}
@media (max-width: 560px) {
  .features { grid-template-columns:1fr; }
  .grid { grid-template-columns:repeat(2, 1fr); gap:10px; }
  .tool { width:38px; height:38px; } .tray { gap:8px; }
  .stats { justify-content:center; }
}
@media (prefers-reduced-motion: reduce) { * { transition:none !important; } }

/* paper: only the puzzle (and the answer on a second page), no interface */
@media print {
  @page { margin:12mm; }
  body { background:#fff; color:#000; }
  body > *:not(main), main > *:not(#print-sheet) { display:none !important; }
  #print-sheet { display:block; }
  #print-sheet h1 { font-size:16pt; margin:0 0 2mm; }
  #print-sheet p { margin:0 0 5mm; font-size:10pt; color:#444; }
  .ps-board svg { width:100%; max-height:225mm; }
  #print-sheet.with-answer .ps-answer { break-before:page; display:block; }
  .ps-answer { display:none; } .ps-answer svg { width:60%; margin:10mm auto; display:block; }
  .print-foot { font-size:8pt; color:#888; text-align:right; }
}
