/* 爬綁模式完成結算 */

/* 嵌入主站時避免污染全域樣式；僅作用於爬榜模式容器 */
.finished,
.finished *,
.finished *::before,
.finished *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.finished {
  --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;
}

.finished button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.finished button:hover {
  transform: scale(1.03);
}

.finished[hidden] {
  display: none !important;
}

.finished:not([hidden]) {
  display: block;
}

.finished a {
  color: inherit;
  text-decoration: none;
}

.finished__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
}

.finished__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 設計稿畫布：（約 85% 視窗高度），由 fit-viewport.js 設定 --ui-scale */
.finished__canvas {
  position: relative;
  flex-shrink: 0;
  width: 1920px;
  height: 920px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  transform: scale(var(--ui-scale));
}

/* ── 結算面板進場動態：依序 1.底板+緞帶由小至大彈出 → 2.食物裝飾彈出/浮現 →
   3.分數跑馬燈彈出至最終分數，同時菜色與菜色介紹一起出現 → 4.登入提示文字框彈出
   「由小至大彈出」的關鍵幀 cw-pop-scale 為共用動態效果，定義於 css/shared-fx.css ── */

@keyframes cw-finished-food-rise {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(70px);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 手機版 .finished--times-up .finished__food--right 定位為 translateX(-10%)，動畫需同步改用此關鍵幀 */
@keyframes cw-finished-food-rise-mobile {
  0% {
    opacity: 0;
    transform: translateX(-10%) translateY(70px);
  }

  100% {
    opacity: 1;
    transform: translateX(-10%) translateY(0);
  }
}

/* ── 頂部 FINISHED ── */

.finished__hero {
  position: relative;
  width: 100%;
  height: auto;
  top: 14%;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 3;
}

.finished__ribbon {
  position: relative;
  width: 550px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.25));
  z-index: 2;
  transform-origin: center center;
  animation: cw-pop-scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.finished__food {
  position: absolute;
  object-fit: contain;
  width: 180px;
  height: auto;
  z-index: 1;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.finished__food--left {
  left: 37%;
  bottom: 50%;
  animation-delay: 0.15s;
}

.finished__food--center {
  left: 50%;
  width: 200px;
  bottom: 62%;
  --pop-base-transform: translateX(-50%);
  z-index: 2;
  animation-delay: 0.3s;
}

.finished__food--right {
  right: 37%;
  bottom: 50%;
  animation-delay: 0.45s;
}

/* ── 時間到（Time's Up）狀態 ── */

.finished--times-up .finished__food--left,
.finished--times-up .finished__food--center {
  display: none;
}

.finished--times-up .finished__food--right {
  width: 220px;
  left: 58%;
  bottom: 55%;
  transform: translateX(-50%);
  animation: cw-finished-food-rise 1s ease-out both;
  animation-delay: 0.25s;
}

.finished--times-up .finished__ribbon {
  width: 540px;
  top: -1.3%;
}

.finished--times-up .finished__panel {
  bottom: 6.3%;
  margin-bottom: -21px;
}

.finished--times-up .finished__panel-frame {
  --pop-base-transform: translateY(-1%);
}

/* ── 對戰勝負結算：動態沿用爬榜通關（cw-pop-scale + 分數跑馬燈） ── */

.finished__pvp-chef {
  display: none;
  position: absolute;
  width: 168px;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  z-index: 4;
  transform-origin: center bottom;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.2s;
}

.finished--battle-win .finished__food--left,
.finished--battle-win .finished__food--center,
.finished--battle-lose .finished__food--left,
.finished--battle-lose .finished__food--center,
.finished--battle-lose .finished__food--right {
  display: none;
}

.finished--battle-win .finished__food--right {
  display: block;
  width: 400px;
  left: 56%;
  right: auto;
  bottom: 52%;
  --pop-base-transform: translateX(-50%);
  z-index: 1;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.25s;
}

.finished--battle-win .finished__ribbon {
  width: 550px;
  z-index: 3;
}

.finished--battle-win .finished__pvp-chef {
  display: block;
  left: calc(50% - 325px + 4%);
  bottom: 42%;
  width: 244px;
  z-index: 2;
  --pop-base-transform: rotate(-15deg);
}

.finished--battle-win .finished__score {
  top: 24%;
}

/* 底框維持原尺寸；用內距把文字往內收（放大容器只會讓文案跟著變寬仍貼邊）。
   菜圖提到框上層，僅對戰勝利，不影響爬榜／時間到／失敗結算。 */
.finished--battle-win .finished__dish-info {
  width: 280px;
  height: 200px;
  padding: 8px 20px 16px;
  background: #bd7738;
  border-radius: 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  z-index: 2;
}

.finished--battle-win .finished__dish-info::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 24px;
  height: 2px;
  background: rgba(92, 48, 16, 0.28);
  border-radius: 1px;
  pointer-events: none;
}

