:root {
  --bg: #0c0f19;
  --panel: #0f1724;
  --accent: #ffce45;
  --accent-strong: #ff5930;
  --text: #f7f2e9;
  --muted: #c3c3d6;
  --grid: #1a2233;
  --success: #76e0a6;
  --warning: #f5d76e;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --font: "Trebuchet MS", "Gill Sans", "Futura", system-ui, sans-serif;
  --fair-red: #f23c3c;
  --fair-blue: #3aa3ff;
  --fair-yellow: #ffd34f;
  --cell-size-height: calc((100vh - 420px) / 3);
  --cell-size: clamp(68px, 17vw, min(120px, var(--cell-size-height)));
  --cell-gap: 10px;
  --mole-base: #b6794a;
  --mole-dark: #5a341d;
  --mole-nose: #f6d6b8;
  --bomb-shell: #16191f;
  --bomb-shell-light: #2b303a;
  --bomb-fuse: #7a4a17;
  --bomb-spark: #ffb84d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

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

.overlay-card {
  background: linear-gradient(160deg, rgba(255, 206, 69, 0.16), rgba(12, 17, 26, 0.9));
  border: 1px solid rgba(255, 206, 69, 0.35);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(0, 0, 0, 0.35);
  text-align: center;
  min-width: 260px;
}

.overlay-card h2 {
  margin: 6px 0 10px;
}

.background-waves {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 10% 10%, rgba(255, 89, 48, 0.18), transparent 40%),
    radial-gradient(120% 80% at 90% 12%, rgba(58, 163, 255, 0.18), transparent 42%),
    linear-gradient(115deg, rgba(255, 206, 69, 0.14) 0%, rgba(12, 15, 25, 0) 35%),
    repeating-linear-gradient(90deg, rgba(255, 206, 69, 0.04) 0 12px, transparent 12px 24px);
  z-index: 0;
}

.background-waves::before,
.background-waves::after {
  content: "";
  position: fixed;
  inset: -40%;
  background: radial-gradient(circle at 30% 20%, rgba(255, 107, 53, 0.35), transparent 45%), radial-gradient(circle at 80% 20%, rgba(255, 180, 84, 0.22), transparent 50%), radial-gradient(circle at 50% 80%, rgba(118, 224, 166, 0.22), transparent 45%);
  filter: blur(24px);
  z-index: 0;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 0.9fr);
  grid-template-areas:
    "header header"
    "stats stats"
    "board footer";
  align-items: start;
  gap: 10px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.35), 0 24px 50px rgba(0, 0, 0, 0.35);
  overflow: visible;
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: -12px;
  background: radial-gradient(circle at 10% 30%, rgba(255, 206, 69, 0.4), transparent 30%), radial-gradient(circle at 90% 20%, rgba(255, 89, 48, 0.35), transparent 32%), radial-gradient(circle at 50% 10%, rgba(58, 163, 255, 0.35), transparent 34%);
  filter: blur(18px);
  z-index: -1;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

header.panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  grid-area: header;
  background: linear-gradient(120deg, rgba(255, 89, 48, 0.2), rgba(58, 163, 255, 0.18));
  border: 1px solid rgba(255, 206, 69, 0.2);
}

.eyebrow {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
  margin: 0 0 4px;
}

h1 {
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.controls {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent-strong), var(--accent));
  color: #0b0b10;
  box-shadow: 0 12px 25px rgba(255, 107, 53, 0.35);
  border: 1px solid rgba(255, 206, 69, 0.4);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.btn:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
  grid-area: stats;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(12, 17, 26, 0.6));
  border-radius: 14px;
  border: 1px solid rgba(255, 206, 69, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.label {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.value {
  font-weight: 800;
  font-size: 26px;
}

.board {
  padding: 8px;
  max-width: 540px;
  margin: 0 auto;
  grid-area: board;
  background: radial-gradient(140% 120% at 50% 0%, rgba(255, 206, 69, 0.08), transparent 50%), linear-gradient(135deg, rgba(255, 89, 48, 0.1), rgba(58, 163, 255, 0.1));
  border: 1px solid rgba(255, 206, 69, 0.2);
  border-radius: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, var(--cell-size)));
  grid-auto-rows: var(--cell-size);
  justify-content: center;
  gap: var(--cell-gap);
  padding: 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(15, 23, 36, 0.8), rgba(12, 15, 25, 0.9));
  max-width: 540px;
  margin: 0 auto;
}

