:root {
  --ink: #e8edf1;
  --muted: #8d99a5;
  --deep: #081018;
  --panel: #111e29;
  --rust: #a9542c;
  --gold: #e2b665;
  --blue: #53d8ff;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: #05090d;
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
}

button { font: inherit; }

.card {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(255,255,255,.035) 50%, transparent 50.2%),
    radial-gradient(circle at 50% 76%, rgba(31, 154, 191, .18), transparent 24%),
    radial-gradient(circle at 50% -10%, rgba(151, 72, 36, .18), transparent 36%),
    linear-gradient(148deg, #111c25 0%, #080f16 52%, #0c151d 100%);
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.card::before {
  opacity: .52;
  background-image:
    repeating-linear-gradient(93deg, transparent 0 96px, rgba(255,255,255,.025) 97px 98px),
    repeating-linear-gradient(0deg, transparent 0 67px, rgba(255,255,255,.018) 68px 69px);
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}

.card::after {
  box-shadow: inset 0 0 190px rgba(0,0,0,.86), inset 0 -80px 120px rgba(0,0,0,.55);
}

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  min-height: 78px;
  padding: 14px clamp(20px, 4vw, 62px);
  border-bottom: 1px solid rgba(219, 230, 237, .1);
  background: rgba(8, 14, 20, .55);
  backdrop-filter: blur(10px);
}

.insignia {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(226, 182, 101, .55);
  color: var(--gold);
  transform: rotate(45deg);
  font-size: 18px;
}

.insignia::first-letter { transform: rotate(-45deg); }

.eyebrow {
  margin: 0;
  color: #a9b3bc;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.eyebrow span { color: var(--rust); padding: 0 .5rem; }

.sound-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 0;
  color: #b8c2ca;
  background: transparent;
  cursor: pointer;
}

.sound-bars { display: flex; gap: 3px; align-items: center; height: 16px; }
.sound-bars i { width: 2px; height: 7px; background: currentColor; transition: .25s; }
.sound-bars i:nth-child(2) { height: 13px; }
.sound-toggle[aria-pressed="true"] .sound-bars i { animation: equalize .8s ease-in-out infinite alternate; color: var(--blue); }
.sound-toggle[aria-pressed="true"] .sound-bars i:nth-child(2) { animation-delay: -.3s; }
.sound-toggle[aria-pressed="true"] .sound-bars i:nth-child(3) { animation-delay: -.55s; }

.stage {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: center;
  min-height: calc(100svh - 132px);
  padding: clamp(40px, 7vh, 90px) 20px 24px;
}

.message { max-height: 330px; overflow: hidden; text-align: center; max-width: 780px; transition: opacity .35s, transform .35s, max-height .45s, margin .45s; }
.chapter { margin: 0 0 18px; color: var(--rust); font-size: .78rem; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; }
h1 { margin: 0; font-family: "Oswald", sans-serif; font-size: clamp(2.6rem, 7vw, 5.7rem); font-weight: 600; line-height: .98; letter-spacing: -.025em; text-transform: uppercase; text-wrap: balance; }
h1 em { color: var(--gold); font-style: normal; }
.intro { max-width: 600px; margin: 26px auto 0; color: #9ba6af; font-size: clamp(1rem, 1.4vw, 1.12rem); line-height: 1.7; }

.gift-zone {
  position: absolute;
  left: 50%;
  top: 58%;
  bottom: auto;
  z-index: 4;
  width: min(760px, 96vw);
  transform: translate(-50%, -40%);
  text-align: center;
  transition: top .72s cubic-bezier(.22,.78,.2,1), opacity .45s ease, transform .72s cubic-bezier(.22,.78,.2,1);
  will-change: top, transform;
}

.chest-button {
  position: relative;
  width: min(680px, 96vw);
  height: clamp(290px, 42vw, 440px);
  border: 0;
  padding: 0;
  color: white;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 30px 24px rgba(0,0,0,.65));
  transition: transform .28s ease, filter .28s ease;
}