.finished--battle-win .finished__dish-name {
  margin-top: 28px;
}

.finished--battle-win .finished__dish-image {
  z-index: 4;
}

.finished--battle-lose .finished__ribbon {
  width: 520px;
  top: -1%;
  z-index: 3;
}

.finished--battle-lose .finished__pvp-chef {
  display: block;
  right: calc(50% - 330px + 3%);
  left: auto;
  bottom: 48%;
  width: 255px;
  z-index: 2;
  --pop-base-transform: scaleX(-1) rotate(-15deg);
}

.finished--battle-lose .finished__score {
  top: 23.5%;
}

.finished--battle-lose .finished__panel {
  bottom: 6.3%;
  margin-bottom: -21px;
}

.finished--battle-lose .finished__panel-frame {
  --pop-base-transform: translateY(-1%);
}

/* ── 分數 ── */

.finished__score {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  z-index: 4;
  top: 22%;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.55s;
}

.finished__score-label {
  width: 90px;
  height: auto;
  object-fit: contain;
}

.finished__score-digits {
  display: flex;
  align-items: center;
}

.finished__score-digits img {
  width: 45px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* ── 主底板 ── */

.finished__panel {
  position: relative;
  width: 100%;
  height: auto;
  max-height: 600px;
  bottom: 4%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.finished__panel-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.2));
  transform-origin: center center;
  animation: cw-pop-scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.finished__panel-body {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  left: 50%;
  top: 50%;
}

.finished__dish-info {
  position: absolute;
  width: 280px;
  height: 200px;
  top: 25%;
  text-align: center;
  color: #fff;
  z-index: 3;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s ease-out both;
  animation-delay: 1.4s;
}

.finished__dish-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  margin-top: 15px;
  margin-bottom: 20px;
}

.finished__dish-desc {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  opacity: 0.95;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
}

.finished__dish-more {
  position: absolute;
  right: 10%;
  bottom: 25%;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  z-index: 4;
}

.finished__dish-more:hover {
  text-decoration: underline;
}

.finished__dish-image {
  position: absolute;
  /* 置中偏下，避開上方說明與下方登入提示 */
  --pop-base-transform: translateY(22%);
  top: 40%;
  left: 50%;
  margin-left: -110px;
  width: 220px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s ease-out both;
  animation-delay: 1.4s;
}

.finished__dish-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished__login-prompt {
  position: absolute;
  --pop-base-transform: translateY(270%);
  width: 320px;
  height: auto;
  transform-origin: center center;
  animation: cw-pop-scale 0.4s ease-out both;
  animation-delay: 1.8s;
}

.finished__login-prompt--linked {
  cursor: pointer;
}

.finished__login-frame {
  height: 100%;
  width: 100%;
  object-fit: contain;
  pointer-events: none;
}

.finished__login-text {
  position: absolute;
  inset: 12% 9% 22% 9%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  color: #603813;
  text-align: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  pointer-events: none;
}

