/* General Styling */
* {
  box-sizing: border-box;
}

body {
  background-color: #312e81;
  background-image: url('assets/bg.svg');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  margin: 0;
  padding: 10px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #333;
}

/* ============================================================
   Mode Selection Screen
   ============================================================ */
#modeSelection {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.menu-card {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  padding: 35px 30px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  animation: fadeInDown 0.4s ease;
}

.menu-badge {
  display: inline-block;
  background: #ff4081;
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.menu-card h2 {
  font-size: 32px;
  margin: 0 0 5px 0;
  color: #d81b60;
  font-weight: 800;
}

.menu-card h3 {
  font-size: 18px;
  margin: 0 0 15px 0;
  color: #455a64;
  font-weight: 700;
}

.menu-desc {
  font-size: 13.5px;
  color: #607d8b;
  line-height: 1.5;
  margin-bottom: 25px;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-mode {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #f1f5f9;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s ease;
  font-family: inherit;
}

.btn-mode:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  border-color: #64b5f6;
  background: #ffffff;
}

.btn-mode.btn-highlight {
  background: linear-gradient(135deg, #ff8008, #ffc837);
  border-color: #ffa000;
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 128, 8, 0.35);
}

.btn-mode.btn-highlight:hover {
  background: linear-gradient(135deg, #ff7200, #ffba20);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(255, 128, 8, 0.45);
}

.btn-mode.btn-highlight .btn-text strong {
  color: #ffffff;
}

.btn-mode.btn-highlight .btn-text small {
  color: rgba(255, 255, 255, 0.9);
}

.btn-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.btn-text strong {
  display: block;
  font-size: 15px;
  color: #1e293b;
  margin-bottom: 2px;
}

.btn-text small {
  display: block;
  font-size: 12px;
  color: #64748b;
}

/* ============================================================
   Level Selection Screen
   ============================================================ */
#levelSelection {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.level-card-panel {
  background: rgba(255, 255, 255, 0.97);
  border-radius: 24px;
  padding: 30px;
  max-width: 650px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  max-height: 90vh;
  overflow-y: auto;
}

.level-card-panel h2 {
  font-size: 26px;
  color: #0284c7;
  margin: 0 0 6px 0;
  font-weight: 800;
}

.level-subtitle {
  font-size: 13.5px;
  color: #64748b;
  margin: 0 0 22px 0;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.level-item-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.level-item-card:hover:not(.locked) {
  transform: translateY(-3px);
  border-color: #38bdf8;
  box-shadow: 0 8px 18px rgba(56, 189, 248, 0.2);
  background: #ffffff;
}

.level-item-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f1f5f9;
}

.level-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.level-num-pill {
  font-size: 11px;
  font-weight: 800;
  background: #0284c7;
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
}

.level-item-stars {
  font-size: 15px;
  letter-spacing: 2px;
  color: #cbd5e1;
}

.level-item-stars .filled {
  color: #f59e0b;
}

.level-item-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 4px 0;
}

.level-item-details {
  font-size: 11.5px;
  color: #64748b;
  margin: 0;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* ============================================================
   Main Game Area
   ============================================================ */
.game-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 25px;
  max-width: 980px;
  width: 100%;
  margin: auto;
}

