/* ==========================================================================
   FAST FOOD MATCH 3 - Dedicated Stylesheet
   Modern, responsive, glossy 3D cartoon aesthetic for Tyspingo
   ========================================================================== */

:root {
  --ff-primary: #f59e0b;
  --ff-primary-glow: rgba(245, 158, 11, 0.5);
  --ff-accent: #ef4444;
  --ff-cyan: #00f3ff;
  --ff-pink: #ec4899;
  --ff-green: #22c55e;
  --ff-board-bg: rgba(15, 23, 42, 0.92);
  --ff-cell-bg: rgba(30, 41, 59, 0.75);
  --ff-cell-border: rgba(255, 255, 255, 0.08);
  --ff-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

/* Page Container */
.match3-page-wrapper {
  min-height: calc(100vh - 65px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.75rem 0.5rem 1.5rem 0.5rem;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 60%, #030712 100%);
  color: #f8fafc;
  overflow-x: hidden;
  position: relative;
  box-sizing: border-box;
}

/* Screens Toggle */
.match3-screen {
  display: none;
  width: 100%;
  max-width: 680px;
  flex-direction: column;
  align-items: center;
  animation: ffFadeIn 0.25s ease-out;
}

.match3-screen.active {
  display: flex;
}

@keyframes ffFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   SCREEN 1: HOME / HERO SCREEN
   ========================================================================== */
.ff-home-card {
  width: 100%;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  margin-top: 0.5rem;
  box-sizing: border-box;
}

.ff-banner-img {
  width: 100%;
  max-width: 460px;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(245, 158, 11, 0.25);
  margin-bottom: 1.25rem;
  transition: transform 0.3s ease;
}

.ff-banner-img:hover {
  transform: scale(1.02);
}

.ff-home-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fef08a 0%, #facc15 40%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.ff-home-desc {
  font-size: 1.05rem;
  color: #cbd5e1;
  max-width: 480px;
  margin: 0 auto 1.5rem auto;
  line-height: 1.5;
}

.ff-home-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.ff-btn-hero {
  font-size: 1.15rem;
  padding: 0.85rem 1.5rem;
  font-weight: 800;
  border-radius: 9999px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.ff-btn-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(245, 158, 11, 0.6);
}

.ff-btn-secondary {
  font-size: 1rem;
  padding: 0.7rem 1.25rem;
  font-weight: 700;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  text-decoration: none;
}

.ff-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.ff-home-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ff-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ff-stat-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: #facc15;
}

.ff-stat-lbl {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   SCREEN 2: WORLD & LEVEL SELECTION MAP (50 Levels)
   ========================================================================== */
.map-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.map-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
}

.world-tabs {
  display: flex;
  width: 100%;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.world-tab {
  flex: 1;
  min-width: 100px;
  padding: 0.6rem 0.4rem;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.world-tab.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.05) 100%);
  border-color: #f59e0b;
  color: #facc15;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

.world-tab .world-icon {
  font-size: 1.15rem;
}

.levels-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.level-node {
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 0.75rem 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  user-select: none;
}

.level-node.unlocked {
  cursor: pointer;
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(245, 158, 11, 0.35);
}

.level-node.unlocked:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.3);
}

.level-node.current {
  border-color: #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.6);
  animation: pulseCurrent 1.6s infinite alternate;
}

@keyframes pulseCurrent {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

.level-node.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.level-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.level-node.unlocked .level-circle {
  background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%);
  border-color: #fef08a;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.level-stars {
  display: flex;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: #475569;
}

.level-star.earned {
  color: #facc15;
  text-shadow: 0 0 6px rgba(250, 204, 21, 0.8);
}

.level-score-preview {
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 600;
}

/* ==========================================================================
   SCREEN 3: GAMEPLAY SCREEN & REDESIGNED HUD
   ========================================================================== */
