:root {
  --sky: #BFE3F2;
  --grass: #7BBF5A;
  --grass-edge: #5E9A40;
  --ink: #3A2716;
  --ink-soft: #6B4E33;
  --paper: #FFF8E8;
  --red: #B33A1E;
  --pit: #3E2716;
  --rim: #6B4528;
  --fur: #8B5A3C;
  --fur-light: #C99A73;
  --cell: min(170px, 27vw, 21vh);
  --hammer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg transform='rotate(-35 24 24)'%3E%3Crect x='21' y='16' width='6' height='30' rx='3' fill='%23C98B4F' stroke='%233A2716' stroke-width='2'/%3E%3Crect x='8' y='4' width='32' height='16' rx='5' fill='%23B33A1E' stroke='%233A2716' stroke-width='2.5'/%3E%3C/g%3E%3C/svg%3E") 10 10, pointer;
  --hammer-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cg transform='rotate(-80 24 24)'%3E%3Crect x='21' y='16' width='6' height='30' rx='3' fill='%23C98B4F' stroke='%233A2716' stroke-width='2'/%3E%3Crect x='8' y='4' width='32' height='16' rx='5' fill='%23B33A1E' stroke='%233A2716' stroke-width='2.5'/%3E%3C/g%3E%3C/svg%3E") 10 10, pointer;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  touch-action: manipulation;  /* no double-tap zoom */
  -webkit-touch-callout: none; /* no long-press menu on the faces */
  overscroll-behavior: none;
  background: var(--sky);
  color: var(--ink);
  font-family: 'Jua', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game {
  position: relative;
  max-width: 960px;
  height: 100%;
  max-height: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 0;
}
h1 { margin: 0; font-size: clamp(32px, 6vw, 44px); font-weight: 400; }
.stats { display: flex; gap: 10px; }
.stat {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 6px 16px;
  min-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat span { font-size: 14px; color: var(--ink-soft); }
.stat b { font-size: 28px; font-weight: 400; }
.red { color: var(--red); }

.field {
  flex: 1;
  margin-top: 20px;
  background: var(--grass);
  border-top: 6px solid var(--grass-edge);
  border-radius: 48px 48px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 72px;
  cursor: var(--hammer);
  touch-action: none; /* taps go to the game, never scroll or zoom */
}
.field.down { cursor: var(--hammer-down); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: min(64px, 5vw);
  row-gap: 4px;
}

/* One hole. Everything is sized from --cell so it scales on phones. */
.hole {
  position: relative;
  width: var(--cell);
  height: calc(var(--cell) * 0.9);
  padding: 0;
  border: 0;
  background: none;
  cursor: inherit;
  font: inherit;
}
.hole:focus-visible { outline: 4px solid var(--paper); outline-offset: 2px; border-radius: 16px; }
.pit {
  position: absolute;
  left: 6%; width: 88%;
  bottom: 5%; height: 34%;
  border-radius: 50%;
  background: var(--pit);
}
.clip {
  position: absolute;
  left: 0; right: 0;
  top: -40%;
  bottom: 22%;
  overflow: hidden;
  pointer-events: none;
}
.mole {
  position: absolute;
  left: 19%; width: 62%;
  bottom: -6%; height: 78%;
  transform: translateY(105%);
  transition: transform 0.12s ease-out;
}
.hole.up .mole { transform: translateY(0); pointer-events: auto; } /* the head above the hole is a target too */
.hole.hit .mole { transform: translateY(0); }
.hole.gone .mole { transition-duration: 0.18s; transform: translateY(105%); }

.body {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 24% 24% / 42% 42% 18% 18%;
  background: var(--fur);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12);
}
.face {
  position: absolute;
  left: 10%; width: 80%;
  top: 7%;
  border-radius: 50%;
  transition: transform 0.1s, filter 0.1s;
}
.ear {
  position: absolute;
  top: 4%;
  width: 24%; aspect-ratio: 1;
  border-radius: 50%;
  background: var(--fur);
  border: 4px solid var(--fur-light);
  z-index: -1;
}
.ear.l { left: -4%; }
.ear.r { right: -4%; }
.paw {
  position: absolute;
  bottom: 10%;
  width: 26%; height: 14%;
  border-radius: 50% 50% 40% 40%;
  background: var(--fur-light);
  border: 2px solid var(--fur);
}
.paw.l { left: 4%; }
.paw.r { right: 4%; }
.stars {
  position: absolute;
  left: 0; right: 0; top: -2%;
  text-align: center;
  color: #FFD23F;
  font-size: calc(var(--cell) * 0.13);
  letter-spacing: 2px;
  -webkit-text-stroke: 1px var(--ink);
  opacity: 0;
}
.hole.hit .face { transform: scale(1.05, 0.86) rotate(-6deg); filter: saturate(0.6) brightness(0.92); }
.hole.hit .stars { opacity: 1; animation: spin 0.4s linear infinite; }

.rim {
  position: absolute;
  left: 2%; width: 96%;
  bottom: 0; height: 22%;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  background: var(--rim);
  pointer-events: none;
}
.pop {
  position: absolute;
  left: 0; right: 0; top: -30%;
  text-align: center;
  font-size: calc(var(--cell) * 0.2);
  color: var(--paper);
  -webkit-text-stroke: 1.5px var(--ink);
  opacity: 0;
  pointer-events: none;
}
.pop.show { animation: pop 0.6s ease-out; }
.hole.miss .pit { animation: shake 0.2s; }

@keyframes spin { 50% { transform: translateY(-4px) rotate(4deg); } }
@keyframes pop {
  0% { opacity: 0; transform: translateY(10px) scale(0.8); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-24px) scale(1); }
}
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.combo {
  position: absolute;
  left: 32px; bottom: 18px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 18px;
  font-size: 20px;
  transition: transform 0.1s;
}
.combo.bump { transform: scale(1.15); }

