/* pnori Puzzles — site styles
   Brand (pnori brand kit): violet #8B5CF6, pink #FF4FA3, blue #3D8BFF, yellow #FFD23F,
   deep violet #6236E0, ink #07060B, paper #F4F1FA.
   Headings: Bricolage Grotesque ExtraBold; body: DM Sans (Google Fonts, with fallbacks).
   Seasonal themes (assets/js/themes.js) override --sky*, --acc*, --tile*, --frame, --trim. */

:root {
  --ink: #07060B;
  --ink-2: #141020;
  --ink-3: #221a33;
  --paper: #F4F1FA;
  --pink: #FF4FA3;
  --pink-deep: #d1006a;
  --violet: #8B5CF6;
  --violet-deep: #6236E0;
  --blue: #3D8BFF;
  --blue-deep: #1f5fd6;
  --sun: #FFD23F;
  --text: #F4F1FA;
  --text-dim: #cfc6e2;
  /* seasonal theme (defaults = Christmas; JS sets the active theme) */
  --sky1: #07060B; --sky2: #140b2e; --sky3: #2a1460;
  --acc1: #FF4FA3; --acc2: #8B5CF6; --acc3: #FFD23F;
  --tile0: #fff0f7; --tile1: #f1ebff; --tile2: #e6f0ff;
  --frame: #1d0f45; --trim: #FF4FA3;
  --radius: 18px;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: var(--acc1);
  --bw: min(94vw, 580px); /* board width */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--ink);
  min-height: 100vh;
}
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 55%, var(--sky3) 100%);
}
h1, h2, h3, .display { font-family: var(--font-display); line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 .4em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 800; }
p { margin: 0 0 1em; }
a { color: #ff9fcb; text-underline-offset: 3px; }
a:hover { color: #ffc0e0; }
img, svg { max-width: 100%; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 6px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--sun); color: var(--ink); padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 12px; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header { position: relative; z-index: 5; border-bottom: 1px solid rgba(255,255,255,.08); background: rgba(13,10,20,.72); backdrop-filter: blur(8px); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; letter-spacing: -0.03em; }
.brand:hover { color: var(--text); }
.brand .logo { height: 40px; width: auto; display: block; }
.brand small { font-family: var(--font-body); font-weight: 600; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); background: linear-gradient(90deg, var(--pink), var(--sun)); padding: 2px 8px; border-radius: 999px; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
@media (max-width: 760px) {
  .site-header .wrap { padding: 10px 0 8px; gap: 8px; }
  .brand .logo { height: 34px; }
  .site-nav { width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav ul { flex-wrap: nowrap; }
  .site-nav a { white-space: nowrap; padding: 6px 11px; font-size: .92rem; }
}
.site-nav a { display: inline-block; padding: 7px 12px; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
.site-nav a:hover { background: rgba(255,255,255,.1); }
.site-nav a[aria-current="page"] { background: var(--text); color: var(--ink); }
.site-nav .lvl-easy::before, .site-nav .lvl-medium::before, .site-nav .lvl-hard::before, .site-nav .lvl-expert::before { content: ""; display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .4em; vertical-align: .05em; }
.lvl-easy::before { background: #3ee08f; } .lvl-medium::before { background: var(--blue); } .lvl-hard::before { background: var(--violet); } .lvl-expert::before { background: var(--pink); }

/* ---------- Art headers ---------- */
.art-head { position: relative; overflow: hidden; isolation: isolate; padding: clamp(36px, 7vw, 80px) 0 clamp(28px, 5vw, 56px); }
.art-head .scene-art { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.art-head .scene-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.art-head::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, rgba(7,6,11,.82) 0%, rgba(7,6,11,.6) 32%, rgba(7,6,11,0) 58%); }
.art-head .wrap { position: relative; }
.art-head .kicker { display: inline-block; font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .16em; background: var(--ink); color: var(--sun); padding: 6px 12px; border-radius: 999px; margin-bottom: 14px; }
.art-head h1 { max-width: 15ch; text-shadow: 0 3px 0 rgba(13,10,20,.35); }
.art-head .lede { font-size: clamp(1.05rem, 2.2vw, 1.25rem); max-width: 56ch; color: #fff; font-weight: 500; }
@media (min-width: 761px) { .art-head .lede { max-width: min(40ch, 46vw); } .art-head h1 { max-width: min(15ch, 50vw); } }
@media (max-width: 760px) {
  /* phones: the scene becomes a full illustration strip under the headline (never behind text) */
  .art-head.art-head { padding-bottom: calc(56vw + 6px); }
  .art-head.art-head--compact { padding-bottom: calc(42vw + 4px); }
  .art-head .scene-art { top: auto; height: 56vw; }
  .art-head--compact .scene-art { height: 42vw; }
  .art-head::before { display: none; }
}
.art-head--compact { padding: clamp(24px, 4vw, 52px) 0 clamp(18px, 3vw, 40px); }
@media (min-width: 1000px) { .art-head--compact { min-height: 300px; } }
.art-head--compact h1 { max-width: none; font-size: clamp(1.9rem, 5vw, 3rem); }
.hl-pink { background: linear-gradient(transparent 58%, rgba(255,63,164,.85) 58%); padding: 0 .08em; }
.hl-blue { background: linear-gradient(transparent 58%, rgba(47,123,255,.9) 58%); padding: 0 .08em; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 2px solid var(--ink); font: 700 1rem/1 var(--font-body); text-decoration: none; cursor: pointer; color: var(--ink); background: var(--sun); box-shadow: 4px 4px 0 var(--ink); transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); color: var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn--pink { background: var(--pink); }
.btn--violet { background: var(--violet); color: #fff; }
.btn--violet:hover { color: #fff; }
.btn--blue { background: var(--blue-deep); color: #fff; }
.btn--blue:hover { color: #fff; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--text); box-shadow: 4px 4px 0 var(--pink); }
.btn--ghost:hover { color: var(--text); box-shadow: 5px 5px 0 var(--pink); }

/* ---------- Home cards ---------- */
.section { padding: clamp(28px, 5vw, 56px) 0; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.level-card { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; gap: 6px; min-height: 230px; padding: 22px; border-radius: 24px; border: 2px solid var(--ink); color: var(--ink); text-decoration: none; box-shadow: 6px 6px 0 rgba(255,255,255,.9); transition: transform .15s, box-shadow .15s; }
.level-card:hover { transform: translate(-2px, -3px) rotate(-.4deg); box-shadow: 9px 9px 0 #fff; color: var(--ink); }
.level-card h3 { font-size: 2rem; margin: 0; font-weight: 800; }
.level-card p { margin: 0; font-weight: 600; }
.level-card .meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.level-card .go { background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 14px; }
.level-card .status { font-size: .85rem; background: rgba(255,255,255,.75); border-radius: 999px; padding: 3px 10px; }
.level-card .status:empty { display: none; }
.level-card svg.card-art { position: absolute; right: -34px; bottom: -40px; width: 170px; height: 170px; z-index: -1; opacity: .9; }
.level-card--easy { background: linear-gradient(135deg, #7ef2b6, #3ee08f 60%, #a7f5ff); }
.level-card--medium { background: linear-gradient(135deg, #1f63ec, var(--blue-deep) 70%, #2a2fd0); }
.level-card--medium, .level-card--medium:hover { color: #fff; }
.level-card--medium .go { background: #fff; color: var(--ink); }
.level-card--hard { background: linear-gradient(135deg, #7d2ff2, var(--violet-deep) 70%, #4a12b8); color: #fff; }
.level-card--hard:hover { color: #fff; }
.level-card--hard .go { background: #fff; color: var(--ink); }
.level-card--expert { background: linear-gradient(135deg, #ffb0d8, var(--pink) 60%, #ff7a59); }
.level-card .status { color: var(--ink); }
.feature-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.panel { position: relative; overflow: hidden; isolation: isolate; background: var(--ink-2); border: 1px solid rgba(255,255,255,.1); border-radius: 24px; padding: 24px; }
.panel h2, .panel h3 { color: #fff; }
.panel--print { background: linear-gradient(160deg, #1b1330, #0d0a14); }
.panel--embed { background: linear-gradient(160deg, #12203f, #0d0a14); }
.panel .btn { margin-top: 6px; }
.panel .blob { position: absolute; right: -50px; bottom: -50px; width: 170px; height: 170px; opacity: .4; pointer-events: none; z-index: -1; }

/* ---------- Play layout ---------- */
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 20px 0 40px; }
.play-main { display: flex; flex-direction: column; align-items: center; gap: 22px; min-width: 0; }
.play-side { display: flex; flex-direction: column; gap: 18px; }
@media (min-width: 1040px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .play-side { position: sticky; top: 16px; }
}
.how-to ol { padding-left: 1.2em; margin: 0; }
.how-to li { margin-bottom: .35em; }
.how-to kbd { font: 700 .85em var(--font-body); background: var(--ink-3); border: 1px solid rgba(255,255,255,.25); border-bottom-width: 3px; border-radius: 6px; padding: 1px 6px; }
.level-links { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.level-links a { display: flex; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: var(--ink-3); color: var(--text); text-decoration: none; font-weight: 700; }
.level-links a:hover { background: #2f2342; }
.level-links a[aria-current="page"] { outline: 2px solid var(--pink); }

/* ---------- Ad slots (placeholders) ---------- */
.ad-slot { width: 100%; max-width: 728px; min-height: 100px; display: grid; place-items: center; border: 2px dashed rgba(255,255,255,.28); border-radius: 14px; background: repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 10px, transparent 10px 20px); color: var(--text-dim); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; }
.ad-slot--sidebar { min-height: 600px; max-width: 300px; display: none; }
@media (min-width: 1040px) { .ad-slot--sidebar { display: grid; } }

/* ---------- Cross-promo + footer ---------- */
.promo { position: relative; overflow: hidden; isolation: isolate; border-radius: 28px; padding: clamp(22px, 4vw, 40px); border: 2px solid var(--ink); background: linear-gradient(120deg, var(--violet) 0%, var(--pink) 55%, #ff9a5a 100%); color: var(--ink); display: grid; gap: 18px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 760px) { .promo { grid-template-columns: 1.3fr 1fr; } }
.promo h2 { color: var(--ink); margin-bottom: .2em; }
.promo p { font-weight: 600; margin: 0; }
.promo .promo-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.promo-title { display: inline-flex; align-items: center; gap: .3em; flex-wrap: wrap; }
.promo-title .promo-logo { height: 1.5em; width: auto; }
.promo .book .book-mark { height: 1em; width: auto; vertical-align: -.12em; }
.promo .book { text-decoration: none; display: flex; gap: 14px; align-items: center; background: var(--ink); color: #fff; border-radius: 18px; padding: 14px; }
.promo .book svg { width: 70px; height: 92px; flex: none; }
.promo .book strong { font-family: var(--font-display); font-size: 1.15rem; display: block; }
.promo .book .soon { display: inline-block; margin-top: 4px; background: var(--sun); color: var(--ink); font-weight: 800; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; padding: 2px 8px; border-radius: 999px; }
.site-footer { margin-top: 40px; padding: 32px 0 40px; border-top: 1px solid rgba(255,255,255,.1); color: var(--text-dim); font-size: .95rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: center; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--text); }

/* ---------- Game ---------- */
.game { width: var(--bw); max-width: 100%; color: var(--ink); }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: var(--text); }
.game-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); border: 2px solid var(--ink); }
.badge--easy { background: #3ee08f; } .badge--medium { background: #7fb2ff; } .badge--hard { background: #b78bff; } .badge--expert { background: var(--pink); }
.game-no { font-size: .9rem; color: var(--text-dim); }
.game-clock { display: flex; align-items: center; gap: 8px; }
.timer { font: 800 1.15rem/1 var(--font-display); font-variant-numeric: tabular-nums; background: var(--ink-3); color: #fff; padding: 8px 12px; border-radius: 999px; min-width: 4.6em; text-align: center; }
.icon-btn { min-width: 44px; min-height: 40px; border-radius: 999px; border: 2px solid rgba(255,255,255,.3); background: transparent; color: var(--text); font-weight: 800; cursor: pointer; padding: 0 12px; }
.icon-btn:hover { background: rgba(255,255,255,.1); }

.board-wrap { position: relative; padding: 8px; border-radius: 22px; background: conic-gradient(from 210deg, var(--acc1), var(--acc2), var(--frame), var(--acc3), var(--acc1)); box-shadow: 0 18px 50px rgba(0,0,0,.45), 0 0 0 2px var(--ink); }
.board { --cell: calc((var(--bw) - 16px) / 9); display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); aspect-ratio: 1; width: 100%; background: var(--ink); border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; gap: 1px; }
.board [role="row"] { display: contents; }
.cell {
  --tint: #fff;
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0;
  background-color: var(--tint);
  font: 800 calc(var(--cell) * .58)/1 var(--font-display);
  color: var(--ink); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
}
.cell.t0 { --tint: var(--tile0); }
.cell.t1 { --tint: var(--tile1); }
.cell.t2 { --tint: var(--tile2); }
.cell.c2, .cell.c5 { margin-right: 2px; }
.cell.r2, .cell.r5 { margin-bottom: 2px; }
.cell.user { color: #3a17c4; }
.cell.peer { background-image: linear-gradient(rgba(255,190,20,.30), rgba(255,190,20,.30)); }
.cell.same { background-image: linear-gradient(rgba(255,79,163,.45), rgba(255,79,163,.45)); }
.cell.sel { background: var(--sun); box-shadow: inset 0 0 0 3px var(--ink); z-index: 1; }
.cell:focus { outline: none; }
.cell:focus-visible { box-shadow: inset 0 0 0 4px var(--blue-deep); outline: none; z-index: 2; }
.cell.sel:focus-visible { box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 6px var(--blue); }
.cell.conflict .v { color: #c4002f; }
.cell.wrong { background-image: repeating-linear-gradient(135deg, rgba(196,0,47,.22) 0 6px, rgba(196,0,47,.08) 6px 12px); }
.cell.wrong .v { color: #b0002a; text-decoration: underline wavy #b0002a 2px; text-underline-offset: 4px; }
.cell .n { position: absolute; inset: 3px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); font: 700 calc(var(--cell) * .22)/1 var(--font-body); color: #4b3a66; }
.cell .n i { font-style: normal; display: grid; place-items: center; }
.cell .n i.hl { background: var(--pink); color: #fff; border-radius: 4px; }
.board-wrap.paused .cell .v, .board-wrap.paused .cell .n { visibility: hidden; }
.pause-cover { position: absolute; inset: 8px; display: none; place-items: center; border-radius: 14px; background: rgba(13,10,20,.82); z-index: 4; }
.board-wrap.paused .pause-cover { display: grid; }

.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0 10px; }
.tool { min-height: 48px; border-radius: 14px; border: 2px solid var(--ink); font: 800 .85rem/1.1 var(--font-body); cursor: pointer; color: var(--ink); padding: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 3px 3px 0 var(--ink); }
.tool .ico { font-size: 1.15rem; line-height: 1; }
.tool:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tool[data-act="undo"] { background: #b9f3d6; }
.tool[data-act="erase"] { background: #ffd0e6; }
.tool[data-act="notes"] { background: #e2d4ff; }
.tool[data-act="check"] { background: #cfe1ff; }
.tool[data-act="more"], .tool[data-act="print"], .tool[data-act="restart"] { background: #fff1b8; }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--sun); box-shadow: 3px 3px 0 var(--pink); }
.tool .state { font-size: .7rem; font-weight: 700; opacity: .9; }

.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.pad button { position: relative; min-width: 0; height: clamp(48px, calc(var(--bw) * .13), 64px); border: 2px solid var(--ink); border-radius: 12px; font: 800 calc(var(--bw) * .055)/1 var(--font-display); color: var(--ink); cursor: pointer; padding: 0; box-shadow: 0 4px 0 var(--ink); }
.pad button:nth-child(3n+1) { background: #ffb3d9; }
.pad button:nth-child(3n+2) { background: #cdb3ff; }
.pad button:nth-child(3n+3) { background: #a9c9ff; }
.pad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pad button small { position: absolute; right: 4px; bottom: 3px; font: 700 .62rem/1 var(--font-body); opacity: .75; }
.pad button.used-up { opacity: .35; }
.pad.notes-mode button { background: #fff; border-style: dashed; }
.more-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.more-row .icon-btn { font-size: .9rem; }

/* Celebration */
.celebrate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(13,10,20,.6); }
.celebrate[hidden] { display: none; }
.celebrate .cel-logo { height: 46px; width: auto; display: block; margin: 0 auto 6px; }
.celebrate .cel-cheer { display: inline-block; margin: 0 0 6px; padding: 4px 12px; border-radius: 999px; background: var(--ink); color: var(--sun); font-weight: 800; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.celebrate .card { position: relative; overflow: hidden; width: min(440px, 100%); text-align: center; color: var(--ink); background: linear-gradient(140deg, #fff6d6, #ffd0e6 45%, #e2d4ff 80%, #dfeaff); background: linear-gradient(140deg, #fff6d6, color-mix(in srgb, var(--acc1) 35%, #fff) 45%, color-mix(in srgb, var(--acc2) 35%, #fff) 80%, #dfeaff); border: 3px solid var(--ink); border-radius: 28px; padding: 30px 24px 24px; box-shadow: 10px 10px 0 var(--ink); animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.celebrate h2 { font-size: 2.6rem; color: var(--ink); margin-bottom: .1em; }
.celebrate .time { font: 800 1.6rem var(--font-display); }
.celebrate .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.celebrate .actions .btn { box-shadow: 3px 3px 0 var(--ink); }
.celebrate .close { position: absolute; top: 10px; right: 12px; background: var(--ink); color: #fff; border: 0; border-radius: 999px; width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer; }
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); } }
.board-wrap.won .cell { animation: wave .9s ease both; animation-delay: calc(var(--d) * 22ms); }
@keyframes wave { 40% { background: var(--sun); transform: scale(.88) rotate(-4deg); } 70% { background: #ff9fd0; } }
.solved-banner { display: none; margin-top: 12px; text-align: center; font-weight: 800; color: var(--sun); }
.game.done .solved-banner { display: block; }

/* ---------- Archive ---------- */
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.archive-list li { background: var(--ink-2); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 14px 16px; }
.archive-list .day { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: #fff; }
.archive-list .day small { display: block; font-family: var(--font-body); font-weight: 600; font-size: .8rem; color: var(--text-dim); }
.archive-list .lv { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.archive-list .lv a { font-size: .85rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; color: var(--ink); text-decoration: none; border: 2px solid var(--ink); }
.archive-list .lv a.easy { background: #3ee08f; } .archive-list .lv a.medium { background: #7fb2ff; } .archive-list .lv a.hard { background: #b78bff; } .archive-list .lv a.expert { background: var(--pink); }
.archive-list .lv a.done::after { content: " \2713"; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 999px; font-weight: 800; text-decoration: none; color: var(--text); border: 2px solid rgba(255,255,255,.3); }
.tabs a[aria-current="page"] { background: var(--text); color: var(--ink); border-color: var(--text); }

/* ---------- Large print ---------- */
.print-controls { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; background: var(--ink-2); border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 18px; margin-bottom: 24px; }
.print-controls label, .print-controls legend { display: block; font-weight: 700; margin-bottom: 6px; }
.print-controls select { width: 100%; min-height: 44px; border-radius: 12px; border: 2px solid var(--text); background: var(--ink); color: var(--text); font: 600 1rem var(--font-body); padding: 0 10px; }
.print-controls fieldset { border: 0; margin: 0; padding: 0; }
.print-controls .checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.print-controls .checks label { font-weight: 600; display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.print-controls input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--pink); }
.sheets { display: grid; gap: 24px; justify-items: center; }
.sheet { width: min(8.5in, 100%); background: #fff; color: #000; border-radius: 6px; padding: 0.45in; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 3px solid #000; padding-bottom: 6px; margin-bottom: 14px; font-family: var(--font-display); }
.sheet-head strong { font-size: 1.4rem; }
.lp-item { margin: 0 auto 18px; }
.lp-item h2 { color: #000; font-size: 1.3rem; margin: 0 0 8px; text-align: center; }
.lp-grid { border-collapse: collapse; margin: 0 auto; border: 4px solid #000; table-layout: fixed; }
.lp-grid td { border: 1px solid #000; text-align: center; vertical-align: middle; padding: 0; font: 700 1em/1 Arial, Helvetica, sans-serif; color: #000; }
.lp-grid td.bl { border-left: 3px solid #000; }
.lp-grid td.bt { border-top: 3px solid #000; }
.lp-1 .lp-grid td { width: 0.76in; height: 0.76in; font-size: 36pt; }
.lp-2 .lp-grid td { width: 0.46in; height: 0.46in; font-size: 22pt; }
.lp-ans .lp-grid td { width: 0.3in; height: 0.3in; font-size: 13pt; font-weight: 400; }
.lp-ans .lp-grid td.g { font-weight: 800; }
.lp-ans-grid { display: grid; grid-template-columns: repeat(2, auto); gap: 18px 36px; justify-content: center; }
.sheet-foot { margin-top: 10px; text-align: center; font-size: 10pt; color: #000; }

/* ---------- Widget ---------- */
.widget-body { background: var(--ink); min-height: 0; }
.widget-body.theme-light { background: #fff6fb; color: var(--ink); --text: var(--ink); --text-dim: #4d4260; }
.widget-body.theme-light .timer { background: var(--ink); }
.widget-body.theme-light .icon-btn { color: var(--ink); border-color: rgba(13,10,20,.35); }
.widget { --bw: min(100vw - 24px, 460px); padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.widget .board-wrap { background: conic-gradient(from 210deg, var(--accent), var(--acc2), var(--frame), var(--acc3), var(--accent)); }
.widget .tools { grid-template-columns: repeat(4, 1fr); }
.widget-head { width: var(--bw); display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text); }
.widget-head .title { font: 800 1.15rem var(--font-display); }
.credit { font-size: .85rem; font-weight: 700; color: var(--text); }
.credit a { color: var(--accent); }
.theme-light .credit a { color: var(--pink-deep); }


/* ---------- Seasonal backdrop + scene animations ---------- */
.fx-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 0; }
.site-header, main, .site-footer, body > section { position: relative; }
main, .site-footer, body > section { z-index: 1; }
.scene-svg .tw { animation: tw 3s ease-in-out infinite; }
.scene-svg .glow { animation: glow 3.5s ease-in-out infinite alternate; }
.scene-svg .flick { transform-box: fill-box; transform-origin: 50% 100%; animation: flick .9s ease-in-out infinite alternate; }
.scene-svg .flick-o { animation: flicko 1.6s steps(6) infinite; }
.scene-svg .sway { transform-box: fill-box; transform-origin: 50% 0; animation: sway 5s ease-in-out infinite alternate; }
.scene-svg .bob { animation: bob 5s ease-in-out infinite alternate; }
.scene-svg .spin { transform-box: fill-box; transform-origin: 50% 50%; animation: spin 60s linear infinite; }
.scene-svg .burst { transform-box: fill-box; transform-origin: 50% 50%; animation: burst 3.4s ease-out infinite; }
.scene-svg .fly { animation: fly 16s linear infinite; }
.scene-svg .drift { animation: drift 7s ease-in-out infinite alternate; }
@keyframes tw { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes glow { from { opacity: .7; } to { opacity: 1; } }
@keyframes flick { from { transform: scale(1, 1) skewX(-2deg); } to { transform: scale(.9, 1.12) skewX(3deg); } }
@keyframes flicko { 0%, 100% { opacity: 1; } 30% { opacity: .75; } 60% { opacity: .95; } }
@keyframes sway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-14px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes burst { 0% { transform: scale(.15); opacity: 0; } 12% { opacity: 1; } 70% { opacity: .9; } 100% { transform: scale(1.1); opacity: 0; } }
@keyframes fly { from { transform: translateX(240px); } to { transform: translateX(-900px); } }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-60px); } }

/* ---------- 3D board ---------- */
.view-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
.view-bar[hidden] { display: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(7,6,11,.7); border: 2px solid rgba(255,255,255,.22); }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; color: var(--text); font: 700 .92rem/1 var(--font-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--sun); color: var(--ink); }
.view-bar .reset-view { background: rgba(7,6,11,.7); }
.view-bar .reset-view[hidden] { display: none; }
.view-hint { margin: 8px 0 0; text-align: center; font-size: .82rem; color: var(--text-dim); }
.view-hint[hidden] { display: none; }
.stage { display: none; }
.board-wrap.is-3d { background: none; box-shadow: none; padding: 8px; }
.board-wrap.is-3d::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--acc1) 45%, transparent), transparent); filter: blur(18px); opacity: .55; pointer-events: none; }
.board-wrap.is-3d .board { opacity: 0; pointer-events: none; }
.board-wrap.is-3d .stage { display: block; position: absolute; inset: -2px; }
.board-wrap.is-3d .board3d { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; -webkit-tap-highlight-color: transparent; }
.board-wrap.is-3d .board3d:active { cursor: grabbing; }
.board-wrap.is-3d.won .cell { animation: none; }
.board-wrap.is-3d .pause-cover { inset: 0; background: rgba(7,6,11,.92); }

/* ---------- Themed pieces (instead of digits) ---------- */
.view-bar { flex-wrap: wrap; justify-content: flex-start; }
.view-bar .reset-view { margin-left: auto; }
.seg[hidden], .view-bar .hint-btn[hidden] { display: none; }
.view-bar .hint-btn { min-height: 44px; background: rgba(7,6,11,.7); font-size: .88rem; }
.view-bar .hint-btn[aria-pressed="true"] { background: var(--sun); color: var(--ink); border-color: var(--ink); }
@media (max-width: 520px) {
  .seg button { padding: 0 11px; font-size: .86rem; }
  .view-bar { gap: 8px; }
}
/* row 1: board view + Reset view; row 2: Pieces / Numbers + tags */
.view-bar .view-seg { order: 0; }
.view-bar .reset-view { order: 1; }
.view-bar .piece-seg { order: 2; }
.view-bar .hint-btn { order: 3; }
.view-bar:has(.reset-view:not([hidden]))::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
.cell .v .pc { display: block; width: 100%; height: 100%; }
.game.pieces .cell .v:not(:empty) { position: relative; display: grid; place-items: center; width: 90%; height: 90%; box-sizing: border-box; border-radius: 22%; padding: 4%; }
.game.pieces .cell:not(.user) .v:not(:empty) { background: #fff; border: 2px solid var(--ink); box-shadow: 0 2px 0 rgba(7,6,11,.35); }
.game.pieces .cell.user .v:not(:empty) { background: rgba(255,255,255,.35); border: 2px dashed var(--violet-deep); }
.game.pieces .cell.conflict .v:not(:empty), .game.pieces .cell.wrong .v:not(:empty) { border: 3px solid #c4002f; }
.game.pieces .cell.wrong .v { text-decoration: none; }
.game.pieces .cell .v .dg { display: none; }
.game.pieces.piece-hints .cell .v .dg { display: grid; place-items: center; position: absolute; right: -5%; bottom: -5%; width: 36%; height: 36%; border-radius: 50%;
  background: var(--ink); color: #fff; border: 1.5px solid #fff; font: 800 calc(var(--cell) * .2)/1 var(--font-body); }
.game.pieces .cell.wrong .v .dg { background: #c4002f; }
.pad.pieces button { display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; padding: 11px 1px 3px; height: clamp(60px, calc(var(--bw) * .17), 76px); }
.pad.pieces button .pc { width: min(88%, 38px); height: auto; aspect-ratio: 1; }
.pad.pieces button .pn { font: 800 .72rem/1 var(--font-body); }
.pad.pieces button small { top: 2px; bottom: auto; right: 3px; font-size: .58rem; }
.pad.pieces.notes-mode button .pc { opacity: .45; }

/* ---------- Logo images ---------- */
.credit .mark { height: 1.35em; width: auto; vertical-align: -.32em; margin: 0 .15em; }
.site-footer .foot-logo { height: 30px; width: auto; vertical-align: middle; margin-right: 8px; }
.sheet-head .wordmark { height: 22px; width: auto; vertical-align: -3px; margin-right: 6px; }

/* ---------- Dokuri promo ---------- */
.dokuri { position: relative; overflow: hidden; isolation: isolate; display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; width: 100%; max-width: 728px; padding: 18px 20px; border-radius: 24px; color: var(--text); background: linear-gradient(135deg, rgba(98,54,224,.92), rgba(20,12,44,.95) 60%); border: 2px solid rgba(255,255,255,.18); box-shadow: 6px 6px 0 var(--acc1); }
.dokuri svg { width: 92px; height: 92px; }
.dokuri .kick { display: inline-block; font: 800 .72rem/1 var(--font-body); letter-spacing: .14em; text-transform: uppercase; background: var(--sun); color: var(--ink); padding: 5px 9px; border-radius: 999px; margin-bottom: 6px; }
.dokuri h2, .dokuri h3 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 0 0 .25em; color: #fff; }
.dokuri p { margin: 0 0 10px; color: #e9e3f7; font-size: .97rem; }
.dokuri .btn { min-height: 40px; padding: 8px 16px; font-size: .95rem; }
.dokuri--wide { max-width: none; grid-template-columns: auto 1fr auto; padding: 24px 28px; }
.dokuri--wide svg { width: 130px; height: 130px; }
@media (max-width: 640px) { .dokuri--wide { grid-template-columns: auto 1fr; } .dokuri--wide .dk-cta { grid-column: 1 / -1; } .dokuri svg { width: 72px; height: 72px; } }

/* ---------- Theme preview page ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.theme-card { background: rgba(20,16,32,.88); border: 1px solid rgba(255,255,255,.14); border-radius: 20px; padding: 16px; }
.theme-card.active { outline: 3px solid var(--sun); }
.theme-card h3 { margin: 0 0 4px; }
.theme-card .when { font-size: .85rem; color: var(--text-dim); margin: 0 0 8px; }
.theme-card .sw { display: flex; gap: 6px; margin: 8px 0 12px; }
.theme-card .sw i { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--ink); }
.theme-card .links { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-card .links a { font-weight: 700; font-size: .9rem; padding: 6px 12px; border-radius: 999px; background: var(--ink-3); color: var(--text); text-decoration: none; }
.theme-card .links a:hover { background: var(--violet-deep); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
  .scene-svg * { animation: none !important; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 0.5in; }
  body { background: #fff !important; color: #000; font-size: 12pt; }
  .site-header, .site-footer, .promo, .ad-slot, .play-side, .tools, .pad, .more-row, .icon-btn, .celebrate, .confetti, .skip-link, .art-head .art, .print-controls, .no-print, .solved-banner { display: none !important; }
  .art-head, .art-head--compact { padding: 0 0 12px !important; min-height: 0 !important; }
  .art-head h1, .art-head .lede, .art-head .kicker { color: #000 !important; text-shadow: none; background: none; padding: 0; font-size: 18pt; }
  .art-head .lede { font-size: 11pt; }
  .hl-pink, .hl-blue { background: none; }
  .play-layout { display: block; padding: 0; }
  .game { --bw: 6.8in; width: 6.8in; margin: 0 auto; color: #000; }
  .game-bar { color: #000; }
  .timer { background: none; color: #000; }
  .game-no { color: #000; }
  .badge { background: none !important; }
  .board-wrap { background: none; box-shadow: none; padding: 0; }
  .board { border: 4px solid #000; border-radius: 0; }
  .cell, .cell.t0, .cell.t1, .cell.t2, .cell.sel { --tint: #fff; background: #fff !important; background-image: none !important; box-shadow: none !important; color: #000 !important; }
  .board { gap: 0; background: #fff; }
  .cell { border-right: 1.5px solid #000; border-bottom: 1.5px solid #000; margin: 0 !important; }
  .cell.c8 { border-right: 0; } .cell.r8 { border-bottom: 0; }
  .cell.c2, .cell.c5 { border-right: 3.5px solid #000; }
  .cell.r2, .cell.r5 { border-bottom: 3.5px solid #000; }
  .cell.user { font-weight: 400; color: #444 !important; }
  .cell .n { display: none; }
  .cell .v .pc { display: none !important; }
  .cell .v, .cell .v .dg { color: inherit !important; text-decoration: none !important; }
  .game.pieces .cell .v:not(:empty), .game.pieces .cell:not(.user) .v:not(:empty), .game.pieces .cell.user .v:not(:empty) { display: inline; width: auto; height: auto; border: 0; background: none; box-shadow: none; padding: 0; }
  .game.pieces .cell .v .dg, .game.pieces.piece-hints .cell .v .dg { display: inline; position: static; width: auto; height: auto; background: none !important; border: 0; color: inherit; font: inherit; }
  .board-wrap.paused .cell .v { visibility: visible; }
  .pause-cover { display: none !important; }
  .stage, .view-bar, .view-hint, .fx-layer, .dokuri, .scene-art { display: none !important; }
  body::before { display: none !important; }
  .board-wrap.is-3d .board { opacity: 1 !important; }
  .board-wrap.is-3d::before { display: none; }
  .art-head::before { display: none; }
  .sheets { display: block; }
  .sheet { width: auto; box-shadow: none; padding: 0; border-radius: 0; break-after: page; page-break-after: always; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .lp-item { break-inside: avoid; page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
