/* Nonogram: cross-stitch on Aida cloth inside an embroidery hoop. */
:root {
  --cloth: #f3ecdd; --cloth-2: #e9e0cc; --weave: rgb(120 100 70 / .18); --hoop: #a97a48; --hoop-2: #7a5430; --thread: #2f4a6d; --ink: #3a2e22; --ink-2: #7d6c58; --line: #cfc2a8; --sel: #ffe27a; --done: #b9a98a;
  --bg: var(--cloth-2); --surface: #faf5ea; --surface-2: #ece3cf; --ok: #3e8f5c; --warn: #d9a521; --bad: #c2412d; --info: #2f6f8f; --accent: var(--hoop-2); --accent-ink: #fff6e6;
  --font-display: "Cormorant Garamond", Georgia, serif; --font-ui: "Mulish", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --cloth: #2b2620; --cloth-2: #1e1a16; --weave: rgb(255 240 210 / .08); --ink: #f1e8d6; --ink-2: #b8a88e; --line: #4a4033; --sel: #6b5a1e; --done: #5a5044; --bg: var(--cloth-2); --surface: #2b2620; --surface-2: #3a3229; --accent: #c99a63; --accent-ink: #2b2620; } }
:root[data-theme="dark"] { --cloth: #2b2620; --cloth-2: #1e1a16; --weave: rgb(255 240 210 / .08); --ink: #f1e8d6; --ink-2: #b8a88e; --line: #4a4033; --sel: #6b5a1e; --done: #5a5044; --bg: var(--cloth-2); --surface: #2b2620; --surface-2: #3a3229; --accent: #c99a63; --accent-ink: #2b2620; }
body { background-image: repeating-linear-gradient(0deg, transparent 0 5px, var(--weave) 5px 6px), repeating-linear-gradient(90deg, transparent 0 5px, var(--weave) 5px 6px); }
.screen { gap: 12px; max-width: 560px; margin-inline: auto; }
.topbar { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.screen-title { font-size: 2rem; font-weight: 700; margin-left: 6px; }
.btn { font-weight: 800; } .cta { font-size: 1.1rem; min-height: 52px; }
.hero { text-align: center; padding-top: 2px; } .title { font-size: clamp(2.6rem, 12vw, 3.6rem); font-weight: 700; } .tagline { color: var(--ink-2); margin-top: 2px; font-weight: 600; }
.hoop { --cells: 10; --c: 10px; position: relative; display: grid; grid-template-columns: repeat(var(--cells), var(--c)); width: max-content; margin: 0 auto; padding: 14px; border-radius: 50%; background: var(--cloth); box-shadow: 0 0 0 7px var(--hoop), 0 0 0 10px var(--hoop-2), 0 6px 16px rgb(0 0 0 / .25); background-image: repeating-linear-gradient(0deg, transparent 0 calc(var(--c) - 1px), var(--weave) calc(var(--c) - 1px) var(--c)), repeating-linear-gradient(90deg, transparent 0 calc(var(--c) - 1px), var(--weave) calc(var(--c) - 1px) var(--c)); }
.hoop i { width: var(--c); height: var(--c); position: relative; } .hoop i[data-on="true"]::before, .hoop i[data-on="true"]::after { content: ""; position: absolute; left: 15%; top: 45%; width: 70%; height: 22%; background: var(--thread); border-radius: 2px; transform: rotate(45deg); } .hoop i[data-on="true"]::after { transform: rotate(-45deg); }
.hoop.small { --c: 9px; margin-bottom: 14px; }
.streak-pill { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface); color: var(--warn); font-weight: 800; box-shadow: var(--shadow-1); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; min-height: 66px; border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; box-shadow: var(--shadow-1); border: 2px solid transparent; }
.mode b { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; } .mode span { color: var(--ink-2); font-size: .8rem; line-height: 1.2; font-weight: 600; } .mode[aria-pressed="true"] { border-color: var(--hoop); }
.seg-line { display: flex; background: var(--surface); border-radius: var(--r-pill); padding: 3px; box-shadow: var(--shadow-1); } .seg-line button { flex: 1; height: 42px; border-radius: var(--r-pill); color: var(--ink-2); font-weight: 800; } .seg-line button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-height: 38dvh; overflow-y: auto; padding: 2px; }
.gallery button { aspect-ratio: 1; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .72rem; font-weight: 800; color: var(--ink-2); border: 2px solid transparent; }
.gallery button[data-done="true"] { border-color: var(--hoop); color: var(--ink); } .gallery button .mini { display: grid; gap: 0; } .gallery button .mini i { width: 5px; height: 5px; background: transparent; } .gallery button .mini i[data-on="true"] { background: var(--thread); } .gallery button[data-done="false"] .mini i[data-on="true"] { background: var(--line); }
.home-actions { display: flex; gap: 8px; } .home-actions .cta { flex: 2; } .home-actions > .btn:not(.cta) { flex: 1; background: var(--surface); box-shadow: var(--shadow-1); }

/* Play */
.screen[data-screen="play"] { height: 100dvh; min-height: 0; overflow: hidden; gap: 6px; }
.hud-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; } .hud-note { color: var(--ink-2); font-weight: 800; }
.board-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board { display: grid; grid-template-columns: var(--cw) auto; grid-template-rows: var(--ch) auto; gap: 3px; --n: 10; --cell: 28px; --cw: 56px; --ch: 56px; }
.col-clues { display: grid; grid-template-columns: repeat(var(--n), var(--cell)); align-items: end; } .col-clues div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; font-family: var(--font-display); font-weight: 700; font-size: calc(var(--cell) * .58); line-height: 1; color: var(--ink); padding-bottom: 3px; }
.row-clues { display: grid; grid-template-rows: repeat(var(--n), var(--cell)); align-items: center; } .row-clues div { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-family: var(--font-display); font-weight: 700; font-size: calc(var(--cell) * .58); line-height: 1; color: var(--ink); padding-right: 4px; }
.col-clues div[data-done="true"], .row-clues div[data-done="true"] { color: var(--done); } .col-clues div[data-cur="true"], .row-clues div[data-cur="true"] { background: var(--sel); border-radius: 4px; }
.grid { display: grid; grid-template-columns: repeat(var(--n), var(--cell)); grid-template-rows: repeat(var(--n), var(--cell)); background: var(--cloth); border: 2px solid var(--hoop-2); touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 0 0 5px var(--hoop), 0 6px 16px rgb(0 0 0 / .2); }
.cell { position: relative; border-right: 1px solid var(--weave); border-bottom: 1px solid var(--weave); } .cell[data-b5="true"] { border-right: 1px solid var(--hoop-2); } .cell[data-r5="true"] { border-bottom: 1px solid var(--hoop-2); }
.cell[data-m="1"]::before, .cell[data-m="1"]::after { content: ""; position: absolute; left: 12%; top: 40%; width: 76%; height: 20%; background: var(--thread); border-radius: 2px; transform: rotate(45deg); animation: stitch var(--t-fast) var(--ease-out); } .cell[data-m="1"]::after { transform: rotate(-45deg); }
@keyframes stitch { from { transform: scale(.4) rotate(45deg); opacity: 0; } }
.cell[data-m="2"]::before { content: ""; position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; border-radius: 50%; background: var(--ink-2); opacity: .5; transform: translate(-50%, -50%); }
.cell[data-cur="true"] { outline: 3px solid var(--warn); outline-offset: -3px; z-index: 1; } .cell[data-wrong="true"] { background: rgb(194 65 45 / .25); } .cell.anim-shake { animation: shake-x var(--t-slow); }
.cell[data-hint="true"] { animation: hint-ring 1s ease-out 2; } @keyframes hint-ring { 0% { box-shadow: 0 0 0 0 var(--warn) inset; } 100% { box-shadow: 0 0 0 8px transparent inset; } }
.play-msg { text-align: center; min-height: 1.3em; color: var(--ink-2); font-weight: 700; font-size: .95rem; }
.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding-bottom: env(safe-area-inset-bottom); }
.seg-tool { display: flex; background: var(--surface); border-radius: var(--r-pill); padding: 3px; box-shadow: var(--shadow-1); flex: 1 1 200px; max-width: 260px; } .seg-tool button { flex: 1; height: 44px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-2); font-weight: 800; } .seg-tool button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.stitch-ic { width: 16px; height: 16px; position: relative; } .stitch-ic::before, .stitch-ic::after { content: ""; position: absolute; left: 0; top: 6px; width: 16px; height: 4px; border-radius: 2px; background: currentColor; transform: rotate(45deg); } .stitch-ic::after { transform: rotate(-45deg); } .dot-ic { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pad { flex-basis: 100%; display: grid; justify-content: center; grid-template-columns: 48px 48px 48px; grid-template-rows: 44px 44px 44px; gap: 4px; grid-template-areas: ". up ." "left mark right" ". down ."; } .pad button { border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1); font-size: 1rem; font-weight: 800; } .pad [data-d="up"] { grid-area: up; } .pad [data-d="left"] { grid-area: left; } .pad [data-d="right"] { grid-area: right; } .pad [data-d="down"] { grid-area: down; } .pad .mark { grid-area: mark; background: var(--accent); color: var(--accent-ink); }
.tool { min-height: 44px; padding: 0 16px; background: var(--surface); box-shadow: var(--shadow-1); } .tool:disabled { opacity: .45; }
@media (min-width: 640px) { .screen[data-screen="play"] { max-width: 760px; } }

/* Result */
.result-verdict { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 2.8rem); text-align: center; font-weight: 700; line-height: 1.05; } .result-sub { text-align: center; color: var(--ink-2); font-weight: 600; }
.stars { display: flex; justify-content: center; gap: 6px; } .stars .icon { width: 32px; height: 32px; color: var(--line); } .stars .icon[data-on="true"] { color: var(--warn); fill: var(--warn); animation: pop var(--t-slow) var(--ease-spring) both; animation-delay: calc(var(--i) * 140ms); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; } .result-actions .cta { grid-column: 1 / -1; }
.set-row small { display: block; color: var(--ink-2); font-size: .8rem; font-weight: 500; }
