:root {
  --primary: #ff6b35;
  --primary-dark: #e85d2a;
  --primary-light: #ff8c5a;
  --accent: #ffd166;
  --success: #06d6a0;
  --danger: #ef476f;
  --gold: #ffd700;
  --dark: #1a1a2e;
  --dark-2: #16213e;
  --dark-3: #0f3460;
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.2);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Nunito", sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Animated background blobs */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  z-index: 0;
  pointer-events: none;
}

body::before {
  width: 500px;
  height: 500px;
  background: var(--primary);
  top: -150px;
  left: -150px;
  animation: float-blob 12s ease-in-out infinite;
}

body::after {
  width: 400px;
  height: 400px;
  background: var(--success);
  bottom: -100px;
  right: -100px;
  animation: float-blob 15s ease-in-out infinite reverse;
}

@keyframes float-blob {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(40px, -30px) scale(1.1);
  }
  66% {
    transform: translate(-30px, 20px) scale(0.95);
  }
}

.game-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  padding: 20px;
}

/* ===== Header ===== */
.game-header {
  text-align: center;
  margin-bottom: 16px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
  position: relative;
}

.game-title {
  font-family: "Baloo 2", cursive;
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent, #ffd166), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
  letter-spacing: 1px;
  line-height: 1.1;
}

.pause-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    opacity 0.15s ease;
  opacity: 0.5;
  pointer-events: none;
}

.pause-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.pause-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.pause-btn.enabled {
  opacity: 1;
  pointer-events: auto;
}

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  padding: 8px 18px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 90px;
  justify-content: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

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

.stat-value {
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s ease;
  display: inline-block;
}

.combo-display {
  border-color: rgba(255, 209, 102, 0.4);
  background: rgba(255, 209, 102, 0.1);
}

.combo-display.active {
  animation: comboPulse 0.3s ease;
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(255, 209, 102, 0.4);
}

@keyframes comboPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* ===== Timer ===== */
.timer-bar {
  position: relative;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--success), var(--accent));
  border-radius: 50px;
  transition: width 0.1s linear;
}

.timer-fill.low {
  background: linear-gradient(90deg, var(--danger), #ff8c42);
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

/* ===== Game Board ===== */
.game-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  position: relative;
}

.hole {
  position: relative;
  aspect-ratio: 1 / 0.9;
  overflow: hidden;
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.hole::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 100%;
  height: 45%;
  background: url("dirt.svg") bottom center no-repeat;
  background-size: contain;
  z-index: 3;
  pointer-events: none;
}

.hole::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 30%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.4),
    transparent 70%
  );
  z-index: 4;
  pointer-events: none;
}

.mole {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 72%;
  height: 72%;
  background: url("mole.svg") no-repeat bottom center;
  background-size: contain;
  transition: top 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
  cursor: pointer;
  pointer-events: none;
}

.hole.up .mole {
  top: 12%;
  pointer-events: auto;
}

.hole.up .mole:hover {
  filter: brightness(1.1);
}

.hole.up .mole.golden:hover {
  filter: sepia(1) saturate(3) hue-rotate(-15deg) brightness(1.4);
}

/* Golden mole */
.mole.golden {
  background-image: url("mole.svg");
  filter: sepia(1) saturate(3) hue-rotate(-15deg) brightness(1.2);
}

/* Bomb */
.mole.bomb {
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* Whacked state */
.mole.whacked {
  transform: translateX(-50%) scale(0.6) rotate(-20deg);
  opacity: 0;
  transition: all 0.25s ease;
}

/* ===== Combo Milestone ===== */
.combo-milestone {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  font-size: 2.2rem;
  color: var(--accent);
  text-shadow:
    0 0 20px rgba(255, 209, 102, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 20;
  pointer-events: none;
  white-space: nowrap;
  animation: comboMilestone 1s ease-out forwards;
}

@keyframes comboMilestone {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1) translateY(-30px);
  }
}

/* ===== Floating Score ===== */
.floating-score {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--success);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
}

.floating-score.negative {
  color: var(--danger);
}

.floating-score.golden {
  color: var(--gold);
  font-size: 2rem;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-60px) scale(1.2);
  }
}

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 25, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  animation: fadeIn 0.3s ease;
}

.overlay.hidden {
  display: none;
}

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

.overlay-card {
  background: linear-gradient(160deg, #1e2a4a, #16213e);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.overlay-card h2 {
  font-family: "Baloo 2", cursive;
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.overlay-subtitle {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 1rem;
}

.high-score-challenge {
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.15),
    rgba(255, 107, 53, 0.15)
  );
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--gold);
  animation: challengePulse 2s ease-in-out infinite;
}

