/* ══════════════════════════════════════════
   Frut Pop! — Main Stylesheet
   /css/style.css
   ══════════════════════════════════════════ */

:root {
  --bg: #c8b8e8;
  --panel-bg: #ffffff;
  --text-dark: #3a3650;
  --text-muted: #9888b8;
  --accent: #ff8da1;
  --shadow: 0 4px 16px rgba(120,90,180,0.10);
  --card-radius: 18px;
  --gap: 10px;
  /* Game canvas dimensions */
  --game-w: 380px;
  --game-h: 560px;
  /* Popup zones — ใช้ร่วมกันทุก Panel/Popup */
  --popup-top:      96px;
  --popup-content: 400px;  /* 560 - 96 - 64 = 400 */
  --popup-footer:   64px;
  /* Popup border — admin-editable via popupBorderCfg */
  --popup-border-color: #ffb3c6;
  --popup-border-width: 3px;
  /* Popup body background — set dynamically from theme popbg.jpg */
  --popup-body-bg: none;
}
* { margin:0; padding:0; box-sizing:border-box; font-family:'Itim','Noto Sans Thai','Sarabun','Prompt',Tahoma,-apple-system,sans-serif; }

/* ── Global font minimum 14px สำหรับ visible text ── */
.hud-text, .pill-chip, .status-item span,
#hudTimer, #ui-fruitpoint, #ui-coin, #ui-diamond, #ui-shake, #ui-hammer,
.diff-version, .pp-stat-row, .popup-title, .popup-body,
.bottom-close-btn, .btn, .btn-primary {
  font-size: max(14px, 1em);
}
#gameCanvas { cursor: crosshair; }

html {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
}

body {
  background-color: #c8e8f8;
  background-image: repeating-linear-gradient(
    -45deg,
    #ffffff 0px,
    #ffffff 20px,
    #b0d8f0 20px,
    #b0d8f0 40px
  );
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  padding-top: 0;
}

.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  display:block; touch-action:none;
  border-radius: 22px;
  box-shadow: 0 4px 18px rgba(120,90,180,0.12);
  border: 2px solid #c0d8f0;
  background: #e8e0f5;
  flex-shrink: 0;
}

#fxLayer {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  display: none;
}

#gameWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--gap);
  padding: 8px;
  width: 100%;
  max-width: 396px;
  margin: 0 auto;
}

#topBar {
  display: flex;
  gap: 6px;
  width: 380px;
  max-width: 100%;
  align-items: stretch;
  flex-shrink: 0;
}
#topBar .card, #settingBtn {
  flex: 1;
  min-width: 0;
  max-width: calc(25% - 5px);
  padding: 0;
  aspect-ratio: 1/1;
  box-sizing: border-box;
  overflow: hidden;
}
#scoreBox  { padding: 4px; }
#levelBox  { padding: 4px; }
#nextBox   { padding: 0; }
#settingBtn {
  border: 0px solid #f9c8d8;
  background: none;
  cursor: pointer;
  padding: 0;
  border-radius: var(--card-radius);
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
}
#settingBtn img {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 120%; height: 120%;
  object-fit: cover;
}
#nextBox img { display:block; width:100%; height:100%; object-fit:cover; }
#settingBtn.active { background: none; }

#scoreBox {
  flex: 2; border: 2px solid #f9c8d8;
  padding: 10px 14px; text-align: center; min-width: 0;
}
.score-label {
  font-size: 10px; font-weight: 700; color: #a898c8;
  letter-spacing: 2px; text-transform: uppercase; line-height: 1;
}
#scoreVal {
  font-size: clamp(16px, 7vw, 32px);
  font-weight: 800; color: #FFD250;
  letter-spacing: 2px; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s;
  white-space: nowrap; overflow: hidden;
  width: 100%; text-align: center;
}
#topScore {
  font-size: clamp(10px, 2.2vw, 13px);
  color: #a898c8; font-weight: 700; margin-top: 2px;
}

#levelBox {
  flex: 1.1; border: 2px solid #f9c8d8;
  padding: 8px 6px; text-align: center; min-width: 0;
}
.lv-label {
  font-size: 10px; font-weight: 700; color: #a898c8;
  letter-spacing: 2px; text-transform: uppercase; line-height: 1;
}
#levelNum {
  font-size: clamp(16px, 7vw, 32px);
  font-weight: 800; color: #90CF5F; line-height: 1;
  transition: transform 0.2s, color 0.2s;
}
#levelNextInfo {
  font-size: clamp(9px, 1.8vw, 11px);
  color: #b8a8d0; font-weight: 500; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#nextBox {
  flex: 1; aspect-ratio: 1/1;
  border: 2px solid #f9c8d8; padding: 4px; min-width: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#nextBox .lv-label {
  font-size: 9px; font-weight: 700; color: #a898c8;
  letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 2px;
  line-height: 1.2; flex-shrink: 0;
}
#nextCanvas {
  display: block;
  width: 85% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  flex-shrink: 0;
  animation: nextFruitBounce 1.6s ease-in-out infinite alternate both;
}

@keyframes nextFruitBounce {
  0%   { transform: translateY(0)    scale(1);    }
  100% { transform: translateY(-6px) scale(1.04); }
}

/* -------------------------------------
   ADS SLIDER CSS WITH INDICATORS
   ------------------------------------- */
.ad-slider-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--card-radius) !important;
  border: 2px solid #f9c8d8;
  background: #fff;
  flex-shrink: 0;
  display: block;
}
.ad-slider-wrap.ratio-16-9 { aspect-ratio: 16 / 9; }
.ad-slider-wrap.ratio-9-16 { aspect-ratio: 9 / 16; }

.ad-slides {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}
.ad-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ad-arrow {
  position: absolute;
  grid-area: 1 / 1;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.75);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: #3a3650;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 10;
}
.ad-arrow:hover { background: #fff; }
.ad-arrow.left { left: 4px; }
.ad-arrow.right { right: 4px; }

/* Navigation Indicator Dots */
.ad-dots {
  position: absolute;
  grid-area: 1 / 1;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}
.ad-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}
.ad-dot.active {
  background: #ff8da1;
  width: 10px;
  height: 10px;
}

/* -------------------------------------
   LAYOUT CSS OVERRIDES
   ------------------------------------- */