.btn {
  font-family: inherit;
  color: var(--paper);
  background: var(--red);
  border: 3px solid var(--ink);
  border-radius: 999px;
  min-height: 48px;
  padding: 8px 26px;
  font-size: 22px;
  cursor: pointer;
}
.btn:active { transform: translateY(2px); }
.controls { position: absolute; right: 32px; bottom: 14px; display: flex; gap: 10px; }
.btn.ghost { background: var(--paper); color: var(--ink); }

/* Pop speed follows the level (set from game.js). */
.mole { transition-duration: var(--rise, 0.12s); }

/* -- hit effects ----------------------------------------------------------- */
.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* The grip sits down and to the right of the target; rotating -51deg brings the head onto it. */
.hammer {
  position: absolute;
  width: 84px; height: 84px;
  margin: -40px 0 0 8px;
  transform-origin: 50% 95%;
  animation: swing 0.28s ease-in forwards;
}
.hammer svg { display: block; }
.word {
  position: absolute;
  margin: -64px 0 0 -90px;
  font-size: 30px;
  color: var(--word, #FFF8E8);
  -webkit-text-stroke: 1.5px var(--ink);
  white-space: nowrap;
  animation: word 0.55s ease-out forwards;
}
.spark.heart { width: 16px; height: 14px; border: 0; border-radius: 0; clip-path: polygon(50% 100%, 0 42%, 4% 14%, 24% 0, 50% 18%, 76% 0, 96% 14%, 100% 42%); }
.spark.star { width: 18px; height: 18px; border: 0; border-radius: 0; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }
.spark.shard { width: 10px; height: 18px; border: 0; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 70%); }
.spark.circle { border-radius: 50%; border-width: 1px; }
.spark.slow { animation-duration: 0.95s; animation-timing-function: cubic-bezier(.1, .6, .3, 1); }

