@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;600;700&display=swap');

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

:root {
  --amber: #f59e0b;
  --amber2: #fbbf24;
  --red: #ef4444;
  --green: #10b981;
  --bg: #0c0a04;
  --bg2: #1a1206;
  --card: rgba(245,158,11,0.06);
  --border: rgba(245,158,11,0.25);
  --text: #fef3c7;
  --muted: #92400e;
}

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(245,158,11,0.1) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(251,191,36,0.07) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.game-wrapper {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 12px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ── Header ── */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  font-family: 'Orbitron', monospace;
  font-size: 0.55rem;
  font-weight: 900;
  color: var(--amber);
  letter-spacing: 2px;
}

.game-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--amber), var(--amber2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Stats bar ── */
.stats-bar {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.stat-pill {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.stat-label {
  font-family: 'Orbitron', monospace;
  font-size: 0.5rem;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stat-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(245,158,11,0.5);
  line-height: 1;
}

.stat-value.timer-val { color: #60a5fa; text-shadow: 0 0 12px rgba(96,165,250,0.5); }
.stat-value.timer-val.urgent { color: var(--red); text-shadow: 0 0 12px rgba(239,68,68,0.6); animation: timerPulse 0.5s ease-in-out infinite alternate; }

@keyframes timerPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.15); }
}

/* ── Difficulty row ── */
.diff-row {
  width: 100%;
  display: flex;
  gap: 6px;
}

.diff-btn {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(245,158,11,0.05);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-family: 'Inter', sans-serif;
}

.diff-btn.active, .diff-btn:hover {
  background: rgba(245,158,11,0.18);
  border-color: var(--amber);
  color: var(--text);
}

/* ── Game board ── */
.board-container {
  width: 100%;
  max-width: 500px;
  position: relative;
}

#ground {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(245,158,11,0.08);
}

.place {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(245,158,11,0.12);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  position: relative;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.place:hover { border-color: rgba(245,158,11,0.3); }
.place:active { background: rgba(245,158,11,0.1); }

/* Mole rendered as emoji/CSS mole */
.place .mole-figure {
  position: absolute;
  bottom: -100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  line-height: 1;
  transition: bottom 0.15s ease-out;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.place.mole-up .mole-figure {
  bottom: 4px;
  animation: moleAppear 0.15s ease-out;
}

@keyframes moleAppear {
  from { bottom: -60%; transform: translateX(-50%) scale(0.7); }
  to   { bottom: 4px; transform: translateX(-50%) scale(1); }
}

.place.whacked .mole-figure {
  animation: moleWhacked 0.25s ease-out forwards;
}

@keyframes moleWhacked {
  0%   { transform: translateX(-50%) scale(1.3) rotate(-10deg); }
  50%  { transform: translateX(-50%) scale(0.5) rotate(15deg); opacity: 0.5; }
  100% { transform: translateX(-50%) scale(0) rotate(30deg); opacity: 0; bottom: -100%; }
}

/* Hit flash */
.place.hit-flash { animation: hitFlash 0.2s ease; }
@keyframes hitFlash {
  0%,100% { background: rgba(0,0,0,0.4); }
  50%      { background: rgba(245,158,11,0.3); border-color: var(--amber); }
}

/* ── +1 score popup ── */
.score-popup {
  position: absolute;
  font-family: 'Orbitron', monospace;
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(245,158,11,0.8);
  pointer-events: none;
  animation: scorePopup 0.7s ease forwards;
  z-index: 10;
}

@keyframes scorePopup {
  from { transform: translate(-50%, 0) scale(1.2); opacity: 1; }
  to   { transform: translate(-50%, -40px) scale(0.8); opacity: 0; }
}

/* ── Controls ── */
.controls {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.ctrl-btn {
  padding: 10px 24px;
  border-radius: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--amber), var(--amber2));
  border: none;
  color: #1a0e00;
  box-shadow: 0 4px 20px rgba(245,158,11,0.4);
}

.ctrl-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(245,158,11,0.5); }
.ctrl-btn.secondary {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--amber);
}
.ctrl-btn.secondary:hover { background: rgba(245,158,11,0.12); }

/* ── Game over overlay ── */
.gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.gameover-overlay.hidden { display: none; }

.gameover-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 60px rgba(245,158,11,0.2);
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.gameover-emoji { font-size: 3rem; }
.gameover-title { font-family: 'Orbitron', monospace; font-size: 1.2rem; font-weight: 900; color: var(--amber); }
.gameover-msg   { font-size: 0.9rem; color: var(--muted); }
.gameover-score { font-family: 'Orbitron', monospace; font-size: 2rem; font-weight: 900; color: var(--text); }
.gameover-best  { font-size: 0.75rem; color: var(--muted); font-family: 'Orbitron', monospace; }

/* ── How to ── */
.how-to {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .game-wrapper { padding: 10px 8px 16px; gap: 8px; }
  #ground { gap: 5px; padding: 5px; }
  .stat-value { font-size: 1.1rem; }
  .game-title { font-size: 0.85rem; }
}