/* Final viewport layer: keep the complete 9:16 card and controls visible. */
.preview-area {
  min-width: 0;
  max-height: none;
  padding-bottom: 0;
}

.phone {
  width: min(78vw, 330px, calc((100vh - 118px) * 9 / 16));
  min-width: 220px;
  aspect-ratio: 9 / 16;
  padding: 0;
  border: 5px solid #282a35;
  border-radius: 28px;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  border: 1px solid #ffffff66;
  border-radius: 22px;
}

.phone-speaker { top: 5px; z-index: 20; }
.phone-home { bottom: 4px; z-index: 20; }
.shot { padding: 13% 10% 17%; }
.shot-content { width: 100%; max-height: 100%; }

.cover-shot .shot-content {
  display: flex;
  min-height: 72%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cover-shot h2 { font-size: clamp(30px, 7vw, 46px); margin: 16px 0; }
.cover-shot .open, .end-shot .open { margin-top: 20px; flex: 0 0 auto; }
.stage-hint { bottom: 8px; max-width: calc(100% - 28px); white-space: nowrap; }
.music-control { top: 10px; right: 9px; max-width: 75%; }

.letter-scene .shot-content {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  max-width: 94%;
}
.letter {
  width: 100%;
  height: auto;
  min-height: 38%;
  max-height: 84%;
  overflow: hidden;
  text-align: left;
  transform: none;
  border-radius: 4px;
  border: 1px solid #efd9d0;
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.letter p { margin-bottom: 8px; }
.letter p:not(.salutation):not(.signature) { overflow-wrap: anywhere; word-break: break-all; }
.letter .salutation { flex: 0 0 auto; }
.letter .signature { flex: 0 0 auto; }
.letter.letter-short p:not(.salutation):not(.signature) { font-size: clamp(15px, 3vw, 20px); line-height: 1.42; }
.letter.letter-medium p:not(.salutation):not(.signature) { font-size: clamp(12px, 2.1vw, 14px); line-height: 1.28; }
.letter.letter-long p:not(.salutation):not(.signature) { font-size: clamp(12px, 2.3vw, 15px); line-height: 1.3; }
.letter.letter-medium, .letter.letter-long { padding: 20px 18px 18px; min-height: 44%; }
.letter.letter-medium .signature, .letter.letter-long .signature { margin-top: 10px; }
.letter.letter-xl { padding: 16px 15px 14px; max-height: 88%; }
.letter.letter-xl p:not(.salutation):not(.signature) { font-size: clamp(10px, 2.65vw, 14px); line-height: 1.28; margin-bottom: 7px; }
.letter.letter-xl .salutation { font-size: 12px; margin-bottom: 7px; }
.letter.letter-xl .signature { font-size: 12px; margin-top: 7px; }

.cake-scene { padding-top: 12%; padding-bottom: 16%; }
.cake-scene .shot-content {
  display: flex !important;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cake-scene h2 { font-size: clamp(25px, 6vw, 38px); margin: 12px 0 6px; }
.cake-scene .cake { width: min(82%, 230px); margin: 22px auto 0; }
.candle-wrap { position: relative; display: block; width: 34px; height: 82px; margin: 0 auto -2px; z-index: 4; }
.candle-stick { position: absolute; left: 9px; bottom: 0; width: 16px; height: 52px; border-radius: 5px 5px 2px 2px; background: repeating-linear-gradient(135deg, #fff 0 7px, #ef6c86 7px 14px); box-shadow: inset -3px 0 4px #9d385744; }
.wick { position: absolute; left: 16px; top: 22px; width: 2px; height: 10px; background: #3c2530; }
.flame { position: absolute; left: 8px; top: 0; width: 18px; height: 26px; border-radius: 60% 40% 58% 42% / 72% 46% 54% 28%; background: radial-gradient(circle at 50% 70%, #fffbd5 0 20%, #ffd34e 23% 50%, #ff7a32 68%, transparent 72%); filter: drop-shadow(0 0 7px #ffd45d); transform: rotate(3deg); transform-origin: 50% 90%; animation: real-flame .85s ease-in-out infinite alternate; }
@keyframes real-flame { to { transform: rotate(-5deg) scale(.9, 1.08); filter: drop-shadow(0 0 11px #ffb23f); } }

.cake-scene .cake-cream { position: relative; display: flex; align-items: center; justify-content: space-around; height: 34px; left: auto; right: auto; top: auto; margin-bottom: -15px; border-radius: 50%; z-index: 3; background: linear-gradient(#fffaf5, #f5ddd4); box-shadow: 0 5px 8px #8f3c5544; }
.cake-cream i { display: block; width: 17px; height: 17px; margin-top: -12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff9d9d, #bd294c 68%); box-shadow: 0 2px 4px #7d253b66; }
.cake-scene .cake-body { height: 105px; border-radius: 8px 8px 24px 24px; background: linear-gradient(180deg, #f7b3aa 0 18%, #e77d88 19% 52%, #c95072 53%); box-shadow: inset 0 -15px 20px #8e315344, 0 12px 18px #101b5044; color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.cake-body b { font-family: Georgia, serif; font-size: 10px; letter-spacing: .12em; }
.cake-body em { font-family: "STKaiti", "KaiTi", cursive; font-size: 20px; font-style: normal; }
.cake-scene .cake-plate { height: 14px; margin-top: 8px; border-radius: 50%; background: linear-gradient(#fff, #cfdaf8); box-shadow: 0 4px 7px #10265e55; }
.cake-scene .cake-prompt { display: inline-block; margin-top: 17px; padding: 7px 13px; border: 1px solid #ffffff66; border-radius: 18px; background: #10255a44; font-size: 11px; }
.cake.revealed .flame { animation: blow .65s forwards; }

.star-shot { padding: 8% 7% 15%; }
.stage .star-shot .star-map { position: relative; left: auto; top: auto; transform: none; width: min(94%, 310px); height: auto; max-width: none; max-height: none; flex: 0 1 auto; }
.stage .star-shot .shot-content > small, .stage .star-shot h3 { position: static; }
.stage .star-shot .shot-content > small { margin-bottom: 10px; }
.stage .star-shot h3 { margin-top: 10px; }
.stage .star-shot .shot-content::after { position: static; margin-top: 8px; }
.stage .star-shot .shot-content { width: 100%; text-align: center; align-items: center; justify-content: center; }
.stage .star-shot .star-map { margin-left: auto; margin-right: auto; }

@media (max-width: 860px) {
  .workspace { padding: 20px 4vw 38px; gap: 26px; }
  .preview-area { position: relative; top: auto; }
  .phone { width: min(76vw, 310px, calc((100vh - 92px) * 9 / 16)); min-width: 210px; }
}

@media (max-height: 680px) {
  .preview-label { margin-bottom: 7px; }
  .phone { width: min(72vw, 275px, calc((100vh - 86px) * 9 / 16)); min-width: 190px; }
  .stage-hint { display: none; }
}
