#birthday-stage {
  position: relative;
  width: 100%;
  background: #271b2b;
  color: #512d22;
  container-type: inline-size;
}
#birthday-stage canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  touch-action: manipulation;
}
#birthday-stage.daughter-scroll canvas { image-rendering:auto; }
#birthday-stage :focus-visible { outline: 2px solid #ffe3a0; outline-offset: 2px; }
.birthday-orb-hud {
  position: absolute;
  top: clamp(57px,6cqw,83px);
  right: 2.4%;
  pointer-events: none;
}
.birthday-orbs {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: #442837e8;
  border: 2px solid #be8c61;
  box-shadow: 2px 2px #281928b5;
  color: #c8b6ae;
  font-size: clamp(9px,1.13cqw,16px);
}
.birthday-orb { display: flex; align-items: center; gap: 4px; padding: 3px 6px; opacity: .78; }
.birthday-orb i, .birthday-fusion i {
  display: block;
  width: 10px;
  height: 10px;
  background: #68545d;
  clip-path: polygon(24% 0,76% 0,76% 16%,100% 16%,100% 80%,76% 80%,76% 100%,24% 100%,24% 80%,0 80%,0 16%,24% 16%);
}
.birthday-orb.lit { opacity: 1; color: #fff1cf; }
.birthday-orb:first-child.lit i, .birthday-fusion i:first-child { background: #a3d789; }
.birthday-orb:nth-child(2).lit i, .birthday-fusion i:nth-child(2) { background: #ffd267; }
.birthday-orb:last-child.lit i, .birthday-fusion i:last-child { background: #97dcee; }
.birthday-controls { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.birthday-controls > * { pointer-events: auto; }
.birthday-controls button {
  font: inherit;
  line-height: 1.1;
  color: #542e24;
  background: #ffdaad;
  border: 2px solid #613a26;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px #fff0c1, 2px 2px #4e2e2a82;
  min-height: clamp(28px,3.3cqw,46px);
  padding: 5px 11px;
  cursor: pointer;
  touch-action: manipulation;
}
.birthday-controls button:hover { background: #ffe8bb; }
.birthday-controls .birthday-main { white-space: nowrap; }
.daughter-board {
  position: absolute;
  left: 55%;
  bottom: 25%;
  transform: translateX(-50%);
}

.game:has(#birthday-stage.daughter-watch:not([hidden])) .game-hud,
#birthday-stage.daughter-watch .birthday-orb-hud { visibility:hidden; }
.daughter-scroll .birthday-orb-hud { display:none; }
.daughter-scroll .daughter-dialogue,
.daughter-scroll .daughter-credits,
.daughter-scroll .daughter-credits button,
.daughter-scroll .daughter-board button {
  font-family: 'Zpix', 'Fusion Pixel', monospace !important;
  font-weight: 400;
  text-shadow: none;
}
.daughter-scroll .daughter-dialogue {
  text-align: left;
  padding: 1.5cqw 2.2cqw 2.2cqw;
  background: #f2ddba;
  border: 3px solid #542f24;
  box-shadow: inset 0 0 0 2px #b2906b, 4px 4px #35241de0;
}
.daughter-scroll .daughter-dialogue strong { display:block; margin-bottom:.6cqw; color:#79513d; }
.daughter-scroll .daughter-dialogue span { line-height:1.65; color:#4c2d22; }
.daughter-scroll .daughter-dialogue i {
  position:absolute;
  right:1.2cqw;
  bottom:.85cqw;
  width:8px;
  height:5px;
  background:#80583e;
  clip-path:polygon(0 0,100% 0,100% 40%,75% 40%,75% 75%,62.5% 75%,62.5% 100%,37.5% 100%,37.5% 75%,25% 75%,25% 40%,0 40%);
}
.daughter-scroll .daughter-dialogue:focus-visible { outline: none; box-shadow: inset 0 0 0 2px #a6835c, 4px 4px #35241de0; }
.daughter-credits {
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  background:#40251e;
  color:#f3d39a;
  animation:daughter-dim 2.2s ease both;
}
.daughter-credits h2 {
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%,-50%);
  font-size:clamp(16px,3.2cqw,43px);
  margin:0;
  white-space:nowrap;
  letter-spacing:.08em;
  animation:daughter-write 1.9s steps(8,end) 2s both;
}
.daughter-credits button {
  font-size:clamp(12px,1.45cqw,20px);
}
.daughter-credits-content {
  width:min(92%,640px);
  text-align:center;
  font-size:clamp(12px,1.65cqw,22px);
  line-height:1.5;
  animation:daughter-replay .7s ease .52s both;
}
.daughter-credits-content p { margin:.6em 0; }
.daughter-credits-content button + button { margin-left:8px; }
.daughter-scroll[data-phase="exchange"] .daughter-credits,
.daughter-scroll[data-phase="reward"] .daughter-credits,
.daughter-scroll[data-phase="farewell"] .daughter-credits { animation:none; }
.daughter-scroll[data-phase="exchange"] .daughter-credits h2,
.daughter-scroll[data-phase="reward"] .daughter-credits h2,
.daughter-scroll[data-phase="farewell"] .daughter-credits h2 { top:12%; animation:none; }
.daughter-scroll[data-phase="exchange"] .daughter-credits h2 { animation:daughter-lift .55s ease both; }
.daughter-scroll[data-phase="reward"] .daughter-credits-content {
  align-self:start;
  margin-top:11%;
  animation-delay:.1s;
}
.daughter-credits-content img {
  display:block;
  width:auto;
  height:32cqw;
  max-width:100%;
  max-height:56vh;
  object-fit:contain;
  margin:0 auto;
  border:2px solid #c99c61;
  box-shadow:3px 3px #261510;
  image-rendering:auto;
}
.daughter-scroll[data-phase="reward"] .daughter-credits button { animation:daughter-replay 1.2s ease 1.6s both; }
@keyframes daughter-dim { from { opacity:0; } to { opacity:1; } }
@keyframes daughter-write { from { clip-path:inset(0 100% 0 0); } to { clip-path:inset(0); } }
@keyframes daughter-lift { from { top:50%; } to { top:12%; } }
@keyframes daughter-replay { from { opacity:0; visibility:hidden; } to { opacity:1; visibility:visible; } }
.birthday-walk-note {
  position: absolute;
  left: 50%;
  bottom: 2%;
  width: max-content;
  max-width: 94%;
  transform: translateX(-50%);
  padding: 3px 4px 3px 9px;
  background: #43252bed;
  color: #ffe8c1;
  border: 2px solid #b9875d;
  font-size: clamp(10px,1.32cqw,18px);
}
.birthday-walk-note button { margin-left: 10px; }
.birthday-talk, .birthday-card {
  position: absolute;
  border: 3px solid #633927;
  background: #f7e5c3;
  box-shadow: inset 0 0 0 2px #d4a571, 4px 4px #44243b96;
  font-size: clamp(10px,1.48cqw,20px);
}
.birthday-talk {
  left: 12%;
  right: 12%;
  bottom: 3.5%;
  padding: clamp(6px,1.1cqw,16px) clamp(10px,1.9cqw,27px);
  min-height: clamp(39px,7cqw,97px);
}
.birthday-talk > strong {
  color: #85442e;
  text-shadow: 1px 1px #fdf2d6;
  font-size: 1.1em;
}
.birthday-talk p { margin: .28em 0; max-width: 86%; line-height: 1.4; }
.birthday-talk small { display: block; color: #886b39; padding-bottom: 4px; }
.birthday-talk .birthday-main { display: block; margin: 0 0 0 auto; }
.birthday-portrait {
  display: block;
  width: clamp(45px,11cqw,132px);
  aspect-ratio: 124 / 120;
  background: url(birthday-cast.png) var(--col) var(--row) / 400% 200% no-repeat;
  image-rendering: pixelated;
}
.birthday-talk > .birthday-portrait { position: absolute; left: 1%; bottom: 100%; pointer-events: none; }
.birthday-card {
  left: 50%; top: 54%;
  transform: translate(-50%,-50%);
  text-align: center;
  width: max-content;
  max-width: 87%;
  padding: clamp(6px,1.1cqw,17px) clamp(9px,1.75cqw,24px);
}
.birthday-card h2 { margin: .15em 0 .36em; color: #743c2d; font-size: clamp(14px,2.24cqw,31px); text-shadow: 1px 1px #fff1c5; }
.birthday-card p { margin: .3em 0 .5em; line-height: 1.35; }
.birthday-food-card { top: auto; bottom: 2.5%; transform: translateX(-50%); }
#birthday-stage[data-phase="candles"] .birthday-food-card { animation: birthday-cake-in .32s .72s both; }
@keyframes birthday-cake-in { from { opacity: 0; } to { opacity: 1; } }
.birthday-controls .birthday-food-art {
  display: block;
  position: relative;
  padding: 0;
  margin: 2px auto 4px;
  width: clamp(72px,9.4cqw,138px);
  border: none;
  box-shadow: none;
  background: transparent;
}
.birthday-food-art img { width: 100%; display: block; image-rendering: pixelated; }
.birthday-castle-card {
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center;
  gap:clamp(7px,1.7cqw,22px);
}
.birthday-controls .birthday-castle-card .birthday-food-art {
  width:clamp(85px,15cqw,190px);
  margin:0;
}
.birthday-castle-card h2 { font-size:clamp(13px,1.8cqw,26px); }
.birthday-flames {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.birthday-flames::after {
  content:'';
  position:absolute;
  left:78.5%;
  top:30.5%;
  width:2%;
  height:9%;
  background:#e29d89;
  box-shadow:inset 1px 0 #ffeecd;
}
.birthday-flames i {
  position: absolute;
  top: 22%;
  left: 77%;
  width: 5%;
  height: 10%;
  background: #ffdd85;
  clip-path: polygon(43% 0,65% 19%,100% 64%,83% 89%,62% 100%,27% 100%,0 68%,17% 33%);
  animation: birthday-flame .56s ease-in-out infinite alternate;
}
@keyframes birthday-flame { to { transform: scale(.78,1.15); background: #ffb352; } }
.birthday-steam { position: absolute; left: 53%; top: -8%; width: 8%; height: 24%; border-left: 3px solid #fffae0a0; transform: skew(-13deg); animation: birthday-steam 1.45s ease-out infinite; }
@keyframes birthday-steam { from { transform: translateY(12px) skew(12deg); opacity: .25; } 60% { opacity: 1; } to { transform: translateY(-9px) skew(-12deg); opacity: 0; } }
.birthday-health small { color: #56703d; }
.birthday-health h2 { color: #3b6b3e; font-size: clamp(22px,4.2cqw,52px); }
.birthday-health h2 span { color: #6c8442; }
.birthday-hp {
  width: 100%;
  height: clamp(10px,1.7cqw,26px);
  background: #f0d79d;
  border: 2px solid #586242;
  margin-bottom: .5em;
}
.birthday-hp::before {
  content: '';
  display: block;
  height: 100%;
  background: #91c46b;
  box-shadow: inset 0 2px #cde28c;
  animation: birthday-hp .75s steps(14,end) both;
}
@keyframes birthday-hp { from { width: 10%; } to { width: 100%; } }
.birthday-photo-card { width: 64%; max-width: 730px; }
.birthday-photo {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: clamp(3px,.65cqw,8px) solid #fff1d4;
  outline: 2px solid #9e6744;
  image-rendering: pixelated;
}
.birthday-chorus { display: flex; justify-content: center; gap: .36cqw; margin: 2px 0; }
.birthday-chorus .birthday-portrait { width: clamp(20px,4cqw,46px); }
.birthday-photo-card p { font-size: .9em; }
.birthday-fusion { display: flex; justify-content: center; gap: 6px; margin: 6px auto 10px; }
.birthday-fusion i { width: 15px; height: 15px; animation: birthday-fusion .9s ease-out both; }
.birthday-fusion i:first-child { --orb-travel: 25px; }
.birthday-fusion i:last-child { --orb-travel: -25px; }
@keyframes birthday-fusion { 70% { transform: translateX(var(--orb-travel,0px)) scale(1.4); } }
.birthday-puzzle { width:min(59cqw,552px); }
.birthday-pieces {
  display:grid;
  grid-template:repeat(3,1fr) / repeat(7,1fr);
  width:100%;
  aspect-ratio:16 / 9;
  box-sizing:border-box;
  margin:auto;
  border:clamp(3px,.45cqw,6px) solid #936445;
  outline:1px solid #fef2d9;
  background:#a47760;
}
.birthday-pieces i { min-width:0; min-height:0; background:#b8896b; }
.birthday-pieces .filled {
  background: url(birthday-group-portrait.webp) var(--col) var(--row) / 700% 300% no-repeat;
  image-rendering: pixelated;
  animation: birthday-piece .48s var(--delay) both;
}
@keyframes birthday-piece { from { opacity: 0; transform: translateY(-13px) scale(1.18); box-shadow: 0 0 0 1px #fff2b8; } }
.birthday-ending img { width: clamp(30px,5cqw,62px); image-rendering: pixelated; }
body:has(#birthday-stage[data-phase="finale"]:not([hidden])),
.game:has(#birthday-stage[data-phase="finale"]:not([hidden])) { background:#fff; }
.game:has(#birthday-stage[data-phase="finale"]:not([hidden])) .game-hud,
#birthday-stage[data-phase="finale"] .birthday-orb-hud { display:none; }
.birthday-end-return { position:absolute; bottom:5%; left:50%; transform:translateX(-50%); animation:birthday-end-return .4s 1.15s both; }
@keyframes birthday-end-return { from { opacity:0; visibility:hidden; } to { opacity:1; visibility:visible; } }
.birthday-bag-photo img { display: block; width: 100%; max-height: 260px; object-fit: contain; image-rendering: pixelated; }
.birthday-talk.birthday-narration { min-height:0; pointer-events:none; background:#f7e5c3ed; }
@media (max-width: 740px) {
  .birthday-puzzle { top:57%; width:53cqw; }
  .birthday-puzzle .birthday-fusion { margin:3px auto 6px; }
  .birthday-puzzle .birthday-fusion i { width:10px; height:10px; }
}
@media (max-width: 500px) {
  .birthday-puzzle { width:47cqw; top:auto; bottom:2%; transform:translateX(-50%); }
}
@media (max-width: 600px) {
  .birthday-orb { padding: 1px 3px; }
  .birthday-orb i { width: 7px; height: 7px; }
  .birthday-talk { left: 8%; right: 8%; padding-block: 3px; }
  .birthday-talk p { max-width: 100%; }
  .birthday-controls button { padding-block: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  #birthday-stage * { animation-duration: .01ms; }
}
