/* ========================= Font ========================= */
@font-face {
  font-family: 'SparrowBrushNumbers';
  src: url('../assets/shared/fonts/SparrowBrushNumbers-Regular.woff2?v=20260805v5') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* ========================= Global / Reset ========================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
  color: #f8e1b8;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

@media (min-width: 1200px) {
  body {
    background: #000 url("../assets/desktop/backgrounds/bg_desktop.png") no-repeat center center fixed;
    background-size: cover;
  }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* ========================= Loading Page ========================= */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000 url("../assets/shared/backgrounds/loadingPage.png") no-repeat center center;
  background-size: contain;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease;
}

/* 進入按鈕 */
.enter-btn-wrapper {
  position: absolute;
  top: 54%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 10;
  padding: 30px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.enter-btn {
  width: 200px;
  height: auto;
  display: block;
  pointer-events: none; /* 讓點擊事件穿透到 wrapper */
  filter: drop-shadow(0 0 15px rgba(255, 140, 0, 0.8)) drop-shadow(0 0 30px rgba(255, 100, 0, 0.5));
  animation: enterBtnBreathing 2s ease-in-out infinite;
}

.enter-btn-wrapper:active .enter-btn {
  transform: scale(0.95);
}

@keyframes enterBtnBreathing {
  0%, 100% {
    filter: drop-shadow(0 0 15px rgba(255, 140, 0, 0.6)) drop-shadow(0 0 30px rgba(255, 100, 0, 0.3));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 25px rgba(255, 140, 0, 1)) drop-shadow(0 0 50px rgba(255, 100, 0, 0.7));
    transform: scale(1.05);
  }
}

/* 載入區域（文字圖 + 進度條） */
.loading-bar-area {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.loading-text-img {
  width: 180px;
  height: auto;
  display: block;
}

.loading-bar-container {
  width: 220px;
  height: 26px;
  background: rgba(0, 0, 0, 0.6);
  border: 6px solid #ff8c00;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px rgba(80, 30, 0, 0.9),
    0 0 0 6px rgba(255, 140, 0, 0.5),
    0 0 20px rgba(255, 140, 0, 0.6),
    inset 0 1px 3px rgba(0, 0, 0, 0.5);
  animation: barBreathing 2.5s ease-in-out infinite;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffcc00, #ff4500);
  box-shadow: 0 0 10px #ff4500;
  transition: width 0.3s ease-out;
}

.loading-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #ffe5a4;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.85);
}

.loading-error[hidden] {
  display: none;
}

.loading-retry-btn {
  min-width: 112px;
  min-height: 38px;
  padding: 6px 18px;
  border: 2px solid #d99a32;
  border-radius: 6px;
  background: #641a12;
  color: #fff1bd;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
}

.loading-retry-btn:active {
  transform: translateY(1px);
}

@keyframes barBreathing {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 140, 0, 0.4);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 25px rgba(255, 140, 0, 0.9);
    transform: scale(1.02);
  }
}

/* ========================= Layout / Scale Wrapper ========================= */
#game-scale-wrapper {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100dvh);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
}

#game-root {
  width: 1080px;
  height: 1920px;
  transform-origin: 50% 100%;
}

.game-wrapper {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top, #7b1b10 0%, #3a0904 40%, #120408 100%);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr 59px 652px auto;
  position: relative;
}

:root {
  --hf-overlap: 28px;
}

/* ========================= Header ========================= */
.header-area {
  position: relative;
  z-index: 10;
  margin-bottom: calc(-1 * var(--hf-overlap));
  padding-bottom: var(--hf-overlap);
  background: url("../assets/shared/backgrounds/header_new260622.png?v=20260803header1280") no-repeat center bottom;
  background-size: 100% auto;
  background-color: #5a130c;
}

.random-wild-intro {
  position: absolute;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  background: #5a130c;
  transition: opacity 160ms ease-out, visibility 0s linear 160ms;
}

.random-wild-intro.is-active {
  visibility: visible;
  opacity: 1;
  transition: opacity 160ms ease-in;
}

.random-wild-intro video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.header-idle-sparrow {
  --header-sparrow-facing: 1;
  position: absolute;
  z-index: 20;
  pointer-events: none;
  contain: layout paint style;
  transform: translate3d(0, 0, 0) scaleX(var(--header-sparrow-facing));
}

.header-idle-sparrow img {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform: translate3d(0, 0, 0);
}

.header-idle-sparrow--flying {
  --header-sparrow-facing: -1;
  left: var(--header-flying-left, 1.1%);
  top: var(--header-flying-top, 1.95%);
  width: var(--header-flying-width, 13.7%);
  aspect-ratio: 554 / 537;
}

