.calendar-present {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  border: 0;
  color: #fff4de;
  background: transparent;
  isolation: isolate;
}

.calendar-present::backdrop {
  background: #190e1ab8;
  backdrop-filter: blur(6px) saturate(.66);
}

.calendar-present::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, #8d503e62 0, #60304467 32%, transparent 70%),
    linear-gradient(180deg, #1a102244, transparent 36%, #140f1e3b 63%, #130e1bba 100%);
  pointer-events: none;
}

.present-layout {
  --chest-size: clamp(114px, min(48vw, 24dvh), 214px);
  --model-height: clamp(116px, min(51vw, 24dvh), 216px);
  --caption-room: 98px;
  display: grid;
  justify-items: center;
  align-content: start;
  align-content: safe center;
  block-size: 100%;
  padding: calc(58px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px))
    calc(24px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
  overflow: hidden auto;
  overscroll-behavior: contain;
  scroll-padding-block: calc(58px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px));
}

.calendar-present[data-reward-count="4"] .present-layout { --caption-room: 144px; }

.present-tools {
  position: absolute;
  z-index: 10;
  top: calc(8px + env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 2px;
}
.present-tools button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fbecd8;
  background: transparent;
}
.present-tools .icon { width: 18px; height: 18px; }
:where(:root:not([data-touch-input])) .present-tools button:focus-visible { background: #f8ebd61c; }

@media (hover: hover) {
  .present-tools button:hover { background: #f8ebd61c; }
}
.calendar-present:not([data-phase=revealed]) .present-replay { visibility: hidden; }

.present-date {
  margin: 0;
  color: #f4d5ac;
  font-size: .875rem;
  font-weight: 610;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px #160b19;
}

.present-display {
  position: relative;
  width: min(100%, 354px);
  height: calc(var(--chest-size) + var(--model-height) + 8px);
  margin-top: clamp(12px, 2dvh, 19px);
}

.present-spotlight {
  position: absolute;
  inset: 6% -10% -5%;
  opacity: .47;
  background: radial-gradient(ellipse 52% 45% at 50% 51%, #ffd3a769 0%, #dd8c6e32 44%, transparent 100%);
  pointer-events: none;
  transition: opacity .55s;
}

.calendar-present:is([data-phase=opening], [data-phase=revealed]) .present-spotlight { opacity: 1; }

.present-parcel {
  --parcel-size: var(--chest-size);
  --chest-base: url("assets/present/chest-berry.webp");
  --chest-lid: url("assets/present/lid-berry.webp");
  position: absolute;
  bottom: 0;
  left: 50%;
  width: var(--parcel-size);
  margin-left: calc(var(--parcel-size) * -.5);
  transform-origin: center;
}

.present-parcel[data-wrap=pine] {
  --chest-base: url("assets/present/chest-pine.webp");
  --chest-lid: url("assets/present/lid-pine.webp");
}

.present-parcel[data-wrap=cream] {
  --chest-base: url("assets/present/chest-cream.webp");
  --chest-lid: url("assets/present/lid-cream.webp");
}

.present-parcel[data-wrap=plum] {
  --chest-base: url("assets/present/chest-plum.webp");
  --chest-lid: url("assets/present/lid-plum.webp");
}

.present-parcel[data-wrap=blue] {
  --chest-base: url("assets/present/chest-blue.webp");
  --chest-lid: url("assets/present/lid-blue.webp");
}

.present-parcel[data-wrap=honey] {
  --chest-base: url("assets/present/chest-honey.webp");
  --chest-lid: url("assets/present/lid-honey.webp");
}

.present-parcel > :is(.present-chest-base, .present-chest-lid, .present-chest-front, .present-chest-silk, .present-chest-bow) {
  position: absolute;
  display: block;
  inset: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}

.present-chest-base,
.present-chest-front { background-image: var(--chest-base); }

.present-chest-base { z-index: 1; }

.present-chest-front {
  z-index: 4;
  clip-path: polygon(0 64%, 10% 64%, 70% 72.4%, 92% 57.3%, 100% 57.3%, 100% 100%, 0 100%);
}

.present-parcel > .present-chest-lid {
  z-index: 2;
  background-image: var(--chest-lid);
  background-position: 0 0;
  background-size: 1000% 100%;
}

.present-chest-silk {
  z-index: 6;
  background-image: url("assets/present/silk-band.webp");
  transform-origin: 46% 56%;
}

.present-chest-bow {
  z-index: 7;
  background-image: url("assets/present/silk-bow.webp");
  transform-origin: 44% 52%;
}

.present-chest-bow-left {
  --ribbon-drift: -20%;
  --ribbon-roll: -22deg;
  clip-path: inset(0 55.8% 0 0);
}

.present-chest-bow-right {
  --ribbon-drift: 23%;
  --ribbon-roll: 29deg;
  clip-path: inset(0 0 0 44.2%);
}

.present-parcel::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: auto -18% 2%;
  height: 19%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #170b1aee 0%, #1c0d1aa6 42%, transparent 70%);
  filter: blur(3px);
}

.present-parcel::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 42% 6% auto;
  height: 25%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff9d8 0%, #ffd08d 27%, #eb8f59 49%, transparent 72%);
  filter: blur(11px);
  opacity: 0;
  pointer-events: none;
}

.present-model {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  height: var(--model-height);
  transform-origin: 50% 76%;
  opacity: 0;
  pointer-events: none;
}

.present-model > img {
  position: absolute;
  inset: 0;
  width: 89%;
  height: 89%;
  margin: auto;
  object-fit: contain;
  filter: drop-shadow(0 5px 16px #200e21a6);
}

:is(.present-model, .daily-prize)[data-gift-renderer=webgl] > img { visibility: hidden; }

.daily-prize:is([data-reward-count="2"], [data-reward-count="3"], [data-reward-count="4"]) {
  width: min(96%, 370px);
  height: min(75%, 246px);
  aspect-ratio: auto;
}

:is(.present-model, .daily-prize):is([data-reward-count="2"], [data-reward-count="3"], [data-reward-count="4"]) > :is(#daily-art, #present-art, .bundle-companion) {
  position: absolute;
  inset: auto;
  top: var(--bundle-top, 4%);
  left: var(--bundle-left, 0%);
  width: var(--bundle-width, 48%);
  height: var(--bundle-height, 88%);
  margin: 0;
  object-fit: contain;
}

:is(.present-model, .daily-prize)[data-reward-count="2"] > img {
  --bundle-offset: 33%;
  --bundle-left: 3%;
}

:is(.present-model, .daily-prize)[data-reward-count="2"] > [data-bundle-index="1"] {
  --bundle-offset: -39%;
  --bundle-left: 49%;
  --bundle-width: 46%;
}

:is(.present-model, .daily-prize)[data-reward-count="3"] > img {
  --bundle-offset: 79%;
  --bundle-width: 34%;
}

:is(.present-model, .daily-prize)[data-reward-count="3"] > [data-bundle-index="1"] {
  --bundle-offset: 0%;
  --bundle-left: 33%;
  --bundle-top: 1%;
}

:is(.present-model, .daily-prize)[data-reward-count="3"] > [data-bundle-index="2"] {
  --bundle-offset: -79%;
  --bundle-left: 66%;
}

:is(.present-model, .daily-prize)[data-reward-count="4"] > img {
  --bundle-offset: 44%;
  --bundle-rise: 55%;
  --bundle-left: 15%;
  --bundle-top: -1%;
  --bundle-width: 35%;
  --bundle-height: 49%;
}

:is(.present-model, .daily-prize)[data-reward-count="4"] > :is([data-bundle-index="1"], [data-bundle-index="3"]) {
  --bundle-offset: -44%;
  --bundle-left: 50%;
}

:is(.present-model, .daily-prize)[data-reward-count="4"] > :is([data-bundle-index="2"], [data-bundle-index="3"]) {
  --bundle-rise: -32%;
  --bundle-top: 48%;
}

:is(.calendar-present[data-phase=opening] .present-model, .daily-card[data-mode=opening] .daily-prize):is([data-reward-count="2"], [data-reward-count="3"], [data-reward-count="4"]) > img {
  animation: bundle-spread 1.4s cubic-bezier(.21,.71,.28,1) both;
}

@keyframes bundle-spread {
  0%, 40% { transform: translate(var(--bundle-offset, 0%), var(--bundle-rise, 0%)) scale(.49); }
  81% { transform: translateX(-3%) scale(1.07); }
  100% { transform: none; }
}

.present-effect {
  position: absolute;
  z-index: 8;
  bottom: 21%;
  left: 50%;
  width: min(195%, 420px);
  aspect-ratio: 3 / 2;
  translate: -50% 0;
  pointer-events: none;
}

.present-caption {
  width: min(100%, 318px);
  min-height: var(--caption-room);
  padding-top: clamp(13px, 2.2dvh, 19px);
  opacity: 0;
  text-align: center;
}

.present-caption h2 {
  margin: 0;
  color: #fff6e9;
  font-size: clamp(1.20rem, 5vw, 1.43rem);
  font-weight: 610;
  line-height: 1.35;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.present-caption h2:focus { outline: none; }

.present-caption p {
  margin: 5px 0 0;
  color: #dbcaba;
  font-size: .84rem;
  line-height: 1.5;
  word-break: keep-all;
}

.calendar-present[data-phase=revealed] .present-caption {
  opacity: 1;
  animation: present-caption-in .42s cubic-bezier(.2,.73,.25,1) both;
}

.present-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(100%, 254px);
  margin: clamp(12px, 1.8dvh, 17px) auto 0;
}

.present-actions a {
  color: #fff5e7;
  text-decoration: none;
}

.present-actions .present-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 24px;
  border: 1px solid #efddd74f;
  border-radius: 12px;
  background: linear-gradient(155deg, #f7e5e42e, #f7e5e40c 75%), #3b293ab3;
  box-shadow: inset 0 1px 0 #fff6ea25, 0 4px 14px #130c1c45;
  -webkit-backdrop-filter: blur(16px) saturate(1.18);
  backdrop-filter: blur(16px) saturate(1.18);
  color: #fff3e4;
  font-size: .89rem;
  line-height: 1.3;
  font-weight: 630;
}

@media (hover: hover) {
  .present-actions .present-primary:hover { border-color: #efddd78a; }
}

.present-actions .present-primary:focus-visible {
  outline: 2px solid #f5dcb8;
  outline-offset: 3px;
}

.present-primary::after {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(45deg);
  opacity: .72;
}

.present-actions .present-secondary {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding-inline: 12px;
  color: #e7d5c2;
  font-size: .8rem;
  font-weight: 520;
}

.present-actions:not([data-reward-size="1"]):not([hidden]),
.daily-result-actions[data-reward-size="4"]:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 310px);
}

.present-actions:not([data-reward-size="1"]) .present-primary,
.daily-result-actions[data-reward-size="4"] > [data-hang] {
  justify-content: space-between;
  min-width: 0;
  min-height: 48px;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 550;
  text-align: start;
  word-break: keep-all;
}

.daily-result-actions[data-reward-size="4"] > [data-hang] {
  display: flex;
  align-items: center;
  color: #f9ecda;
  background: #f7e8d20d;
  border: 1px solid #eedfc230;
}

.present-streak-hint {
  color: #ffe7b7;
  text-align: center;
}

.present-streak-hint summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 7px;
  padding-inline: 8px;
  color: inherit;
  font-size: .8rem;
  font-weight: 730;
  cursor: pointer;
  list-style: none;
}

