/* ============ Mole Party! stylesheet ============ */

:root {
  --kid-font: "Chalkboard SE", "Comic Sans MS", "Marker Felt", "Segoe Print", "Baloo 2", cursive, sans-serif;
  --panel-bg: #fffdf4;
  --panel-shadow: 0 10px 0 rgba(140, 90, 40, .25), 0 18px 40px rgba(30, 60, 20, .25);
  --btn-green: #58c14e;
  --btn-green-dark: #3d9a35;
  --btn-yellow: #ffc93c;
  --btn-yellow-dark: #e0a416;
  --ink: #4c3a28;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #8ed3f5;
  font-family: var(--kid-font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#game-root { position: fixed; inset: 0; }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 128px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 20;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 253, 244, .95);
  border: 3px solid #f0b64f;
  border-radius: 999px;
  padding: 4px 16px 4px 10px;
  font-size: clamp(20px, 3.4vmin, 30px);
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(140, 90, 40, .25);
  min-width: 92px;
  justify-content: flex-start;
  transition: transform .12s ease-out;
}

.hud-pill.bump { transform: scale(1.16); }
.hud-icon { font-size: .9em; }
.hud-round { min-width: 0; }

.hud-timer {
  position: relative;
  flex: 1;
  max-width: 300px;
  height: clamp(20px, 3vmin, 26px);
  margin-left: 4px;
  background: rgba(255, 253, 244, .9);
  border: 3px solid #f0b64f;
  border-radius: 999px;
  overflow: visible;
  box-shadow: 0 4px 0 rgba(140, 90, 40, .25);
}

.hud-timer-fill {
  position: absolute;
  inset: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd93c, #ff9f43);
  transform-origin: left center;
  transition: transform .3s linear;
}

.hud-timer.low .hud-timer-fill { background: linear-gradient(90deg, #ff9f43, #ff6b6b); }

.hud-timer-sun {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -54%);
  font-size: clamp(22px, 3.6vmin, 30px);
  transition: left .3s linear;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}

/* ---------- Corner controls ---------- */

#corner-controls {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 40;
}

.round-btn {
  width: clamp(46px, 7vmin, 56px);
  height: clamp(46px, 7vmin, 56px);
  border-radius: 50%;
  border: 3px solid #f0b64f;
  background: rgba(255, 253, 244, .95);
  font-size: clamp(20px, 3.4vmin, 26px);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(140, 90, 40, .3);
  transition: transform .1s;
  line-height: 1;
}

.round-btn:active { transform: scale(.9) translateY(2px); box-shadow: 0 2px 0 rgba(140,90,40,.3); }
.round-btn.muted { filter: grayscale(1); opacity: .75; }

/* ---------- Combo chip ---------- */

#combo-chip {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #ff8fd0, #f75fb8);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 4px 18px;
  font-size: clamp(20px, 3.6vmin, 30px);
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(150, 20, 90, .4);
  box-shadow: 0 5px 14px rgba(200, 40, 130, .4);
  z-index: 25;
  pointer-events: none;
  animation: combo-pop .25s ease-out;
}

@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(.4); }
  70% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---------- Encouragement banner ---------- */

#banner {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  font-size: clamp(34px, 7vmin, 64px);
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 2px rgba(180, 90, 0, .35);
  text-shadow: 0 4px 0 #e8862c, 0 8px 18px rgba(120, 60, 0, .35);
  z-index: 30;
  pointer-events: none;
  white-space: nowrap;
  animation: banner-in .9s ease-out forwards;
}

#banner.gold { text-shadow: 0 4px 0 #c9930a, 0 8px 22px rgba(160, 110, 0, .5); }
#banner.oops { text-shadow: 0 4px 0 #7f9fe8, 0 8px 18px rgba(40, 70, 160, .35); }

@keyframes banner-in {
  0% { transform: translateX(-50%) rotate(-3deg) scale(.2); opacity: 0; }
  18% { transform: translateX(-50%) rotate(2deg) scale(1.15); opacity: 1; }
  32% { transform: translateX(-50%) rotate(-2deg) scale(1); }
  75% { transform: translateX(-50%) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) rotate(0deg) scale(1.05) translateY(-16px); opacity: 0; }
}

/* ---------- Overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vmin, 22px);
  z-index: 50;
  padding: 16px;
  text-align: center;
}

.overlay.dim { background: rgba(40, 80, 40, .45); backdrop-filter: blur(3px); }
.overlay.soft { pointer-events: none; }

/* ---------- Title screen ---------- */

#title-overlay { justify-content: flex-start; padding-top: clamp(28px, 9vh, 90px); }

.title-word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .04em;
  font-size: clamp(52px, 13vmin, 120px);
  font-weight: 800;
  line-height: 1;
}

