/* ===== CSS Variables & Base ===== */
:root {
  /* Coke Theme Colors */
  --coke-red: #e61939;
  --coke-dark-red: #c41230;
  --coke-cream: #fff5e6;
  --coke-white: #ffffff;
  --coke-black: #2d2d2d;

  /* Game Colors */
  --balloon-blue: #4facfe;
  --balloon-purple: #a18cd1;
  --balloon-orange: #ff9a9e;
  --balloon-pink: #fecfef;
  --balloon-green: #43e97b;
  --balloon-yellow: #f6d365;

  /* Effects */
  --glow-color: rgba(230, 25, 57, 0.5);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.1);
  --shadow-strong: 0 12px 24px rgba(0, 0, 0, 0.2);
  --shadow-inset: inset 0 -4px 0 rgba(0, 0, 0, 0.1);

  /* Typography */
  --font-heading: "Baloo 2", cursive;
  --font-body: "Baloo 2", cursive;
}

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

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Screens ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

/* ===== Start Screen ===== */
#startScreen {
  background: radial-gradient(circle at center, #ff6b6b 0%, #ee5253 100%);
}

.start-content {
  text-align: center;
  z-index: 10;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 40px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  border: 4px solid rgba(255, 255, 255, 0.2);
}

.game-title {
  font-family: var(--font-heading);
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 800; /* Extra Bold for bubble effect */
  color: var(--coke-white);
  text-shadow: 4px 4px 0 var(--coke-dark-red), 8px 8px 0 rgba(0, 0, 0, 0.2);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
  animation: titlePop 2s ease-in-out infinite;
  line-height: 1.2;
}

.letter-a {
  display: inline-block;
  color: var(--balloon-yellow);
  text-shadow: 4px 4px 0 #d4ac0d, 8px 8px 0 rgba(0, 0, 0, 0.2);
  transform: rotate(-10deg);
}

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

.game-subtitle {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  color: white;
  margin-bottom: 2.5rem;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.start-button,
.restart-button {
  background: linear-gradient(to bottom, #ffd700, #ffa500);
  border: 4px solid #ffffff;
  padding: 0.8rem 3rem 1rem; /* Adjusted padding for font alignment */
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  color: #b35900;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 0 #cc8400, 0 15px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.1s ease;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  /* Removed uppercase to better support Turkish chars */
}

.start-button:hover,
.restart-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0 #cc8400, 0 20px 30px rgba(0, 0, 0, 0.3);
}

.start-button:active,
.restart-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #cc8400, 0 5px 10px rgba(0, 0, 0, 0.2);
}

.button-icon {
  font-size: 1.2em;
}

/* Floating Letters Background */
.floating-letters {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.float-letter {
  position: absolute;
  bottom: -100px;
  left: var(--x);
  font-family: var(--font-heading);
  font-size: 5rem;
  color: rgba(255, 255, 255, 0.2);
  font-weight: 700;
  animation: floatUp 8s ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.2;
  }
  90% {
    opacity: 0.2;
  }
  100% {
    transform: translateY(-120vh) rotate(360deg);
    opacity: 0;
  }
}

/* ===== Game Screen ===== */
#gameScreen {
  flex-direction: column;
  /* Sky Gradient */
  background: linear-gradient(180deg, #4facfe 0%, #00f2fe 100%);
}

/* Clouds Pattern */
#gameScreen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
      rgba(255, 255, 255, 0.4) 15%,
      transparent 16%
    ),
    radial-gradient(rgba(255, 255, 255, 0.4) 15%, transparent 16%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  opacity: 0.3;
  pointer-events: none;
}

/* Game Header - Compact Redesign */
.game-header {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
  pointer-events: none; /* Let clicks pass through if empty areas */
}

/* Grouping stats for better layout */
.header-left {
  display: flex;
  gap: 10px;
}

.header-right {
  display: flex;
  gap: 10px;
}

/* Compact Score & Timer badges */
.score-container,
.timer-container {
  background: white;
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
}

.score-label,
.timer-icon {
  font-size: 1.2rem;
  color: #ffd700;
}

.score-value,
.timer-value {
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  font-size: 1.5rem;
  color: #333;
}

.timer-value {
  min-width: 40px;
  text-align: center;
}

/* Compact Target Letter Box - Top/Center or Side */
.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

