@import url("https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;800&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: "Nunito", sans-serif;
  background: #1a0d00;
  touch-action: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(700px, 98vw);
}

#fruitcontainer {
  position: relative;
  width: 100%;
  height: min(480px, 64vh);
  cursor: none;
  
  overflow: hidden;
  border-radius: 10px;
  user-select: none;
  touch-action: none;

  
  background-color: #3b1f08;
  background-image:
    
    radial-gradient(ellipse 40px 60px at 18% 35%, rgba(0, 0, 0, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 30px 50px at 75% 70%, rgba(0, 0, 0, 0.14) 0%, transparent 65%),
    radial-gradient(ellipse 25px 40px at 55% 20%, rgba(0, 0, 0, 0.12) 0%, transparent 60%),
    
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0.22) 0px, rgba(0, 0, 0, 0.04) 2px,
      transparent 3px, transparent 88px,
      rgba(0, 0, 0, 0.18) 88px, rgba(0, 0, 0, 0.04) 90px,
      transparent 91px, transparent 178px,
      rgba(0, 0, 0, 0.22) 178px),
    
    repeating-linear-gradient(180deg,
      rgba(255, 180, 80, 0.025) 0px, transparent 4px,
      rgba(0, 0, 0, 0.05) 5px, transparent 9px,
      rgba(255, 160, 60, 0.02) 10px, transparent 14px),
    
    linear-gradient(180deg, #2a1304 0%, #4a2408 35%, #3a1c06 65%, #251002 100%);

  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.6),
    inset 0 2px 0 rgba(255, 200, 80, 0.08),
    0 8px 40px rgba(0, 0, 0, 0.8);
}

.bg-slashes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.9;
}

#score-overlay {
  position: absolute;
  top: 14px;
  left: 18px;
  z-index: 20;
  pointer-events: none;
}

#scoreValue {
  font-family: "Fredoka One", cursive;
  font-size: 3rem;
  color: #f59e0b;
  text-shadow:
    0 0 20px rgba(245, 158, 11, 0.6),
    2px 2px 0 rgba(0, 0, 0, 0.6),
    -1px -1px 0 rgba(180, 100, 0, 0.4);
  line-height: 1;
}

#lives-overlay {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 20;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.life {
  font-size: 2rem;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5), 0 0 10px rgba(239, 68, 68, 0.5);
  transition: opacity 0.3s, color 0.3s;
  line-height: 1;
  display: block;
}

.life.lost {
  color: #4b5563;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
  opacity: 0.4;
}

#btn-sound {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 20;
  width: 46px;
  height: 46px;
  background: linear-gradient(145deg, #8b5e1a, #5c3a0a);
  border: 2px solid rgba(255, 200, 80, 0.3);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 0 #3a2200, 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: all 0.15s;
}

#btn-sound:hover {
  background: linear-gradient(145deg, #a06d20, #6e4510);
}

#btn-sound:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #3a2200;
}

#btn-sound svg {
  width: 24px;
  height: 24px;
  fill: #f59e0b;
}

#btn-sound.muted svg {
  fill: #6b7280;
}

.fruit {
  display: none;
  position: absolute;
  width: 80px;
  height: 80px;
  object-fit: contain;
  z-index: 5;
  pointer-events: none;
  
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 4px rgba(255, 140, 0, 0.2));
  will-change: top;
  -webkit-user-drag: none;
}

.fruit-half {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  will-change: transform, opacity;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.4, 1),
    opacity 0.55s ease;
}

#juice-splat {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transform: scale(0);
  transition: none;
}

#juice-splat.active {
  animation: splatAnim 0.4s ease forwards;
}

@keyframes splatAnim {
  0% {
    opacity: 0.9;
    transform: scale(0);
  }

  40% {
    opacity: 0.7;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}

#blade-cursor {
  position: absolute;
  width: 28px;
  height: 28px;
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -50%) rotate(-45deg);
  opacity: 0;
  transition: opacity 0.2s;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
}

