/* Photo scene with nine gifts; each gift opens with its own clip, played in place. */
:root {
  --red: #c8202f;
  --red-dark: #a51a26;
  /* Title band and the frame below the photo share one flat, warm wood tone; no red, no fades (Tim 23.11.). */
  --floor: #4d3526;
  --text: #ffffff;
  --soft: #d9c8b8;
  --radius: 20px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  color: var(--text);
  /* In its own window the room's flat tone, also where the browser shows the page beside the game (the safe areas of a
     phone held sideways). */
  background: #2d1608;
}
html.embedded, html.embedded body { background: transparent; }
/* Above the photo the name and the one instruction, on the same flat tone as the frame below it (Tim 24.11. evening:
   the old words and places were better). */
.sky {
  position: relative; min-height: 72px; padding: 16px 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--floor);
}
.title {
  position: relative; z-index: 1; margin: 0; color: #fff; font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em;
  font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}
/* A badge beside the title while new customers get double, in the look of the best discount pill: dark warm plate,
   gold rim, a soft gold glow, no black shadow (Tim 24.11.). */
.title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; }
.badge {
  padding: 3px 12px; border-radius: 999px; background: #2b1b12; border: 1px solid rgba(255, 214, 140, .85);
  box-shadow: 0 0 10px rgba(255, 200, 110, .35); color: #f6e3c4; font-size: 13px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
/* The one instruction stands under the name, above the photo. An unseen copy of its longest wording holds the line's
   height, so the gifts below do not move when it shortens to „Noch 2 Geschenke“ or goes quiet after the last pick. */
.hint { position: relative; z-index: 1; display: grid; margin: 0; color: #fff; font-size: 18px; font-weight: 600; text-align: center; text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }
.hint > span { grid-area: 1 / 1; }
.hint-room { visibility: hidden; }
html:not(.embedded) .close { display: none; }

.overlay {
  position: fixed; inset: 0; background: rgba(20, 12, 10, .4);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow-y: auto;
}
.dialog {
  position: relative; outline: none; width: 100%; max-width: 880px;
  background: var(--floor); border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
  overflow: hidden; margin: auto;
}

.scene { position: relative; background: var(--floor); }
/* Every gift, outline and clip is placed in the photo's pixel frame of 1672 by 941. */
.stage {
  position: relative; aspect-ratio: 1672 / 941; overflow: hidden; isolation: isolate;
  background: #3a1418 url("szene.webp") 0 0 / 100% 100% no-repeat; container-type: inline-size;
  filter: brightness(1.15);
  /* Select all or quick clicks would paint the selection blue through the soft clip masks (Matthias 24.11.). */
  -webkit-user-select: none; user-select: none;
}
.close {
  position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; z-index: 102;
  border: 1px solid rgba(255, 255, 255, .3); border-radius: 50%; padding: 0 0 3px;
  background: rgba(28, 16, 10, .55); color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.close:hover { background: rgba(28, 16, 10, .75); }
.close:focus-visible, .btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.fine a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.message { margin: 0 auto; padding: 32px 24px; max-width: 520px; text-align: center; }
.message[hidden], .result[hidden], .elf[hidden] { display: none; }

/* Clips: one full-frame video per gift, shown only in a soft zone around it. Opened clips stay on their last frame;
   a still of that frame stands in when the clip cannot play. */
.clip, .still {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 1; pointer-events: none;
  opacity: 0; transition: opacity .18s ease;
  -webkit-mask: var(--mask) 0 0 / 100% 100% no-repeat; mask: var(--mask) 0 0 / 100% 100% no-repeat;
}
.clip.on, .still.on { opacity: 1; }
.clip.opened, .still.opened { z-index: calc(2 + var(--order)); transition-duration: .08s; }
/* A shaking gift shows at once, above open gifts, under their labels; its mask keeps gifts in front over it. */
.clip.shaking { opacity: 1; transition: none; z-index: 15; }
/* Keyboard focus only: a thin light line around the focused gift, hidden where a gift in front covers it. No rim on hover or rustle (Tim 23.11.). */
.rings { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 20; pointer-events: none; overflow: visible; }
.ring { opacity: 0; }
.ring.hot { opacity: 1; }
.ring polygon { fill: none; stroke: rgba(255, 255, 255, .9); stroke-width: 3.5; stroke-linejoin: round; }
.gift {
  position: absolute; inset: 0; z-index: calc(30 + var(--z)); clip-path: var(--sil);
  border: 0; padding: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.gift:focus { outline: none; }
.gift:disabled { cursor: default; pointer-events: none; }
.stage.busy .gift { cursor: progress; }
/* The discount: a solid warm pill above the opened gift, nothing of the photo shines through (Tim 24.11.). */
.labels { position: absolute; inset: 0; z-index: 60; pointer-events: none; }
/* Gifts at the top edge: the pill keeps room above, so it stays clear of the photo's soft edge, also at the peak of
   its rise (Tim 24.11.). */
.value { position: absolute; left: var(--x); top: max(var(--y), var(--room, 12cqw)); width: 0; height: 0; }
.value[hidden] { display: none; }
.num {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -130%); padding: .7cqw 1.8cqw; border-radius: 999px;
  background: #2b1b12; border: 1px solid rgba(255, 236, 210, .22);
  box-shadow: 0 .4cqw 1.6cqw rgba(0, 0, 0, .4); color: #fff6e8; white-space: nowrap;
  font: 600 4.4cqw/1 "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.value.best .num { border-color: rgba(255, 214, 140, .85); box-shadow: 0 .6cqw 2cqw rgba(0, 0, 0, .35), 0 0 2.4cqw rgba(255, 200, 110, .45); }
.value.rise .num { animation: rise .35s cubic-bezier(.2, .9, .3, 1) both; }
/* Out of the box: starts small inside the open top, climbs above it, settles. */
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, 10%) scale(.35); }
  25% { opacity: 1; }
  70% { transform: translate(-50%, -142%) scale(1.06); }
  100% { opacity: 1; transform: translate(-50%, -130%); }
}


/* Result: a small line, then the number in a warm, lighter tone; it fades in gently (Tim 24.11.: softer). */
.result { text-align: center; padding: 32px 40px 8px; }
.result:not([hidden]) { animation: settle .4s ease-out both; }
@keyframes settle { from { opacity: 0; transform: translateY(6px); } }
/* „Ihr Rabatt“ and the number stand out (Tim 24.11.: bigger); they grow with the game window on a computer. */
.result .label { margin: 0; color: var(--soft); font-size: clamp(18px, 1.9cqw, 26px); letter-spacing: .02em; }
.result .big {
  margin: 2px 0 0; color: #f6e3c4; font-size: clamp(56px, 6.2cqw, 88px); font-weight: 500; line-height: 1.15;
  font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.elf { margin: 4px 0 0; color: var(--text); font-size: 18px; }
.note { margin: 24px auto 0; max-width: 560px; color: var(--soft); }
.btn {
  display: inline-block; margin-top: 32px; border: 0; border-radius: 8px; padding: 16px 32px;
  background: var(--red); color: #fff; font-size: 16px; font-weight: 600; line-height: 1;
  cursor: pointer; text-decoration: none; transition: background-color .15s ease;
}
.btn[hidden] { display: none; }
.btn:hover { background: var(--red-dark); }

/* Rules: always visible under the photo, before and after playing. */
.rules { margin: 0 auto; padding: 16px 40px 0; max-width: 640px; color: var(--soft); text-align: center; }
.rules strong { color: var(--text); font-weight: 600; }
/* The new-customer line stands on its own row, so no word of it hangs alone. */
#rules-double:not([hidden]) { display: block; }
/* Footer: the sender's logo, cut out for the dark picture, beside the fine print. */
.foot { padding: 16px 40px 20px; }
.foot-row { display: flex; align-items: center; justify-content: center; gap: 16px; }
/* Who built it: one quiet line on its own row, bottom left. */
.credit { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 12px; color: var(--soft); opacity: .75; text-align: left; }
.credit .mark { flex: none; width: 14px; height: 14px; }
.logo { flex: none; height: 40px; width: auto; }
.fine { margin: 0; font-size: 13px; color: var(--soft); }
.fine a { color: var(--soft); text-underline-offset: 2px; }

@media (max-width: 600px) {
  .overlay { padding: 8px; }
  .sky { min-height: 56px; padding: 12px 56px; }
  .title { font-size: 22px; }
  /* Less text weight on the phone (Tim 24.11. evening): the rules stay, quieter than the one instruction above them. */
  .rules { padding: 8px 16px 0; font-size: 14px; }
  .foot { padding: 12px 16px 16px; }
  .foot-row { gap: 12px; }
  .logo { height: 34px; }
  .hint { font-size: 16px; }
  .ring polygon { stroke-width: 5; }
  .num { font-size: 5.6cqw; padding: 1cqw 2.4cqw; }
  /* The pill is larger on the phone, so it also keeps room at the sides, clear of the photo's soft edge. */
  .value { --room: 15cqw; left: clamp(15.5cqw, var(--x), 100% - 15.5cqw); }
  .close { top: 8px; right: 8px; width: 40px; height: 40px; }
  .scene::after { height: 16px; }
  .result { padding: 24px 16px 8px; }
  .btn { display: block; width: 100%; text-align: center; }
  .btn[hidden] { display: none; }
}
/* On a computer the game follows the screen height: title and all gifts fit, the text below starts at the edge.
   Never smaller than before, never wider than the photo itself (Tim 24.11.: gifts and everything bigger). */
@media (min-width: 601px) {
  .dialog { max-width: clamp(880px, calc((100dvh - 210px) * 1672 / 941), 1672px); container-type: inline-size; }
  .title { font-size: clamp(28px, 2.6cqw, 40px); }
  .hint { font-size: clamp(18px, 1.6cqw, 24px); }
}
/* In its own window the game stands in one big picture of the room, no bands (Tim 24.11.). On a computer the picture
   holds a copy of the photo at 850, 398, 1368 wide out of 3072 (a phone or a portrait window has its own, below);
   spiel.js reports where the stage is, so the copy lies exactly under it. No box (Tim 24.11. evening): the copy's edge
   fades into the room, and the stage's edge fades the same way, so photo and room are one picture. Outward the room
   keeps its light, no black („kein schwarz“), and its outermost rim eases into one flat floor tone, the colour beside
   the picture. Width 0 until spiel.js has measured, so nothing shows out of place. Only the shop pop-up keeps the
   brown frame.
   The game stands at the top of the window (Tim 24.11. night: „das Rote oben“ goes): spare height becomes floor below,
   never empty wall above. Every size follows one unit --u, so text and gifts grow together (Tim: „viel zu klein“). */
html:not(.embedded) .overlay {
  --stage-x: 0px; --stage-y: 0px; --stage-w: 0px;
  --u: calc(clamp(14px, min(1.9dvh, 2.2vw), 22px) * var(--fit-s, 1));
  --ink: #fff8ee;
  --ink-soft: #f1e4d3;
  --line: rgba(242, 220, 188, .5);
  --frame-w: min(90%, 100% - 32px);
  --r: 18px;
  align-items: flex-start;
  background:
    url("szene-desktop.webp")
      calc(var(--stage-x) - var(--stage-w) * 850 / 1368) calc(var(--stage-y) - var(--stage-w) * 398 / 1368)
      / calc(var(--stage-w) * 3072 / 1368) auto no-repeat local,
    linear-gradient(#300305, #300305) 0 0 / 100% calc(var(--stage-y) - var(--stage-w) * 398 / 1368 + 2px) no-repeat local,
    #2d1608;
}
html:not(.embedded) :is(.dialog, .scene, .sky) { background: transparent; }
html:not(.embedded) .dialog { box-shadow: none; border-radius: 0; margin: 0 auto; }
/* At the sides (60 of 1368) and below (24 of 770) as wide as the copy's soft edge in the picture, where gifts and their
   percent pills reach the photo's edge. Above, the picture fades over about 69 of 770, the stage only over 40 (5.2 %),
   so the pills of the top gifts stay whole. */
html:not(.embedded) .stage {
  --edge: linear-gradient(90deg, transparent, #000 4.4%, #000 95.6%, transparent), linear-gradient(transparent, #000 5.2%, #000 96.9%, transparent);
  -webkit-mask-image: var(--edge); -webkit-mask-composite: source-in;
  mask-image: var(--edge); mask-composite: intersect;
}
/* Text stands on the picture: a soft warm shade under each letter keeps it legible on the floor's light streak, no
   black rim („diese schwarzen Schatten“). */
html:not(.embedded) :is(.sky, .body, .rules, .foot) { text-shadow: 0 1px 2px rgba(36, 14, 4, .55), 0 0 14px rgba(36, 14, 4, .3); }
html:not(.embedded) :is(.title, .hint) { text-shadow: inherit; }
html:not(.embedded) :is(.badge, .btn) { text-shadow: none; }

/* The name large and calm, the badge a fine gold line beside it, then the one instruction. */
html:not(.embedded) .sky { min-height: 0; padding: calc(var(--u) * .85) 24px calc(var(--u) * .4); gap: calc(var(--u) * .3); }
html:not(.embedded) .title-row { gap: 8px calc(var(--u) * .9); }
html:not(.embedded) .title {
  font-family: Georgia, Cambria, "Times New Roman", serif; font-weight: 400;
  font-size: calc(var(--u) * 3); line-height: 1.1; letter-spacing: -.005em; color: var(--ink);
}
html:not(.embedded) .badge {
  padding: .32em 1em .36em; background: rgba(74, 22, 16, .5); border: 1px solid rgba(236, 200, 140, .75); box-shadow: none;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: #f7e0b4; font-size: max(14px, calc(var(--u) * .9)); font-weight: 600; letter-spacing: .03em;
}
html:not(.embedded) .hint { font-size: calc(var(--u) * 1.35); font-weight: 600; line-height: 1.3; color: var(--ink); }

/* Below the photo one fine light frame holds the rules, the sender and the fine print; who built it stands under it.
   The frame is drawn by the rules (top half) and the logo row (bottom half), so the page keeps its order. */
html:not(.embedded) .rules {
  width: var(--frame-w); max-width: none; margin: calc(var(--u) * .3) auto 0;
  padding: calc(var(--u) * .75) calc(var(--u) * 1.4) calc(var(--u) * .65);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
  color: var(--ink-soft); font-size: max(16px, calc(var(--u) * 1.1)); line-height: 1.4;
}
html:not(.embedded) .foot { padding: 0 0 calc(var(--u) * .45); }
html:not(.embedded) .foot-row {
  width: var(--frame-w); margin: 0 auto; gap: calc(var(--u) * 1.1);
  padding: calc(var(--u) * .65) calc(var(--u) * 1.4) calc(var(--u) * .75);
  border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  background: linear-gradient(90deg, transparent, rgba(242, 220, 188, .3) 15%, rgba(242, 220, 188, .3) 85%, transparent) 50% 0 / calc(100% - var(--u) * 2.8) 1px no-repeat;
}
html:not(.embedded) .logo { height: max(40px, calc(var(--u) * 2.5)); }
html:not(.embedded) .fine { color: var(--ink-soft); font-size: max(13px, calc(var(--u) * .84)); line-height: 1.45; }
html:not(.embedded) .fine a { color: var(--ink-soft); }
html:not(.embedded) .credit {
  width: var(--frame-w); margin: calc(var(--u) * .35) auto 0; gap: .45em; padding-left: 2px;
  color: #e6d6c3; opacity: 1; font-size: max(12px, calc(var(--u) * .74));
}
html:not(.embedded) .credit .mark { width: 1.15em; height: 1.15em; }
html:not(.embedded) :is(.hint, .rules, .note) { text-wrap: balance; }
html:not(.embedded) .fine { text-wrap: pretty; }

/* The result in the same calm scale: the line, the number large, the note, one button. It takes the rules' place as
   the frame's top half, so the frame holds the discount right under the gifts and nothing is cut off (Tim 24.11. night:
   „warum das dann so abgeschnitten ist“). */
html:not(.embedded) .message { font-size: calc(var(--u) * 1.2); }
html:not(.embedded) .dialog:has(.result:not([hidden])) .rules { display: none; }
html:not(.embedded) .result {
  width: var(--frame-w); margin: calc(var(--u) * .3) auto 0;
  padding: calc(var(--u) * 1) calc(var(--u) * 1.4) calc(var(--u) * .85);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r) var(--r) 0 0;
}
html:not(.embedded) .result .label { color: var(--ink-soft); font-size: calc(var(--u) * 1.4); line-height: 1.3; }
html:not(.embedded) .result .big { font-size: calc(var(--u) * 6); font-weight: 400; line-height: 1.05; margin-top: calc(var(--u) * .2); }
html:not(.embedded) .elf { font-size: max(18px, calc(var(--u) * 1.05)); line-height: 1.35; }
html:not(.embedded) .note { margin-top: calc(var(--u) * .8); max-width: 36em; color: var(--ink-soft); font-size: max(16px, calc(var(--u) * 1.05)); line-height: 1.45; }
html:not(.embedded) .btn { margin-top: calc(var(--u) * 1.1); padding: calc(var(--u) * .9) calc(var(--u) * 2); border-radius: 999px; font-size: max(16px, calc(var(--u) * 1.05)); }
/* On a computer the result stands in two columns: what you get on the left, what it means on the right, and the one
   button level with the foot of the number, so the frame is no taller than the number needs. */
@media (min-width: 601px) {
  html:not(.embedded) .result:not([hidden]) {
    display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: calc(var(--u) * 1.8); row-gap: 0;
    align-items: end; text-align: left;
    grid-template-areas: "label note" "elf note" "big note" "big btn";
  }
  html:not(.embedded) .result .label { grid-area: label; }
  html:not(.embedded) .result .elf { grid-area: elf; max-width: 15em; text-wrap: balance; }
  html:not(.embedded) .result .big { grid-area: big; }
  html:not(.embedded) .result .note { grid-area: note; margin: 0 0 calc(var(--u) * .8); max-width: 34em; text-wrap: pretty; }
  html:not(.embedded) .result .btn { grid-area: btn; justify-self: start; margin: 0 0 calc(var(--u) * .5); }
}
/* On a computer the whole page is one picture: title, gifts and the frame fit the window without scrolling, before the
   game and with the result (Tim 24.11. night: „jeder hat halt verschiedene Bildschirme“). spiel.js measures the widest
   game that fits for playing (the frame's width, --fit-d) and the widest that leaves room for the result, and the game
   glides from one to the other as --fit-w; until then the game grows as far as the height leaves room for about 17.4
   units of text. */
@media (min-width: 601px) {
  /* The text keeps at least 900 wide, so a narrow game never wraps it taller. */
  html:not(.embedded) .dialog { max-width: max(var(--fit-d, clamp(880px, calc((100dvh - var(--u) * 17.4 - 4px) * 1672 / 941), 1672px)), 900px); }
  html:not(.embedded) .stage { max-width: var(--fit-w, none); margin-inline: auto; }
  html:not(.embedded) .stage { transition: max-width .7s cubic-bezier(.25, .8, .25, 1); }
  html:not(.embedded) .fitting .stage { transition: none; }
  /* Held still while the page loads unfitted and while the gifts glide for the result (spiel.js). */
  html:not(.embedded) .settling { overflow-y: hidden; }
  html:not(.embedded) .overlay { padding-block: 0; }
}
/* On a phone, and in a window taller than wide, the game spans the whole width and stands in a tall room of its own,
   the copy of the photo across its full width at 0, 1095 out of 1280, wall above and a long floor below (Tim 24.11.
   evening: „mach das ganze Bild groß also kein schwarz“). */
@media (max-width: 600px), (max-aspect-ratio: 5/6) {
  html:not(.embedded) .overlay {
    padding: 0;
    background:
      url("szene-handy.webp") var(--stage-x) calc(var(--stage-y) - var(--stage-w) * 1095 / 1280) / var(--stage-w) auto no-repeat local,
      linear-gradient(#2d0808, #2d0808) 0 0 / 100% calc(var(--stage-y) - var(--stage-w) * 1095 / 1280 + 2px) no-repeat local,
      #3a1e0c;
  }
  html:not(.embedded) body { background: #2d0808; }
}
/* The phone keeps the same order in one column: name, badge below it, instruction, gifts, the frame with the logo
   bottom left beside the fine print (Tim and Matthias 21.11.). */
@media (max-width: 600px) {
  /* Every size in units, so on a short phone spiel.js can make the page a little smaller (--fit-s) until it fits. */
  html:not(.embedded) .overlay { --u: calc(16px * var(--fit-s, 1)); --frame-w: calc(100% - 24px); --r: 16px; }
  html:not(.embedded) .sky { padding: calc(var(--u) * 1.375) 20px calc(var(--u) * .625); gap: calc(var(--u) * .625); }
  html:not(.embedded) .title-row { flex-direction: column; gap: calc(var(--u) * .625); }
  html:not(.embedded) .title { font-size: calc(var(--u) * 2.375); }
  html:not(.embedded) .badge { font-size: max(13px, calc(var(--u) * .94)); }
  html:not(.embedded) .hint { font-size: max(16px, calc(var(--u) * 1.19)); }
  html:not(.embedded) .rules { margin-top: calc(var(--u) * .375); padding: var(--u) 18px calc(var(--u) * .875); font-size: max(14.5px, var(--u)); line-height: 1.45; }
  html:not(.embedded) .foot-row { gap: 14px; padding: var(--u) 18px calc(var(--u) * 1.125); background-size: calc(100% - 36px) 1px; }
  html:not(.embedded) .logo { height: calc(var(--u) * 2.375); }
  html:not(.embedded) .fine { font-size: max(12.5px, calc(var(--u) * .875)); line-height: 1.45; }
  html:not(.embedded) .credit { margin-top: calc(var(--u) * .625); font-size: max(12px, calc(var(--u) * .78)); }
  html:not(.embedded) .result { margin-top: calc(var(--u) * .375); padding: 24px 18px 20px; }
  html:not(.embedded) .result .big { font-size: 84px; }
  html:not(.embedded) .note { font-size: 17px; }
  html:not(.embedded) .btn { font-size: 18px; padding: 18px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