.finished__login-link {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.finished__login-link--chef,
.finished__login-link--book {
  color: #8b4513;
}

.finished__login-link--bind {
  color: #d32f2f;
}

.finished__gift {
  position: absolute;
  width: 72px;
  top: 77%;
  right: 37%;
  z-index: 5;
  transition: transform 0.15s ease;
}

.finished__gift[hidden] {
  display: none !important;
}

.finished__gift img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.finished__gift:hover {
  transform: scale(1.05);
}

/* ── 操作按鈕 ── */

.finished__actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  height: auto;
  bottom: 5%;
  z-index: 3;
}

.finished__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.finished__action-btn:hover {
  transform: scale(1.03);
}

.finished__action-btn img {
  width: 100%;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.finished__action-btn span {
  position: absolute;
  top: 15%;
  font-size: 30px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.finished__action-btn--confirm,
.finished__action-btn--retry {
  width: 160px;
}

.finished__action-btn--retry span {
  font-size: 30px;
}

.finished__action-btn--share {
  width: 60px;
}

/* ── 底部推薦區 ── */

.finished__footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  bottom: 4%;
  gap: 8px;
}

.finished__promo {
  position: relative;
  width: 220px;
  flex-shrink: 0;
}

.finished__promo-frame {
  display: block;
  width: 100%;
  height: auto;
}

/* 氣泡內文：左氣泡圖左文右、右氣泡文左圖右；圖不蓋字、字自動換行 */
.finished__promo-body {
  position: absolute;
  left: 9%;
  right: 8%;
  top: 12%;
  bottom: 26%;
  display: flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
}

.finished__promo p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 1000;
  color: #6b3a14;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.finished__promo-gif,
.finished__qr {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.finished__promo-gif img,
.finished__qr img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── 菜品完整說明彈窗（Frame_Dialog）── */

.finished__dialog-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.finished__dialog-overlay[hidden] {
  display: none !important;
}

.finished__dialog-panel {
  position: relative;
  width: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.finished__dialog-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}

.finished__dialog-close {
  position: absolute;
  top: -2%;
  right: -4%;
  width: 64px;
  height: 64px;
  z-index: 4;
}

.finished__dialog-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished__dialog-body {
  position: absolute;
  inset: 12% 10% 28%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.finished__dialog-title {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 28px;
  font-weight: bold;
  color: #603813;
  margin-bottom: 36px;
}

.finished__dialog-text {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.5;
  color: #603813;
  text-align: left;
  align-self: stretch;
}

.finished__dialog-dish {
  position: absolute;
  right: 10%;
  bottom: -8%;
  width: 200px;
  pointer-events: none;
  z-index: 3;
}

.finished__dialog-dish img {
  width: 150%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.2));
}

@media (max-width: 800px) {
  .finished__dialog-panel {
    width: 320px;
  }

  .finished__dialog-close {
    width: 52px;
    height: 52px;
    top: -1%;
    right: -3%;
  }

  .finished__dialog-title {
    font-size: 22px;
    margin-bottom: 14px;
  }

  .finished__dialog-text {
    font-size: 14px;
    line-height: 1.55;
  }

  .finished__dialog-dish {
    width: 140px;
    right: 10%;
    bottom: -6%;
  }
}

/* ── 觀看廣告面板（Frame_Wooden）── */

.finished__ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

/* 面板已移出 .finished，需自行重置 button 預設底板（否則出現白底／邊框） */
.finished__ad-overlay,
.finished__ad-overlay *,
.finished__ad-overlay *::before,
.finished__ad-overlay *::after {
  box-sizing: border-box;
}

.finished__ad-overlay button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.finished__ad-overlay[hidden] {
  display: none !important;
}

.finished__ad-overlay.is-ad-confirm-open .finished__ad-panel {
  filter: grayscale(1) brightness(1);
  pointer-events: none;
}

/* 進場：由小至大彈出（共用 cw-pop-scale，與設定／菜品說明面板一致） */
.finished__ad-panel {
  position: relative;
  width: 480px;
  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;
}

.finished__ad-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}

.finished__ad-close {
  position: absolute;
  top: 2%;
  right: 2%;
  width: 64px;
  height: 64px;
  z-index: 4;
}

.finished__ad-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished__ad-body {
  position: absolute;
  inset: 28% 12% 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
}

