/* Canshove: a corner store drawn as a transit sign system. Flat plates, stripes, one-word
   signs, all on a strict grid. Colours and fonts come from kit.css only. */

:root {
  --edge: 8px;
  --gap: 6px;
  --top-h: 52px;
  --aisle-h: 46px;
  --score-h: 60px;
  --turn-h: 42px;
  --panel-min: 170px;
  --mute-lane: 64px;
  --side-min: 300px;
  --side-max: 430px;
  --plate-r: 6px;
  --rule: 3px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  /* The painted board: the hazard frame box is 343 of the picture's 383px; the grid is 301 of it. */
  --frame-to-grid: 0.8776;
  --chrome-portrait: calc(var(--top-h) + var(--aisle-h) + var(--score-h) + var(--turn-h) + var(--panel-min) + 5 * var(--gap) + 2 * var(--edge));
  --vis: min(
    calc(100dvw - var(--safe-l) - var(--safe-r)),
    calc(100dvh - var(--chrome-portrait) - var(--safe-t) - var(--safe-b)),
    600px
  );
  --cell: calc(var(--vis) * var(--frame-to-grid) / 7);
  --snap: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --stripe-red: repeating-linear-gradient(-45deg, var(--ak-accent) 0 8px, var(--ak-surface) 8px 16px);
  --stripe-ink: repeating-linear-gradient(-45deg, var(--ak-ink) 0 6px, var(--ak-accent-2) 6px 12px);
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center top;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

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

/* ---------- Signs that act as buttons ---------- */

.sign-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 48px;
  padding: 0 16px;
  border: var(--rule) solid var(--ak-ink);
  border-radius: var(--plate-r);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  box-shadow: inset 0 0 0 2px var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.sign-btn svg { width: 22px; height: 22px; flex: none; }
.sign-btn:active { background: var(--ak-btn-active); transform: translateY(2px) scale(0.97, 0.94); }
.sign-btn:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 3px; }
.sign-btn-quiet {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  box-shadow: none;
}
.sign-btn-quiet:active { background: var(--ak-choice-border); }
.sign-btn-big { min-height: 56px; font-size: 19px; padding: 0 22px; }
@media (hover: hover) {
  .sign-btn:hover { background: var(--ak-btn-hover); }
  .sign-btn-quiet:hover { background: var(--ak-surface); }
}

/* ---------- Mute: a small square sign in the top-left corner ---------- */

.mute {
  position: fixed;
  z-index: 30;
  top: max(var(--edge), var(--safe-t));
  left: max(var(--edge), var(--safe-l));
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: none;
}
.mute[hidden] { display: none; }
.mute .icon { width: 26px; height: 26px; }
.mute .icon-off { display: none; }
.mute[aria-pressed="true"] .icon-on { display: none; }
.mute[aria-pressed="true"] .icon-off { display: block; }
@media (hover: hover) { .mute:hover { background: var(--ak-choice-bg); } }

/* ---------- Page grid: upright, the board sits above the controls ---------- */

.play {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--top-h) var(--aisle-h) var(--score-h) var(--turn-h) var(--vis) minmax(var(--panel-min), 1fr);
  grid-template-areas: "top" "aisle" "scores" "turn" "stage" "panel";
  row-gap: var(--gap);
  justify-items: center;
  align-content: center;
  padding: max(var(--edge), var(--safe-t)) var(--safe-r) max(var(--edge), var(--safe-b)) var(--safe-l);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.play[hidden] { display: none; }
.play > .top,
.play > .aisle,
.play > .scores,
.play > .turn,
.play > .panel {
  width: min(calc(100% - 2 * var(--edge)), var(--side-max));
}

.play > :not(.stage):not(.sr-only):not(.burst) { position: relative; z-index: 2; }
.stage { z-index: 1; }

.top { grid-area: top; display: flex; align-items: center; justify-content: center; }
.logo { height: 40px; width: auto; max-width: calc(100% - 2 * 64px); object-fit: contain; }

