/* ==========================================================================
   ACE · styles
   Premium, not playful: near-black, monochrome, one accent used sparingly.
   One hero per screen; space, not boxes, creates the hierarchy.
   Mobile-first: base styles target ~375px phones; one wider rule at the end.
   ========================================================================== */

/* ---- Font: self-hosted Inter (variable), system font as fallback --------- */
/* Latin-only subset of Inter 4 (all weights, both axes, all OpenType
   features). Letters outside Latin, e.g. in a player's name, fall back to
   the system font. */
@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable-latin.woff2?v=1") format("woff2");  /* same URL as the preload in index.html */
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- Design tokens ------------------------------------------------------ */
:root {
  /* Surfaces */
  --bg: #0A0A0B;
  --surface: #141416;
  --hairline: rgba(255, 255, 255, 0.10);
  --hairline-strong: rgba(255, 255, 255, 0.18);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* Text */
  --text: #F5F5F3;
  --text-2: #A1A1A6;
  --text-3: #8E8E93;

  /* The one accent: cue word, main button, selected states. Nothing else. */
  --ball: #D7F205;
  --ball-soft: rgba(215, 242, 5, 0.15);
  --ball-ring: rgba(215, 242, 5, 0.6);  /* keyboard focus ring */
  --on-ball: #0A0A0B;

  /* Shape */
  --radius: 16px;
  --radius-input: 14px;

  /* Spacing (8px scale). Tight inside a group, wide between groups. */
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --space-7: 64px;

  /* Page edges */
  --page-x: 24px;
  /* Extra room kept clear at the bottom for a host's floating badge. No
     host adds one now, so it's 0; raise it here if one ever comes back. */
  --badge-clearance: 0px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  /* Motion: one calm ease-out, no overshoot */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- Base --------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

/* Full-height column so each view can fill the screen. The soft radial light
   from the top gives depth without adding colour. */
body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 255, 255, 0.05), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3, p {
  margin: 0;
}

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

/* Focus ring: keyboard only. Taps and clicks never show a ring (this also
   removes the browser's default blue outline), but Tab still gets a soft
   accent ring that follows each control's rounded corners. */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--ball-ring);
  outline-offset: 3px;
}

/* Headings that receive focus programmatically don't need a ring. */
[tabindex="-1"]:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Wordmark: small and quiet, chrome rather than content -------------- */
.brand {
  padding: 20px var(--page-x) 0;
  line-height: 20px;
}

.brand__name {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--text-3);
}

/* ---- Layout ------------------------------------------------------------- */
.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;  /* anchors the view that is fading out */
  width: 100%;
  padding: var(--space-5) var(--page-x)
           calc(var(--space-4) + var(--badge-clearance));
}

/* Views stack their blocks with explicit margins (below), not a uniform gap,
   so spacing follows the hierarchy. */
/* Keep fill-mode "both" on entrance animations: it keeps finished text on its
   own layer, which gives the smooth greyscale text edges this design is
   tuned for. Switching to "backwards" visibly changes text rendering. */
.view {
  display: flex;
  flex-direction: column;
  flex: 1;
  animation: view-in 400ms var(--ease) both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* The old view sits on top of the new one, in the same spot, and fades out
   while the new one fades in. Duration matches VIEW_LEAVE_MS in app.js.
   padding: inherit copies .app's padding so nothing shifts. */
.view.is-leaving {
  position: absolute;
  inset: 0;
  padding: inherit;
  pointer-events: none;
  animation: view-out 200ms var(--ease) both;
}

@keyframes view-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Opacity-only entrance, used when the player prefers reduced motion. */
@keyframes view-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ---- Type --------------------------------------------------------------- */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.greeting {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text-2);
}

.greeting:empty {
  display: none;
}

/* The hero question on the welcome and picker screens. */
.title {
  font-size: clamp(2.5rem, 11vw, 3.5rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

/* ---- Court-line divider (subtle tennis touch) --------------------------- */
/* A hairline with a small centre mark, like a court's centre service mark. */
.court-line {
  position: relative;
  height: 1px;
  background: var(--hairline);
}

.court-line::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 8px;
  background: var(--hairline-strong);
}

/* ---- Welcome (name) ----------------------------------------------------- */
.welcome {
  display: flex;
  flex-direction: column;
  margin-block: auto;  /* centre the form in the spare height */
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-6);
}

