:root { --pink: #f0528c; --deep: #a61e4d; --soft: #ffe3ee; --gold: #e8b84a; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, #fff0f6, #ffc9de) fixed; color: var(--deep); font: 17px/1.5 Fredoka, system-ui, sans-serif; text-align: center; }
main { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { margin: 4px 0 16px; font-size: 42px; }
h1 a { color: var(--pink); text-decoration: none; text-shadow: 0 3px 0 #fff, 0 6px 12px #f0528c55; }
a { color: var(--deep); font-weight: 600; }
section#choose, section#invite, section#join { background: #fffc; border: 3px solid #fff; border-radius: 24px; padding: 16px; box-shadow: 0 10px 30px #c2255c2e; margin-bottom: 16px; }
.hero { display: block; width: 220px; margin: 0 auto; animation: float 4s ease-in-out infinite; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 16px 0; }
button { font: 600 17px Fredoka, system-ui, sans-serif; cursor: pointer; }
.actions button, .menu button, .close { background: linear-gradient(180deg, #ff86b0, var(--pink)); color: #fff; border: 2px solid var(--gold); border-radius: 999px; padding: 11px 22px; box-shadow: 0 5px 0 #b82e63; transition: transform .12s, box-shadow .12s; }
.actions button:hover, .menu button:hover { transform: translateY(-2px); }
.actions button:active, .menu button:active, .close:active { transform: translateY(4px); box-shadow: 0 1px 0 #b82e63; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible { outline: 3px solid var(--deep); outline-offset: 3px; }
.paper:disabled { opacity: 1; }
input { width: 100%; padding: 12px; border-radius: 12px; border: 2px dashed var(--pink); font: inherit; font-size: 14px; color: var(--deep); background: #fff; }
#timer { display: inline-block; margin: 0; padding: 4px 16px; border-radius: 999px; background: #fff; font-weight: 600; }
#timer:empty { display: none; }
.hint { font-size: 14px; margin: 8px 0 0; }

/* Camera. The video sits in the opening of the frame (see js/layout.js). */
.stage { position: relative; aspect-ratio: 1; }
.stage video, .stage .countdown, .stage .flash { position: absolute; left: 10.5%; top: 13%; width: 79%; height: 80%; }
.stage video { object-fit: cover; background: #6b2440; transform: scaleX(-1); }
.stage .frame { position: absolute; inset: 0; width: 100%; pointer-events: none; }
.countdown { z-index: 2; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 130px; font-weight: 700; text-shadow: 0 4px 0 var(--pink), 0 6px 24px #000a; pointer-events: none; }
.countdown:not(:empty) { animation: bounce 1s ease-out infinite; }
.flash { z-index: 3; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .45s ease-out; }

.counter { position: absolute; z-index: 4; left: 50%; bottom: 9%; translate: -50% 0; padding: 4px 14px; border-radius: 999px; background: #fff; color: var(--deep); font-weight: 600; animation: pop .3s ease-out; }

/* Shared board: A on the left, B on the right. Empty slots are black. */
#board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; padding: 12px; background: #fffc; border: 3px solid #fff; border-radius: 24px; box-shadow: 0 10px 30px #c2255c2e; }
.column h3 { margin: 0 0 6px; font-size: 18px; }
.column.unsaved h3::after { content: ' (not saved)'; font-size: 13px; font-weight: 400; }
.cell { position: relative; aspect-ratio: 1; }
.cell .shot { position: absolute; left: 10.5%; top: 13%; width: 79%; height: 80%; background: #141014; }
.cell .shot img { display: block; width: 100%; height: 100%; object-fit: cover; animation: pop .35s ease-out; }
.cell .frame { position: absolute; inset: 0; width: 100%; pointer-events: none; }
#error { min-height: 1.5em; margin: 0; }

/* Photo machine */
.machine { margin: 12px auto 0; max-width: 340px; scroll-margin-top: 12px; }
.machine-body { position: relative; z-index: 2; background: linear-gradient(180deg, #ff8fb7, #e64980); border: 4px solid var(--gold); border-radius: 28px 28px 16px 16px; padding: 14px 16px 18px; color: #fff; box-shadow: 0 12px 24px #a61e4d55; }
.machine-top { display: flex; justify-content: center; gap: 14px; }
.light { width: 14px; height: 14px; border-radius: 50%; background: #fff6; }
.printing .light { animation: blink .6s infinite; }
.light:nth-child(2) { animation-delay: .2s !important; }
.light:nth-child(3) { animation-delay: .4s !important; }
.machine-label { margin: 8px 0; font-size: 22px; font-weight: 600; }
.slot { height: 14px; margin: 0 14px; border-radius: 8px; background: #5c1030; box-shadow: inset 0 3px 6px #000a; }
.printing .machine-body { animation: shake .18s linear infinite; }
.chute { margin-top: -26px; padding: 0 36px 40px; overflow: hidden; }
.paper { display: block; width: 100%; padding: 6px; border: 0; background: #fff; box-shadow: 0 8px 20px #a61e4d55; transform: translateY(-101%); }
.paper img { display: block; width: 100%; }
.feeding .paper { transform: translateY(-14%); transition: transform 2.2s steps(14); }
.dropped .chute { overflow: visible; }
.dropped .paper { transform: none; margin-top: 34px; animation: drop .9s ease-in both; }
.dropped .paper:enabled:hover { rotate: 1.5deg; }

/* Download options */
.options { width: min(440px, 94vw); max-height: 92vh; border: 4px solid var(--gold); border-radius: 24px; background: var(--soft); color: var(--deep); text-align: center; padding: 16px; }
.options[open] { animation: pop .35s ease-out; }
.options::backdrop { background: #4a0d26cc; }
.zoom { max-width: 100%; max-height: 46vh; border: 6px solid #fff; border-radius: 6px; }
.menu { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 14px 0; }
.menu button { animation: pop .4s ease-out backwards; }
.menu button:nth-child(2) { animation-delay: .1s; }
.menu button:nth-child(3) { animation-delay: .2s; }
.picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.pick { padding: 3px; background: #fff; border: 2px solid var(--pink); border-radius: 8px; }
.pick img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }

.snow { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.snow i { position: absolute; top: -30px; color: #fff; font-style: normal; text-shadow: 0 0 4px #f0528c88; animation: fall linear infinite; }

@keyframes fall { to { transform: translate(30px, 108vh) rotate(360deg); } }
@keyframes float { 50% { transform: translateY(-10px) rotate(1.5deg); } }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
@keyframes bounce { 0% { transform: scale(1.7); opacity: 0; } 30% { transform: scale(.9); opacity: 1; } 50% { transform: scale(1.05); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } }
@keyframes blink { 50% { background: #fff27a; box-shadow: 0 0 12px 3px #fff27a; } }
@keyframes shake { 25% { transform: translate(-2px, 1px) rotate(-.6deg); } 75% { transform: translate(2px, -1px) rotate(.6deg); } }
@keyframes drop { 0% { translate: 0 -75px; } 45% { translate: 0 0; rotate: -2.5deg; } 65% { translate: 0 -20px; rotate: 2deg; } 82% { translate: 0 0; rotate: -1deg; } 91% { translate: 0 -6px; } }
@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
  .hero, .printing .machine-body, .countdown:not(:empty), .dropped .paper { animation: none !important; }
}