.finished__ad-watch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88%;
  transition: transform 0.15s ease;
}

.finished__ad-watch:hover {
  transform: scale(1.03);
}

.finished__ad-watch img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.finished__ad-watch span {
  position: absolute;
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.finished__ad-search {
  position: relative;
  top: -5%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.finished__ad-search-frame {
  width: 80%;
  height: auto;
  object-fit: contain;
}

.finished__ad-search-input {
  position: absolute;
  inset: 0 100px 5px 56px;
  border: none;
  background: transparent;
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 20px;
  font-weight: bold;
  color: #603813;
  outline: none;
}

.finished__ad-search-input::placeholder {
  color: #8a5a32;
  opacity: 0.85;
}

.finished__ad-search-btn {
  position: absolute;
  right: 50px;
  top: 15%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.finished__ad-search-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished__ad-flour {
  position: absolute;
  right: -7%;
  bottom: 3%;
  width: 160px;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  z-index: 3;
}

.finished__ad-confirm {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.finished__ad-confirm[hidden] {
  display: none !important;
}

.finished__ad-confirm-panel {
  position: relative;
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  --pop-base-transform: scale(calc(var(--ui-scale, 1) * 0.8));
  transform-origin: center center;
  animation: cw-pop-scale 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: auto;
}

.finished__ad-confirm-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}

.finished__ad-confirm-close {
  position: absolute;
  top: 2%;
  right: 2%;
  width: 64px;
  height: 64px;
  z-index: 2;
}

.finished__ad-confirm-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.finished__ad-confirm-body {
  position: absolute;
  inset: 32% 14% 24%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}

.finished__ad-confirm-reward {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 32px;
  font-weight: bold;
  color: #603813;
  line-height: 1.2;
}

.finished__ad-confirm-note {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 20px;
  font-weight: bold;
  color: #8a5a32;
  line-height: 1.3;
}

@media (max-width: 800px) {
  .finished__ad-panel {
    width: 320px;
  }

  .finished__ad-close {
    width: 48px;
    height: 48px;
    top: 1%;
    right: 1%;
  }

  .finished__ad-body {
    inset: 30% 10% 20%;
    gap: 12px;
  }

  .finished__ad-watch span {
    font-size: 20px;
  }

  .finished__ad-search-input {
    left: 36px;
    right: 50px;
    top: 50%;
    bottom: auto;
    height: 1.35em;
    margin: 0;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 1.35em;
    transform: translateY(-50%);
  }

  .finished__ad-search-btn {
    top: 50%;
    right: 34px;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
  }

  .finished__ad-flour {
    width: 76px;
    right: -4%;
    z-index: 2;
  }

  .finished__ad-confirm-panel {
    width: 320px;
  }

  .finished__ad-confirm-close {
    width: 48px;
    height: 48px;
    top: 1%;
    right: 1%;
  }

  .finished__ad-confirm-reward {
    font-size: 22px;
  }

  .finished__ad-confirm-note {
    font-size: 14px;
  }
}

/* ── 本次獲得獎勵彈窗（Frame_Dough）進場動態：依序
   1.底板彈出 → 2.擀麵棍與標題彈出且左右晃動三下 → 3.最上方禮物盒由小至大彈出 →
   內容物件（禮物/卡片）由左至右、由上至下一一浮現彈出
   「由小至大彈出」的關鍵幀 cw-pop-scale 為共用動態效果，定義於 css/shared-fx.css ── */

@keyframes cw-reward-title-wobble {
  0% {
    opacity: 0;
    transform: translateX(0) rotate(4deg) scale(0.3);
  }

  18% {
    opacity: 1;
    transform: translateX(0) rotate(4deg) scale(1.1);
  }

  28% {
    transform: translateX(0) rotate(4deg) scale(1);
  }

  40% {
    transform: translateX(-16px) rotate(4deg) scale(1);
  }

  52% {
    transform: translateX(16px) rotate(4deg) scale(1);
  }

  64% {
    transform: translateX(-12px) rotate(4deg) scale(1);
  }

  76% {
    transform: translateX(12px) rotate(4deg) scale(1);
  }

  88% {
    transform: translateX(-6px) rotate(4deg) scale(1);
  }

  100% {
    opacity: 1;
    transform: translateX(0) rotate(4deg) scale(1);
  }
}

@keyframes cw-reward-fade-up {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.finished__reward-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.finished__reward-overlay[hidden] {
  display: none !important;
}

.finished__reward-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 500px;
  transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
}

.finished__reward-heading {
  position: relative;
  z-index: 4;
  width: 100%;
  margin-bottom: -36px;
  display: flex;
  justify-content: center;
}

.finished__reward-title-wrap {
  position: relative;
  top: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(4deg);
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.28));
  transform-origin: center center;
  animation: cw-reward-title-wobble 1s ease-in-out both;
  animation-delay: 0.15s;
}

.finished__reward-rolling-pin {
  width: 500px;
  height: auto;
  z-index: 1;
  object-fit: contain;
}

.finished__reward-title {
  position: absolute;
  z-index: 2;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -60%) rotate(4deg);
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 32px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.finished__reward-gift-deco {
  position: absolute;
  top: -85px;
  width: 100px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  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.3s;
}

.finished__reward-body {
  position: relative;
  width: 100%;
  z-index: 2;
}

.finished__reward-frame {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25));
  transform-origin: center center;
  animation: cw-pop-scale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.finished__reward-content {
  position: absolute;
  inset: 0% 12% 16%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.finished__reward-panel[data-reward-view="simple"] .finished__reward-content--detail {
  display: none !important;
}

.finished__reward-panel[data-reward-view="detail"] .finished__reward-content--simple {
  display: none !important;
}

.finished__reward-content--detail {
  inset: 12% 8% 12%;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
}

.finished__reward-scroll-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 95%;
}