.present-streak-hint summary::-webkit-details-marker { display: none; }

.present-streak-hint summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.present-streak-hint[open] summary::after { transform: translateY(1px) rotate(225deg); }

.present-streak-hint p {
  margin: 0;
  color: #f7dfc5;
  font-size: .8rem;
}

.calendar-present[data-phase=opening] .present-chest-bow {
  animation: present-bow-release .85s cubic-bezier(.25,.11,.27,1) both;
}

.calendar-present[data-phase=opening] .present-chest-silk {
  animation: present-silk-slide .88s cubic-bezier(.29,.09,.23,1) both;
}

.calendar-present[data-phase=opening] .present-chest-lid {
  animation: present-chest-hinge 1.38s steps(9, end) both;
}

.calendar-present[data-phase=opening] .present-parcel::after {
  animation: present-glow 1.57s ease-out both;
}

.calendar-present[data-phase=opening] .present-model {
  animation: present-emerge 1.46s cubic-bezier(.31,.04,.2,1) both;
}

.calendar-present[data-phase=revealed] .present-chest-lid { background-position-x: 100%; }
.calendar-present[data-phase=revealed] :is(.present-chest-bow, .present-chest-silk) { visibility: hidden; }
.calendar-present[data-phase=revealed] .present-parcel::after { opacity: .41; }
.calendar-present[data-phase=revealed] .present-model { opacity: 1; }