#hudRow, .hud-spacer {
  width: 380px; max-width: 100%;
  display: flex; align-items: center;
  gap: 3px; padding: 2px 4px;
  box-sizing: border-box; flex-shrink: 0;
  min-height: 32px;
}
@media (orientation: landscape) {
  #hudRow { width: 100%; max-width: 380px; }
}
.hud-spacer {
  width: 100% !important;
  visibility: hidden; /* เอาแค่ความสูง ไม่แสดง content */
}

@media (orientation: landscape) {
  body {
    align-items: center;
    justify-content: center;
    padding: 0;
    height: 100vh;
  }
  #gameWrap {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    width: auto;
    max-width: 98vw;
    padding: 0;
    gap: 10px;
    margin: 0 auto;
    overflow: visible;
  }
  #topBar { display: none !important; }
  /* hudRow และ spacer ใน col ใช้ style เดียวกัน — สูงเท่ากันเสมอ */

  /* Scale ทั้ง col ลงให้พอดี viewport — layout เหมือนเดิม ย่อ scale เดียว */
  #leftCol  { display: flex !important; flex-direction: column; gap: 8px; flex-shrink: 0;
               width: 165px; overflow: visible;
               transform-origin: top left;
               transform: scale(var(--col-scale,1));
               /* ชดเชย gap หลัง scale */
               margin-right: calc(165px * var(--col-scale,1) - 165px); }
  #rightCol { display: flex !important; flex-direction: column; gap: 8px; flex-shrink: 0;
               width: 165px; overflow: visible;
               transform-origin: top right;
               transform: scale(var(--col-scale,1));
               margin-left: calc(165px * var(--col-scale,1) - 165px); }

  #scoreBoxL { width:100%; aspect-ratio:1/1; }
  #levelBoxL  { width:100%; aspect-ratio:1/1; }

  /* A: Theme Button Card */
  #themeCardL { width:100%; aspect-ratio:1/1; border:none; overflow:hidden; cursor:pointer; background:none; box-shadow:none; padding:0; border-radius:var(--card-radius); }
  #themeCardL img { width:100%; height:100%; object-fit:cover; display:block; }

  /* B: Wide Setting Button */
  #settingBtnLandscape { width:100%; border:none; overflow:hidden; cursor:pointer; background:none; box-shadow:none; padding:0; border-radius:var(--card-radius); }
  #settingBtnLandscape img { width:100%; height:100%; object-fit:cover; display:block; }

  #nextBoxR   { width:100%; aspect-ratio:1/1; overflow:hidden; border-radius:var(--card-radius); padding:0; }
  #nextBoxR img { width:100%; height:100%; object-fit:cover; display:block; }

  /* C: Shop Button Card */
  #chestCardL { width:100%; aspect-ratio:1/1; border:none; overflow:hidden; cursor:pointer; background:none; box-shadow:none; padding:0; border-radius:var(--card-radius); }
  #chestCardL img { width:100%; height:100%; object-fit:cover; display:block; }

  #scoreValL { font-size: clamp(20px,3.2vw,42px); letter-spacing:2px; font-weight:800; color:#FFD250; font-variant-numeric:tabular-nums; text-align:center; width:100%; }
  #levelNumL  { font-size: clamp(20px,3.2vw,42px); font-weight:800; color:#90CF5F; }
  #topScoreL  { font-size: clamp(9px,1.1vw,12px); color:#a898c8; font-weight:700; }
  #levelNextInfoL { font-size: clamp(8px,1vw,10px); color:#b8a8d0; }
  .score-label, .lv-label { font-size: 10px; }
}

@media (orientation: portrait) {
  #leftCol, #rightCol { display: none !important; }
  #topBar  { display: flex !important; }

  body {
    align-items: center;
    height: 100vh;
  }

  #gameWrap {
    padding-top: 0 !important;
  }

  #topBar {
    display: flex !important;
    width: 100% !important;
    gap: 6px !important;
    align-items: flex-start !important;
    height: auto !important;
  }

  #scoreBox, #levelBox, #nextBox, #settingBtn {
    flex: 1 1 0 !important;
    max-width: 96px !important;
    min-width: 0 !important;
    width: calc((100% - 18px) / 4) !important;
    height: calc((100% - 18px) / 4) !important;
    aspect-ratio: 1/1 !important;
    padding: 4px !important;
  }

  #scoreBox, #levelBox { 
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #scoreVal       { font-size: clamp(16px, 7vw, 32px); }
  #levelNum       { font-size: clamp(16px, 7vw, 32px); }
  #topScore       { font-size: clamp(8px, 2vw, 10px); }
  .score-label, .lv-label { font-size: 9px; letter-spacing: 1px; }
  #levelNextInfo  { font-size: clamp(7px, 1.8vw, 9px); }
}

@keyframes canvasShake {
  0%   { transform: translate(0,0) rotate(0deg); }
  8%   { transform: translate(-10px, 5px) rotate(-1.5deg); }
  16%  { transform: translate(10px, -6px) rotate(1.5deg); }
  24%  { transform: translate(-12px, 4px) rotate(-1.2deg); }
  32%  { transform: translate(12px, -4px) rotate(1.2deg); }
  42%  { transform: translate(-8px, 6px) rotate(-0.8deg); }
  52%  { transform: translate(8px, -5px) rotate(0.8deg); }
  62%  { transform: translate(-5px, 3px) rotate(-0.4deg); }
  72%  { transform: translate(5px, -3px) rotate(0.4deg); }
  84%  { transform: translate(-2px, 1px) rotate(-0.2deg); }
  92%  { transform: translate(2px, -1px) rotate(0.2deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}
#canvasWrap.shaking {
  animation: canvasShake 0.65s cubic-bezier(0.36,0.07,0.19,0.97) both;
}
.popup-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(20,10,40,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.popup-overlay.open { display: flex; }

#overlayDifficulty {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background-size: 56px 56px;
}
/* overlayTheme ต้องอยู่เหนือ settingPanel (z-index:200) */
#overlayTheme {
  z-index: 310;
}
/* Theme popup — ใช้ขนาดชุดเดียวกับ popup ทั้งระบบ */
#overlayTheme .popup-box {
  width:      var(--game-w, 380px);
  max-width:  98vw;
  height: calc(var(--popup-top, 96px) + var(--popup-content, 400px) + var(--popup-footer, 64px));
  max-height: 96vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#overlayTheme .popup-body {
  height: var(--popup-content, 400px);
  overflow-y: auto;
  padding: 10px 12px 4px;
}
#overlayTheme .theme-grid-3x3 {
  height: auto;
  gap: 8px;
}
#overlayTheme .theme-cell {
  aspect-ratio: 1 / 1;
}
#overlayTheme .popup-title {
  height: var(--popup-top, 96px);
  font-size: 0; /* ซ่อน text — header_theme.webp แสดงแทน */
}
@keyframes diffStripeMove {
  from { background-position: 0 0; }
  to   { background-position: 56px 56px; }
}
#overlayDifficulty.open {
  animation: diffStripeMove 4s linear infinite;
}