.target-letter {
  gap: 0.8rem;
  background: linear-gradient(135deg, #ff6b6b, #ee5253);
  padding: 0.5rem 2rem;
  border-radius: 50px;
  box-shadow: 0 5px 15px rgba(238, 82, 83, 0.4),
    inset 0 4px 0 rgba(255, 255, 255, 0.2), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
  border: 3px solid white;
}

.target-letter.pulse {
  animation: targetPop 0.5s ease-out;
}

@keyframes targetPop {
  0% {
    transform: scale(1.1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1.1);
  }
}

.target-label {
  color: #ffe5e5;
  font-size: 1.1rem;
  font-weight: 700;
}

.target-char {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 400;
  color: white;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.3rem 1rem;
  border-radius: 50px;
  border: 2px solid #eee;
  margin-top: 0.5rem;
}

.timer-icon {
  font-size: 1.2rem;
}

.timer-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: #555;
  min-width: 1.5ch;
  text-align: center;
}

.timer-value.urgent {
  color: #e61939;
  animation: urgentPulse 0.5s infinite;
}

@keyframes urgentPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ===== Game Area ===== */
.game-area {
  position: fixed;
  inset: 0;
  padding-top: 80px;
  overflow: hidden;
}

/* ===== Balloons ===== */
.balloon {
  position: absolute;
  width: 80px;
  height: 100px;
  cursor: pointer;
  animation: floatBalloon linear forwards;
  transition: transform 0.1s ease;
  z-index: 10;
}

.balloon:hover {
  transform: scale(1.1);
}

.balloon:active {
  transform: scale(0.95);
}

.balloon-body {
  width: 100%;
  height: 80px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.15),
    inset 10px 10px 20px rgba(255, 255, 255, 0.3),
    0 10px 30px rgba(0, 0, 0, 0.2);
}

.balloon-body::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 20%;
  width: 20px;
  height: 25px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: rotate(-30deg);
}

.balloon-letter {
  font-size: 2rem;
  font-weight: 700;
  color: var(--coke-white);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2), 0 0 10px rgba(255, 255, 255, 0.5);
  z-index: 5;
}

.balloon-knot {
  width: 15px;
  height: 15px;
  margin: -5px auto 0;
  position: relative;
}

.balloon-knot::before {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid currentColor;
}

.balloon-string {
  width: 2px;
  height: 40px;
  background: linear-gradient(180deg, currentColor 0%, transparent 100%);
  margin: 0 auto;
  opacity: 0.5;
}

