* {
  box-sizing:border-box;
}

html,body {
  margin:0;
  overflow:hidden;
  width:100%;
  height:100%;
  background:#1e1723;
  color:#fff2cf;
  font-family:Georgia,'Times New Roman',serif;
}

button {
  color:inherit;
  font:inherit;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}

button:focus-visible {
  outline:3px solid #ffda87;
  outline-offset:3px;
}

button:disabled {
  cursor:default;
}

[hidden] {
  display:none!important;
}

#world {
  position:relative;
  width:100%;
  height:100%;
  height:100dvh;
  overflow:hidden;
  isolation:isolate;
  background:#1b1921;
}

.scene,.film-bg,#tree,.vignette,#sparkle {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
}

.film-bg {
  background:linear-gradient(#241c3160,#241c3180),url('../immagini/borgo.webp') center/cover;
  filter:blur(13px);
  transform:scale(1.06);
}

.scene {
  display:grid;
  place-items:center;
}

.scene video {
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:48% 58%;
  display:block;
}

.vignette {
  background:linear-gradient(180deg,#130e1c7a,transparent 19%,transparent 60%,#160e1fd9 100%),radial-gradient(ellipse at center,transparent 55%,#1e152630);
}

#tree {
  background:url('../immagini/albero.webp') center center/cover no-repeat;
  opacity:0;
  transition:opacity .85s;
}

.tree #tree,.wheel #tree,.prize #tree {
  opacity:1;
}

.tree .scene,.wheel .scene,.prize .scene {
  visibility:hidden;
}

#sparkle {
  z-index:1;
}

#hud {
  position:absolute;
  z-index:5;
  top:max(16px,env(safe-area-inset-top));
  left:max(18px,env(safe-area-inset-left));
  right:max(18px,env(safe-area-inset-right));
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:8px;
}

#signature {
  font-style:italic;
  font-size:clamp(16px,2vw,25px);
  text-shadow:0 2px 5px #211320,0 0 9px #27171b;
  white-space:nowrap;
}

.controls {
  display:flex;
  gap:6px;
  align-items:center;
}

.controls button,.quiet {
  border:1px solid #e8cf9380;
  border-radius:24px;
  background:linear-gradient(#382c30db,#201821e8);
  padding:7px 13px;
  font:500 12px/1.25 system-ui,sans-serif;
  color:#fff0d1;
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
}

.controls svg,.quiet svg {
  width:16px;
  height:16px;
  stroke:currentColor;
  fill:none;
  stroke-width:1.6;
  stroke-linecap:round;
  stroke-linejoin:round;
}

.controls button:hover,.quiet:hover {
  background:#573940;
}

.controls .sound,.controls .pause {
  padding:7px;
  min-width:36px;
}

.controls button[aria-pressed=true] {
  border-color:#f5cd80;
}

.controls .pause[hidden] {
  display:none;
}

#titlecard {
  position:absolute;
  z-index:2;
  top:19%;
  right:5%;
  width:55%;
  text-align:center;
  text-shadow:0 2px 20px #25131c,0 1px 6px #312026;
  margin:0;
  transition:opacity .65s;
}

.pre,.chapter,.edition,.label {
  font:600 10px/1.5 system-ui,sans-serif;
  letter-spacing:.18em;
  text-transform:uppercase;
}

.pre {
  color:#fff0ba;
}

h1,h2,p {
  margin:0;
}

h1 {
  font-weight:normal;
  font-size:clamp(44px,6.7vw,108px);
  line-height:.96;
  margin:14px 0;
  color:#fff8df;
  letter-spacing:-.05em;
}

h1 em {
  font-weight:normal;
  color:#ffdd9e;
}

.flourish {
  font-size:24px;
  color:#ffd992;
  letter-spacing:.32em;
}

#storysay {
  position:absolute;
  z-index:2;
  left:50%;
  bottom:max(6%,26px);
  text-align:center;
  transform:translateX(-50%);
  width:min(820px,90%);
  padding:9px 20px 13px;
  text-shadow:0 2px 3px #160e19,0 0 12px #130c12;
}

#storysay:before {
  content:"";
  position:absolute;
  inset:-18px -8% -10px;
  background:radial-gradient(ellipse,#23152299 13%,transparent 72%);
  z-index:-1;
}

.chapter {
  color:#ffe1a0;
  margin-bottom:7px;
}

#say {
  font-size:clamp(19px,2.15vw,35px);
  line-height:1.32;
  color:#fff6e2;
  text-wrap:balance;
}

