:root {
  color-scheme: light;
  --wine: #79000a;
  --deep-wine: #430008;
  --cream: #fcefe2;
  --gold: #c99a60;
  --rose-ink: #8d3634;
}
* { box-sizing: border-box; }
html { margin: 0; scroll-behavior: smooth; background: #2d0008; }
body { margin: 0; color: var(--wine); font-family: Arial, sans-serif; background: radial-gradient(ellipse at 50% 12%, #6a1522 0, #33040f 58%, #210006 100%); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid #ceaa64; outline-offset: 5px; }
.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; }
.skip-link { position: fixed; left: 15px; top: -80px; z-index: 100; background: var(--cream); color: var(--wine); border-radius: 30px; padding: 13px 20px; }
.skip-link:focus { top: 12px; }
.paper { position: relative; isolation: isolate; container-type: inline-size; width: 100%; max-width: 720px; margin: 0 auto; background: var(--cream); box-shadow: 0 0 90px #0006; }
.artwork { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.artwork img { position: absolute; display: block; width: 100%; max-width: none; object-fit: fill; }
.overlay { position: absolute; z-index: 3; }
#scratch-area { overflow: hidden; border-radius: 50%; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#scratch-canvas { width: 100%; height: 100%; display: block; touch-action: none; transition: opacity 650ms ease; }
#scratch-area.is-revealed { pointer-events: none; outline: none; }
#scratch-area.is-revealed #scratch-canvas { opacity: 0; }
#scratch-hint { margin: 0; color: var(--rose-ink); font-size: clamp(11px, 2.35cqw, 17px); line-height: 1.4; text-align: center; letter-spacing: .03em; transition: opacity .4s; }
#scratch-area.is-revealed ~ #scratch-hint { opacity: 0; }
#countdown { opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .8s, transform .8s, visibility .8s; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
#countdown.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.countdown-heading { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: clamp(17px, 3.6cqw, 26px); font-weight: 400; margin: 0 0 2.1cqw; color: var(--rose-ink); }
.countdown-numbers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 1.75cqw; }
.countdown-cell { position: relative; display: flex; flex-direction: column; align-items: center; padding: 1.2cqw .8cqw 1.7cqw; border-top: 1px solid #b3756080; border-bottom: 1px solid #b3756080; background: linear-gradient(180deg, #fff8f030, #dcb39318); }
.countdown-cell strong { font: 400 clamp(26px, 6.3cqw, 46px)/1.1 Georgia, 'Times New Roman', serif; font-variant-numeric: tabular-nums; color: #79000a; }
.countdown-cell span { font-size: clamp(11px, 2.25cqw, 16px); margin-top: 1cqw; letter-spacing: .08em; }
.countdown-date { margin: 2cqw 0 0; font-size: clamp(10px, 2.15cqw, 15px); letter-spacing: .08em; color: var(--rose-ink); }
.directions-link, #play-again { border: 0; border-radius: 3.75cqw; display: flex; align-items: center; justify-content: center; background: #79000a; color: #fff9f0; text-decoration: none; font-size: clamp(14px, 3.7cqw, 26px); letter-spacing: .04em; line-height: 1.1; cursor: pointer; box-shadow: none; transition: background .2s, box-shadow .2s; }
.directions-link:hover, #play-again:hover { background: #9b1720; box-shadow: 0 4px 16px #6000141f; }
#memory-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 1.4% 1.7%; perspective: 1000px; }
.memory-card { position: relative; padding: 0; border: 0; border-radius: 28%; background: transparent; cursor: pointer; min-width: 0; min-height: 0; perspective: 800px; touch-action: manipulation; }
.card-inner { position: absolute; inset: 0; display: block; border-radius: inherit; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.65,.2,1); }
.memory-card.is-flipped .card-inner, .memory-card.is-matched .card-inner { transform: rotateY(180deg); }
.card-front, .card-back { position: absolute; display: flex; align-items: center; justify-content: center; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-front { background: #79000a; color: #fff; }
.card-front svg { display: block; width: 38%; height: 38%; fill: #fff; transition: transform .2s; }
.memory-card:hover .card-front svg { transform: scale(1.08); }
.card-back { background: #f6e4be; transform: rotateY(180deg); border: 1.5px solid #c6974b; color: #79000a; font-size: clamp(26px, 7.2cqw, 52px); font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.memory-card.is-matched .card-back { border-color: #ba9144; box-shadow: inset 0 0 0 2px #fff4d352; background: #f6e4be; }
.memory-card:disabled { opacity: 1; cursor: default; }
.game-stats { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: clamp(11px, 2.35cqw, 17px); color: var(--rose-ink); letter-spacing: .08em; text-transform: uppercase; }
.game-stats strong { font-weight: 600; font-variant-numeric: tabular-nums; }
#game-feedback { margin: 0; text-align: center; color: var(--rose-ink); font: italic clamp(12px, 2.65cqw, 19px)/1.2 Georgia, 'Times New Roman', serif; display: flex; justify-content: center; align-items: center; }
.ambience { position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 720px); z-index: 12; overflow: hidden; pointer-events: none; mix-blend-mode: multiply; }
#butterflies { position: absolute; inset: 0; }
.butterfly { position: absolute; top: 0; left: 0; will-change: transform; }
.butterfly-body { display: block; position: relative; width: 100%; height: 100%; perspective: 140px; transform-style: preserve-3d; }
.butterfly-wing { position: absolute; top: 0; width: 50%; height: 100%; background-image: url('assets/butterfly.png'); background-size: 200% 100%; background-repeat: no-repeat; backface-visibility: visible; }
.butterfly-wing.left { left: 0; background-position: left center; transform-origin: right center; animation: flutter-left var(--flap, .7s) ease-in-out infinite; }
.butterfly-wing.right { right: 0; background-position: right center; transform-origin: left center; animation: flutter-right var(--flap, .7s) ease-in-out infinite; }
@keyframes flutter-left { 0%, 100% { transform: rotateY(0deg); } 50% { transform: rotateY(-69deg); } }
@keyframes flutter-right { 0%, 100% { transform: rotateY(0deg); } 50% { transform: rotateY(69deg); } }
.petal { position: absolute; top: -7vh; left: var(--x); width: var(--size); height: calc(var(--size) * 1.35); animation: petal-fall var(--duration) linear var(--delay) infinite; will-change: transform; }
.petal-sway { display: block; width: 100%; height: 100%; animation: petal-sway var(--sway-duration) ease-in-out infinite alternate; }
.petal img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 1px #52001420); }
@keyframes petal-fall { 0% { transform: translate3d(0, -7vh, 0) rotate(0deg); opacity: 0; } 5% { opacity: .88; } 88% { opacity: .82; } 100% { transform: translate3d(var(--drift), 115vh, 0) rotate(var(--spin)); opacity: 0; } }
@keyframes petal-sway { from { transform: translateX(-14px) rotateY(0deg); } to { transform: translateX(20px) rotateY(65deg); } }
.music-button { position: fixed; z-index: 30; right: max(14px, calc((100vw - 720px) / 2 + 14px)); bottom: max(16px, env(safe-area-inset-bottom)); border: 1px solid #d8b58b88; color: #fff7e9; background: #690611ed; box-shadow: 0 4px 20px #3000123b; border-radius: 30px; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 11px 15px; font-size: 13px; letter-spacing: .03em; cursor: pointer; backdrop-filter: blur(8px); }
.music-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.music-button .playing-mark { display: none; }
.music-button.is-playing .paused-mark { display: none; }
.music-button.is-playing .playing-mark { display: block; }
.music-button.is-playing { padding: 12px; min-width: 44px; }
.music-button.is-playing .music-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.music-button:hover { background: #8b1420; }
.petal.celebration { animation-iteration-count: 1; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ambience { display: none; }
  .card-inner, #countdown, #scratch-canvas { transition: none; }
}
@media (max-width: 359px) {
  .countdown-heading { margin-bottom: 1cqw; }
  .countdown-date { margin-top: 1cqw; font-size: 9px; }
  .countdown-cell { padding-top: .8cqw; padding-bottom: .8cqw; }
}