/* Balloon Colors */
.balloon.red .balloon-body {
  background: linear-gradient(135deg, #ff6b6b 0%, var(--coke-red) 100%);
}
.balloon.red .balloon-knot::before {
  border-top-color: var(--coke-red);
}
.balloon.red .balloon-string {
  background: linear-gradient(180deg, var(--coke-red) 0%, transparent 100%);
}

.balloon.blue .balloon-body {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}
.balloon.blue .balloon-knot::before {
  border-top-color: #0984e3;
}
.balloon.blue .balloon-string {
  background: linear-gradient(180deg, #0984e3 0%, transparent 100%);
}

.balloon.purple .balloon-body {
  background: linear-gradient(135deg, #a29bfe 0%, var(--balloon-purple) 100%);
}
.balloon.purple .balloon-knot::before {
  border-top-color: var(--balloon-purple);
}
.balloon.purple .balloon-string {
  background: linear-gradient(
    180deg,
    var(--balloon-purple) 0%,
    transparent 100%
  );
}

.balloon.orange .balloon-body {
  background: linear-gradient(135deg, #ffeaa7 0%, var(--balloon-orange) 100%);
}
.balloon.orange .balloon-knot::before {
  border-top-color: var(--balloon-orange);
}
.balloon.orange .balloon-string {
  background: linear-gradient(
    180deg,
    var(--balloon-orange) 0%,
    transparent 100%
  );
}

.balloon.pink .balloon-body {
  background: linear-gradient(135deg, #fd79a8 0%, var(--balloon-pink) 100%);
}
.balloon.pink .balloon-knot::before {
  border-top-color: var(--balloon-pink);
}
.balloon.pink .balloon-string {
  background: linear-gradient(180deg, var(--balloon-pink) 0%, transparent 100%);
}

.balloon.green .balloon-body {
  background: linear-gradient(135deg, #55efc4 0%, var(--balloon-green) 100%);
}
.balloon.green .balloon-knot::before {
  border-top-color: var(--balloon-green);
}
.balloon.green .balloon-string {
  background: linear-gradient(
    180deg,
    var(--balloon-green) 0%,
    transparent 100%
  );
}

.balloon.yellow .balloon-body {
  background: linear-gradient(135deg, #fff59d 0%, var(--balloon-yellow) 100%);
}
.balloon.yellow .balloon-knot::before {
  border-top-color: var(--balloon-yellow);
}
.balloon.yellow .balloon-string {
  background: linear-gradient(
    180deg,
    var(--balloon-yellow) 0%,
    transparent 100%
  );
}

/* Special A balloon glow */
.balloon.target-balloon .balloon-body {
  box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.15),
    inset 10px 10px 20px rgba(255, 255, 255, 0.3),
    0 0 30px rgba(255, 215, 0, 0.6), 0 10px 30px rgba(0, 0, 0, 0.2);
}

@keyframes floatBalloon {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-25vh) rotate(5deg);
  }
  50% {
    transform: translateY(-50vh) rotate(-5deg);
  }
  75% {
    transform: translateY(-75vh) rotate(5deg);
  }
  100% {
    transform: translateY(-120vh) rotate(0deg);
  }
}

/* ===== Pop Effect ===== */
.balloon.popping {
  animation: popBalloon 0.3s ease-out forwards !important;
}

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

/* Wrong balloon shake */
.balloon.wrong {
  animation: wrongShake 0.5s ease-out !important;
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  20% {
    transform: translateX(-15px) rotate(-10deg);
  }
  40% {
    transform: translateX(15px) rotate(10deg);
  }
  60% {
    transform: translateX(-10px) rotate(-5deg);
  }
  80% {
    transform: translateX(10px) rotate(5deg);
  }
}

/* ===== Confetti ===== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confettiFall 1s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(200px) rotate(720deg) scale(0);
    opacity: 0;
  }
}

/* ===== Score Popup ===== */
.score-popup {
  position: absolute;
  font-size: 2rem;
  font-weight: 700;
  pointer-events: none;
  animation: scoreFloat 1s ease-out forwards;
  z-index: 150;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.score-popup.positive {
  color: var(--balloon-green);
}

.score-popup.negative {
  color: var(--coke-red);
}

@keyframes scoreFloat {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  20% {
    transform: translateY(-20px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-80px) scale(1);
    opacity: 0;
  }
}

/* ===== Game Over Screen ===== */
#gameOverScreen {
  background: linear-gradient(
    180deg,
    var(--coke-red) 0%,
    var(--coke-dark-red) 100%
  );
}

.game-over-content {
  text-align: center;
  padding: 2rem;
}

.game-over-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: var(--coke-white);
  text-shadow: 0 4px 0 var(--coke-dark-red);
  margin-bottom: 1.5rem;
}

.final-score {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 1.5rem 3rem;
  border-radius: 20px;
  margin-bottom: 1.5rem;
}

.final-score-label {
  display: block;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
}

.final-score-value {
  font-size: 4rem;
  font-weight: 700;
  color: var(--balloon-yellow);
  text-shadow: 0 4px 0 var(--balloon-orange);
}

.stars-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.star {
  font-size: 3rem;
  animation: starPop 0.5s ease-out forwards;
  opacity: 0;
}

.star:nth-child(1) {
  animation-delay: 0.2s;
}
.star:nth-child(2) {
  animation-delay: 0.4s;
}
.star:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes starPop {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.3) rotate(0deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.star.empty {
  filter: grayscale(100%);
  opacity: 0.5 !important;
}

/* ===== Speaking Indicator ===== */
.speaking-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2rem 3rem;
  border-radius: 20px;
  font-size: 3rem;
  font-weight: 700;
  z-index: 300;
  animation: speakPulse 0.5s ease-in-out infinite;
}

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

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .balloon {
    width: 60px;
    height: 80px;
  }

  .balloon-body {
    height: 60px;
  }

  .balloon-letter {
    font-size: 1.5rem;
  }

  .game-header {
    padding: 0.8rem 1rem;
  }

  .score-value,
  .lives-value {
    font-size: 1.4rem;
  }

  .target-char {
    font-size: 1.5rem;
  }
}