/* Candy Grid */
.grid {
  display: none;
  flex-wrap: wrap;
  height: 560px;
  width: 560px;
  background: rgba(15, 23, 42, 0.7);
  padding: 5px;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.grid div {
  height: 70px;
  width: 70px;
  background-size: 85%;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 10px;
  cursor: grab;
  transition: transform 0.15s ease;
  user-select: none;
}

.grid div:hover {
  transform: scale(1.12);
  filter: brightness(1.1);
  z-index: 2;
}

.grid div:active {
  cursor: grabbing;
}

/* ============================================================
   Scoreboard & Story Info Panel
   ============================================================ */
.scoreBoard {
  display: none;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  width: 320px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
}

/* Level Info Box */
.level-info-box {
  background: linear-gradient(135deg, #e0f2fe, #f0fdf4);
  border: 1px solid #bae6fd;
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
}

.level-badge {
  display: inline-block;
  background: #0284c7;
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.level-info-box h4 {
  margin: 2px 0 4px 0;
  font-size: 14px;
  color: #0f172a;
}

.level-story-text {
  font-size: 11.5px;
  color: #475569;
  margin: 0;
  line-height: 1.4;
  font-style: italic;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
}

.stat-card {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 2px;
}

.stat-val, .stat-card h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  color: #1e293b;
}

.stat-score h1 {
  font-size: 24px;
  color: #d97706;
}

.stat-moves .stat-val {
  color: #2563eb;
}

/* Progress Bar */
.progress-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  transition: width 0.3s ease;
  border-radius: 5px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: #64748b;
  font-weight: 600;
}

/* Character Humorous Quote Box */
.quote-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fdf4ff;
  border: 1.5px dashed #f0abfc;
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
}

.char-avatar {
  font-size: 26px;
  flex-shrink: 0;
}

.quote-text-container {
  flex-grow: 1;
}

.char-name {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #a21caf;
  margin-bottom: 2px;
}

#characterQuoteText {
  font-size: 11.5px;
  color: #701a75;
  margin: 0;
  line-height: 1.35;
}

/* Finish Early Button */
.btn-finish {
  background: #10b981;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  font-family: inherit;
}

.btn-finish:hover {
  background: #059669;
  transform: translateY(-2px);
}

/* Timer Display (Timed Mode) */
#timer {
  font-size: 16px;
  font-weight: 700;
  color: #dc2626;
  text-align: center;
}

/* Change Mode / Menu Button */
#changeMode {
  background: #e2e8f0;
  color: #334155;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  margin-top: 4px;
}

#changeMode:hover {
  background: #cbd5e1;
}

/* ============================================================
   Win / Lose Result Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 35px 25px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  animation: zoomIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-icon {
  font-size: 54px;
  margin-bottom: 5px;
}

.modal-card h2 {
  font-size: 24px;
  margin: 0 0 12px 0;
  font-weight: 800;
}

.modal-card.win h2 {
  color: #10b981;
}

.modal-card.lose h2 {
  color: #ef4444;
}

/* Star Rating 1-3 */
.stars-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stars-display .star {
  font-size: 46px;
  color: #e2e8f0;
  transition: transform 0.3s ease, color 0.3s ease;
  user-select: none;
  line-height: 1;
}

.stars-display .star.active {
  color: #f59e0b;
  text-shadow: 0 0 16px rgba(245, 158, 11, 0.7);
  animation: starPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes starPop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.35); }
  100% { transform: scale(1); opacity: 1; }
}

.result-quote {
  font-size: 13.5px;
  color: #475569;
  line-height: 1.45;
  margin: 0 0 20px 0;
  font-style: italic;
  background: #f8fafc;
  padding: 10px 14px;
  border-radius: 12px;
  border-left: 3px solid #0284c7;
}

/* Result Stats Row */
.result-stats {
  display: flex;
  justify-content: space-around;
  background: #f1f5f9;
  border-radius: 14px;
  padding: 12px 10px;
  margin-bottom: 22px;
}

.res-stat-item span {
  display: block;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 2px;
}

.res-stat-item strong {
  display: block;
  font-size: 20px;
  color: #1e293b;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-modal {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-next {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
}

.btn-retry {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}

.btn-retry:hover {
  transform: translateY(-2px);
}

.btn-menu {
  background: #f1f5f9;
  color: #475569;
}

.btn-menu:hover {
  background: #e2e8f0;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 920px) {
  .game-wrapper {
    flex-direction: column;
    align-items: center;
  }

  .scoreBoard {
    width: 560px;
  }
}

@media (max-width: 600px) {
  .grid {
    width: 360px;
    height: 360px;
  }
  .grid div {
    width: 45px;
    height: 45px;
  }
  .scoreBoard {
    width: 360px;
  }
}

/* ============================================================
   Candy Explosion Animation & Particle Effects
   ============================================================ */
