/* Llama Bocce */

:root {
  color-scheme: light;
  --ink: #3b2a20;
  --ink-soft: #7a6253;
  --outline: #5b3f2e;
  --cream: #fff7e6;
  --paper: #fffcf4;
  --sky: #cfede4;
  --sky-deep: #b5e2d6;
  --sand: #f3ddae;
  --wood: #a9744b;
  --grass: #a8d98f;
  --coral: #ef6a5b;
  --coral-deep: #c94a3d;
  --teal: #2fa7a0;
  --violet: #8a6fdb;
  --amber: #f0a93a;
  --c0: var(--coral);
  --c1: var(--teal);
  --c2: var(--violet);
  --c3: var(--amber);
  --font-display: 'Baloo 2', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --col: 540px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* The page's bottom colour. Phone browsers paint it in any space shown past the page (under the keyboard's
     AutoFill bar, or when pulled past the end), which would otherwise be white. */
  background-color: var(--cream);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% 0%, #e6f7f0 0%, transparent 70%),
    linear-gradient(180deg, var(--sky) 0%, #e9f6e4 46%, var(--cream) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* While typing in a browser that shrinks the page for the keyboard (see main.ts): the court is shortened so
   the page ends right on top of the keyboard, and so fits exactly with nothing to scroll. The page
   is deliberately not locked with overflow: hidden, as Chrome then skips animating the page's height and
   jumps straight to the end. */
html.keyboard-up body {
  min-height: 0;
}

html.keyboard-up #app {
  padding-bottom: 0;
}

/* While typing on a phone the throws so far are put away, so the court and its four ideas keep the room
   above the keyboard for the court. They come back as it closes. */
html.typing .throws,
html.keyboard-up .throws {
  display: none;
}

/* Safari's keyboard on iPhone, with its bar, covers more than half the screen: Bruno's line is put away too
   while typing there, so the court keeps some room (see fitAboveCoveringKeyboard in main.ts) */
html.covering .ticker {
  display: none;
}

#app {
  max-width: var(--col);
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 32px;
  flex: none;
  overflow: hidden;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 6vw, 25px);
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.brand-day {
  margin-top: 1px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
}

.top-nav {
  display: flex;
  gap: 5px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2.5px solid var(--outline);
  border-radius: 13px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--outline);
  transition: transform 0.08s, box-shadow 0.08s;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--outline);
}

.icon-btn:focus-visible,
.btn:focus-visible,
.throw-btn:focus-visible,
.link-btn:focus-visible,
.tab:focus-visible,
.throw-row:focus-visible,
.court-card:focus-visible,
.hat-btn:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 8px 7px 14px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: #e8e0fa;
  font-size: 14px;
  font-weight: 800;
}

.modebar[hidden] {
  display: none;
}

.link-btn {
  border: 0;
  background: none;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 900;
  color: #5d43b8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Scene ---------- */

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scene {
  position: relative;
  /* The corner signs size their text from the court's width (cqi), not the screen's */
  container-type: inline-size;
  /* Sized so the whole page, header to footer, fits on screen. --screen-h is the height measured once on
     phones, so the keyboard never resizes the court, and --other-h the height of everything else (see
     main.ts). */
  width: min(100%, max(200px, calc((var(--screen-h, 100dvh) - var(--other-h, 178px)) * 400 / 570)));
  aspect-ratio: 400 / 570;
  margin-top: 6px;
  user-select: none;
  -webkit-user-select: none;
}

.scene-svg {
  /* Above the corner signs, so a ball in flight passes over them */
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  font-family: var(--font-body);
}

.sign {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 47.5%;
  padding: 3px 8px 3px 5px;
  border: 2px solid var(--outline);
  border-radius: 10px;
  background: color-mix(in srgb, var(--c) 20%, var(--paper));
  box-shadow: 0 2px 0 var(--outline);
  /* Scales with the court, so an idea fits on one line however big the court is drawn */
  font-size: clamp(9px, 3.5cqi, 13.5px);
  font-weight: 800;
  line-height: 1.12;
}

.sign-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-wrap: balance;
}

