@font-face {
  font-family: "BirthdayBrush";
  src: url("assets/fonts/brush-zhufuta.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --gold-hi: #fff2c8;
  --gold: #f2d18c;
  --gold-mid: #d8a951;
  --gold-deep: #8d5d16;
  --red-ink: #4d0303;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "宋体", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background: #160000;
}

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #160000;
  color: var(--gold);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background-image: url("assets/grain.png");
  background-repeat: repeat;
  opacity: 0.28;
  mix-blend-mode: soft-light;
}

button {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.scene {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(78% 62% at 50% 46%, #8a100a 0%, #5d0504 34%, #2f0101 68%, #160000 100%);
}

.ambient {
  position: absolute;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  background-image: url("assets/poster-desktop.webp");
  background-position: center;
  background-size: cover;
  filter: blur(58px) brightness(0.5) saturate(1.15);
  opacity: 0.9;
  transform: scale(1.08);
}

@media (max-aspect-ratio: 1 / 1) {
  .ambient {
    background-image: url("assets/poster-mobile.webp");
    filter: blur(58px) brightness(0.46) saturate(1.18);
  }
}

.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(42% 36% at 50% 47%, rgba(255, 166, 76, 0.17), transparent 72%),
    radial-gradient(90% 55% at 50% 108%, rgba(255, 109, 45, 0.08), transparent 65%);
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background:
    radial-gradient(125% 92% at 50% 50%, transparent 52%, rgba(10, 0, 0, 0.58) 100%);
}

.poster {
  position: relative;
  z-index: 2;
  flex: none;
  width: min(100vw, calc(100vh * 1.7777));
  width: min(100vw, calc(100svh * 1.7777));
  aspect-ratio: 1672 / 941;
  background: #500404;
  container-type: size;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(255, 224, 160, 0.12),
    0 36px 100px rgba(0, 0, 0, 0.55),
    0 0 90px rgba(255, 128, 45, 0.07);
}

/* A near-16:9 screen gets the full-bleed treatment. Other ratios keep the
   whole artwork visible instead of cutting the dedication or the date. */
@media (min-aspect-ratio: 1.72) and (max-aspect-ratio: 1.84) {
  .poster {
    width: max(100vw, calc(100vh * 1.7777));
    width: max(100vw, calc(100svh * 1.7777));
  }
}

.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border: 1px solid rgba(255, 226, 166, 0.2);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.14);
}

.poster-media,
.poster-media img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.poster-media img {
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.wish {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 63.2%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wish-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.2cqw, 22px);
}

.wish-btn {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 56px;
  height: clamp(56px, 7.4cqh, 88px);
  min-width: 252px;
  min-width: clamp(252px, 24cqw, 440px);
  padding: 0 24px;
  padding: 0 clamp(24px, 2.8cqw, 46px);
  overflow: hidden;
  border: 1px solid rgba(255, 226, 166, 0.68);
  border-radius: 3px;
  background:
    radial-gradient(120% 180% at 50% -25%, rgba(255, 214, 136, 0.26), transparent 56%),
    linear-gradient(180deg, rgba(120, 9, 6, 0.34), rgba(58, 2, 2, 0.5));
  box-shadow:
    inset 0 1px 0 rgba(255, 242, 202, 0.34),
    inset 0 14px 30px rgba(255, 178, 86, 0.07),
    inset 0 -12px 24px rgba(0, 0, 0, 0.26),
    0 12px 30px rgba(30, 0, 0, 0.34),
    0 0 34px rgba(255, 174, 72, 0.14);
  color: var(--gold-hi);
  cursor: pointer;
  isolation: isolate;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(6px) brightness(0.68) saturate(1.12);
  backdrop-filter: blur(6px) brightness(0.68) saturate(1.12);
  transition:
    transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 0.35s ease,
    border-color 0.35s ease,
    background 0.35s ease;
}

.wish-btn::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 1;
  pointer-events: none;
  border: 1px solid rgba(255, 226, 166, 0.24);
  border-radius: 1px;
}