.finished__reward-scroll-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  --reward-edge-blur: 40px;
  --fade-top: 0px;
  --fade-bottom: 0px;
}

.finished__reward-scroll {
  padding: 0 24px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-top),
    #000 calc(100% - var(--fade-bottom)),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 var(--fade-top),
    #000 calc(100% - var(--fade-bottom)),
    transparent 100%
  );
}

.finished__reward-scroll-edge {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--reward-edge-blur);
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  background: linear-gradient(
    to bottom,
    rgba(237, 221, 194, 0) 0%,
    rgba(237, 221, 194, 0.28) 50%,
    rgba(237, 221, 194, 0) 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 50%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 50%,
    transparent 100%
  );
}

.finished__reward-scroll-edge.is-active {
  opacity: 1;
}

.finished__reward-scroll-edge--top {
  top: calc(var(--reward-edge-blur) / -2);
}

.finished__reward-scroll-edge--bottom {
  bottom: calc(var(--reward-edge-blur) / -2);
}

.finished__reward-scroll::-webkit-scrollbar {
  display: none;
}

.finished__reward-section {
  margin-top: 40px;
}

.finished__reward-section-title {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 18px;
  font-weight: bold;
  color: #603813;
  margin-bottom: 8px;
  line-height: 1.3;
  animation: cw-reward-fade-up 0.3s ease-out both;
}

/* 依畫面上出現先後，分別調整每個分類標題的淡入延遲時間，
   讓標題文字略早於底下對應的禮物／卡片格子浮現 */
.finished__reward-section:nth-of-type(1) .finished__reward-section-title {
  animation-delay: 1.2s;
}

.finished__reward-section:nth-of-type(2) .finished__reward-section-title {
  animation-delay: 1.9s;
}

.finished__reward-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: -20px;
  gap: 8px 10px;
}

.finished__reward-item {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  opacity: 0;
  animation: cw-pop-scale 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* 禮物與卡片依左至右、由上至下的順序對應 DOM 順序，因此直接用 nth-child 設定各自延遲 */
#finished-reward-gifts .finished__reward-item:nth-child(1) {
  animation-delay: 1.3s;
}

#finished-reward-gifts .finished__reward-item:nth-child(2) {
  animation-delay: 1.4s;
}