.chest-button:hover { transform: translateY(-8px) scale(1.02); filter: drop-shadow(0 38px 28px rgba(0,0,0,.72)); }
.chest-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 8px; border-radius: 28px; }
.chest-image { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; z-index: 2; transition: opacity .22s ease, transform .6s cubic-bezier(.2,.86,.22,1); }
.chest-image--closed { opacity: 1; transform: scale(.9); }
.chest-image--open { opacity: 0; transform: scale(.86) translateY(18px); }
.card.open .chest-image--closed { opacity: 0; transform: scale(.94) translateY(-8px); }
.card.open .chest-image--open { opacity: 1; transform: scale(1) translateY(0); transition-delay: .14s; }
.chest-fallback { display: none; font-size: 10rem; }
.chest-button img:not([src]), .chest-button img[src=""] { display: none; }
.chest-button img:not([src]) + .chest-fallback, .chest-button img[src=""] + .chest-fallback { display: block; }

.crystal-glow {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 58%;
  height: 34%;
  border-radius: 50%;
  background: rgba(41, 194, 255, .44);
  filter: blur(34px);
  transform: translate(-50%, -50%);
  animation: glow 1.8s ease-in-out infinite alternate;
}

.light-column {
  position: absolute;
  left: 50%;
  bottom: 95px;
  width: 340px;
  height: 0;
  transform: translateX(-50%);
  clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom, transparent, rgba(92,218,255,.16));
  filter: blur(3px);
  opacity: 0;
  transition: height .9s cubic-bezier(.2,.8,.2,1), opacity .35s;
}

