/* 毛手毛腳食堂 — 流程線元件：轉場遮罩、新機關小卡、結算加料、出錯畫面、HUD 最後 30 秒、主選單 3D 背景 */

/* ---------- 主選單：背景是活的小廚房（3D 畫布透出來） ---------- */
.pp-ui.has-3d .pp-s-title.pp-bg-gingham {
  background: radial-gradient(120% 85% at 50% 42%, rgba(251, 239, 214, .72) 0 26%, rgba(251, 239, 214, .28) 52%, rgba(59, 42, 34, .08) 100%);
}
.pp-ui.has-3d .pp-s-title .tt-sun { opacity: .55; }
.pp-ui.has-3d .pp-s-title .tt-doodles { opacity: .7; }
.pp-ui.has-3d .pp-s-title .tt-paws { opacity: .45; }
/* 著色器還在背景編譯時畫布先藏著（藏是瞬間、出現是淡入），編好才淡入，不會先看到一格黑畫面 */
#game { transition: opacity .55s ease; }
#game.is-warming { opacity: 0; transition: none; }

/* ---------- 轉場遮罩 ---------- */
.fl-mask {
  position: fixed; inset: 0; z-index: 60; display: none; pointer-events: auto;
  background-color: #fbefd6;
  background-image:
    linear-gradient(90deg, rgba(229, 72, 59, .17) 50%, transparent 50%),
    linear-gradient(rgba(229, 72, 59, .17) 50%, transparent 50%);
  background-size: 64px 64px;
  font-family: "Huninn", "Noto Sans TC", sans-serif; color: #3b2a22;
}
.fl-mask.is-on { display: grid; place-items: center; animation: fl-mask-in .22s cubic-bezier(.2, 1.2, .4, 1) both; }
.fl-mask.is-out { animation: fl-mask-out .36s ease-in both; pointer-events: none; }
@keyframes fl-mask-in { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(80% at 50% 50%); } }
@keyframes fl-mask-out { from { clip-path: circle(80% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
.fl-mask-paper {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 34px 22px; background: #fff8ea; border: 3px solid #3b2a22; border-radius: 22px; box-shadow: 6px 6px 0 #3b2a22;
  transform: rotate(-1.5deg);
}
.fl-mask-run { position: relative; width: 220px; height: 84px; overflow: hidden; border-bottom: 3px dashed rgba(59, 42, 34, .35); }
/* 跑步只用 transform／opacity（交給合成器）：進關時主執行緒在蓋廚房、編著色器，小廚師照樣跑，不會定格 */
.fl-mask-lane { position: absolute; left: 0; bottom: 4px; width: 0; height: 0; will-change: transform; animation: fl-run 1.25s linear infinite; }
.fl-mask-chef {
  position: absolute; bottom: 0; left: 0; width: 64px; height: 64px; display: grid; place-items: center;
  background: #f2b632; border: 3px solid #3b2a22; border-radius: 50%; box-shadow: 3px 3px 0 #3b2a22;
  will-change: transform; animation: fl-hop .25s ease-in-out infinite alternate;
}
.fl-mask-chef.is-img { width: 76px; height: 84px; bottom: -4px; background: center bottom / contain no-repeat; border: 0; border-radius: 0; box-shadow: none; filter: drop-shadow(3px 3px 0 rgba(59, 42, 34, .3)); }
.fl-mask-chef.is-img svg { display: none; }
.fl-mask-run i { position: absolute; left: 0; bottom: 6px; width: 12px; height: 12px; will-change: transform, opacity; border-radius: 50%; background: rgba(255, 250, 240, .95); border: 2px solid rgba(59, 42, 34, .4); opacity: 0; animation: fl-dust 1.25s linear infinite; }
.fl-mask-run i:nth-of-type(2) { animation-delay: .2s; }
.fl-mask-run i:nth-of-type(3) { animation-delay: .4s; }
@keyframes fl-run { from { transform: translateX(-70px); } to { transform: translateX(230px); } }
@keyframes fl-hop { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-10px) rotate(6deg); } }
@keyframes fl-bob { from { translate: 0 0; rotate: -6deg; } to { translate: 0 -10px; rotate: 6deg; } }
@keyframes fl-dust { 0% { opacity: 0; transform: translateX(-20px) scale(.4); } 10% { opacity: .9; transform: translateX(0) scale(.57); } 60% { opacity: 0; transform: translateX(100px) scale(1.4); } 100% { opacity: 0; transform: translateX(180px) scale(1); } }
.fl-mask-text { font-size: 22px; letter-spacing: .04em; }

/* ---------- 新機關小卡 ---------- */
.fl-tip {
  position: absolute; z-index: 25; left: 50%; top: calc(var(--sat, 0px) + 150px); translate: -50% 0;
  display: flex; align-items: center; gap: 12px; width: min(560px, calc(100vw - 32px));
  padding: 14px 44px 14px 14px; pointer-events: auto;
  background: #fff9c9; border: 3px solid #3b2a22; border-radius: 18px; box-shadow: 5px 5px 0 #3b2a22;
  font-family: "Noto Sans TC", sans-serif; color: #3b2a22;
  animation: fl-tip-in .5s cubic-bezier(.2, 1.5, .45, 1) both; transform: rotate(-1deg);
}
.fl-tip.is-out { animation: fl-tip-out .3s ease-in both; }
@keyframes fl-tip-in { from { opacity: 0; transform: translateY(-24px) rotate(-6deg) scale(.8); } to { opacity: 1; transform: rotate(-1deg); } }
@keyframes fl-tip-out { to { opacity: 0; transform: translateY(-18px) rotate(3deg) scale(.9); } }
.fl-tip-badge { position: absolute; top: -14px; left: 16px; padding: 1px 12px; font-family: "Huninn", sans-serif; font-size: 15px; color: #fff; background: #e5483b; border: 3px solid #3b2a22; border-radius: 999px; box-shadow: 2px 2px 0 #3b2a22; }
.fl-tip-ico { flex: none; width: 58px; height: 58px; display: grid; place-items: center; background: #fffaf0; border: 3px solid #3b2a22; border-radius: 50%; }
.fl-tip-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fl-tip-body b { font-family: "Huninn", sans-serif; font-weight: 400; font-size: 21px; }
.fl-tip-body span { font-size: 15px; line-height: 1.45; }
.fl-tip-x { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 2.5px solid #3b2a22; background: #fffaf0; cursor: pointer; }
@media (max-width: 600px), (max-height: 460px) {
  .fl-tip { top: auto; bottom: calc(var(--sab, 0px) + 12px); padding: 10px 40px 10px 10px; }
  .fl-tip-ico { width: 44px; height: 44px; }
  .fl-tip-body b { font-size: 18px; }
  .fl-tip-body span { font-size: 13px; }
}
@media (max-height: 460px) { .fl-tip { left: 50%; bottom: auto; top: calc(var(--sat, 0px) + 96px); width: min(460px, calc(100vw - 330px)); min-width: 260px; } }

/* ---------- HUD：最後 30 秒變紅心跳、掉線碎星 ---------- */
.pp-hud .hud-timer.is-final { background: radial-gradient(circle at 32% 26%, #ff7a64 0 12%, transparent 30%), #d12f22; animation: fl-beat .9s ease-in-out infinite; }
.pp-hud .hud-timer.is-final .ht-time { color: #c0261a; }
.pp-hud .hud-timer.is-final.is-warn { animation: fl-beat .9s ease-in-out infinite, ht-warn .5s ease-in-out infinite; }
@keyframes fl-beat { 0%, 100% { scale: 1; } 14% { scale: 1.12; } 28% { scale: 1; } 42% { scale: 1.08; } 60% { scale: 1; } }
.pp-hud .hud-sl { position: relative; }
.pp-hud .hud-sl.is-break { animation: fl-sl-break .45s ease-out; }
@keyframes fl-sl-break { 0% { transform: none; } 20% { transform: translateX(-6px) rotate(-3deg); } 45% { transform: translateX(5px) rotate(2deg); } 70% { transform: translateX(-3px); } 100% { transform: none; } }
.hs-shard {
  position: absolute; left: 50%; top: 18px; width: 10px; height: 10px; margin: -5px 0 0 -5px; pointer-events: none;
  background: #f2b632; border: 2px solid #3b2a22; clip-path: polygon(50% 0, 100% 60%, 30% 100%, 0 40%);
  animation: fl-shard .7s cubic-bezier(.2, .8, .4, 1) forwards;
}
@keyframes fl-shard { from { transform: translate(0, 0) rotate(0); opacity: 1; } to { transform: translate(var(--x), calc(var(--y) + 40px)) rotate(var(--r)); opacity: 0; } }

/* ---------- 結算：隊伍頭像 ---------- */
.fl-team { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 2px; }
.fl-mate { display: flex; flex-direction: column; align-items: center; gap: 2px; animation: pp-pop .5s cubic-bezier(.2, 1.6, .45, 1) both; animation-delay: var(--d, 0s); }
.fl-mate-por {
  position: relative; width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #fffaf0 0 50%, color-mix(in srgb, var(--pc) 35%, #fff8ea) 51%);
  border: 3px solid #3b2a22; box-shadow: 0 0 0 3px var(--pc), 3px 3px 0 3px #3b2a22;
}
.fl-mate-por img { position: absolute; inset: 4%; width: 92%; height: 92%; object-fit: contain; object-position: 50% 15%; }
.pp-s-results .rs-card.is-win .fl-mate-por img { animation: fl-cheer .6s ease-in-out .8s 3; }
@keyframes fl-cheer { 50% { transform: translateY(-6px) rotate(-6deg); } }
.fl-mate b { font-family: "Huninn", sans-serif; font-weight: 400; font-size: 14px; }

/* ---------- 結算：排行榜 ---------- */
.fl-lb { grid-column: 1 / -1; margin-top: 4px; padding: 10px 14px 8px; background: #fffdf6; border: 3px solid #3b2a22; border-radius: 16px; box-shadow: 3px 3px 0 #3b2a22; animation: pp-pop .45s cubic-bezier(.2, 1.4, .45, 1) both; }
.fl-lb h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 6px; font-family: "Huninn", sans-serif; font-weight: 400; font-size: 19px; }
.fl-lb h4 small { margin-left: auto; font-family: "Noto Sans TC", sans-serif; font-size: 12px; color: #6b4f3f; }
.fl-lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.fl-lb-row { display: grid; grid-template-columns: 30px auto minmax(0, 1fr) auto 18px; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 10px; font-size: 14px; }
.fl-lb-row:nth-child(odd) { background: rgba(242, 182, 50, .12); }
.fl-lb-row.is-mine { background: #fff1b8; outline: 2.5px solid #e5483b; outline-offset: -2px; }
.fl-lb-rank { font-family: "Huninn", sans-serif; font-size: 18px; text-align: center; }
.fl-lb-row:nth-child(1) .fl-lb-rank { color: #c98d14; }
.fl-lb-pics { display: flex; }
.fl-lb-pics img { width: 26px; height: 26px; object-fit: contain; margin-right: -6px; border-radius: 50%; background: #fff8ea; border: 2px solid #3b2a22; }
.fl-lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 6px; }
.fl-lb-name em { font-style: normal; margin-left: 6px; padding: 0 7px; font-size: 12px; color: #fff; background: #e5483b; border-radius: 999px; }
.fl-lb-time { font-family: "Huninn", sans-serif; font-weight: 400; font-size: 17px; font-variant-numeric: tabular-nums; }
.fl-lb-ok { color: #2a8a43; }
.fl-lb-gap { text-align: center; color: #9c8169; line-height: 1; }

/* ---------- 登入連結 ---------- */
.fl-login {
  display: inline-flex; align-items: center; gap: 6px; align-self: center; justify-self: center;
  padding: 4px 12px; font-size: 14px; color: #2a6dba; text-decoration: none;
  background: rgba(59, 143, 229, .1); border: 2px dashed #3b8fe5; border-radius: 999px;
  pointer-events: auto; transition: transform .1s;
}
.fl-login:hover { transform: translateY(-1px); background: rgba(59, 143, 229, .18); }
.fl-login:active { transform: translateY(1px); }
.rs-card .fl-login { grid-column: 1 / -1; }
.st-card .fl-login { margin-top: 6px; }

/* ---------- 新紀錄煙火 ---------- */
.fl-fw { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 3; }
.fl-fw-burst { position: absolute; width: 0; height: 0; }
.fl-fw-burst i {
  position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 2px rgba(59, 42, 34, .8);
  opacity: 0; animation: fl-fw 1.2s cubic-bezier(.15, .8, .3, 1) both; animation-delay: var(--d, 0s);
}
@keyframes fl-fw {
  0% { opacity: 0; transform: translate(0, 0) scale(.3); }
  8% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 30px)) scale(.6); }
}

/* ---------- 出錯畫面 ---------- */
.fl-crash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(43, 28, 20, .55); }
.fl-crash-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; padding: 28px 30px 24px; cursor: pointer;
  font-family: "Noto Sans TC", sans-serif; color: #3b2a22; text-align: center;
  background: #fff8ea; border: 3px solid #3b2a22; border-radius: 22px; box-shadow: 6px 6px 0 #3b2a22; transform: rotate(-1deg);
}
.fl-crash-card b { font-family: "Huninn", sans-serif; font-weight: 400; font-size: 30px; }
.fl-crash-ico { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 50%; background: #f2b632; border: 3px solid #3b2a22; animation: fl-bob .6s ease-in-out infinite alternate; }
.fl-crash-btn { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 10px 22px; font-family: "Huninn", sans-serif; font-size: 20px; color: #fff; background: #e5483b; border: 3px solid #3b2a22; border-radius: 14px; box-shadow: inset 0 -4px 0 #b8322a, 4px 4px 0 #3b2a22; }
.fl-crash-card:active .fl-crash-btn { transform: translate(3px, 3px); box-shadow: inset 0 -2px 0 #b8322a, 1px 1px 0 #3b2a22; }

@media (prefers-reduced-motion: reduce) {
  .fl-mask.is-on, .fl-mask.is-out { animation: none; }
  .fl-mask-lane, .fl-mask-chef, .fl-mask-run i, .fl-crash-ico, .pp-hud .hud-timer.is-final { animation: none; }
  .fl-mask-lane { transform: translateX(76px); }   /* 不跑：小廚師站在中間 */
}

/* ---------- 世界地圖：有大關卡片插畫就換上 ---------- */
.wm-disc img.fl-wart { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* ---------- 暫停卡多一顆「設定」 ---------- */
.pa-mini { display: flex; justify-content: center; margin-top: 10px; }
.pa-mini .pp-btn { min-width: 0; padding-inline: 18px; font-size: 16px; }

/* ---------- 小螢幕結算：隊伍頭像縮小、登入提示收起來（標題與設定頁還有） ---------- */
@media (max-width: 520px), (max-height: 560px) {
  .rs-card .fl-team { gap: 6px; margin: -2px 0 0; }
  .rs-card .fl-mate-por { width: 44px; height: 44px; border-width: 2.5px; box-shadow: 0 0 0 2.5px var(--pc), 2px 2px 0 2.5px #3b2a22; }
  .rs-card .fl-mate b { display: none; }
  .rs-card .fl-login { display: none; }
}

/* ---------- 結算：時間滾動、動畫中不能按（按一下＝快轉） ---------- */
.rs-time b { transition: color .2s; }
.rs-time b.is-tick { animation: fl-tick .34s cubic-bezier(.2, 1.6, .45, 1); }
@keyframes fl-tick { 40% { transform: scale(1.12); } }
.rs-row { transition: transform .18s cubic-bezier(.2, 1.6, .45, 1), background-color .18s, box-shadow .18s; }
.rs-row.is-hot { transform: translateX(-6px) scale(1.04); background: #fff1b8; box-shadow: 3px 3px 0 #3b2a22; }
.rs-card.is-rolling .rs-actions .pp-btn { filter: saturate(.55) brightness(.97); transform: translateY(2px); box-shadow: 1px 1px 0 #3b2a22; cursor: default; }
.rs-card .rs-actions .pp-btn { transition: filter .25s, transform .2s cubic-bezier(.2, 1.6, .45, 1), box-shadow .2s; }
.rs-card.is-rolling { cursor: pointer; }

/* 解鎖卡剛跳出來：按鈕先灰一下（0.6 秒），避免連打直接按掉 */
.pp-s-unlock .pp-btn.is-wait { filter: saturate(.5); transform: translateY(2px); box-shadow: 1px 1px 0 #3b2a22; }

/* 新關卡解鎖卡（隱藏關） */
.ul-key { display: grid; place-items: center; background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, .5), transparent 50%), conic-gradient(from 0deg, #7a4fb0, #3b8fe5, #3fb35a, #f2b632, #e5483b, #7a4fb0); }
.ul-key > .pp-ico:first-child { position: relative; inset: auto; width: 56%; height: 56%; filter: drop-shadow(0 0 6px rgba(255, 246, 216, .9)); }
.ul-key .ul-spark { position: absolute; inset: auto; right: 10%; top: 10%; width: 28%; height: 28%; animation: fl-spark 1.4s ease-in-out infinite; }
@keyframes fl-spark { 50% { transform: scale(1.25) rotate(20deg); } }

/* 關卡選擇：上一局剛打開的關卡節點蹦出來 */
.lv-node.is-fresh:not(.is-pop) .lv-badge { transform: scale(.35); opacity: .35; }
.lv-node.is-fresh:not(.is-pop) .lv-stars, .lv-node.is-fresh:not(.is-pop) .lv-kind { opacity: 0; }
.lv-node.is-pop .lv-badge { animation: fl-node-pop .75s cubic-bezier(.2, 1.6, .45, 1) backwards; }
.lv-node.is-pop .lv-stars, .lv-node.is-pop .lv-kind { animation: pp-pop .4s cubic-bezier(.2, 1.6, .45, 1) .35s backwards; }
.lv-node.is-pop::after { content: ""; position: absolute; inset: -14%; border-radius: 50%; border: 4px solid #f2b632; pointer-events: none; animation: fl-node-ring .8s ease-out both; }
.lv-node.is-pop.is-secret::before { content: ""; position: absolute; inset: -60%; pointer-events: none; z-index: -1; border-radius: 50%;
  background: repeating-conic-gradient(rgba(242, 182, 50, .55) 0 10deg, transparent 10deg 26deg); -webkit-mask: radial-gradient(closest-side, #000 25%, transparent 72%); mask: radial-gradient(closest-side, #000 25%, transparent 72%);
  animation: tt-spin 10s linear infinite, fl-rays-in .6s ease-out both; }
@keyframes fl-node-pop { 0% { transform: scale(.35) rotate(-24deg); opacity: .35; } 55% { transform: scale(1.32) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes fl-node-ring { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes fl-rays-in { from { opacity: 0; } }

/* 手機橫拿（矮螢幕）：結算卡再收緊一點，整張放得進畫面 */
@media (max-height: 420px) and (orientation: landscape) {
  .pp-s-results { padding-top: calc(var(--sat) + 22px); padding-bottom: calc(var(--sab) + 6px); }
  .rs-card { padding: 22px 16px 10px; gap: 4px 16px; }
  /* 彩帶縮小、往上提，右欄往下讓一點：彩帶不再蓋住第一列「實際用時」 */
  .rs-ribbon { top: -20px; font-size: 20px; padding: 3px 32px 5px; }
  .rs-left { gap: 4px; }
  .rs-stars { margin: 0; }
  .rs-star { width: 48px; height: 48px; }
  .rs-star:nth-child(2) { width: 58px; height: 58px; translate: 0 -8px; }
  .rs-time { margin-top: 6px; }
  .rs-time b { font-size: 36px; }
  .rs-right { gap: 4px; padding-top: 12px; }
  .rs-row { padding: 2px 10px; }
  .rs-actions .pp-btn { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .rs-time b.is-tick, .lv-node.is-pop .lv-badge, .lv-node.is-pop::after, .lv-node.is-pop.is-secret::before, .ul-key .ul-spark { animation: none; }
  .lv-node.is-fresh:not(.is-pop) .lv-badge { transform: none; opacity: 1; }
}

/* 本機排行榜（本機打的成績另外排，標清楚） */
.fl-lb.is-local { background: #fffaf0; }
.fl-lb-tag { font-style: normal; font-family: "Noto Sans TC", sans-serif; font-size: 12px; padding: 1px 8px; margin-left: 2px; color: #fff; background: #3b8fe5; border: 2px solid #3b2a22; border-radius: 999px; }
.fl-lb-note { margin: 6px 2px 0; font-size: 12px; color: #6b4f3f; }
/* 螢幕不夠高（手機橫拿、直拿、矮筆電）：排行榜排到按鈕下面（往下捲才看），重來／地圖／下一關一定在第一屏 */
@media (max-height: 760px), (max-width: 600px) { .rs-card > .fl-lb { order: 1; } }