.header-idle-sparrow__flying-left-wing {
  left: 4.8736%;
  top: 7.8212%;
  width: 45.8484%;
  height: 49.3482%;
  transform-origin: 82.28% 72.45%;
  will-change: transform;
  animation: headerFlyingLeftWing 1.9s ease-in-out infinite;
}

.header-idle-sparrow__flying-right-wing {
  left: 46.2094%;
  top: 7.635%;
  width: 48.0144%;
  height: 55.8659%;
  transform-origin: 10.9% 65.67%;
  will-change: transform;
  animation: headerFlyingRightWing 1.9s ease-in-out infinite;
}

.header-idle-sparrow__flying-body {
  left: 16.426%;
  top: 32.216%;
  width: 75.9928%;
  height: 57.3557%;
  transform-origin: 46.08% 46.43%;
  animation: headerFlyingBody 3.8s ease-in-out infinite;
}

.header-idle-sparrow--perched {
  left: var(--header-perched-left, 86.85%);
  top: var(--header-perched-top, 22.4%);
  width: var(--header-perched-width, 10.9%);
  aspect-ratio: 487 / 527;
}

.header-idle-sparrow__perched-body {
  left: 9.4456%;
  top: 11.1954%;
  width: 90.5544%;
  height: 75.5218%;
}

.header-idle-sparrow__perched-left-wing {
  left: 34.7023%;
  top: 21.0626%;
  width: 54.8255%;
  height: 44.4023%;
  transform-origin: 13.48% 31.62%;
  will-change: transform;
  animation: headerPerchedWingTwitch 3s ease-in-out infinite;
}

.header-area.freespin-normal .header-idle-sparrow,
.header-area.freespin-golden .header-idle-sparrow {
  display: none;
}

@keyframes headerFlyingLeftWing {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(-3deg);
  }

  50% {
    transform: translate3d(0, -3.2%, 0) rotate(13.5deg);
  }
}

@keyframes headerFlyingRightWing {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(3deg);
  }

  50% {
    transform: translate3d(0, -3.2%, 0) rotate(-13.5deg);
  }
}

@keyframes headerFlyingBody {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  50% {
    transform: translate3d(0, 1.2%, 0) rotate(-0.6deg);
  }
}

@keyframes headerPerchedWingTwitch {
  0%, 48%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  55% {
    transform: translate3d(0.6%, -1.2%, 0) rotate(-6deg);
  }

  61% {
    transform: translate3d(-0.6%, 0.9%, 0) rotate(8deg);
  }

  67% {
    transform: translate3d(0.4%, -0.7%, 0) rotate(-5deg);
  }

  73% {
    transform: translate3d(0, 0.4%, 0) rotate(2.6deg);
  }

  80% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
}

.bigwin-layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
}

.bigwin-layer img {
  max-width: none;
  margin-top: 20%;
  object-fit: contain;
  display: block;
}

.bigwin-layer.win-big img {
  width: 1280px;
}

.bigwin-layer.win-epic img {
  width: 1680px;
}

.bigwin-layer.win-super img {
  width: 2160px;
}

/* Pixi Super／Epic Win 的舞台就是各自 webp 的 448x252 構圖，所以畫布必須佔用和
   .bigwin-layer img 完全一樣的版面：寬度撐滿版面（img 是 flex item，2160px 會被壓成
   100%），上緣 = 設計稿寬 1080 的 20%，換算成高 1920 即 11.25%。 */
.bigwin-pixi-canvas {
  position: absolute;
  left: 0;
  top: 11.25%;
  width: 100%;
  height: auto;
  max-width: none;
  display: none;
  pointer-events: none;
}

.bigwin-layer.pixi-super-active #bigWinImg,
.bigwin-layer.pixi-epic-active #bigWinImg,
.bigwin-layer.pixi-big-active #bigWinImg {
  display: none;
}

.bigwin-layer.pixi-super-active #superWinPixiCanvas,
.bigwin-layer.pixi-epic-active #epicWinPixiCanvas,
.bigwin-layer.pixi-big-active #bigWinPixiCanvas {
  display: block;
}

.bigwin-layer.active {
  opacity: 1;
  animation: bigWinFadeIn 0.4s ease-out forwards;
}

@keyframes bigWinFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.bigwin-countup {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translateX(-50%);
  font-family: 'SparrowBrushNumbers', system-ui, sans-serif;
  font-size: 72px;
  font-weight: 400;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 20px rgba(255, 200, 0, 0.8),
    0 0 40px rgba(255, 150, 0, 0.6),
    0 4px 12px rgba(0, 0, 0, 0.9);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 10000;
}

