* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #4f9a3d; position: fixed; inset: 0;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }

#hud {
  position: fixed; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px) 0 calc(env(safe-area-inset-left) + 12px);
  display: flex; align-items: flex-start; gap: 8px; pointer-events: none;
}
#coins {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 6px;
  background: rgba(30, 45, 25, .55); border-radius: 22px; color: #fff;
  font-weight: 900; font-size: 24px; letter-spacing: .5px;
  box-shadow: 0 3px 0 rgba(0,0,0,.18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .08s;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
#coins.bump { transform: scale(1.12); }
.coin {
  width: 32px; height: 32px; border-radius: 50%; display: inline-block; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff3a8 0 12%, #ffd84a 13% 55%, #f2a900 56% 100%);
  box-shadow: inset 0 0 0 2.5px #c98a00, 0 2px 0 rgba(0,0,0,.2);
}
#level {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 4px;
  color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1.5px 0 rgba(0,0,0,.35);
}
#levelBar { width: 100%; max-width: 130px; height: 10px; border-radius: 5px; background: rgba(30,45,25,.5); overflow: hidden; }
#levelBar i { display: block; height: 100%; width: 0%; border-radius: 5px; background: linear-gradient(90deg, #7be35a, #c5f56a); transition: width .4s; }
#btns { display: flex; gap: 8px; pointer-events: auto; }
#btns button {
  width: 44px; height: 44px; border-radius: 22px; border: 0; padding: 10px;
  background: rgba(30,45,25,.55); color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.18);
  touch-action: manipulation;
}
#btns button svg { width: 24px; height: 24px; display: block; }
#btns button:active { transform: scale(.92); }

#hint {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 66px); transform: translateX(-50%);
  max-width: 86vw; padding: 10px 18px; border-radius: 18px; text-align: center;
  background: rgba(255,255,255,.92); color: #2d4a1e; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15); pointer-events: none; transition: opacity .25s;
}
#hint:empty { opacity: 0; }

#banner {
  position: fixed; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  padding: 12px 24px; border-radius: 22px; white-space: nowrap;
  font-weight: 900; font-size: 24px; color: #fff; pointer-events: none;
  text-shadow: 0 2px 0 rgba(0,0,0,.25); box-shadow: 0 5px 0 rgba(0,0,0,.2);
  transition: transform .18s cubic-bezier(.3,1.6,.5,1), opacity .18s;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner.bad { background: #e5484d; }
#banner.good { background: #31a24c; }
#banner.gold { background: linear-gradient(180deg, #ffcf3f, #f29a00); }
#banner.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { margin-left: 0 } 20% { margin-left: -10px } 40% { margin-left: 10px } 60% { margin-left: -7px } 80% { margin-left: 6px } }

#modal { position: fixed; inset: 0; background: rgba(15,30,10,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
#modal.hidden { display: none; }
#modal .card {
  width: 100%; max-width: 340px; background: #fffaf0; border-radius: 26px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 8px 0 rgba(0,0,0,.2); color: #3b2a1a;
}
#modal h2 { margin: 0 0 8px; font-size: 24px; font-weight: 900; color: #2f7d32; }
#modal p { margin: 0 0 16px; font-size: 17px; line-height: 1.35; font-weight: 600; }
#modal .row { display: flex; flex-direction: column; gap: 10px; }
#modal button {
  border: 0; border-radius: 16px; padding: 14px; font-size: 18px; font-weight: 900; font-family: inherit;
  background: #3fb950; color: #fff; box-shadow: 0 4px 0 #2a8a39; touch-action: manipulation;
}
#modal button.sec { background: #ece3d0; color: #5a4630; box-shadow: 0 4px 0 #cfc2a8; }
#modal button.danger { background: #e5484d; box-shadow: 0 4px 0 #b3343a; }
#modal button:active { transform: translateY(3px); box-shadow: none; }

#rotate { display: none; position: fixed; inset: 0; background: #4f9a3d; color: #fff; font-weight: 900; font-size: 26px; align-items: center; justify-content: center; text-align: center; z-index: 9; }
#rotate small { font-size: 16px; font-weight: 700; opacity: .9; }
@media (orientation: landscape) and (max-height: 500px) { #rotate { display: flex; } }

#btns button svg[hidden] { display: none; }
