* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #7fcf6a;
  font-family: "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Marker Felt", system-ui, sans-serif;
  color: #222;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
body.shooting #game { cursor: crosshair; }
button { font: inherit; cursor: pointer; border: none; color: inherit; }
.hidden { display: none !important; }

/* HUD */
#hud {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex; justify-content: space-between; align-items: center; gap: 8px; z-index: 10; pointer-events: none;
}
#hud button { pointer-events: auto; }
.hud-right { display: flex; gap: 8px; align-items: center; }
.pill {
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 7px 14px;
  font-size: 18px; font-weight: bold; box-shadow: 0 3px 0 rgba(0,0,0,.18); white-space: nowrap;
}
.pill.round { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; }
#hearts { letter-spacing: -2px; font-size: 16px; }
#hearts .gone { opacity: .25; filter: grayscale(1); }
#timer {
  position: absolute; left: 50%; transform: translateX(-50%); top: 0;
  font-size: 22px; min-width: 120px; text-align: center; border: 3px solid #222;
}
#timer.low { background: #ff4f6d; color: #fff; animation: throb .5s ease-in-out infinite alternate; }
@keyframes throb { to { transform: translateX(-50%) scale(1.08); } }

#toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: #fff8c4; border: 3px solid #222; border-radius: 16px; padding: 10px 20px;
  font-size: 22px; font-weight: bold; z-index: 11; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap; max-width: 94vw;
}
body.shooting #toast { top: 112px; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#hint {
  position: fixed; top: calc(66px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.7); color: #fff; padding: 10px 18px; border-radius: 14px;
  font-size: 18px; z-index: 10; pointer-events: none; white-space: nowrap;
}

/* Screens */
.screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(40, 90, 40, .45);
}
#title { background: linear-gradient(#8fd3ff, #c9f0ff 60%, #7fcf6a 60%); }
.card {
  background: #fffdf3; border: 4px solid #222; border-radius: 24px; padding: 22px 24px;
  width: min(480px, 100%); box-shadow: 0 8px 0 rgba(0,0,0,.25);
}
.card.wide { width: min(900px, 100%); }
.center { text-align: center; }
.title { font-size: clamp(40px, 11vw, 64px); margin: 0; line-height: 1; letter-spacing: 1px; }
.title span { color: #e24b4a; }
.title-balloons { font-size: 48px; }
.sub { font-size: 18px; margin: 12px 0 18px; }
h2 { margin: 6px 0 8px; font-size: 30px; }
.big-text { font-size: 20px; margin: 8px 0 18px; }
.menu-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 10px 0; }
button.big {
  background: #5cb85c; color: #fff; font-size: 28px; font-weight: bold; padding: 12px 34px;
  border-radius: 18px; border: 4px solid #222; box-shadow: 0 5px 0 #222;
}
button.big:active { transform: translateY(4px); box-shadow: 0 1px 0 #222; }
button.small {
  background: #fff; font-size: 17px; padding: 8px 16px; border-radius: 14px; border: 3px solid #222;
  box-shadow: 0 3px 0 #222;
}
button.small:active { transform: translateY(2px); box-shadow: 0 1px 0 #222; }
.help { font-size: 15px; color: #555; margin: 14px 0; display: grid; gap: 3px; }
body.is-touch .mouse-only, body:not(.is-touch) .touch-only { display: none; }
.progress { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 10px 0 4px; font-size: 22px; min-height: 4px; }
.progress .todo { opacity: .25; filter: grayscale(1); }
.end-emoji { font-size: 72px; line-height: 1.1; }
.end-name { font-size: 34px; margin: 6px 0; }
#readyBalloon { width: 120px; height: 120px; }
.drawings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 14px; }
.drawings img { width: 100%; border-radius: 12px; border: 3px solid #222; }
@media (max-width: 600px) {
  .drawings { grid-template-columns: 1fr; }
  #toast { white-space: normal; text-align: center; width: max-content; max-width: 92vw; font-size: 18px; }
  .pill { font-size: 15px; padding: 6px 10px; }
  #hearts { font-size: 15px; letter-spacing: 0; }
  #hint { white-space: normal; text-align: center; width: max-content; max-width: 90vw; font-size: 16px; }
  #timer { top: 50px; font-size: 20px; }
}
@media (max-height: 460px) {
  .card { padding: 12px 18px; }
  .title-balloons { font-size: 32px; }
  .sub { margin: 6px 0 8px; font-size: 16px; }
  .help { margin: 6px 0; }
  #readyBalloon { width: 80px; height: 80px; }
  .end-emoji { font-size: 48px; }
}