@keyframes present-bow-release {
  0%, 23% { opacity: 1; transform: none; }
  47% { opacity: 1; transform: translateY(-7%) scale(1.06, .97); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--ribbon-drift), -13%) rotate(var(--ribbon-roll)) scale(.92, .73); }
}

@keyframes present-silk-slide {
  0%, 29% { opacity: 1; transform: none; }
  49% { opacity: 1; transform: translateY(-5%) skewX(-5deg); }
  100% { opacity: 0; transform: translate(-27%, -25%) rotate(-19deg) scale(1.20, .45); }
}

@keyframes present-chest-hinge {
  0%, 36% { background-position-x: 0%; }
  81%, 100% { background-position-x: 100%; }
}

@keyframes present-glow {
  0%, 28% { opacity: 0; transform: scale(.76); }
  52% { opacity: .99; transform: scale(1.21); }
  100% { opacity: .41; transform: none; }
}

@keyframes present-emerge {
  0%, 37% { opacity: 0; transform: translateY(calc(var(--model-height) * .89 + var(--chest-size) * .37)) scale(.26); }
  45% { opacity: .68; }
  81% { opacity: 1; transform: translateY(-5%) scale(1.025); }
  100% { opacity: 1; transform: none; }
}

@keyframes present-caption-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

@media (max-height: 690px) {
  .present-layout {
    --chest-size: clamp(97px, min(43vw, 22dvh), 171px);
    --model-height: clamp(106px, min(49vw, 22dvh), 171px);
  }

  .present-display { margin-top: 10px; }

  .present-caption { padding-top: 12px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .present-layout {
    --chest-size: clamp(64px, 23dvh, 124px);
    --model-height: clamp(72px, 29dvh, 150px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "inscription caption"
      "date caption"
      "display caption";
    column-gap: clamp(12px, 4vw, 52px);
    max-inline-size: 960px;
    margin-inline: auto;
    padding-block-start: calc(54px + env(safe-area-inset-top, 0px));
    padding-block-end: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .present-inscription { grid-area: inscription; }
  .present-date { grid-area: date; }
  .present-display { grid-area: display; margin-top: 6px; }
  .present-caption {
    grid-area: caption;
    align-self: start;
    align-self: safe center;
    min-height: 0;
    padding-top: 0;
  }

  .present-actions { margin-block-start: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .present-spotlight { transition: none; }
  .calendar-present[data-phase=opening] :is(.present-chest-bow, .present-chest-silk) {
    animation: none;
    visibility: hidden;
  }
  .calendar-present[data-phase=opening] .present-chest-lid {
    animation: none;
    background-position-x: 100%;
  }
  .calendar-present[data-phase=opening] .present-model {
    animation: none;
    opacity: 1;
  }
  .calendar-present[data-phase=revealed] .present-caption { animation: none; }
  :is(.calendar-present[data-phase=opening] .present-model, .daily-card[data-mode=opening] .daily-prize) > img { animation: none; }
}

.present-caption p:empty { display: none; }