.gameplay-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* 1. Top Bar: Level Meta & Control Strip (Non-overlapping, cleanly separated) */
.game-top-bar {
  width: 100%;
  max-width: 500px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-sizing: border-box;
}

.game-level-meta {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.game-level-number {
  font-size: 1.15rem;
  font-weight: 900;
  color: #facc15;
  letter-spacing: 0.5px;
}

.game-world-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
}

.game-control-strip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Uniform Buttons for Sound, Music, Pause */
.ff-ctrl-btn {
  height: 34px;
  padding: 0 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
  user-select: none;
}

.ff-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.ff-ctrl-btn:active {
  transform: translateY(0);
}

.ctrl-icon {
  font-size: 0.95rem;
  line-height: 1;
}

/* 2. Stats HUD (Moves Box, Target Orders, Score Box) */
.game-stats-hud {
  width: 100%;
  max-width: 500px;
  display: grid;
  grid-template-columns: 80px 1fr 120px;
  gap: 0.5rem;
  align-items: stretch;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 0.5rem 0.65rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.hud-stat-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.4rem;
  box-sizing: border-box;
}

/* Moves Box */
.moves-box {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.85) 0%, rgba(185, 28, 28, 0.95) 100%);
  border-color: #fca5a5;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

.hud-stat-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fee2e2;
  letter-spacing: 0.5px;
}

.hud-stat-num {
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  margin-top: 0.1rem;
}

/* Objectives Target Orders Panel */
.hud-objectives-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.35rem 0.5rem;
  overflow: hidden;
}

.hud-panel-title {
  font-size: 0.65rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.hud-objectives-grid {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.hud-obj-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  padding: 0.2rem 0.5rem;
  transition: all 0.2s ease;
}

.hud-obj-item.completed {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.25);
}

.hud-obj-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.hud-obj-text {
  font-size: 0.8rem;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: 0.2px;
}

.hud-obj-item.completed .hud-obj-text {
  color: #4ade80;
}

/* Score Box */
.score-box {
  padding: 0.35rem 0.5rem;
  justify-content: space-between;
}

.score-top-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.score-box .hud-stat-label {
  color: #cbd5e1;
}

.hud-score-num {
  font-size: 1.25rem;
  font-weight: 900;
  color: #facc15;
  line-height: 1.1;
}

.hud-star-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 9999px;
  position: relative;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 0.2rem;
}

.hud-star-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b 0%, #ec4899 50%, #00f3ff 100%);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.hud-star-milestones {
  position: absolute;
  inset: -6px 0 0 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.star-milestone {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1;
}

.star-milestone.active {
  color: #facc15;
  text-shadow: 0 0 6px rgba(250, 204, 21, 0.9);
}

/* ==========================================================================
   MAIN GAME BOARD (8 x 8)
   ========================================================================== */
.board-wrapper {
  position: relative;
  width: min(94vw, 470px);
  max-width: 470px;
  aspect-ratio: 1 / 1;
  background: var(--ff-board-bg);
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.08);
  overflow: hidden;
  touch-action: none; /* Prevents mobile scroll during swipe */
  user-select: none;
  box-sizing: border-box;
}

.match3-board {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 3px;
}

/* Board Cell */
.match3-cell {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--ff-cell-bg);
  border-radius: 8px;
  border: 1px solid var(--ff-cell-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.12s ease;
  box-sizing: border-box;
}

.match3-cell:hover {
  background: rgba(51, 65, 85, 0.6);
}

/* Hammer Targeting Cursor */
.match3-board.targeting-hammer .match3-cell {
  cursor: crosshair;
  animation: cellPulseTarget 0.8s infinite alternate;
}

@keyframes cellPulseTarget {
  from { border-color: rgba(245, 158, 11, 0.3); }
  to { border-color: rgba(245, 158, 11, 0.95); }
}

/* Food Tile Item */
.food-tile {
  position: absolute;
  inset: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  z-index: 2;
  transition: transform 0.18s ease-out;
  box-sizing: border-box;
}

