/* Sweetie 16 palette */
:root {
  --ink: #1a1c2c;
  --plum: #5d275d;
  --red: #b13e53;
  --orange: #ef7d57;
  --sand: #ffcd75;
  --lime: #a7f070;
  --grass: #38b764;
  --teal: #257179;
  --navy: #29366f;
  --blue: #3b5dc9;
  --sky: #41a6f6;
  --foam: #73eff7;
  --white: #f4f4f4;
  --silver: #94b0c2;
  --slate: #566c86;
  --panel: #333c57;

  /* Day theme: what sits directly on the page background */
  --bg: var(--grass);
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' shape-rendering='crispEdges'%3E%3Cg fill='%2332a85b'%3E%3Crect x='32' y='32' width='4' height='4'/%3E%3Crect x='24' y='36' width='4' height='4'/%3E%3Crect x='32' y='36' width='4' height='4'/%3E%3Crect x='40' y='36' width='4' height='4'/%3E%3Crect x='28' y='40' width='4' height='4'/%3E%3Crect x='32' y='40' width='4' height='4'/%3E%3Crect x='36' y='40' width='4' height='4'/%3E%3Crect x='28' y='44' width='4' height='4'/%3E%3Crect x='32' y='44' width='4' height='4'/%3E%3Crect x='36' y='44' width='4' height='4'/%3E%3Crect x='160' y='160' width='4' height='4'/%3E%3Crect x='152' y='164' width='4' height='4'/%3E%3Crect x='160' y='164' width='4' height='4'/%3E%3Crect x='168' y='164' width='4' height='4'/%3E%3Crect x='156' y='168' width='4' height='4'/%3E%3Crect x='160' y='168' width='4' height='4'/%3E%3Crect x='164' y='168' width='4' height='4'/%3E%3Crect x='156' y='172' width='4' height='4'/%3E%3Crect x='160' y='172' width='4' height='4'/%3E%3Crect x='164' y='172' width='4' height='4'/%3E%3C/g%3E%3C/svg%3E");
  --on-bg: var(--ink);
  --on-bg-dim: var(--navy);
  --water: var(--blue);
  --water-edge: var(--navy);
  --water-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='64' shape-rendering='crispEdges'%3E%3Cg fill='%2341a6f6'%3E%3Crect x='8' y='12' width='12' height='4'/%3E%3Crect x='20' y='8' width='8' height='4'/%3E%3Crect x='48' y='44' width='12' height='4'/%3E%3Crect x='60' y='40' width='8' height='4'/%3E%3C/g%3E%3C/svg%3E");

  --px: 4px; /* one "pixel" of UI chrome */
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --body: 'Pixelify Sans', ui-monospace, monospace;
  color-scheme: dark;
}

/* Night theme, following the device's dark mode: a dark meadow with a couple of fireflies, and a deeper pond */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f3347;
    --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' shape-rendering='crispEdges'%3E%3Cg fill='%23243f55'%3E%3Crect x='32' y='32' width='4' height='4'/%3E%3Crect x='24' y='36' width='4' height='4'/%3E%3Crect x='32' y='36' width='4' height='4'/%3E%3Crect x='40' y='36' width='4' height='4'/%3E%3Crect x='28' y='40' width='4' height='4'/%3E%3Crect x='32' y='40' width='4' height='4'/%3E%3Crect x='36' y='40' width='4' height='4'/%3E%3Crect x='28' y='44' width='4' height='4'/%3E%3Crect x='32' y='44' width='4' height='4'/%3E%3Crect x='36' y='44' width='4' height='4'/%3E%3Crect x='160' y='160' width='4' height='4'/%3E%3Crect x='152' y='164' width='4' height='4'/%3E%3Crect x='160' y='164' width='4' height='4'/%3E%3Crect x='168' y='164' width='4' height='4'/%3E%3Crect x='156' y='168' width='4' height='4'/%3E%3Crect x='160' y='168' width='4' height='4'/%3E%3Crect x='164' y='168' width='4' height='4'/%3E%3Crect x='156' y='172' width='4' height='4'/%3E%3Crect x='160' y='172' width='4' height='4'/%3E%3Crect x='164' y='172' width='4' height='4'/%3E%3C/g%3E%3Cg fill='%23a7f070'%3E%3Crect x='112' y='84' width='4' height='4'/%3E%3Crect x='204' y='212' width='4' height='4'/%3E%3C/g%3E%3C/svg%3E");
    --on-bg: var(--white);
    --on-bg-dim: var(--silver);
    --water: var(--navy);
    --water-edge: var(--ink);
    --water-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='64' shape-rendering='crispEdges'%3E%3Cg fill='%233b5dc9'%3E%3Crect x='8' y='12' width='12' height='4'/%3E%3Crect x='20' y='8' width='8' height='4'/%3E%3Crect x='48' y='44' width='12' height='4'/%3E%3Crect x='60' y='40' width='8' height='4'/%3E%3C/g%3E%3C/svg%3E");
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font: 20px/1.4 var(--body);
  color: var(--white);
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-size: 240px 240px;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px 48px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