/* -- weapon picker ----------------------------------------------------------- */
.pick-label { margin: 0 0 8px !important; color: var(--ink) !important; font-size: 18px !important; }
.weapons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.weapon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 76px;
  padding: 6px 2px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #FFFFFF;
  border: 3px solid #E6DCC6;
  border-radius: 16px;
  cursor: pointer;
}
.weapon svg { width: 42px; height: 42px; }
.weapon[aria-pressed="true"] { border-color: var(--ink); background: #FFE9A8; }
.weapon:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.ring {
  position: absolute;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 5px solid #FFF8E8;
  animation: ring 0.4s ease-out forwards;
}
.spark {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 3px;
  border: 2px solid var(--ink);
  animation: spark 0.55s cubic-bezier(.2, .7, .4, 1) forwards;
}
.hole.hit .face { animation: flash 0.18s; }
.field.shake { animation: quake 0.25s; }

.banner {
  position: absolute;
  left: 0; right: 0; top: 42%;
  text-align: center;
  font-size: clamp(40px, 9vw, 72px);
  color: #FFD23F;
  -webkit-text-stroke: 2.5px var(--ink);
  pointer-events: none;
  opacity: 0;
}
.banner.show { animation: banner 1.1s ease-out; }
.banner.small { font-size: clamp(30px, 6vw, 48px); color: var(--paper); }
#time-box.warn { animation: pulse 0.5s infinite alternate; background: #FFD9CC; }

@keyframes swing {
  0% { transform: rotate(25deg); opacity: 1; }
  50% { transform: rotate(-51deg); }
  70% { transform: rotate(-44deg); opacity: 1; }
  100% { transform: rotate(-48deg); opacity: 0; }
}
@keyframes word {
  0% { opacity: 0; transform: scale(0.5) rotate(-12deg); }
  25% { opacity: 1; transform: scale(1.2) rotate(-8deg); }
  100% { opacity: 0; transform: scale(1) rotate(-8deg) translateY(-14px); }
}
@keyframes ring { to { transform: scale(7); opacity: 0; border-width: 1px; } }
@keyframes spark {
  from { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(260deg) scale(0.3); opacity: 0; }
}
@keyframes flash { 0% { filter: brightness(2.2) saturate(0); } 100% { filter: saturate(0.6) brightness(0.92); } }
@keyframes quake {
  20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); } 80% { transform: translate(3px, 3px); }
}
@keyframes banner {
  0% { opacity: 0; transform: scale(0.4); }
  18% { opacity: 1; transform: scale(1.15); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}
@keyframes pulse { to { transform: scale(1.08); } }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(58, 39, 22, 0.55);
  padding: 16px;
}
.overlay[hidden] { display: none; }
.card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 32px;
  padding: 24px 28px;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
}
.card-face { width: 84px; border-radius: 50%; background: var(--fur); padding: 8px; }
.card h2 { margin: 8px 0 6px; font-size: 36px; font-weight: 400; }
.card p { margin: 0 0 18px; font-size: 18px; line-height: 1.5; color: var(--ink-soft); }
.card .hint { margin: 14px 0 0; font-size: 14px; }

@media (max-width: 560px) {
  .top { padding: 16px 16px 0; }
  .stat { min-width: 0; padding: 4px 10px; }
  .stat b { font-size: 22px; }
  .combo { left: 16px; font-size: 16px; padding: 6px 12px; }
  .controls { right: 16px; gap: 6px; }
  .controls .btn { font-size: 17px; padding: 6px 14px; }
  .card { padding: 18px 14px; border-radius: 24px; }
  .card-face { width: 64px; }
  .card h2 { font-size: 30px; }
  .card p { font-size: 16px; margin-bottom: 12px; }
  .weapons { gap: 6px; }
  .weapon { min-height: 66px; font-size: 13px; }
  .weapon svg { width: 34px; height: 34px; }
}

/* -- name and leaderboard ------------------------------------------------------ */
.pick-label { display: block; }
.name-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 18px;
  padding: 10px 16px;
  font: inherit;
  font-size: 20px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
}
.name-input:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.name-input.bad { border-color: var(--red); background: #FFE7DF; }
.card .name-err { margin: -10px 0 14px; font-size: 15px; color: var(--red); }

.board { margin-top: 22px; padding-top: 18px; border-top: 3px dashed var(--ink-soft); text-align: left; }
.board h3 { margin: 0 0 10px; font-size: 24px; font-weight: 400; text-align: center; }
.card .board-note { margin: 0 0 10px; font-size: 15px; text-align: center; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.board-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 18px;
  border-radius: 14px;
  background: #F3E9D2;
}
.board-list li:nth-child(1) { background: #FFE08A; }
.board-list li:nth-child(2) { background: #E9E4DA; }
.board-list li:nth-child(3) { background: #F2CFA8; }
.board-list li.me { outline: 3px solid var(--red); outline-offset: -3px; }
.board-list .rank { text-align: center; color: var(--ink-soft); }
.board-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .who small { font-size: 12px; color: var(--paper); background: var(--red); border-radius: 999px; padding: 1px 7px; vertical-align: 2px; }
.board-list .pts { font-variant-numeric: tabular-nums; }

@media (min-width: 900px) {
  .card { max-width: 900px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; }
  .card-face { width: 60px; }
  .card h2 { margin: 4px 0; }
  .card p { font-size: 16px; margin-bottom: 12px; }
  .name-input { margin-bottom: 12px; padding: 8px 16px; }
  .weapon { min-height: 66px; }
  .weapon svg { width: 32px; height: 32px; }
  .board { margin: 0; padding: 0 0 0 26px; border-top: 0; border-left: 3px dashed var(--ink-soft); overflow-y: auto; }
}
@media (max-width: 560px) {
  .name-input { font-size: 18px; padding: 8px 14px; margin-bottom: 12px; }
  .board-list li { font-size: 16px; padding: 5px 10px; }
}