.popup-box {
  background: #fff var(--popup-body-bg) center center / cover no-repeat;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  border: var(--popup-border-width) solid var(--popup-border-color);
  position: relative;
  width:      var(--game-w, 380px);
  max-width:  98vw;
  /* ความสูง = top + content + footer — ขยายตาม 3 zones เสมอ */
  height: calc(var(--popup-top, 96px) + var(--popup-content, 400px) + var(--popup-footer, 64px));
  max-height: 96vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
}
/* TOP zone — 96px */
.popup-title {
  height: var(--popup-top, 96px);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--text-dark);
  padding: 0 16px;
  background: transparent;
  border-radius: 24px 24px 0 0;
}
/* [v7.8] Header image popups — ซ่อน text ปกติ, แสดงเมื่อภาพโหลดไม่ได้ */
#overlayGO       .popup-title,
#overlayScore    .popup-title,
#overlayHelp     .popup-title,
#overlayTheme    .popup-title,
#overlayAbout    .popup-title,
#settingPanelInner .popup-title,
#shopPanelInner    .popup-title {
  font-size: 0;
  color: transparent;
}
#overlayGO.img-missing       .popup-title,
#overlayScore.img-missing    .popup-title,
#overlayHelp.img-missing     .popup-title,
#overlayTheme.img-missing    .popup-title,
#overlayAbout.img-missing    .popup-title,
#settingPanel.img-missing    .popup-title,
#shopPanel.img-missing       .popup-title {
  font-size: 15px;
  color: var(--text-dark);
}
#overlayGO       .popup-title { background-image: url('../image/ui/header/header_game_over.webp');  background-size: auto; background-position: center; }
#overlayScore    .popup-title { background-image: url('../image/ui/header/header_score.webp');      background-size: auto; background-position: center; }
#overlayHelp     .popup-title { background-image: url('../image/ui/header/header_howtoplay.webp');  background-size: auto; background-position: center; }
#overlayTheme    .popup-title { background-image: url('../image/ui/header/header_theme.webp');      background-size: auto; background-position: center; }
#overlayAbout    .popup-title { background-image: url('../image/ui/header/header_about.webp');      background-size: auto; background-position: center; }
#settingPanelInner .popup-title { background-image: url('../image/ui/header/header_setting.webp'); background-size: auto; background-position: center; }
#shopPanelInner    .popup-title { background-image: url('../image/ui/header/header_shop.webp');    background-size: auto; background-position: center; }

/* CONTENT zone — 400px, scroll Y only */
.popup-body {
  height: var(--popup-content, 400px);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  background: transparent;
}
/* FOOTER zone — 64px */
.popup-footer {
  height: var(--popup-footer, 64px);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0;
  background: transparent;
  border-radius: 0 0 24px 24px;
}
@keyframes popIn { from { transform: scale(0.75); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* wrapper สำหรับ popup + ปุ่ม close ด้านล่าง */
.popup-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: popIn 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
}

/* ปุ่ม Close ด้านล่าง popup — ใช้กับทุก popup ขนาดเท่ากันหมด */
.bottom-close-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  background: none; border: none; cursor: pointer;
  padding: 0;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}
.bottom-close-btn img {
  width: 120px; height: auto; object-fit: contain; display: block;
}
.bottom-close-btn span {
  display: none; /* ซ่อนข้อความ ใช้รูปอย่างเดียว */
}
/* Game Over Back to Menu ปุ่มพิเศษ — แสดงข้อความ */
#overlayGO .bottom-close-btn span {
  display: block;
  font-size: 12px; font-weight: 700; color: #7060a0;
  margin-top: 2px;
}
.bottom-close-btn:hover { transform: scale(1.08); opacity: 0.85; }

/* .popup-close ถูกแทนที่ด้วย .bottom-close-btn แล้ว */

/* popup-title และ popup-body ใช้ชุดเดียวด้านบน */

