/* Play online — minigames on free-printable pages. Builds on free-printables.v01.css tokens. */
.play-jump { margin: 18px 0 0; font-weight: 700; }
.play-jump a { color: var(--violet); text-underline-offset: 4px; }

.play-online { padding: 72px 0 88px; background: var(--paper); border-top: 1px solid var(--line); scroll-margin-top: 72px; }
.play-head { max-width: 760px; margin: 0 auto 22px; text-align: center; }
.play-title { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 600; line-height: 1.02; letter-spacing: -.045em; }
.play-hint { margin: 12px auto 0; max-width: 620px; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.6; }
.play-stage { max-width: 760px; margin-inline: auto; }

/* HUD: what is happening (left) · quiet tools (right) */
.play-hud { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.play-status { margin: 0; min-height: 1.5em; font-weight: 700; font-size: 1.02rem; }
.play-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.play-tool, .color-zoom button, .roll-mode-btn {
  min-height: 40px; padding: .4rem .85rem; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font: inherit; font-size: .88rem; font-weight: 650; cursor: pointer;
}
.play-tool:hover, .color-zoom button:hover, .roll-mode-btn:hover { border-color: var(--ink); }
.play-tool:disabled { opacity: .4; cursor: default; border-color: var(--line); }
.play-tool:focus-visible, .play-stage button:focus-visible, .play-stage svg:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

.play-board { position: relative; border: 1px solid var(--line); background: var(--cream); padding: clamp(10px, 2.4vw, 22px); }
.play-board svg { display: block; width: 100%; height: auto; max-height: 76vh; user-select: none; -webkit-user-select: none; }

/* Win banner: status, proof, one action — above the board so the result stays visible */
.play-win { display: flex; align-items: center; gap: 14px 18px; margin-bottom: 12px; padding: 14px 18px; border: 2px solid var(--ink); background: var(--lilac-soft); animation: play-in .3s ease both; }
.play-win img { width: 64px; height: 64px; flex: none; object-fit: contain; }
.play-win-copy { flex: 1; min-width: 0; }
.play-win-title { margin: 0; font-size: 1.45rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.play-win-detail { margin: 2px 0 0; color: var(--ink-soft); }
.play-win .button { flex: none; }
@media (max-width: 520px) { .play-win { flex-wrap: wrap; } .play-win .button { width: 100%; } }
@keyframes play-in { from { opacity: 0; } }

/* Maze */
.maze-svg { touch-action: none; cursor: pointer; }
.maze-wall { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.maze-trail { fill: none; stroke: #f39ac6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.maze-token-halo { fill: var(--paper); stroke: var(--violet); stroke-width: 2.5; }
.maze-goal-halo { fill: var(--lilac); }
.maze-token { transition: transform .12s ease-out; }

/* Dot to dot */
.dots-svg { touch-action: none; cursor: pointer; background: var(--paper); }
.dots-guides > * { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dots-line { fill: none; stroke: var(--violet); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.dots-shape { opacity: 0; transition: opacity .8s ease; pointer-events: none; }
.dots-shape.is-on { opacity: .3; }
.dots-pin { fill: var(--ink); }
.dots-label { fill: var(--ink); font: 600 14px "Avenir Next", Avenir, system-ui, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.dots-dot.is-done .dots-pin { fill: var(--violet); }
.dots-dot.is-done .dots-label { fill: var(--ink-soft); opacity: .55; }
.dots-dot.is-wrong .dots-pin { animation: play-wrong .45s ease; }
.dots-hint { fill: none; stroke: #e0207f; stroke-width: 2.5; opacity: 0; pointer-events: none; }
.dots-hint.is-on { opacity: 1; animation: play-pulse 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes play-pulse { 50% { transform: scale(1.35); opacity: .45; } }
@keyframes play-wrong { 0%, 100% { fill: var(--ink); } 30%, 70% { fill: #d4213d; } }

/* Spot the difference */
.play-spot .play-board { padding: 0; background: var(--paper); }
.spot-wrap { position: relative; max-width: 560px; margin-inline: auto; }
.spot-wrap img { width: 100%; height: auto; }
.spot-svg { position: absolute; inset: 0; width: 100%; height: 100% !important; max-height: none !important; cursor: pointer; }
.spot-found { fill: none; stroke: #d4213d; stroke-width: 7; animation: play-in .25s ease both; }
.spot-miss path { stroke: var(--ink-soft); stroke-width: 6; stroke-linecap: round; animation: play-fade .7s ease forwards; }
@keyframes play-fade { 60% { opacity: 1; } to { opacity: 0; } }

/* Memory */
.memory-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: clamp(6px, 1.6vw, 12px); }
.memory-card { aspect-ratio: 1; padding: 0; border: 0; background: none; perspective: 700px; cursor: pointer; }
.memory-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .4s ease; }
.memory-card.is-up .memory-inner { transform: rotateY(180deg); }
.memory-back, .memory-front { position: absolute; inset: 0; display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 14px; }
.memory-back { background: var(--lilac); border: 2px solid var(--violet); }
.memory-back img { width: 46%; opacity: .9; }
.memory-front { transform: rotateY(180deg); background: var(--paper); border: 5px solid var(--card); }
.memory-front img { width: 80%; height: 80%; object-fit: contain; }
.memory-card.is-match .memory-front::after { content: "✓"; position: absolute; top: 4px; right: 7px; color: var(--ink); font-weight: 800; }
.memory-card:disabled { cursor: default; }

/* Roll & color */
.roll-boards { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 2.4vw, 22px); }
.roll-board { padding: 12px; border: 2px solid transparent; background: var(--paper); transition: border-color .2s, opacity .2s; opacity: .6; }
.roll-board.is-active { border-color: var(--ink); opacity: 1; }
.roll-p0 { --player: #ffd23f; } .roll-p1 { --player: #ff8a1f; }
.roll-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-weight: 750; font-size: 1.1rem; }
.roll-head img { width: 44px; height: 44px; object-fit: contain; }
.roll-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1.5px solid var(--ink); border-left: 1.5px solid var(--ink); }
.roll-cell { aspect-ratio: 1; border: 0; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); font: 600 clamp(1.3rem, 4.4vw, 2.2rem) "Avenir Next", Avenir, system-ui, sans-serif; cursor: pointer; }
.roll-cell.is-colored { background: var(--player); }
.roll-cell.is-colored::after { content: " ✓"; font-size: .5em; vertical-align: super; }
.roll-cell.is-wrong { animation: play-shake .4s ease; }
.roll-cell:disabled { cursor: default; color: var(--ink); }
@keyframes play-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.roll-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 18px; margin-top: 18px; }
.roll-mode { display: inline-flex; }
.roll-mode-btn + .roll-mode-btn { border-left: 0; }
.roll-mode-btn[aria-checked="true"] { background: var(--lilac); border-color: var(--ink); }
.roll-dice { display: flex; gap: 10px; }
.roll-die { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; width: 52px; height: 52px; padding: 8px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); }
.roll-die[hidden] { display: none; }
.roll-die i { border-radius: 50%; }
.roll-die i.on { background: var(--ink); }
.roll-die.is-rolling { animation: play-roll .45s ease; }
@keyframes play-roll { 40% { transform: rotate(-14deg) scale(1.08); } 70% { transform: rotate(10deg); } }
.roll-go { min-width: 140px; font-size: 1.05rem; }
.roll-go:disabled { opacity: .45; cursor: default; transform: none; background: var(--ink); }

/* Coloring */
.color-board { background: var(--paper); padding: clamp(8px, 2vw, 18px); overflow: hidden; }
.color-canvas { min-height: 240px; }
.color-svg { touch-action: manipulation; cursor: pointer; }
.play-color .color-svg .f { transition: fill .15s ease; }
.color-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.color-zoom button { width: 42px; padding: 0; font-size: 1.2rem; box-shadow: 0 2px 10px rgba(41, 20, 80, .12); }
.color-palette { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: clamp(5px, 1.6vw, 8px); max-width: 560px; margin: 14px auto 0; }
.color-swatch { aspect-ratio: 1; min-width: 0; border: 2px solid rgba(41, 20, 80, .25); border-radius: 50%; background: var(--swatch); cursor: pointer; transition: transform .12s ease; }
.color-swatch[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); transform: scale(1.06); }
.color-swatch:last-child { background: linear-gradient(135deg, #fff 0 45%, var(--line) 45% 55%, #fff 55%); }

@media (max-width: 640px) {
  .play-online { padding: 52px 0 64px; }
  .play-head { text-align: left; }
  .memory-grid { grid-template-columns: repeat(4, 1fr); }
  .roll-boards { grid-template-columns: 1fr; }
  .roll-board:not(.is-active) .roll-grid { display: none; }
  .roll-board:not(.is-active) { padding-block: 8px; }
  .roll-board:not(.is-active) .roll-head { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .play-stage *, .play-stage *::before, .play-stage *::after { animation: none !important; transition: none !important; }
}

/* Maze levels, step counter and congratulation popup */
.play-count { margin: 0 auto 0 0; padding: .2rem .7rem; border: 1px solid var(--line); background: var(--paper); font-weight: 750; font-variant-numeric: tabular-nums; }
.maze-levels { display: inline-flex; margin-right: 6px; }
.maze-levels .roll-mode-btn + .roll-mode-btn { border-left: 0; }
.play-popup { width: min(420px, calc(100% - 32px)); padding: 30px 26px 24px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); text-align: center; overflow: hidden; box-shadow: var(--shadow); }
.play-popup::backdrop { background: rgba(41, 20, 80, .45); }
.play-popup[open] { animation: play-pop .35s cubic-bezier(.2, .9, .3, 1.3) both; }
.play-popup-pics { display: flex; justify-content: center; gap: 4px; }
.play-popup-pics img { width: 88px; height: 88px; object-fit: contain; animation: play-hop .9s ease-in-out .2s 2 both; }
.play-popup-pics img + img { animation-delay: .35s; }
.play-popup h2 { margin: 10px 0 6px; font-size: 2rem; line-height: 1.1; letter-spacing: -.03em; }
.play-popup-lead { margin: 0; font-size: 1.1rem; font-weight: 650; }
.play-popup-note { margin: 4px 0 0; color: var(--ink-soft); }
.play-popup-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 20px; }
.play-confetti { position: absolute; inset: 0; pointer-events: none; }
.play-confetti i { position: absolute; top: -14px; left: var(--x); width: 8px; height: 13px; background: var(--c); transform: rotate(var(--r)); animation: play-fall 1.8s var(--d) ease-in forwards; }
@keyframes play-fall { to { transform: translateY(520px) rotate(calc(var(--r) + 600deg)); opacity: 0; } }
@keyframes play-pop { from { transform: scale(.85); opacity: 0; } }
@keyframes play-hop { 50% { transform: translateY(-10px); } }
@media (max-width: 640px) { .play-count { order: -1; } .maze-levels { width: 100%; margin: 0; } .maze-levels .roll-mode-btn { flex: 1; } }