.wish-btn::after {
  content: "";
  position: absolute;
  inset: 9px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.62;
  background:
    linear-gradient(#f6d89a, #f6d89a) left top / 13px 1px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) left top / 1px 13px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) right top / 13px 1px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) right top / 1px 13px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) left bottom / 13px 1px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) left bottom / 1px 13px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) right bottom / 13px 1px no-repeat,
    linear-gradient(#f6d89a, #f6d89a) right bottom / 1px 13px no-repeat;
}

.wish-btn-label,
.wish-btn-response {
  position: relative;
  z-index: 3;
  transition:
    opacity 0.26s ease,
    transform 0.26s ease;
}

.wish-btn-label {
  display: block;
  font-family: "BirthdayBrush", var(--serif);
  font-size: 30px;
  font-size: clamp(30px, 4.9cqh, 48px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.14em;
  padding-left: 0.14em;
  transform: translateY(-1px);
  background: linear-gradient(180deg, #fff7d8 0%, #f9dda1 34%, #e2b35b 64%, #f8e4b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(0 1px 0 rgba(255, 244, 208, 0.22))
    drop-shadow(0 2px 1px rgba(76, 26, 0, 0.6))
    drop-shadow(0 4px 8px rgba(34, 0, 0, 0.35))
    drop-shadow(0 0 14px rgba(255, 184, 80, 0.22));
}

.wish-btn-response {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-size: clamp(24px, 3.2cqh, 36px);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold-hi);
  text-shadow:
    0 1px 1px rgba(58, 16, 0, 0.6),
    0 0 18px rgba(255, 186, 82, 0.4);
  transform: translateY(7px) scale(0.97);
}

.wish-btn-sheen {
  position: absolute;
  inset: -60% -30%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 244, 208, 0.5) 50%,
    transparent 62%
  );
  transform: translateX(-130%) rotate(8deg);
}

@media (hover: hover) and (pointer: fine) {
  .wish-btn:hover {
    border-color: rgba(255, 234, 184, 0.82);
    background:
      radial-gradient(120% 180% at 50% -25%, rgba(255, 222, 154, 0.32), transparent 56%),
      linear-gradient(180deg, rgba(132, 12, 7, 0.4), rgba(68, 3, 3, 0.56));
    box-shadow:
      inset 0 1px 0 rgba(255, 238, 190, 0.28),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 12px 30px rgba(30, 0, 0, 0.36),
      0 0 34px rgba(255, 176, 78, 0.18);
    transform: translateY(-1px);
  }

  .wish-btn:hover .wish-btn-sheen {
    opacity: 1;
    animation: sheen 0.95s ease 0.04s;
  }
}

.wish-btn:focus-visible {
  outline: 2px solid rgba(255, 238, 188, 0.92);
  outline-offset: 5px;
}

.wish-btn:active {
  transform: translateY(1px) scale(0.992);
}

.wish-btn.is-blessed {
  border-color: rgba(255, 238, 190, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 190, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 12px 30px rgba(30, 0, 0, 0.36),
    0 0 38px rgba(255, 180, 80, 0.26);
}

.wish-btn.is-blessed .wish-btn-label {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
}

.wish-btn.is-blessed .wish-btn-response {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: response-glow 1.05s ease both;
}

.wish-btn.is-blessed .wish-btn-sheen {
  opacity: 1;
  animation: sheen 0.8s ease;
}

.bless-tally {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 16px);
  margin: 0;
  padding: 0;
  opacity: 0;
  transform: translateX(-50%);
  color: rgba(252, 230, 180, 0.82);
  font-family: var(--serif);
  font-size: clamp(10px, 0.82vw, 13px);
  line-height: 1;
  letter-spacing: 0.18em;
  white-space: nowrap;
  text-shadow: 0 1px 10px rgba(30, 0, 0, 0.95), 0 0 20px rgba(255, 175, 75, 0.12);
  transition: opacity 0.7s ease 0.1s;
  pointer-events: none;
}

.bless-tally.is-visible {
  opacity: 1;
}

.bless-tally b {
  display: inline-block;
  min-width: 1.2em;
  color: var(--gold-hi);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.bless-tally b.is-bumped {
  animation: count-bump 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tally-rule {
  display: block;
  width: clamp(20px, 2.4vw, 46px);
  height: 1px;
  background: linear-gradient(90deg, rgba(247, 211, 144, 0), rgba(247, 211, 144, 0.55));
}

.tally-rule:last-child {
  transform: scaleX(-1);
}

@keyframes sheen {
  0% {
    transform: translateX(-130%) rotate(8deg);
  }
  100% {
    transform: translateX(130%) rotate(8deg);
  }
}

@keyframes response-glow {
  0% {
    opacity: 0;
    transform: translateY(7px) scale(0.97);
    filter: brightness(1.4);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  72% {
    opacity: 1;
    filter: brightness(1);
  }
  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

@keyframes count-bump {
  0% {
    transform: translateY(0);
    color: var(--gold-hi);
    text-shadow: 0 0 0 rgba(255, 190, 90, 0);
  }
  35% {
    transform: translateY(-3px);
    color: #fff9e4;
    text-shadow: 0 0 12px rgba(255, 190, 90, 0.8);
  }
  100% {
    transform: translateY(0);
    color: var(--gold-hi);
    text-shadow: 0 0 0 rgba(255, 190, 90, 0);
  }
}

@media (max-aspect-ratio: 1 / 1) {
  .poster {
    width: min(100vw, calc(100vh * 0.6666667));
    width: min(100vw, calc(100svh * 0.6666667));
    aspect-ratio: 1024 / 1536;
    box-shadow:
      0 0 0 1px rgba(255, 224, 160, 0.22),
      0 26px 80px rgba(0, 0, 0, 0.58),
      0 0 70px rgba(255, 128, 45, 0.09);
  }

  .wish {
    top: 53.7%;
  }
}

@media (max-height: 780px) {
  .wish-btn {
    height: clamp(44px, 7.4cqh, 64px);
    min-width: clamp(220px, 24cqw, 340px);
  }

  .wish-btn-label {
    font-size: clamp(26px, 4.9cqh, 38px);
  }

  .wish-btn-response {
    font-size: clamp(21px, 3.2cqh, 30px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .poster {
    animation: poster-reveal 1.25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .wish {
    animation: wish-reveal 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.42s both;
  }
}

@keyframes poster-reveal {
  from {
    opacity: 0;
    transform: scale(1.018);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wish-reveal {
  from {
    opacity: 0;
    transform: translate(-50%, 9px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .poster,
  .wish,
  .bless-tally {
    animation: none;
  }

  .wish-btn,
  .wish-btn-label,
  .wish-btn-response,
  .bless-tally {
    transition-duration: 0.01ms;
  }

  .wish-btn-sheen {
    display: none;
  }

  .wish-btn.is-blessed .wish-btn-response {
    animation: none;
  }

  .bless-tally b.is-bumped {
    animation: none;
  }
}
