/* ==========================================================================
   JELLY JOY - CANDY CRUSH MATCH-3 DESIGN SYSTEM (DYNAMIC SCREEN FIT)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
  --bg-gradient: linear-gradient(180deg, #9a2cb2 0%, #681594 40%, #a4198c 100%);
  --glass-bg: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 10px 35px rgba(0, 0, 0, 0.5);
  --accent-gold: #ffd15c;
  --accent-pink: #ff3b7b;
  --text-color: #ffffff;
  --font-family: 'Fredoka', 'Outfit', sans-serif;
  
  --cell-size: min(54px, 7.2vh, 11vw);
  --grid-gap: min(4px, 0.5vh);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0.05) 25px, transparent 25px, transparent 50px);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 4px 0;
}

/* Background animated decorative blurred shapes */
.bg-decor {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  animation: floatBg 15s infinite alternate ease-in-out;
}

.bg-decor-1 {
  width: 300px;
  height: 300px;
  background: #ff3b7b;
  top: -60px;
  left: -60px;
}

.bg-decor-2 {
  width: 320px;
  height: 320px;
  background: #7928ca;
  bottom: -80px;
  right: -60px;
  animation-delay: -5s;
}

@keyframes floatBg {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 40px) scale(1.1); }
  100% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Canvas Particle Container */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99;
}

/* Main App Container */
.game-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 95%;
  max-width: 540px;
  max-height: 98vh;
  height: auto;
}

/* Header HUD Bar */
.hud-header {
  width: 100%;
  background: rgba(45, 16, 75, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 18px;
  padding: min(5px, 0.8vh) min(10px, 1.5vw);
  margin-bottom: min(4px, 0.6vh);
  display: flex;
  flex-direction: column;
  gap: min(6px, 0.8vh);
}

.hud-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.moves-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #ff3b7b, #ff758c);
  padding: 2px 10px;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(255, 59, 123, 0.4);
}

.moves-count {
  font-size: min(1.3rem, 2.8vh);
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.moves-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  opacity: 0.9;
}

/* Star Progress Bar */
.progress-container {
  flex: 1;
  margin: 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.star-bar-bg {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: visible;
}

.star-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb800, #ffd15c);
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(255, 209, 92, 0.8);
  transition: width 0.3s ease;
}

.star-node {
  position: absolute;
  top: -6px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.3);
  transition: transform 0.3s ease, color 0.3s ease;
}

.star-node-1 { left: 30%; }
.star-node-2 { left: 60%; }
.star-node-3 { left: 92%; }

.star-node.active {
  color: #ffd15c;
  text-shadow: 0 0 8px rgba(255, 209, 92, 0.9);
  animation: starNodePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes starNodePop {
  0% { transform: scale(0.6); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.score-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-align: center;
}

/* Mascot Character Badge */
.mascot-badge {
  width: 32px;
  height: 32px;
  background: radial-gradient(circle, #ffe14d, #ff9800);
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 3px 10px rgba(255, 152, 0, 0.5);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn-icon:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.25);
}

/* Objective Bar Panel */
.objective-bar {
  width: 100%;
  background: rgba(20, 10, 36, 0.6);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 3px 8px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.target-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.target-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.target-count {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
}

/* Game Board Area */
.board-wrapper {
  position: relative;
  background: rgba(24, 12, 48, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65), inset 0 0 20px rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: min(4px, 0.6vh);
}

.grid-board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--grid-gap);
  position: relative;
}

/* Grid Cell Slot */
.cell-slot {
  width: var(--cell-size);
  height: var(--cell-size);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  cursor: pointer;
}

/* Jelly Pieces - Distinct Candy Shapes */
.jelly {
  width: var(--cell-size);
  height: var(--cell-size);
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  z-index: 2;
}

.jelly svg {
  width: 90%;
  height: 90%;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.4));
  transition: transform 0.2s ease;
  pointer-events: none;
}

.cell-slot:hover .jelly svg {
  transform: scale(1.12);
}

.jelly.selected svg {
  transform: scale(1.22);
  filter: drop-shadow(0 0 14px #ffffff) drop-shadow(0 0 25px rgba(255, 255, 255, 0.9));
  animation: selectedPulse 0.8s infinite alternate ease-in-out;
}

@keyframes selectedPulse {
  0% { transform: scale(1.14); }
  100% { transform: scale(1.24); }
}

.jelly.hint svg {
  animation: hintBounce 0.6s infinite alternate ease-in-out;
}

@keyframes hintBounce {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-5px) scale(1.1); }
}

.jelly.pop {
  animation: jellyPop 0.25s forwards ease-out;
}

@keyframes jellyPop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.8; }
  100% { transform: scale(0); opacity: 0; }
}

/* Special Candy Overlay Markers */
.jelly.special-striped-h::after {
  content: '↔';
  position: absolute;
  font-size: 1.1rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 8px #000000, 0 0 12px #ffffff;
}

.jelly.special-striped-v::after {
  content: '↕';
  position: absolute;
  font-size: 1.1rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 8px #000000, 0 0 12px #ffffff;
}

.jelly.special-wrapped::after {
  content: '💣';
  position: absolute;
  font-size: 0.9rem;
  filter: drop-shadow(0 0 10px #ffffff);
}

.jelly.special-rainbow svg {
  animation: rainbowSpin 3s linear infinite;
  filter: drop-shadow(0 0 12px #ffffff) drop-shadow(0 0 20px #ffd15c);
}

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

/* Bottom Booster Toolbar */
.booster-bar {
  width: 100%;
  background: rgba(36, 16, 62, 0.85); /* Dark background for readability */
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.btn-booster {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  padding: 3px 10px;
  color: white;
  font-family: var(--font-family);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn-booster:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.06);
  background: rgba(255, 255, 255, 0.3);
}

.btn-booster.active {
  background: linear-gradient(135deg, #ff3b7b, #ff758c);
  box-shadow: 0 0 10px rgba(255, 59, 123, 0.7);
}

.btn-booster:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Floating Popup Score Text */
.score-popup {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.9), 0 0 10px var(--accent-gold);
  pointer-events: none;
  z-index: 100;
  animation: floatScore 0.85s forwards ease-out;
}

@keyframes floatScore {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  20% { opacity: 1; transform: translateY(-10px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-35px) scale(1); }
}

/* Modals & Overlays */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 4, 25, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: rgba(36, 16, 62, 0.92);
  border: 2px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  border-radius: 22px;
  width: 90%;
  max-width: 380px;
  padding: 20px 16px;
  text-align: center;
  transform: scale(0.85) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ffd15c, #ff758c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 14px;
}

.star-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
}

.star-icon {
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease, color 0.3s ease;
}

.star-icon.active {
  color: #ffd15c;
  text-shadow: 0 0 15px rgba(255, 209, 92, 0.8);
  animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes starPop {
  0% { transform: scale(0.5) rotate(-20deg); }
  70% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

.btn-primary {
  background: linear-gradient(135deg, #ff3b7b 0%, #d80056 100%);
  border: none;
  color: white;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 24px;
  border-radius: 22px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 59, 123, 0.5);
  margin: 4px 4px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 22px;
  cursor: pointer;
  margin: 4px 4px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.level-item {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.level-num {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-gold);
}

.level-stars {
  font-size: 0.75rem;
  color: #ffd15c;
}

/* Ad Banner Area */
.ad-banner {
    width: 90%;
    max-width: 600px;
    height: 90px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    margin: 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.ad-label {
    position: absolute;
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    pointer-events: none;
}
.ad-bottom { margin-top: auto; margin-bottom: 20px; }