.theme-grid-3x3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  height: 100%;
}
.theme-cell {
  aspect-ratio: 1/1;
  border-radius: 14px; border: 2px solid #f0eef8;
  overflow: hidden; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  position: relative; background: #f8f6ff;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}
.theme-cell:hover { transform: scale(0.96); border-color: #c8b8e8; }
.theme-cell.active { border-color: #ff8da1; box-shadow: 0 0 0 2px #ff8da133; }
.theme-cell img { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; }
.theme-cell .cell-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.45); color: #fff;
  font-size: 10px; font-weight: 600; text-align: center; padding: 3px;
}
.theme-cell .active-badge {
  position: absolute; top: 5px; right: 5px; z-index: 3;
  background: #ff8da1; color: #fff;
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 8px;
  letter-spacing: 0.5px;
}
.theme-cell .use-btn {
  position: absolute; inset: 0; z-index: 2;
  background: rgba(255,141,161,0.0);
  border: none; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 24px;
  transition: background 0.18s;
}
.theme-cell .use-btn span {
  background: #ff8da1; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 12px; border-radius: 10px;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.18s, transform 0.18s;
}
.theme-cell:hover { background: rgba(255,141,161,0.15); }
.theme-cell:hover .use-btn span { opacity: 1; transform: translateY(0); }
.theme-cell.active .use-btn span { opacity: 1; transform: translateY(0); background: #2ecc71; }

.theme-coming {
  background: #f0eef8; color: #c0b8d8;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; cursor: default;
}
.theme-coming img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }

.help-inner {
  display: flex; flex-direction: column; gap: 10px; height: 100%;
}
.help-ring { width: 100%; aspect-ratio: 1/1; max-height: 55%; object-fit: contain; border-radius: 12px; }
.help-text { font-size: 12px; color: #506850; line-height: 1.8; }
.help-text b { color: #3a5838; display: block; margin-bottom: 4px; font-size: 13px; }

.vol-section {
  display: flex; flex-direction: column; gap: 10px;
  padding: 8px 0;
}
.vol-row {
  display: flex; align-items: center; gap: 10px;
}
.vol-label {
  font-size: 13px; font-weight: 700; color: #3a3650;
  min-width: 26px; text-align: center;
}
.vol-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, #c878a8 0%, #c878a8 var(--val,40%), #ede8f5 var(--val,40%), #ede8f5 100%);
  outline: none; cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: #c878a8;
  box-shadow: 0 2px 6px rgba(200,120,168,0.45); cursor: pointer;
}
.vol-pct {
  font-size: 11px; color: #a898b8; font-weight: 600;
  min-width: 32px; text-align: right;
}

.gameover-inner {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 8px;
}
.gameover-inner h2 { font-size: 28px; color: #e74c3c; }
.gameover-inner .go-score { font-size: 56px; font-weight: 800; color: var(--text-dark); }
.gameover-inner button {
  background: linear-gradient(135deg,#4CAF50,#2ecc71);
  color: #fff; border: none; border-radius: 14px;
  padding: 14px 40px; font-size: 17px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px rgba(46,204,113,0.4);
  margin-top: 8px;
}

/* --- SCOREBOARD --- */
.sb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
}
.sb-row:last-child { border-bottom: none; }
.sb-row.sb-top1 { background: rgba(255,215,0,0.12); }
.sb-row.sb-top2 { background: rgba(192,192,192,0.1); }
.sb-row.sb-top3 { background: rgba(205,127,50,0.1); }
.sb-rank { font-size:18px; text-align:center; }
.sb-info { display:flex; flex-direction:column; gap:1px; }
.sb-name { font-weight:700; color:#3a2a60; font-size:14px; }
.sb-meta { font-size:10px; color:#999; }
.sb-score { font-weight:800; color:#e85d8a; font-size:16px; text-align:right; }
.sb-loading { text-align:center; padding:24px; color:#aaa; font-size:14px; }

#overlayDifficulty {
  align-items: center;
  justify-content: center;
}

.diff-menu-card {
  position: relative;
  background: #fff;
  border-radius: 32px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  width: min(86vw, 340px);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 0 24px 22px;
  overflow: visible;
  animation: popIn 0.3s cubic-bezier(0.175,0.885,0.32,1.275) both;
}

.diff-logo-wrap {
  position: relative;
  width: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  margin-top: -52px;
  margin-bottom: 10px;
  height: 150px;
}
.diff-logo-img {
  height: 220px;
  object-fit: contain;
  position: relative; z-index: 2;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.16));
}

.diff-deco-fruit {
  position: absolute;
  width: 88px; height: 88px;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.22));
  z-index: 1;
  bottom: 50px;
}
.diff-deco-fruit.left  {
  left: -20px;
  animation: decoFloat 2.2s ease-in-out infinite alternate both;
}
.diff-deco-fruit.right {
  right: -20px;
  animation: decoFloat 2.6s ease-in-out infinite alternate-reverse both;
}
@keyframes decoFloat {
  0%   { transform: translateY(0)    rotate(-4deg) scale(1); }
  100% { transform: translateY(-10px) rotate(4deg) scale(1.05); }
}

.diff-char-area {
  position: relative;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  gap: 0;
  margin: -50px 0 4px;
}
.diff-char-plate {
  position: absolute;
  width: 72%;
  aspect-ratio: 1/1;
  object-fit: contain;
  z-index: 1;
  opacity: 0.92;
}
.diff-char-img {
  position: relative; z-index: 2;
  height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.15));
}
.diff-arrow-btn {
  position: relative; z-index: 3;
  background: none; border: none; padding: 0; cursor: pointer;
  transition: transform 0.12s;
  flex-shrink: 0;
}
.diff-arrow-btn:hover  { transform: scale(1.18); }
.diff-arrow-btn:active { transform: scale(0.88); }
.diff-arrow-btn img { width: 52px; height: 52px; object-fit: contain; display: block; }

.diff-play-btn {
  background: none; border: none; padding: 0;
  cursor: pointer; margin-top: -10px;
  transition: transform 0.12s, filter 0.12s;
  width: 88%;
}
.diff-play-btn:hover  { transform: scale(1.04); filter: brightness(1.06); }
.diff-play-btn:active { transform: scale(0.96); }
.diff-play-btn img {
  width: 100%; object-fit: contain; display: block;
  filter: drop-shadow(0 4px 14px rgba(200,80,120,0.35));
}

.diff-version {
  font-size: 11px; font-weight: 500;
  color: #b0a8c8; letter-spacing: 0.8px;
  text-align: center; margin-top: 10px;
}

/* ─── Special Ball Popup — Sunburst Circle ─── */
#overlaySpecialBall {
  background: transparent !important;
  pointer-events: all;
}
#overlaySpecialBall .popup-box { display: none !important; }

#sbSunburstWrap {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 261; pointer-events: all;
  cursor: pointer;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#sbSunburstWrap.active { display: flex; }

/* วงกลม sunburst — เฉพาะวงกลมตรงกลาง */
#sbSunburst {
  position: absolute;
  width: min(55vw, 55vh);
  height: min(55vw, 55vh);
  border-radius: 50%;
  overflow: hidden;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
#sbSunburst canvas {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
@keyframes sbSpin { from { transform: translate(-50%,-50%) rotate(0deg); } to { transform: translate(-50%,-50%) rotate(360deg); } }
#sbSunburstImg { animation: sbSpin 8s linear infinite; }

#sbContent {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  text-align: center;
  animation: sbPop 0.4s cubic-bezier(0.175,0.885,0.32,1.6) both;
  pointer-events: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
@keyframes sbPop {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1);   opacity: 1; }
}