.hint { margin: -16px 0 0; color: #8b969f; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.hint span { color: #d6dde2; font-weight: 800; }

.reveal {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 14px;
  width: min(700px, 94vw);
  margin-top: 28px;
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  transition: opacity .38s .12s ease, transform .45s .12s ease-out;
}

.close-reveal {
  position: absolute;
  top: -18px;
  right: -18px;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(226, 182, 101, .52);
  border-radius: 50%;
  color: #f7e1b2;
  background: rgba(10, 17, 24, .96);
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .22s ease, background .22s ease, border-color .22s ease;
}
.close-reveal:hover { transform: rotate(90deg) scale(1.06); background: #1b2b37; border-color: var(--gold); }
.close-reveal:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.congratulation { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 16px 20px; border: 1px solid rgba(226,182,101,.35); background: linear-gradient(100deg, rgba(83,46,20,.72), rgba(17,29,39,.94)); box-shadow: 0 16px 40px rgba(0,0,0,.32); }
.congratulation .crown { color: var(--gold); font-size: 2.5rem; line-height: 1; filter: drop-shadow(0 0 12px rgba(226,182,101,.25)); }
.congratulation p { margin: 0; color: #aeb8bf; font-size: .9rem; line-height: 1.5; }
.congratulation strong { color: #f5dfae; font-family: "Oswald", sans-serif; font-size: 1.2rem; letter-spacing: .035em; text-transform: uppercase; }

.video-card, .music-card {
  border: 1px solid rgba(209, 224, 233, .15);
  background: rgba(13, 23, 32, .92);
  box-shadow: 0 22px 60px rgba(0,0,0,.4);
  backdrop-filter: blur(14px);
}

.video-card { padding: 9px; }
.video-screen {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(170px, 28vw, 300px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 80%, rgba(48, 145, 169, .23), transparent 27%),
    linear-gradient(135deg, #111c25, #080e14);
}
.video-screen::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(255,255,255,.025) 5px); }
.scanline { position: absolute; left: 0; right: 0; height: 1px; top: 12%; background: rgba(95,218,255,.35); box-shadow: 0 0 12px var(--blue); animation: scan 4s linear infinite; }
.video-screen p { position: absolute; bottom: 18px; margin: 0; color: #8fa0ac; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.play-video { position: relative; display: grid; place-items: center; width: 66px; height: 66px; border: 1px solid rgba(83,216,255,.6); border-radius: 50%; background: rgba(17,38,51,.82); cursor: pointer; box-shadow: 0 0 28px rgba(56,186,222,.15); }
.play-video span { width: 0; height: 0; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 14px solid #dff8ff; margin-left: 4px; }
.play-video:hover { background: rgba(36,82,102,.9); transform: scale(1.05); }
.video-meta { display: flex; justify-content: space-between; padding: 12px 8px 4px; color: #bbc4cb; font-size: .85rem; }
.duration { color: #71808c; font-variant-numeric: tabular-nums; }

.music-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 14px 18px; }
.music-button { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid rgba(226,182,101,.5); border-radius: 50%; color: var(--gold); background: #151f27; cursor: pointer; }
.music-button[aria-pressed="true"] .music-icon { animation: pulse .7s ease-in-out infinite alternate; }
.track-copy { min-width: 0; }
.track-copy span, .track-copy strong { display: block; }
.track-kicker { color: #74828c; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }
.track-copy strong { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.progress { height: 2px; margin-top: 9px; overflow: hidden; background: #2c3943; }
.progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--rust), var(--gold)); transition: width .25s linear; }
.track-time { color: #77848d; font-size: .72rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
#birthdayTrack { display: none; }

.card.open .message { max-height: 0; margin: 0; opacity: 0; transform: translateY(-12px); }
.card.open .reveal { z-index: 5; opacity: 1; transform: translateY(0); pointer-events: auto; }
.card.open .gift-zone { z-index: 1; top: calc(100% - 54px); opacity: .62; transform: translate(-50%, -14%) scale(.4); }
.card.open .light-column { height: min(460px, 54vh); opacity: .7; }
.card.open .hint { opacity: 0; }

footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 10px 20px;
  color: #5f6b74;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.seal { color: var(--rust); }
.fog { position: absolute; width: 55vw; height: 24vh; border-radius: 50%; background: rgba(162,174,182,.055); filter: blur(50px); animation: drift 13s ease-in-out infinite alternate; }
.fog--one { left: -16vw; top: 28%; }
.fog--two { right: -19vw; bottom: 12%; animation-delay: -6s; }

@keyframes glow { to { opacity: .62; transform: translate(-50%, -50%) scale(1.15); } }
@keyframes scan { to { top: 88%; } }
@keyframes pulse { to { transform: scale(1.25) rotate(-8deg); } }
@keyframes drift { to { transform: translateX(14vw) scale(1.2); } }
@keyframes equalize { to { height: 15px; } }

@media (max-width: 700px) {
  .card.open { overflow-y: auto; }
  .topbar { grid-template-columns: 36px 1fr auto; min-height: 64px; padding-inline: 16px; }
  .eyebrow { font-size: .62rem; letter-spacing: .1em; }
  .sound-label { display: none; }
  .stage { min-height: calc(100svh - 104px); padding-top: 34px; }
  .card.open .stage { min-height: 790px; }
  .message { width: calc(100vw - 40px); max-width: calc(100vw - 40px); min-width: 0; }
  h1 { font-size: clamp(2.25rem, 11.5vw, 3.2rem); letter-spacing: -.035em; }
  h1 em { white-space: nowrap; }
  .intro { width: 100%; max-width: 100%; font-size: .95rem; line-height: 1.55; margin-top: 18px; overflow-wrap: break-word; }
  .gift-zone { top: 58%; width: min(560px, 100vw); transform: translate(-50%, -36%); }
  .chest-button { width: min(540px, 100vw); height: 320px; }
  .hint { margin-top: -22px; }
  .card.open .message { opacity: 0; }
  .card.open .reveal { margin-top: 8px; transform: translateY(0); }
  .close-reveal { position: sticky; top: 8px; justify-self: end; margin: -4px 2px -36px 0; }
  .card.open .gift-zone { top: calc(100% - 38px); transform: translate(-50%, -10%) scale(.38); }
  .video-screen { min-height: 205px; }
  .congratulation { grid-template-columns: 1fr; gap: 4px; padding: 12px 14px; text-align: center; }
  .congratulation .crown { font-size: 1.7rem; }
  .congratulation p { font-size: .78rem; }
  .congratulation strong { font-size: 1rem; }
  footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