.bigwin-countup.active {
  opacity: 1;
}

.bigwin-countup.fade-out {
  transition: opacity 0.5s ease-out;
  opacity: 0;
}

.particles-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
}

.particles-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.particles-layer.active {
  animation: particlesFade ease-in-out forwards;
}

.particles-layer.sparrow-playing img {
  transform: scale(0.36) translateY(-6%);
  transform-origin: center bottom;
}

.particles-layer.sparrow-playing2 img {
  transform: scale(0.50) translate(65%, -8.5%);
  transform-origin: center bottom;
}

.particles-layer.coins-bursting img {
  transform: scale(0.80) translateY(7.5%);
  transform-origin: center center;
}

@keyframes particlesFade {
  0% {
    opacity: 0;
  }

  20%,
  80% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* ========================= Upper Frame Row ========================= */
.upper-frame-row {
  position: relative;
  z-index: 20;
  width: 100%;
  height: 59px;
  background: url("../assets/shared/frames/upper_frame.png") no-repeat center center;
  background-size: 100% 100%;
  pointer-events: none;
}

/* ========================= Reels ========================= */
.reel-area {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: block;
}

.reel-bg {
  width: 100%;
  height: 100%;
  position: relative;
  background: url("../assets/shared/backgrounds/reel_bg.png") no-repeat center;
  background-size: 100% 100%;
}

.reel-frame {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.pixi-reel-canvas {
  position: absolute;
  z-index: 2;
  display: block;
  pointer-events: none;
  touch-action: none;
}

.reel-grid {
  --gap: 4px;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, auto);
  column-gap: var(--gap);
  row-gap: var(--gap);
  place-content: center;
  position: relative;
  z-index: 4;
}

.symbol-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border-radius: 0;
  border-left: 1px solid rgba(255, 220, 160, 0.35);
  border-right: 1px solid rgba(255, 220, 160, 0.35);
  overflow: visible;
}

.symbol-cell img,
.symbol-cell canvas.s0-winning-frame {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 50% 50%;
  display: block;
}

.pixi-reels-active .symbol-cell > img {
  visibility: hidden;
}

.pixi-reels-active .symbol-cell.s0-winning > img,
.pixi-reels-active .symbol-cell.s0-winning > canvas.s0-winning-frame {
  visibility: visible;
  position: absolute;
  z-index: 6;
}

.symbol-cell.reel-base-spinning > img {
  visibility: hidden;
}

.reel-spin-layer {
  position: absolute;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: 1fr;
  column-gap: var(--reel-column-gap, 4px);
  pointer-events: none;
  overflow: hidden;
  contain: layout paint style;
}

.reel-strip-viewport {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: visible;
}

.reel-strip-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--reel-row-gap, 4px);
  will-change: transform;
  backface-visibility: hidden;
}

.reel-strip-symbol {
  position: relative;
  flex: 0 0 var(--reel-cell-height);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.reel-strip-symbol img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
}

.reel-strip-symbol.symbol-sc {
  z-index: 3;
}

.reel-strip-symbol.symbol-sc img {
  position: absolute;
  left: -7.5%;
  top: -7.5%;
  width: 115%;
  height: 115%;
  max-width: none;
  max-height: none;
}

.symbol-cell.symbol-sc {
  z-index: 3;
}

.symbol-cell.symbol-sc img {
  position: absolute;
  left: -7.5%;
  top: -7.5%;
  width: 115%;
  height: 115%;
  max-width: none;
  max-height: none;
}

.symbol-cell.symbol-sc.sc-trigger-glow::after {
  content: "";
  position: absolute;
  inset: auto;
  left: -7.5%;
  top: -7.5%;
  width: 115%;
  height: 115%;
  z-index: 5;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  box-sizing: border-box;
  pointer-events: none;
  background: url("../assets/shared/frames/scGoldFrame115.png?v=20260807scframefix1") no-repeat center / 100% 100%;
  transform-origin: 50% 50%;
  will-change: transform, opacity, filter;
  animation:
    scTriggerShake 0.12s ease-in-out infinite,
    scFrameTriggerGlow 0.64s ease-in-out infinite;
}