.field__label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-2);
}

.field__input {
  min-height: 56px;
  padding: 14px 16px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-input);
  background: var(--surface);
  box-shadow: var(--highlight);
  font-size: 1.1875rem;   /* 16px+ stops iOS zooming in on focus */
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.field__input:focus,
.field__input:focus-visible {
  outline: none;
  border-color: var(--ball);
  box-shadow: var(--highlight), 0 0 0 3px var(--ball-soft);
}

.field__hint {
  min-height: 1.5em;
  font-size: 0.9375rem;
  color: var(--text);
}

.welcome .button-main {
  margin-top: var(--space-4);  /* hint line above adds ~24px, so ~48 total */
}

/* ---- Picker tiles ------------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: 40px;
  margin-top: clamp(40px, 6dvh, var(--space-7));
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Grow with the screen so tall phones don't get a blank band below the
     tiles. ~480px is the height of everything else on the picker, plus any
     badge clearance at the bottom. */
  min-height: 116px;
  min-height: clamp(116px, calc((100vh - 480px - var(--badge-clearance)) / 2), 200px);
  min-height: clamp(116px, calc((100dvh - 480px - var(--badge-clearance)) / 2), 200px);
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 60%),
    var(--surface);
  box-shadow: var(--highlight);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 200ms var(--ease),
    box-shadow 200ms var(--ease),
    transform 200ms var(--ease);
}

/* Touch hygiene for tappable controls: no grey iOS flash, no text selection,
   no long-press callout, no double-tap-zoom delay. */
.tile,
.segmented__option {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.tile__icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--text-2);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 200ms var(--ease);
}

.tile__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile__label {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* "2 of 3 worked": quiet and numeric. No accent, so the tile stays calm. */
.tile__tally {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.tile__tally:empty {
  display: none;
}

@media (hover: hover) {
  .tile:hover {
    border-color: var(--hairline-strong);
  }
}

/* Selected (pressed) state: the accent appears only here. app.js keeps
   .is-pressed on the tapped tile while the picker fades out, so the
   highlight fades away with it and navigation never waits. */
.tile:active,
.tile.is-pressed {
  border-color: var(--ball);
  box-shadow: var(--highlight), inset 0 0 24px var(--ball-soft);
  transform: scale(0.985);
}

.tile:active .tile__icon,
.tile.is-pressed .tile__icon {
  stroke: var(--ball);
}

/* Footer sits at the bottom of the picker and soaks up any leftover space. */
.picker__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: var(--space-5);
  text-align: center;
}

.picker__note {
  font-size: 0.9375rem;
  color: var(--text-3);
  text-wrap: balance;
}

/* On tall screens the tiles hit their height cap. Share the spare height
   above the hero and above the footer so nothing leaves a blank band.
   On short screens there is no spare height, so this changes nothing. */
#picker .intro {
  margin-top: auto;
}

.link-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 0.875rem;
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;  /* no blue flash on Android taps */
  touch-action: manipulation;
  transition: color 200ms var(--ease);
}

@media (hover: hover) {
  .link-button:hover {
    color: var(--text);
  }
}

/* Tapped link: brightens while its screen fades out (see switchView). */
.link-button:active,
.link-button.is-pressed {
  color: var(--text);
}

/* ---- Result: the cue, unboxed, is the hero ------------------------------ */
/* The coach's line when ACE changed the cue: quiet, and it leads straight
   into the cue ("Didn't work? Try this:"). */
.result__note {
  margin-top: var(--space-2);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-2);
  text-wrap: pretty;
}

.cue {
  margin-top: var(--space-3);
}

