/* 爬綁模式遊戲進行中 */

/* 嵌入主站時避免污染全域樣式；僅作用於爬榜模式容器 */
.play,
.play *,
.play *::before,
.play *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.play {
  --ui-scale: 1;
  position: fixed;
  inset: 0;
  z-index: 500;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
}

.play button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.play button:hover {
  transform: scale(1.03);
}

.play[hidden] {
  display: none !important;
}

.play:not([hidden]) {
  display: block;
}

.play__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
}

.play__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.play__canvas {
  position: relative;
  z-index: 3;
  width: 1920px;
  height: 920px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0px 18px;
  transform-origin: center center;
  transform: scale(var(--ui-scale));
}

/* ── 頂部 HUD ── */

.play__hud {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  column-gap: 40px;

}

/* 對戰 PK 前導：左右大廚各約半邊畫面，完整顯示後對撞 */
.play__pvp-intro {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.play__pvp-intro:not([hidden]) {
  display: block;
}

.play__pvp-intro[hidden] {
  display: none !important;
}

.play__pvp-intro-img {
  position: absolute;
  top: 50%;
  width: 55%;
  height: auto;
  object-fit: contain;
}

.play__pvp-intro-img--left {
  top: 48.75%;
  left: 0;
  object-position: left center;
  transform: translate(-110%, -50%);
}

.play__pvp-intro-img--right {
  top: 51.25%;
  right: 0;
  object-position: right center;
  transform: translate(110%, -50%);
}

.play__pvp-intro.is-in .play__pvp-intro-img--left {
  animation: cw-pvp-intro-left-in 0.4s cubic-bezier(0.15, 0.85, 0.25, 1) both;
}

.play__pvp-intro.is-in .play__pvp-intro-img--right {
  animation: cw-pvp-intro-right-in 0.4s cubic-bezier(0.15, 0.85, 0.25, 1) both;
}

.play__pvp-intro.is-out .play__pvp-intro-img--left {
  animation: cw-pvp-intro-left-out 0.4s ease-in both;
}

.play__pvp-intro.is-out .play__pvp-intro-img--right {
  animation: cw-pvp-intro-right-out 0.4s ease-in both;
}

@keyframes cw-pvp-intro-left-in {
  0% {
    transform: translate(-110%, -50%);
  }

  78% {
    transform: translate(6px, -50%);
  }

  100% {
    transform: translate(0, -50%);
  }
}

@keyframes cw-pvp-intro-right-in {
  0% {
    transform: translate(110%, -50%);
  }

  78% {
    transform: translate(-6px, -50%);
  }

  100% {
    transform: translate(0, -50%);
  }
}

@keyframes cw-pvp-intro-left-out {
  0% {
    transform: translate(0, -50%);
  }

  100% {
    transform: translate(-110%, -50%);
  }
}

@keyframes cw-pvp-intro-right-out {
  0% {
    transform: translate(0, -50%);
  }

  100% {
    transform: translate(110%, -50%);
  }
}

.play__timer {
  position: relative;
  width: 140px;
  height: 140px;
  top: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play__timer-frame {
  position: absolute;
  width: 140px;
  height: 140px;
  object-fit: contain;
}

.play__timer-digits {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: #603813;
}

.play__progress-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 65px;
}

.play__progress-track {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.play__progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--progress, 0) * 1%);
  height: 100%;
  overflow: hidden;
  border-radius: 9999px;
  box-sizing: border-box;
}

.play__progress-fill img {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / max(var(--progress, 1), 1) * 100);
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.play__progress-label {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 1;
  font-size: 36px;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  line-height: 1;
  transform: translate(-100%, -50%);
  pointer-events: none;
}

.play__energy {
  position: absolute;
  left: 60%;
  top: 80%;
  width: 210px;
  height: 66px;
}
 