@keyframes scFrameTriggerGlow {
  0%, 100% {
    opacity: 0.28;
    filter:
      brightness(1.25) saturate(1.06)
      drop-shadow(0 0 3px rgba(255, 255, 220, 0.86))
      drop-shadow(0 0 8px rgba(255, 207, 55, 0.72));
  }
  50% {
    opacity: 0.96;
    filter:
      brightness(1.72) saturate(1.12)
      drop-shadow(0 0 5px rgba(255, 255, 235, 1))
      drop-shadow(0 0 13px rgba(255, 215, 74, 0.96))
      drop-shadow(0 0 24px rgba(255, 145, 22, 0.72));
  }
}

.symbol-cell.symbol-big img {
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
  z-index: 2;
}

.sc-respin-layer,
.random-wild-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

.sc-respin-layer {
  z-index: 84;
  overflow: visible;
}

.sc-respin-column-beam {
  position: absolute;
  z-index: 1;
  left: var(--sc-respin-column-left);
  top: var(--sc-respin-reel-top);
  width: var(--sc-respin-column-width);
  height: var(--sc-respin-reel-height);
  opacity: 0.3;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 238, 145, 0.28) 28%,
    rgba(255, 252, 218, 0.58) 50%,
    rgba(255, 238, 145, 0.28) 72%,
    transparent
  );
  mix-blend-mode: screen;
  animation: scRespinColumnBeamPulse 0.75s ease-in-out infinite;
}

.sc-respin-flash {
  position: absolute;
  z-index: 3;
  left: var(--sc-respin-x);
  top: var(--sc-respin-start-y);
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.2);
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 1) 0 5%,
    rgba(255, 243, 186, 0.9) 14%,
    rgba(255, 190, 47, 0.32) 42%,
    transparent 70%
  );
  mix-blend-mode: screen;
}

.sc-respin-flash.active {
  animation: scRespinFlashBurst 400ms linear forwards;
}

.random-wild-layer {
  z-index: 85;
  overflow: visible;
}

.sc-respin-layer.active,
.random-wild-layer.active {
  visibility: visible;
}

.sc-respin-sparrow {
  position: absolute;
  z-index: 2;
  left: var(--sc-respin-x);
  top: var(--sc-respin-start-y);
  width: 87.5%;
  height: auto;
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.88);
  transform-origin: 50% 50%;
  animation: scRespinBirdGlow 0.8s ease-in-out infinite;
  will-change: top, opacity, transform, filter;
}

.sc-respin-sparrow.diving {
  animation:
    scRespinDive var(--sc-respin-dive-duration) linear forwards,
    scRespinBirdGlow 0.8s ease-in-out infinite;
}

@keyframes scRespinBirdGlow {
  0%, 100% {
    filter:
      brightness(1.22) saturate(1.12)
      drop-shadow(0 0 7px rgba(255, 255, 225, 1))
      drop-shadow(0 0 20px rgba(255, 210, 76, 0.98))
      drop-shadow(0 0 42px rgba(255, 139, 24, 0.72));
  }
  50% {
    filter:
      brightness(1.48) saturate(1.2)
      drop-shadow(0 0 11px rgba(255, 255, 240, 1))
      drop-shadow(0 0 30px rgba(255, 224, 112, 1))
      drop-shadow(0 0 62px rgba(255, 145, 20, 0.9));
  }
}

@keyframes scRespinColumnBeamPulse {
  0%, 100% {
    opacity: 0.28;
    filter: brightness(1);
  }
  50% {
    opacity: 0.88;
    filter: brightness(1.55);
  }
}

@keyframes scRespinFlashBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.55);
  }
  55% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.9);
  }
}

@keyframes scRespinDive {
  0% {
    top: var(--sc-respin-start-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.88);
  }
  86% {
    top: var(--sc-respin-end-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62);
  }
  100% {
    top: var(--sc-respin-exit-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.52);
  }
}

.random-wild-sparrow {
  position: absolute;
  left: var(--random-wild-start-x);
  top: var(--random-wild-start-y);
  width: 55%;
  height: auto;
  opacity: 0;
  transform: translate3d(0, 0, 0) translate(-50%, -50%) scale(0.9);
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  animation: randomWildFlyIn var(--random-wild-duration) linear forwards;
  animation-delay: var(--random-wild-delay);
  will-change: transform, opacity;
}

@keyframes randomWildFlyIn {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) translate(-50%, -50%) scale(0.9);
  }
  82% {
    opacity: 1;
    transform: translate3d(var(--random-wild-travel-x), var(--random-wild-travel-y), 0) translate(-50%, -50%) scale(0.8);
  }
  92% {
    opacity: 1;
    transform: translate3d(var(--random-wild-travel-x), var(--random-wild-travel-y), 0) translate(-50%, -50%) scale(0.65);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--random-wild-travel-x), var(--random-wild-travel-y), 0) translate(-50%, -50%) scale(0.3);
  }
}