/* Sideways: the board on one side, the signs and controls on the other. */
@media (orientation: portrait) and (max-height: 760px) {
  :root {
    --top-h: 52px;
    --aisle-h: 38px;
    --score-h: 54px;
    --turn-h: 38px;
    --panel-min: 150px;
  }
}

@media (orientation: landscape) {
  :root {
    --top-h: 52px;
    --aisle-h: 40px;
    --score-h: 54px;
    --panel-min: 120px;
    --vis: min(
      calc(100dvh - 2 * var(--edge) - var(--safe-t) - var(--safe-b)),
      calc(100dvw - var(--mute-lane) - var(--side-min) - 3 * var(--gap) - var(--safe-l) - var(--safe-r)),
      640px
    );
  }
  .play {
    grid-template-columns: var(--vis) minmax(var(--side-min), var(--side-max));
    grid-template-rows: var(--top-h) var(--aisle-h) var(--score-h) var(--turn-h) minmax(var(--panel-min), 1fr);
    grid-template-areas:
      "stage top"
      "stage aisle"
      "stage scores"
      "stage turn"
      "stage panel";
    column-gap: calc(3 * var(--gap));
    justify-content: center;
    align-content: center;
    padding-left: calc(var(--mute-lane) + var(--safe-l));
    padding-right: calc(var(--edge) + var(--safe-r));
  }
  .play > .top,
  .play > .aisle,
  .play > .scores,
  .play > .turn,
  .play > .panel { width: 100%; }
  .play > .stage { align-self: center; }
  .play > .panel { max-height: calc(var(--vis) - var(--top-h) - var(--aisle-h) - var(--score-h) - var(--turn-h) - 4 * var(--gap)); }
  /* Keep the top-right corner free for the ? button. */
  .top { justify-content: flex-start; padding-right: 64px; }
  .logo { max-width: 100%; }
}

/* ---------- AISLE 7 header: a red flip-board sign ---------- */

.aisle {
  grid-area: aisle;
  padding: 4px;
  border-radius: var(--plate-r);
  background: var(--ak-ink);
}
.flaps {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
  height: 100%;
}
.flap {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-weight: 800;
  line-height: 1;
  transform-origin: 50% 50%;
}
.flap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: color-mix(in srgb, var(--ak-btn-active) 70%, transparent);
}
.flaps .flap { font-size: clamp(20px, 7.5vw, 30px); }
@media (orientation: landscape) { .flaps .flap { font-size: clamp(18px, 3.2vw, 28px); } }
.flap.is-blank { background: var(--ak-btn-active); }

/* ---------- Snowbank score signs ---------- */

.scores {
  grid-area: scores;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}