.special-popup-img {
  width: 130px; height: 130px; object-fit: contain;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.35));
  animation: specialPopBounce 0.55s cubic-bezier(0.175,0.885,0.32,1.6) both;
}
@keyframes specialPopBounce {
  0%   { transform: scale(0) rotate(-15deg); opacity:0; }
  70%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); opacity:1; }
}
.special-popup-title {
  font-size: 26px; font-weight: 800; color: #e040fb;
  text-shadow: 0 2px 10px rgba(255,255,255,0.9), 0 0 20px rgba(224,64,251,0.5);
  -webkit-text-stroke: 1.5px #fff;
  paint-order: stroke fill;
}
.special-popup-text {
  font-size: 15px; font-weight: 700; color: #3a1a50;
  text-shadow: 0 1px 4px rgba(255,255,255,0.8);
  line-height: 1.7; max-width: 260px;
}
#sbTapHint {
  font-size: 12px; color: rgba(60,20,80,0.55);
  letter-spacing: 0.5px; margin-top: 2px;
}

#specialBallAlert {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg,#ab47bc,#e040fb);
  color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 10px; white-space: nowrap;
  display: none; z-index: 10; letter-spacing: 0.5px;
  animation: badAlertPop 0.3s cubic-bezier(0.175,0.885,0.32,1.6) both;
}

@keyframes iconBounceActive {
  0%, 100% { transform: translateY(0) scale(1); }
  50%       { transform: translateY(-5px) scale(1.15); }
}
.cd-icon.mode-active {
  animation: iconBounceActive 0.5s ease-in-out infinite;
}

#badFruitAlert {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg,#e74c3c,#c0392b);
  color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 10px; border-radius: 10px; white-space: nowrap;
  display: none; z-index: 10; letter-spacing: 0.5px;
  animation: badAlertPop 0.3s cubic-bezier(0.175,0.885,0.32,1.6) both;
}
@keyframes badAlertPop { from { transform: translate(-50%, -50%) scale(0.6); opacity:0; } to { transform: translate(-50%, -50%) scale(1); opacity:1; } }

#shopPanel {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 280;
  background: rgba(20,10,40,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  padding: 16px 0;
}
#shopPanel.open { display: flex; }
#shopPanelInner {
  background: #fff var(--popup-body-bg) center center / cover no-repeat;
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  border: var(--popup-border-width) solid var(--popup-border-color);
  width:      var(--game-w, 380px);
  max-width:  98vw;
  height: calc(var(--popup-top, 96px) + var(--popup-content, 400px) + var(--popup-footer, 64px));
  max-height: 96vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
/* [SHOP BANNER] banner ชิดขอบบน แทน popup-title */
#shopBannerWrap {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  border-radius: 24px 24px 0 0;
  overflow: hidden;
}
#shopBannerWrap #shopAdSlider {
  border-radius: 24px 24px 0 0 !important;
  border: none !important;
  margin-bottom: 0 !important;
  aspect-ratio: 16 / 6 !important; /* สูงกว่า 16/9 เล็กน้อยเหมาะกับ header */
}
#shopBannerLabel {
  position: absolute;
  top: 10px;
  left: 14px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 800;
  color: #3a3650;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