.symbol-cell.random-wild-reveal img {
  animation: randomWildReveal 0.42s cubic-bezier(0.16, 0.92, 0.28, 1.35);
}

@keyframes randomWildReveal {
  0% {
    opacity: 0;
    transform: scale(0.2);
    filter: brightness(2.4) drop-shadow(0 0 24px rgba(255, 219, 88, 1));
  }
  65% {
    opacity: 1;
    transform: scale(1.16);
    filter: brightness(1.5) drop-shadow(0 0 18px rgba(255, 196, 58, 0.95));
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
  }
}

.symbol-cell.win-highlight::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 0;
  border: 8px solid rgb(250, 250, 170);
  box-sizing: border-box;
  box-shadow: 0 0 14px rgba(255, 255, 235, 1), 0 0 32px rgba(255, 230, 150, 1), 0 0 72px rgba(255, 200, 90, 0.95);
  animation: winFramePulse 0.7s ease-in-out infinite;
}

@keyframes winFramePulse {

  0%,
  100% {
    opacity: 0.80;
    filter: brightness(1.05);
  }

  50% {
    opacity: 1.00;
    filter: brightness(1.45);
  }
}

.symbol-cell img.pulse-win {
  animation: pulseWin 0.55s ease-in-out infinite;
}

@keyframes pulseWin {

  0%,
  100% {
    transform: scale(1.00);
  }

  50% {
    transform: scale(1.15);
  }
}

.symbol-cell img.shake-win {
  animation: shakeWin 0.45s ease-in-out infinite;
}

@keyframes shakeWin {

  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  25% {
    transform: translateX(-3%) rotate(-2deg);
  }

  75% {
    transform: translateX(3%) rotate(2deg);
  }
}

.symbol-cell img.reel-bounce {
  animation: reelBounce 0.28s ease-out;
}

@keyframes reelBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(8%);
  }

  60% {
    transform: translateY(-4%);
  }
}

.symbol-cell.s0-winning {
  overflow: visible;
}

.symbol-cell.s0-winning img,
.symbol-cell.s0-winning canvas.s0-winning-frame {
  width: auto;
  height: 93%;
  aspect-ratio: 1 / 1;
}

/* SC 觸發狂震 */
.symbol-cell img.sc-trigger-shake {
  animation: scTriggerShake 0.12s ease-in-out infinite;
}

@keyframes scTriggerShake {
  0%, 100% { transform: translateX(0) rotate(0deg) scale(1.05); }
  25% { transform: translateX(-4%) rotate(-3deg) scale(1.1); }
  75% { transform: translateX(4%) rotate(3deg) scale(1.1); }
}

/* ========================= Gold Particle (SC 金粉飛行) ========================= */
.gold-particle {
  position: fixed;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, #fff 10%, #ffcc00 60%, transparent 100%);
  border-radius: 50%;
  box-shadow: 0 0 2px #ffcc00, 0 0 4px #ffae00;
  z-index: 9999;
  pointer-events: none;
  opacity: 1;
  animation: particleSpin 0.5s linear infinite;
}

@keyframes particleSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.gold-particle.flying {
  transition: all 3.6s cubic-bezier(0.25, 1, 0.5, 1);
  opacity: 0;
}

/* ========================= Anticipation (咪牌) Glow ========================= */
.anticipation-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  border: 8px solid rgb(212, 175, 55);
  border-radius: 0;
  box-shadow: 0 0 14px rgba(255, 255, 235, 1), 0 0 32px rgba(255, 230, 150, 1), 0 0 72px rgba(255, 200, 90, 0.95);
  animation: anticipationPulse 0.7s ease-in-out infinite;
  display: none;
}

.anticipation-overlay.active {
  display: block;
}

.anticipation-overlay.sc-respin-highlight {
  animation: scRespinAnticipationPulse 0.52s ease-in-out infinite;
}

@keyframes anticipationPulse {
  0%, 100% {
    opacity: 0.80;
    filter: brightness(1.05);
  }
  50% {
    opacity: 1.00;
    filter: brightness(1.45);
  }
}

@keyframes scRespinAnticipationPulse {
  0%, 100% {
    opacity: 0.88;
    filter: brightness(1.15);
    box-shadow: 0 0 16px #fffde8, 0 0 42px #ffe58a, 0 0 90px rgba(255, 176, 39, 0.95);
  }
  50% {
    opacity: 1;
    filter: brightness(1.75);
    box-shadow: 0 0 24px #fff, 0 0 58px #ffe272, 0 0 120px rgba(255, 129, 19, 1);
  }
}