.filmline {
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  background:#322426;
  height:3px;
}

.filmline i {
  display:block;
  background:#e6c187;
  height:100%;
  width:0;
}

#calendar {
  position:absolute;
  z-index:2;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
}

.treeheader {
  position:absolute;
  left:2%;
  right:2%;
  top:max(57px,8%);
  text-align:center;
  text-shadow:0 2px 8px #20141c,0 0 20px #191018;
}

.treeheader h2,.reward h2 {
  font-weight:normal;
  font-size:clamp(30px,3.5vw,60px);
  line-height:1.01;
  letter-spacing:-.03em;
}

.treeheader p {
  font-size:clamp(14px,1.25vw,20px);
  margin-top:7px;
}

#miofilo {
  font:italic 13px/1.5 Georgia,serif;
  color:#f2d39a;
  margin-top:4px;
}

a.quiet {
  text-decoration:none;
}

.ornaments {
  position:absolute;
  top:max(133px,23%);
  bottom:max(40px,6%);
  left:50%;
  transform:translateX(-50%);
  width:min(75vw,80vh,750px);
  display:grid;
  grid-template-rows:repeat(6,minmax(0,1fr));
  align-items:center;
}

.row {
  display:flex;
  justify-content:center;
  align-items:center;
  gap:clamp(1px,1vw,19px);
  height:100%;
}

.orb {
  --base:#7b2338;
  --lit:#c26b69;
  --shadow:#421221;
  --emb:#ecce91;
  --num:#fff3cf;
  position:relative;
  display:grid;
  place-items:center;
  height:100%;
  width:calc(100% / 4.5);
  min-width:0;
  border:0;
  padding:0;
  background:none;
  flex-shrink:0;
}

.orb.intro {
  display:flex;
  flex-direction:column;
  gap:4px;
  justify-content:center;
}

.orb.intro .sphere {
  --base:#b9854a;
  --lit:#ffe3ab;
  --shadow:#7a532f;
  --emb:#7a532f;
  --num:#3a2618;
  box-shadow:0 0 0 2px #ffda8799,0 0 22px #ffce7677,inset 1px 1px 3px #fff8,inset -2px -3px 6px #1a081733;
}

.intro-label {
  font:600 9px/1 system-ui,sans-serif;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:#ffda87;
  text-shadow:0 1px 4px #000;
  white-space:nowrap;
}

.orb:nth-child(3n+2),.row:nth-child(2n) .orb:first-child {
  --base:#bd944f;
  --lit:#f9d795;
  --shadow:#785334;
  --num:#382620;
  --emb:#795331;
}

.row:nth-child(3n) .orb:nth-child(2n+1),.row:nth-child(2n) .orb:last-child {
  --base:#e8d9bb;
  --lit:#fff5d7;
  --shadow:#ac8f6a;
  --num:#4a3327;
  --emb:#ac7b49;
}

.sphere {
  position:relative;
  display:grid;
  place-items:center;
  aspect-ratio:1;
  width:min(100%,7.2vh);
  max-width:67px;
  border-radius:50%;
  background:radial-gradient(circle at 30% 22%,var(--lit),var(--base) 53%,var(--shadow) 100%);
  box-shadow:inset 1px 1px 3px #fff8,inset -2px -3px 6px #1a081733,1px 5px 10px #0c0b1790;
  color:var(--num);
  font-size:clamp(20px,3.2vh,36px);
  text-shadow:0 1px 2px #49241930;
  transform-origin:center -9px;
  animation:sway 4s ease-in-out infinite alternate;
  animation-delay:var(--delay);
}

