:root {
  --ink: #1D1228;
  --cream: #FFF1C9;
  --mustard: #F4B73B;
  --orange: #F2701F;
  --purple: #6A3FA3;
  --teal: #19B5A5;
  --pink: #FF7CC0;
  --lime: #9BE04A;
  --display: "Bowlby One", Impact, "Arial Black", sans-serif;
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ink);
  font-family: var(--body);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
/* The swatter is drawn on the canvas, so hide the real cursor while playing. */
body.is-play #stage { cursor: none; }

/* HUD */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
}
.score {
  font-family: var(--display);
  font-size: clamp(48px, 9vw, 84px);
  line-height: 1;
  color: var(--cream);
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
}
.level {
  display: inline-block;
  margin-top: 8px;
  font-weight: 700;
  font-size: 15px;
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 2px 8px;
  transform: rotate(1.5deg);
}
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.patience { display: flex; align-items: center; gap: 10px; }
.patience-label {
  font-weight: 700;
  font-size: 15px;
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 2px 8px;
  transform: rotate(-2deg);
}
.pips { display: flex; gap: 6px; }
.pips i {
  width: 22px; height: 22px;
  background: var(--orange);
  border: 3px solid var(--ink);
  border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%;
  transition: transform .15s;
}
.pips i.lost {
  background: transparent;
  border-style: dashed;
  opacity: .55;
  transform: scale(.8);
}
.sound {
  pointer-events: auto;
  font: 700 14px var(--body);
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  min-height: 44px;
  padding: 4px 14px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.sound:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* Score and patience mean nothing on the title screen. */
body.is-title .score, body.is-title .patience { visibility: hidden; }

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(29, 18, 40, .6);
}
.card {
  width: min(440px, 100%);
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 3% 5% 4% 6% / 5% 3% 6% 4%;
  box-shadow: 10px 10px 0 var(--orange), 10px 10px 0 4px var(--ink);
  padding: 28px 28px 30px;
  transform: rotate(-1.5deg);
}
h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  margin: 0;
  line-height: .95;
  letter-spacing: .01em;
}
h1 {
  font-size: clamp(54px, 15vw, 88px);
  color: var(--orange);
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--ink);
  /* Cartoon "line boil": two near-identical frames flicking back and forth. */
  animation: boil .5s steps(1) infinite;
}
h2 {
  font-size: clamp(36px, 10vw, 54px);
  color: var(--purple);
}
@keyframes boil {
  0%   { transform: rotate(0deg) translate(0, 0); }
  50%  { transform: rotate(-.8deg) translate(1px, -1px); }
}
.tagline { margin: 14px 0 0; font-size: 19px; font-weight: 700; line-height: 1.25; }
.rules { margin: 18px 0 0; padding-left: 20px; font-size: 17px; line-height: 1.5; }
.cause { margin: 12px 0 0; font-size: 18px; line-height: 1.3; }
.stats { display: flex; gap: 22px; margin: 18px 0 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: 14px; font-weight: 700; }
.stats dd { margin: 0; font-family: var(--display); font-size: 34px; line-height: 1.1; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 24px; }
.actions .go { margin-top: 0; }
.go {
  margin-top: 24px;
  font: 400 28px var(--display);
  color: var(--ink);
  background: var(--lime);
  border: 4px solid var(--ink);
  padding: 8px 26px 10px;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  transform: rotate(1deg);
}
.go:active { transform: rotate(1deg) translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.share {
  font: 700 18px var(--body);
  color: var(--ink);
  background: var(--cream);
  border: 4px solid var(--ink);
  min-height: 48px;
  padding: 6px 18px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-1deg);
}
.share:active { transform: rotate(-1deg) translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.share-note { margin: 14px 0 0; font-size: 15px; font-weight: 700; }
.go:focus-visible, .share:focus-visible, .sound:focus-visible { outline: 4px solid var(--teal); outline-offset: 3px; }

@media (max-height: 520px) {
  .overlay { padding: 8px; }
  .card { width: min(560px, 100%); padding: 14px 22px 18px; }
  h1 { font-size: clamp(44px, 14vh, 72px); }
  h2 { font-size: 34px; }
  .tagline { margin-top: 8px; font-size: 16px; }
  .rules { margin-top: 8px; font-size: 15px; line-height: 1.35; }
  .cause { margin-top: 8px; font-size: 16px; }
  .stats { margin-top: 10px; }
  .stats dd { font-size: 28px; }
  .go { margin-top: 12px; font-size: 24px; }
  .actions { margin-top: 12px; }
  .share-note { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  h1 { animation: none; }
}
