:root {
  --cream: #FFF6E9;
  --ink: #2B1B3D;
  --pink: #FF3D8B;
  --yellow: #FFD23F;
  --blue: #3EC5FF;
  --white: #FFFFFF;
  --muted: #EFE3D3;
  --shadow: 5px 5px 0 var(--ink);
  --display: 'Fredoka', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { background: var(--cream); }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

main {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(48px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
  flex-direction: column;
  gap: 20px;
}
.screen.active { display: flex; }
#open, #cake, #prank, #love { align-items: center; text-align: center; }

h1 {
  margin: 0;
  font: 700 44px/1 var(--display);
}
.title { font-size: 64px; line-height: .95; }
.lead { margin: 8px 0 0; font-size: 17px; font-weight: 500; line-height: 1.45; }

mark {
  background: var(--yellow);
  color: inherit;
  padding: 0 8px;
  border-radius: 10px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
  font-size: 14px;
}
.pill.blue { background: var(--blue); }

.btn {
  width: 100%;
  min-height: 64px;
  margin-top: auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--pink);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font: 700 22px var(--display);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { background: var(--muted); border-style: dashed; box-shadow: none; font-weight: 600; font-size: 19px; cursor: not-allowed; transform: none; }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.hint {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.sprinkles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.sprinkles i { position: absolute; width: 22px; height: 8px; border-radius: 4px; background: var(--pink); }
.sprinkles i:nth-child(1) { left: 6%; top: 14%; rotate: -30deg; background: var(--blue); }
.sprinkles i:nth-child(2) { right: 8%; top: 10%; rotate: 40deg; }
.sprinkles i:nth-child(3) { left: 10%; top: 48%; rotate: 70deg; background: var(--yellow); }
.sprinkles i:nth-child(4) { right: 7%; top: 55%; rotate: -60deg; background: var(--blue); }
.sprinkles i:nth-child(5) { left: 5%; top: 33%; width: 12px; height: 12px; border-radius: 50%; }
.sprinkles i:nth-child(6) { right: 6%; top: 37%; width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); border: 2px solid var(--ink); }
.sprinkles i:nth-child(7) { left: 12%; top: 78%; rotate: 20deg; background: var(--yellow); }
.sprinkles i:nth-child(8) { right: 14%; top: 84%; rotate: -15deg; }
.sprinkles i:nth-child(9) { left: 44%; top: 3%; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.sprinkles i:nth-child(10) { right: 30%; top: 95%; rotate: 50deg; background: var(--blue); }

.mute {
  position: fixed;
  z-index: 10;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--white);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.mute .slash { display: none; }
.mute[aria-pressed="true"] .slash { display: inline; }
.mute[aria-pressed="true"] .wave { display: none; }

/* open */
.gift-wrap { position: relative; flex: 1; width: 100%; display: grid; place-items: center; min-height: 260px; }
.gift-wrap::before {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 210 63 / .45), transparent 65%);
}
#gift {
  position: relative;
  width: min(240px, 62vw);
  overflow: visible;
  filter: drop-shadow(5px 5px 0 var(--ink));
  animation: wobble 2.4s ease-in-out infinite;
}
#lid { transform-box: fill-box; transform-origin: center; transition: transform .6s cubic-bezier(.3, 1.6, .5, 1); }
#gift.opening { animation: none; }
#gift.opening #lid { transform: translateY(-70px) rotate(-18deg); }
.tag {
  position: absolute;
  right: 10%;
  bottom: 18%;
  padding: 6px 16px;
  background: var(--blue);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font: 600 17px var(--display);
  rotate: 12deg;
}
@keyframes wobble {
  0%, 78%, 100% { rotate: 0deg; }
  84% { rotate: -5deg; }
  90% { rotate: 5deg; }
  95% { rotate: -2deg; }
}

/* cake */
#cake-svg { width: min(300px, 80vw); flex: 1; max-height: 380px; overflow: visible; filter: drop-shadow(4px 4px 0 var(--ink)); }
.candle { cursor: pointer; }
.flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flicker .5s ease-in-out infinite alternate;
  transition: transform .3s, opacity .3s;
}
.candle:nth-child(even) .flame { animation-duration: .65s; animation-delay: -.2s; }
.out .flame { animation: none; transform: scale(0); opacity: 0; }
@keyframes flicker {
  from { transform: scale(1, 1) rotate(-4deg); }
  to { transform: scale(.9, 1.1) rotate(4deg); }
}
.status {
  margin: 0;
  padding: 10px 18px;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
  font-size: 15px;
}

/* letter */
.paper {
  position: relative;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 28px 22px 22px;
  rotate: -1.2deg;
  font-size: 16.5px;
  line-height: 1.6;
  text-align: left;
}
.paper::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  width: 84px;
  height: 24px;
  translate: -50%;
  rotate: 3deg;
  background: rgb(62 197 255 / .85);
}
.paper p { margin: 0 0 12px; white-space: pre-line; }
.paper p:last-child { margin-bottom: 0; }
#letter-body { min-height: 220px; cursor: pointer; }
.sign { font: 600 22px var(--display); }