.candy-burst {
  position: absolute;
  width: 70px;
  height: 70px;
  background-size: 85%;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 10;
  animation: candyExplodePop 0.38s ease-out forwards;
}

@keyframes candyExplodePop {
  0% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1.7) drop-shadow(0 0 12px rgba(255, 255, 255, 0.95));
    opacity: 1;
  }
  45% {
    transform: scale(1.35) rotate(10deg);
    filter: brightness(2.2) drop-shadow(0 0 20px rgba(255, 220, 100, 1));
    opacity: 0.95;
  }
  100% {
    transform: scale(0) rotate(-20deg);
    filter: brightness(2.5);
    opacity: 0;
  }
}

/* Flying Candy Shards */
.candy-shard {
  position: absolute;
  width: 24px;
  height: 24px;
  top: 23px;
  left: 23px;
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: 50%;
  pointer-events: none;
}

.shard-0 { animation: flyShard0 0.4s cubic-bezier(0.2, 0.9, 0.4, 1) forwards; }
.shard-1 { animation: flyShard1 0.4s cubic-bezier(0.2, 0.9, 0.4, 1) forwards; }
.shard-2 { animation: flyShard2 0.4s cubic-bezier(0.2, 0.9, 0.4, 1) forwards; }
.shard-3 { animation: flyShard3 0.4s cubic-bezier(0.2, 0.9, 0.4, 1) forwards; }

@keyframes flyShard0 {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-38px, -38px) scale(0) rotate(180deg); opacity: 0; }
}
@keyframes flyShard1 {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(38px, -38px) scale(0) rotate(-180deg); opacity: 0; }
}
@keyframes flyShard2 {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-38px, 38px) scale(0) rotate(180deg); opacity: 0; }
}
@keyframes flyShard3 {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(38px, 38px) scale(0) rotate(-180deg); opacity: 0; }
}

/* Floating Score Indicator */
.floating-score {
  position: absolute;
  font-size: 19px;
  font-weight: 800;
  color: #fef08a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), 0 0 12px #f59e0b;
  pointer-events: none;
  z-index: 15;
  animation: floatScoreUp 0.6s ease-out forwards;
}

@keyframes floatScoreUp {
  0% {
    transform: translateY(0) scale(0.6);
    opacity: 0;
  }
  25% {
    transform: translateY(-12px) scale(1.3);
    opacity: 1;
  }
  100% {
    transform: translateY(-42px) scale(0.9);
    opacity: 0;
  }
}

/* Gentle Grid Recoil / Shake */
.grid.grid-shake {
  animation: gridMicroShake 0.22s ease-in-out;
}

@keyframes gridMicroShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 2px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
}

/* ============================================================
   Mute Buttons (Global & In-Game)
   ============================================================ */
.global-mute-btn {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid #e2e8f0;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 22px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  user-select: none;
}

.global-mute-btn:hover {
  transform: scale(1.12);
  background: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.4);
}

.global-mute-btn.muted {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.score-mute-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.score-mute-btn:hover {
  background: #e2e8f0;
}

.score-mute-btn.muted {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ============================================================
   Special Candies: Striped (Match 4) & Bomb (Match 5)
   ============================================================ */

/* Permen Bergaris (Striped Candy) */
.grid div.striped-candy {
  position: relative;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9));
  animation: stripePulse 1.4s infinite alternate ease-in-out;
}

.grid div.striped-candy::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.95) 0px,
    rgba(255, 255, 255, 0.95) 4px,
    transparent 4px,
    transparent 11px
  );
  pointer-events: none;
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.85);
}

@keyframes stripePulse {
  from { transform: scale(1); filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8)); }
  to { transform: scale(1.06); filter: drop-shadow(0 0 14px rgba(56, 189, 248, 1)); }
}

/* Bom Permen (Bomb Candy - Area 3x3) */
.grid div.bomb-candy {
  position: relative;
  animation: bombWiggle 1.3s infinite ease-in-out;
}

.grid div.bomb-candy::after {
  content: '💣';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 0 10px rgba(255, 69, 0, 0.95));
  animation: bombGlow 0.8s infinite alternate;
}