.tile-food-img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}

/* Selection Highlight Effect (STEP 1) */
.food-tile.selected {
  outline: 3px solid #facc15;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.85);
  transform: scale(1.08);
  z-index: 6;
  animation: tileSelectedPulse 0.9s infinite alternate;
}

@keyframes tileSelectedPulse {
  from { transform: scale(1.05); }
  to { transform: scale(1.12); }
}

/* Match Highlight Flash (STEP 3) */
.food-tile.match-highlight {
  transform: scale(1.16);
  filter: brightness(1.6) drop-shadow(0 0 14px #facc15);
  z-index: 8;
  transition: transform 0.12s ease-out, filter 0.12s ease-out;
}

/* Match Destruction & Pop (STEP 4) */
.food-tile.destroying {
  transform: scale(0.1) rotate(15deg) !important;
  opacity: 0 !important;
  filter: brightness(2) !important;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease-out !important;
}

/* Obstacles Layer */
.obstacle-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.stone-img { z-index: 4; }
.crate-img { z-index: 4; }
.ice-img { z-index: 5; pointer-events: none; }
.sauce-img { z-index: 1; opacity: 0.85; }

.locked-overlay-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.special-overlay-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  animation: specialElectricPulse 1.2s infinite alternate;
}

@keyframes specialElectricPulse {
  0% { transform: scale(0.95); opacity: 0.8; filter: drop-shadow(0 0 4px #00f3ff); }
  100% { transform: scale(1.05); opacity: 1; filter: drop-shadow(0 0 10px #00f3ff); }
}

.special-rainbow {
  animation: rainbowSpin 6s linear infinite;
}

@keyframes rainbowSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Floating Scores & Combo Labels */
.floating-text-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 20;
}

.floating-score-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'Impact', 'Arial Black', system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 10px currentColor;
  letter-spacing: 1px;
  animation: floatUpFade 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  white-space: nowrap;
}

@keyframes floatUpFade {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.2); }
  80% { opacity: 1; transform: translate(-50%, -110%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(0.8); }
}

/* Match Burst Particles */
.match-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 25;
  animation: particleBurstAnim 0.3s ease-out forwards;
}

@keyframes particleBurstAnim {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* Tutorial Overlay */
.tutorial-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  z-index: 30;
  border-radius: 18px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.tutorial-overlay.active {
  display: flex;
}

.tutorial-tooltip {
  background: rgba(30, 41, 59, 0.95);
  border: 2px solid #facc15;
  border-radius: 18px;
  padding: 1.5rem;
  max-width: 320px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.tutorial-tooltip h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #facc15;
  margin-bottom: 0.5rem;
}

.tutorial-tooltip p {
  font-size: 0.95rem;
  color: #e2e8f0;
  line-height: 1.4;
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   BOOSTERS ACTION BAR (Bottom Bar)
   ========================================================================== */
.boosters-bar {
  width: 100%;
  max-width: 500px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 0.45rem 0.4rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.booster-action-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.4rem 0.25rem;
  border-radius: 12px;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 48px;
}

.booster-action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.booster-action-btn:active {
  transform: translateY(0);
}

.booster-action-btn.active {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.2);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5);
}

.booster-icon-container {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.booster-icon-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
}

.booster-qty-badge {
  position: absolute;
  top: -3px;
  right: -5px;
  background: #facc15;
  color: #78350f;
  font-size: 0.75rem;
  font-weight: 900;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.booster-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
}

/* ==========================================================================
   MODALS (Victory, Loss, Pause, Tutorial)
   ========================================================================== */
.ff-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ff-modal-backdrop.active {
  display: flex;
  animation: ffModalFadeIn 0.25s ease-out;
}

