:root {
  color-scheme: dark;
  --bg: #17120f;
  --ink: #f4eadf;
  --dim: rgb(244 234 223 / 72%);
  --flesh: #e48b78;
  --hole: #1a0d0c;
  --button: #f3e7da;
  --button-ink: #1b120f;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-height: 100%;
  overflow: hidden;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(4.6rem + env(safe-area-inset-top))
    calc(1.1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1.1rem + env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 42%, #2a211c 0, var(--bg) 52%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[data-state="playing"] {
  cursor: pointer;
}

.mute {
  position: absolute;
  z-index: 2;
  top: calc(0.6rem + env(safe-area-inset-top));
  right: calc(0.7rem + env(safe-area-inset-right));
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(244 234 223 / 10%);
  color: var(--ink);
  cursor: pointer;
}

.mute svg {
  width: 1.55rem;
  height: 1.55rem;
}

.slash {
  display: none;
  position: absolute;
  width: 2px;
  height: 1.55rem;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(40deg);
}

.mute.is-muted .slash {
  display: block;
}

.board {
  width: min(100%, 26rem);
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-areas:
    "title"
    "snout"
    "best"
    "actions";
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  justify-items: center;
  align-items: center;
  gap: 0.75rem;
}

.title,
.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0.35rem;
  text-align: center;
}

.title {
  grid-area: title;
}

.snout-wrap {
  grid-area: snout;
  width: min(72vw, 300px);
  max-height: 100%;
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  transform: scale(var(--grow, 1));
}

.best {
  grid-area: best;
}

.actions {
  grid-area: actions;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(4.4rem, 22vw, 7.2rem);
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: 0.03em;
}

#count {
  font-size: clamp(5rem, 26vw, 8rem);
  line-height: 0.82;
}

.challenge {
  font-size: clamp(1.7rem, 7vw, 2.5rem);
  line-height: 1;
}

.dim {
  color: var(--dim);
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  letter-spacing: 0.04em;
}

.ring {
  position: absolute;
  z-index: 1;
  inset: 13%;
  border-radius: 50%;
  border: 5px solid rgb(244 234 223 / 42%);
  pointer-events: none;
}

[data-beat="hot"] .ring {
  border-color: #fff8f2;
  box-shadow: 0 0 0 8px rgb(255 248 242 / 24%);
}

.snout {
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #f6c3b4, #e48b78 62%, #c86d5e);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16%;
  box-shadow: inset 0 -12px 18px rgb(80 24 18 / 28%);
}

.nostril {
  width: 15%;
  height: 26%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #4a2a26, var(--hole) 72%);
}

.go,
.ghost {
  appearance: none;
  width: 100%;
  border-radius: 999px;
  font: inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.go {
  min-height: 4.6rem;
  border: 0;
  background: var(--button);
  color: var(--button-ink);
  font-size: clamp(2.4rem, 10vw, 3.1rem);
}

.ghost {
  min-height: 3.2rem;
  border: 2px solid rgb(243 231 218 / 55%);
  background: transparent;
  color: var(--ink);
  font-size: 1.35rem;
}

.note {
  min-height: 1.2em;
  word-break: break-all;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  [data-state="idle"] .snout {
    animation: breathe 3.6s ease-in-out infinite;
  }

  .is-miss .snout-wrap {
    animation: nudge 180ms linear;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  [data-beat="hot"] .ring {
    box-shadow: none;
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.035);
  }
}

@keyframes nudge {
  0%,
  100% {
    translate: 0 0;
  }
  30% {
    translate: -7px 0;
  }
  70% {
    translate: 7px 0;
  }
}

.is-miss {
  background: #2c1614;
}

@media (max-height: 520px) {
  .stage {
    padding-top: calc(0.75rem + env(safe-area-inset-top));
  }

  .board {
    width: min(100%, 52rem);
    grid-template-columns: auto minmax(12rem, 20rem);
    grid-template-areas:
      "snout title"
      "snout best"
      "snout actions";
    grid-template-rows: auto auto auto;
    column-gap: 1.6rem;
    justify-content: center;
    align-content: center;
  }

  .title,
  .actions,
  .best {
    justify-self: start;
    text-align: left;
    align-items: flex-start;
  }

  .snout-wrap {
    width: min(46vh, 220px);
  }

  h1 {
    font-size: clamp(2.8rem, 14vh, 4.6rem);
  }

  #count {
    font-size: clamp(3.2rem, 18vh, 5.4rem);
  }

  .go {
    min-height: 3.3rem;
    font-size: 1.7rem;
  }

  .ghost {
    min-height: 2.8rem;
  }
}

@media (min-width: 900px) and (min-height: 700px) {
  .snout-wrap {
    width: min(34vh, 320px);
  }
}