.sign-flag {
  flex: none;
  width: 11px;
  height: 11px;
  border: 2px solid var(--outline);
  border-radius: 50%;
  background: var(--c);
}

.sign-0 { --c: var(--c0); left: 1.5%; bottom: 94.4%; }
.sign-1 { --c: var(--c1); right: 1.5%; bottom: 94.4%; flex-direction: row-reverse; text-align: right; padding: 3px 5px 3px 8px; }
.sign-2 { --c: var(--c2); right: 1.5%; top: 71.6%; flex-direction: row-reverse; text-align: right; padding: 3px 5px 3px 8px; }
.sign-3 { --c: var(--c3); left: 1.5%; top: 71.6%; }

/* Balls and markings */

.ball text {
  font-family: var(--font-body);
  pointer-events: none;
}

.measure {
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.measure.is-focus {
  opacity: 1;
}

.measure-line {
  fill: none;
  stroke: var(--outline);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.measure-label rect {
  fill: var(--paper);
  stroke: var(--outline);
  stroke-width: 1.6;
}

.measure-label text {
  font: 900 10px var(--font-body);
  fill: var(--ink);
}

.measure-in .measure-label {
  animation: pop-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  transform-box: fill-box;
  transform-origin: center;
}

.ball.is-focus circle:first-child {
  stroke-width: 2.6;
}

.puff {
  fill: #d9b878;
  opacity: 0.8;
  transform-box: fill-box;
  transform-origin: center;
  animation: puff 0.6s ease-out forwards;
}

.ring {
  fill: none;
  stroke-width: 2.2;
  transform-box: fill-box;
  transform-origin: center;
  animation: ring 0.85s ease-out forwards;
}

.confetti {
  transform-box: fill-box;
  transform-origin: center;
  animation: confetti 1.7s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.emote {
  transform-box: fill-box;
  transform-origin: center;
  animation: emote 1.4s ease-out forwards;
}

@keyframes puff {
  to { transform: translate(var(--dx), var(--dy)) scale(1.9); opacity: 0; }
}

@keyframes ring {
  from { transform: scale(0.4); opacity: 0.9; }
  to { transform: scale(4.2); opacity: 0; }
}

@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 46px)) rotate(var(--rot)); opacity: 0; }
}

@keyframes emote {
  0% { transform: translateY(6px) scale(0); opacity: 0; }
  18% { transform: translateY(-6px) scale(1.25); opacity: 1; }
  30% { transform: translateY(-9px) scale(1); }
  75% { opacity: 1; }
  100% { transform: translateY(-30px) scale(1); opacity: 0; }
}

@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Llamas ---------- */

.ll-face { display: none; }
.llama[data-face='neutral'] .ll-face-neutral,
.llama[data-face='happy'] .ll-face-happy,
.llama[data-face='love'] .ll-face-love,
.llama[data-face='meh'] .ll-face-meh,
.llama[data-face='sad'] .ll-face-sad,
.llama[data-face='angry'] .ll-face-angry,
.llama[data-face='shock'] .ll-face-shock,
.llama[data-face='smug'] .ll-face-smug,
.llama[data-face='focus'] .ll-face-focus,
.llama[data-face='flirt'] .ll-face-flirt,
.llama[data-face='bite'] .ll-face-bite { display: inline; }

/* The flirt face waggles its raised eyebrows twice */
.llama[data-face='flirt'] .ll-face-flirt .ll-brows { animation: ll-brow-waggle 0.36s ease-in-out 2; }
@keyframes ll-brow-waggle { 50% { transform: translateY(-1.6px); } }

.ll-neck,
.ll-head,
.ll-ear,
.ll-tache {
  transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1);
}

