/* Puzzle & word-game skin (Letter Tiles, Crossword, Word Daily, Word Search, Hangman, Anagrams, Sliding Tiles,
 * Nonogram, Pairs, Suit Swap, Mines). Materials, motion and the big win screen, on top of cw-kit.css.
 * Motion uses transforms/opacity only and switches off for reduced motion. */
:root {
  --pz-wood-1: #fbe7b5; --pz-wood-2: #eccb82; --pz-wood-3: #c99a4a; --pz-wood-ink: #3b2a07;
  --pz-paper: #fffdf6; --pz-paper-line: #e8dfc8; --pz-ink: #1d2a33;
  --pz-acrylic-1: #6ea8ff; --pz-acrylic-2: #2f62d8;
  --pz-me: #22b8cf; --pz-rival: #f97316;
  /* Materials as variables, so pages can use them on their own elements: background: var(--pz-wood-bg) */
  --pz-wood-bg: radial-gradient(120% 70% at 30% 0%, rgba(255, 255, 255, .7), transparent 55%), repeating-linear-gradient(97deg, rgba(120, 72, 18, .07) 0 2px, transparent 2px 7px), repeating-linear-gradient(83deg, rgba(120, 72, 18, .05) 0 1px, transparent 1px 13px), linear-gradient(180deg, #fbe7b5, #eccb82 62%, #c99a4a);
  --pz-wood-shadow: inset 0 2px 0 rgba(255, 255, 255, .75), inset 0 -3px 0 rgba(110, 66, 16, .35), inset 0 0 0 1px rgba(110, 66, 16, .25), 0 2px 0 #8a5a1d, 0 4px 7px rgba(40, 20, 0, .28);
  --pz-acrylic-bg: radial-gradient(130% 80% at 25% 0%, rgba(255, 255, 255, .55), transparent 50%), linear-gradient(170deg, #6ea8ff, #2f62d8);
  --pz-acrylic-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -4px 0 rgba(0, 0, 40, .25), 0 3px 0 #1f3f94, 0 6px 12px rgba(10, 30, 90, .3);
  --pz-mint-bg: radial-gradient(130% 80% at 25% 0%, rgba(255, 255, 255, .55), transparent 50%), linear-gradient(170deg, #4fe0a8, #12a072);
  --pz-mint-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), inset 0 -4px 0 rgba(0, 50, 30, .25), 0 3px 0 #0b6e4e, 0 6px 12px rgba(5, 60, 40, .3);
  --pz-tray-bg: linear-gradient(180deg, #b07a3a, #7a4f1e);
  --pz-tray-shadow: inset 0 3px 6px rgba(0, 0, 0, .35), inset 0 -2px 0 rgba(255, 255, 255, .15), 0 4px 0 #5a3812, 0 10px 18px rgba(40, 20, 0, .25);
}
:root[data-theme="dark"], :root:not([data-theme="light"]) { --pz-paper-dark: #1c2a30; }

/* ---------- Wooden letter tile (Letter Tiles, Anagrams, Word Daily keys) ---------- */
.pz-wood, .pz-wood-tile {
  background:
    radial-gradient(120% 70% at 30% 0%, rgba(255, 255, 255, .7), transparent 55%),
    repeating-linear-gradient(97deg, rgba(120, 72, 18, .07) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(83deg, rgba(120, 72, 18, .05) 0 1px, transparent 1px 13px),
    linear-gradient(180deg, var(--pz-wood-1), var(--pz-wood-2) 62%, var(--pz-wood-3));
  color: var(--pz-wood-ink);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .75), inset 0 -4px 0 rgba(110, 66, 16, .35), inset 0 0 0 1px rgba(110, 66, 16, .25), 0 3px 0 #8a5a1d, 0 6px 10px rgba(40, 20, 0, .28);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
/* Clear acrylic tile (Sliding Tiles, typed letters) */
.pz-acrylic {
  background: radial-gradient(130% 80% at 25% 0%, rgba(255, 255, 255, .55), transparent 50%), linear-gradient(170deg, var(--pz-acrylic-1), var(--pz-acrylic-2));
  color: #fff;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -5px 0 rgba(0, 0, 40, .25), 0 4px 0 #1f3f94, 0 8px 14px rgba(10, 30, 90, .3);
  text-shadow: 0 2px 0 rgba(0, 0, 40, .3);
}
/* Paper sheet (Crossword, Nonogram, Word Search) */
.pz-paper {
  background-color: var(--pz-paper);
  background-image:
    radial-gradient(rgba(120, 100, 60, .05) 1px, transparent 1px),
    radial-gradient(rgba(120, 100, 60, .04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, .6), rgba(240, 230, 205, .35));
  background-size: 7px 7px, 11px 11px, 100% 100%;
  background-position: 0 0, 3px 5px, 0 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 10px 28px rgba(60, 45, 10, .18), 0 2px 4px rgba(60, 45, 10, .12);
}
:root[data-theme="dark"] .pz-paper { --pz-paper: #f4ecd6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pz-paper { --pz-paper: #f4ecd6; } }

/* Press state for any tappable game piece */
.pz-press { transition: transform .12s cubic-bezier(.34, 1.56, .64, 1), filter .12s; }
.pz-press:hover { filter: brightness(1.06); }
.pz-press:active { transform: translateY(2px) scale(.96); }
.pz-press:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Motion ---------- */
@keyframes pz-drop { 0% { transform: translateY(-38%) scale(1.15); opacity: 0; } 55% { transform: translateY(4%) scale(1.08, .88); opacity: 1; } 78% { transform: translateY(-2%) scale(.97, 1.04); } 100% { transform: none; } }
@keyframes pz-squash { 0% { transform: scale(1); } 35% { transform: scale(1.14, .86); } 65% { transform: scale(.94, 1.06); } 100% { transform: scale(1); } }
@keyframes pz-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pz-sweep { 0% { transform: translateX(-120%) skewX(-18deg); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateX(220%) skewX(-18deg); opacity: 0; } }
@keyframes pz-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.25); } }
@keyframes pz-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(200%); } }
@keyframes pz-glow { 0% { box-shadow: 0 0 0 0 var(--glow, rgba(255, 201, 77, .8)); } 100% { box-shadow: 0 0 0 14px rgba(255, 201, 77, 0); } }
@keyframes pz-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pz-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.pz-drop { animation: pz-drop .42s cubic-bezier(.3, 1.4, .5, 1) both; }
.pz-squash { animation: pz-squash .32s ease both; }
.pz-glow { animation: pz-glow .7s ease-out; }
/* A light sweep across a found word: add .pz-sweep to the cell; --sweep sets the finder's colour. */
.pz-sweep { position: relative; overflow: hidden; }
.pz-sweep::before { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: linear-gradient(90deg, transparent, var(--sweep, rgba(255, 255, 255, .85)), transparent); animation: pz-sweep .7s ease-out both; animation-delay: var(--sweep-delay, 0s); }

/* Race progress bars from race-room.js: glossy, with a shimmer on the leader. */
.rr-bar { box-shadow: inset 0 2px 3px rgba(0, 0, 0, .15); height: 12px !important; }
.rr-bar i { position: relative; overflow: hidden; background-image: linear-gradient(180deg, rgba(255, 255, 255, .45), transparent 60%) !important; background-color: currentColor; }
.rr-bar i::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent); animation: pz-shimmer 1.6s linear infinite; }
.rr-row.lead .rr-bar i { animation: pz-pulse 1.2s ease-in-out infinite; }