.hole {
  position: relative;
  background: radial-gradient(120% 100% at 50% 20%, rgba(255, 206, 69, 0.06), transparent 42%), linear-gradient(160deg, var(--grid), #0c1624);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  box-shadow: inset 0 12px 32px rgba(0, 0, 0, 0.45);
  aspect-ratio: 1 / 1;
}

.hole .ring {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}

.mole {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transform: translateY(60%);
  transition: opacity 180ms ease, transform 220ms ease, filter 120ms ease;
}

.mole.up {
  opacity: 1;
  transform: translateY(-6%);
}

.mole button {
  border: 3px solid #7a0a0a;
  background: linear-gradient(180deg, #ff4040, #a80000);
  width: 70%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 64, 64, 0.25);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 80ms ease, box-shadow 80ms ease, filter 100ms ease;
}

.mole button:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.25), 0 0 10px rgba(255, 82, 82, 0.28);
}

.mole.bomb button {
  border-color: #0d0f13;
  background: radial-gradient(100% 100% at 30% 32%, rgba(255, 255, 255, 0.1), transparent 40%), linear-gradient(180deg, var(--bomb-shell-light), var(--bomb-shell));
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.45), 0 0 18px rgba(0, 0, 0, 0.35);
  overflow: visible;
}

.mole.bomb button::before {
  content: "";
  position: absolute;
  width: 8%;
  height: 44%;
  background: linear-gradient(180deg, #9f6b2a, var(--bomb-fuse));
  border-radius: 50px;
  top: -22%;
  right: 18%;
  transform: rotate(18deg);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2), 0 4px 0 rgba(0, 0, 0, 0.15);
}

.mole.bomb button::after {
  content: "";
  position: absolute;
  width: 18%;
  height: 22%;
  background:
    radial-gradient(80% 80% at 50% 70%, rgba(0, 0, 0, 0.18), transparent 55%),
    radial-gradient(60% 80% at 40% 20%, #ffd27c 0 35%, rgba(255, 184, 77, 0.8) 60%, transparent 72%),
    radial-gradient(80% 80% at 60% 40%, #fff4d6 0 28%, #ffc65c 40%, rgba(255, 184, 77, 0.4) 70%, transparent 80%);
  border-radius: 40% 60% 50% 65%;
  top: -8%;
  right: 4%;
  filter: drop-shadow(0 0 6px rgba(255, 184, 77, 0.9));
  animation: spark 380ms infinite ease-in-out;
}

.mole.bomb.explode button {
  animation: bomb-pop 260ms ease forwards;
  box-shadow: 0 18px 26px rgba(0, 0, 0, 0.45), 0 0 24px rgba(255, 180, 77, 0.4);
}

.mole.bomb.explode button::before {
  display: none;
}

.mole.bomb.explode button::after {
  width: 220%;
  height: 220%;
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  background: radial-gradient(circle at 50% 50%, #fff4d6 0%, rgba(255, 214, 138, 0.9) 28%, rgba(255, 180, 77, 0.18) 60%, transparent 70%);
  filter: blur(2px);
  animation: bomb-flash 260ms ease forwards;
}

@keyframes spark {
  0% {
    transform: translate(-6%, 2%) scale(0.8) rotate(-6deg);
    opacity: 0.75;
    filter: drop-shadow(0 0 5px rgba(255, 184, 77, 0.8));
  }
  40% {
    transform: translate(4%, -4%) scale(1.05) rotate(4deg);
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(255, 214, 138, 1));
  }
  70% {
    transform: translate(-3%, -6%) scale(0.95) rotate(-2deg);
    opacity: 0.9;
  }
  100% {
    transform: translate(3%, 3%) scale(1.08) rotate(6deg);
    opacity: 0.7;
    filter: drop-shadow(0 0 4px rgba(255, 170, 64, 0.7));
  }
}

@keyframes bomb-pop {
  0% {
    transform: scale(1);
  }
  60% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes bomb-flash {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(50%, -50%) scale(1.6);
  }
}
.mole button .ears,
.mole button .face,
.mole button .face::before,
.mole button .face::after,
.mole button .mouth,
.mole button .mouth::before,
.mole button .mouth::after,
.mole button .whiskers,
.mole button .whiskers::before,
.mole button .whiskers::after {
  display: none;
}

.mole button .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.mole button .face::before {
  content: "";
  width: 10%;
  aspect-ratio: 1;
  background: var(--mole-dark);
  border-radius: 50%;
  box-shadow: 18px 0 0 0 var(--mole-dark);
  transform: translateY(-6px);
}

.mole button .face::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 22%;
  background: var(--mole-nose);
  border-radius: 50% 50% 60% 60%;
  border: 2px solid var(--mole-dark);
  border-top-width: 3px;
  transform: translateY(14px);
  box-shadow: 0 6px 0 -2px rgba(0, 0, 0, 0.25);
}

.mole button .mouth {
  position: absolute;
  width: 36%;
  height: 18%;
  background: #2f1c12;
  border-radius: 0 0 40% 40%;
  bottom: 14%;
  left: 32%;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
}

.mole button .mouth::after {
  content: "";
  position: absolute;
  inset: 0 26% auto 26%;
  height: 45%;
  background: #f4eedc;
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.mole button .mouth::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -14px;
  width: 28px;
  height: 2px;
  background: var(--mole-dark);
  box-shadow: 40px 0 0 0 var(--mole-dark);
}

.mole button .whiskers {
  position: absolute;
  width: 90%;
  height: 60%;
  top: 26%;
  left: 5%;
  pointer-events: none;
}

.mole button .whiskers::before,
.mole button .whiskers::after {
  content: "";
  position: absolute;
  width: 48%;
  height: 70%;
  top: 10%;
  left: 0;
  background:
    radial-gradient(140% 180% at 100% 50%, transparent 56%, var(--mole-dark) 57% 60%, transparent 63%) 0% 0%/100% 24% no-repeat,
    radial-gradient(140% 180% at 100% 50%, transparent 56%, var(--mole-dark) 57% 60%, transparent 63%) 0% 38%/100% 24% no-repeat,
    radial-gradient(140% 180% at 100% 50%, transparent 56%, var(--mole-dark) 57% 60%, transparent 63%) 0% 76%/100% 24% no-repeat;
  transform-origin: right center;
  transform: rotate(-12deg);
}

.mole button .whiskers::after {
  left: auto;
  right: 0;
  transform-origin: left center;
  transform: rotate(12deg) scaleX(-1);
}

.mole button:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 8px 14px rgba(255, 148, 85, 0.25);
}