/* Idle: breathing, a slow sway, the odd ear twitch, tail wag and blink */
.ll-body { animation: ll-breathe 3.4s ease-in-out infinite; }
.ll-neck { animation: ll-sway 5.2s ease-in-out infinite; }
.ll-tail { animation: ll-wag 3.1s ease-in-out infinite; }
.ll-ear-l { animation: ll-twitch 6.3s ease-in-out infinite; }
.ll-ear-r { animation: ll-twitch 7.9s ease-in-out 1.7s infinite reverse; }
.ll-blink { transform-box: fill-box; transform-origin: center; animation: ll-blink 4.7s infinite; }
.llama-bruno .ll-neck { animation-duration: 6.4s; animation-delay: -2s; }
.llama-bruno .ll-body { animation-delay: -1.2s; }
.llama-bruno .ll-blink { animation-delay: -2.2s; }

@keyframes ll-breathe { 50% { transform: scale(1.012, 1.035); } }
@keyframes ll-sway { 0%, 100% { transform: rotate(-1.7deg); } 50% { transform: rotate(1.9deg); } }
@keyframes ll-wag { 0%, 62%, 100% { transform: rotate(0); } 70% { transform: rotate(-18deg); } 80% { transform: rotate(12deg); } 90% { transform: rotate(-10deg); } }
@keyframes ll-twitch { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-15deg); } 94% { transform: rotate(5deg); } }
@keyframes ll-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.08); } }

