/* ===================================================
   TANGKAP BUAH CERIA - ASHEEQA GAMES
   Design System & Styling
   =================================================== */

:root {
  --primary-color: #ff5e7e;
  --primary-hover: #ff3b61;
  --secondary-color: #2ed573;
  --secondary-hover: #26af5f;
  --accent-color: #ffa502;
  --accent-cyan: #00d2d3;
  --accent-purple: #9b59b6;
  --bg-gradient-top: #85d8ce;
  --bg-gradient-bottom: #085078;
  --text-dark: #2c3e50;
  --text-light: #ffffff;
  --font-bubble: 'Bubblegum Sans', cursive, sans-serif;
  --font-body: 'Fredoka', cursive, sans-serif;
  --shadow-cartoon: 0 8px 0 rgba(0, 0, 0, 0.18);
  --shadow-btn: 0 6px 0 rgba(0, 0, 0, 0.2);
  --shadow-btn-active: 0 2px 0 rgba(0, 0, 0, 0.2);
  --radius-pill: 999px;
  --radius-card: 28px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2b3a4a;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

#game-app {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(circle at center, #3a506b 0%, #1c2541 100%);
}

/* Game container maintaining a friendly 4:3 or 16:9 responsive box */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 800px;
  max-height: 900px;
  background: #87ceeb;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 8px #fffa65;
  border-radius: 24px;
}

@media (max-width: 820px) {
  #game-container {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Canvas fills the container */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* ================= HUD Overlay ================= */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hud-layer > * {
  pointer-events: auto;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15), 0 3px 0 #dedede;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 3px solid #ffd32a;
}

.hud-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.hud-info {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #7f8c8d;
}

.hud-value {
  font-family: var(--font-bubble);
  font-size: 1.6rem;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1;
}

.combo-badge {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-family: var(--font-bubble);
  font-size: 1.1rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4), 0 3px 0 #b33939;
  animation: pulse-quick 0.4s infinite alternate;
  border: 2px solid #fff;
}

.lives-container {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 3px solid #ff7675;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.heart-icon {
  font-size: 1.4rem;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.heart-icon.lost {
  opacity: 0.25;
  filter: grayscale(100%);
  transform: scale(0.8);
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid white;
  background: white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2), 0 4px 0 #dcdde1;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
}

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

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #dcdde1;
}

/* ================= Praise Popups ================= */
.praise-popup {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, #ffd32a, #ff9f1a);
  color: #fff;
  text-shadow: 2px 2px 0 #cc8e35;
  font-family: var(--font-bubble);
  font-size: 2.5rem;
  font-weight: 800;
  padding: 12px 32px;
  border-radius: var(--radius-pill);
  border: 4px solid #ffffff;
  box-shadow: 0 12px 30px rgba(255, 159, 26, 0.5), 0 6px 0 #c27803;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.praise-popup.show {
  transform: translate(-50%, -50%) scale(1.1);
  opacity: 1;
}

/* ================= Screen Overlays ================= */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
  background: rgba(18, 30, 49, 0.65);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

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

.screen-overlay.hidden {
  display: none !important;
}

/* ================= Menu Box ================= */
.menu-content {
  background: linear-gradient(180deg, #ffffff 0%, #f6fbfb 100%);
  border-radius: var(--radius-card);
  padding: 32px 28px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35), 0 8px 0 #1dd1a1;
  border: 5px solid #2ed573;
  position: relative;
}

.fruit-icons-banner {
  font-size: 2.2rem;
  letter-spacing: 6px;
  margin-bottom: 6px;
  animation: float-gentle 2s ease-in-out infinite alternate;
}

.game-title {
  font-family: var(--font-bubble);
  font-size: 2.6rem;
  line-height: 1.05;
  color: #ff4757;
  text-shadow: 3px 3px 0 #ffcccc;
  margin-bottom: 4px;
}

.title-sub {
  color: #2ed573;
  text-shadow: 3px 3px 0 #d1f2eb;
}

.brand-tag {
  font-size: 0.85rem;
  font-weight: 700;
  color: #747d8c;
  margin-bottom: 22px;
}