.score {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 5px 8px 5px 12px;
  border-radius: var(--plate-r);
  background: var(--ak-surface);
  background-image: linear-gradient(90deg, var(--band) 0 6px, transparent 6px);
}
.score-you { --band: var(--ak-accent); }
.score-rival { --band: var(--ak-accent-2); }
.score-line {
  margin: 0;
  overflow: hidden;
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.score-line b { color: var(--ak-ink); text-transform: uppercase; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.slots { display: flex; gap: 3px; }
.slot {
  width: 22px;
  height: 22px;
  border: 2px dashed var(--ak-choice-border);
  border-radius: 4px;
}
.slot img { display: block; width: 100%; height: 100%; }
.slot.is-full { border: none; }
.score-num {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-family: var(--ak-font-display);
  font-weight: 800;
}
.flap-digit {
  width: 28px;
  height: 30px;
  font-size: 22px;
}
.of { color: var(--ak-ink); font-size: 16px; }

/* ---------- Turn strip ---------- */

.turn {
  grid-area: turn;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 10px;
  overflow: hidden;
  border-radius: var(--plate-r);
  background: var(--ak-surface);
}
.turn-plate {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 48px;
  flex: none;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}
.turn-plate svg { width: 26px; height: 26px; }
.turn.is-rival .turn-plate { background: var(--ak-choice-bg); color: var(--ak-choice-ink); }
.turn.is-rival .turn-plate svg { transform: scaleX(-1); }
.turn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-transform: uppercase;
}
.turn.is-reason .turn-text {
  font-family: var(--ak-font-body);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}
.turn.is-reason .turn-plate { background: var(--ak-ink); color: var(--ak-surface); }
.turn.is-reason .turn-plate svg { transform: rotate(90deg); }
.clock {
  flex: none;
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.clock b { color: var(--ak-ink); font-size: 14px; }
.turn.is-reason .clock { display: none; }
.dots { display: none; gap: 4px; }
.turn.is-thinking .dots { display: inline-flex; }
.dots i { width: 7px; height: 7px; background: var(--ak-accent-2); border-radius: 1px; }

/* ---------- The shelf ---------- */

.stage {
  grid-area: stage;
  width: var(--vis);
  height: var(--vis);
}
.shelf {
  position: relative;
  width: 100%;
  height: 100%;
}
.shelf-art {
  position: absolute;
  left: calc(-100% * 20 / 343);
  top: calc(-100% * 19 / 343);
  width: calc(100% * 383 / 343);
  height: auto;
  pointer-events: none;
}
.grid,
.layer {
  position: absolute;
  left: calc(100% * 21 / 343);
  top: calc(100% * 21 / 343);
  width: calc(100% * var(--frame-to-grid));
  height: calc(100% * var(--frame-to-grid));
}
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
}
.layer { pointer-events: none; }
.fx { overflow: visible; }

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.cell:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: -3px; z-index: 2; }
.cell.is-target::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ak-accent-2) 28%, transparent);
}
.cell.is-pushable::before {
  content: "";
  position: absolute;
  inset: 1px;
  border: 3px dashed var(--ak-accent);
  border-radius: 4px;
}

/* Cans: placed by row and column, so a move is just a new --r and --c. */
.can {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / 7);
  height: calc(100% / 7);
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  z-index: 1;
}
.can-body {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
}
.can.is-blue .can-body { border-radius: 16%; }
.can-body img { display: block; width: 100%; height: 100%; pointer-events: none; }
.can.is-picked { z-index: 3; }
.can.is-picked .can-body {
  transform: translateY(-6%) scale(1.06);
  box-shadow: 0 0 0 3px var(--ak-surface), 0 0 0 6px var(--ak-ink);
}
.can.is-chosen { z-index: 3; }
.can.is-chosen .can-body {
  transform: translateY(-6%) scale(1.06);
  box-shadow: 0 0 0 3px var(--ak-surface), 0 0 0 6px var(--ak-accent-2);
}
.can.is-boxed .can-body { box-shadow: 0 0 0 3px var(--ak-ink); }
.can.is-gone { z-index: 4; }

/* Arrow signs: where a picked line may slide. */
.mark {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / 7);
  height: calc(100% / 7);
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  z-index: 5;
}
.mark-sign {
  position: absolute;
  inset: 12%;
  rotate: var(--turn, 0deg);
}
.mark-sign img { display: block; width: 100%; height: 100%; }
.mark.is-push { pointer-events: auto; cursor: pointer; }
.mark.is-push .mark-sign { inset: 14%; rotate: 0deg; }
.push-sign { display: block; width: 100%; height: 100%; overflow: visible; }
.push-sign .plate { fill: var(--ak-surface); stroke: var(--ak-ink); stroke-width: 5; stroke-linejoin: round; }
.push-sign .arrow { fill: var(--ak-accent); }
.push-sign text {
  fill: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.puff {
  position: absolute;
  width: calc(100% / 7);
  height: calc(100% / 7);
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
}
.puff i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  height: 26%;
  margin: -13% 0 0 -13%;
  border-radius: 50%;
  background: var(--ak-surface);
  box-shadow: 0 0 0 2px var(--ak-choice-border);
  opacity: 0;
}