/* ========================= Bottom / Info Panel ========================= */
.bottom-area {
  background: linear-gradient(#3a0904, #1a0503);
  display: flex;
  flex-direction: column;
  padding: 0 0 env(safe-area-inset-bottom, 0px) 0;
  position: relative;
  z-index: 10;
}

.info-panel {
  width: 100%;
  height: 250px;
  background: url("../assets/shared/frames/info_box_frame.png") no-repeat center center;
  background-size: 100% 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  padding: 0;
  position: relative;
}

.info-credit,
.info-win {
  position: relative;
  display: block;
}

#balanceValue,
#winValue {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 36%;
  width: 50%;
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  margin: 0;
  line-height: 1;
  white-space: nowrap;
}

.info-bet {
  grid-column: 1 / span 2;
  grid-row: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 0px 22px 0 22px;
  transform: translateY(-4px);
}

.bet-button-2 {
  width: 86px;
  height: 86px;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  background: transparent no-repeat center;
  background-size: contain;
  box-shadow: none;
  transform: translateY(-8px);
}

.bet-button-2.bet-minus {
  background-image: url("../assets/shared/ui/buttons/minusButton.png?v=20260812assets256q1");
}

.bet-button-2.bet-plus {
  background-image: url("../assets/shared/ui/buttons/plusButton.png?v=20260812assets256q1");
}

.bet-button-2:active {
  transform: translateY(-8px) scale(0.96);
}

.bet-display {
  width: 260px;
  background: transparent;
  border: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#betValue {
  display: block;
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  transform: translateY(-6px);
}

/* ========================= Buy Feature Button ========================= */
.buy-feature-wrapper {
  position: absolute;
  right: 2%;
  top: 80%;
  width: 30%;
  overflow: hidden;
  border-radius: 12px;
  cursor: pointer;
  z-index: 100;
  touch-action: manipulation;
}

.buy-feature-wrapper.is-random-wild-intro-hidden {
  display: none;
}

.buy-feature-btn {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.1s ease;
}

.buy-feature-btn:active {
  transform: scale(0.95);
}

.buy-feature-btn:disabled {
  filter: grayscale(0.8);
  opacity: 0.6;
  cursor: not-allowed;
}

.buy-feature-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  left: -150%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0) 70%);
  transition: none;
  pointer-events: none;
  animation: shineLoop 5s infinite;
}

.buy-feature-wrapper.is-unavailable::after {
  display: none;
  animation: none;
}

@keyframes shineLoop {
  0% {
    left: -150%;
  }

  15%,
  100% {
    left: 150%;
  }
}

/* ========================= Modal / Popup Styles ========================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: linear-gradient(180deg, #4a0d08 0%, #2a0503 100%);
  border: 3px solid #f8e1b8;
  border-radius: 20px;
  width: 90%;
  max-width: 800px;
  padding: 40px;
  position: relative;
  text-align: center;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-title {
  color: #f8e1b8;
  font-size: 48px;
  margin-bottom: 30px;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.feature-options {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.feature-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid #9a7a4a;
  border-radius: 15px;
  padding: 20px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.feature-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #f8e1b8;
  transform: translateY(-5px);
}

.feature-name {
  font-size: 32px;
  font-weight: bold;
  margin: 15px 0;
}

.feature-cost {
  color: #ffcc00;
  font-size: 24px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 20px;
  background: none;
  border: none;
  color: #f8e1b8;
  font-size: 50px;
  cursor: pointer;
  touch-action: manipulation;
}

.feature-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  object-fit: contain;
  display: block;
}

/* ========================= Spin / Message ========================= */
.bottom-row-3 {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  padding: 10px 0 30px 0;
  gap: 10px;
}

.action-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 35px;
  width: 100%;
  padding: 0 40px;
}

#infoBtn {
  margin-right: 10px;
}

#menuBtn {
  margin-left: 10px;
}

.side-btn {
  width: 135px;
  height: 135px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.1s ease;
}

.side-btn:active {
  transform: scale(0.92);
}

.spin-image {
  width: 225px;
  height: 225px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  animation: spinIdle 10s linear infinite;
  transform-origin: 50% 50%;
}

.spin-image.spinning {
  animation: none;
}