#finished-reward-gifts .finished__reward-item:nth-child(3) {
  animation-delay: 1.5s;
}

#finished-reward-gifts .finished__reward-item:nth-child(n+4) {
  animation-delay: 1.5s;
}

#finished-reward-cards .finished__reward-item:nth-child(1) {
  animation-delay: 2s;
}

#finished-reward-cards .finished__reward-item:nth-child(2) {
  animation-delay: 2.08s;
}

#finished-reward-cards .finished__reward-item:nth-child(3) {
  animation-delay: 2.16s;
}

#finished-reward-cards .finished__reward-item:nth-child(4) {
  animation-delay: 2.24s;
}

#finished-reward-cards .finished__reward-item:nth-child(5) {
  animation-delay: 2.32s;
}

#finished-reward-cards .finished__reward-item:nth-child(6) {
  animation-delay: 2.4s;
}

#finished-reward-cards .finished__reward-item:nth-child(7) {
  animation-delay: 2.48s;
}

#finished-reward-cards .finished__reward-item:nth-child(8) {
  animation-delay: 2.56s;
}

#finished-reward-cards .finished__reward-item:nth-child(9) {
  animation-delay: 2.64s;
}

#finished-reward-cards .finished__reward-item:nth-child(10) {
  animation-delay: 2.72s;
}

#finished-reward-cards .finished__reward-item:nth-child(11) {
  animation-delay: 2.8s;
}

#finished-reward-cards .finished__reward-item:nth-child(n+12) {
  animation-delay: 2.88s;
}

.finished__reward-item--gift img {
  width: 70%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.18));
}

.finished__reward-item--card img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.15));
}

.finished__reward-bind-note {
  flex-shrink: 0;
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 22px;
  font-weight: bold;
  color: #d62828;
  text-align: center;
  margin-top: 6px;
  padding-bottom: 4px;
}

.finished__reward-scrollbar {
  position: absolute;
  top: 15%;
  right: 0%;
  width: 10px;
  height: 70%;
  z-index: 3;
  pointer-events: none;
  --scrollbar-track-inset: 0px;
  --scrollbar-thumb-width: 27px;
  --scrollbar-thumb-height: 46px;
  --scrollbar-thumb-visual-inset: 10px;
}

.finished__reward-scrollbar-track {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.finished__reward-scrollbar-thumb-wrap {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--scrollbar-thumb-width);
  height: var(--scrollbar-thumb-height);
  transform: translateX(-50%);
  transition: top 0.05s linear;
  pointer-events: auto;
  cursor: grab;
}

.finished__reward-scrollbar-thumb-wrap:active {
  cursor: grabbing;
}

.finished__reward-scrollbar-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.finished__reward-icon {
  width: 300px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
}

.finished__reward-hint {
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 22px;
  font-weight: bold;
  color: #d62828;
  text-align: center;
}

.finished__reward-confirm {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 168px;
  transition: transform 0.15s ease;
}

.finished__reward-confirm:hover {
  transform: scale(1.03);
}

