* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation; /* 關掉手機的雙擊放大手勢 */
  -webkit-tap-highlight-color: transparent; /* 關掉點擊時的灰色閃爍 */
}

:root {
  --heart-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23e8887a' d='M12 21s-6.5-4.35-9.5-8.5C.5 9.5 1.5 5 5.5 4 8 3.4 10 4.5 12 7c2-2.5 4-3.6 6.5-3 4 1 5 5.5 3 8.5C18.5 16.65 12 21 12 21z'/%3E%3C/svg%3E") 12 12, pointer;
}

html, body {
  overscroll-behavior: none; /* 關掉手機邊界的橡皮筋彈動效果 */
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* 手機網址列縮合/展開時，畫面不會跟著跳動 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3ece0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  padding: 24px 16px;
}

.stage {
  width: min(360px, 92vw);
  aspect-ratio: 4 / 5;
  background: linear-gradient(180deg, #fbf5e8 0%, #f3e6d8 100%);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 44px rgba(107, 46, 53, 0.18);
  border: 3px solid #6b2e35;
  position: relative;
}

/* 開場入場動畫：粉紅擋板鏤空出 Dirty Baby 字樣，淡出接到遊戲畫面 */
.splash-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: linear-gradient(180deg, #fbf5e8 0%, #f3e6d8 100%);
  transition: opacity 0.6s ease;
}
.splash-overlay.splash-fade-out {
  opacity: 0;
}
.splash-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.splash-title-text {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 1px;
}
.splash-subtitle-text {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  fill: #fbf5e8;
}
/* 疊在鏤空按鈕上面的透明按鈕，實際負責接收點擊，視覺完全由底下的 SVG 鏤空負責 */
.splash-start-btn {
  position: absolute;
  left: 50%;
  top: 59%;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  border: 2px solid #fbf5e8;
  border-radius: 14px;
  background: #BF878C;
  color: #fbf5e8;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  text-align: justify;
  text-align-last: justify;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(107, 46, 53, 0.35);
}
.splash-start-btn:hover,
.vbtn:hover,
.deco-icon:hover,
.ending-restart-btn:hover,
.outro-restart-icon:hover {
  cursor: var(--heart-cursor);
}
.splash-start-btn:active {
  transform: translate(-50%, calc(-50% + 3px));
  box-shadow: 0 1px 0 rgba(107, 46, 53, 0.35);
}

/* 頂部狀態列 */
.status-bar {
  padding: 14px 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.status-bar .timer {
  font-size: 15px;
  font-weight: 700;
  color: #6b2e35;
  background: #f2b9be;
  padding: 4px 14px;
  border-radius: 999px;
}
.status-bar .hint {
  font-size: 17px;
  font-weight: 700;
  color: #a37a56;
}

/* 序列提示區：預設實心（外框色），答對才變成方向色 */
.sequence-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 5; /* 蓋在 .reveal-mask 上面，看階段要能看清楚序列格子 */
  min-height: 30px; /* 固定保留格子的高度，格子還沒生成之前版面也不會跳動 */
}
.seq-chip {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #6b2e35;
  color: transparent;
  position: relative;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.seq-chip.revealed {
  color: #6b2e35;
  transform: scale(1.08);
  box-shadow: 0 3px 6px rgba(107, 46, 53, 0.25);
}
.seq-chip.wrong {
  background: #e8887a;
  color: #fff8ec;
  transform: scale(1.12);
  animation: shake 0.35s ease;
}
.seq-chip .spark {
  position: absolute;
  inset: -10px;
  pointer-events: none;
  opacity: 0;
  font-size: 16px;
}
.seq-chip.revealed .spark {
  animation: sparkle-burst 0.5s ease-out;
}
@keyframes sparkle-burst {
  0%   { opacity: 1; transform: scale(0.4) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.6) rotate(25deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0) scale(1.12); }
  25%      { transform: translateX(-4px) scale(1.12); }
  75%      { transform: translateX(4px) scale(1.12); }
}

/* 寶寶主視覺區 */
.baby-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 寶寶兩側的手繪小海報，當背景裝飾用 */
.bg-poster {
  position: absolute;
  top: 50%;
  width: 34%;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(107, 46, 53, 0.2));
}
.bg-poster-left {
  left: 4%;
  transform: translateY(-50%) rotate(-6deg);
}
.bg-poster-right {
  right: 4%;
  transform: translateY(-50%) rotate(6deg);
}
#babyImg {
  width: 56%;
  filter: drop-shadow(0 10px 14px rgba(107, 46, 53, 0.25));
  position: relative;
  z-index: 5; /* 蓋在 .reveal-mask 上面，看階段時寶寶圖要保持清楚 */
}