#shopBackdrop { display: none; }
.shop-panel-title {
  font-size: 18px; font-weight: 800; color: #3a3650;
  text-align: center; margin-bottom: 4px;
}
.shop-hr { border: none; border-top: 1px solid #f0eef8; margin: 4px 0; }
.shop-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  background: #fff8f8; border-radius: 12px;
  padding: 8px 10px;
}
.shop-arrow { color:#bbb; font-size:11px; flex-shrink:0; }
.shop-icon  { width:28px;height:28px;object-fit:contain;flex-shrink:0; }
.shop-cost  { font-size:13px;font-weight:700;min-width:28px; }
.shop-get   { font-size:13px;font-weight:700;min-width:28px; }
.coin-color    { color:#e05050; }
.diamond-color { color:#4090e0; }
.shake-color   { color:#a060e0; }
.hammer-color  { color:#e08040; }
.shop-ads-btn {
  display:flex;align-items:center;gap:6px;
  background:linear-gradient(135deg,#e74c3c,#c0392b);
  border:none;border-radius:12px;padding:8px 16px;
  font-size:13px;font-weight:700;color:#fff;cursor:pointer;
  box-shadow:0 3px 10px rgba(231,76,60,0.4); flex-shrink:0;
}
.shop-ads-btn img { width:22px;height:22px;object-fit:contain; }
.shop-pm {
  display:flex;align-items:center;gap:4px;margin-left:auto;flex-shrink:0;
  background:#f5f0ff;border-radius:10px;padding:3px 6px;
}
.shop-pm button {
  width:24px;height:24px;border-radius:50%;
  background:#e8e0f8;border:none;cursor:pointer;
  font-size:15px;font-weight:700;color:#6050a0;
  display:flex;align-items:center;justify-content:center;
}
.shop-pm span { min-width:22px;text-align:center;font-weight:700;font-size:14px;color:#3a3650; }
/* shop-ok-btn ลบออก — ใช้ Confirm กลาง */
.shop-rows-card {
  background:#fff;border-radius:16px;
  padding:8px;display:flex;flex-direction:column;gap:6px;
  box-shadow:0 2px 8px rgba(120,90,180,0.08);
}
.shop-status-bar {
  display:flex;align-items:center;justify-content:space-around;
  background:#fff;border-radius:14px;padding:8px 10px;
  box-shadow:0 2px 8px rgba(120,90,180,0.08);
  font-size:13px;font-weight:800;gap:8px;
}
.shop-status-bar .si { display:flex;align-items:center;gap:4px; }
.shop-status-bar img { width:22px;height:22px;object-fit:contain; }
.shop-bottom-row {
  display:flex;gap:10px;align-items:center;justify-content:center;
  padding:4px 0 8px;
}
/* Close และ Confirm ขนาดเท่ากันทุกปุ่ม */
.shop-bottom-row .bottom-close-btn img,
.shop-confirm-btn img {
  width: 120px; height: auto; object-fit: contain; display: block;
}
.shop-confirm-btn {
  background:none;border:none;cursor:pointer;padding:0;
  transition:transform 0.15s,opacity 0.15s;
}
.shop-confirm-btn:hover { transform:scale(1.07);opacity:0.88; }
/* Watch Ads button */
.shop-watch-ads-wrap {
  display:flex;flex-direction:column;align-items:center;gap:4px;
  padding:4px 0;
}
.shop-ads-btn {
  background:none;border:none;cursor:pointer;padding:0;
  transition:transform 0.15s,opacity 0.15s;
  display:flex;flex-direction:column;align-items:center;gap:4px;
}
.shop-ads-btn img.watch-logo { width:160px;height:auto;object-fit:contain; }
.shop-ads-btn .watch-sub {
  font-size:11px;color:#a090c0;font-weight:600;text-align:center;
}
.shop-ads-btn:hover { transform:scale(1.05);opacity:0.9; }

#statusBar {
  display: flex; align-items: center;
  width: 100%; padding: 4px 4px;
  gap: 5px; flex-shrink: 0;
  box-sizing: border-box;
}
@media (orientation: landscape) {
  #statusBar { display: flex !important; flex-shrink: 0; }
}

/* ── bottom pill per item ── */
.status-item {
  display: flex; align-items: center;
  justify-content: flex-start;
  gap: 6px; font-variant-numeric: tabular-nums;
  flex: 1;
  background: #fff;
  border-radius: var(--pill-radius);
  padding: 5px 10px 5px 6px;
  min-width: 0;
}
.status-item img:not(.cd-icon) {
  width: 32px; height: 32px; object-fit: contain;
  flex-shrink: 0;
}
.status-item.coin    { border: 2.5px solid #f5c842; }
.status-item.diamond { border: 2.5px solid #60c0f0; }
.status-item.shake-item  { border: 2.5px solid #ff8da1; }
.status-item.hammer-item { border: 2.5px solid #b090f0; }

/* ══════════════════════════════════════
   PILL SYSTEM — ใช้ค่าเดียวทั้งหมด
   ══════════════════════════════════════ */
:root {
  --pill-bg:     rgba(255,255,255,0.82);
  --pill-radius: 15px;
  --pill-shadow: 0 1px 4px rgba(0,0,0,0.08);
  --hud-text-color: #7060a8;
}

/* ── HUD text — ใช้ทุกจุด (A B C D) ── */
.hud-text {
  font-family: 'Noto Sans Thai','Itim',sans-serif;
  font-weight: 800;
  color: var(--hud-text-color);
  text-shadow: none !important;
  -webkit-text-stroke: 0 !important;
  paint-order: fill;
}

/* ── pill chip (generic) ── */
.pill-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--pill-bg);
  border-radius: var(--pill-radius);
  box-shadow: var(--pill-shadow);
  padding: 3px 8px; white-space: nowrap;
  flex-shrink: 0;
}

.shake-item, .hammer-item {
  cursor: pointer; user-select: none;
  flex-direction: row;  
  gap: 5px;             
  padding: 3px 6px; border-radius: var(--pill-radius);
  transition: background 0.15s, transform 0.1s;
}
.shake-item  { color: #a060e0; }
.hammer-item { color: #e08040; }
.shake-item:active, .hammer-item:active  { transform: scale(0.92); }

.cd-ring-wrap {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
}
.cd-ring-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.cd-bg {
  fill: none; stroke: rgba(0,0,0,0.08); stroke-width: 3;
}
.cd-fill {
  fill: none; stroke-width: 3;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear, stroke 0.3s;
}
#shakeCDFill   { stroke: #ff8da1; }
#hammerCDFill  { stroke: #a78bfa; }

.cd-ring-wrap.on-cd .cd-icon {
  filter: brightness(0.35) saturate(0);
}
.cd-icon {
  position: relative; z-index: 1;
  width: 32px; height: 32px; object-fit: contain;
  transition: filter 0.3s;
}

@keyframes hammerWiggle {
  0%,100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}
#hammerIconImg.animating {
  animation: hammerWiggle 0.4s ease-in-out infinite;
}

.coin-particle {
  position: fixed; z-index: 999; pointer-events: none;
  width: 22px; height: 22px;
  background: url('../image/ui/coin.png') center/contain no-repeat;
  animation: coinFly 0.85s ease-out forwards;
  transform-origin: center;
}
@keyframes coinFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}

#settingPanel {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 280;
  background: rgba(20,10,40,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#settingPanel.open { display: flex; }
#settingPanelInner {
  background: #fff var(--popup-body-bg) center center / cover no-repeat;
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.28);
  border: var(--popup-border-width) solid var(--popup-border-color);
  width:      var(--game-w, 380px);
  max-width:  98vw;
  height: calc(var(--popup-top, 96px) + var(--popup-content, 400px) + var(--popup-footer, 64px));
  max-height: 96vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
}
#settingBackdrop { display: none; }
#spLeft { flex: 1; display: flex; flex-direction: row; gap: 8px; }
#spThumbWrap {
  position: relative; border-radius: 14px; overflow: hidden;
  cursor: pointer; aspect-ratio: 1/1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
#spThumbWrap img { width:100%; height:100%; object-fit:cover; display:block; }
#spThumbLabel {
  position: absolute; bottom:0; left:0; right:0;
  background: rgba(0,0,0,0.45); color:#fff;
  font-size: 11px; font-weight:600; text-align:center; padding:4px;
}
#spMusicPlayer {
  background: #fff; border-radius: 14px; padding: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex; flex-direction: column; gap: 8px;
}
.sp-vol-title {
  font-size: 11px; font-weight: 700; color: #8878a8;
  letter-spacing: 1px; text-align: center;
}
.sp-vol-row {
  display: flex; align-items: center; gap: 6px;
}
.sp-vol-icon { font-size: 14px; }
.sp-vol-slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 3px; outline: none; cursor: pointer;
  background: linear-gradient(to right, #c878a8 0%, #c878a8 var(--val,40%), #ede8f5 var(--val,40%), #ede8f5 100%);
}
.sp-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: #c878a8; cursor: pointer;
}
.sp-vol-pct { font-size: 10px; color: #a898b8; min-width: 28px; text-align:right; }
#spRight { flex: 1.2; display: flex; flex-direction: column; gap: 8px; }
#spRingWrap img { width:100%; object-fit:contain; border-radius:10px; }
#spHowto {
  font-size: 11px; color: #506850; line-height: 1.7;
  background:#fff; border-radius:10px; padding:8px;
}
#spHowto b { display:block; color:#3a5838; font-size:12px; margin-bottom:2px; }
/* #spCloseBtn ถูกแทนที่ด้วย .bottom-close-btn แล้ว */

#themePanel {
  position: fixed; left:0; right:0; bottom:0;
  background: #fff; border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
  z-index: 300; transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
  max-height: 80vh; overflow-y: auto;
}
#themePanel.open { transform: translateY(0); }
#themePanelHeader {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px 8px; font-size: 16px; font-weight: 700; color: #3a3650;
  position: sticky; top:0; background:#fff; z-index:1;
  border-bottom: 1px solid #f0eef8;
}
#themePanelHeader button {
  background: #f0eef8; border:none; border-radius:50%;
  width:30px;height:30px;font-size:14px;cursor:pointer;color:#6050a0;
}
#themePanelGrid { display:grid;grid-template-columns:repeat(3,1fr);gap:10px;padding:12px; }
#themePanelBackdrop {
  position:fixed;inset:0;background:rgba(0,0,0,0.4);
  z-index:299;display:none;backdrop-filter:blur(4px);
}
#themePanelBackdrop.open { display:block; }