#blade-cursor.visible {
  opacity: 1;
}

#blade-cursor.slicing {
  filter: drop-shadow(0 0 12px rgba(251, 191, 36, 1)) drop-shadow(0 0 4px #fff);
}

#sliceCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#front {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 30;
  background: rgba(10, 4, 0, 0.65);
  backdrop-filter: blur(4px);
}

.front-inner {
  text-align: center;
  padding: 36px 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(245, 158, 11, 0.25);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
}

.splash-emoji {
  font-size: 2.8rem;
  letter-spacing: 10px;
  margin-bottom: 14px;
  animation: floatE 2.6s ease-in-out infinite;
}

@keyframes floatE {

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

  50% {
    transform: translateY(-10px);
  }
}

.splash-title {
  font-family: "Fredoka One", cursive;
  font-size: 2.8rem;
  color: #f59e0b;
  text-shadow: 0 0 30px rgba(245, 158, 11, 0.6), 2px 2px 0 rgba(0, 0, 0, 0.4);
  margin-bottom: 12px;
}

.splash-sub {
  font-size: 1rem;
  color: #fef3c7;
  opacity: 0.85;
  margin-bottom: 5px;
}

.splash-sub.dim {
  font-size: 0.8rem;
  opacity: 0.4;
}

#gameOver {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
  background: rgba(8, 3, 0, 0.82);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  animation: goAnim 0.4s ease;
}

@keyframes goAnim {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

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

.go-title {
  font-family: "Fredoka One", cursive;
  font-size: 3.2rem;
  color: #ef4444;
  text-shadow: 0 0 25px rgba(239, 68, 68, 0.6), 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.go-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: #d97706;
  text-transform: uppercase;
  opacity: 0.7;
}

.go-score-num {
  font-family: "Fredoka One", cursive;
  font-size: 5.5rem;
  color: #f59e0b;
  text-shadow: 0 0 40px rgba(245, 158, 11, 0.8), 2px 2px 0 rgba(0, 0, 0, 0.4);
  line-height: 1;
}

#playAgainBtn {
  font-family: "Fredoka One", cursive;
  font-size: 1.25rem;
  color: #1a1a1a;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  border-radius: 50px;
  padding: 12px 44px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 5px 0 #92400e, 0 8px 25px rgba(245, 158, 11, 0.4);
  transition: all 0.15s;
  letter-spacing: 1px;
}

#playAgainBtn:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #92400e, 0 12px 30px rgba(245, 158, 11, 0.5);
}

#playAgainBtn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #92400e;
}

#startReset {
  font-family: "Fredoka One", cursive;
  font-size: 1.3rem;
  color: #1a0d00;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  border-radius: 50px;
  padding: 14px 52px;
  cursor: pointer;
  box-shadow: 0 5px 0 #92400e, 0 10px 30px rgba(245, 158, 11, 0.4);
  transition: all 0.15s;
  user-select: none;
  position: relative;
  top: 0;
  animation: pulseS 2.4s ease-in-out infinite;
}

@keyframes pulseS {

  0%,
  100% {
    box-shadow: 0 5px 0 #92400e, 0 10px 30px rgba(245, 158, 11, 0.4);
  }

  50% {
    box-shadow: 0 5px 0 #92400e, 0 10px 44px rgba(245, 158, 11, 0.7);
  }
}

#startReset:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
  animation: none;
  box-shadow: 0 7px 0 #92400e, 0 14px 38px rgba(245, 158, 11, 0.55);
}

#startReset:active {
  top: 5px;
  box-shadow: 0 0 0 #92400e;
}

#startReset.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
}

.score-pop {
  position: absolute;
  font-family: "Fredoka One", cursive;
  font-size: 1.8rem;
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.9), 2px 2px 0 rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 25;
  animation: scorePopAnim 0.7s ease forwards;
}

@keyframes scorePopAnim {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-70px) scale(1.5);
  }
}