.title-word .tl {
  display: inline-block;
  color: var(--c, #ff6b6b);
  -webkit-text-stroke: 2.5px rgba(255,255,255,.9);
  text-shadow: 0 5px 0 rgba(120, 60, 10, .35), 0 10px 24px rgba(60, 90, 30, .35);
  animation: letter-bounce 2.4s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

.title-word .tl.space { width: .35em; }

@keyframes letter-bounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  10% { transform: translateY(-.16em) rotate(3deg) scale(1.06); }
  20% { transform: translateY(0) rotate(-1deg); }
}

.title-sub {
  font-size: clamp(17px, 3.2vmin, 26px);
  color: #2c5a1e;
  background: rgba(255, 253, 244, .85);
  padding: 4px 18px;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(140, 90, 40, .18);
}

.big-btn {
  font-family: var(--kid-font);
  font-size: clamp(26px, 5.4vmin, 44px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #6fd863, var(--btn-green));
  border: 4px solid #fff;
  border-radius: 999px;
  padding: clamp(10px, 2vmin, 18px) clamp(34px, 7vmin, 64px);
  cursor: pointer;
  box-shadow: 0 7px 0 var(--btn-green-dark), 0 14px 30px rgba(30, 90, 20, .35);
  text-shadow: 0 2px 0 rgba(20, 90, 10, .4);
  transition: transform .12s;
}

.big-btn:hover { transform: scale(1.05); }
.big-btn:active { transform: scale(.94) translateY(4px); box-shadow: 0 3px 0 var(--btn-green-dark); }

.play-btn { margin-top: clamp(8px, 2vh, 22px); animation: play-pulse 1.6s ease-in-out infinite; }

@keyframes play-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.mid-btn {
  font-family: var(--kid-font);
  font-size: clamp(18px, 3.4vmin, 26px);
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, #ffe9a8, var(--btn-yellow));
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 8px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--btn-yellow-dark);
  transition: transform .12s;
}

.mid-btn:active { transform: scale(.94) translateY(3px); box-shadow: 0 2px 0 var(--btn-yellow-dark); }

.title-hints {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: clamp(4px, 1.6vh, 14px);
}

.hint-chip {
  background: rgba(255, 253, 244, .9);
  border: 3px solid #f0b64f;
  border-radius: 999px;
  padding: 5px 16px;
  font-size: clamp(15px, 2.8vmin, 22px);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(140, 90, 40, .2);
}

.title-best {
  font-size: clamp(16px, 3vmin, 24px);
  color: #6b4d2e;
  background: rgba(255,253,244,.85);
  border-radius: 999px;
  padding: 4px 16px;
}

/* ---------- Round intro ---------- */

#round-intro { gap: 8px; }

.intro-round {
  font-size: clamp(44px, 10vmin, 92px);
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 3px rgba(34, 84, 22, .6);
  text-shadow: 0 5px 0 #2f7a24, 0 10px 24px rgba(20, 60, 10, .55);
  animation: intro-drop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}

.intro-tip {
  font-size: clamp(20px, 4vmin, 32px);
  color: var(--ink);
  background: rgba(255, 253, 244, .92);
  border: 3px solid #f0b64f;
  border-radius: 999px;
  padding: 6px 22px;
  box-shadow: 0 4px 0 rgba(140,90,40,.22);
  animation: intro-drop .5s .12s cubic-bezier(.2, 1.6, .4, 1) both;
}

.intro-count {
  font-size: clamp(30px, 6.4vmin, 56px);
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 2px rgba(140, 70, 0, .5);
  text-shadow: 0 4px 0 #d1721a, 0 8px 18px rgba(110, 55, 0, .5);
  animation: intro-drop .5s .24s cubic-bezier(.2, 1.6, .4, 1) both;
}

@keyframes intro-drop {
  from { transform: translateY(-60px) scale(.4); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- Panels ---------- */

.panel {
  background: var(--panel-bg);
  border: 5px solid #f0b64f;
  border-radius: 30px;
  padding: clamp(18px, 4vmin, 36px) clamp(22px, 5vmin, 48px);
  box-shadow: var(--panel-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2vmin, 16px);
  max-width: min(92vw, 560px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  animation: panel-pop .35s cubic-bezier(.2, 1.5, .45, 1) both;
}

@keyframes panel-pop {
  from { transform: scale(.5) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.panel-title {
  font-size: clamp(28px, 6vmin, 46px);
  font-weight: 800;
  color: var(--ink);
}

.panel-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- Round end ---------- */

.stars-row { display: flex; gap: clamp(6px, 2vmin, 16px); }

.star {
  font-size: clamp(48px, 11vmin, 88px);
  color: #d8d2c2;
  -webkit-text-stroke: 2px rgba(140, 100, 20, .25);
  transform: scale(.6);
  transition: color .2s;
}

.star.earned {
  color: #ffc93c;
  text-shadow: 0 3px 0 #e0a416, 0 6px 18px rgba(230, 160, 0, .55);
  animation: star-pop .5s cubic-bezier(.2, 1.8, .4, 1) both;
}

@keyframes star-pop {
  0% { transform: scale(.1) rotate(-60deg); }
  60% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.re-score { font-size: clamp(26px, 5.4vmin, 42px); font-weight: 800; color: var(--ink); }

.re-best {
  font-size: clamp(18px, 3.6vmin, 28px);
  color: #d1338f;
  font-weight: 800;
  animation: play-pulse 1.2s ease-in-out infinite;
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 440px;
}

.badge-chip {
  background: linear-gradient(180deg, #d9f3ff, #aee4ff);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: clamp(13px, 2.6vmin, 19px);
  color: #1d5d8a;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(40, 110, 160, .25);
  animation: intro-drop .4s cubic-bezier(.2, 1.6, .4, 1) both;
}

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  #hud { right: 118px; gap: 6px; }
  .hud-pill { padding: 3px 12px 3px 8px; min-width: 76px; }
  .hud-timer { max-width: none; }
}
