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

:root {
  --bg-color: #0d0f12;
  --panel-bg: rgba(18, 22, 28, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --pistachio-green: #85C16C;
  --pistachio-green-glow: rgba(133, 193, 108, 0.4);
  --pistachio-shell: #e8d8b8;
  --accent-gold: #ffd700;
  --accent-red: #ff4a5a;
  --accent-red-glow: rgba(255, 74, 90, 0.4);
  --text-primary: #f5f6f8;
  --text-secondary: #8e9aa8;
}

* {
  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: hidden;
  background-color: var(--bg-color);
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
}

/* Background Grid Pattern */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(133, 193, 108, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 215, 0, 0.03) 0%, transparent 40%),
    linear-gradient(rgba(255, 255, 255, 0.003) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.003) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  z-index: 0;
  pointer-events: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1;
  background-color: var(--bg-color);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.85);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1b2028 0%, #0d0f12 100%);
}

/* Screen Shake Animation */
.shake {
  animation: screen-shake 0.35s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screen-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* HUD Styling */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 24px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-item {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 20px;
  border-radius: 14px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

#hud-left {
  justify-self: start;
}

#hud-center {
  justify-self: center;
  transform-origin: center;
}

#hud-right {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 2px;
}

.hud-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.hud-value.highlight {
  color: var(--pistachio-green);
  text-shadow: 0 0 12px var(--pistachio-green-glow);
}

/* Multiplier styling */
#multiplier-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 24px;
  border-radius: 16px;
  border: 1px solid rgba(133, 193, 108, 0.2);
  transition: transform 0.1s ease-out;
}

#multiplier-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--pistachio-green);
  text-shadow: 0 0 15px var(--pistachio-green-glow);
  font-family: 'Syne', sans-serif;
}

/* Hearts */
.heart {
  width: 24px;
  height: 24px;
  fill: var(--accent-red);
  filter: drop-shadow(0 0 4px var(--accent-red-glow));
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.heart.lost {
  opacity: 0.2;
  transform: scale(0.6) rotate(-15deg);
  filter: none;
}

.heart.shake {
  animation: pulse-heart 0.4s ease-out;
}

@keyframes pulse-heart {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Floaty Combo Text in Canvas (CSS fallback/helper) */
.floaty-text {
  position: absolute;
  pointer-events: none;
  font-weight: 800;
  font-family: 'Syne', sans-serif;
  text-transform: uppercase;
  z-index: 15;
  animation: floaty-up 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes floaty-up {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -80%) scale(1.2);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -90%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -150%) scale(0.85);
    opacity: 0;
  }
}

/* Overlay / Modal Layouts */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 12, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  width: 90%;
  max-width: 460px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  max-height: 90vh;
}

.overlay.hidden .modal-content {
  transform: translateY(20px);
}

/* Logo & Headers */
.logo-container {
  margin-bottom: 24px;
}

.logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--pistachio-green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 20px rgba(133, 193, 108, 0.15);
}

.logo-tagline {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
  font-weight: 600;
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 50%, var(--pistachio-green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-description {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 28px;
}

/* Instruction Cards */
.instructions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 32px;
  text-align: left;
}

.instruction-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.instruction-icon {
  width: 40px;
  height: 40px;
  background: rgba(133, 193, 108, 0.1);
  border: 1px solid rgba(133, 193, 108, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pistachio-green);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.instruction-text h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.instruction-text p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Buttons and Inputs */
.btn {
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: var(--pistachio-green);
  color: #0c1008;
  box-shadow: 0 4px 24px var(--pistachio-green-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: #9bd681;
  box-shadow: 0 6px 30px rgba(133, 193, 108, 0.6);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  margin-top: 12px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Results section on Game Over */
.results-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.result-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px;
  border-radius: 18px;
}

.result-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--pistachio-green);
  text-shadow: 0 0 10px var(--pistachio-green-glow);
}

/* Lead Gen Form */
.form-group {
  margin-bottom: 24px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrapper {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  transition: all 0.2s ease;
  outline: none;
}

.form-input:focus {
  border-color: var(--pistachio-green);
  box-shadow: 0 0 0 3px rgba(133, 193, 108, 0.15);
  background: rgba(0, 0, 0, 0.3);
}

.error-text {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}

.form-group.invalid .form-input {
  border-color: var(--accent-red);
}

.form-group.invalid .error-text {
  display: block;
}

/* Leaderboard Overlay */
.leaderboard-title {
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  margin: 28px 0 12px 0;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

.leaderboard-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar styling */
.leaderboard-list::-webkit-scrollbar {
  width: 6px;
}
.leaderboard-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid transparent;
}

.leaderboard-item.highlight-user {
  background: rgba(133, 193, 108, 0.05);
  border-color: rgba(133, 193, 108, 0.15);
}

.leaderboard-rank-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leaderboard-rank {
  font-weight: 700;
  color: var(--text-secondary);
  width: 20px;
}

.leaderboard-item:nth-child(1) .leaderboard-rank { color: var(--accent-gold); }
.leaderboard-item:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #cd7f32; }

.leaderboard-name {
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  #hud {
    padding: 16px 20px;
  }
  .hud-value {
    font-size: 20px;
  }
  #multiplier-container {
    padding: 8px 16px;
  }
  #multiplier-value {
    font-size: 28px;
  }
  .modal-content {
    padding: 30px 20px;
  }
  .logo-text {
    font-size: 32px;
  }
}

/* Modal Footer Copyright Style */
.modal-footer {
  margin-top: 32px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.modal-footer a {
  color: var(--pistachio-green);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.2s ease;
}

.modal-footer a:hover {
  color: #ffd700; /* Gold shine on hover */
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Fever Mode Multiplier HUD Styling */
#multiplier-container.fever-active {
  border-color: var(--accent-gold);
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.35);
  animation: fever-pulse 0.4s infinite alternate cubic-bezier(0.25, 0.8, 0.25, 1);
}

#multiplier-container.fever-active #multiplier-value {
  color: var(--accent-gold);
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
}

@keyframes fever-pulse {
  0% { transform: scale(1.0); }
  100% { transform: scale(1.1); }
}