/* 按到假icon的吐槽跑馬燈，飄在寶寶背後，純裝飾用 */
.icon-joke-marquee {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  overflow: hidden;
  white-space: nowrap;
  color: #ff5c5c;
  font-weight: 800;
  font-size: 20px;
  z-index: 4; /* 蓋在背景海報上面，寶寶圖下面 */
  pointer-events: none;
}
.icon-joke-marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 3s linear;
}

/* 階段一：看寶寶要幹嘛時，除了寶寶圖跟序列格子之外全部蓋上半透明黃色蒙版（視覺+操作都鎖住） */
.reveal-mask {
  position: absolute;
  inset: 0;
  background: rgba(255, 200, 64, 0.45);
  z-index: 3;
  pointer-events: auto;
}

/* 寶寶待機/成功/失敗動畫，class 由 BabyAnimator.js 動態切換 */
.anim-breathe { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

.anim-squash { animation: squash 1.1s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes squash {
  0%, 100% { transform: scaleX(1) scaleY(1); }
  45%      { transform: scaleX(1.06) scaleY(0.92); }
  55%      { transform: scaleX(1.06) scaleY(0.92); }
  75%      { transform: scaleX(0.97) scaleY(1.05); }
}

.anim-shake { animation: babyShake 0.4s ease; }
@keyframes babyShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(-6px) rotate(-3deg); }
  75%      { transform: translateX(6px) rotate(3deg); }
}