/* Mode Buttons */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.btn {
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.15s ease;
  width: 100%;
}

.btn-emoji {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.btn-title {
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.2;
}

.btn-desc {
  font-size: 0.78rem;
  opacity: 0.9;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: white;
  box-shadow: 0 6px 0 #c23616, 0 10px 20px rgba(255, 71, 87, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ff5e6f, #ff7b91);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #c23616;
}

.btn-secondary {
  background: linear-gradient(135deg, #2ed573, #10ac84);
  color: white;
  box-shadow: 0 6px 0 #0e8566, 0 10px 20px rgba(46, 213, 115, 0.35);
}

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

.btn-secondary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #0e8566;
}

.btn-outline {
  background: #f1f2f6;
  color: #2f3542;
  box-shadow: 0 5px 0 #ced6e0;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px;
}

.btn-outline:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #ced6e0;
}

/* Bowl Selector Bar */
.bowl-selection-bar {
  background: #f1f8fe;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 2px dashed #70a1ff;
}

.selection-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2e86de;
  margin-bottom: 8px;
}

.bowl-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.bowl-opt-btn {
  background: white;
  border: 2px solid #ced6e0;
  border-radius: 12px;
  padding: 8px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #57606f;
  cursor: pointer;
  box-shadow: 0 3px 0 #dfe4ea;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.bowl-opt-btn.active {
  border-color: #ff4757;
  background: #ffeff1;
  color: #ff4757;
  transform: translateY(-2px);
  box-shadow: 0 4px 0 #ff4757;
}

.menu-footer {
  font-size: 0.85rem;
  color: #747d8c;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.high-score-tag {
  font-weight: 800;
  font-size: 1.05rem;
  color: #ff9f1a;
  background: #fff8e7;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  display: inline-block;
  align-self: center;
  border: 2px solid #ffd32a;
}

.how-to-play-hint {
  font-size: 0.78rem;
  line-height: 1.4;
  color: #57606f;
}

/* ================= Modal Box (Pause & GameOver) ================= */
.modal-box {
  background: white;
  border-radius: var(--radius-card);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  border: 5px solid #ff9f43;
}

.modal-title {
  font-family: var(--font-bubble);
  font-size: 2.3rem;
  color: #ff9f43;
  margin-bottom: 6px;
}

.modal-desc, .modal-sub {
  color: #747d8c;
  font-size: 0.95rem;
  margin-bottom: 20px;
  font-weight: 600;
}

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

/* Game Over Stats */
.gameover-emojis {
  font-size: 2.8rem;
  letter-spacing: 6px;
  margin-bottom: 6px;
}

.result-stats {
  background: #f8f9fa;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  border: 2px solid #dfe4ea;
}

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

.stat-item.highlight .stat-val {
  color: #ff4757;
  font-size: 1.8rem;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #a4b0be;
  text-transform: uppercase;
}

.stat-val {
  font-family: var(--font-bubble);
  font-size: 1.4rem;
  font-weight: 800;
  color: #2f3542;
}

.new-record-badge {
  background: #ffd32a;
  color: #d35400;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  display: inline-block;
  animation: pulse-quick 0.5s infinite alternate;
}

/* ================= On-Screen Touch Controls ================= */
.touch-controls {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 12;
  pointer-events: none;
}

.touch-btn {
  pointer-events: auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  border: 4px solid #70a1ff;
  color: #1e90ff;
  font-size: 1.8rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2), 0 4px 0 #1e90ff;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.touch-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #1e90ff;
  background: #e7f3ff;
}

.touch-indicator {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
}

/* Hide touch buttons on desktop mouse hover devices if preferred, but keep active for touch */
@media (min-width: 900px) and (hover: hover) {
  .touch-controls {
    opacity: 0.4;
    transition: opacity 0.2s;
  }
  .touch-controls:hover {
    opacity: 1;
  }
}

/* ================= Animations ================= */
.bounce-in {
  animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pulse-btn {
  animation: pulseBtn 2s infinite ease-in-out;
}

@keyframes bounceIn {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes pulse-quick {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

@keyframes float-gentle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}