.play__energy-frame {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__energy-icon {
  position: absolute;
  left: -10%;
  top: 50%;
  width: 70px;
  height: 70px;
  object-fit: contain;
  transform: translateY(-50%);
}

.play__energy-count-wrap {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.play__energy-count-symbol {
  font-size: 36px;
  font-weight: bold;
  color: #603813;
}

.play__energy-count-value {
  font-size: 36px;
  font-weight: bold;
  color: #603813;
}

.play__score {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 360px;
  height: 40px;
}

.play__score-label {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__score-digits {
  display: flex;
  align-items: center;
}

.play__score-digits img {
  width: 50px;
  height: auto;
  object-fit: contain;
}

/* ── 分數增加動態：1.數字放大彈一下 → 2.光暈與亮片飛入分數
   由 JS 於分數實際增加時切換 .cw-score-pop／.cw-score-burst-play 來（重新）觸發播放 ── */

@keyframes cw-score-digit-pop {
  0% {
    transform: scale(1);
  }

  35% {
    transform: scale(1.4);
  }

  60% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
  }
}

.play__score-digits img.cw-score-pop {
  animation: cw-score-digit-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.play__score-label,
.play__score-digits {
  position: relative;
  z-index: 1;
}

.play__score-burst {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.play__score-burst-glow,
.play__score-burst-star {
  position: absolute;
  left: 80%;
  top: 70%;
  opacity: 0;
  object-fit: contain;
}

.play__score-burst-glow {
  width: 180px;
  height: 180px;
  transform: translate(-50%, -50%) scale(0.3);
}

.play__score-burst-star {
  z-index: 2;
}

.play__score-burst-star--1 {
  width: 48px;
  --star-start-x: -100px;
  --star-start-y: -60px;
  --star-mid-x: -26px;
  --star-mid-y: -16px;
  --star-end-x: -14px;
  --star-end-y: -10px;
  --star-rotate: -140deg;
}

.play__score-burst-star--2 {
  width: 44px;
  --star-start-x: 96px;
  --star-start-y: 54px;
  --star-mid-x: 24px;
  --star-mid-y: 14px;
  --star-end-x: 14px;
  --star-end-y: 8px;
  --star-rotate: 160deg;
}

.play__score-burst-star--3 {
  width: 54px;
  --star-start-x: 84px;
  --star-start-y: -66px;
  --star-mid-x: 20px;
  --star-mid-y: -14px;
  --star-end-x: 10px;
  --star-end-y: -8px;
  --star-rotate: -110deg;
}

@keyframes cw-score-burst-glow {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }

  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.25);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
}

@keyframes cw-score-burst-star {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--star-start-x, 0), var(--star-start-y, 0)) scale(0.2) rotate(0deg);
  }

  45% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(var(--star-mid-x, 0), var(--star-mid-y, 0)) scale(1.15) rotate(var(--star-rotate, 120deg));
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--star-end-x, 0), var(--star-end-y, 0)) scale(0.85) rotate(var(--star-rotate, 120deg));
  }
}

.play__score-burst.cw-score-burst-play .play__score-burst-glow {
  animation: cw-score-burst-glow 0.6s ease-out both;
}

.play__score-burst.cw-score-burst-play .play__score-burst-star--1 {
  animation: cw-score-burst-star 0.55s ease-out both;
}

.play__score-burst.cw-score-burst-play .play__score-burst-star--2 {
  animation: cw-score-burst-star 0.55s ease-out 0.04s both;
}

.play__score-burst.cw-score-burst-play .play__score-burst-star--3 {
  animation: cw-score-burst-star 0.55s ease-out 0.08s both;
}

.play__setting {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
}

.play__setting img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── 主遊戲區 ── */

.play__main {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  gap: 50px;
}

/* 關卡進場面板 */