[hidden] {
  display: none !important;
}

h1,
h2 {
  font-family: var(--pixel);
  font-weight: 400;
  margin: 0;
}

h2 {
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--sand);
}

.label {
  font: 12px/1.4 var(--pixel);
  text-transform: uppercase;
}

.dim {
  color: var(--silver);
}

.sprite {
  display: inline-block;
  line-height: 0;
}

.sprite svg {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* Hero */

.hero {
  text-align: center;
  padding-top: 12px;
}

.flock {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 16px;
}

.flock .sprite {
  width: 64px;
  height: 64px;
  animation: hop 1s steps(1) infinite;
}

.flock .sprite:nth-child(2) {
  animation-delay: 0.33s;
}

.flock .goose {
  width: 96px;
  height: 96px;
  animation-delay: 0.66s;
}

@keyframes hop {
  50% {
    transform: translateY(-8px);
  }
}

.hero h1 {
  font-size: clamp(14px, 4.4vw, 26px);
  line-height: 1.8;
  white-space: nowrap;
  color: var(--white);
  text-shadow:
    4px 4px 0 var(--ink),
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink);
}

/* One line, with a bigger, slightly wonky "Goose!" */
.hero h1 span {
  display: inline-block;
  margin-left: 0.2em;
  font-size: 1.5em;
  color: var(--sand);
  transform: rotate(-1deg);
  transform-origin: 50% 60%;
}

/* Panels: square, hard shadow, bevelled top edge */

.panel {
  background: var(--panel);
  border: var(--px) solid var(--ink);
  box-shadow:
    inset 0 var(--px) 0 var(--slate),
    var(--px) var(--px) 0 var(--ink),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 rgba(26, 28, 44, 0.35);
  padding: 20px;
}

/* Form bits */

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

input:not([type='checkbox']) {
  font: 22px var(--body);
  color: var(--white);
  background: var(--ink);
  border: var(--px) solid var(--ink);
  box-shadow: inset var(--px) var(--px) 0 #10111c;
  border-radius: 0;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}

input::placeholder {
  color: var(--slate);
}

input:focus-visible,
button:focus-visible {
  outline: var(--px) solid var(--sand);
  outline-offset: 2px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  cursor: pointer;
}

.check small {
  display: block;
  font-size: 16px;
  color: var(--silver);
}

.check input {
  appearance: none;
  flex: none;
  width: 28px;
  height: 28px;
  margin: 0;
  background: var(--ink);
  border: var(--px) solid var(--ink);
  box-shadow: inset 0 0 0 var(--px) var(--slate);
  cursor: pointer;
}

.check input:checked {
  background: var(--sand);
  box-shadow: inset 0 0 0 var(--px) var(--ink);
}

/* Buttons */

