/* =========================================================
   FUFU 聖誕雪球戰 — 版面以 360×640 為設計基準（素材 @2x = 720×1280）
   由 game.js 依視窗算出 scale，整個 .stage 用 transform 縮放
   ========================================================= */
:root {
  --stage-w: 360px;
  --stage-h: 640px;
  --green: #1f9973;
  --green-dark: #2b5446;
  --red: #e8474f;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfe6df;
  font-family: var(--font);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  overflow: hidden;
  transform-origin: center center;
  background: #d9efe9;
  box-shadow: 0 0 40px rgba(0, 0, 0, .12);
}

.snow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

img { display: block; -webkit-user-drag: none; }
[hidden] { display: none !important; }

/* ---------- 共用 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
}
.screen.is-active { display: block; animation: fadeIn .35s ease both; }
.screen.is-leaving { display: block; animation: fadeOut .35s ease both; pointer-events: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 128px;
  transform: translateX(-50%);
  z-index: 3;
}

.img-btn {
  position: absolute;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.img-btn img { width: 100%; height: auto; }
.img-btn:active { transform: scale(.94); filter: brightness(.95); }
.img-btn:disabled { cursor: default; }

/* ---------- 1. 首頁 ---------- */
.btn-start {
  left: 50%;
  bottom: 38px;
  width: 214px;
  margin-left: -107px;
}

/* ---------- 2. 快問快答 ---------- */
.quiz-frame {
  position: absolute;
  left: 50%;
  top: 76px;
  width: 317px;
  margin-left: -158px;
}

/* 碼錶 */
.timer {
  position: absolute;
  left: 50%;
  top: 46px;
  width: 64px;
  height: 72px;
  margin-left: -32px;
  z-index: 4;
}
.timer__knob {
  position: absolute;
  left: 50%;
  top: 0;
  width: 14px;
  height: 12px;
  margin-left: -7px;
  background: var(--red);
  border-radius: 4px 4px 2px 2px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}