/* 作答階段：寶寶跟著節奏上下壓縮，打拍子感 */
.anim-beat { animation: beat 0.5s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes beat {
  0%, 100% { transform: scaleX(1) scaleY(1); }
  30%      { transform: scaleX(1.07) scaleY(0.87); }
  55%      { transform: scaleX(0.97) scaleY(1.05); }
}

/* 階段一：寶寶吵鬧躁動感 —— 壓縮＋左右平移 */
.anim-fuss { animation: fuss 0.5s ease-in-out infinite; }
@keyframes fuss {
  0%   { transform: translateX(0) scaleX(1) scaleY(1); }
  20%  { transform: translateX(-10px) scaleX(1.08) scaleY(0.93); }
  50%  { transform: translateX(0) scaleX(0.95) scaleY(1.05); }
  80%  { transform: translateX(10px) scaleX(1.08) scaleY(0.93); }
  100% { transform: translateX(0) scaleX(1) scaleY(1); }
}

/* 倒數畫面：3 → 2 → 1 → START */
.countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(251, 245, 232, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.countdown-num {
  font-size: 96px;
  font-weight: 800;
  color: #6b2e35;
  animation: countBounce 0.5s cubic-bezier(.36, 1.7, .5, 1) both;
}
.countdown-num.start-text {
  font-size: 52px;
  color: #e8887a;
}
@keyframes countBounce {
  0%   { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  50%  { transform: scale(1.25) rotate(6deg); opacity: 1; }
  75%  { transform: scale(0.92) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* 結局畫面（共用外框） */
.ending-overlay {
  position: absolute;
  inset: 0;
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  z-index: 30;
  text-align: center;
  padding: 20px;
}
.ending-overlay h2 {
  color: #6b2e35;
  font-size: 22px;
}

/* perfect / photo 是使用者畫好的完整結局插畫，文字已經畫在圖裡了，上面只疊一句標語 */
.ending-full-img {
  max-width: 88%;
  max-height: 74%;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(107, 46, 53, 0.25));
}

/* 結局標語：從中間縮小狀態一路放大定住 */
.ending-caption {
  font-size: 21px;
  font-weight: 800;
  color: #6b2e35;
  animation: captionGrow 0.7s cubic-bezier(.25, 1.5, .4, 1) both;
}
@keyframes captionGrow {
  0%   { transform: scale(0.15); opacity: 0; }
  70%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.ending-perfect { background: linear-gradient(180deg, #fbf5e8 0%, #f3e6d8 100%); }
.ending-photo   { background: #fffdf8; }

/* 送終結局的圖是模擬抬棺舞步梗圖，讓它前後晃動出舞步感 */
.ending-perfect .ending-full-img {
  animation: coffinDance 0.6s ease-in-out infinite;
}
@keyframes coffinDance {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(-8px) rotate(-2deg); }
  75%      { transform: translateX(8px) rotate(2deg); }
}

.photo-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 40;
  pointer-events: none;
}
.photo-flash.flash-on { animation: flashPop 0.15s ease; }
@keyframes flashPop {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* 混亂結局：跑馬燈 + 亂飄 emoji + 崩潰圖轉圈 */
.ending-fail { background: #2c1216; }
.marquee-row {
  position: absolute;
  left: 0;
  right: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #ff5c5c;
  font-weight: 800;
  font-size: 27px;
  z-index: 34;
  pointer-events: none; /* 純裝飾文字，不能擋住底下的重來按鈕 */
}
.marquee-row.top { top: 18%; }
.marquee-row.bottom { bottom: 18%; }
.marquee-row span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 6s linear infinite;
}
@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-200%); }
}

.fail-emoji-field {
  position: absolute;
  inset: 0;
  z-index: 31;
  pointer-events: none; /* 純裝飾飄浮 emoji，不能擋住底下的重來按鈕 */
}
.floating-emoji {
  position: absolute;
  animation: floatWiggle ease-in-out infinite;
}
@keyframes floatWiggle {
  0%   { transform: translateY(0) rotate(0deg); }
  25%  { transform: translateY(-14px) rotate(-10deg); }
  50%  { transform: translateY(6px) rotate(8deg); }
  75%  { transform: translateY(-8px) rotate(-6deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

.fail-baby-img {
  position: relative;
  z-index: 33;
  width: 92%;
  animation: spin 2.6s linear infinite;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.4));
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ending-restart-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 36;
  pointer-events: auto;
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: #f2b9be;
  color: #6b2e35;
  font-weight: 700;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(107, 46, 53, 0.35);
}
.ending-restart-btn:active {
  transform: translate(-50%, calc(-50% + 3px));
  box-shadow: 0 1px 0 rgba(107, 46, 53, 0.35);
}

/* 結局停留幾秒後的黑幕：淡入巡演海報並慢慢放大，附上歌曲連結跟工作人員名單 */
.outro-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 34px;
  overflow-y: auto;
  animation: outroFadeIn 0.6s ease both;
}
@keyframes outroFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.outro-poster {
  width: 62%;
  border-radius: 12px;
  flex-shrink: 0;
  margin-top: -20px;
  margin-bottom: 14px;
  animation:
    outroPosterIn 1.4s ease both,
    outroPosterZoom 6s ease-in-out 1.4s infinite alternate;
}
@keyframes outroPosterIn {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes outroPosterZoom {
  0%   { transform: scale(1); }
  100% { transform: scale(1.08); }
}
.outro-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
  margin-bottom: 6px;
}
.outro-links a {
  display: block;
  text-align: center;
  padding: 9px 12px;
  border-radius: 999px;
  background: #d6c9e8;
  color: #2c1216;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.outro-credits {
  color: #f3e6d8;
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
  flex-shrink: 0;
}
.outro-restart-icon {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #6b2e35;
  background: #f2b9be;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.outro-restart-icon:active {
  transform: scale(0.9);
}
.outro-copyright {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  color: #a3897e;
  font-size: 9px;
  text-align: center;
}

/* 四角裝飾 icon */
.deco-icon {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: #d6c9e8;
  box-shadow: 0 2px 6px rgba(107, 46, 53, 0.18);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.deco-icon.shake-once { animation: babyShake 0.3s ease; }
.deco-tl { left: 12px; top: 12px; }
.deco-tr { right: 12px; top: 12px; }
.deco-bl { left: 12px; bottom: 12px; }
.deco-br { right: 12px; bottom: 12px; }

/* 底部虛擬按鍵 */
.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 12px 20px;
}
.vbtn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #6b2e35;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(107, 46, 53, 0.25);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease;
}
.vbtn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(107, 46, 53, 0.25);
}

/* 五個方向對應色，seq-chip 跟 vbtn 共用同一組 class */
.c-look { background: #f6d9b8; } /* 看：蜜桃 */
.c-kiss { background: #f2b9be; } /* 親：珊瑚粉 */
.c-hug  { background: #b9cfe0; } /* 抱：霧霾藍 */
.c-pat  { background: #bcd9b8; } /* 拍：鼠尾草綠 */
.c-me   { background: #d6c9e8; } /* 我：薰衣草紫 */