/* Shared hero type for the cue on the result and check-in screens. */
.cue__word,
.checkin__cue {
  color: var(--ball);
  font-size: clamp(3.5rem, 17vw, 6.5rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.cue__word {
  overflow-wrap: break-word;
}

/* Long cues (app.js sets data-length) step down so they fit on two lines
   on a 320px phone. Same weight, tracking and colour as the hero. */
.cue__word[data-length="long"] {
  font-size: clamp(2.25rem, 11vw, 4rem);
  line-height: 1;
}

/* Words never break mid-letter; lines wrap between words. */
.flap-word {
  display: inline-block;
  white-space: nowrap;
}

/* Timing must match FLAP_STAGGER_MS / FLAP_DURATION_MS in app.js. */
.flap {
  display: inline-block;
  transform-origin: 50% 50%;
  animation: flap 420ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

@keyframes flap {
  from { transform: perspective(600px) rotateX(-70deg); opacity: 0; }
  to   { transform: perspective(600px) rotateX(0);      opacity: 1; }
}

/* A soft accent glow once the last letter lands, then it settles. */
.cue.is-revealing .cue__word {
  animation: cue-glow 900ms var(--ease) both;
  animation-delay: var(--flip-total, 0ms);
}

@keyframes cue-glow {
  0%   { text-shadow: 0 0 0 rgba(215, 242, 5, 0); }
  35%  { text-shadow: 0 0 28px rgba(215, 242, 5, 0.35); }
  100% { text-shadow: 0 0 16px rgba(215, 242, 5, 0.12); }
}

/* ---- Result: focus (small label + one line) ----------------------------- */
.focus {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-6);
}

.focus__text {
  font-size: 1.0625rem;
  color: var(--text);
  text-wrap: pretty;
}

#result .court-line {
  margin-top: var(--space-6);
}

/* ---- Result: drill (plain text) ----------------------------------------- */
.drill {
  margin-top: var(--space-6);
}

.drill__name {
  margin-top: var(--space-1);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

/* Segmented control: "With a mate | Solo", and the weekly goal's 1 2 3 4+.
   A neutral thumb (not the accent) so the cue and the main button stay the
   only accent elements on screen. --count is the number of options and
   --index the selected one (0-based); the thumb slides to it. */
.segmented {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--count, 2), 1fr);
  margin-top: var(--space-4);
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
}

.segmented::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--count, 2));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: var(--highlight);
  transform: translateX(calc(var(--index, 0) * 100%));
  transition: transform 250ms var(--ease);
}

.segmented[data-mode="solo"] {
  --index: 1;
}

.segmented__option {
  position: relative;  /* above the thumb */
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 200ms var(--ease);
}

.segmented__option[aria-selected="true"],
.segmented__option[aria-checked="true"] {
  color: var(--text);
}

.drill__text {
  min-height: 3em;  /* stops the button below jumping between versions */
  margin-top: var(--space-3);
  color: var(--text-2);
  text-wrap: pretty;
}

/* ---- Result: commit (Lock it in → confirmation) ------------------------- */
/* Pinned to the bottom of the screen in the thumb zone, so the main button
   is always in reach; the content scrolls up behind it. It sits where .app's
   bottom padding ends, so it doesn't move when scrolling reaches the end. */
.result__actions {
  position: sticky;
  bottom: calc(var(--space-4) + var(--badge-clearance) + env(safe-area-inset-bottom));
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  margin-top: auto;
  padding-top: var(--space-5);
}

/* The backdrop: text scrolling up fades out over the top padding, and solid
   background covers the strip below, down to the screen's edge. */
.result__actions::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  right: calc(-1 * var(--page-x));
  bottom: calc(-1 * (var(--space-4) + var(--badge-clearance) + env(safe-area-inset-bottom)));
  left: calc(-1 * var(--page-x));
  background: linear-gradient(to bottom, rgba(10, 10, 11, 0), var(--bg) var(--space-5));
}

.result__actions .link-button {
  align-self: center;
}

/* app.js sets data-state: the pill and the confirmation take turns. */
.result__actions[data-state="browsing"] .locked,
.result__actions[data-state="locked"] #lock-in {
  display: none;
}

/* Same height as the pill it replaces, so nothing below jumps. */
.locked {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: center;
  animation: locked-in 300ms var(--ease) both;
}

.locked__icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ball);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes locked-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* Opacity-only version for reduced motion. */
@keyframes locked-in-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Check-in: did the last cue work? ----------------------------------- */
/* Same skeleton as the result screen: eyebrow, unboxed cue hero, then the
   answers pinned to the bottom of the screen, where a thumb rests. */
.checkin__title {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-3);
  font-size: inherit;  /* each line sets its own size */
}

/* The whole phrase stays on one line. app.js (fitCheckinCue) shrinks the
   font only when a long cue would overflow; short cues keep the hero size.
   The soft glow is the result screen's settled glow, without the reveal. */