@keyframes spinIdle {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.message {
  position: static;
  transform: none;
  font-size: 18px;
  opacity: 0.85;
  pointer-events: none;
  text-align: center;
  line-height: 1.2;
  min-height: 22px;
}

/* ========================= Free Spin ========================= */

/* FG 倍數藝術字 */
.fg-multiplier {
  --fg-multiplier-font-size: 140px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
}

.fg-multiplier[data-size-step="1"] {
  --fg-multiplier-font-size: 155px;
}

.fg-multiplier[data-size-step="2"] {
  --fg-multiplier-font-size: 170px;
}

.fg-multiplier[data-size-step="3"] {
  --fg-multiplier-font-size: 185px;
}

.fg-multiplier[data-size-step="4"] {
  --fg-multiplier-font-size: 200px;
}

.fg-multiplier-text {
  display: block;
  font-family: 'SparrowBrushNumbers', system-ui, sans-serif;
  font-size: var(--fg-multiplier-font-size);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.1em;
  font-variant-numeric: tabular-nums;
}

.fg-multiplier.fg-normal .fg-multiplier-text {
  color: #e62817;
  text-shadow:
    0 2px 0 #790900,
    0 0 14px rgba(255, 74, 20, 0.62),
    0 6px 14px rgba(0, 0, 0, 0.78);
}

.fg-multiplier.fg-golden .fg-multiplier-text {
  color: #6f400c;
  text-shadow:
    0 2px 0 #301803,
    0 0 9px rgba(181, 105, 21, 0.38),
    0 6px 14px rgba(0, 0, 0, 0.86);
}

/* 脈衝 + 殘影出現 */
.fg-multiplier.entering {
  animation: multiEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes multiEnter {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.5);
    filter: brightness(3) blur(8px);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
    filter: brightness(1.5) blur(2px);
  }
  60% {
    transform: translate(-50%, -50%) scale(1.08);
    filter: brightness(1.2) blur(0);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1) blur(0);
  }
}

/* 停留時脈衝呼吸 */
.fg-multiplier.idle {
  animation: multiIdle 2s ease-in-out infinite;
}

@keyframes multiIdle {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    filter: brightness(1.2);
  }
}

/* 淡出 */
.fg-multiplier.exiting {
  animation: multiExit 0.4s ease-in forwards;
}

@keyframes multiExit {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    filter: blur(4px);
  }
}

/* Header 切換 */
.header-area.freespin-normal {
  background-image: url("../assets/shared/backgrounds/fgHeader.png");
}

.header-area.freespin-golden {
  background-image: url("../assets/shared/backgrounds/fgHeaderGold.png");
}

/* Spin Counter (reel 區域上方) */
.free-spin-counter {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: none;
  border: none;
  border-radius: 0;
  padding: 6px 32px;
  text-align: center;
}

.free-spin-text {
  font-family: 'SparrowBrushNumbers', system-ui, sans-serif;
  font-size: 48px;
  font-weight: 400;
  line-height: 1;
  color: #ffcc00;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  letter-spacing: 0;
  white-space: nowrap;
}

.free-spin-text span {
  display: inline-block;
}

.free-spin-separator {
  font-family: inherit;
  font-size: 1em;
  line-height: 1;
  letter-spacing: 0;
  margin: 0;
}

/* 一般版 FG：金色字 */
.free-spin-counter.fg-normal .free-spin-text {
  color: #ffcc00;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* 黃金版 FG：黑色字 */
.free-spin-counter.fg-golden .free-spin-text {
  color: #1a1a1a;
  text-shadow: 0 1px 4px rgba(255,200,0,0.3);
}

/* 過場動畫層 */
.freespin-transition {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--fg-transition-fade-out-ms, 550ms) ease-in-out;
}

.freespin-transition.is-visible {
  opacity: 1;
  transition-duration: var(--fg-transition-fade-in-ms, 550ms);
}

.freespin-transition img,
.freespin-transition video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.freespin-transition video {
  display: block;
}

/* 總贏分結算畫面 */
.freespin-summary {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 0;
}

.freespin-summary-card {
  position: fixed;
  top: 0;
  left: 50%;
  width: min(100vw, calc(100vh * 1393 / 2475));
  height: 100vh;
  opacity: 0;
  transform: translateX(-50%) scale(0.86);
  filter: brightness(1.5) blur(8px);
  overflow: hidden;
}

