/* ============================================ */
/* CLOCK CATCHER 3D GAME - 10 LEVEL SYSTEM */
/* Safe for embedding, mobile-first approach */
/* Matched to VOLTR color theme */
/* SCALED DOWN FOR SINGLE LINE */
/* ============================================ */

/* Base game section */
#coffee-game-section {
  width: 100%;
  padding: 30px 0;
  background: transparent;
  position: relative;
}

#coffee-game-section * {
  box-sizing: border-box;
}

/* Game container - responsive by default */
#coffee-game-section #gameSection {
  width: 100%;
  max-width: 1400px;
  height: min(75vh, 650px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 40px 100px rgba(107, 33, 168, 0.3),
              0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Header */
#coffee-game-section #gameHeader {
  background: linear-gradient(135deg, #6b21a8 0%, #be185d 100%);
  padding: clamp(10px, 2.5vw, 16px) clamp(12px, 3vw, 24px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(107, 33, 168, 0.3);
  position: relative;
  z-index: 10;
  gap: clamp(8px, 2vw, 15px);
  flex-wrap: nowrap;
}

#coffee-game-section #gameTitle {
  font-size: clamp(16px, 3.5vw, 24px);
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.5px;
  margin: 0;
  flex-shrink: 0;
}

/* Stats - compact layout for 5 items on one line */
#coffee-game-section #gameStats {
  display: flex;
  gap: clamp(4px, 1vw, 10px);
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 1;
}

#coffee-game-section .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: clamp(38px, 7vw, 55px);
}

/* Level stat - highlighted but compact */
#coffee-game-section .level-stat {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  padding: clamp(4px, 1vw, 8px) clamp(6px, 1.5vw, 12px);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

#coffee-game-section .level-stat .statLabel {
  color: white;
  opacity: 1;
  font-weight: 700;
}

#coffee-game-section .level-stat .statValue {
  font-size: clamp(18px, 4vw, 26px);
  color: white;
}

/* Catches stat - highlighted but compact */
#coffee-game-section .catches-stat {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  padding: clamp(4px, 1vw, 8px) clamp(6px, 1.5vw, 12px);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
  min-width: clamp(50px, 9vw, 70px);
}

#coffee-game-section .catches-stat .statLabel {
  color: white;
  opacity: 1;
  font-weight: 700;
}

#coffee-game-section .catches-stat .statValue {
  color: white;
}

#coffee-game-section .catches-value {
  font-size: clamp(14px, 3vw, 18px) !important;
}

#coffee-game-section .statLabel {
  font-size: clamp(8px, 1.8vw, 10px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.8);
}

#coffee-game-section .statValue {
  font-size: clamp(15px, 3.5vw, 22px);
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  text-align: center;
}

/* Game stage */
#coffee-game-section #ccgStage {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, #faf5ff 0%, #f3e8ff 100%);
  overflow: hidden;
  min-height: 50vh;
  /* Prevent iOS long-press magnification loupe when holding to drag */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Prevent swipe up/down (page scroll) when touching game area */
  touch-action: none;
}

#coffee-game-section #ccgStage canvas {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* Overlays */
#coffee-game-section .overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(107, 33, 168, 0.97) 0%, rgba(190, 24, 93, 0.97) 100%);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: ccgFadeIn 0.4s ease-out;
  padding: 20px;
  overflow-y: auto;
}

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

#coffee-game-section .overlayContent {
  text-align: center;
  color: white;
  animation: ccgSlideUp 0.6s ease-out;
  max-width: 90%;
  padding: 20px;
}

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

#coffee-game-section .overlayTitle {
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 900;
  margin-bottom: 16px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  letter-spacing: -1px;
}

#coffee-game-section .overlaySubtitle {
  font-size: clamp(14px, 3vw, 20px);
  font-weight: 500;
  margin-bottom: 40px;
  opacity: 0.95;
  line-height: 1.6;
}

/* Score display */
#coffee-game-section .finalScore {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: clamp(15px, 3vw, 25px) clamp(25px, 5vw, 40px);
  border-radius: 20px;
  margin: 20px 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#coffee-game-section .finalScoreLabel {
  font-size: clamp(12px, 2.5vw, 14px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.9;
  margin-bottom: 8px;
}

#coffee-game-section .finalScoreValue {
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 900;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Level reached display - special styling */
#coffee-game-section .level-reached {
  font-size: clamp(28px, 6vw, 42px) !important;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(245, 87, 108, 0.5));
}

/* Buttons */
#coffee-game-section .btn {
  background: linear-gradient(to bottom, #A020F0, #7B2CBF);
  color: white;
  border: none;
  padding: clamp(14px, 3vw, 16px) clamp(32px, 6vw, 40px);
  font-size: clamp(16px, 3vw, 18px);
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(123, 44, 191, 0.4);
  font-family: inherit;
  margin-top: 20px;
}

#coffee-game-section .btn:hover {
  background: linear-gradient(to bottom, #8b1fe4, #6821a5);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(123, 44, 191, 0.6);
}

#coffee-game-section .btn:active {
  transform: scale(1.02);
}

/* Instructions */
#coffee-game-section .instructions {
  margin-top: 40px;
  display: flex;
  gap: clamp(10px, 2vw, 20px);
  justify-content: center;
  flex-wrap: wrap;
  padding: 0 15px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

#coffee-game-section .instruction {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 20px);
  border-radius: 15px;
  font-size: clamp(13px, 2.5vw, 15px);
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
}