@keyframes ffModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ff-modal-card {
  width: 100%;
  max-width: 420px;
  background: rgba(30, 41, 59, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  animation: ffModalPop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  box-sizing: border-box;
}

@keyframes ffModalPop {
  to { transform: scale(1); }
}

.win-modal-card {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 40px rgba(250, 204, 21, 0.25);
}

.modal-title {
  font-size: 1.85rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
  letter-spacing: 0.5px;
}

.win-title {
  background: linear-gradient(135deg, #fef08a 0%, #facc15 50%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lose-title {
  color: #f87171;
}

.win-stars-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 2.8rem;
  color: #475569;
  margin: 0.75rem 0;
}

.win-star.earned {
  color: #facc15;
  text-shadow: 0 0 15px rgba(250, 204, 21, 0.9);
  animation: starPop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4) forwards;
}

@keyframes starPop {
  0% { transform: scale(0.2); }
  70% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.modal-stat-box {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 14px;
  padding: 0.75rem;
  margin: 1rem 0;
  display: flex;
  justify-content: space-around;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-stat-val {
  font-size: 1.35rem;
  font-weight: 900;
  color: #facc15;
}

.modal-stat-lbl {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.tutorial-guide-content {
  text-align: left;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 0.5rem;
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.45;
}

.tutorial-guide-content h4 {
  color: #facc15;
  font-size: 1rem;
  margin: 0.85rem 0 0.35rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tutorial-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  background: rgba(15, 23, 42, 0.5);
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
}

.tutorial-item-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ==========================================================================
   MOBILE & VIEWPORT RESPONSIVENESS
   ========================================================================== */
@media (max-width: 480px) {
  .match3-page-wrapper {
    padding: 0.4rem 0.25rem 1rem 0.25rem;
  }

  .gameplay-container {
    gap: 0.4rem;
  }

  .game-top-bar {
    padding: 0.35rem 0.5rem;
  }

  .game-level-number {
    font-size: 1.05rem;
  }

  .game-world-title {
    font-size: 0.75rem;
  }

  /* Compact Audio / Pause Buttons on Mobile */
  .ff-ctrl-btn {
    height: 32px;
    padding: 0 0.45rem;
    font-size: 0.75rem;
  }

  .game-stats-hud {
    grid-template-columns: 70px 1fr 105px;
    padding: 0.4rem 0.5rem;
    gap: 0.35rem;
  }

  .hud-stat-num {
    font-size: 1.35rem;
  }

  .hud-score-num {
    font-size: 1.1rem;
  }

  .hud-obj-item {
    padding: 0.15rem 0.4rem;
  }

  .hud-obj-icon {
    width: 18px;
    height: 18px;
  }

  .hud-obj-text {
    font-size: 0.75rem;
  }

  .board-wrapper {
    width: min(96vw, 420px);
    padding: 4px;
    border-radius: 16px;
  }

  .match3-board {
    gap: 2.5px;
  }

  .match3-cell {
    border-radius: 6px;
  }

  .boosters-bar {
    padding: 0.35rem 0.25rem;
    gap: 0.35rem;
  }

  .booster-action-btn {
    padding: 0.3rem 0.2rem;
    min-height: 44px;
  }

  .booster-icon-container {
    width: 32px;
    height: 32px;
  }

  .booster-title {
    font-size: 0.65rem;
  }

  .levels-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .level-circle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

/* Short screens (e.g. 428x509, landscape, or small devices) */
@media (max-height: 650px) {
  .match3-page-wrapper {
    padding: 0.25rem 0.25rem 0.75rem 0.25rem;
  }

  .gameplay-container {
    gap: 0.25rem;
  }

  .game-top-bar {
    padding: 0.25rem 0.4rem;
  }

  .game-stats-hud {
    padding: 0.25rem 0.4rem;
  }

  .board-wrapper {
    width: min(92vw, 360px);
  }

  .boosters-bar {
    padding: 0.25rem 0.2rem;
  }

  .booster-action-btn {
    min-height: 40px;
  }

  .booster-icon-container {
    width: 28px;
    height: 28px;
  }
}