.sphere:before {
  content:"";
  position:absolute;
  bottom:98%;
  width:22%;
  height:10%;
  border-radius:2px;
  background:repeating-linear-gradient(90deg,#a47a4e 0 2px,#e9d19a 3px 4px);
}

.sphere:after {
  content:"";
  position:absolute;
  bottom:106%;
  width:12%;
  height:14%;
  border:1px solid #ddc694;
  border-radius:50%;
}

.sphere i {
  position:absolute;
  inset:9%;
  border:1px dotted var(--emb);
  border-radius:50%;
  opacity:.8;
}

.orb[aria-pressed=true] .sphere i:after {
  content:'✧';
  position:absolute;
  bottom:-10%;
  right:-11%;
  background:#523a2d;
  border:1px solid #c3a36b;
  border-radius:50%;
  color:white;
  font:13px/16px serif;
  width:16px;
  height:16px;
}

.orb:hover .sphere,.orb:focus-visible .sphere {
  filter:brightness(1.25);
  box-shadow:0 0 18px #ffe3a599;
}

.orb:focus-visible {
  outline:none;
}

.orb:focus-visible .sphere {
  outline:3px solid #ffda87;
  outline-offset:3px;
}

.orb:nth-child(2n) .sphere {
  animation-direction:alternate-reverse;
}

@keyframes sway {
  from {
    transform:rotate(-3deg);
  }
  to {
    transform:rotate(3deg);
  }
}

.edition {
  position:absolute;
  bottom:max(12px,env(safe-area-inset-bottom));
  left:10px;
  right:10px;
  text-align:center;
  text-shadow:0 1px 5px black;
  letter-spacing:.08em;
  font-size:10px;
}

.edition b {
  color:#ffdda0;
}

#prizestage {
  position:absolute;
  z-index:3;
  inset:0;
  background:radial-gradient(ellipse at center,#3422389c,#130f20de);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:61px 18px 18px;
  gap:clamp(10px,2vh,20px);
}

.reward h2 {
  margin-top:6px;
  color:#fff2d8;
}

.reward .label {
  color:#efce95;
}

#wheelbox {
  position:relative;
  width:min(45vh,74vw,360px);
  aspect-ratio:1;
  filter:drop-shadow(0 9px 20px #110b13);
  flex-shrink:0;
}

#wheel {
  height:100%;
  width:100%;
  border-radius:50%;
  border:5px double #ddba82;
}

.needle {
  position:absolute;
  top:-7px;
  left:50%;
  transform:translateX(-50%);
  border-left:10px solid transparent;
  border-right:10px solid transparent;
  border-top:26px solid #ffdc97;
  z-index:2;
  filter:drop-shadow(0 1px 2px #532);
}

.hub {
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  border:3px double #d9ba8f;
  color:#ffda99;
  background:#6a343a;
  width:16%;
  height:16%;
  border-radius:50%;
  display:grid;
  place-items:center;
  font-size:25px;
}

.resultnote {
  font:14px/1.4 system-ui,sans-serif;
  color:#f6e5cb;
  max-width:460px;
}

.buttons {
  display:flex;
  gap:8px;
}

#soundnote {
  position:absolute;
  right:16px;
  top:60px;
  color:#fff2cf;
  font:11px system-ui,sans-serif;
}

.pin {
  display:none;
}

@media(max-aspect-ratio:4/5) {
  .scene video {
    object-fit:contain;
    width:118%;
    height:auto;
    max-height:58vh;
  }
  .scene {
    overflow:hidden;
    align-items:center;
    justify-items:center;
    display:flex;
    justify-content:center;
  }
  .vignette {
    background:linear-gradient(#140c2580,transparent 40%,transparent 65%,#1e1424de);
  }
  #titlecard {
    top:13%;
    left:4%;
    width:92%;
    right:auto;
  }
  h1 {
    font-size:clamp(39px,9vw,62px);
    margin:4px 0;
  }
  h1 br {
    display:none;
  }
  .flourish {
    font-size:16px;
  }
  #storysay {
    bottom:7%;
    width:97%;
    padding:7px 13px;
  }
  #say {
    font-size:clamp(18px,5vw,26px);
  }
  #hud {
    left:10px;
    right:10px;
    top:max(11px,env(safe-area-inset-top));
    justify-content:flex-end;
  }
  #signature {
    display:none;
  }
  .controls {
    gap:3px;
  }
  .controls button,.controls a.quiet {
    padding:5px 8px;
    min-height:34px;
    font-size:11px;
  }
  #percorso .etichetta-bottone {
    display:none;
  }
  .controls .pause,.controls .sound {
    min-width:31px;
    padding:5px;
  }
  .treeheader {
    top:13%;
  }
  .ornaments {
    width:min(96%,580px);
    top:26%;
    bottom:10%;
  }
  .sphere {
    width:min(100%,8vh);
    max-width:58px;
  }
  .row {
    gap:2.3%;
  }
  .orb {
    width:22%;
  }
  #tree {
    background-position:51.5% center;
  }
  .edition {
    bottom:3.7%;
  }
}