.high-score-challenge strong {
  font-size: 1.2rem;
}

@keyframes challengePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px 4px rgba(255, 215, 0, 0.2);
  }
}

/* Legend */
.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
  text-align: left;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.legend-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.mole-legend {
  background: url("mole.svg") no-repeat center;
  background-size: contain;
}

.golden-legend {
  background: url("mole.svg") no-repeat center;
  background-size: contain;
  filter: sepia(1) saturate(3) hue-rotate(-15deg) brightness(1.2);
}

.bomb-legend {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== Buttons ===== */
.btn {
  font-family: "Baloo 2", cursive;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 14px 40px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 28px rgba(255, 107, 53, 0.5);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

/* ===== Final Stats ===== */
.final-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.final-stat {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 90px;
}

.final-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.final-value {
  font-family: "Baloo 2", cursive;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

.new-record {
  font-family: "Baloo 2", cursive;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 16px;
  animation: recordPulse 1s ease-in-out infinite;
}

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

/* ===== Screen shake ===== */
.game-wrapper.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(5px);
  }
}

/* ===== Status Bar ===== */
.status-bar {
  text-align: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 1;
  position: relative;
}

.developer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    border-color 0.15s ease;
}

.developer-link:hover {
  background: rgba(255, 209, 102, 0.15);
  border-color: rgba(255, 209, 102, 0.3);
  transform: translateY(-1px);
}

.github-icon {
  flex-shrink: 0;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  body {
    overflow-y: auto;
    align-items: flex-start;
    padding: 8px 0;
  }

  .status-bar {
    font-size: 0.75rem;
    margin-top: 6px;
  }

  .developer-link {
    padding: 3px 8px;
    font-size: 0.8rem;
  }

  .game-wrapper {
    padding: 8px;
    max-width: 100%;
  }

  .game-header {
    margin-bottom: 10px;
  }

  .header-top {
    margin-bottom: 8px;
  }

  .game-title {
    font-size: 1.8rem;
  }

  .pause-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .stats-bar {
    gap: 8px;
    margin-bottom: 10px;
  }

  .stat {
    padding: 5px 10px;
    font-size: 0.85rem;
    min-width: 65px;
    gap: 5px;
  }

  .stat-icon {
    font-size: 0.95rem;
  }

  .timer-bar {
    height: 10px;
  }

  .game-board {
    gap: 6px;
    padding: 8px;
    border-radius: 12px;
  }

  .hole {
    aspect-ratio: 1 / 0.85;
  }

  .mole {
    width: 75%;
    height: 70%;
  }

  .mole.bomb {
    font-size: 2.2rem;
  }

  .overlay-card {
    padding: 20px 16px;
    max-width: 340px;
    border-radius: 16px;
  }

  .overlay-card h2 {
    font-size: 1.7rem;
    margin-bottom: 6px;
  }

  .overlay-subtitle {
    font-size: 0.85rem;
    margin-bottom: 12px;
  }

  .high-score-challenge {
    padding: 8px 12px;
    font-size: 0.85rem;
    margin-bottom: 12px;
  }

  .legend {
    gap: 6px;
    margin-bottom: 16px;
  }

  .legend-item {
    padding: 5px 10px;
    font-size: 0.8rem;
    gap: 8px;
  }

  .legend-icon {
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
  }

  .btn {
    font-size: 1.1rem;
    padding: 10px 32px;
  }

  .final-stats {
    gap: 8px;
    margin-bottom: 14px;
  }

  .final-stat {
    padding: 8px 10px;
    min-width: 65px;
  }

  .final-label {
    font-size: 0.65rem;
  }

  .final-value {
    font-size: 1.4rem;
  }

  .new-record {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .combo-milestone {
    font-size: 1.6rem;
  }

  .floating-score {
    font-size: 1.2rem;
  }

  .floating-score.golden {
    font-size: 1.5rem;
  }
}

@media (max-width: 380px) {
  .game-title {
    font-size: 1.5rem;
  }

  .stat {
    padding: 4px 8px;
    font-size: 0.75rem;
    min-width: 55px;
  }

  .stat-icon {
    font-size: 0.85rem;
  }

  .game-board {
    gap: 4px;
    padding: 6px;
  }

  .mole.bomb {
    font-size: 1.8rem;
  }

  .overlay-card {
    padding: 16px 12px;
  }

  .overlay-card h2 {
    font-size: 1.5rem;
  }

  .legend-item {
    font-size: 0.75rem;
  }

  .btn {
    font-size: 1rem;
    padding: 9px 26px;
  }
}
