:root {
  --bg: #ffe4ec;
  --surface: #fff5f8;
  --fg: #5a1233;
  --muted: #9d4468;
  --border: #f7b6cc;
  --accent: #c2185b;
  --accent-fg: #fff;
  --radius: 20px;
  --font-sans: "Comic Sans MS", "Comic Sans", "Chalkboard SE", "Comic Neue", cursive;
}
button, input, select, textarea { font-family: inherit; }
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-sans);
  display: grid; place-items: center;
}
.page { width: 100%; max-width: 860px; padding: 24px 16px 40px; text-align: center; }
h1 { font-size: clamp(2rem, 7vw, 3rem); margin: 0 0 8px; letter-spacing: -0.02em; }
header p { margin: 0 0 24px; color: var(--muted); font-size: 1.1rem; }
.frame {
  margin: 0 0 24px; padding: 12px 12px 16px;
  background: var(--surface); border: 4px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 0 var(--border), 0 20px 30px rgba(194, 24, 91, .2);
  transform: rotate(-1deg);
}
.stage {
  position: relative; aspect-ratio: 4 / 3; width: 100%;
  background: #fcd3e1; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
}
.stage.has-photo { aspect-ratio: auto; }
.stage #photo { position: relative; z-index: 1; width: auto; height: auto; max-width: 100%; max-height: 70vh; object-fit: contain; object-position: center; display: block; }
.stage #backdrop {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: blur(24px) saturate(1.1); transform: scale(1.2); opacity: .75; z-index: 0;
}
.stage #backdrop::after { content: ""; }
.stage::before { content: ""; position: absolute; inset: 0; z-index: 0; background: rgba(247, 182, 204, .25); pointer-events: none; }
.overlay { z-index: 2; }
#backdrop[hidden] { display: none; }
@media (max-width: 600px) { .stage #photo { max-height: 60vh; } .frame { transform: none; } }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 16px;
  color: var(--muted); font-weight: 600;
}
.overlay[hidden], img[hidden] { display: none; }
.overlay p { margin: 0; }
figcaption { margin-top: 12px; font-weight: 700; }
figcaption a { color: var(--accent); }
figcaption a:hover { color: #8e1245; }
.badge {
  display: inline-block; margin-left: 8px; padding: 2px 10px; font-size: .8rem;
  background: var(--accent); color: var(--accent-fg); border-radius: 999px; vertical-align: middle;
}
::selection { background: #f7b6cc; }
.btn {
  min-height: 48px; padding: 0 28px; font: inherit; font-weight: 700; font-size: 1.1rem;
  background: var(--accent); color: var(--accent-fg);
  border: 0; border-radius: 999px; cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}
.btn:hover:not(:disabled) { background: #8e1245; transform: translateY(-2px); }
.btn:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--fg); }
#loading { background: #fcd3e1; }
.dice-wrap { position: relative; width: 120px; height: 140px; display: grid; place-items: center; perspective: 500px; }
.dice { --s: 64px; position: relative; width: var(--s); height: var(--s); transform-style: preserve-3d; animation: tumble 1.1s ease-in-out infinite, hop 1.1s ease-in-out infinite; }
.face {
  position: absolute; inset: 0; background: #fff5f8; border: 3px solid var(--accent); border-radius: 12px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 9px; gap: 2px; backface-visibility: visible;
  background: linear-gradient(145deg, #fff5f8, #f7b6cc);
}
.face i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); place-self: center; }
.f1 { transform: rotateY(0deg) translateZ(32px); }
.f2 { transform: rotateY(90deg) translateZ(32px); }
.f3 { transform: rotateX(90deg) translateZ(32px); }
.f4 { transform: rotateX(-90deg) translateZ(32px); }
.f5 { transform: rotateY(-90deg) translateZ(32px); }
.f6 { transform: rotateY(180deg) translateZ(32px); }
.f1 i { grid-area: 2 / 2; }
.f2 i:nth-child(1) { grid-area: 1 / 1; } .f2 i:nth-child(2) { grid-area: 3 / 3; }
.f3 i:nth-child(1) { grid-area: 1 / 1; } .f3 i:nth-child(2) { grid-area: 2 / 2; } .f3 i:nth-child(3) { grid-area: 3 / 3; }
.f4 i:nth-child(1) { grid-area: 1 / 1; } .f4 i:nth-child(2) { grid-area: 1 / 3; } .f4 i:nth-child(3) { grid-area: 3 / 1; } .f4 i:nth-child(4) { grid-area: 3 / 3; }
.f5 i:nth-child(1) { grid-area: 1 / 1; } .f5 i:nth-child(2) { grid-area: 1 / 3; } .f5 i:nth-child(3) { grid-area: 2 / 2; } .f5 i:nth-child(4) { grid-area: 3 / 1; } .f5 i:nth-child(5) { grid-area: 3 / 3; }
.f6 i:nth-child(1) { grid-area: 1 / 1; } .f6 i:nth-child(2) { grid-area: 2 / 1; } .f6 i:nth-child(3) { grid-area: 3 / 1; } .f6 i:nth-child(4) { grid-area: 1 / 3; } .f6 i:nth-child(5) { grid-area: 2 / 3; } .f6 i:nth-child(6) { grid-area: 3 / 3; }
.dice-shadow { position: absolute; bottom: 4px; left: 50%; width: 56px; height: 10px; margin-left: -28px; border-radius: 50%; background: rgba(194, 24, 91, .25); animation: shade 1.1s ease-in-out infinite; }
@keyframes tumble {
  0% { transform: rotateX(-20deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(700deg) rotateY(540deg) rotateZ(180deg); }
}
@keyframes hop { 0%, 100% { translate: 0 18px; } 50% { translate: 0 -18px; } }
@keyframes shade { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.6); opacity: .5; } }
@keyframes gentle { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .dice { animation: gentle 1.6s ease-in-out infinite; transform: rotateX(-25deg) rotateY(-35deg); }
  .dice-shadow { animation: none; }
  .btn { transition: none; }
  .btn:hover:not(:disabled) { transform: none; }
}