@media(max-height:490px) and (orientation:landscape) {
  #hud {
    top:6px;
  }
  .controls button {
    min-height:29px;
    padding:4px 8px;
  }
  #titlecard {
    top:17%;
  }
  h1 {
    font-size:48px;
  }
  .treeheader {
    top:9%;
    left:3%;
    right:auto;
    text-align:left;
    max-width:25%;
  }
  .treeheader h2 {
    font-size:25px;
  }
  .treeheader p {
    font-size:13px;
  }
  .ornaments {
    top:14%;
    bottom:8%;
    width:min(65vw,102vh);
  }
  .sphere {
    width:min(100%,9vh);
    font-size:19px;
  }
  #storysay {
    bottom:3%;
  }
  #say {
    font-size:20px;
  }
  #prizestage {
    padding-top:26px;
    gap:5px;
  }
  .reward h2 {
    font-size:27px;
  }
}

@media(prefers-reduced-motion:reduce) {
  .sphere {
    animation:none;
  }
  * {
    scroll-behavior:auto;
  }
}

#treetitle:focus,#wishheading:focus {
  outline:none;
}

#calendar:before {
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(0deg,#1e1525c9 0%,transparent 25%,transparent 70%,#20182466 100%);
}

.orb:disabled .sphere {
  animation:none;
  filter:saturate(.46) brightness(.79);
  box-shadow:inset 1px 1px 3px #fff6,1px 5px 10px #0c0b1780;
}

.orb[data-today=true] .sphere {
  filter:none;
  box-shadow:0 0 0 2px #fff0b4,0 0 16px #ffce76,0 0 30px #f4bc643d;
}

.orb[data-used=true] .sphere i:after {
  content:'✓';
  position:absolute;
  right:-11%;
  bottom:-10%;
  background:#523a2d;
  border:1px solid #c3a36b;
  border-radius:50%;
  color:white;
  font:13px/16px serif;
  width:16px;
  height:16px;
}

.orb[data-vinto=true] .sphere i:after {
  content:'★';
  position:absolute;
  right:-11%;
  bottom:-10%;
  background:#7a532f;
  border:1px solid #ffda87;
  border-radius:50%;
  color:#fff8df;
  font:13px/16px serif;
  width:16px;
  height:16px;
}

.orb[data-bonus=true] .sphere i:after {
  content:'%';
  position:absolute;
  right:-11%;
  bottom:-10%;
  background:#2f4a3a;
  border:1px solid #9fc4a9;
  border-radius:50%;
  color:#e6f5e6;
  font:12px/16px system-ui, sans-serif;
  width:16px;
  height:16px;
}

.ornaments {
  bottom:max(94px,13%);
}

.edition {
  bottom:max(12px,2%);
}

.candleshelf {
  width:min(340px,86vw);
  margin:auto;
  color:#f5dbae;
}

.tapers {
  height:31px;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  border-bottom:2px solid #bc9466;
  border-radius:0 0 38% 37% / 0 0 2px 2px;
  margin:0 auto 6px;
  padding:0 4px 3px;
}

.tapers i {
  position:relative;
  display:block;
  width:clamp(4px,.62vw,8px);
  height:12px;
  border-radius:2px 2px 1px 1px;
  background:linear-gradient(90deg,#8c6a55,#f0d5ac 42%,#bda087);
  box-shadow:1px 1px 3px #160c17;
}

.tapers i:nth-child(3n) {
  height:15px;
}

.tapers i:before {
  content:"";
  position:absolute;
  bottom:100%;
  left:calc(50% - .7px);
  height:3px;
  width:1.5px;
  background:#3b2b2c;
}

.tapers i:after {
  content:"";
  position:absolute;
  bottom:calc(100% + 1px);
  left:50%;
  width:4.5px;
  height:8px;
  border-radius:70% 28% 56% 44%;
  background:radial-gradient(ellipse at center bottom,#fffbe0 5%,#ffcf70 54%,#e99b46 100%);
  box-shadow:0 0 5px 2px #f3943580;
  transform-origin:center bottom;
  animation:flame 1.2s ease-in-out infinite alternate;
  animation-delay:var(--phase);
}

.tapers i.out:after {
  opacity:0;
  animation:none;
}

.tapers i.out {
  filter:saturate(.65);
}

@keyframes flame {
  from {
    transform:translateX(-50%) rotate(-10deg) scaleY(.91);
  }
  to {
    transform:translateX(-50%) rotate(10deg) scaleY(1.07);
  }
}

#readwish {
  margin:7px auto 0;
  padding:2px 12px;
  min-height:26px;
  font-family:Georgia,serif;
  font-style:italic;
}

#ending {
  position:absolute;
  inset:0;
  z-index:3;
  background:#251e2a;
  display:grid;
  align-items:center;
  isolation:isolate;
}