/* ---------- Panel: messages, the worked example, the result ---------- */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  overflow-y: auto;
}
.talk { display: flex; flex-direction: column; gap: var(--gap); }

/* First-move guide: two signs, the current one lit. It stays until the first move is made. */
.steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 10px;
  border: var(--rule) solid var(--ak-ink);
  border-radius: var(--plate-r);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}
.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 18px;
}
.step.is-now {
  background: var(--ak-choice-selected-bg);
  border-color: var(--ak-choice-selected-border);
  color: var(--ak-choice-selected-ink);
}
.step.is-done .step-num { background: var(--ak-choice-border); }
.step-arrow { display: grid; place-items: center; color: var(--ak-ink); }
.step-arrow svg { width: 24px; height: 24px; }

/* On the first turn, every can that can move wears a ring that says "tap me". */
.can.is-invite .can-body { box-shadow: 0 0 0 3px var(--ak-surface), 0 0 0 6px var(--ak-accent); }
.say-row { display: flex; align-items: stretch; gap: var(--gap); }
.say {
  flex: 1;
  min-height: 48px;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--plate-r);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
.say b { color: var(--ak-accent); }
.say.is-first { font-size: 18px; font-weight: 700; color: var(--ak-ink); }
.oops {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--plate-r);
  background: var(--ak-surface);
  background-image: linear-gradient(90deg, var(--ak-accent) 0 6px, transparent 6px);
  color: var(--ak-ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.oops[hidden] { display: none; }
.oops svg { width: 24px; height: 24px; flex: none; margin-top: 1px; color: var(--ak-accent); }

.teach {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  border-radius: var(--plate-r);
  background: var(--ak-surface);
  border-top: 8px solid transparent;
  border-image: var(--stripe-red) 8 0 0 0 / 8px 0 0 0;
  color: var(--ak-ink);
}
.teach[hidden] { display: none; }
.teach-steps {
  margin: 0;
  padding-left: 26px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.teach-steps b { color: var(--ak-accent); }
.teach .sign-btn { align-self: stretch; }

/* The result: a sign that hangs down over the shelf. The reason stays in the turn strip above. */
.stage { position: relative; }
.result {
  position: absolute;
  z-index: 8;
  left: 4%;
  right: 4%;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: calc(100% - 12px);
  overflow-y: auto;
  padding: 0 12px 10px;
  border: var(--rule) solid var(--ak-ink);
  border-radius: var(--plate-r);
  background: var(--ak-surface);
  translate: 0 -50%;
  transform-origin: 50% 0;
}
.result-head {
  margin: 0 -12px;
  padding: 8px 12px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
}
.result.is-lose .result-head,
.result.is-draw .result-head {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  border-bottom: var(--rule) solid var(--ak-ink);
}
.tally { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tally-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.tally-cans { display: flex; gap: 2px; flex: none; min-width: 74px; }
.tally-cans img { width: 24px; height: 24px; }
.tally-cans .slot { width: 24px; height: 24px; }
/* The confetti falls behind the result sign, never over its words. */
.play.is-ended .stage { z-index: 25; }
.result-says {
  margin: 0;
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.quip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 6px 10px 6px 6px;
  border-radius: var(--plate-r);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 15px;
  font-style: italic;
  line-height: 1.3;
}
.quip b { font-style: normal; }
.quip-face { width: 36px; height: 36px; flex: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: var(--gap); }
.result-actions .sign-btn { flex: 1 1 120px; min-height: 48px; font-size: 15px; padding: 0 10px; }

/* ---------- Snow ---------- */

.flakes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.flakes i {
  position: absolute;
  top: -12px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--ak-surface);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ak-accent-2) 40%, transparent);
  opacity: 0.9;
  translate: 0 var(--y0, 30vh);
}
.play { z-index: 1; }
.burst { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
.burst i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  background: var(--fill);
  border-radius: var(--rad, 50%);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .can { transition: transform 260ms var(--snap); }
  .can-body { transition: transform 180ms var(--snap), box-shadow 180ms ease-out; }
  .can.is-landing .can-body { animation: land 240ms var(--snap); }
  .can.is-wobbly .can-body { animation: wobble 460ms ease-out; }
  .can.is-gone { transition: transform 240ms ease-in; }
  .can.is-gone .can-body { animation: tip 560ms 200ms ease-in forwards; }
  .can.is-hop .can-body { animation: hop 520ms var(--snap) var(--d, 0ms) 3; }
  .can.is-nudge .can-body { animation: wobble 420ms ease-out; }
  .can.is-boxed .can-body { animation: boxed 900ms ease-in-out infinite; }
  .can.is-invite .can-body { animation: invite 1600ms ease-in-out infinite; }

  .mark .mark-sign { animation: sign-in 300ms var(--snap) both; animation-delay: var(--d, 0ms); }
  .mark.is-pulse .mark-sign { animation: sign-in 300ms var(--snap) both, sign-pulse 1100ms ease-in-out 300ms infinite; }
  .cell:active .tap { transform: scale(0.9); }
  .cell.is-tapped::after {
    content: "";
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    border: 3px solid var(--ak-accent-2);
    animation: ring 360ms ease-out forwards;
  }

  .puff i { animation: puff 620ms var(--ease-out) forwards; }
  .flap.is-flipping { animation: flap-out 110ms ease-in forwards; }
  .flap.is-flipped { animation: flap-in 170ms var(--snap); }
  .turn.is-cue { animation: turn-cue 360ms var(--snap); }
  .turn.is-cue .turn-plate svg { animation: arrow-slide 360ms var(--snap); }
  .turn.is-thinking .dots i { animation: dot 900ms ease-in-out infinite; }
  .turn.is-thinking .dots i:nth-child(2) { animation-delay: 150ms; }
  .turn.is-thinking .dots i:nth-child(3) { animation-delay: 300ms; }
  .say.is-nudge { animation: nudge 300ms ease-out; }
  .step.is-now { animation: step-glow 1200ms ease-in-out infinite; }
  .step.is-now .step-num { animation: invite 1200ms ease-in-out infinite; }
  .oops.is-new { animation: slide-in 260ms var(--snap); }
  .teach:not([hidden]) { animation: slide-in 320ms var(--snap); }
  .result:not([hidden]) { animation: sign-drop 520ms var(--snap) both; }
  .quip-face { animation: hop 520ms var(--snap) 600ms 2; }
  .flakes i { animation: fall var(--t) linear var(--delay) infinite; }
  .burst i { animation: burst var(--t) var(--ease-out) var(--delay, 0ms) forwards; }
  .score.is-hit { animation: turn-cue 360ms var(--snap); }
  .slot.is-new img { animation: drop-in 420ms var(--snap); }
  .logo { animation: sway 5s ease-in-out infinite; }
}