@media (max-height:650px) and (orientation:landscape) {
  #gameWrap { padding: 6px; gap: 8px; }
  #leftCol, #rightCol { gap: 6px; width: clamp(80px, 12vw, 130px); }
  #scoreVal { font-size: clamp(14px, 2.5vw, 24px); }
  #levelNum { font-size: clamp(14px, 2.5vw, 22px); }
}

#loadingScreen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0;
  background: #ede7f6;
  transition: opacity 0.6s ease, transform 0.6s ease;
  overflow: hidden;
}
#loadingScreen.hide {
  opacity: 0; transform: scale(1.06); pointer-events: none;
}

#loadingScreen::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

#loadingContent {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  width: 100%; max-width: 380px;
  padding: 0 32px;
}

#loadingFruitStrip {
  display: flex; gap: 14px; justify-content: center;
  align-items: flex-end;
  height: 110px; margin-bottom: 4px;
  flex-wrap: nowrap; overflow: visible;
}
.ld-fruit {
  width: 68px; height: 68px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.18));
  animation: ldFruitFloat 1.4s ease-in-out infinite alternate both;
}
.ld-fruit:nth-child(1) { animation-delay: 0s;    animation-duration: 1.3s; width:52px;height:52px; }
.ld-fruit:nth-child(2) { animation-delay: 0.18s; animation-duration: 1.5s; width:72px;height:72px; }
.ld-fruit:nth-child(3) { animation-delay: 0.36s; animation-duration: 1.2s; width:60px; height:60px; }
.ld-fruit:nth-child(4) { animation-delay: 0.54s; animation-duration: 1.6s; width:78px;height:78px; }
.ld-fruit:nth-child(5) { animation-delay: 0.72s; animation-duration: 1.35s; width:55px;height:55px; }
@keyframes ldFruitFloat {
  from { transform: translateY(0) rotate(-4deg) scale(1); }
  to   { transform: translateY(-18px) rotate(4deg) scale(1.06); }
}

#loadingTitle {
  font-family: 'Itim', sans-serif;
  font-size: 28px; font-weight: 800; letter-spacing: 2px;
  margin-bottom: 2px; text-align: center;
  text-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

#loadingBarWrap {
  width: 100%; height: 28px;
  background: rgba(255,255,255,0.45);
  border-radius: 14px;
  border: 4px solid rgba(255,255,255,0.9);
  box-shadow: 0 3px 10px rgba(0,0,0,0.10), inset 0 1px 3px rgba(0,0,0,0.08);
  position: relative; overflow: hidden;
}
#loadingBarFill {
  height: 100%; border-radius: 0;
  width: 0%;
  transition: width 0.28s cubic-bezier(0.4,0,0.2,1);
  position: relative; overflow: hidden;
}
#loadingBarFill::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.28) 0px,
    rgba(255,255,255,0.28) 8px,
    transparent 8px,
    transparent 16px
  );
  animation: ldStripeMove 0.7s linear infinite;
}
@keyframes ldStripeMove {
  from { background-position: 0 0; }
  to   { background-position: 22px 0; }
}

#loadingLabel {
  font-family: 'Itim', sans-serif;
  font-size: 13px; font-weight: 700;
  letter-spacing: 3px; opacity: 0.75;
  text-align: center; margin-top: 2px;
}

#loadingTip {
  font-family: 'Itim', sans-serif;
  font-size: 12px; font-weight: 500;
  opacity: 0.6; text-align: center; margin-top: 2px;
  min-height: 18px;
}
.music-track-btn {
  padding: 7px 6px;
  border: 2px solid #e8e0f4;
  border-radius: 10px;
  background: #f8f4ff;
  color: #7060a0;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: 'Itim', sans-serif;
}
.music-track-btn:hover  { background: #ede8ff; border-color: #c8a8f8; }
.music-track-btn:active { transform: scale(0.93); }
.music-track-btn.active {
  background: linear-gradient(135deg,#c878a8,#9b59b6);
  color: #fff; border-color: transparent;
  box-shadow: 0 3px 10px rgba(155,89,182,0.35);
}

#spMusicGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sp-music-mode-btn {
  padding: 8px 4px;
  border: 2px solid #e8e0f4;
  border-radius: 10px;
  background: #f8f4ff;
  color: #7060a0;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: 'Itim', sans-serif;
  text-align: center;
  line-height: 1.3;
}
.sp-music-mode-btn:hover  { background: #ede8ff; border-color: #c8a8f8; }
.sp-music-mode-btn:active { transform: scale(0.93); }
.sp-music-mode-btn.active {
  background: linear-gradient(135deg,#c878a8,#9b59b6);
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(155,89,182,0.35);
}
.sp-music-mode-btn.auto-active {
  background: linear-gradient(135deg,#54a0ff,#2e86de);
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(46,134,222,0.35);
}
#spMusicAutoHint {
  font-size: 9px; color: #b8a8c8; text-align: center; margin-top: 2px;
}

/* ── Fullscreen: ทุกโหมด ── */

/* ── ลบ combo height override — ใช้ค่าเดิมจาก config ── */

/* ── Fullscreen mode layout ── */
:fullscreen,
:-webkit-full-screen,
:-moz-full-screen {
  background: #1a0a2e !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
:fullscreen #gameWrap,
:-webkit-full-screen #gameWrap {
  max-height: 100vh;
  overflow: hidden;
}

/* ── HUD text ── */
.hud-text {
  font-family: 'Noto Sans Thai','Itim',sans-serif;
  font-weight: 800;
  color: #7060a8;
  text-shadow: none !important;
  -webkit-text-stroke: 0 !important;
  paint-order: fill;
}
#profilePanel { align-items:center; justify-content:center; }
#profilePanel .popup-wrap {
  animation:popIn 0.25s cubic-bezier(0.34,1.4,0.64,1);
  width:370px; max-width:95%; max-height:570px;
  display:flex; flex-direction:column;
}
#profilePanel .popup-box {
  display:flex; flex-direction:column;
  max-height:570px; overflow:hidden;
}
#profilePanel .popup-body {
  overflow-y:auto; flex:1;
}
}
@keyframes popIn {
  from { opacity:0; transform:scale(0.88); }
  to   { opacity:1; transform:scale(1); }
}
.pp-stat-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: #3a3650; padding: 2px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.pp-stat-row:last-child { border-bottom: none; }