.checkin__cue {
  white-space: nowrap;
  text-shadow: 0 0 16px rgba(215, 242, 5, 0.12);
}

.checkin__question {
  margin-top: var(--space-4);
  font-size: clamp(1.75rem, 8vw, 2.25rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.checkin__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  margin-top: auto;            /* pushes the answers to the bottom */
  padding-top: var(--space-6);
}

.checkin__answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.checkin__actions .link-button {
  align-self: center;
}

/* ---- Why it didn't work: four picker-style tiles in the thumb zone ------ */
.why__lead {
  margin-top: var(--space-2);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text-2);
  text-wrap: balance;
}

/* Same height behaviour as the picker tiles (116px to 200px each), but
   measured from this screen's own space: the grid grows into whatever
   height is free, so there's no blank band above it. Once the tiles hit
   their cap on a tall phone, the leftover goes above the eyebrow (as the
   picker puts its leftover above the hero). */
#why .eyebrow {
  margin-top: auto;
}

.why__reasons {
  flex: 1 1 auto;
  grid-template-rows: 1fr 1fr;
  min-height: calc(2 * 116px + var(--space-2));
  max-height: calc(2 * 200px + var(--space-2));
  margin-top: var(--space-6);
}

.why__tile {
  min-height: 0;               /* the grid rows set the height */
}

.why__skip {
  align-self: center;
  margin-top: var(--space-1);
}

/* ---- Weekly goal: offer and change ------------------------------------- */
/* Same skeleton as the check-in: heading, the choice, then the actions
   pinned to the bottom in the thumb zone. */
.goal__options {
  --count: 4;
  margin-top: var(--space-6);
}

/* "2 sessions a week", or the note when a lower goal waits for Monday. */
.goal__hint {
  min-height: 1.5em;
  margin-top: var(--space-2);
  font-size: 0.9375rem;
  color: var(--text-2);
  text-align: center;
  text-wrap: balance;
}

.goal__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
  margin-top: auto;            /* pushes the actions to the bottom */
  padding-top: var(--space-6);
}

.goal__actions .link-button {
  align-self: center;
}

/* Change mode's way out, top left. Pulled into the page margin so the
   arrow (not its 44px tap area) lines up with the text below. */
.goal__back {
  align-self: flex-start;
  margin: -10px 0 var(--space-1) -12px;
}

/* ---- Icon button: a 44px tap target around a small line icon ------------ */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 200ms var(--ease);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .icon-button:hover {
    color: var(--text);
  }
}

.icon-button:active,
.icon-button.is-pressed {
  color: var(--text);
}

/* ---- Picker: greeting row with the weekly goal on the right ------------- */
.picker__top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.picker__top .greeting {
  flex: 1;
  min-width: 0;
}

/* A 44px tap target that doesn't make the row taller: the negative block
   margins give back what the target adds above the greeting's line. The
   right margin lines the text up with the page edge. */
.goal-button {
  flex: none;
  margin-left: auto;
  margin-block: calc((1.0625rem * 1.5 - 44px) / 2);
  margin-right: -12px;
}

.goal-button.has-goal {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

/* One slot per session. Empty: a greyed hairline ball. Filled: the accent.
   18px sits inside the greeting's line, so the row doesn't grow. */
.goal-slot {
  position: relative;
  flex: none;
  width: 18px;
  height: 18px;
}

.goal-ball {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1.25;
  stroke-linecap: round;
}

.goal-ball path {
  stroke-width: 1;
}

.goal-ball.is-filled circle {
  fill: var(--ball);
  stroke: var(--ball);
}

.goal-ball.is-filled path {
  stroke: rgba(10, 10, 11, 0.45);
}

/* ---- Goal reveal: a ball curves into its slot ---------------------------- */
/* The slot keeps its empty ball; a filled ball (.goal-flyer) flies in over
   it. The flyer moves on X with the app's ease-out while the ball inside
   moves on Y on a gentler curve, so together they trace an arc in from the
   lower left. A soft streak trails it, it settles with a 2px dip (no
   overshoot), then a short accent glow. Starts 200ms into the picker's
   fade-in and lands well under a second. Matches the cue reveal's easing. */
.goal-flyer {
  position: absolute;
  inset: 0;
  animation: ball-x 600ms var(--ease) 200ms both;
}

.goal-flyer .goal-ball {
  animation:
    ball-y 750ms cubic-bezier(0.3, 0, 0.2, 1) 200ms both,
    ball-glow 700ms var(--ease) 900ms both;
}

/* The streak: a short fading line behind the ball. */
.goal-flyer::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 50%;
  width: 32px;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: linear-gradient(90deg, rgba(215, 242, 5, 0), rgba(215, 242, 5, 0.45));
  transform-origin: right center;
  animation: ball-streak 650ms var(--ease) 200ms both;
}