/* A newly chosen hat drops onto the head */
.ll-hat.is-new { animation: hat-drop 0.5s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes hat-drop {
  0% { transform: translateY(-16px) rotate(-14deg); opacity: 0; }
  55% { opacity: 1; }
  70% { transform: translateY(1.5px) rotate(3deg) scale(1.06, 0.92); }
  100% { transform: none; }
}

/* Poses that hold */
.llama[data-pose='droop'] .ll-neck { animation: none; transform: rotate(15deg); }
.llama[data-pose='droop'] .ll-head { transform: rotate(9deg); }
.llama[data-pose='droop'] .ll-ear-l { animation: none; transform: rotate(-46deg); }
.llama[data-pose='droop'] .ll-ear-r { animation: none; transform: rotate(46deg); }
.llama[data-pose='proud'] .ll-neck { animation: none; transform: rotate(-7deg); }
.llama[data-pose='proud'] .ll-head { transform: rotate(-5deg); }

/* A moustache has moods of its own */
.llama[data-face='smug'] .ll-tache-l, .llama[data-face='happy'] .ll-tache-l { transform: rotate(10deg); }
.llama[data-face='smug'] .ll-tache-r, .llama[data-face='happy'] .ll-tache-r { transform: rotate(-10deg); }
.llama[data-face='shock'] .ll-tache-l, .llama[data-face='sad'] .ll-tache-l { transform: rotate(-16deg); }
.llama[data-face='shock'] .ll-tache-r, .llama[data-face='sad'] .ll-tache-r { transform: rotate(16deg); }

/* Being touched (see Scene.listen). The cover takes the touch, so dragging pets instead of scrolling. */
.ll-hit {
  cursor: pointer;
  touch-action: none;
}

/* Being petted: a happy wiggle for as long as it lasts. Bruno shakes his head until he gives in (smug). */
.llama[data-pet] .ll-head { animation: ll-pet-head 0.7s ease-in-out infinite; }
.llama[data-pet] .ll-neck { animation: ll-pet-neck 0.7s ease-in-out infinite; }
.llama[data-pet] .ll-body { animation: ll-jiggle 0.35s ease-in-out infinite; }
.llama[data-pet] .ll-tail { animation: ll-wag-fast 0.3s linear infinite; }
.llama-bruno[data-pet]:not([data-face='smug']) .ll-head { animation: ll-shake 0.5s linear infinite; }
.llama-bruno[data-pet]:not([data-face='smug']) .ll-tail { animation: none; }
@keyframes ll-pet-head { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes ll-pet-neck { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

/* One-shot moves */
.llama[data-move='kick'] .ll-all { animation: ll-kick-all 0.9s ease-in-out; }
.llama[data-move='kick'] .ll-leg-nf { animation: ll-kick-leg 0.9s ease-in-out; }
.llama[data-move='kick'] .ll-leg-ff { animation: ll-kick-leg-far 0.9s ease-in-out; }
.llama[data-move='kick'] .ll-neck { animation: ll-kick-neck 0.9s ease-in-out; }
@keyframes ll-kick-all { 0% { transform: rotate(0); } 34% { transform: rotate(-10deg); } 48% { transform: rotate(4deg) translateX(3px); } 66% { transform: rotate(2deg); } 100% { transform: rotate(0); } }
@keyframes ll-kick-leg { 0% { transform: rotate(0); } 34% { transform: rotate(44deg); } 47% { transform: rotate(-80deg); } 62% { transform: rotate(-58deg); } 100% { transform: rotate(0); } }
@keyframes ll-kick-leg-far { 0%, 100% { transform: rotate(0); } 34% { transform: rotate(-14deg); } 50% { transform: rotate(16deg); } }
@keyframes ll-kick-neck { 0%, 100% { transform: rotate(0); } 34% { transform: rotate(-9deg); } 48% { transform: rotate(11deg); } }

.llama[data-move='hop'] .ll-all { animation: ll-hop 0.7s ease-out; }
@keyframes ll-hop { 0%, 100% { transform: translateY(0); } 12% { transform: translateY(1px) scale(1.04, 0.95); } 34% { transform: translateY(-15px) scale(0.98, 1.03); } 56% { transform: translateY(0) scale(1.03, 0.96); } 74% { transform: translateY(-6px); } }

.llama[data-move='jump'] .ll-all { animation: ll-jump 1.5s ease-out; }
.llama[data-move='jump'] .ll-neck { animation: ll-wiggle 0.5s ease-in-out 3; }
.llama[data-move='jump'] .ll-tail { animation: ll-wag-fast 0.3s linear 5; }
@keyframes ll-jump { 0%, 100% { transform: translateY(0); } 6% { transform: translateY(2px) scale(1.05, 0.93); } 20% { transform: translateY(-24px) rotate(-5deg); } 34% { transform: translateY(0) scale(1.05, 0.94); } 50% { transform: translateY(-20px) rotate(5deg); } 66% { transform: translateY(0) scale(1.04, 0.95); } 82% { transform: translateY(-12px); } }
@keyframes ll-wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(7deg); } }
@keyframes ll-wag-fast { 0%, 100% { transform: rotate(-20deg); } 50% { transform: rotate(16deg); } }

.llama[data-move='stomp'] .ll-leg-nf { animation: ll-stomp 0.36s ease-in 3; }
.llama[data-move='stomp'] .ll-head { animation: ll-shake 0.24s linear 4; }
.llama[data-move='stomp'] .ll-all { animation: ll-rumble 0.36s linear 3; }
@keyframes ll-stomp { 0%, 100% { transform: rotate(0); } 45% { transform: rotate(-38deg) translateY(-3px); } }
@keyframes ll-shake { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes ll-rumble { 0%, 60%, 100% { transform: translateY(0); } 80% { transform: translateY(1.6px); } }

.llama[data-move='chuckle'] .ll-neck { animation: ll-chuckle 0.25s ease-in-out 4; }
.llama[data-move='chuckle'] .ll-body { animation: ll-jiggle 0.25s ease-in-out 4; }
@keyframes ll-chuckle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(1.5px); } }
@keyframes ll-jiggle { 50% { transform: scale(1.02, 0.97); } }

.llama[data-move='startle'] .ll-all { animation: ll-startle 0.7s ease-out; }
.llama[data-move='startle'] .ll-ear-l, .llama[data-move='startle'] .ll-ear-r { animation: ll-ears-up 0.7s ease-out; }
@keyframes ll-startle { 0%, 100% { transform: translate(0, 0); } 18% { transform: translate(-7px, -12px) rotate(-6deg); } 45% { transform: translate(-5px, 0) scale(1.03, 0.96); } }
@keyframes ll-ears-up { 20%, 60% { transform: scaleY(1.2); } }

.llama[data-move='nod'] .ll-head { animation: ll-nod 0.35s ease-in-out 2; }
@keyframes ll-nod { 50% { transform: rotate(10deg); } }