.freespin-summary.is-image-in .freespin-summary-card {
  animation: fgSummaryImageImpact 640ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@supports (height: 100dvh) {
  .freespin-summary-card {
    width: min(100vw, calc(100dvh * 1393 / 2475));
    height: 100dvh;
  }
}

.freespin-summary-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.freespin-summary-amount {
  position: absolute;
  left: 50%;
  top: var(--fg-summary-amount-top, 53%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.62);
  width: 68%;
  font-family: 'SparrowBrushNumbers', system-ui, sans-serif;
  font-size: clamp(42px, min(10vw, 7vh), 88px);
  font-weight: 400;
  line-height: 1;
  color: #ffd35a;
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 2px 0 rgba(80, 28, 0, 0.95),
    0 0 16px rgba(255, 211, 89, 0.75),
    0 5px 14px rgba(0, 0, 0, 0.9);
  filter: blur(4px);
}

.freespin-summary.is-amount-in .freespin-summary-amount {
  animation: fgSummaryAmountImpact 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.freespin-summary.is-amount-idle .freespin-summary-amount {
  opacity: 1;
  filter: none;
  animation: summaryPulse 1.5s ease-in-out infinite;
}

@keyframes fgSummaryImageImpact {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.78);
    filter: brightness(1.8) blur(10px);
  }
  48% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
    filter: brightness(1.28) blur(0);
  }
  68% {
    transform: translateX(-50%) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    filter: brightness(1) blur(0);
  }
}

@keyframes fgSummaryAmountImpact {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
    filter: blur(8px);
  }
  45% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.18);
    filter: blur(0);
  }
  68% {
    transform: translate(-50%, -50%) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: none;
  }
}

@keyframes summaryPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Retrigger 提示 */
.retrigger-banner {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  font-size: 56px;
  font-weight: 900;
  color: #ffcc00;
  text-shadow: 0 0 20px rgba(255, 200, 0, 0.8), 0 4px 12px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  animation: retriggerPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes retriggerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ========================= Tablet ========================= */
@media (min-width: 769px) and (max-width: 1199px) {
  body {
    background: #000;
    overflow: hidden;
  }

  #game-scale-wrapper {
    width: 100vw;
    height: 100vh;
    height: var(--app-height, 100dvh);
    background: none;
    overflow: hidden;
    padding: 0;
    margin: 0;
  }

  #game-root {
    position: absolute;
    left: 50%;
    bottom: 0;
    top: auto;
    transform-origin: 50% 100%;
  }

  /* Modal tablet */
  .modal-content {
    width: 80%;
    max-width: 600px;
    padding: 32px 24px;
  }

  .modal-title {
    font-size: 36px;
    margin-bottom: 24px;
  }

  .feature-icon {
    width: 90px;
    height: 90px;
  }

  .feature-name {
    font-size: 26px;
  }

  .feature-cost {
    font-size: 20px;
  }
}

/* ========================= Mobile ========================= */
@media (max-width: 768px) {
  .loading-overlay {
    background-size: cover;
  }

  body {
    background: #000;
    overflow: hidden;
  }

  #game-scale-wrapper {
    width: 100vw;
    height: 100vh;
    height: var(--app-height, 100dvh);
    background: none;
    overflow: hidden;
    padding: 0;
    margin: 0;
  }

  #game-root {
    position: absolute;
    left: 50%;
    bottom: 0;
    top: auto;
    transform-origin: 50% 100%;
  }

  /* Modal responsive */
  .modal-content {
    width: 92%;
    max-width: 400px;
    padding: 24px 16px;
  }

  .modal-title {
    font-size: 28px;
    margin-bottom: 18px;
  }

  .feature-options {
    gap: 12px;
  }

  .feature-card {
    padding: 14px 10px;
  }

  .feature-icon {
    width: 70px;
    height: 70px;
  }

  .feature-name {
    font-size: 20px;
    margin: 10px 0;
  }

  .feature-cost {
    font-size: 16px;
  }

  .modal-close {
    font-size: 36px;
    top: 6px;
    right: 14px;
  }

  /* FG mobile fixes */
  .fg-multiplier {
    --fg-multiplier-font-size: 92px;
  }

  .fg-multiplier[data-size-step="1"] {
    --fg-multiplier-font-size: 102px;
  }

  .fg-multiplier[data-size-step="2"] {
    --fg-multiplier-font-size: 112px;
  }

  .fg-multiplier[data-size-step="3"] {
    --fg-multiplier-font-size: 122px;
  }

  .fg-multiplier[data-size-step="4"] {
    --fg-multiplier-font-size: 132px;
  }

  .freespin-summary {
    --fg-summary-amount-top: 52%;
  }

  .freespin-summary-amount {
    font-size: clamp(38px, 10vw, 64px);
  }

  .retrigger-banner {
    font-size: 40px;
  }

  .bigwin-countup {
    font-size: 48px;
  }
}
