* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  background: #8fd3fb;
  color: white;
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
button, #menu, #over, #hud, #countdown, #skip { font-family: inherit; }

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}
#score, #dist, #streak {
  background: linear-gradient(#1e88e5, #0d47a1);
  border: 2px solid rgba(255,255,255,0.95);
  box-shadow: 0 3px 0 rgba(6, 24, 56, 0.45);
}
#score {
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-self: start;
  margin-top: 0;
  font-size: clamp(22px, 6.4vw, 34px);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 2px 0 #08356e;
  border-radius: 16px;
  padding: 6px 12px 7px;
}
#score::before, #dist::before {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  opacity: 0.92;
}
#score::before { content: "SCORE"; }
#dist {
  grid-column: 3;
  grid-row: 1;
  position: static;
  justify-self: end;
  font-weight: 900;
  font-size: clamp(16px, 4.4vw, 22px);
  line-height: 1;
  text-shadow: 0 2px 0 #08356e;
  border-radius: 16px;
  padding: 6px 12px 7px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
}
#dist::before { content: "DISTANCE"; }
.waterwrap {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#waterlabel {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 0 #0d3b7a;
  width: 78px;
}
#waterlabel::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 16px;
  margin-right: 4px;
  vertical-align: -3px;
  background: radial-gradient(circle at 35% 30%, #fff, #7ecbff 40%, #1e88e5 72%);
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
}
#meter {
  width: min(46vw, 200px);
  height: 16px;
  border-radius: 999px;
  background: rgba(6, 24, 48, 0.55);
  border: 2px solid white;
  overflow: hidden;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
#waterfill {
  height: 100%;
  width: 64%;
  background: linear-gradient(#b5ecff, #1e88e5);
}
#meter.low #waterfill { background: linear-gradient(#ffd0c8, #e53935); }
#hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  column-gap: 8px;
}
#streak {
  grid-column: 2;
  grid-row: 1;
  position: static;
  justify-self: center;
  font-weight: 900;
  font-size: clamp(12px, 3.2vw, 16px);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 #08356e;
  white-space: nowrap;
  background: linear-gradient(#ffd23f, #f0b429);
  color: #12315f;
  border: 2px solid white;
  border-radius: 999px;
  padding: 7px 12px;
}
#streak.hot { color: #0b3f86; }
#mute2 {
  pointer-events: auto;
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(8, 32, 56, 0.55);
  color: white;
  border: 2px solid white;
  border-radius: 999px;
  font-weight: 800;
  padding: 8px 12px;
  font-size: 12px;
}
#floater {
  position: absolute;
  left: 50%;
  top: 32%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: clamp(18px, 5vw, 28px);
  color: #ffd23f;
  text-shadow: 0 3px 0 #0d3b7a;
  opacity: 0;
  white-space: nowrap;
}
#floater.show { animation: pop 0.75s ease forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.85); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1); }
}

#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(72px, 22vw, 160px);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 8px 0 #0d3b7a;
  pointer-events: none;
}
#countdown[hidden] { display: none; }
#skip {
  position: absolute;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(8, 32, 56, 0.45);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 13px;
  pointer-events: none;
}
#menu, #over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
}
#menu { pointer-events: none; background: linear-gradient(to top, rgba(8, 32, 56, 0.35), rgba(8, 32, 56, 0.05) 45%, rgba(8, 32, 56, 0)); }
#menu > *, #over > * { pointer-events: auto; }
h1 {
  margin: 0 0 8px;
  font-size: clamp(42px, 12vw, 84px);
  line-height: 0.86;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 0 #0d3b7a;
}
h1 span { color: #ffd23f; }
.hint {
  margin: 0 0 14px;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 2px 0 #0d3b7a;
}
#best { font-weight: 800; margin-top: 10px; text-shadow: 0 2px 0 #0d3b7a; }
button.big {
  appearance: none;
  border: 4px solid #ffd23f;
  background: #1565c0;
  color: white;
  font-weight: 900;
  font-size: 32px;
  letter-spacing: 0.06em;
  border-radius: 18px;
  min-width: min(84vw, 320px);
  min-height: 72px;
  padding: 8px 28px;
  box-shadow: 0 6px 0 #0d3b7a;
}
button.big:active { transform: translateY(2px); box-shadow: 0 4px 0 #0d3b7a; }
button.ghost {
  margin-top: 12px;
  background: rgba(8, 32, 56, 0.45);
  color: white;
  border: 2px solid white;
  border-radius: 999px;
  font-weight: 800;
  padding: 8px 16px;
}
#over {
  background: rgba(8, 32, 56, 0.72);
}
#over h2 {
  margin: 0;
  font-size: clamp(48px, 14vw, 84px);
  letter-spacing: -0.03em;
  text-shadow: 0 4px 0 #062038;
}
#onew {
  margin: 0 0 6px;
  color: #ffd23f;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.stats {
  width: min(86vw, 360px);
  margin: 8px 0 12px;
  text-align: left;
}
.stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 700;
}
.stats b { font-weight: 900; }
.joke {
  margin: 4px 0 14px;
  max-width: 320px;
  font-style: italic;
  color: #ffd23f;
  font-weight: 700;
}
[hidden] { display: none !important; }