.llama[data-move='shrug'] .ll-head { animation: ll-shrug 0.8s ease-in-out; }
.llama[data-move='shrug'] .ll-all { animation: ll-shrug-body 0.8s ease-in-out; }
@keyframes ll-shrug { 30%, 70% { transform: rotate(-11deg); } }
@keyframes ll-shrug-body { 30%, 70% { transform: translateY(-2.5px); } }

.llama[data-move='spit'] .ll-neck { animation: ll-spit 0.7s ease-in-out; }
@keyframes ll-spit { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-12deg); } 46% { transform: rotate(13deg); } }

/* A happy head wiggle, eyes closed (face tap) */
.llama[data-move='giggle'] .ll-head { animation: ll-giggle 0.32s ease-in-out 3; }
.llama[data-move='giggle'] .ll-neck { animation: ll-chuckle 0.32s ease-in-out 3; }
@keyframes ll-giggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-11deg); } 75% { transform: rotate(11deg); } }

/* A butt wiggle (tail tap) */
.llama[data-move='wiggle'] .ll-body { animation: ll-butt 0.25s ease-in-out 4; }
.llama[data-move='wiggle'] .ll-tail { animation: ll-butt-tail 0.25s ease-in-out 4; }
.llama[data-move='wiggle'] .ll-leg-nb,
.llama[data-move='wiggle'] .ll-leg-fb { animation: ll-butt-leg 0.25s ease-in-out 4; }
@keyframes ll-butt { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-3px) rotate(-3deg); } 75% { transform: translateX(3px) rotate(3deg); } }
@keyframes ll-butt-tail { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-4px) rotate(-24deg); } 75% { transform: translateX(3px) rotate(20deg); } }
@keyframes ll-butt-leg { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

/* Bruno, poked on the nose: rears back and shakes his head, hmph */
.llama[data-move='scowl'] .ll-head { animation: ll-scowl 1s ease-in-out; }
.llama[data-move='scowl'] .ll-all { animation: ll-lean-back 1s ease-in-out; }
@keyframes ll-scowl { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-9deg); } 30% { transform: rotate(-2deg); } 45% { transform: rotate(-9deg); } 60% { transform: rotate(-3deg); } 75% { transform: rotate(-7deg); } }
@keyframes ll-lean-back { 20%, 70% { transform: translateX(-3px) rotate(-2deg); } }

/* ---------- Ticker, input, throws ---------- */

.ticker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance;
}

.ticker-line {
  animation: rise 0.3s ease-out both;
}

.ticker-who {
  color: var(--coral-deep);
  font-weight: 900;
}

@keyframes rise {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.throw-form {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.throw-form[hidden],
.hint[hidden] {
  display: none;
}

.throw-form input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: inset 0 3px 0 rgba(91, 63, 46, 0.1);
  font-size: 17px;
  font-weight: 800;
  outline: none;
}

.throw-form input::placeholder {
  color: #b39f8f;
  font-weight: 700;
}

.throw-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 167, 160, 0.25);
}

.throw-form input:disabled {
  background: #f1e9d8;
  color: var(--ink-soft);
}

.throw-form.is-wrong {
  animation: wobble 0.36s;
}

.throw-form.is-wrong input {
  border-color: var(--coral-deep);
}

@keyframes wobble {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.throw-btn,
.btn {
  flex: none;
  height: 52px;
  padding: 0 22px;
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  background: var(--coral);
  color: #fff;
  box-shadow: 0 4px 0 var(--outline);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-shadow: 0 1.5px 0 rgba(91, 63, 46, 0.45);
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}

.throw-btn:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--outline);
}

.throw-btn:disabled,
.btn:disabled {
  filter: grayscale(0.7) opacity(0.6);
  cursor: default;
}

.btn {
  height: 48px;
  font-size: 18px;
}

.btn-quiet {
  background: var(--paper);
  color: var(--ink);
  text-shadow: none;
}

.btn-teal {
  background: var(--teal);
}

.btn-small {
  height: 40px;
  padding: 0 14px;
  font-size: 16px;
  border-radius: 13px;
  box-shadow: 0 3px 0 var(--outline);
}