/* ── Profile Button on canvas ── */
#profileBtn:hover { transform: scale(1.08); }
#profileBtn:active { transform: scale(0.92); }

/* ── Fruit Point HUD ── */

/* ── Debug FAB (floating button) ─────────────────── */
#dbgFab{ display:none !important; }
  position:fixed;right:0;top:50%;transform:translateY(-50%);
  width:32px;height:56px;
  background:linear-gradient(135deg,#a78bfa,#f85149);
  border:none;border-radius:10px 0 0 10px;
  color:#fff;font-size:17px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  z-index:99989;box-shadow:-2px 0 12px rgba(0,0,0,.5);
  transition:width .2s;writing-mode:vertical-rl;
  letter-spacing:1px;font-family:'Noto Sans Thai',sans-serif;
  font-size:11px;font-weight:700;padding:6px 4px;
}
#dbgFab:hover{width:40px}
/* ── Overlay ──────────────────────────────────────── */
#dbgOverlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:99990}
#dbgOverlay.active{display:block}
#dbgPanel{
  position:fixed;top:50%;right:0;transform:translateY(-50%);
  width:min(400px,98vw);max-height:92vh;overflow-y:auto;
  background:#0d1117;border:1.5px solid #30363d;
  border-radius:14px 0 0 14px;
  box-shadow:-4px 0 32px rgba(0,0,0,.8);
  font-family:'Noto Sans Thai','Segoe UI',sans-serif;
  font-size:13px;color:#e6edf3;z-index:99991;padding:0 0 14px
}
#dbgPanel h2{
  margin:0;padding:10px 14px;font-size:13px;font-weight:700;
  background:#161b22;border-bottom:1px solid #30363d;
  border-radius:14px 0 0 0;
  display:flex;align-items:center;justify-content:space-between
}
.dbg-badge{background:#f85149;color:#fff;border-radius:5px;font-size:10px;padding:1px 5px}
#dbgPanel section{padding:8px 14px 2px}
#dbgPanel section h3{
  font-size:11px;font-weight:600;color:#8b949e;
  text-transform:uppercase;letter-spacing:.5px;
  margin:0 0 7px;padding-bottom:4px;border-bottom:1px solid #21262d
}
#dbgPanel .dbg-row{display:flex;flex-wrap:wrap;gap:5px;margin-bottom:4px}
.dbg-btn{
  padding:4px 10px;border-radius:7px;border:1px solid #30363d;
  background:#21262d;color:#e6edf3;cursor:pointer;
  font-size:12px;font-family:'Noto Sans Thai','Segoe UI',sans-serif;transition:background .15s
}
.dbg-btn:hover{background:#30363d}
.dbg-btn.red{border-color:#f85149;color:#f85149}
.dbg-btn.red:hover{background:#2d1b1b}
.dbg-btn.green{border-color:#3fb950;color:#3fb950}
.dbg-btn.green:hover{background:#1a2d1a}
.dbg-btn.amber{border-color:#d29922;color:#d29922}
.dbg-btn.amber:hover{background:#2d2510}
.dbg-btn.purple{border-color:#a78bfa;color:#a78bfa}
.dbg-btn.purple:hover{background:#1d1a2d}
#dbgFruitGrid{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(58px,1fr));
  gap:4px;margin-top:4px
}
.dbg-fruit-btn{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:5px 2px;border-radius:8px;border:1px solid #30363d;
  background:#161b22;cursor:pointer;font-size:10px;color:#8b949e;
  transition:all .15s;gap:1px
}
.dbg-fruit-btn:hover{background:#21262d;border-color:#8b949e;color:#e6edf3}
.dbg-fruit-btn .dbg-emoji{font-size:18px;line-height:1}
.dbg-fruit-btn .dbg-idx{font-size:9px;opacity:.5}
.dbg-fruit-btn.special{border-color:#a78bfa;background:#1d1a2d}
.dbg-fruit-btn.special:hover{background:#2a2045}
#dbgStatus{
  margin:7px 14px 0;padding:7px 10px;background:#161b22;
  border-radius:7px;font-size:11px;color:#8b949e;
  border:1px solid #21262d;min-height:24px
}
#dbgCloseBtn{
  background:none;border:none;cursor:pointer;color:#8b949e;
  font-size:17px;line-height:1;padding:0;transition:color .15s
}


/* ==========================================
   FALLBACK BUTTON PILL STYLE v3.7.08
   ใช้ตอนรูปปุ่มโหลดไม่สำเร็จ — ให้ทุกปุ่ม fallback หน้าตา/สไตล์เดียวกัน
   (ขอบมน, ตัวหนา, ตัวอักษรขาว, เงานุ่มๆ) ส่วนสี/ขนาดแต่ละปุ่มกำหนดแยกตามจุดเดิม
   ========================================== */
.fb-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  font-family: inherit;
}
