:root {
  --red: #b3202a;
  --red-dark: #7d1219;
  --green: #1f5a3d;
  --green-dark: #143d29;
  --gold: #d9a441;
  --gold-light: #f3d58a;
  --cream: #fbf6ee;
  --ink: #2a1f1a;
  --muted: #6b5d55;
  --line: #e7dccd;
  --page: #eef0f2;
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--page);
}
html.embedded, html.embedded body { background: transparent; }
html:not(.embedded) .close { display: none; }
html:not(.embedded) .overlay { background: var(--green-dark); }


/* Pop-up */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 12, 10, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.dialog {
  position: relative; width: 100%; max-width: 560px;
  background: var(--cream); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  overflow: hidden; margin: auto;
}
.band {
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff; text-align: center; padding: 26px 24px 22px; position: relative;
}
.band .eyebrow { margin: 0; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-light); }
.band h1 { margin: 6px 0 6px; font-size: 28px; line-height: 1.15; }
.band .claim { margin: 0; font-size: 17px; font-weight: 600; }
.snow { position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(#fff 1.2px, transparent 1.6px), radial-gradient(#fff 1px, transparent 1.4px);
  background-size: 46px 46px, 29px 29px; background-position: 0 0, 13px 19px; }
.close {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.close:focus-visible, .gift:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
.body { padding: 20px 24px 24px; }
.intro { margin: 0 0 4px; text-align: center; font-size: 16px; }
.status { margin: 0 0 16px; text-align: center; font-size: 14px; color: var(--muted); min-height: 1.4em; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gift {
  position: relative; aspect-ratio: 1 / 1; border: 0; border-radius: 14px;
  background: #fff; box-shadow: 0 2px 0 var(--line), 0 6px 14px rgba(60,30,20,.08);
  cursor: pointer; padding: 10px; display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.gift:hover:not(:disabled) { transform: translateY(-3px) rotate(-1.5deg); }
.gift:disabled { cursor: default; }
.gift svg { width: 78%; height: 78%; transition: transform .35s ease, opacity .35s ease; }
.gift .lid { transition: transform .5s cubic-bezier(.2,.9,.3,1.3); transform-origin: 50% 40%; }
.gift.open .lid { transform: translateY(-34%) rotate(-14deg); }
.gift.open { background: #fff4dc; }
.gift.open svg { opacity: 0; transform: scale(.7); }
.gift.dim { opacity: .45; }
.gift .value {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: var(--red);
  opacity: 0; transform: scale(.6); transition: opacity .3s ease .15s, transform .4s cubic-bezier(.2,.9,.3,1.4) .15s;
}
.gift.open .value { opacity: 1; transform: scale(1); }
.gift.best { box-shadow: 0 0 0 3px var(--gold), 0 6px 18px rgba(217,164,65,.45); }

.result { margin-top: 20px; text-align: center; }
.result[hidden] { display: none; }
.result .label { margin: 0; font-size: 14px; color: var(--muted); }
.result .big { margin: 2px 0 0; font-size: 46px; font-weight: 800; color: var(--red); line-height: 1.05; }
.elf {
  margin: 14px auto 0; max-width: 420px; background: var(--green); color: #fff;
  border-radius: 14px; padding: 14px 16px;
}
.elf[hidden] { display: none; }
.elf p { margin: 0; }
.elf .double { font-size: 34px; font-weight: 800; color: var(--gold-light); margin-top: 2px; }
.note { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.btn {
  display: inline-block; margin-top: 16px; border: 0; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 16px; font-weight: 700;
  padding: 13px 28px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.fine { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.5; }
.fine a { color: inherit; }

@media (max-width: 420px) {
  .band h1 { font-size: 23px; }
  .gift .value { font-size: 24px; }
  .body { padding: 16px; }
  .grid { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.message { margin: 8px 0 4px; text-align: center; font-size: 16px; }
.message[hidden], .play[hidden] { display: none; }
.gift.busy { cursor: progress; }
