:root {
  --bg: #7ec850;
  --ink: #0e2a17;
  --card: rgba(255, 255, 255, 0.92);
  --accent: #ff9f1c;
  --accent-2: #ffcf5c;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --font: 'Baloo 2', 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #6bbf45;
  font-family: var(--font);
  color: var(--ink);
  user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

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

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
  background: radial-gradient(circle at 50% 30%, rgba(120, 200, 90, 0.35), rgba(30, 60, 30, 0.72));
  backdrop-filter: blur(3px);
  transition: opacity 0.35s ease;
}

.overlay.hidden,
.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.loader-card,
.menu-card {
  width: min(440px, 92vw);
  background: var(--card);
  border-radius: 26px;
  padding: 34px 28px 30px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 3px solid rgba(255, 255, 255, 0.6);
}

.logo-mark {
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 4px;
  color: var(--ink);
  line-height: 1;
}
.logo-mark.big {
  font-size: 52px;
}
.logo-sub {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 10px;
  color: var(--accent);
  margin-top: 2px;
}
.logo-sub.big {
  font-size: 30px;
  letter-spacing: 14px;
}

.tagline {
  margin: 18px 4px 24px;
  font-size: 16px;
  font-weight: 600;
  color: #3a5b40;
  line-height: 1.45;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  border-radius: 16px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.btn.primary {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  letter-spacing: 1.5px;
  color: #4a2600;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 0 #d97e08, 0 14px 22px rgba(0, 0, 0, 0.25);
}
.btn.primary:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #d97e08, 0 8px 14px rgba(0, 0, 0, 0.25);
}
.btn.primary:hover {
  filter: brightness(1.04);
}

.controls-grid {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}
.controls-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: #3a5b40;
}
.key {
  background: #eef4ea;
  border: 2px solid #d3e3ca;
  border-radius: 9px;
  padding: 4px 10px;
  font-weight: 800;
  color: #2c4a2f;
  font-size: 13px;
}

/* ---------- Loader ---------- */
.loader-track {
  margin: 26px auto 14px;
  width: 100%;
  height: 12px;
  background: #e4ecdd;
  border-radius: 999px;
  overflow: hidden;
}
#loader-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 999px;
  transition: width 0.25s ease;
}
#loading-status {
  font-size: 14px;
  font-weight: 600;
  color: #5a7a5f;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 16px 0;
}
.score-pill {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 8px 18px;
  box-shadow: var(--shadow);
  min-width: 92px;
}
.score-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #8aa07f;
}
#score-value {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.best-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 9px 13px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: var(--shadow);
  color: var(--ink);
}
.coin-ico {
  color: #f5b60a;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active {
  transform: scale(0.92);
}

/* ---------- Callout ---------- */
.callout {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 42, 23, 0.82);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 10px 20px;
  border-radius: 14px;
  font-size: 18px;
  white-space: nowrap;
  animation: pop 0.4s ease;
}
@keyframes pop {
  0% {
    transform: translateX(-50%) scale(0.6);
    opacity: 0;
  }
  60% {
    transform: translateX(-50%) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

/* ---------- Game over ---------- */
.kicker {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #e5443b;
  margin-bottom: 18px;
  transform: rotate(-3deg);
}
.result-scores {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 26px;
}
.result-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #eef4ea;
  border-radius: 16px;
  padding: 14px 8px;
  flex: 1;
}
.result-num {
  font-size: 30px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.result-cap {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #8aa07f;
}

/* ---------- Hint ---------- */
.hint {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(14, 42, 23, 0.66);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

@media (max-width: 480px) {
  #score-value {
    font-size: 28px;
  }
  .kicker {
    font-size: 34px;
  }
}