.hint {
  width: 100%;
  min-height: 20px;
  margin: 7px 0 0;
  padding: 0 6px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink-soft);
  text-align: center;
  text-wrap: balance;
}

.hint.is-error {
  color: var(--coral-deep);
}

.throws {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

/* No gap kept for the list before anything has been thrown: that space goes to the court */
.throws:empty {
  margin-top: 0;
}

.throw-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  grid-template-areas: 'ball phrase cm' 'ball bar bar';
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  width: 100%;
  padding: 8px 12px 9px 10px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--outline);
  text-align: left;
  animation: rise 0.3s ease-out both;
}

.throw-row.is-best {
  background: #fff3c9;
}

.throw-row.is-focus {
  border-color: var(--teal);
  box-shadow: 0 3px 0 var(--teal);
}

.throw-ball {
  grid-area: ball;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--outline);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8a70, #e4532f 55%, #b93a1c);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.throw-phrase {
  grid-area: phrase;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.2;
}

.throw-cm {
  grid-area: cm;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.throw-cm small {
  margin-left: 5px;
  font-size: 13px;
}

.pull {
  grid-area: bar;
  display: flex;
  height: 10px;
  border: 2px solid var(--outline);
  border-radius: 6px;
  overflow: hidden;
  background: var(--cream);
}

.pull i {
  display: block;
  height: 100%;
  min-width: 0;
  transition: flex-grow 0.6s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.pull i + i {
  border-left: 1.5px solid var(--outline);
}

.pull .p0 { background: var(--c0); }
.pull .p1 { background: var(--c1); }
.pull .p2 { background: var(--c2); }
.pull .p3 { background: var(--c3); }

.after {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  text-align: center;
}

.after[hidden] {
  display: none;
}

.after-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  width: 100%;
}

.after-row .btn {
  padding: 0 6px;
  font-size: clamp(14px, 4.2vw, 17px);
}

.countdown {
  font-size: 14px;
  color: var(--ink-soft);
}

.countdown b {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.foot {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
}

/* On phones, "A new court every day" waits until the game is over: while playing, the court gets the room */
@media (max-width: 619px) {
  .playing .foot {
    display: none;
  }
}

/* ---------- Sheets ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(59, 42, 32, 0.45);
  animation: fade 0.2s ease-out both;
}

.sheet {
  position: relative;
  width: min(100%, 520px);
  max-height: 96dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border: 3px solid var(--outline);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: var(--cream);
  animation: sheet-up 0.32s cubic-bezier(0.2, 1, 0.3, 1) both;
}

@media (min-width: 620px) and (min-height: 620px) {
  .sheet-backdrop {
    align-items: center;
  }
  .sheet {
    border-bottom: 3px solid var(--outline);
    border-radius: 26px;
    box-shadow: 0 8px 0 rgba(59, 42, 32, 0.35);
    padding-bottom: 24px;
  }
}

.sheet-backdrop.is-closing {
  animation: fade 0.18s ease-in reverse both;
}

.sheet-backdrop.is-closing .sheet {
  animation: sheet-up 0.18s ease-in reverse both;
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  box-shadow: 0 2px 0 var(--outline);
  border-radius: 12px;
}

.sheet h2 {
  margin: 0 44px 4px 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.05;
}

.sheet h3 {
  margin: 18px 0 6px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
}

.sheet p {
  margin: 6px 0;
  font-size: 15.5px;
  line-height: 1.4;
}

.sheet .lede {
  color: var(--ink-soft);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.sheet-actions .btn {
  flex: 1;
}

/* How to play: sized to show everything at once, without scrolling */

.sheet-roomy {
  padding-top: 18px;
}

.sheet-roomy .steps {
  gap: 8px;
  margin-top: 10px;
}

.sheet-roomy .steps li {
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1.32;
}

.sheet-roomy .sheet-actions {
  margin-top: 12px;
}

.help-foot {
  text-align: center;
}

/* Short screens: tighten up rather than scroll */
@media (max-height: 800px) and (max-width: 619px) {
  .sheet-roomy .demo {
    max-width: 270px;
    margin-top: 8px;
  }
  .sheet-roomy h2 {
    font-size: 25px;
  }
  .sheet-roomy .steps li {
    padding: 7px 11px;
    font-size: 14.5px;
  }
}

@media (max-height: 700px) {
  .sheet-roomy .demo {
    max-width: 215px;
  }
  .sheet-roomy .steps li {
    grid-template-columns: 28px 1fr;
    gap: 10px;
    font-size: 14px;
  }
  .sheet-roomy .steps li::before {
    width: 26px;
    height: 26px;
    font-size: 15px;
  }
  .sheet-roomy .lede {
    margin: 3px 0;
    font-size: 14.5px;
  }
}

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

.steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 13px;
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  background: var(--paper);
  font-size: 15.5px;
  line-height: 1.35;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--outline);
  border-radius: 50%;
  background: var(--amber);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
}