.btn {
  font: 13px/1.2 var(--pixel);
  text-transform: uppercase;
  color: var(--ink);
  background: var(--silver);
  border: var(--px) solid var(--ink);
  border-radius: 0;
  box-shadow: inset calc(var(--px) * -1) calc(var(--px) * -1) 0 var(--slate);
  padding: 14px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--white);
}

.btn:active {
  box-shadow: inset var(--px) var(--px) 0 var(--slate);
  padding: 16px 14px 12px 18px;
}

.btn.primary {
  background: var(--sand);
  box-shadow: inset calc(var(--px) * -1) calc(var(--px) * -1) 0 var(--orange);
}

.btn.primary:hover {
  background: #ffe0a3;
}

.btn.primary:active {
  box-shadow: inset var(--px) var(--px) 0 var(--orange);
}

.btn.ghost {
  background: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--on-bg);
}

.btn.ghost:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn.small {
  font-size: 10px;
  padding: 8px 10px;
}

.btn.small:active {
  padding: 10px 8px 6px 12px;
}

.btn .sprite {
  width: 24px;
  height: 24px;
  margin: -4px 0;
}

.btn.wide {
  width: 100%;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 12px;
}

#join-code {
  font: 18px var(--pixel);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.error {
  font-size: 18px;
  color: var(--ink);
  background: var(--orange);
  border: var(--px) solid var(--ink);
  padding: 6px 10px;
  margin: 14px 0 0;
}

.waiting {
  text-align: center;
  color: var(--silver);
  margin: 0;
}

#final-waiting {
  color: var(--on-bg);
}

/* How to play */

.how ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
}

.how li {
  counter-increment: step;
  position: relative;
  padding-left: 30px;
}

.how li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  font: 12px/1.9 var(--pixel);
  color: var(--sand);
}

.how strong {
  color: var(--orange);
  font-weight: 600;
}

kbd {
  font: 10px var(--pixel);
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  box-shadow: inset -2px -2px 0 var(--silver);
  padding: 3px 6px;
  vertical-align: 2px;
}

.sound-test {
  margin-top: 18px;
  padding-top: 16px;
  border-top: var(--px) dotted var(--slate);
}

.sound-test > .label {
  display: block;
  color: var(--silver);
  margin-bottom: 12px;
}

/* Soundboard: a numbered button for every recording */

.soundboard {
  display: grid;
  gap: 12px;
}

.sound-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: start;
  gap: 10px;
}

.sound-row-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 10px/1 var(--pixel);
  text-transform: uppercase;
  padding-top: 8px;
}

.sound-row-label .sprite {
  width: 28px;
  height: 28px;
  margin: -8px 0;
}

.clips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.clip {
  font: 10px/1 var(--pixel);
  color: var(--ink);
  background: var(--silver);
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: inset -3px -3px 0 var(--slate);
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  cursor: pointer;
}

.clip:hover {
  background: var(--white);
}

.clip:active {
  box-shadow: inset 3px 3px 0 var(--slate);
}

.clip.goose {
  background: var(--sand);
  box-shadow: inset -3px -3px 0 var(--orange);
}

.clip.goose:hover {
  background: #ffe0a3;
}

.clip.decoy {
  color: var(--white);
  background: var(--slate);
  box-shadow: inset -3px -3px 0 var(--panel);
}

.clip.decoy:hover {
  background: #6b82a0;
}

.clip.ambience {
  color: var(--ink);
  background: var(--foam);
  box-shadow: inset -3px -3px 0 var(--sky);
}

.clip.ambience[aria-pressed='true'] {
  background: var(--lime);
  box-shadow: inset 3px 3px 0 var(--grass);
}

.clip.playing,
.clip.goose.playing,
.clip.decoy.playing {
  background: var(--lime);
  box-shadow: inset 3px 3px 0 var(--grass);
}

@media (max-width: 420px) {
  .sound-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .sound-row-label {
    padding-top: 0;
  }
}

.records {
  margin: 16px 0 0;
  color: var(--silver);
}

.records strong {
  font: 12px var(--pixel);
  color: var(--sand);
}