@keyframes ball-x {
  from { transform: translateX(-56px); }
  to   { transform: none; }
}

@keyframes ball-y {
  0%   { transform: translateY(26px); opacity: 0; }
  20%  { opacity: 1; }
  78%  { transform: translateY(0); }
  89%  { transform: translateY(2px); }
  100% { transform: none; opacity: 1; }
}

@keyframes ball-streak {
  0%   { opacity: 0; transform: scaleX(0.4); }
  25%  { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(0); }
}

@keyframes ball-glow {
  0%   { filter: drop-shadow(0 0 0 rgba(215, 242, 5, 0)); }
  35%  { filter: drop-shadow(0 0 6px rgba(215, 242, 5, 0.55)); }
  100% { filter: drop-shadow(0 0 0 rgba(215, 242, 5, 0)); }
}

/* Goal complete: once the last ball has landed, one soft light sweeps
   across all the balls, left to right. */
.goal-button.is-complete .goal-slot {
  animation: ball-sweep 600ms var(--ease) both;
  animation-delay: calc(1000ms + var(--i, 0) * 90ms);
}

@keyframes ball-sweep {
  0%   { filter: drop-shadow(0 0 0 rgba(215, 242, 5, 0)); }
  40%  { filter: drop-shadow(0 0 7px rgba(215, 242, 5, 0.6)); }
  100% { filter: drop-shadow(0 0 0 rgba(215, 242, 5, 0)); }
}

/* ---- Main button: the only pill shape ----------------------------------- */
.button-main {
  min-height: 56px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--ball);
  color: var(--on-ball);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 200ms var(--ease), filter 200ms var(--ease);
}

@media (hover: hover) {
  .button-main:hover {
    filter: brightness(1.05);
  }
}

.button-main:active,
.button-main.is-pressed {
  transform: scale(0.98);
}

/* Nothing to save yet: neutral, never the accent, and no press effect. */
.button-main:disabled {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text-3);
  cursor: default;
  filter: none;
  transform: none;
}

/* ---- Quiet button: a dark pill for answers that shouldn't be pushed ----- */
.button-quiet {
  min-height: 56px;
  padding: 14px 24px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--highlight);
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease);
}

@media (hover: hover) {
  .button-quiet:hover {
    border-color: rgba(255, 255, 255, 0.28);
  }
}

.button-quiet:active,
.button-quiet.is-pressed {
  border-color: var(--ball);
  transform: scale(0.98);
}

/* ---- Wider screens: centre a phone-width column ------------------------- */
@media (min-width: 600px) {
  .brand,
  .app {
    width: 100%;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
  }

  .brand {
    padding-top: var(--space-5);
  }

  .app {
    padding-top: var(--space-6);
  }
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  /* Screens still cross-fade (no movement), so a tap is still acknowledged. */
  .view {
    animation-name: view-fade;
  }

  .locked {
    animation-name: locked-in-fade;
  }

  .flap,
  .cue.is-revealing .cue__word {
    animation: none;
  }

  /* Goal reveal: the slot simply fills (a fade), with no flight, streak,
     settle, glow or sweep. */
  .goal-flyer {
    animation: view-fade 300ms var(--ease) 200ms both;
  }

  .goal-flyer .goal-ball,
  .goal-button.is-complete .goal-slot {
    animation: none;
  }

  .goal-flyer::before {
    content: none;
  }

  .tile,
  .tile__icon,
  .button-main,
  .button-quiet,
  .field__input,
  .link-button,
  .icon-button,
  .segmented::before,
  .segmented__option {
    transition: none;
  }

  /* The colour flash on a pressed tile stays; only the scale is removed. */
  .tile:active,
  .tile.is-pressed,
  .button-main:active,
  .button-main.is-pressed,
  .button-quiet:active,
  .button-quiet.is-pressed {
    transform: none;
  }
}