.mole.good {
  filter: drop-shadow(0 0 12px rgba(118, 224, 166, 0.7));
}

.mole.bad {
  filter: drop-shadow(0 0 12px rgba(245, 215, 110, 0.9));
}

.footer {
  color: var(--muted);
  font-size: 14px;
  max-width: 280px;
  align-self: stretch;
  text-align: left;
  grid-area: footer;
  background: linear-gradient(120deg, rgba(255, 206, 69, 0.08), rgba(255, 89, 48, 0.08));
  border: 1px solid rgba(255, 206, 69, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
}

@media (max-width: 700px) {
  body {
    padding: 16px 8px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "stats"
      "board"
      "footer";
    border-width: 2px;
  }

  header.panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    width: 100%;
  }

  .controls .btn {
    flex: 1;
    text-align: center;
  }

  :root {
    --cell-size-height: calc((100vh - 220px) / 3);
    --cell-size: clamp(64px, 24vw, min(110px, var(--cell-size-height)));
    --cell-gap: 6px;
  }

  .board {
    max-width: 420px;
  }

  .hole .ring {
    inset: 10px;
  }

  .mole button {
    width: 64%;
  }

  .footer {
    max-width: 100%;
    text-align: left;
    margin-left: 0;
    align-self: stretch;
  }
}

@media (max-height: 720px) {
  :root {
    --cell-size-height: calc((100vh - 230px) / 3);
    --cell-size: clamp(64px, 18vw, min(105px, var(--cell-size-height)));
    --cell-gap: 8px;
  }

  .panel {
    padding: 14px 16px;
  }

  h1 {
    font-size: 28px;
  }

  .lede {
    font-size: 15px;
  }

  .game-shell {
    gap: 10px;
  }

  .board {
    padding: 10px;
  }
}

@media (max-height: 620px) {
  :root {
    --cell-size-height: calc((100vh - 170px) / 3);
    --cell-size: clamp(56px, 17vw, min(86px, var(--cell-size-height)));
    --cell-gap: 6px;
  }

  .stats {
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .value {
    font-size: 22px;
  }

  .footer {
    font-size: 13px;
  }
}
