/* Patches board. Tokens from style.css (Moonlit). Eight clue colours (--pc0…7 main, --pcs0…7 soft fill), a dashed grid
 * that disappears on the win, patches tinted in their clue's colour. */
:root {
  --pc0: #6d66e0; --pc1: #1f9e8a; --pc2: #e0644f; --pc3: #d9a12e; --pc4: #3b8fd9; --pc5: #d2559a; --pc6: #6fa83a; --pc7: #8b5fbf;
  --pcs0: #e6e4fb; --pcs1: #d8f2ed; --pcs2: #fbe1dc; --pcs3: #fbeed0; --pcs4: #dcebfa; --pcs5: #f9dfec; --pcs6: #e5f2d6; --pcs7: #ece2f6;
  --pt-grid: #b9b3d9; --pt-dim: rgba(27, 26, 63, .32); --pt-mark-ink: #ffffff;
}
[data-theme='dark'] {
  --pc0: #9a94ff; --pc1: #4cc9b3; --pc2: #ff8a76; --pc3: #f2c25a; --pc4: #6cb2ff; --pc5: #f07cbd; --pc6: #9ad45c; --pc7: #b48ae6;
  --pcs0: #2c2a63; --pcs1: #17403a; --pcs2: #4a2a26; --pcs3: #443620; --pcs4: #1f3350; --pcs5: #46243a; --pcs6: #2a3d1c; --pcs7: #362a4d;
  --pt-grid: #4a4880; --pt-dim: rgba(0, 0, 0, .45); --pt-mark-ink: #0f0e24;
}

.pt { width: 100%; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; --cs: 52px; --n: 6; --rows: 6; }
.pt-stage { position: relative; width: fit-content; margin: 0 auto; }
.pt-board { display: grid; grid-template-columns: repeat(var(--n), var(--cs)); grid-template-rows: repeat(var(--rows), var(--cs)); position: relative; touch-action: none; border-radius: 14px; overflow: hidden; background: var(--surface); cursor: crosshair; outline: none; }
.pt-board:focus-visible { box-shadow: 0 0 0 3px var(--accent-2); }
.pc { width: var(--cs); height: var(--cs); position: relative; transition: background-color .15s ease; }
.pc.cur { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 6px; z-index: 5; }

/* layers */
.pt-lines, .pt-patches, .pt-marks { position: absolute; inset: 0; pointer-events: none; }
.pt-lines { z-index: 1; overflow: visible; transition: opacity .3s ease; }
.pt-patches { z-index: 2; } .pt-marks { z-index: 3; }
.pt-lines .grid { stroke: var(--pt-grid); stroke-width: 1; stroke-dasharray: 3 3; fill: none; }
.pt-lines .frame { fill: none; stroke: var(--line-strong); stroke-width: 2; }