.timer__knob::before {
  content: "";
  position: absolute;
  left: 3px;
  top: -4px;
  width: 8px;
  height: 5px;
  background: var(--red);
  border-radius: 3px 3px 0 0;
}
.timer__ring {
  position: absolute;
  left: 0;
  top: 8px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--red);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
  overflow: hidden;
}
.timer__pie {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* --p 由 JS 更新（0~1，剩餘比例） */
  background: conic-gradient(#f7b8bc calc(var(--p, 1) * 360deg), #fff 0);
}
.timer__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -.5px;
}
.timer.is-urgent .timer__ring { animation: shake .4s ease-in-out infinite; }
.timer.is-urgent .timer__text { color: #d0202a; }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

.quiz-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
.q-badge {
  height: 43px;
  margin-bottom: 14px;
}
.q-text {
  width: 232px;
  height: 61px;
  object-fit: contain;
  margin-bottom: 14px;
}
.answers {
  display: flex;
  gap: 14px;
  justify-content: center;
  width: 100%;
  min-height: 92px;
  align-items: center;
  margin-bottom: 16px;
}
.answer {
  position: relative;
  width: 110px;
  transition: transform .15s ease, opacity .25s ease;
}
.answer:disabled { transform: none; }
.answer.is-dim { opacity: .45; }
.answer.is-picked { transform: scale(1.06); }
.answer .mark {
  position: absolute;
  right: -14px;
  top: -14px;
  width: 44px;
  height: 44px;
  object-fit: contain;
  animation: pop .3s cubic-bezier(.2, 1.6, .4, 1) both;
  pointer-events: none;
}
@keyframes pop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.quiz-hint {
  width: 230px;
}

/* 題目切換動畫 */
.quiz-body.is-switching .q-badge,
.quiz-body.is-switching .q-text,
.quiz-body.is-switching .answers {
  animation: slideIn .35s ease both;
}
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.quiz-chars {
  position: absolute;
  left: 50%;
  bottom: 62px;
  width: 264px;
  height: 134px;
  margin-left: -132px;
  z-index: 3;
}
.quiz-chars__img { width: 100%; height: 100%; }
.quiz-snowball {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 64px;
  height: 64px;
  margin-left: -32px;
  transform-origin: 50% 100%;
  /* --ball 由 JS 更新（雪球倍率） */
  transform: scale(var(--ball, .7));
  transition: transform .45s cubic-bezier(.2, 1.4, .4, 1);
}
.quiz-snowball.is-bump { animation: bump .45s ease; }
@keyframes bump {
  0% { filter: brightness(1); }
  40% { filter: brightness(1.15) drop-shadow(0 0 8px #fff); }
  100% { filter: brightness(1); }
}

/* ---------- 3. 破關 ---------- */
.clear-card {
  position: absolute;
  left: 50%;
  top: 66px;
  width: 322px;
  margin-left: -161px;
  animation: dropIn .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.clear-card__img { width: 100%; }
.clear-card__count {
  position: absolute;
  /* 對應原圖 x 690~800 / 1287、y 205~340 / 1705 */
  left: 53.6%;
  top: 11.9%;
  width: 9.4%;
  height: 8%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  color: var(--green);
  font-family: "Chalkboard SE", "Comic Sans MS", "Marker Felt", var(--font);
}
@keyframes dropIn {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.btn-pk {
  left: 50%;
  bottom: 74px;
  width: 262px;
  margin-left: -131px;
}

/* ---------- 4. 丟雪球 ---------- */
.targets {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.target {
  position: absolute;
  transform-origin: 50% 100%;
  animation: idle 2.2s ease-in-out infinite;
}
.target img { width: 100%; height: 100%; }
.target.is-hit { animation: wobble .6s ease both; }
@keyframes idle {
  0%, 100% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(-4px) scaleX(1.02); }
}
@keyframes wobble {
  0% { transform: rotate(0); }
  20% { transform: rotate(-14deg) translateY(-6px); }
  45% { transform: rotate(12deg); }
  70% { transform: rotate(-6deg); }
  100% { transform: rotate(0); }
}

.hit-fx {
  position: absolute;
  width: 110px;
  height: 66px;
  margin: -33px 0 0 -55px;
  z-index: 6;
  animation: fx .7s ease-out both;
  pointer-events: none;
}
.hit-fx img { width: 100%; height: 100%; }
@keyframes fx {
  0% { transform: scale(.3); opacity: 0; }
  30% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.aim {
  position: absolute;
  left: 50%;
  top: 405px;
  width: 332px;
  height: 78px;
  margin-left: -166px;
  z-index: 3;
  pointer-events: none;
}
.aim__bar { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.aim__arrow {
  position: absolute;
  left: 0;
  top: -104px;
  width: 58px;
  height: 94px;
  margin-left: -29px;
  will-change: transform;
}

.thrower {
  position: absolute;
  left: 50%;
  bottom: -30px;
  width: 200px;
  height: 180px;
  margin-left: -100px;
  z-index: 4;
}
.thrower__hand {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 140px;
}
.thrower__ball {
  position: absolute;
  left: 78px;
  bottom: 82px;
  width: 110px;
  height: 110px;
  transform-origin: 50% 80%;
  transform: scale(var(--ball, .7));
  transition: transform .3s ease;
  animation: glow 1.6s ease-in-out infinite;
}
.thrower__ball.is-hidden { visibility: hidden; }
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 230, 120, .55)); }
  50% { filter: drop-shadow(0 0 16px rgba(255, 230, 120, .95)); }
}

.ball-fly {
  position: absolute;
  left: 0;
  top: 0;
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  z-index: 5;
  pointer-events: none;
  will-change: transform;
}
.ball-fly img { width: 100%; height: 100%; }
.ball-ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .28);
  z-index: 4;
  pointer-events: none;
  animation: ghost .5s ease-out forwards;
}
@keyframes ghost {
  from { opacity: .9; }
  to { opacity: 0; }
}

.toast {
  position: absolute;
  left: 50%;
  top: 372px;
  transform: translateX(-50%);
  padding: 7px 16px;
  background: rgba(43, 84, 70, .88);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  z-index: 7;
  white-space: nowrap;
  animation: toastIn .25s ease both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 60, 50, .45);
  backdrop-filter: blur(2px);
}
.overlay__card {
  width: 270px;
  padding: 26px 20px 22px;
  background: #fff;
  border-radius: 18px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
  animation: dropIn .4s cubic-bezier(.2, 1.4, .4, 1) both;
}
.overlay__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 900;
  color: var(--green-dark);
}
.overlay__desc {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.6;
  color: #55706a;
}
.overlay__btn {
  position: relative;
  width: 150px;
  margin: 0 auto;
}

/* ---------- 5. 結果 ---------- */
.result-btns {
  position: absolute;
  left: 0;
  right: 0;
  top: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 3;
}
.result-btn { position: relative; }
.result-btn--claim { width: 224px; animation: dropIn .45s .1s cubic-bezier(.2, 1.4, .4, 1) both; }
.result-btn--share { width: 224px; animation: dropIn .45s .2s cubic-bezier(.2, 1.4, .4, 1) both; }
.result-btns__row {
  display: flex;
  gap: 10px;
  margin-top: 2px;
  animation: dropIn .45s .3s cubic-bezier(.2, 1.4, .4, 1) both;
}
.result-btn--replay, .result-btn--open { width: 130px; }