/* ---------- Big win screen ---------- */
.pz-win { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none; }
.pz-win .burst { position: absolute; width: 140vmax; height: 140vmax; background: repeating-conic-gradient(from 0deg, rgba(255, 201, 77, .28) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: pz-spin 9s linear infinite; mask-image: radial-gradient(closest-side, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(closest-side, #000 20%, transparent 70%); }
.pz-win .medal { position: relative; font-size: min(26vw, 150px); filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .3)); animation: pz-medal .8s cubic-bezier(.3, 1.6, .5, 1) both; }
.pz-win .title { position: absolute; top: calc(50% + min(16vw, 95px)); font-family: var(--display); font-weight: 800; font-size: min(9vw, 48px); color: #fff; background: rgba(16, 42, 51, .88); border-radius: 999px; padding: 8px 24px; box-shadow: 0 0 0 3px #ffc94d, 0 10px 24px rgba(0, 0, 0, .3); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); animation: pz-in .5s .25s cubic-bezier(.3, 1.6, .5, 1) both; text-align: center; max-width: calc(100vw - 32px); }
@keyframes pz-spin { to { transform: rotate(360deg); } }
@keyframes pz-medal { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.15) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }

@media (prefers-reduced-motion: reduce) {
  .pz-drop, .pz-squash, .pz-glow, .pz-sweep::before, .rr-bar i::after, .rr-row.lead .rr-bar i, .pz-win .burst, .pz-win .medal, .pz-win .title { animation: none !important; }
  .pz-press:active { transform: none; }
}
html.cw-reduce .pz-drop, html.cw-reduce .pz-squash, html.cw-reduce .pz-sweep::before, html.cw-reduce .pz-win .burst { animation: none !important; }