.credits {
  margin: 0;
  text-align: center;
  font-size: 18px;
  color: var(--on-bg);
}

.credits a,
.back-link {
  font: 10px var(--pixel);
  text-transform: uppercase;
  color: var(--ink);
  background: var(--sand);
  border: 3px solid var(--ink);
  padding: 5px 8px;
  margin-left: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.credits a:hover,
.back-link:hover {
  background: var(--white);
}

/* Credits page */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-head .back-link {
  margin: 0;
}

.credits-title {
  text-align: center;
  padding-top: 8px;
}

.credits-title h1 {
  font-size: clamp(26px, 8vw, 40px);
  color: var(--white);
  text-shadow: 4px 4px 0 var(--ink);
}


.section-label {
  font: 12px var(--pixel);
  text-transform: uppercase;
  color: var(--on-bg);
  margin: 12px 0 -4px;
}

.recordings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

.recording {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
}

.recording > .sprite {
  width: 64px;
  height: 64px;
}

.recording h3 {
  font: 16px/1.3 var(--pixel);
  color: var(--white);
  margin: 0 0 4px;
}

.recording .species {
  font: 10px var(--pixel);
  text-transform: uppercase;
  color: var(--sand);
  margin: 0 0 8px;
}

.recording .where {
  margin: 0 0 12px;
  color: var(--silver);
  font-size: 18px;
}

.recording footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.clip-count {
  font-size: 10px;
  margin: 0 0 8px;
}

.licence {
  font: 8px var(--pixel);
  color: var(--ink);
  background: var(--lime);
  padding: 4px 6px;
}

.recording a,
.also a {
  color: var(--foam);
  text-underline-offset: 3px;
}

.also dl {
  margin: 0;
  display: grid;
  gap: 14px;
}

.also dt {
  font: 10px var(--pixel);
  text-transform: uppercase;
  color: var(--sand);
  margin-bottom: 4px;
}

.also dd {
  margin: 0;
}

@media (max-width: 420px) {
  .recording {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .recording > .sprite {
    width: 48px;
    height: 48px;
  }
}

.noscript {
  max-width: 560px;
  margin: 24px auto 0;
  padding: 16px;
  background: var(--sand);
  color: var(--ink);
  border: var(--px) solid var(--ink);
}

.byline {
  margin-top: 8px;
  text-align: center;
  font-size: 18px;
  color: var(--on-bg);
}

.byline a {
  color: inherit;
  font-weight: 600;
  text-underline-offset: 3px;
}

.final-actions {
  display: grid;
  gap: 12px;
}

.final-actions .actions:has(> [hidden]) {
  grid-template-columns: 1fr;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  font: 11px/1.5 var(--pixel);
  text-transform: uppercase;
  text-align: center;
  color: var(--ink);
  background: var(--sand);
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
  padding: 10px 14px;
  z-index: 10;
}

/* Lobby */

.code-block {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-top: 12px;
}

.code-block .label {
  margin: 0;
  color: var(--on-bg);
}

.code {
  font-family: var(--pixel);
  line-height: 1.1;
  margin-block: 0;
  font-size: clamp(40px, 14vw, 64px);
  letter-spacing: 0.15em;
  margin-right: -0.15em;
  color: var(--white);
  text-shadow: 6px 6px 0 var(--ink);
}

.qr {
  width: min(200px, 60vw);
  aspect-ratio: 1;
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
  line-height: 0;
}

.qr svg {
  width: 100%;
  height: 100%;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 6px;
}

.code-block .qr-caption {
  font-size: 10px;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.players li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.players li::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--lime);
  box-shadow: 2px 2px 0 var(--ink);
}

.tag {
  font: 8px var(--pixel);
  text-transform: uppercase;
  color: var(--ink);
  background: var(--sand);
  padding: 4px 6px;
}

.tag.you {
  background: var(--foam);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.segmented {
  display: inline-flex;
  border: var(--px) solid var(--ink);
}

.segmented button {
  font: 12px var(--pixel);
  color: var(--white);
  background: var(--ink);
  border: 0;
  padding: 10px 14px;
  cursor: pointer;
}

.segmented button + button {
  border-left: var(--px) solid var(--panel);
}

.segmented button[aria-pressed='true'] {
  color: var(--ink);
  background: var(--sand);
}

/* Game */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--on-bg);
}

