:root {
  --night: #22102a;        /* deep plum night */
  --night-2: #34183c;
  --marigold: #ffa526;
  --brass: #e2b45c;
  --rose: #f3a6b8;
  --sindoor: #c8243f;
  --ivory: #fff4e8;
  --muted: #d9c4cf;
  --display: "Yatra One", "Georgia", serif;
  --body: "Lora", "Georgia", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(120% 70% at 50% 0%, #4a2148 0%, var(--night) 55%, #160a1b 100%) fixed;
  background-color: var(--night);
  color: var(--ivory);
  font: 400 1.0625rem/1.65 var(--body);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; } /* the img rule above would otherwise un-hide the fallback render */
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 3px; border-radius: 6px; }

#petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
main, footer { position: relative; z-index: 1; }
main { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 0; }

/* ---------- countdown header ---------- */
.top { text-align: center; padding-top: 1rem; }
.hello { font: 400 clamp(1.6rem, 6vw, 2.2rem)/1 var(--display); color: var(--rose); margin: 0; }
.count {
  font: 400 clamp(6rem, 30vw, 10rem)/0.9 var(--display);
  margin: 0.2rem 0 0;
  background: linear-gradient(180deg, #ffe2a8 10%, var(--marigold) 55%, #d9741a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 24px rgba(255, 165, 38, 0.35));
}
.count-label { margin: 0.3rem 0 0; font-size: 1.15rem; color: var(--ivory); }
.next { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- gift stage ---------- */
.stage {
  position: relative; margin: 1.25rem auto 0; width: min(100%, 36rem); aspect-ratio: 1;
}
.viewer { position: absolute; inset: 0; }
.viewer::before {               /* soft diya glow behind the gift */
  content: ""; position: absolute; inset: 12%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 110, 0.32), transparent 68%);
}
.gift-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.gift-img { position: absolute; inset: 4%; width: 92%; height: 92%; object-fit: contain; opacity: 0; transform: scale(0.6); }
.stage.revealed .gift-img { animation: rise 0.9s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.stage:not(.revealed) .gift-canvas { visibility: hidden; }
@keyframes rise { to { opacity: 1; transform: scale(1); } }

/* wrapped box the gift hides inside */
.wrap {
  position: absolute; left: 50%; top: 52%; width: 46%; aspect-ratio: 1;
  transform: translate(-50%, -50%); border: 0; padding: 0; background: none; cursor: pointer;
  animation: nudge 3.2s ease-in-out infinite;
}
.wrap .body, .wrap .lid { position: absolute; left: 0; right: 0; border-radius: 10px; }
.wrap .body {
  top: 30%; bottom: 0;
  background:
    linear-gradient(90deg, transparent 43%, var(--brass) 43% 57%, transparent 57%),
    linear-gradient(160deg, #e2405f, var(--sindoor) 60%, #8e1530);
  box-shadow: inset 0 -14px 24px rgba(0, 0, 0, 0.25), 0 18px 40px rgba(0, 0, 0, 0.45);
}
.wrap .lid {
  top: 16%; height: 20%; left: -6%; right: -6%;
  background:
    linear-gradient(90deg, transparent 44%, #f6cf7a 44% 56%, transparent 56%),
    linear-gradient(180deg, #ef5a76, #b81d3b);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.7s cubic-bezier(.3, 1.6, .5, 1), opacity 0.6s 0.25s;
}
.wrap .bow { position: absolute; top: 2%; left: 50%; width: 44%; height: 18%; transform: translateX(-50%); transition: inherit; }
.wrap .bow::before, .wrap .bow::after {
  content: ""; position: absolute; top: 0; width: 52%; height: 100%;
  border: 0.55rem solid #f6cf7a; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.wrap .bow::before { left: 0; transform: rotate(-18deg); }
.wrap .bow::after { right: 0; transform: rotate(18deg); }
.wrap .tap {
  position: absolute; top: 104%; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font: 400 1.05rem var(--display); color: var(--marigold);
}
.wrap.opening { animation: none; }
.wrap.opening .lid, .wrap.opening .bow { transform: translate(18%, -140%) rotate(24deg); opacity: 0; }
.wrap.opening .body { transition: transform 0.6s 0.25s ease-in, opacity 0.5s 0.3s; transform: translateY(30%) scale(0.7); opacity: 0; }
.wrap.opening .tap { opacity: 0; }
@keyframes nudge {
  0%, 70%, 100% { transform: translate(-50%, -50%) rotate(0); }
  76% { transform: translate(-50%, -52%) rotate(-4deg); }
  82% { transform: translate(-50%, -50%) rotate(4deg); }
  88% { transform: translate(-50%, -51%) rotate(-2deg); }
}

.spark { position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border-radius: 50%; pointer-events: none;
  animation: burst 1.1s ease-out forwards; }
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0.2); opacity: 0; }
}
.drag-hint { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 0.25rem 0 0; min-height: 1.4em; }

/* ---------- today's message ---------- */
.card { text-align: center; margin: 1.5rem auto 0; max-width: 34rem; }
.day-of { color: var(--brass); margin: 0; font-size: 0.95rem; }
.card h2 { font: 400 clamp(1.7rem, 6.5vw, 2.4rem)/1.15 var(--display); margin: 0.35rem 0 0.9rem; color: var(--ivory); }
.quote { font-size: clamp(1.2rem, 4.6vw, 1.45rem); line-height: 1.6; font-style: italic; margin: 0; color: #ffeedd; }
.quote .w { display: inline-block; opacity: 0; transform: translateY(0.4em); filter: blur(4px); }
.card.show .quote .w { animation: word 0.6s forwards; animation-delay: calc(var(--i) * 55ms + 0.2s); }
@keyframes word { to { opacity: 1; transform: none; filter: none; } }
.note { margin: 1.1rem 0 0; color: var(--rose); opacity: 0; transition: opacity 0.8s; }
.card.show .note { opacity: 1; transition-delay: var(--note-delay, 1.5s); }
.gift-name { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95rem; opacity: 0; transition: opacity 0.8s; }
.card.show .gift-name { opacity: 1; transition-delay: var(--note-delay, 1.5s); }
.locked-msg { color: var(--muted); font-style: italic; }
.card.show .locked-msg { display: none; }

/* ---------- 3D calendar ---------- */
.calendar { margin: 3.5rem auto 0; text-align: center; }
.calendar h2 { font: 400 clamp(1.6rem, 6vw, 2.1rem) var(--display); margin: 0; color: var(--marigold); }
.calendar > p { margin: 0.3rem auto 0; color: var(--muted); max-width: 30rem; }
.cal-scene { perspective: 1600px; margin-top: 1.2rem; padding: 0.5rem 0 1rem; }
.cal-board {
  position: relative; transform: rotateX(20deg) scale(0.9); transform-style: preserve-3d; transform-origin: 50% 0;
  background: linear-gradient(170deg, #6b3a24, #4a2414);
  border-radius: 16px; padding: 1.6rem 0.75rem 0.9rem;
  box-shadow: 0 2px 0 #8a5333 inset, 0 14px 0 #2c140b, 0 30px 50px rgba(0, 0, 0, 0.55);
}
/* brass binder rings looping over the top edge, each through a punched hole */
.rings { position: absolute; top: -0.95rem; left: 7%; right: 7%; display: flex; justify-content: space-between; pointer-events: none; }
.rings i { position: relative; width: 0.75rem; height: 1.9rem; }
.rings i::before {            /* punched hole in the board */
  content: ""; position: absolute; left: 50%; bottom: 0; width: 0.6rem; height: 0.6rem; transform: translateX(-50%);
  border-radius: 50%; background: #1e0c06; box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.8);
}
.rings i::after {             /* the ring itself */
  content: ""; position: absolute; inset: 0 0 0.2rem; border-radius: 999px;
  border: 3px solid #f0c977; border-left-color: #b98a35; border-bottom-color: transparent;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}
.cal-head {
  font: 400 1.15rem var(--display); color: #ffe2a8; margin: 0 0 0.8rem; padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(240, 201, 119, 0.35);
}
.cal-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.45rem; transform-style: preserve-3d; }
.tile {
  position: relative; aspect-ratio: 0.82; border: 0; border-radius: 10px; padding: 0.25rem 0.15rem;
  background: linear-gradient(180deg, #fff6ea, #f1dcc6); color: #4a2414;
  box-shadow: 0 5px 0 #c9a98c, 0 8px 10px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  cursor: pointer; transition: transform 0.25s, box-shadow 0.25s;
}
.tile .d { font: 400 clamp(0.95rem, 4vw, 1.3rem)/1 var(--display); }
.tile .m { font-size: 0.62rem; line-height: 1; opacity: 0.75; }
.tile img { width: 78%; aspect-ratio: 1; object-fit: contain; margin: -0.1rem 0; }
.tile:hover, .tile:focus-visible { transform: translateZ(14px) translateY(-3px); }
.tile.today { background: linear-gradient(180deg, #ffd27a, var(--marigold)); box-shadow: 0 5px 0 #b86a10, 0 0 22px rgba(255, 165, 38, 0.8); }
.tile.selected { transform: translateZ(18px) translateY(-5px); outline: 3px solid var(--rose); outline-offset: 2px; }
.tile.locked { background: linear-gradient(180deg, #5a3550, #432740); color: #c9a9c0; box-shadow: 0 5px 0 #2a1428, 0 8px 10px rgba(0, 0, 0, 0.35); cursor: not-allowed; }
.tile.locked .lock { width: 40%; opacity: 0.7; margin: auto 0; }
.tile.birthday { grid-column: span 6; aspect-ratio: auto; flex-direction: row; justify-content: center; gap: 0.6rem; padding: 0.6rem; font-size: 0.9rem; line-height: 1.3; }
.tile.birthday .d { font-size: 1.1rem; white-space: nowrap; }
.sig { display: block; margin-top: 0.2rem; font-style: italic; }
.tile.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 150%); z-index: 5;
  background: #fff4e8; color: #3a1a2a; padding: 0.7rem 1.1rem; border-radius: 12px; max-width: calc(100% - 2rem);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); transition: transform 0.35s; text-align: center;
}
.toast.on { transform: translate(-50%, 0); }

footer { text-align: center; padding: 1rem 1rem 2.5rem; color: var(--muted); font-size: 0.95rem; }
footer p { margin: 0 auto; max-width: 30rem; }
.heart-btn { background: none; border: 0; color: var(--rose); font-size: 1.4rem; cursor: pointer; padding: 0.4rem; }

/* ---------- review page ---------- */
.review-head { text-align: center; padding: 2rem 1rem 0.5rem; }
.review-head h1 { font: 400 clamp(1.8rem, 6vw, 2.6rem) var(--display); color: var(--marigold); margin: 0; }
.review-head p { color: var(--muted); margin: 0.4rem auto 0; max-width: 36rem; }
.review-head a { color: var(--rose); }
.review { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.25rem; max-width: 76rem; margin: 1.5rem auto; padding: 0 1rem 3rem; }
.rcard { background: rgba(255, 244, 232, 0.05); border: 1px solid rgba(226, 180, 92, 0.25); border-radius: 18px; padding: 1rem; display: flex; flex-direction: column; }
.rcard img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.rcard .day-of { margin-top: 0.4rem; }
.rcard h2 { font: 400 1.35rem/1.2 var(--display); margin: 0.2rem 0 0.5rem; }
.rcard .quote { font-size: 1.02rem; }
.rcard .note, .rcard .gift-name { opacity: 1; font-size: 0.92rem; }
.rcard button { margin-top: auto; align-self: center; margin-top: 0.9rem; background: var(--marigold); color: #3a1a0a; border: 0; border-radius: 999px; padding: 0.5rem 1.2rem; cursor: pointer; }
dialog.viewer3d { width: min(92vw, 40rem); aspect-ratio: 1; padding: 0; border: 0; border-radius: 22px; background: var(--night-2); color: var(--ivory); }
dialog.viewer3d::backdrop { background: rgba(10, 4, 14, 0.75); }
dialog.viewer3d .vhost { position: absolute; inset: 0; }
dialog.viewer3d .close { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2; background: var(--ivory); color: var(--night); border: 0; border-radius: 999px; padding: 0.3rem 0.9rem; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .quote .w { opacity: 1; transform: none; filter: none; }
}