.play__level-intro {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play__level-intro[hidden] {
  display: none !important;
}

.play__main--intro .play__question,
.play__main--intro .play__answer-zone,
.play__question[hidden],
.play__answer-zone[hidden] {
  display: none !important;
}

/* 關卡進場動態：1.底板+面板由下往上彈出浮現 → 2.國旗由小到大彈出（每次關卡開始重新播放）
   國旗「由小至大彈出」用共用動態效果 cw-pop-scale（定義於 css/shared-fx.css） */
@keyframes cw-level-panel-rise {
  0% {
    opacity: 0;
    transform: translateY(140px);
  }

  70% {
    opacity: 1;
    transform: translateY(-16px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.play__level-panel {
  position: relative;
  width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cw-level-panel-rise 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.play__level-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}

.play__level-banner {
  position: absolute;
  top: -6%;
  left: 50%;
  width: 72%;
  height: auto;
  object-fit: contain;
  transform: translateX(-50%);
  z-index: 2;
}

.play__level-body {
  position: absolute;
  top: 32%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
}

.play__level-flag {
  width: 180px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.22s;
}

@media (prefers-reduced-motion: reduce) {

  .play__level-panel,
  .play__level-flag {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .play__pvp-intro.is-in .play__pvp-intro-img--left,
  .play__pvp-intro.is-in .play__pvp-intro-img--right,
  .play__pvp-intro.is-out .play__pvp-intro-img--left,
  .play__pvp-intro.is-out .play__pvp-intro-img--right {
    animation: none;
  }

  .play__pvp-intro.is-in .play__pvp-intro-img--left,
  .play__pvp-intro.is-out .play__pvp-intro-img--left,
  .play__pvp-intro.is-in .play__pvp-intro-img--right,
  .play__pvp-intro.is-out .play__pvp-intro-img--right {
    transform: translate(0, -50%);
  }
}

/* 設定面板（遊戲中暫停）進場動態：依序 1.底板與內容由小到大彈出 → 2.緞帶由小到大彈出 →
   3.橘色按鈕由小到大彈出，皆用共用動態效果 cw-pop-scale（定義於 css/shared-fx.css） */

.play__setting-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.play__setting-overlay[hidden] {
  display: none !important;
}

.play__setting-panel {
  position: relative;
  width: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  --pop-base-transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
  animation: cw-pop-scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.play__setting-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.3));
}

.play__setting-heading {
  position: absolute;
  top: -5%;
  left: 50%;
  width: 100%;
  --pop-base-transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.28s;
}

.play__setting-banner {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.play__setting-title {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 20%;
  bottom: 30%;
  margin: 0;
  z-index: 1;
}

.play__setting-title svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.play__setting-title text {
  fill: #fff;
  font-size: 34px;
  font-weight: bold;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  stroke: rgba(55, 12, 12, 0.45);
  stroke-width: 1.2px;
  paint-order: stroke fill;
  letter-spacing: 5px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
}

.play__setting-close {
  position: absolute;
  top: 8%;
  right: 0%;
  width: 76px;
  height: 76px;
  z-index: 4;
}

.play__setting-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__setting-body {
  position: absolute;
  inset: 14% 12% 10%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.play__setting-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.play__setting-avatar {
  position: relative;
  width: 180px;
  height: 180px;
}

.play__setting-avatar-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.play__setting-avatar-face {
  position: absolute;
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 50%;
  top: 48.5%;
  left: 50.5%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.play__setting-avatar-mask {
  position: absolute;
  width: 140px;
  height: 140px;
  object-fit: contain;
  top: 48.5%;
  left: 50.5%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.play__setting-name {
  position: relative;
  margin-top: -40px;
  width: 260px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.play__setting-name img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__setting-name span {
  position: relative;
  z-index: 1;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  bottom: 5px;
  max-width: 78%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play__setting-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 70px;
  width: 100%;
}

.play__setting-stat {
  display: flex;
  align-items: center;
}

.play__setting-stat-label {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.play__setting-stat-digits {
  display: flex;
  align-items: center;
}

.play__setting-stat-digits img {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.play__setting-music {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.play__setting-music img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__setting-music-off[hidden] {
  display: none !important;
}

.play__setting-music-on[hidden] {
  display: none !important;
}

.play__setting-surrender {
  position: relative;
  width: 300px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -70px;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.5s;
}

.play__setting-surrender img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__setting-surrender span {
  position: relative;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

/* Frame_Question 進場動態：依序 1.底板由左至右彈出漸顯浮現 → 2.料理由小至大彈出；
   每換一道料理（含第一題）都會由 JS 重新觸發料理的彈出＋快速晃動兩下動畫 */

@keyframes cw-question-frame-reveal {
  0% {
    opacity: 0;
    transform: translateX(-60px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes cw-question-dish-pop-shake {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  50% {
    opacity: 1;
    transform: scale(1.12);
  }

  62% {
    transform: scale(1) translateX(0);
  }

  71% {
    transform: scale(1) translateX(-10px);
  }

  80% {
    transform: scale(1) translateX(10px);
  }

  89% {
    transform: scale(1) translateX(-6px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateX(0);
  }
}

.play__question {
  position: relative;
  width: 600px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cw-question-frame-reveal 0.45s ease-out both;
}

.play__question-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}

.play__question-body {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  top: 5%;
}

.play__question-flag {
  width: 100px;
  height: auto;
  object-fit: contain;
}

.play__question-dish {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 600px;
  height: auto;
  margin-top: -30px;
  margin-bottom: 40px;
  transform-origin: center center;
  animation: cw-question-dish-pop-shake 0.5s ease-out both;
  animation-delay: 0.3s;
}

.play__question-dish img {
  object-fit: contain;
}

.play__question-name {
  font-size: 26px;
  font-weight: bold;
  color: #c07b46;
}

/* 作答區 */

.play__answer-zone {
  gap: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.play__answer-grid {
  display: grid;
  grid-template-columns: repeat(3, 200px);
  grid-template-rows: repeat(2, 160px);
  gap: 14px;
}

.play__answer-slot {
  position: relative;
  width: 200px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform 0.12s ease;
}

.play__answer-slot--selected {
  transform: scale(1.05);
}

/* 題目選項由左至右、由上至下一一快速彈出：延遲時間依 DOM 順序
   （= 版面左至右、由上至下的順序）用 nth-child 逐格遞增 */
.play__answer-slot:nth-child(1) {
  --slot-pop-delay: 0s;
}

.play__answer-slot:nth-child(2) {
  --slot-pop-delay: 0.06s;
}

.play__answer-slot:nth-child(3) {
  --slot-pop-delay: 0.12s;
}

.play__answer-slot:nth-child(4) {
  --slot-pop-delay: 0.18s;
}

.play__answer-slot:nth-child(5) {
  --slot-pop-delay: 0.24s;
}

.play__answer-slot:nth-child(6) {
  --slot-pop-delay: 0.3s;
}

/* 動畫套在按鈕內的圖層（底框＋食材圖），不動到 .play__answer-slot 本身，
   避免蓋掉答題選取時的 scale(1.05) 效果 */
.play__answer-slot-frame {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform-origin: center center;
  animation: cw-pop-scale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--slot-pop-delay, 0s);
}

.play__answer-slot-material {
  position: relative;
  width: 90%;
  height: 90%;
  object-fit: contain;
  z-index: 1;
  transform-origin: center center;
  animation: cw-pop-scale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--slot-pop-delay, 0s);
}

/* 答題結果遮罩：與暫停面板同樣為「整個畫面」全屏置中 + 黑色透明模糊底板
   內容包含 Combo 圖示（有連擊時顯示）與答對／答錯提示（全對顯示綠勾+卡普頭、
   部分正確只顯示加分、全錯顯示叉叉+卡普頭），共用同一層遮罩避免重疊模糊 */

.play__result-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  pointer-events: none;
}

.play__result-overlay[hidden] {
  display: none !important;
}

.play__result-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
}

.play__result-combo {
  display: flex;
  align-items: center;
  gap: 12px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  animation: play-combo-pop 1s ease forwards;
}

.play__result-combo[hidden] {
  display: none !important;
}

.play__result-combo-label {
  height: 80px;
  width: auto;
  object-fit: contain;
}

.play__result-combo-digits {
  display: flex;
  align-items: center;
}

.play__result-combo-digits img {
  height: 80px;
  width: auto;
  object-fit: contain;
}

@keyframes play-combo-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }

  80% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.play__result-mark-wrap {
  position: relative;
  width: 360px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: play-score-pop 1s ease forwards;
}

@keyframes play-score-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }

  15% {
    transform: scale(1.2);
    opacity: 1;
  }

  80% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.play__result-mark {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(-8deg);
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}

.play__result-mark[hidden] {
  display: none !important;
}

.play__result-mascot {
  position: absolute;
  bottom: -4%;
  right: -8%;
  width: 60%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}

.play__result-mascot[hidden] {
  display: none !important;
}

.play__result-score {
  position: absolute;
  bottom: -35%;
  left: 50%;
  transform: translateX(-50%) rotate(-6deg);
  display: flex;
  align-items: center;
  white-space: nowrap;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.play__result-score img {
  height: 120px;
  width: auto;
  object-fit: contain;
}

.play__result-score:empty {
  display: none;
}

/* Button_Confirm_1 / Button_Confirm_2（圖檔不變）
   外框（Button_Confirm_2）用 conic-gradient 遮罩 + CSS animation 讓 --confirm-time-pct
   隨該關總秒數由 100 平滑（非每秒跳格）順時鐘減少到 0；底色（Button_Confirm_1）維持原圖，
   剩餘時間 <50% 時用 CSS filter(hue-rotate) 將黃色調成紅色並加上脈動提示 */

@property --confirm-time-pct {
  syntax: "<number>";
  inherits: true;
  initial-value: 100;
}

.play__confirm-btn {
  position: relative;
  width: 264px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.play__confirm-outline,
.play__confirm-body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.play__confirm-outline {
  transform: scale(1.2, 1.2);
  z-index: 3;
  --confirm-time-pct: 100;
  --confirm-duration: 60s;
  animation: play-confirm-drain var(--confirm-duration) linear forwards;
  -webkit-mask-image: conic-gradient(from 0deg at 50% 50%,
      transparent calc((100 - var(--confirm-time-pct)) * 1%),
      #000 calc((100 - var(--confirm-time-pct)) * 1%));
  mask-image: conic-gradient(from 0deg at 50% 50%,
      transparent calc((100 - var(--confirm-time-pct)) * 1%),
      #000 calc((100 - var(--confirm-time-pct)) * 1%));
  transition: filter 0.25s linear;
}

/* 剩餘時間 <50%：外框（黃）轉偏橘色，底色（黃）轉紅並脈動，兩者皆由 .play__confirm-btn--danger 觸發 */
.play__confirm-btn--danger .play__confirm-outline {
  filter: hue-rotate(-75deg);
}

@keyframes play-confirm-drain {
  from {
    --confirm-time-pct: 100;
  }

  to {
    --confirm-time-pct: 0;
  }
}

.play__confirm-body {
  z-index: 1;
  transition: filter 0.25s linear;
}

.play__confirm-btn--danger .play__confirm-body {
  filter: hue-rotate(300deg) saturate(1.6);
  animation: play-confirm-pulse 0.8s ease-in-out infinite;
}

@keyframes play-confirm-pulse {

  0%,
  100% {
    filter: hue-rotate(300deg) saturate(1.6) brightness(1);
  }

  50% {
    filter: hue-rotate(300deg) saturate(1.6) brightness(1.15);
  }
}

.play__confirm-btn span {
  position: relative;
  z-index: 2;
  font-size: 42px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ── 廣告區（真實 GAM Banner 為 fixed 底；此區僅保留版面高度） ── */

.play__ad {
  flex-shrink: 0;
  position: relative;
  width: 40%;
  height: 60px;
  background: transparent;
  border-radius: 4px;
  pointer-events: none;
}

.play__ad-label {
  display: none;
}

/* ── 直向畫布 ── */

.play__bg--portrait {
  display: none;
}

@media (max-width: 800px) {
  .play__bg--landscape {
    display: none;
  }

  .play__bg--portrait {
    display: block;
  }

  .play__canvas {
    width: 400px;
    height: 844px;
    padding: 12px 14px 10px;
  }

  /* 手機：左圖上移、右圖下移，讓中間鋸齒對撞邊對齊 */
  .play__pvp-intro-img--left {
    top: 49.75%;
  }

  .play__pvp-intro-img--right {
    top: 50.25%;
  }

  /* 頂部 HUD：第一排「計時器－進度條－設定」，第二排「體力－分數」靠右對齊，
     利用 flex-wrap + 進度條 flex:1 撐滿第一排寬度，讓體力／分數自然換到第二排 */
  .play__hud {
    display: flex;
    align-items: center;
    justify-content: flex-start;
  }

  .play__timer {
    position: relative;
    width: 56px;
    height: 56px;
    left: 5%;
    top: 10%;
  }

  .play__timer-frame {
    width: 90px;
    height: 90px;
  }

  .play__timer-digits {
    top: 5%;
    font-size: 24px;
  }

  .play__progress-wrap {
    position: absolute;
    left: 22%;
    width: 60%;
    height: 70%;
  }

  .play__progress-label {
    font-size: 24px;
  }

  .play__setting {
    position: relative;
    width: 56px;
    height: 56px;
  }

  .play__setting img {
    width: 60px;
    height: 60px;
  }

  .play__energy {
    position: relative;
    left: 3%;
    top: 90%;
    width: 200px;
    height: 50px;
  }

  .play__energy-icon {
    width: 40px;
    height: 40px;
  }

  .play__energy-count-symbol,
  .play__energy-count-value {
    font-size: 24px;
  }

  .play__score {
    position: relative;
    left: 5%;
    top: 90%;
    width: 60px;
    height: auto;
  }

  .play__score-label {
    width: 64px;
    height: 100%;
  }

  .play__score-digits img {
    width: 18px;
  }

  /* 手機版分數框較窄，光暈與亮片飛入距離同步縮小，避免蓋到其他 HUD 元件 */
  .play__score-burst-glow {
    width: 90px;
    height: 90px;
  }

  .play__score-burst-star--1 {
    width: 26px;
    --star-start-x: -50px;
    --star-start-y: -30px;
    --star-mid-x: -14px;
    --star-mid-y: -8px;
    --star-end-x: -8px;
    --star-end-y: -6px;
  }

  .play__score-burst-star--2 {
    width: 24px;
    --star-start-x: 48px;
    --star-start-y: 27px;
    --star-mid-x: 12px;
    --star-mid-y: 7px;
    --star-end-x: 7px;
    --star-end-y: 4px;
  }

  .play__score-burst-star--3 {
    width: 28px;
    --star-start-x: 42px;
    --star-start-y: -33px;
    --star-mid-x: 10px;
    --star-mid-y: -7px;
    --star-end-x: 5px;
    --star-end-y: -4px;
  }

  .play__main {
    top: 5%;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .play__level-panel {
    width: 340px;
  }

  .play__level-banner {
    top: -5%;
    width: 78%;
  }

  .play__level-body {
    top: 30%;
  }

  .play__level-flag {
    width: 110px;
  }

  .play__setting-panel {
    width: 340px;
  }

  .play__setting-heading {
    width: 100%;
    top: -5%;
  }

  .play__setting-title {
    left: 8%;
    right: 8%;
    top: 20%;
    bottom: 26%;
  }

  .play__setting-title text {
    font-size: 36px;
    stroke-width: 0.8px;
  }

  .play__setting-close {
    width: 48px;
    height: 48px;
    right: -1%;
  }

  .play__setting-avatar {
    position: relative;
    width: 140px;
    height: 140px;
  }
  
  .play__setting-avatar-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  
  .play__setting-avatar-mask {
    position: absolute;
    width: 110px;
    height: 110px;
    object-fit: contain;
    top: 48.5%;
    left: 50.5%;
    transform: translate(-50%, -50%);
  }

  .play__setting-name {
    width: 180px;
    height: 80px;
  }

  .play__setting-name span {
    font-size: 18px;
  }

  .play__setting-stats {
    gap: 24px;
  }

  .play__setting-stat-label {
    height: 24px;
  }

  .play__setting-stat-digits img {
    height: 28px;
  }

  .play__setting-music {
    width: 44px;
    height: 44px;
  }

  .play__setting-surrender {
    top: -5%;
    width: 200px;
    height: 60px;
  }

  .play__setting-surrender span {
    font-size: 20px;
  }

  .play__question {
    width: 100%;
    width: 340px;
    height: auto;
  }

  .play__question-body {
    top: -7%;
    width: 100%;
  }

  .play__question-flag {
    width: 50px;
    margin-bottom: 18%;
  }

  .play__question-dish {
    width: 100%;
    margin-bottom: 10%;
  }

  .play__question-dish img {
    max-height: 150px;
  }

  .play__question-name {
    max-width: 100%;
    font-size: 16px;
    text-align: center;
  }

  .play__answer-zone {
    align-items: center;
    gap: 12px;
    padding-top: 0;
  }

  .play__answer-grid {
    grid-template-columns: repeat(3, 108px);
    grid-template-rows: repeat(2, 108px);
    gap: 8px;
  }

  .play__answer-slot {
    width: 108px;
    height: 108px;
  }

  .play__confirm-btn {
    width: 140px;
    height: 60px;
  }

  .play__result-panel {
    gap: 12px;
  }

  .play__result-mark-wrap {
    width: 220px;
    height: 220px;
  }

  .play__result-score img {
    height: 34px;
  }

  .play__result-combo-label,
  .play__result-combo-digits img {
    height: 46px;
  }

  .play__confirm-btn span {
    font-size: 20px;
  }

  .play__ad {
    width: 100%;
    max-width: 100%;
    height: 44px;
    margin-top: 8px;
  }
}

/* ── 降低動態效果偏好：關閉設定面板與題目卡片進場動畫 ── */
@media (prefers-reduced-motion: reduce) {

  .play__setting-panel,
  .play__setting-surrender {
    animation: none;
    opacity: 1;
  }

  .play__setting-panel {
    transform: var(--pop-base-transform, none);
  }

  .play__setting-heading {
    animation: none;
    opacity: 1;
    transform: var(--pop-base-transform, none);
  }

  .play__question,
  .play__question-dish {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .play__answer-slot-frame,
  .play__answer-slot-material {
    animation: none;
    opacity: 1;
  }

  .play__answer-slot-debuff {
    animation: none !important;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: none;
  }

  .play__answer-slot--burn::after {
    animation: none !important;
    opacity: 0;
  }

  .play__answer-slot--flip.is-flipping .play__answer-slot-material {
    animation: none !important;
    opacity: 0;
  }

  .play__answer-slot--flip.is-flipping .play__answer-slot-frame {
    animation: none !important;
  }

  .play__score-digits img.cw-score-pop {
    animation: none;
    transform: none;
  }

  .play__score-burst-glow,
  .play__score-burst-star {
    animation: none;
    opacity: 0;
  }
}

/* 練習模式：隱藏 HUD 體力與暫停勝敗場 */
.play--practice .play__energy,
.play--practice .play__setting-stats {
  display: none !important;
}

/* 對戰：不顯示體力／爬榜進度條／舊 Enemy 數字 HUD；改用頭貼賽道 */
.play--battle .play__energy,
.play--battle .play__progress-wrap,
.play--battle .play__battle-enemy {
  display: none !important;
}

.play--battle .play__hud {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto 88px;
  grid-template-rows: auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 0;
  width: 100%;
}

.play--battle .play__timer {
  grid-column: 1;
  grid-row: 1;
  top: 0;
  justify-self: start;
}

.play--battle .play__pvp-race {
  grid-column: 2;
  grid-row: 1;
  display: block;
  width: auto;
  max-width: none;
  min-width: 0;
  --pvp-goal-w: 56px;
}

.play--battle .play__pvp-race-bar {
  height: 32px;
}

.play--battle .play__pvp-race-avatar {
  width: 48px;
  height: 48px;
}

.play--battle .play__score {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  width: auto;
  max-width: none;
  height: 48px;
}

.play--battle .play__setting {
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
  align-self: center;
}

.play--battle .play__score-label {
  width: 140px;
  height: auto;
}

.play--battle .play__score-digits img {
  width: 40px;
}

.play__pvp-race {
  --pvp-goal-w: 48px;
  --pvp-player-left: 3.5%;
  --pvp-enemy-left: 3.5%;
  display: none;
  position: relative;
  width: 100%;
  height: 148px;
  min-width: 0;
  overflow: visible;
}

.play__pvp-race-track {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.play__pvp-race-bar {
  position: absolute;
  left: 0;
  width: calc(100% - var(--pvp-goal-w));
  right: auto;
  top: 50%;
  height: 26px;
  transform: translateY(-50%);
  object-fit: fill;
  pointer-events: none;
}

.play__pvp-race-goal {
  position: absolute;
  right: 0;
  top: 50%;
  width: var(--pvp-goal-w);
  height: calc(var(--pvp-goal-w) * 1.32);
  transform: translateY(calc(-50% - 14px));
  object-fit: contain;
  pointer-events: none;
}

.play__pvp-race-lane {
  position: absolute;
  left: 0;
  width: calc(100% - var(--pvp-goal-w));
  right: auto;
  top: 0;
  bottom: 0;
  pointer-events: none;
}

.play__pvp-race-marker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 56px;
  transform: translateX(-50%);
  transition: left 0.4s ease;
}

.play__pvp-race-marker--player {
  bottom: calc(50% + 10px);
  left: var(--pvp-player-left, 3.5%);
}

.play__pvp-race-marker--enemy {
  top: calc(50% + 10px);
  left: var(--pvp-enemy-left, 3.5%);
}

.play__pvp-race-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  background: #3a2a1a;
}

.play__pvp-race-label {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  line-height: 1.15;
  white-space: nowrap;
}

.play__battle-enemy {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin-right: 8px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.15;
  z-index: 6;
}

.play__battle-enemy-tag {
  opacity: 0.9;
  font-size: 0.75rem;
}

.play__battle-enemy-score {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.play__answer-slot-debuff {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center center;
}

.play__answer-slot-debuff--burn {
  width: 78%;
  height: 78%;
  animation: cw-pvp-burn-in 5s linear both;
  animation-delay: calc(var(--slot-pop-delay, 0s) + 0.12s);
}

.play__answer-slot--burn::after {
  content: "";
  position: absolute;
  inset: 6%;
  z-index: 5;
  pointer-events: none;
  border-radius: 18px;
  background: #fff6e4;
  mix-blend-mode: screen;
  animation: cw-pvp-burn-flash 5s ease-out both;
  animation-delay: calc(var(--slot-pop-delay, 0s) + 0.12s);
}

.play__answer-slot-debuff--ketchup {
  width: 108%;
  height: 108%;
  animation: cw-pvp-ketchup-splat 0.5s cubic-bezier(0.18, 1.4, 0.32, 1) both;
  animation-delay: calc(var(--slot-pop-delay, 0s) + 0.12s);
}

@keyframes cw-pvp-burn-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }

  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62);
  }

  48% {
    transform: translate(-50%, -50%) scale(0.86);
  }

  75% {
    transform: translate(-50%, -50%) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.play__answer-slot-debuff--ketchup {
  width: 108%;
  height: 108%;
  animation: cw-pvp-ketchup-splat 0.5s cubic-bezier(0.18, 1.4, 0.32, 1) both;
  animation-delay: calc(var(--slot-pop-delay, 0s) + 0.12s);
}

@keyframes cw-pvp-burn-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes cw-pvp-burn-flash {
  0% {
    opacity: 0;
  }

  18% {
    opacity: 0.95;
  }

  100% {
    opacity: 0;
  }
}

@keyframes cw-pvp-ketchup-splat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.12) rotate(-18deg);
  }

  58% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.22) rotate(6deg);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

.play__answer-slot--flip {
  perspective: 720px;
}

.play__answer-slot--flip.is-flipping .play__answer-slot-frame {
  animation: cw-pvp-slot-flip-frame 0.55s ease-in-out forwards;
}

.play__answer-slot--flip.is-flipping .play__answer-slot-material {
  animation: cw-pvp-slot-flip-hide 0.55s ease-in-out forwards;
}

@keyframes cw-pvp-slot-flip-frame {
  0% {
    transform: rotateY(0deg);
  }

  50% {
    transform: rotateY(90deg);
  }

  100% {
    transform: rotateY(0deg);
  }
}

@keyframes cw-pvp-slot-flip-hide {
  0% {
    transform: rotateY(0deg);
    opacity: 1;
  }

  50% {
    transform: rotateY(90deg);
    opacity: 1;
  }

  51% {
    transform: rotateY(90deg);
    opacity: 0;
  }

  100% {
    transform: rotateY(0deg);
    opacity: 0;
  }
}

/* 手機練習模式：體力不佔 flex 寬度後，計時器與齒輪改錨左右上角 */
@media (max-width: 800px) {
  .play--practice .play__timer {
    left: 0;
    top: 0;
  }

  .play--practice .play__setting {
    margin-left: auto;
    top: 0;
  }

  .play--battle .play__hud {
    grid-template-columns: 72px minmax(0, 1fr) 78px;
    grid-template-rows: auto auto;
    min-height: 118px;
  }

  .play--battle .play__timer {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 72px;
    height: 72px;
    left: 0;
    top: 0;
  }

  .play--battle .play__pvp-race {
    grid-column: 2;
    grid-row: 1 / span 2;
    height: 118px;
    --pvp-goal-w: 32px;
  }

  .play--battle .play__pvp-race-bar {
    height: 14px;
  }

  .play--battle .play__pvp-race-avatar {
    width: 28px;
    height: 28px;
  }

  .play--battle .play__setting {
    grid-column: 3;
    grid-row: 1;
    width: 48px;
    height: 48px;
  }

  .play--battle .play__setting img {
    width: 48px;
    height: 48px;
  }

  .play--battle .play__score {
    grid-column: 3;
    grid-row: 2;
    left: 0;
    top: 0;
    max-width: 78px;
    height: auto;
  }

  .play--battle .play__score-label {
    width: 54px;
  }

  .play--battle .play__score-digits img {
    width: 12px;
  }

  .play__pvp-race-goal {
    transform: translateY(calc(-50% - 10px));
  }

  .play__pvp-race-marker {
    width: 40px;
  }

  .play__pvp-race-label {
    font-size: 10px;
  }
}
