/* Ricochet. One accent family (lime) for beam, crystal and primary actions on a #121713 base.
   Type scale: 12 / 13 / 15 / 18 / 22 / 30 / 40. Nothing is set below 12px. */
:root {
  color-scheme: dark;
  --bg: #121713;
  --surface: #1a211b;
  --surface-hover: #222c22;
  --line: #333f32;
  --text: #eef2e8;
  --muted: #a3ad9b;
  --lime: #d3f78b;
  --hot: #f6ffe0;
  --deep: #9fd04f;
  --violet: #bba8f4;
  --fs-12: 12px; --fs-13: 13px; --fs-15: 15px; --fs-18: 18px; --fs-22: 22px; --fs-30: 30px; --fs-40: 40px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-15)/1.5 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; }
button, a, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }
button:disabled { cursor: default; opacity: .35; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
::selection { background: var(--lime); color: var(--bg); }

/* Header */
.header { max-width: 1008px; margin: auto; height: 76px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 9px; align-items: center; min-height: 44px; font-size: var(--fs-22); letter-spacing: -.8px; font-weight: 700; }
.brand svg { width: 27px; height: 27px; color: var(--lime); }
.header nav { display: flex; gap: 4px; }
.header nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 15px; border-radius: 8px; color: var(--muted); font-size: var(--fs-15); }
.header nav a:hover { color: var(--text); background: var(--surface); }
.header nav a.active, .header nav a[aria-current="page"] { color: var(--lime); background: #d3f78b0d; }
.header-tools { display: flex; gap: 8px; }
.icon-button { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: transparent; font-size: var(--fs-18); color: var(--muted); }
.icon-button:hover { background: var(--surface-hover); color: var(--text); }
#main-content { max-width: 1008px; margin: 0 auto; padding: 32px 24px 20px; }
body.playing #main-content { max-width: 640px; padding-top: 20px; }
.page-heading { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
body.playing .page-heading { margin-bottom: 6px; }
h1 { font-size: var(--fs-30); font-weight: 600; letter-spacing: -.8px; line-height: 1.2; margin: 0; }
#collection-progress { color: var(--muted); font-size: var(--fs-15); white-space: nowrap; }
.instruction { color: var(--muted); margin: 0 0 14px; font-size: var(--fs-15); }
.daily-meta { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0 14px; color: var(--muted); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.daily-meta .text-button { color: var(--lime); }
.newcomer { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; margin: 0 0 12px; padding: 8px 14px; border: 1px solid #4c603b; border-radius: 10px; background: #d3f78b0a; color: var(--lime); font-size: var(--fs-15); }
.newcomer:hover { background: #d3f78b14; }

/* Library */
.daily-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 56px; padding: 14px 18px; border: 1px solid #4c603b; border-radius: 10px; background: #d3f78b0a; margin-bottom: 24px; }
.daily-row > span:first-child { color: var(--muted); }
.daily-row strong { color: var(--text); font-weight: 500; margin-left: 12px; }
.daily-row > span:last-child { color: var(--lime); white-space: nowrap; }
.daily-row:hover { background: #d3f78b14; }
.filter-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.filter-tabs button { min-height: 44px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); padding: 8px 15px; font-size: var(--fs-15); }
.filter-tabs button:hover { color: var(--text); }
.filter-tabs button.active { background: var(--surface-hover); border-color: var(--line); color: var(--text); }
.puzzle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.puzzle-card { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.puzzle-card:hover { border-color: #6b8254; background: #1f281f; }
.puzzle-preview { width: 100%; height: 152px; }
.card-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-top: 1px solid #2b352a; }
.puzzle-name { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: var(--fs-15); line-height: 1.4; }
.puzzle-name b { color: var(--muted); font-size: var(--fs-12); font-weight: 500; }
.stars { display: inline-flex; gap: 2px; color: #65735b; flex-shrink: 0; font-size: var(--fs-15); line-height: 1; }
.star-earned { color: var(--lime); }

/* Board. Tiles are static between moves; the beam plays in its own stacked layer. */
.board-shell { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.board-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
#board-mode { color: var(--text); }
.board-stage { padding: 6px 12px 0; }
.board-wrap { position: relative; width: 100%; max-width: min(100%, max(300px, calc(100dvh - 330px))); margin: 0 auto; }
.board { width: 100%; height: auto; overflow: visible; touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
.beam-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.board .interactive { cursor: pointer; }
.board .interactive:hover .tile { stroke: #86a362; }
.board .interactive:active .tile { fill: #2b3728; }
.board .interactive:focus-visible { outline: none; }
.board .interactive:focus-visible .tile { stroke: var(--lime); stroke-width: 3; }
.mirror { pointer-events: none; }
.mirror-halo { stroke-width: 14; stroke-linecap: round; opacity: .1; }
/* Movable mirrors beat three times when a board opens, then hold still. */
.mirror.pulse .mirror-halo { animation: mirror-pulse 1.5s ease-in-out calc(var(--i, 0) * 80ms + .3s) 3; }
@keyframes mirror-pulse { 50% { opacity: .42; stroke-width: 20; } }
.mirror.snap { transform-box: fill-box; transform-origin: center; animation: mirror-snap .17s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes mirror-snap { from { transform: rotate(-90deg) scale(.9); } }
.ring circle { stroke: var(--violet); }
.ring .ring-dot { fill: var(--violet); stroke: none; }
.ring.charged circle { stroke: var(--lime); }
.ring.charged .ring-dot { fill: var(--hot); }
/* A ring keeps its uncharged colour until the beam head reaches it. */
.ring.wait circle { animation: ring-wait var(--d) steps(1, end) backwards; }
.ring.wait .ring-dot { animation: ring-dot-wait var(--d) steps(1, end) backwards; }
@keyframes ring-wait { from { stroke: var(--violet); } }
@keyframes ring-dot-wait { from { fill: var(--violet); } }
.crystal.lit-in { transform-box: fill-box; transform-origin: center; animation: lit-in .5s var(--d) cubic-bezier(.2, .9, .3, 1.25) backwards; }
@keyframes lit-in { from { opacity: 0; transform: scale(.4); } }
.hint-ring { animation: hint-pulse 1s ease-in-out infinite alternate; }
@keyframes hint-pulse { to { opacity: .35; } }
.aim { fill: none; stroke: var(--lime); stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: .1 11; opacity: .5; pointer-events: none; animation: aim-march .9s linear infinite; }
.aim.on { opacity: .95; }
@keyframes aim-march { to { stroke-dashoffset: -11.1; } }
.board-wrap.punch { animation: punch .24s ease-out; }
@keyframes punch { 30% { transform: scale(1.014); } }

/* Beam playback. The resting state of every rule below is the finished shot, so removing animation loses only motion. */
.beam-set polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail { stroke-dasharray: 1; stroke-dashoffset: 0; }
.beam-halo { stroke: var(--c); stroke-width: 17; opacity: .09; }
.beam-glow { stroke: var(--c); stroke-width: 9; opacity: .2; }
.beam { stroke: var(--c); stroke-width: 3.4; }
.beam-hot { stroke: var(--hot); stroke-width: 1.3; }
.play .trail { animation: beam-travel var(--t) linear backwards; }
@keyframes beam-travel { from { stroke-dashoffset: 1; } }
/* Real blur only on the finished, motionless beam, faded in over three steps. */
.beam-bloom { stroke: var(--c); stroke-width: 11; opacity: .5; filter: blur(7px); }
.play .beam-bloom { animation: bloom-in .3s var(--t) steps(3, end) backwards; }
@keyframes bloom-in { from { opacity: 0; } }
.beam-head { opacity: 0; }
.play .beam-head { animation: head-show var(--t) steps(1, end) backwards; }
@keyframes head-show { from { opacity: 1; } }
.head-glow { fill: var(--c); opacity: .35; }
.head-core { fill: var(--hot); }
.muzzle { fill: var(--hot); opacity: 0; transform-box: fill-box; transform-origin: center; }
.play .muzzle { animation: muzzle .28s ease-out; }
@keyframes muzzle { from { opacity: .9; transform: scale(.5); } to { opacity: 0; transform: scale(1.7); } }
.spark { opacity: 0; fill: var(--hot); stroke: var(--hot); stroke-width: 2.4; stroke-linecap: round; transform-box: fill-box; transform-origin: center; }
.spark circle { stroke: none; }
.spark.dull { stroke: var(--c); }
.play .spark { animation: spark .44s var(--d) cubic-bezier(.15, .8, .3, 1); }
@keyframes spark { 0% { opacity: 1; transform: scale(.25); } 60% { opacity: .9; } 100% { opacity: 0; transform: scale(1.25); } }
.mirror-flash { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; opacity: 0; }
.play .mirror-flash { animation: flash .3s var(--d) ease-out; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }
.ring-pop { fill: none; stroke: var(--hot); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.play .ring-pop { animation: ring-pop .55s var(--d) ease-out; }
@keyframes ring-pop { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(2.1); } }
/* Solve: flash on impact, a 90 ms hit-stop, then the crystal shatters to reveal the lit core beneath. */
.burst-flash { fill: var(--hot); opacity: 0; transform-box: fill-box; transform-origin: center; }
.play .burst-flash { animation: burst-flash .5s var(--t) ease-out; }
@keyframes burst-flash { 0% { opacity: 0; transform: scale(.3); } 18% { opacity: .95; } 100% { opacity: 0; transform: scale(1.9); } }
.shard { opacity: 0; transform-box: fill-box; transform-origin: center; }
.play .shard { animation: shard .75s var(--after) cubic-bezier(.15, .75, .3, 1) backwards; }
@keyframes shard { from { opacity: 1; transform: none; } 70% { opacity: .9; } to { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(.35); } }
.burst-wave { fill: none; stroke: var(--c); stroke-width: 4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.play .burst-wave { animation: wave .8s var(--after) cubic-bezier(.1, .7, .3, 1); }
.play .burst-wave.late { animation-delay: calc(var(--after) + .14s); stroke: var(--hot); stroke-width: 2; }
@keyframes wave { from { opacity: .9; transform: scale(.6); } to { opacity: 0; transform: scale(5.2); } }
/* Miss: a marker where the beam stopped, then the path dims. The ghost of it fades after the next move. */
.beam-set.miss { opacity: .5; }
.beam-set.miss.play { animation: miss-dim .5s calc(var(--t) + .75s) ease-out backwards; }
@keyframes miss-dim { from { opacity: 1; } }
.end-mark { fill: none; stroke: var(--hot); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.end-ring { stroke-dasharray: 5 6; }
.play .end-mark { animation: mark-in .25s var(--t) ease-out backwards; }
@keyframes mark-in { from { opacity: 0; } }
.ring-miss { fill: none; stroke: var(--violet); stroke-width: 3; opacity: .9; transform-box: fill-box; transform-origin: center; }
.play .ring-miss { animation: ring-miss .7s var(--t) ease-in-out 3 backwards; }
@keyframes ring-miss { 0% { opacity: 0; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.beam-ghost { fill: none; stroke: var(--c); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 9; }
.beam-set.ghost { opacity: 0; animation: ghost-out 2.2s ease-in; }
@keyframes ghost-out { from { opacity: .45; } }

/* Controls */
.duel-tools { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.tool-button { flex: 1; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: var(--fs-15); color: var(--muted); }
.tool-button:hover { background: var(--surface-hover); }
.tool-button.active { border-color: #819d60; background: #d3f78b0d; color: var(--lime); }
.game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.secondary-tools { display: flex; gap: 4px; }
.quiet-button, .primary-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-size: var(--fs-15); line-height: 1.4; font-weight: 500; }
.quiet-button { background: transparent; color: var(--muted); }
.quiet-button:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }
.primary-button { background: var(--lime); color: #1f2d13; }
.primary-button:hover:not(:disabled) { background: #e1ffad; }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
#fire { min-width: 124px; min-height: 50px; font-size: var(--fs-18); font-weight: 700; box-shadow: 0 0 0 0 #d3f78b00; transition: box-shadow .2s; }
#fire:hover:not(:disabled) { box-shadow: 0 0 22px #d3f78b55; }
.full-width { width: 100%; }
.game-status { min-height: 44px; margin: 12px 3px 0; font-size: var(--fs-15); color: var(--muted); }
.game-status strong { font-weight: 600; color: var(--text); margin-right: 6px; }
.game-status span:empty, .game-status strong:empty { display: none; }
.below-game { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 2px; }
.text-button { border: 0; padding: 9px 0; min-width: 44px; min-height: 44px; background: transparent; color: var(--muted); font-size: var(--fs-13); }
.text-button:hover { color: var(--text); }
#route-panel a, .puzzle-navigation a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; color: var(--muted); font-size: var(--fs-13); }
#route-panel a:hover { color: var(--lime); }
.puzzle-navigation { display: flex; gap: 20px; }
.result-card { padding: 20px; margin-top: 12px; border: 1px solid #526c3d; background: #d3f78b0a; border-radius: 12px; }
.result-card.reveal { animation: rise-in .45s var(--d) cubic-bezier(.2, .8, .3, 1) backwards; }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
.result-title { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.result-title h2 { margin: 0; font-size: var(--fs-22); font-weight: 600; letter-spacing: -.4px; }
.result-title .stars { font-size: var(--fs-22); gap: 5px; }
.result-summary { color: var(--muted); font-size: var(--fs-15); margin: 8px 0 16px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.result-ad { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; color: var(--muted); font-size: var(--fs-12); }

/* Duel */
.opponent-options { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.duel-settings { margin-bottom: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.mode-switch { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 10px; }
.mode-switch button { min-height: 44px; padding: 8px 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: var(--fs-13); }
.mode-switch button.active { background: var(--surface-hover); color: var(--text); }
.difficulty-setting { display: flex; gap: 8px; align-items: center; margin-left: auto; color: var(--muted); font-size: var(--fs-13); }
.difficulty-setting select { max-width: 165px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); padding: 8px 10px; font-size: var(--fs-13); }
.duel-players { width: 100%; display: flex; gap: 10px; }
.duel-player { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: var(--fs-13); }
.duel-player.active { border-color: #7d9365; background: #d3f78b0a; color: var(--text); }
.duel-player strong { font-weight: 500; }
.duel-player small { margin-left: auto; white-space: nowrap; font-size: var(--fs-12); color: var(--muted); }
.player-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex-shrink: 0; }
.player-dot.violet { background: var(--violet); }

/* Footer, dialogs, settings */
footer { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-end; gap: 8px 20px; margin-top: 24px; color: var(--muted); font-size: var(--fs-12); }
#save-notice { margin-right: auto; flex-basis: 100%; overflow-wrap: anywhere; }
dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow: auto; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: #070c09c4; }
dialog h2 { margin: 0 0 20px; font-size: var(--fs-22); letter-spacing: -.5px; font-weight: 600; }
dialog p { color: var(--muted); line-height: 1.6; margin: 0 0 16px; }
dialog .full-width { margin-top: 22px; }
details { border-top: 1px solid var(--line); }
summary { cursor: pointer; padding: 11px 0; font-size: var(--fs-15); }
details p { padding: 0 0 14px; font-size: var(--fs-15); margin-bottom: 0; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 54px; border-bottom: 1px solid var(--line); }
.settings-row input { width: 22px; height: 22px; accent-color: var(--lime); }
.saved-summary { display: flex; gap: 20px; padding: 20px 0 10px; color: var(--muted); font-size: var(--fs-15); }
.small { font-size: var(--fs-13); }
/* Accounts are optional and remain hidden until sign-in is configured. */
.account-dialog { width: min(420px, calc(100% - 24px)); }
.account-dialog h2 { margin-bottom: 10px; }
.account-dialog h2:focus { outline: none; }
.account-dialog .full-width { min-height: 44px; }
.account-dialog #account-google { margin-top: 2px; }
.account-dialog .account-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; font-size: var(--fs-13); text-align: center; }
.account-divider::before, .account-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#account-email-form label { display: block; margin-bottom: 6px; font-size: var(--fs-13); }
#account-email { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 16px; }
#account-email-form .full-width { margin-top: 12px; }
.account-dialog .account-email-address { margin-bottom: 6px; color: var(--text); overflow-wrap: anywhere; }
#account-import-area { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
#account-import-area p { margin-bottom: 8px; }
#account-import-area .full-width { margin-top: 0; }
.account-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }
.account-actions button { min-height: 44px; }
.account-dialog .account-message { margin: 16px 0 0; font-size: var(--fs-13); color: var(--lime); overflow-wrap: anywhere; }
.account-dialog .account-error { color: #f6b9ac; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); width: max-content; padding: 13px 18px; background: #e5efdb; color: #253020; border-radius: 10px; font-size: var(--fs-15); box-shadow: 0 8px 30px #0003; }
.toast:empty { display: none; }
.daily-unavailable { max-width: 480px; padding: 36px 0; margin: auto; text-align: center; }
.daily-unavailable h2 { font-size: var(--fs-22); letter-spacing: -.5px; }
.daily-unavailable p { color: var(--muted); }
.daily-unavailable .result-actions { justify-content: center; }
#daily-load-title:focus { outline: none; }

/* Welcome: the illustration plays the game, so the idea lands before any reading. */
.onboarding .header { max-width: 800px; }
.welcome { max-width: 420px; margin: 0 auto; padding: clamp(0px, 3vh, 28px) 0 24px; text-align: center; }
.welcome-art { width: min(270px, 78%); margin: 0 auto 6px; }
.welcome-art svg { width: 100%; height: auto; }
.demo-beam { fill: none; stroke: var(--lime); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: demo-beam 4.4s linear infinite; }
.demo-glow { stroke-width: 15; stroke-opacity: .12; }
@keyframes demo-beam { 0%, 10% { stroke-dashoffset: 1; opacity: 1; } 36%, 86% { stroke-dashoffset: 0; opacity: 1; } 95%, 100% { stroke-dashoffset: 0; opacity: 0; } }
.demo-lit { opacity: .9; animation: demo-lit 4.4s ease-out infinite; }
@keyframes demo-lit { 0%, 35% { opacity: 0; } 40% { opacity: 1; } 86% { opacity: .9; } 95%, 100% { opacity: 0; } }
.demo-spark path { fill: none; stroke: var(--hot); stroke-width: 2.6; stroke-linecap: round; opacity: 0; transform-box: fill-box; transform-origin: center; animation: 4.4s linear infinite; }
.demo-spark.one path { animation-name: demo-spark-one; }
.demo-spark.two path { animation-name: demo-spark-two; }
@keyframes demo-spark-one { 0%, 16% { opacity: 0; transform: scale(.3); } 17% { opacity: 1; } 25%, 100% { opacity: 0; transform: scale(1.2); } }
@keyframes demo-spark-two { 0%, 29% { opacity: 0; transform: scale(.3); } 30% { opacity: 1; } 38%, 100% { opacity: 0; transform: scale(1.2); } }
.welcome h1 { font-size: var(--fs-40); letter-spacing: -1.6px; }
.welcome p { margin: 10px 0 24px; color: var(--muted); font-size: var(--fs-18); }
.welcome .play-now { width: min(100%, 330px); min-height: 62px; border-radius: 14px; font-size: var(--fs-22); font-weight: 700; gap: 20px; box-shadow: 0 5px 0 #7d9e4e; }
.welcome .play-now:hover { transform: translateY(-1px); }
.welcome-note { display: block; margin-top: 18px; color: var(--muted); font-size: var(--fs-12); }
.welcome-skip { display: inline-flex; align-items: center; min-height: 44px; margin-top: 12px; color: var(--muted); font-size: var(--fs-13); text-decoration: underline; text-underline-offset: 4px; }
.welcome-skip:hover { color: var(--text); }

/* Tutorial */
body.in-tutorial #main-content { max-width: 480px; }
.tutorial-coach { margin: 0 4px 14px; }
.tutorial-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: var(--fs-13); color: var(--muted); }
.tutorial-top > span { color: var(--lime); font-weight: 600; }
.tutorial-top a { display: inline-flex; align-items: center; justify-content: flex-end; min-width: 44px; min-height: 44px; }
.tutorial-top a:hover { color: var(--text); }
.tutorial-coach h1 { font-size: var(--fs-22); letter-spacing: -.5px; line-height: 1.25; }
.tutorial-coach p { margin: 6px 0 0; min-height: 3em; color: var(--muted); font-size: var(--fs-15); }
.in-tutorial .board-wrap { max-width: min(320px, max(220px, calc(100dvh - 380px))); }
.in-tutorial .board-top, .in-tutorial .secondary-tools, .in-tutorial .below-game { display: none; }
.in-tutorial .game-toolbar { justify-content: center; }
/* Once the tutorial is won, Fire has nothing left to do; the next step takes its place. */
.intro-solved .game-toolbar { display: none; }
.intro-solved .result-card { margin-top: 14px; }
.in-tutorial #fire { min-width: 200px; min-height: 54px; }
.in-tutorial .result-card { padding: 0; border: 0; background: transparent; text-align: center; }
.in-tutorial #intro-next { min-height: 56px; font-size: var(--fs-18); font-weight: 700; }
.intro-warmup { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; color: var(--muted); font-size: var(--fs-13); text-decoration: underline; text-underline-offset: 4px; }
.intro-warmup:hover { color: var(--text); }
.tutorial-fire { animation: fire-ready 1.2s ease-in-out infinite alternate; }
@keyframes fire-ready { from { box-shadow: 0 0 0 0 #d3f78b55; } to { box-shadow: 0 0 0 9px #d3f78b00, 0 0 26px #d3f78b55; } }
dialog .replay-tutorial { margin: 0 0 20px; }

/* Results sheet: the score and two next actions, with detail available on demand. */
.share-dialog { width: min(440px, calc(100% - 24px)); padding: 24px 22px 16px; text-align: center; }
.share-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
.share-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 2px 4px; }
.dialog-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: var(--fs-30); line-height: 1; border-radius: 10px; }
.dialog-close:hover { color: var(--text); background: var(--surface-hover); }
.share-dialog h2 { margin: 0 30px 2px; font-size: var(--fs-30); }
.share-dialog h2:focus { outline: none; }
.share-dialog .share-subtitle { margin: 0; font-size: var(--fs-13); }
.share-dialog .share-score { margin: 0; color: var(--text); font-size: var(--fs-18); font-weight: 600; line-height: 1.4; }
.share-score:empty { display: none; }
.share-stars { display: flex; justify-content: center; gap: 12px; margin: 12px 0 10px; font-size: var(--fs-40); line-height: 1; color: #4a5745; }
.share-stars .earned { color: var(--lime); text-shadow: 0 0 20px #d3f78b70; }
.share-stars.reveal .earned { display: inline-block; animation: star-pop .5s calc(.25s + var(--i) * .17s) cubic-bezier(.2, 1.6, .4, 1) backwards; }
@keyframes star-pop { from { opacity: 0; transform: scale(.2) rotate(-40deg); } }
.share-emoji { margin: 14px 0 12px; font-size: var(--fs-22); letter-spacing: 4px; }
.share-chips { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 0; margin: 0; }
.share-chips li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: var(--fs-13); }
.share-chips li.ok { color: var(--text); border-color: #4c603b; background: #d3f78b0d; }
.share-chips li.ok span { color: var(--lime); font-weight: 700; }
.share-dialog .share-streak { margin: 6px 0 0; color: var(--text); font-size: var(--fs-15); }
.share-streak strong { display: inline-block; font-size: var(--fs-18); }
.share-streak em { font-style: normal; font-weight: 600; color: var(--lime); }
.share-streak.bump strong { animation: streak-bump .5s .95s cubic-bezier(.2, 1.8, .4, 1) backwards; }
@keyframes streak-bump { from { opacity: .3; transform: scale(.5); } }
.share-card { margin-top: 14px; padding: 11px 14px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); text-align: left; }
.share-card-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: var(--fs-12); }
.share-card pre { margin: 0; font: inherit; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.share-card-link { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--deep); font-size: var(--fs-13); }
.share-dialog .share-note { margin: 8px 0 0; color: var(--muted); font-size: var(--fs-12); line-height: 1.45; }
.share-next { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 2px 8px; margin-top: 4px; }
.share-next > span { font-size: var(--fs-12); color: var(--muted); }
.share-next strong { font-variant-numeric: tabular-nums; font-size: var(--fs-13); letter-spacing: .5px; }
.share-next .text-button { flex-basis: 100%; min-height: 44px; color: var(--lime); }
.share-practice { display: flex; align-items: center; justify-content: center; min-height: 48px; margin-top: 8px; padding: 10px 14px; border: 1px solid #526c3d; border-radius: 10px; color: var(--text); font-size: var(--fs-15); font-weight: 600; }
.share-practice:hover { border-color: #6b8254; color: var(--lime); }
.share-details { margin-top: 10px; text-align: left; }
.share-details > summary { min-height: 44px; padding: 12px 0; color: var(--muted); font-size: var(--fs-13); }
.share-details > summary:hover { color: var(--text); }
.share-overall { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); text-align: left; }
.share-overall h3 { margin: 0 0 12px; color: var(--muted); font-size: var(--fs-13); font-weight: 500; text-align: center; }
.share-stats { display: flex; justify-content: center; gap: 8px; margin: 0; text-align: center; }
.share-stats > div { flex: 1; min-width: 0; display: flex; flex-direction: column-reverse; gap: 2px; }
.share-stats dd { margin: 0; color: var(--text); font-size: var(--fs-22); line-height: 1.25; font-weight: 600; letter-spacing: -.6px; }
.share-stats dt { color: var(--muted); font-size: var(--fs-12); }
.share-distribution { max-width: 285px; margin: 13px auto 0; }
.share-distribution h4 { margin: 0 0 6px; color: var(--muted); font-size: var(--fs-12); font-weight: 500; }
.distribution-row { display: flex; gap: 9px; align-items: center; margin: 4px 0; }
.distribution-row > span { width: 38px; color: var(--lime); font-size: var(--fs-12); letter-spacing: 1px; }
.distribution-track { flex: 1; }
.distribution-track strong { display: block; min-width: 24px; background: #3d5030; color: var(--text); padding: 1px 7px; border-radius: 3px; font-size: var(--fs-12); text-align: right; }
.share-distribution p { margin: 6px 0 0; color: var(--muted); text-align: right; font-size: var(--fs-12); }
.share-overall .share-note { padding: 0 0 10px; text-align: center; }
.share-buttons { display: flex; align-items: stretch; gap: 8px; margin-top: 14px; }
.share-buttons .primary-button { flex: 1; min-height: 54px; font-size: var(--fs-18); font-weight: 700; }
.share-dialog .share-feedback { margin: 8px 0 0; font-size: var(--fs-13); color: var(--lime); }
.share-feedback:empty { display: none; }
.share-continue { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 22px; margin-top: 2px; }
.share-continue .text-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; font-size: var(--fs-13); }
#share-manual { margin-top: 12px; text-align: left; }
#share-manual label { display: block; margin-bottom: 6px; font-size: var(--fs-12); color: var(--muted); }
#share-text { width: 100%; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: var(--fs-13)/1.6 ui-monospace, monospace; resize: vertical; }

@media (max-width: 760px) {
  .header { padding: 0 20px; gap: 16px; }
  #main-content { padding: 24px 20px 16px; }
  .puzzle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-info { align-items: flex-start; flex-direction: column; gap: 9px; }
}
/* Phones: one header row, a compact heading, and the board edge to edge so Fire is on screen without scrolling. */
@media (max-width: 520px) {
  .header { height: 56px; padding: 0 12px; gap: 6px; }
  .brand { min-width: 44px; justify-content: center; }
  .brand span { display: none; }
  .onboarding .brand { justify-content: flex-start; }
  .onboarding .brand span { display: inline; }
  .header nav { flex: 1; justify-content: center; gap: 0; }
  .header nav a { padding: 0 12px; border-radius: 0; border-bottom: 2px solid transparent; height: 56px; }
  .header nav a.active, .header nav a[aria-current="page"] { border-color: var(--lime); background: transparent; }
  .header-tools { gap: 6px; }
  #main-content, body.playing #main-content { padding: 14px 12px 12px; }
  h1 { font-size: var(--fs-22); letter-spacing: -.5px; }
  .welcome h1 { font-size: var(--fs-40); }
  .page-heading { margin-bottom: 18px; gap: 2px 12px; }
  #collection-progress { font-size: var(--fs-13); }
  .instruction { margin-bottom: 10px; font-size: var(--fs-13); line-height: 1.4; }
  .daily-row { padding: 13px 14px; gap: 12px; font-size: var(--fs-13); margin-bottom: 18px; }
  .daily-row strong { display: block; margin: 4px 0 0; font-size: var(--fs-15); }
  .filter-tabs { gap: 2px; }
  .filter-tabs button { flex: 1; padding: 8px 6px; font-size: var(--fs-13); }
  .puzzle-grid { gap: 12px; }
  .puzzle-preview { height: 132px; }
  .card-info { padding: 12px; }
  .puzzle-name { gap: 7px; }
  .board-stage { padding: 0; }
  .board-wrap { max-width: 100%; }
  .board-top { padding: 9px 14px; }
  .game-toolbar { padding: 8px 10px 10px; gap: 6px; }
  .secondary-tools { gap: 0; }
  .secondary-tools .quiet-button { padding: 10px 11px; }
  #fire { min-width: 112px; }
  .duel-tools { padding: 10px; }
  .difficulty-setting { gap: 5px; }
  .difficulty-setting select { max-width: 125px; padding: 8px; }
  .duel-player { flex-wrap: wrap; padding: 10px; }
  .duel-player small { width: 100%; margin-left: 16px; }
  .result-card { padding: 16px; }
  dialog { padding: 22px; }
  .share-dialog { padding: 22px 16px 10px; }
  .share-stars { margin: 10px 0; }
}
@media (max-width: 350px) {
  .brand { display: none; }
  .onboarding .brand { display: flex; }
  .header nav a { padding: 0 8px; }
  .puzzle-grid { grid-template-columns: 1fr; }
  .card-info { flex-direction: row; align-items: center; }
  .mode-switch button { padding: 8px 9px; }
  .secondary-tools .quiet-button { padding: 10px 7px; font-size: var(--fs-13); }
  #fire { min-width: 92px; }
}

/* Reduced motion, from the OS or the Reduce animation setting. Every rule above rests in its final state,
   so switching animation off shows each shot finished: beam complete, rings lit, crystal lit, cards visible. */
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