.finished__reward-confirm img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.finished__reward-confirm span {
  position: absolute;
  font-family: "Huninn", "jf open huninn", "Yuanti TC", sans-serif;
  font-size: 30px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

@media (max-width: 800px) {
  .finished__reward-panel {
    width: 320px;
  }

  .finished__reward-heading {
    margin-bottom: -28px;
  }

  .finished__reward-rolling-pin {
    width: 270px;
  }

  .finished__reward-title {
    font-size: 20px;
  }

  .finished__reward-gift-deco {
    width: 60px;
    top: -16px;
    right: 6%;
  }

  .finished__reward-icon {
    width: 150px;
  }

  .finished__reward-hint {
    font-size: 12px;
  }

  .finished__reward-section-title {
    font-size: 13px;
    margin-bottom: 6px;
  }

  .finished__reward-grid {
    gap: 6px 8px;
  }

  .finished__reward-bind-note {
    font-size: 11px;
  }

  .finished__reward-scroll-viewport {
    --reward-edge-blur: 28px;
  }

  .finished__reward-scrollbar {
    width: 10px;
    right: -1%;
    --scrollbar-thumb-width: 20px;
    --scrollbar-thumb-height: 34px;
    --scrollbar-thumb-visual-inset: 2px;
  }

  .finished__reward-confirm {
    width: 136px;
    margin-top: -22px;
  }

  .finished__reward-confirm span {
    font-size: 22px;
  }
}

/* ── 手機直版：直向畫布 + 直向底圖 ── */

.finished__bg--portrait {
  display: none;
}

@media (max-width: 800px) {
  .finished__bg--landscape {
    display: none;
  }

  .finished__bg--portrait {
    display: block;
  }

  .finished__canvas {
    width: 400px;
    height: 844px;
    justify-content: flex-start;
    gap: 0;
  }

  .finished__hero {
    position: relative;
    top: auto;
    height: 140px;
    margin-bottom: -28px;
    flex-shrink: 0;
  }

  .finished__ribbon {
    margin-bottom: -120px;
    width: 420px;
  }

  .finished__food {
    width: 96px;
  }

  .finished__food--left {
    width: 140px;
    left: 3%;
    top: 25%;
  }

  .finished__food--center {
    width: 180px;
    top: 0%;
  }

  .finished__food--right {
    width: 140px;
    left: 65%;
    top: 20%;
  }

  .finished--times-up .finished__food--right {
    top: -30%;
    left: 50%;
    animation-name: cw-finished-food-rise-mobile;
  }

  .finished--times-up .finished__ribbon {
    top: -30%;
    width: 360px;
  }

  .finished--times-up .finished__retry-label--times-up {
    font-size: 14px;
  }

  .finished--times-up .finished__score {
    position: relative;
    top: 50px;
    margin-bottom: 6px;
  }

  .finished--battle-win .finished__food--right {
    width: 280px;
    left: 67%;
    top: 42%;
    bottom: auto;
  }

  .finished--battle-win .finished__ribbon {
    width: 400px;
    margin-bottom: -110px;
  }

  .finished--battle-win .finished__pvp-chef {
    left: 2%;
    bottom: -7%;
    width: 177px;
  }

  .finished--battle-win .finished__dish-info {
    width: 168px;
    height: 110px;
    padding: 4px 12px 10px;
    border-radius: 18px;
    --pop-base-transform: scale(1.5);
  }

  .finished--battle-win .finished__dish-info::before {
    left: 10px;
    right: 10px;
    top: 16px;
  }

  .finished--battle-win .finished__dish-name {
    margin-top: 18px;
  }

  .finished--battle-win .finished__score {
    position: relative;
    top: 86px;
    margin-bottom: 6px;
  }

  .finished--battle-lose .finished__ribbon {
    top: auto;
    width: 400px;
    margin-bottom: -110px;
  }

  .finished--battle-lose .finished__pvp-chef {
    right: 2%;
    left: auto;
    bottom: -10%;
    width: 184px;
  }

  .finished--battle-lose .finished__score {
    position: relative;
    top: 86px;
    margin-bottom: 6px;
  }

  .finished--battle-lose .finished__panel {
    bottom: auto;
    margin-bottom: 10px;
  }

  .finished__score {
    position: relative;
    top: 100px;
    margin-bottom: 6px;
  }

  .finished__score-label {
    width: 100px;
  }

  .finished__score-digits {
    width: 100px;
  }

  .finished__score-digits img {
    width: 30px;
  }

  .finished__panel {
    position: relative;
    width: 368px;
    height: 450px;
    max-height: none;
    bottom: auto;
    flex-shrink: 0;
    margin-bottom: 10px;
  }

  .finished__panel-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .finished__dish-info {
    width: 168px;
    height: 110px;
    top: 27%;
  }

  .finished__dish-name {
    font-size: 15px;
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .finished__dish-desc {
    font-size: 11px;
    -webkit-line-clamp: 2;
  }

  .finished__dish-more {
    font-size: 11px;
    bottom: 6%;
  }

  .finished__dish-image {
    top: 42%;
    width: 168px;
    margin-left: -84px;
    --pop-base-transform: translateY(16%);
  }

  .finished__login-prompt {
    width: 240px;
  }

  .finished__login-text {
    inset: 14% 10% 24% 10%;
    font-size: 11px;
    line-height: 1.2;
  }

  .finished__gift {
    width: 60px;
    top: 74%;
    right: 0%;
  }

  .finished__actions {
    position: relative;
    bottom: auto;
    gap: 14px;
    flex-shrink: 0;
    margin-bottom: 10px;
  }

  .finished__action-btn--confirm,
  .finished__action-btn--retry {
    width: 120px;
  }

  .finished__action-btn span {
    font-size: 20px;
  }

  .finished__action-btn--retry span {
    font-size: 20px;
  }

  .finished__action-btn--share {
    width: 48px;
  }

  .finished__footer {
    position: relative;
    bottom: 5%;
    flex-shrink: 0;
    margin-top: auto;
    width: 100%;
    padding: 0 10px;
    gap: 6px;
    box-sizing: border-box;
  }

  .finished__promo {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }

  .finished__promo-body {
    left: 7%;
    right: 6%;
    top: 10%;
    bottom: 28%;
    gap: 4px;
  }

  .finished__promo p {
    font-size: 11px;
    line-height: 1.2;
  }

  .finished__promo-gif,
  .finished__qr {
    width: 38px;
    height: 38px;
  }

  .finished__reward-title-wrap {
    margin-bottom: 20px;
  }

  .finished__reward-rolling-pin {
    width: 350px;
  }

  .finished__reward-gift-deco {
    width: auto;
    top: -75%;
    left: 40%;
  }

  .finished__reward-confirm {
    margin-top: 20px;
  }
}

/* ── 降低動態效果偏好：關閉結算面板進場動畫 ── */
@media (prefers-reduced-motion: reduce) {

  .finished__ribbon,
  .finished__food,
  .finished__pvp-chef,
  .finished__panel-frame,
  .finished__score,
  .finished__dish-info {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .finished--battle-win .finished__pvp-chef {
    transform: rotate(-15deg);
  }

  .finished--battle-lose .finished__pvp-chef {
    transform: scaleX(-1) rotate(-15deg);
  }

  .finished__food--center {
    animation: none;
    opacity: 1;
    transform: translateX(-50%);
  }

  .finished--times-up .finished__panel-frame {
    animation: none;
    opacity: 1;
    transform: translateY(-1%);
  }

  .finished--times-up .finished__food--right {
    animation: none;
    opacity: 1;
    transform: translateX(-50%);
  }

  .finished--battle-win .finished__food--right {
    animation: none;
    opacity: 1;
    transform: translateX(-50%);
  }

  .finished--battle-lose .finished__panel-frame {
    animation: none;
    opacity: 1;
    transform: translateY(-1%);
  }

  .finished__dish-image {
    animation: none;
    opacity: 1;
    transform: translateY(22%);
  }

  .finished__login-prompt {
    animation: none;
    opacity: 1;
    transform: translateY(270%);
  }

  .finished__reward-frame,
  .finished__reward-gift-deco,
  .finished__reward-section-title,
  .finished__reward-item {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .finished__reward-title-wrap {
    animation: none;
    opacity: 1;
    transform: rotate(4deg);
  }

  .finished__ad-panel,
  .finished__ad-confirm-panel {
    animation: none;
    opacity: 1;
    transform: var(--pop-base-transform, none);
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 800px) {
  .finished--times-up .finished__food--right {
    transform: translateX(-10%);
  }

  .finished--battle-win .finished__food--right {
    transform: translateX(-50%);
  }

  .finished--battle-win .finished__dish-info {
    transform: scale(1.5);
  }

  .finished__dish-image {
    transform: translateY(14%);
  }
}

/* 練習模式：隱藏結算禮物盒（無獎勵／圖鑑） */
.finished--practice .finished__gift {
  display: none !important;
}

.finished--battle .finished__gift {
  display: none !important;
}