/* clue markers: square = solid square, tall/wide = solid rectangle, any = two translucent rectangles crossed */
.pm { position: absolute; width: var(--cs); height: var(--cs); display: grid; place-items: center; transition: opacity .2s ease, transform .2s cubic-bezier(.3, 1.4, .5, 1); }
.pm i { grid-area: 1 / 1; display: block; background: var(--pc); border-radius: max(4px, calc(var(--cs) * .1)); box-shadow: 0 2px 4px rgba(0, 0, 0, .12); }
.pm.square i:first-child { width: 58%; height: 58%; }
.pm.tall i:first-child { width: 44%; height: 74%; }
.pm.wide i:first-child { width: 74%; height: 44%; }
.pm.square i + i, .pm.tall i + i, .pm.wide i + i { display: none; }
.pm.any i { background: color-mix(in srgb, var(--pc) 34%, transparent); box-shadow: none; border: 1.5px solid var(--pc); }
.pm.any i:first-child { width: 44%; height: 74%; }
.pm.any i + i { width: 74%; height: 44%; }
.pm b { grid-area: 1 / 1; color: var(--pt-mark-ink); font-family: var(--display); font-weight: 800; font-size: max(11px, calc(var(--cs) * .34)); line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.pm.any b { color: var(--pc); text-shadow: none; }
.pm.taken { opacity: 0; transform: scale(.55); }
.pm.hl { z-index: 6; }
.pm.hl i { animation: ptpulse .8s ease-in-out infinite; }
.pm.hl.any i { border-style: dashed; }
@keyframes ptpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* placed patches */
.pp { position: absolute; box-sizing: border-box; border: 2.5px solid var(--pc); background: color-mix(in srgb, var(--pc) 16%, transparent); border-radius: 8px; display: grid; place-items: center; transition: background-color .25s ease, border-color .2s ease, opacity .16s ease, transform .16s ease; }
.pp .badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 6px; background: var(--pcs); color: var(--pc); border: 1px solid var(--pc); font-family: var(--body); font-weight: 800; font-size: 12px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; transition: opacity .2s ease; }
.pt.no-badges .pp .badge { opacity: 0; }
.pp.bad { border-style: dashed; border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pp.bad .badge { color: var(--bad); border-color: var(--bad); background: var(--surface); }
.pp.in { animation: ptin .2s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes ptin { 0% { transform: scale(.88); opacity: .5; } 60% { transform: scale(1.03); opacity: 1; } 100% { transform: scale(1); } }
.pp.out { opacity: 0; transform: scale(.92); }
.pp.revealed { border-style: dashed; border-color: var(--ink-faint); background: transparent; }
.pp.revealed .badge { color: var(--ink-faint); border-color: var(--ink-faint); background: transparent; }

/* drag preview */
.pt-preview { position: absolute; z-index: 4; pointer-events: none; box-sizing: border-box; border-radius: 8px; transition: left .06s linear, top .06s linear, width .06s linear, height .06s linear, opacity .13s ease, transform .13s ease; }
.pt-preview[hidden] { display: none; }
.pt-preview.ok { border: 2.5px solid var(--pc); background: color-mix(in srgb, var(--pc) 12%, transparent); }
.pt-preview.no { border: 2px dashed var(--ink-faint); background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.pt-preview.shrink { opacity: 0; transform: scale(.85); }

/* hint: dim everything except the cells and the clue the hint talks about */
.pt-stage.hinting .pc:not(.hl) { background: var(--pt-dim); }
.pt-stage.hinting .pp:not(.hl), .pt-stage.hinting .pm:not(.hl) { opacity: .35; }
.pt-stage.hinting .pm.taken:not(.hl) { opacity: 0; }
.pc.hl { z-index: 5; box-shadow: inset 0 0 0 3px var(--accent-2); border-radius: 6px; background: color-mix(in srgb, var(--accent-2) 14%, transparent); }
.pp.hl { z-index: 5; }
.pt-hint { margin: 12px auto 0; max-width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-btn); padding: 10px 12px; font-size: 14px; color: var(--ink); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; line-height: 1.4; animation: hintin .25s cubic-bezier(.3, 1.2, .5, 1); }
.pt-hint[hidden] { display: none; }
.pt-hint .ic { width: 22px; height: 22px; flex: none; color: var(--accent-2); }
.pt-hint .ic svg { width: 22px; height: 22px; }
.pt-hint p { margin: 0; flex: 1 1 200px; }
.pt-hint .acts { display: flex; gap: 6px; flex: none; margin-left: auto; }
@keyframes hintin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* win: the dashed grid disappears, patches light up in the order they were placed, glow + confetti */
.pt-board.won ~ .pt-lines .grid { opacity: 0; }
.pt-stage.won .pt-lines .grid { opacity: 0; transition: opacity .3s ease; }
.pp.lit { animation: ptlit .5s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, 0s); }
@keyframes ptlit { 0% { transform: scale(1); background-color: color-mix(in srgb, var(--pc) 16%, transparent); } 40% { transform: scale(1.04); background-color: color-mix(in srgb, var(--pc) 55%, transparent); } 100% { transform: scale(1); background-color: color-mix(in srgb, var(--pc) 38%, transparent); } }
.pt-stage.won .pp .badge { opacity: 0; transition-delay: .4s; }
.pt-board.won.quiet ~ .pt-patches .pp { animation: none; background-color: color-mix(in srgb, var(--pc) 38%, transparent); }
.pt-stage::after { content: ""; position: absolute; inset: -12%; border-radius: 50%; pointer-events: none; z-index: 6; background: radial-gradient(circle, rgba(255, 236, 190, .75), rgba(233, 181, 74, .25) 45%, transparent 70%); opacity: 0; }
.pt-stage.glow::after { animation: ptglow 2s ease-out both; }
@keyframes ptglow { 0% { opacity: 0; transform: scale(.7); } 22% { opacity: .85; transform: scale(1); } 100% { opacity: 0; transform: scale(1.15); } }
[data-theme='dark'] .pt-stage::after { background: radial-gradient(circle, rgba(242, 194, 90, .5), rgba(154, 148, 255, .2) 45%, transparent 70%); mix-blend-mode: screen; }
.pt-board.locked { cursor: default; }
.pt-fx { position: absolute; inset: -60px -30px -30px; width: calc(100% + 60px); height: calc(100% + 90px); pointer-events: none; z-index: 30; }
.pt-help { text-align: center; font-size: 12px; color: var(--ink-faint); margin: 10px 0 0; }

/* legend (how to play + under the board) */
.pt-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; margin: 12px auto 0; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.pt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pt-legend .pm { position: static; width: 26px; height: 26px; --cs: 26px; --pc: var(--ink-soft); }
.pt-legend .pm i { box-shadow: none; }

/* page bits (same look as the other games) */
.pt-page .board-wrap { padding: 14px; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon { position: relative; }
.btn-icon .cnt { position: absolute; right: -5px; top: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.btn-icon .cnt:empty { display: none; }
.snd-off .ic-on, .btn-icon:not(.snd-off) .ic-off { display: none; }
.q-settings { position: static; }
.gp-bar { position: relative; }
.q-pop { position: absolute; right: 0; top: calc(100% - 4px); max-width: calc(100vw - 32px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn); box-shadow: var(--shadow-hover); padding: 6px 4px; min-width: 240px; }
.q-pop[hidden] { display: none; }
.q-pop label { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.q-pop .sw { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background .15s ease; }
.q-pop .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.q-pop input { position: absolute; opacity: 0; pointer-events: none; }
.q-pop input:checked + .sw { background: var(--good); }
.q-pop input:checked + .sw::after { transform: translateX(16px); }
.q-pop input:focus-visible + .sw { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.q-meta { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.q-meta .pill { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.q-pick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px; }
.q-pick button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.q-pick button[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.q-pick .sep { width: 100%; height: 0; }
.pt-demo { margin: 14px 0 6px; }
@media (max-width: 480px) { .pt-page .board-wrap { padding: 8px; } .pt-page .wrap-game { padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { .pp.in, .pp.lit, .pm.hl i, .pt-stage.glow::after { animation: none !important; } }