@keyframes land { 0% { transform: scale(1.12, 0.86); } 60% { transform: scale(0.95, 1.06); } 100% { transform: none; } }
@keyframes wobble {
  0% { transform: scale(1.1, 0.9); }
  25% { transform: rotate(-9deg); }
  50% { transform: rotate(7deg); }
  75% { transform: rotate(-3deg); }
  100% { transform: none; }
}
@keyframes tip {
  0% { transform: rotate(0) scale(1); opacity: 1; }
  45% { transform: rotate(var(--tip, 70deg)) scale(0.9); opacity: 1; }
  100% { transform: rotate(var(--tip, 70deg)) translate(0, 40%) scale(0.2); opacity: 0; }
}
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-22%) scale(0.96, 1.06); } 70% { transform: scale(1.08, 0.92); } }
@keyframes boxed { 0%, 100% { transform: none; } 50% { transform: scale(0.92); } }
@keyframes invite { 0%, 100% { transform: none; } 50% { transform: translateY(-5%) scale(1.04); } }
@keyframes sign-in {
  0% { opacity: 0; translate: var(--from-x, 0) var(--from-y, 0); scale: 0.7; }
  70% { opacity: 1; scale: 1.08; }
  100% { opacity: 1; translate: 0 0; scale: 1; }
}
@keyframes step-glow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ak-accent) 45%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ak-accent) 0%, transparent); }
}
@keyframes sign-drop {
  0% { transform: scaleY(0); }
  55% { transform: scaleY(1.06); }
  75% { transform: scaleY(0.97); }
  100% { transform: scaleY(1); }
}
@keyframes sign-pulse { 0%, 100% { scale: 1; } 50% { scale: 1.1; } }
@keyframes ring { from { transform: scale(0.5); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@keyframes puff {
  0% { opacity: 1; transform: translate(0, 0) scale(0.4); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(1.4); }
}
@keyframes flap-out { to { transform: scaleY(0); } }
@keyframes flap-in { 0% { transform: scaleY(0); } 70% { transform: scaleY(1.12); } 100% { transform: scaleY(1); } }
@keyframes turn-cue { 0% { transform: scale(0.96, 1.08); } 60% { transform: scale(1.02, 0.97); } 100% { transform: none; } }
@keyframes arrow-slide { 0% { translate: -18px 0; opacity: 0; } 100% { translate: 0 0; opacity: 1; } }
@keyframes dot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes nudge { 0%, 100% { translate: 0 0; } 30% { translate: -6px 0; } 65% { translate: 4px 0; } }
@keyframes slide-in { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
@keyframes fall {
  from { transform: translate(0, -5vh); }
  50% { transform: translate(var(--sway), 50vh); }
  to { transform: translate(0, 105vh); }
}
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0) scale(0.4); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}
@keyframes drop-in { 0% { transform: translateY(-120%) scale(0.6); } 70% { transform: translateY(8%) scale(1.1, 0.9); } 100% { transform: none; } }
@keyframes sway { 0%, 100% { rotate: -1.5deg; } 50% { rotate: 1.5deg; } }

/* ---------- Start screen (built by start.js): the logo leads, every word in full ink ----------
   Two ids outrank start.js's own rules. Nothing on it starts see-through, so it reads at once. */

#activity-start#activity-start,
#activity-start#activity-start .ak-sheet,
#activity-start#activity-start .ak-section,
#activity-start#activity-start .ak-logo,
#activity-start#activity-start .ak-title { animation: none; opacity: 1; }
#activity-start#activity-start .ak-sheet {
  border-top: 10px solid transparent;
  border-image: var(--stripe-red) 10 0 0 0 / 10px 0 0 0;
}
#activity-start#activity-start .ak-head { text-align: center; }
#activity-start#activity-start .ak-logo {
  margin: 0 auto;
  max-width: min(440px, 100%);
  max-height: 120px;
}
#activity-start#activity-start.is-setup .ak-logo { max-height: 84px; }
#activity-start#activity-start .ak-tagline {
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
}
#activity-start#activity-start .ak-label,
#activity-start#activity-start .ak-legend {
  color: var(--ak-accent);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
#activity-start#activity-start .ak-body,
#activity-start#activity-start .ak-controls li,
#activity-start#activity-start .ak-first {
  color: var(--ak-ink);
  font-weight: 700;
}
#activity-start#activity-start .ak-how { color: var(--ak-ink); font-weight: 800; }

@media (orientation: landscape) and (max-height: 500px) {
  #activity-start#activity-start .ak-logo { max-height: 52px; }
  #activity-start#activity-start .ak-tagline { margin-top: 4px; font-size: 13px; }
  #activity-start#activity-start .ak-head { padding-bottom: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  #activity-start#activity-start.is-instructions .ak-sheet { animation: start-drop 420ms var(--snap) both; transform-origin: 50% 0; }
  #activity-start#activity-start .ak-logo { animation: sway 5s ease-in-out infinite; }
}
@keyframes start-drop {
  0% { transform: translateY(-16px) scaleY(0.92); }
  100% { transform: none; }
}