/* photos */
#photos { padding-inline: 0; }
#photos > :not(.track) { margin-inline: 24px; }
#photos > .btn { width: auto; }
.track {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 24px 12.5% 28px;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.polaroid {
  flex: 0 0 75%;
  scroll-snap-align: center;
  margin: 0;
  padding: 12px 12px 0;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  rotate: -2deg;
}
.polaroid:nth-child(even) { rotate: 2deg; }
.photo, .face {
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 700;
  background: var(--pink);
}
.photo { aspect-ratio: 4 / 5; border: 2px solid var(--ink); }
.photo::before, .face::before { content: attr(data-label); grid-area: 1 / 1; }
.photo img, .face img { grid-area: 1 / 1; width: 100%; height: 100%; object-fit: cover; }
.polaroid:nth-child(3n+2) .photo { background: var(--blue); }
.polaroid:nth-child(3n+3) .photo { background: var(--yellow); }
.polaroid figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 12px 4px 16px;
  font: 600 20px var(--display);
}
.polaroid small { font: 700 13px var(--body); }
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 10px; height: 10px; border: 2px solid var(--ink); border-radius: 999px; transition: width .2s, background .2s; }
.dots .on { width: 28px; background: var(--pink); }

/* wishes */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wish {
  min-height: 124px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  background: var(--pink);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 4px 4px 0 var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.wish.yellow { background: var(--yellow); rotate: 1.5deg; }
.wish.blue { background: var(--blue); rotate: -1.5deg; }
.wish.white { background: var(--white); }
.wish:active { translate: 2px 2px; box-shadow: 2px 2px 0 var(--ink); }
.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  font: 700 17px var(--display);
}
.who { display: flex; flex-direction: column; gap: 2px; }
.who b { font: 600 18px var(--display); }
.who small { font-size: 13px; font-weight: 700; }

dialog {
  width: min(92vw, 420px);
  padding: 24px;
  background: var(--white);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
}
dialog::backdrop { background: rgb(43 27 61 / .55); }
dialog .from { margin: 0 0 12px; font: 700 24px var(--display); }
dialog .msg { margin: 0 0 20px; font-size: 17px; line-height: 1.6; white-space: pre-line; }
dialog .btn { margin-top: 0; min-height: 52px; font-size: 19px; }

/* game */
.stats { display: flex; gap: 10px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.card {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  perspective: 600px;
}
.card > span {
  position: absolute;
  inset: 0;
  border: 3px solid var(--ink);
  border-radius: 14px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: transform .4s;
}
.back { display: grid; place-items: center; background: var(--pink); box-shadow: 3px 3px 0 var(--ink); }
.face { transform: rotateY(180deg); background: var(--blue); }
.card.up .back { transform: rotateY(-180deg); }
.card.up .face { transform: rotateY(0deg); }
.card.done .face { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* finale */
.coupons { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.coupon {
  position: relative;
  min-height: 72px;
  padding: 14px 18px 14px 76px;
  display: flex;
  align-items: center;
  background: var(--yellow);
  border: 3px dashed var(--ink);
  border-radius: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  font: 600 18px/1.3 var(--display);
}
.coupon:nth-child(3n+2) { background: var(--blue); }
.coupon:nth-child(3n) { background: var(--pink); }
.coupon b {
  position: absolute;
  left: 14px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
}

/* prank */
#prank { justify-content: center; }
.choices { width: 100%; margin-top: 40px; display: flex; gap: 14px; }
.choices .btn { margin-top: 0; flex: 1; }
.btn.no { background: var(--white); }
.btn.no.loose {
  position: fixed;
  z-index: 20;
  width: auto;
  flex: none;
  white-space: nowrap;
  transition: left .25s cubic-bezier(.3, 1.4, .5, 1), top .25s cubic-bezier(.3, 1.4, .5, 1);
}

/* love */
#love { justify-content: center; }
#love .paper { width: 100%; font: 600 24px/1.4 var(--display); text-align: center; }
#love .btn { margin-top: 24px; }

/* tablet */
@media (min-width: 700px) {
  main { max-width: 680px; }
  .screen { padding-inline: 48px; gap: 28px; padding-top: max(72px, env(safe-area-inset-top)); }
  h1 { font-size: 60px; }
  .title { font-size: 92px; }
  .lead { font-size: 21px; }
  .btn { width: min(100%, 440px); align-self: center; }
  .choices { width: min(100%, 440px); }
  #photos > .btn { width: min(100% - 96px, 440px); align-self: center; }
  #gift { width: 340px; }
  .gift-wrap::before { width: 440px; height: 440px; }
  #cake-svg { width: 420px; max-height: 480px; }
  .paper { padding: 40px 36px 32px; font-size: 19px; }
  #photos > :not(.track) { margin-inline: 48px; }
  .track { padding-inline: 25%; gap: 28px; }
  .polaroid { flex-basis: 50%; }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .wish { min-height: 150px; }
  .board { width: min(100%, 520px); align-self: center; gap: 14px; }
  dialog { width: min(80vw, 520px); padding: 32px; }
  dialog .msg { font-size: 19px; }
}

/* landscape tablet: keep the hero shapes from pushing buttons off screen */
@media (min-width: 700px) and (max-height: 820px) {
  #gift { width: 260px; }
  #cake-svg { width: 320px; max-height: 340px; }
  .title { font-size: 72px; }
}

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

/* photos inside a wish card */
dialog { max-height: 85dvh; overflow-y: auto; }
.wish-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 20px; }
.wish-photos:empty { display: none; }
.wish-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 3px solid var(--ink); border-radius: 12px; }
.wish.read small::after { content: ' · udah dibuka'; }