#ending:before {
  content:"";
  position:absolute;
  inset:0;
  background:var(--immagine-auguri) center/cover;
  z-index:-2;
  animation:sendWish 8s ease-out both;
}

#ending:after {
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background:linear-gradient(90deg,transparent 34%,#22192355 54%,#21182277);
}

@keyframes sendWish {
  from {
    transform:scale(1.025);
    opacity:.35;
  }
  to {
    transform:scale(1);
    opacity:1;
  }
}

.wishwords {
  margin-left:51%;
  width:min(44%,620px);
  text-align:center;
  padding:18px 12px;
  color:#fff1da;
  text-shadow:0 2px 6px #251824;
}

.wishwords .label {
  color:#f2d39a;
}

.wishwords h2 {
  margin:12px 0;
  font-weight:normal;
  line-height:.98;
  font-size:clamp(35px,4.8vw,82px);
  letter-spacing:-.045em;
}

.wishwords blockquote {
  margin:20px auto 5px;
  max-width:28em;
  font-size:clamp(17px,1.55vw,26px);
  line-height:1.4;
  text-wrap:balance;
}

.fromlia {
  font:italic clamp(22px,2.5vw,40px) Georgia,serif;
  color:#fad49d;
}

.wishwords .candleshelf {
  width:min(90%,320px);
  margin:16px auto 10px;
}

.wishwords .buttons {
  justify-content:center;
  flex-wrap:wrap;
  margin-top:14px;
}

#lastgift {
  font:13px/1.5 system-ui,sans-serif;
  color:#f7d8a0;
}

.ending .scene {
  visibility:hidden;
}

.ending #tree {
  opacity:0;
}

@media(max-aspect-ratio:4/5) {
  #ending:before {
    height:54%;
    background-position:26% 37%;
    background-size:auto 115%;
  }
  #ending:after {
    background:linear-gradient(180deg,transparent 21%,#251e2a00 39%,#251e2a 54%);
  }
  .wishwords {
    position:absolute;
    left:4%;
    right:4%;
    width:auto;
    bottom:max(3%,14px);
    margin:0;
    padding:0;
  }
  .wishwords h2 {
    font-size:clamp(34px,9vw,55px);
    margin:6px 0;
  }
  .wishwords blockquote {
    margin:10px 0 3px;
    font-size:clamp(16px,4.1vw,22px);
  }
  .wishwords .candleshelf {
    margin:10px auto 5px;
  }
  .wishwords .buttons {
    margin-top:10px;
  }
  .ornaments {
    bottom:max(89px,13%);
  }
  .edition {
    bottom:max(11px,2%);
  }
  .treeheader {
    top:max(65px,10%);
    padding:0 6px;
  }
}

@media(max-height:490px) and (orientation:landscape) {
  .ornaments {
    bottom:18%;
    top:13%;
  }
  .edition {
    bottom:4px;
  }
  .tapers {
    height:22px;
  }
  .treeheader {
    top:15%;
  }
  .wishwords {
    padding-top:30px;
  }
  .wishwords h2 {
    margin:4px 0;
    font-size:30px;
  }
  .wishwords blockquote {
    margin:5px 0;
    font-size:14px;
  }
  .wishwords .candleshelf,.wishwords .buttons {
    margin:4px auto;
  }
  .fromlia {
    font-size:20px;
  }
}

@media(prefers-reduced-motion:reduce) {
  .tapers i:after,#ending:before {
    animation:none;
  }
}

.fallback-scene {
  position:absolute;
  inset:0;
  background-size:cover;
  background-position:center;
  pointer-events:none;
}

.fallback-actor {
  position:absolute;
  left:32%;
  bottom:14%;
  height:55%;
  max-width:40%;
  object-fit:contain;
}

#avvio {
  position:fixed;
  inset:0;
  z-index:20;
  display:grid;
  align-content:center;
  justify-items:center;
  gap:18px;
  background:#251e2a;
  color:#fff1da;
  padding:24px;
  text-align:center;
}

#avvio p {
  max-width:540px;
}

@keyframes soundHint {
  50% {
    border-color:#f5cd80;
    box-shadow:0 0 0 3px #ffda8766,0 0 16px #ffce7699;
  }
}

.sound.attesa {
  animation:soundHint 1.8s ease-in-out infinite;
}

@media(prefers-reduced-motion:reduce) {
  .sound.attesa {
    animation:none;
    border-color:#f5cd80;
  }
}