.steps b {
  font-weight: 900;
}

.chip {
  display: inline-block;
  padding: 0 7px;
  border: 2px solid var(--outline);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c, var(--amber)) 26%, var(--paper));
  font-weight: 800;
  white-space: nowrap;
}

/* A chip and the full stop after it stay on one line. The full stop hangs into the padding, so it never
   pushes the chip onto a new line. */
.chip-end {
  margin-right: -0.3em;
  white-space: nowrap;
}

.demo {
  display: block;
  width: 100%;
  max-width: 330px;
  margin: 12px auto 2px;
}

/* Results */

.result-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}

.result-llama {
  flex: none;
  width: 104px;
  height: 116px;
  overflow: visible;
}

.result-kicker {
  font-size: 13.5px;
  font-weight: 900;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.result-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.result-cm {
  margin-top: 2px;
  font-size: 16px;
}

.result-cm b {
  font-family: var(--font-display);
  font-size: 22px;
}

.result-dots {
  margin: 12px 0 2px;
  font-size: 24px;
  letter-spacing: 3px;
}

/* How the player did against the friend whose link brought them here */
.result-versus {
  margin: 8px 0 2px !important;
  font-weight: 800;
}

.statline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stat {
  padding: 8px 4px 7px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--paper);
  text-align: center;
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
}

.stat span {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.name-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.name-form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 2.5px solid var(--outline);
  border-radius: 13px;
  background: var(--paper);
  font-size: 16px;
  font-weight: 800;
  outline: none;
}

.name-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 167, 160, 0.25);
}

.form-note {
  min-height: 18px;
  margin: 5px 2px 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.form-note.is-error {
  color: var(--coral-deep);
}

/* Leaderboards */

.tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 10px;
  padding: 4px;
  border: 2.5px solid var(--outline);
  border-radius: 15px;
  background: var(--paper);
}

.tabs-narrow {
  max-width: 230px;
  margin: 8px 0 6px;
}

.tab {
  flex: 1;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 14.5px;
  font-weight: 900;
  color: var(--ink-soft);
}

.tab[aria-selected='true'] {
  background: var(--amber);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--outline);
}

.board-body {
  min-height: min(46dvh, 380px);
}

/* One grid for the whole list, so names line up even when a rank runs to six digits */
.board-list {
  display: grid;
  grid-template-columns: minmax(34px, auto) 1fr auto;
  column-gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-row {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  padding: 4px 10px;
  border-bottom: 2px dashed rgba(91, 63, 46, 0.2);
  font-size: 15.5px;
}

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

.board-row.is-you {
  border: 2.5px solid var(--outline);
  border-radius: 12px;
  background: #fff3c9;
}

.board-rank {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.board-rank.is-long {
  font-size: 14px;
}

/* Marks the players left out between the leaders and the viewer's own neighbourhood */
.board-gap {
  grid-column: 1 / -1;
  padding: 3px 0 5px;
  border-bottom: 2px dashed rgba(91, 63, 46, 0.2);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--ink-soft);
  text-align: center;
}

.board-who {
  min-width: 0;
}

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

.board-phrase {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink-soft);
}