@keyframes bombWiggle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes bombGlow {
  from { filter: drop-shadow(0 0 6px rgba(255, 140, 0, 0.8)); }
  to { filter: drop-shadow(0 0 16px rgba(255, 0, 0, 1)) scale(1.15); }
}

/* Laser Row Beam (Striped Candy Clears 1 Row) */
.row-laser-beam {
  position: absolute;
  left: 0;
  width: 100%;
  height: 70px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.95) 20%,
    #38bdf8 50%,
    rgba(255, 255, 255, 0.95) 80%,
    transparent 100%
  );
  box-shadow: 0 0 25px #38bdf8, 0 0 50px #0284c7;
  pointer-events: none;
  z-index: 25;
  animation: laserSweep 0.45s ease-out forwards;
}

@keyframes laserSweep {
  0% { transform: scaleX(0); opacity: 0; }
  25% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1) scaleY(0.15); opacity: 0; }
}

/* 3x3 Bomb Shockwave (Bomb Clears 3x3 Area) */
.bomb-shockwave {
  position: absolute;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 215, 0, 0.9) 30%,
    rgba(255, 69, 0, 0.85) 60%,
    transparent 78%
  );
  box-shadow: 0 0 45px #ff4500, inset 0 0 35px #fff;
  pointer-events: none;
  z-index: 25;
  transform: translate(-50%, -50%);
  animation: shockwaveExpand 0.52s ease-out forwards;
}

@keyframes shockwaveExpand {
  0% { transform: translate(-50%, -50%) scale(0.15); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}

/* Special Notice Banner */
.special-notice-banner {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.5);
  pointer-events: none;
  z-index: 35;
  white-space: nowrap;
  animation: bannerPop 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bannerPop {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  25% { transform: translateX(-50%) scale(1.12); opacity: 1; }
  75% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.85); opacity: 0; }
}

/* Special Candies Guide Box in Scoreboard */
.special-guide-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.guide-item {
  font-size: 11px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  color: white;
  display: inline-block;
}

.guide-badge.striped {
  background: #0284c7;
}

.guide-badge.bomb {
  background: #dc2626;
}

/* ============================================================
   Boss Battle UI: Panel, HP Bar, Avatar & Taunts
   ============================================================ */