.topbar .dim {
  color: var(--on-bg-dim);
}

/* The pond: water with a stepped, pixel-rounded sand shore and ink outline */
.pond {
  --shore: var(--sand);
  position: relative;
  align-self: center;
  width: calc(100% - 32px);
  max-width: 400px;
  aspect-ratio: 1;
  margin: 16px 0;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  color: var(--white);
  font: inherit;
  background-color: var(--water);
  background-image: var(--water-pattern);
  background-size: 80px 64px;
  animation: drift 2s steps(4) infinite;
  box-shadow:
    8px 0 var(--shore),
    -8px 0 var(--shore),
    0 8px var(--shore),
    0 -8px var(--shore),
    16px 0 var(--ink),
    -16px 0 var(--ink),
    0 16px var(--ink),
    0 -16px var(--ink),
    8px 8px var(--ink),
    -8px 8px var(--ink),
    8px -8px var(--ink),
    -8px -8px var(--ink),
    inset 0 8px 0 var(--water-edge);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

@keyframes drift {
  to {
    background-position: 80px 0;
  }
}

.pond.good {
  --shore: var(--lime);
}

.pond.bad {
  --shore: var(--red);
}

.pond-sprite {
  width: 45%;
  aspect-ratio: 1;
  animation: bob 1.2s steps(1) infinite;
}

@keyframes bob {
  50% {
    transform: translateY(4px);
  }
}

.pond.pop .pond-sprite {
  animation: pop 0.3s steps(3);
}

@keyframes pop {
  from {
    transform: translateY(24px) scale(0.6);
  }
}

.pond-text {
  font: clamp(18px, 6vw, 26px) / 1.2 var(--pixel);
  text-transform: uppercase;
  text-shadow: 4px 4px 0 var(--ink);
}

.pond-sub {
  font-size: 18px;
  line-height: 1.2;
  color: var(--foam);
  text-shadow: 2px 2px 0 var(--ink);
  max-width: 90%;
}

.pond-sub kbd {
  font-size: 9px;
  text-shadow: none;
  vertical-align: 1px;
}

/* A square pixel ripple */
.ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border: var(--px) solid transparent;
  pointer-events: none;
}

.pond.rippling .ripple {
  animation: ripple 0.6s steps(5) forwards;
}

@keyframes ripple {
  from {
    width: 20%;
    height: 20%;
    border-color: var(--foam);
    transform: translate(-50%, -50%);
  }
  to {
    width: 110%;
    height: 110%;
    border-color: transparent;
    transform: translate(-50%, -50%);
  }
}

/* Scoreboard */

.board {
  list-style: none;
  margin: 0;
  padding: 0;
}

.board li {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: var(--px) dotted var(--slate);
}

.board li:last-child {
  border-bottom: 0;
}

.board .marker {
  font: 10px var(--pixel);
  color: var(--silver);
}

.board .marker .sprite {
  width: 32px;
  height: 32px;
}

.board .place-1 {
  color: var(--sand);
}

.board .place-2 {
  color: var(--white);
}

.board .place-3 {
  color: var(--orange);
}

.board .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board .me .name {
  color: var(--foam);
}

.board .stat {
  font: 12px/1.4 var(--pixel);
  text-align: right;
}

.board .stat small {
  display: block;
  font: 16px/1.2 var(--body);
  color: var(--silver);
}

.board .early {
  color: var(--orange);
}

@media (max-width: 420px) {
  body {
    font-size: 18px;
  }
  .actions {
    grid-template-columns: 1fr;
  }
  .btn {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flock .sprite,
  .pond,
  .pond-sprite,
  .pond.pop .pond-sprite,
  .pond.rippling .ripple {
    animation: none;
  }
}