#coffee-game-section .emoji {
  font-size: clamp(18px, 3.5vw, 22px);
  flex-shrink: 0;
}

/* Loading animation */
@keyframes ccgSpin {
  to { transform: rotate(360deg); }
}

#coffee-game-section .loading {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: ccgSpin 0.8s linear infinite;
}

/* Reset inherited styles */
#coffee-game-section #gameSection p,
#coffee-game-section #gameSection h1,
#coffee-game-section #gameSection h2,
#coffee-game-section #gameSection h3,
#coffee-game-section #gameSection h4,
#coffee-game-section #gameSection h5,
#coffee-game-section #gameSection h6 {
  margin: 0;
  line-height: 1.2;
}

#coffee-game-section h2 {
  font-size: 2.8rem;
  font-weight: 700;
  color: #be185d !important;
  margin-bottom: 3rem;
}

/* Desktop optimization */
@media (min-width: 769px) {
  #coffee-game-section {
    padding: 60px 0;
  }

  #coffee-game-section #gameSection {
    height: min(88vh, 1100px);
    border-radius: 32px;
  }

  #coffee-game-section #ccgStage {
    min-height: auto;
  }

  #coffee-game-section #gameHeader {
    flex-wrap: nowrap;
  }

  #coffee-game-section #gameStats {
    flex-wrap: nowrap;
  }
}

/* Tablet optimization */
@media (min-width: 481px) and (max-width: 768px) {
  #coffee-game-section {
    padding: 40px 0;
  }

  #coffee-game-section #gameSection {
    height: min(70vh, 600px);
    border-radius: 20px;
  }

  #coffee-game-section #ccgStage {
    min-height: 45vh;
  }

  #coffee-game-section .instruction {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* Mobile optimization */
@media (max-width: 480px) {
  #coffee-game-section #gameHeader {
    padding: 10px 12px;
    flex-wrap: nowrap;
  }

  #coffee-game-section #gameTitle {
    font-size: 14px;
  }

  #coffee-game-section #gameStats {
    flex-wrap: nowrap;
    gap: 3px;
  }

  #coffee-game-section .stat {
    min-width: 40px;
  }

  #coffee-game-section .level-stat,
  #coffee-game-section .catches-stat {
    padding: 4px 6px;
  }

  #coffee-game-section .catches-stat {
    min-width: 50px;
  }

  #coffee-game-section .statLabel {
    font-size: 7px;
    letter-spacing: 0.3px;
  }

  #coffee-game-section .statValue {
    font-size: 13px;
  }

  #coffee-game-section .level-stat .statValue {
    font-size: 16px;
  }

  #coffee-game-section .catches-value {
    font-size: 12px !important;
  }

  #coffee-game-section .instruction {
    font-size: 12px;
    padding: 8px 12px;
    flex: 0 0 calc(50% - 5px);
  }

  #coffee-game-section .finalScore {
    margin: 15px 0;
    padding: 15px 20px;
  }
}

/* End overlay (win screen) – scale down on mobile */
@media (max-width: 768px) {
  #coffee-game-section #ccgEndOverlay.overlay {
    padding: 12px;
  }
  #coffee-game-section #ccgEndOverlay .overlayContent {
    padding: 12px 16px;
    max-width: 95%;
  }
  #coffee-game-section #ccgEndOverlay .overlayTitle {
    font-size: clamp(20px, 5.5vw, 28px);
    margin-bottom: 10px;
  }
  #coffee-game-section #ccgEndOverlay .finalScore {
    padding: 10px 14px;
    margin: 10px 0;
  }
  #coffee-game-section #ccgEndOverlay .finalScoreLabel {
    font-size: 10px;
    margin-bottom: 4px;
  }
  #coffee-game-section #ccgEndOverlay .finalScoreValue {
    font-size: clamp(28px, 7vw, 44px);
  }
  #coffee-game-section #ccgEndOverlay .level-reached {
    font-size: clamp(20px, 5vw, 28px) !important;
  }
  #coffee-game-section #ccgEndOverlay .btn {
    padding: 12px 24px;
    font-size: 14px;
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  #coffee-game-section #ccgEndOverlay .overlayTitle {
    font-size: clamp(18px, 5vw, 24px);
  }
  #coffee-game-section #ccgEndOverlay .finalScore {
    padding: 8px 12px;
    margin: 8px 0;
  }
  #coffee-game-section #ccgEndOverlay .finalScoreValue {
    font-size: clamp(24px, 6vw, 36px);
  }
  #coffee-game-section #ccgEndOverlay .level-reached {
    font-size: clamp(18px, 4.5vw, 24px) !important;
  }
  #coffee-game-section #ccgEndOverlay .btn {
    padding: 10px 20px;
    font-size: 13px;
    margin-top: 10px;
  }
}

/* Kill container padding on mobile */
@media (max-width: 768px) {
  #coffee-game-section .container,
  #coffee-game-section .container-fluid {
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  #coffee-game-section #gameTitle {
    font-size: 13px;
  }

  #coffee-game-section .stat {
    min-width: 36px;
  }

  #coffee-game-section .statLabel {
    font-size: 6px;
  }

  #coffee-game-section .statValue {
    font-size: 12px;
  }

  #coffee-game-section .level-stat .statValue {
    font-size: 15px;
  }

  #coffee-game-section .catches-value {
    font-size: 11px !important;
  }
}