.boss-panel {
  background: linear-gradient(135deg, #1e1b4b, #450a0a);
  border: 2px solid #ef4444;
  border-radius: 16px;
  padding: 12px 14px;
  color: white;
  text-align: left;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
  animation: bossEntry 0.5s ease-out;
}

@keyframes bossEntry {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.boss-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.boss-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.boss-avatar {
  font-size: 38px;
  display: block;
  animation: bossFloat 2s infinite ease-in-out;
}

@keyframes bossFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.boss-avatar.hit {
  animation: bossHurt 0.35s ease-in-out;
}

@keyframes bossHurt {
  0%, 100% { transform: translate(0, 0) scale(1); filter: brightness(1); }
  25% { transform: translate(-4px, 4px) scale(0.9); filter: brightness(2) drop-shadow(0 0 10px #ff0000); }
  50% { transform: translate(4px, -4px) scale(1.1); filter: brightness(2.5); }
  75% { transform: translate(-3px, -2px) scale(0.95); }
}

.boss-dmg-float {
  position: absolute;
  top: -12px;
  right: -10px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.8);
  animation: dmgFloat 0.6s ease-out forwards;
}

@keyframes dmgFloat {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  30% { transform: translateY(-8px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-20px) scale(0.9); opacity: 0; }
}

.boss-meta {
  flex-grow: 1;
}

.boss-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.boss-badge {
  background: #dc2626;
  color: white;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.boss-title-row strong {
  font-size: 13px;
  color: #fecaca;
}

.boss-hp-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.boss-hp-bar {
  width: 100%;
  height: 12px;
  background: #27272a;
  border-radius: 6px;
  border: 1px solid #7f1d1d;
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  border-radius: 6px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.boss-hp-stats {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: #cbd5e1;
}

.boss-attack-tracker {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #fde047;
}

.boss-dialog-bubble {
  background: rgba(255, 255, 255, 0.1);
  border-left: 3px solid #f87171;
  border-radius: 6px;
  padding: 6px 8px;
}

#bossTauntText {
  margin: 0;
  font-size: 11px;
  color: #fecdd3;
  line-height: 1.35;
  font-style: italic;
}

/* ============================================================
   Obstacle Candy (Rintangan Kolesterol / Batu Gula)
   ============================================================ */
.grid div.obstacle-candy {
  position: relative;
  background-color: #334155 !important;
  border-radius: 12px;
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.25), 0 4px 10px rgba(0, 0, 0, 0.6);
  cursor: not-allowed !important;
  animation: obstacleLand 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes obstacleLand {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  70% { transform: scale(1.15) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.grid div.obstacle-candy::after {
  content: '🪨';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

/* Card Badge for Boss Level in Level Grid */
.level-item-card.boss-level {
  border-color: #ef4444;
  background: linear-gradient(135deg, #fff1f2, #fef2f2);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2);
}

.level-item-card.boss-level .level-num-pill {
  background: #dc2626;
}

/* "Tantang Ulang" Button in Result Modal */
.btn-boss-retry {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.45);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  animation: retryPulse 1.4s infinite alternate;
}

.btn-boss-retry:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.6);
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

@keyframes retryPulse {
  from { box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4); }
  to { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.7); }
}

/* ============================================================
   Combo Popups (Double Combo, Triple Combo, SWEET GOD MODE)
   ============================================================ */
.combo-popup-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-radius: 50px;
  z-index: 60;
  pointer-events: none;
  animation: comboPopAnimation 1.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.combo-popup-banner .combo-icon {
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.combo-popup-banner .combo-text-wrapper {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.combo-popup-banner .combo-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.combo-popup-banner .combo-bonus {
  font-size: 13px;
  font-weight: 800;
  color: #fff9c4;
  letter-spacing: 1px;
}

/* Tier 2: Double Combo */
.combo-popup-banner.combo-level-2 {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border: 3px solid #fef08a;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
}

/* Tier 3: Triple Combo */
.combo-popup-banner.combo-level-3 {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  border: 3px solid #fbcfe8;
  box-shadow: 0 0 35px rgba(236, 72, 153, 0.7);
}
.combo-popup-banner.combo-level-3 .combo-title {
  font-size: 25px;
}

/* Tier 4+: SWEET GOD MODE! */
.combo-popup-banner.combo-level-god {
  background: linear-gradient(135deg, #eab308, #f97316, #ef4444);
  border: 4px solid #ffffff;
  padding: 16px 30px;
  box-shadow: 0 0 45px rgba(250, 204, 21, 0.95), inset 0 0 20px rgba(255, 255, 255, 0.5);
  animation: sweetGodAnimation 1.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.combo-popup-banner.combo-level-god .combo-title {
  font-size: 28px;
  color: #fff;
  text-shadow: 0 0 12px #ffe066, 0 3px 6px rgba(0, 0, 0, 0.8);
  letter-spacing: 1px;
}
.combo-popup-banner.combo-level-god .combo-icon {
  font-size: 46px;
  animation: godIconSpin 0.9s infinite alternate;
}

@keyframes comboPopAnimation {
  0% {
    transform: translate(-50%, -50%) scale(0.3) rotate(-8deg);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.15) rotate(3deg);
    opacity: 1;
  }
  35% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  75% {
    transform: translate(-50%, -50%) scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -75%) scale(0.85);
    opacity: 0;
  }
}

@keyframes sweetGodAnimation {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.25);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -85%) scale(0.9);
    opacity: 0;
  }
}

@keyframes godIconSpin {
  from { transform: scale(1) rotate(-8deg); }
  to { transform: scale(1.2) rotate(8deg); }
}

/* ============================================================
   Leaderboard Modal & Table Styling
   ============================================================ */
.modal-card.lb-card {
  max-width: 620px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 20px 24px;
}

.lb-header {
  text-align: center;
}

.lb-header h2 {
  font-size: 22px;
  color: #1e293b;
  margin: 6px 0 2px 0;
  font-weight: 800;
}

.lb-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 16px 0;
}

.lb-table-container {
  overflow-y: auto;
  max-height: 360px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
  background: #ffffff;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.lb-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 2px solid #e2e8f0;
  z-index: 2;
}

.lb-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.lb-table tbody tr:hover {
  background: #f8fafc;
}

.lb-table tbody tr.rank-1 {
  background: #fffbeb;
  font-weight: 600;
}
.lb-table tbody tr.rank-2 {
  background: #f8fafc;
  font-weight: 600;
}
.lb-table tbody tr.rank-3 {
  background: #fff7ed;
  font-weight: 600;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.lb-score-val {
  color: #059669;
  font-weight: 800;
  font-size: 15px;
}

.lb-date-val {
  color: #94a3b8;
  font-size: 11px;
}

.lb-footer {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.btn-reset-lb {
  background: #f1f5f9;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-size: 13px;
  padding: 10px 16px;
}

.btn-reset-lb:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* In-game Leaderboard Button */
.score-lb-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.3);
}

.score-lb-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(217, 119, 6, 0.4);
}

.btn-mode-lb {
  border-color: #fde68a !important;
  background: linear-gradient(135deg, #fffbeb, #fef3c7) !important;
}

.btn-mode-lb:hover {
  border-color: #f59e0b !important;
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
}

/* New Highscore Box in Result Modal */
.new-highscore-box {
  background: #f0fdf4;
  border: 2px dashed #86efac;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 15px;
  text-align: center;
  animation: pulseGreen 1.5s infinite alternate;
}

@keyframes pulseGreen {
  from { box-shadow: 0 0 0 rgba(34, 197, 94, 0.2); }
  to { box-shadow: 0 0 12px rgba(34, 197, 94, 0.4); }
}

.hs-badge {
  display: inline-block;
  background: #16a34a;
  color: white;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 4px;
}

.new-highscore-box p {
  margin: 3px 0 8px 0;
  font-size: 12.5px;
  color: #166534;
  font-weight: 600;
}

.hs-input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.hs-input-row input {
  flex: 1;
  max-width: 220px;
  padding: 8px 12px;
  border: 1px solid #86efac;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #14532d;
  outline: none;
}

.hs-input-row input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.btn-save-hs {
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-save-hs:hover {
  background: #15803d;
}

.btn-modal-lb {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}
.btn-modal-lb:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* ============================================================
   Hint Button & Highlighting
   ============================================================ */
.score-hint-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.25s ease;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.score-hint-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.55);
}

.score-hint-btn:active {
  transform: translateY(0);
}

/* Hint Highlighting on Grid Squares */
.grid div.hint-highlight {
  outline: 4px solid #fef08a !important;
  box-shadow: 0 0 22px #facc15, inset 0 0 14px rgba(254, 240, 138, 0.85) !important;
  border-radius: 14px;
  z-index: 25;
  animation: hintPulse 0.85s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes hintPulse {
  0% {
    transform: scale(0.96);
    outline-color: #fde047;
    box-shadow: 0 0 12px #facc15;
  }
  100% {
    transform: scale(1.08);
    outline-color: #ffffff;
    box-shadow: 0 0 28px #f59e0b, 0 0 10px #ffffff;
  }
}

/* ============================================================
   Board Shuffle Animations & Announcement
   ============================================================ */
.grid.shuffling div {
  animation: shuffleSpin 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes shuffleSpin {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.2) rotate(180deg);
    opacity: 0.3;
  }
  100% {
    transform: scale(1) rotate(360deg);
    opacity: 1;
  }
}

.shuffle-notice-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  border: 3px solid #7dd3fc;
  box-shadow: 0 8px 30px rgba(2, 132, 199, 0.65);
  padding: 14px 24px;
  border-radius: 40px;
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  z-index: 65;
  pointer-events: none;
  animation: fadeInDown 0.35s ease forwards;
  line-height: 1.4;
}