.board-score {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.board-score small {
  display: block;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

/* Short screens: one line per row, so all ten fit without scrolling */
@media (max-height: 720px) {
  .board-score small {
    display: none;
  }
  .board-row {
    padding: 4px 10px;
  }
  .tabs {
    margin: 8px 0 6px;
  }
  .board-note {
    margin-top: 6px;
  }
}

.empty {
  padding: 22px 10px;
  text-align: center;
  color: var(--ink-soft);
}

.board-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

/* Practice */

.court-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.court-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--outline);
  text-align: left;
}

.court-card:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--outline);
}

.court-title {
  font-weight: 900;
  font-size: 15.5px;
}

.court-corners {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink-soft);
}

.court-best {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
}

/* You: hats */

.hats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.hat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px 7px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--paper);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.hat-btn svg {
  width: 58px;
  height: 56px;
  overflow: hidden;
}

.hat-btn[aria-pressed='true'] {
  background: #fff3c9;
  box-shadow: inset 0 0 0 2px var(--amber);
}

.hat-btn:disabled {
  cursor: default;
  color: var(--ink-soft);
}

.hat-btn:disabled svg {
  filter: grayscale(1) opacity(0.4);
}

/* A shared result, as its visitor sees it */

.shared-card {
  display: block;
  width: calc(100% - 44px);
  height: auto;
  margin: 0 0 14px;
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--outline);
}

.shared-title {
  margin: 4px 0 8px;
  font-size: 28px;
  line-height: 1.08;
}

/* Share panel */

.share-preview {
  display: grid;
  place-items: center;
  min-height: 160px;
  margin: 8px 0 14px;
}

/* A still of the finished game, then the replay video once it is made, or the result card where a
   video can't be made. Each replaces the last at the same size. */
.share-preview img,
.share-preview canvas,
.share-preview video {
  display: block;
  width: auto;
  max-width: 100%;
  /* A first guess. The share panel then sets the height to exactly what the screen has left (see `fit`
     in share.ts), so the panel never needs scrolling. */
  height: min(440px, max(150px, 96dvh - 330px));
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--outline);
  background: var(--sky);
}

/* The one big button: the words and the link */
.share-main {
  display: block;
  width: 100%;
}

/* Under it, the quieter ways: the video or picture as a file, and copying */
.share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  margin-top: 12px;
}

.share-actions .btn {
  flex: 1 1 0;
  display: inline-grid;
  place-items: center;
  padding: 0 11px;
  white-space: nowrap;
  text-decoration: none;
}

/* While the video is being made its button fills from the left (--made is set from share.ts) */
.share-media:disabled {
  opacity: 1;
  color: var(--ink-soft);
  background: linear-gradient(to right, #d5efe9 var(--made, 0%), var(--paper) var(--made, 0%));
  cursor: progress;
}

@media (max-width: 380px) {
  .share-actions .btn {
    padding: 0 8px;
    font-size: 15px;
  }
}

.share-label {
  margin: 14px 0 6px !important;
  font-size: 13px !important;
  font-weight: 900;
  color: var(--ink-soft);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.share-link {
  padding: 5px 12px;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.share-link:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  background: var(--ink);
  color: var(--cream);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s, opacity 0.25s;
}

.toast.is-on {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------- Calm mode ---------- */

@media (prefers-reduced-motion: reduce) {
  .ll-body, .ll-neck, .ll-tail, .ll-ear, .ll-blink, .ll-hat.is-new,
  .llama[data-move] *,
  .llama[data-pet] *,
  .ticker-line, .throw-row, .sheet, .sheet-backdrop, .measure-in .measure-label {
    animation: none !important;
  }
  .pull i, .toast, .icon-btn, .throw-btn, .btn {
    transition: none;
  }
}

/* Development only: what the keyboard handling sees, for checking it on a real phone (see showFit in main.ts) */
.fit-readout {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 2px 6px;
  background: rgb(0 0 0 / 0.65);
  color: #fff;
  font: 600 10px/1.3 ui-monospace, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}

/* Out of the way while typing, when the top of the page matters; it shows what happened once the keyboard closes */
html.typing .fit-readout,
html.keyboard-up .fit-readout {
  display: none;
}
