:root {
  --ink: #3b2a10;
  --cream: #fffaf0;
  --yellow: #ffd23f;
  --orange: #ff9f1c;
  --shadow: 0 4px 0 rgba(59, 42, 16, 0.25);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
#stage.over-duck { cursor: grab; }
#stage.dragging { cursor: grabbing; }

.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  padding: 0 16px;
}

.hud h1 {
  margin: 0;
  font-size: clamp(30px, 7vw, 60px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--yellow);
  -webkit-text-stroke: clamp(1.5px, 0.4vw, 3px) var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
  transform: rotate(-2deg);
}
.hud h1 span { color: var(--orange); }

.tagline {
  display: inline-block;
  margin: 10px 0 0;
  padding: 5px 12px;
  font-size: clamp(12px, 2.6vw, 15px);
  font-weight: 700;
  background: rgba(255, 250, 240, 0.85);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.counter {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.counter strong { font-variant-numeric: tabular-nums; }

.toolbar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  max-width: calc(100vw - 16px);
  background: rgba(255, 250, 240, 0.9);
  border: 2px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 8px 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.2s;
}
.toolbar button span[aria-hidden] { font-size: 18px; line-height: 1; }
.toolbar button:hover { background: #ffe066; }
.toolbar button:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.toolbar button:focus-visible { outline: 3px solid #4361ee; outline-offset: 2px; }
.toolbar button[aria-pressed="true"]#btnParty { background: #ff70a6; }
.toolbar button[aria-pressed="false"]#btnSound { background: #ddd; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Party mode UI tint */
body.party .hud h1 { animation: wobble 0.5s ease-in-out infinite alternate; }
body.party .toolbar, body.party .counter, body.party .tagline { background: #fff0f6; }
@keyframes wobble {
  from { transform: rotate(-4deg) scale(1); }
  to   { transform: rotate(3deg) scale(1.05); }
}

/* Small screens: icon-only buttons */
@media (max-width: 560px) {
  .toolbar { gap: 6px; padding: 6px; }
  .toolbar button { padding: 8px 10px; }
  .toolbar .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .toolbar button span[aria-hidden] { font-size: 22px; }
  .counter { top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px); }
}

/* Short landscape phones */
@media (max-height: 460px) {
  .tagline { display: none; }
  .hud h1 { font-size: 30px; }
  .toolbar { gap: 6px; padding: 5px; }
  .toolbar button { min-height: 40px; padding: 6px 10px; }
  .toolbar .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

@media (prefers-reduced-motion: reduce) {
  body.party .hud h1 { animation: none; }
  .toolbar button { transition: none; }
}

.noscript {
  position: fixed; inset: 0; margin: 0;
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800;
}
