/* Weekbench: a playfield on a coarse pixel grid. Square corners, hard edges, whole-step motion. */

:root {
  --cell: 8px;
  --edge: 4px;
  --steel: color-mix(in srgb, var(--ak-ink) 30%, var(--ak-surface));
  --grid-line: color-mix(in srgb, var(--ak-accent) 9%, transparent);
  --safe-t: max(var(--cell), env(safe-area-inset-top));
  --safe-r: max(var(--cell), env(safe-area-inset-right));
  --safe-b: max(var(--cell), env(safe-area-inset-bottom));
  --safe-l: max(var(--cell), env(safe-area-inset-left));
  --lamp: 44px;
  --lamp-gap: var(--cell);
  --slip-w: 56px;
  --plate-px: clamp(14px, calc(1.1dvh + 1dvw + 2px), 17px);
}

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

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

body {
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-weight: 600;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

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

/* ---------- the table ---------- */

.table {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "glass"
    "decision"
    "board"
    "panel";
  gap: var(--cell);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* The visible coarse grid everything snaps to. Hard 1px lines, no blur. */
.table::before,
.result::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: calc(var(--cell) * 2) calc(var(--cell) * 2);
}

.table > * {
  position: relative;
}

/* ---------- top: backglass strip with the logo; mute top left, help sits top right ---------- */

.mute {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 30;
  width: 48px;
  height: 48px;
  padding: 10px;
  border: var(--edge) solid var(--ak-accent);
  border-radius: 0;
  background: var(--ak-bg);
  color: var(--ak-ink);
  cursor: pointer;
}

.mute svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.mute .mute-off,
.mute.is-muted .mute-on {
  display: none;
}

.mute.is-muted .mute-off {
  display: inline;
}

.mute.is-muted {
  color: var(--ak-accent-2);
}

.mute:focus-visible {
  outline: var(--edge) solid var(--ak-ink);
  outline-offset: 2px;
}

.glass {
  grid-area: glass;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 64px;
  background: var(--ak-bg);
  border-bottom: var(--edge) solid var(--ak-accent);
}

.logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

/* ---------- the decision ---------- */

.decision {
  grid-area: decision;
  padding: var(--cell) calc(var(--cell) * 1.5);
  background: var(--ak-surface);
  border-left: var(--cell) solid var(--ak-accent);
}

.kicker {
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 15px;
  line-height: 1.25;
}

.ask {
  margin: 2px 0 0;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(18px, calc(1.2dvh + 1.6dvw + 4px), 24px);
  line-height: 1.15;
  color: var(--ak-ink);
}

/* ---------- the board: lamps rail | bumpers | memo rail ---------- */

.board {
  grid-area: board;
  display: grid;
  grid-template-columns: var(--lamp) minmax(0, 1fr) var(--slip-w);
  grid-template-areas: "lamps field memo";
  gap: var(--cell);
  min-height: 0;
  padding: var(--cell);
  border: var(--edge) solid var(--ak-accent);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--cell);
  min-height: 0;
}

.rail-lamps {
  grid-area: lamps;
}

.rail-memo {
  grid-area: memo;
}

.cap {
  display: block;
  width: 100%;
  padding: 2px 0;
  background: var(--ak-bg);
  color: var(--ak-ink-muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lamps,
.memo {
  position: relative;
  display: grid;
  gap: var(--lamp-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lamp {
  width: var(--lamp);
  height: var(--lamp);
  background-color: var(--ak-bg);
  border: var(--edge) solid var(--steel);
}

/* round-lamp.png holds three lamps side by side: gold diamond, amber triangle, red cross. */
.lamp.is-strong,
.lamp.is-weak {
  border: 0;
  background-image: url("./art/round-lamp.png");
  background-repeat: no-repeat;
  background-size: 369.23% 190.38%;
  background-position-y: 23.4%;
}

.lamp.is-strong {
  background-position-x: 7.86%;
}

.lamp.is-weak {
  background-position-x: 91.79%;
}

.ball {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--lamp);
  height: var(--lamp);
  padding: 4px;
  transform: translateY(calc(var(--row, 0) * (var(--lamp) + var(--lamp-gap))));
  pointer-events: none;
}

.ball.is-drained {
  display: none;
}

.slot {
  width: var(--slip-w);
  height: calc(var(--slip-w) * 0.76);
  border: 2px dashed var(--steel);
}

.slot.is-filled {
  border: 0;
  background: url("./art/memo-slip.png") center / 100% 100% no-repeat;
}

/* ---------- cards: a bumper set into a dark plate ---------- */

.field {
  grid-area: field;
  /* game.js sets --plate-px here: as large as the board allows. Everything on a card scales from it. */
  --bumper: clamp(44px, calc(var(--plate-px) * 3.4), 88px);
  display: flex;
  flex-direction: column;
  gap: var(--cell);
  min-width: 0;
  min-height: 0;
}

/* Cards share the board's height equally, so the evidence fills the table. */
/* No fixed min-height: a card never shrinks below its words, so the fit in game.js can see overflow. */
.card {
  display: flex;
  flex: 1 1 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

div.card {
  cursor: default;
}

.plate {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  padding: calc(var(--plate-px) * 0.6) calc(var(--plate-px) * 0.75);
  background: var(--ak-surface);
  border: var(--edge) solid var(--steel);
  color: var(--ak-ink);
  font-size: var(--plate-px);
  line-height: 1.2;
}

.plate-body {
  display: flow-root;
  width: 100%;
}

/* The bumper sits in the plate's corner and the words wrap under it. */
.bumper {
  float: left;
  display: grid;
  place-items: center;
  width: var(--bumper);
  height: var(--bumper);
  margin: -2px calc(var(--plate-px) * 0.6) 2px -2px;
  padding: 2px;
}

.bumper img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Key and tag ride the first line of the text, so a plate costs no extra row. */
.plate-top {
  display: inline;
}

.plate-top > * {
  margin-right: 0.4em;
  vertical-align: 0.1em;
}

.text {
  display: inline;
}

.key {
  display: inline-grid;
  place-items: center;
  min-width: max(20px, 1.2em);
  height: max(20px, 1.2em);
  padding: 0 4px;
  background: var(--ak-bg);
  border: 2px solid var(--steel);
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-display);
  font-size: max(11px, 0.6em);
  line-height: 1;
}

.side-name {
  font-family: var(--ak-font-display);
  font-size: 1.35em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--ak-accent);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.1em 0.5em;
  font-family: var(--ak-font-display);
  font-size: max(11px, 0.62em);
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tag .mark {
  width: 0.9em;
  height: 0.9em;
}

.tag.is-strong {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
}

.tag.is-weak {
  background: var(--ak-bg);
  border: 2px solid var(--ak-accent-2);
  color: var(--ak-ink);
}

.tag.is-weak .mark {
  fill: var(--ak-accent-2);
}

.mark {
  flex: none;
  fill: currentColor;
}

.card:focus-visible {
  outline: var(--edge) solid var(--ak-focus);
  outline-offset: 2px;
}

button.card:active .plate {
  border-color: var(--ak-accent);
}

@media (hover: hover) {
  button.card:not([aria-disabled]):hover .plate {
    border-color: var(--ak-accent);
  }
}

.card.is-picked .plate {
  border-color: var(--ak-accent);
}

.card.is-picked .bumper {
  background: var(--ak-accent);
}

.is-settled .card:not(.is-picked) .bumper,
.is-example .card:not(.is-picked) .bumper {
  filter: grayscale(1) brightness(0.55);
}

.is-settled .card:not(.is-picked) .plate {
  color: var(--ak-ink-muted);
}

.is-settled button.card {
  cursor: default;
}

/* The bumpers go dark when the memo is filed. */
.is-dark .bumper {
  background: none !important;
  filter: grayscale(1) brightness(0.3);
}

.is-dark .plate {
  color: var(--ak-ink-muted);
  border-color: var(--steel);
}

/* The two sides get the same room. */
.field.is-sides {
  gap: calc(var(--cell) * 2);
}

.is-sides .bumper {
  width: calc(var(--bumper) * 1.25);
  height: calc(var(--bumper) * 1.25);
}

.is-sides .plate {
  border-color: var(--ak-accent);
  padding: calc(var(--cell) * 1.5) 12px;
}

.is-sides .plate-top {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.is-sides .text {
  display: block;
}

/* ---------- the status panel ---------- */

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--cell);
  min-height: 136px;
  padding: calc(var(--cell) * 1.5);
  overflow-y: auto;
  background: var(--ak-surface);
  border: var(--edge) solid var(--steel);
}

.panel p {
  margin: 0;
}

.lead,
.verdict {
  display: flex;
  align-items: center;
  gap: var(--cell);
  font-size: 19px;
  line-height: 1.25;
  color: var(--ak-ink);
}

.teach {
  font-size: 18px;
  line-height: 1.3;
  color: var(--ak-ink);
}

.sub,
.note {
  font-size: 17px;
  line-height: 1.3;
  color: var(--ak-ink-muted);
}

.note {
  color: var(--ak-ink);
}

.verdict {
  font-family: var(--ak-font-display);
  font-size: 18px;
  text-transform: uppercase;
}

.verdict .mark {
  width: 21px;
  height: 21px;
}

.verdict.is-strong .mark {
  fill: var(--ak-accent);
}

.verdict.is-weak .mark {
  fill: var(--ak-accent-2);
}

.pointer {
  width: 21px;
  height: 21px;
  fill: var(--ak-accent);
}

.count {
  font-size: 15px;
  line-height: 1.3;
  color: var(--ak-ink-muted);
}

.count.is-last {
  font-size: 17px;
  color: var(--ak-ink);
}

.panel.is-example {
  border-color: var(--ak-accent);
}

/* ---------- buttons: square, hard 4px step ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 calc(var(--cell) * 3);
  margin-bottom: var(--edge);
  border: 0;
  border-radius: 0;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  box-shadow: 0 var(--edge) 0 var(--ak-btn-active);
  font-family: var(--ak-font-display);
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:active {
  transform: translateY(var(--edge));
  box-shadow: none;
  background: var(--ak-btn-active);
}

.btn:focus-visible {
  outline: var(--edge) solid var(--ak-ink);
  outline-offset: 2px;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--ak-btn-hover);
  }
}

.btn-big {
  min-height: 56px;
  font-size: 22px;
}

.btn-quiet {
  background: var(--ak-bg);
  color: var(--ak-ink);
  box-shadow: inset 0 0 0 var(--edge) var(--ak-ink);
}

.btn-quiet:active {
  background: var(--ak-surface);
  box-shadow: inset 0 0 0 var(--edge) var(--ak-ink);
}

@media (hover: hover) {
  .btn-quiet:hover {
    background: var(--ak-surface);
  }
}

.panel .btn {
  align-self: flex-start;
}

/* ---------- upright: both rails share the left edge, the cards get the width ---------- */

@media (orientation: portrait) {
  :root {
    --lamp-gap: 6px;
  }

  .board {
    grid-template-columns: var(--lamp) minmax(0, 1fr);
    grid-template-areas: "lamps field";
    column-gap: 10px;
  }

  .rail-lamps .cap,
  .rail-memo {
    display: none;
  }

  .decision {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--lamp);
    align-items: center;
    gap: 12px;
  }

  /* The memo is a stack: each slip lands one small step below the last. */
  .memo-top {
    display: block;
    width: var(--lamp);
    height: calc(var(--lamp) * 0.76 + 4 * 4px);
    outline: 2px dashed var(--steel);
  }

  .memo-top .slot {
    position: absolute;
    left: 0;
    top: calc(var(--i, 0) * 4px);
    width: var(--lamp);
    height: calc(var(--lamp) * 0.76);
    border: 0;
  }

  .memo-top .slot:not(.is-filled) {
    visibility: hidden;
  }
}

@media (orientation: landscape) {
  .memo-top {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 380px) {
  .board {
    padding: 6px;
    column-gap: 8px;
  }

  .field {
    gap: 6px;
  }

  .plate {
    padding: 6px 8px;
  }
}

@media (orientation: portrait) and (max-height: 760px) {
  .panel {
    min-height: 120px;
    padding: var(--cell) 12px;
  }

  .glass {
    min-height: 52px;
  }

  .kicker {
    font-size: 14px;
  }

  .decision {
    padding: 6px 12px;
  }
}

/* ---------- sideways: board on one side, words and controls on the other ---------- */

@media (orientation: landscape) {
  :root {
    --plate-px: clamp(14px, calc(1.4dvh + 0.5dvw + 2px), 17px);
  }

  .table {
    grid-template-columns: minmax(0, 1fr) clamp(240px, 32vw, 380px);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "board glass"
      "board decision"
      "board panel";
  }

  .glass {
    padding: 0 60px 0 var(--cell);
    justify-content: flex-start;
  }

  /* The mute sits above the rail caps, top left. */
  .rail .cap {
    margin-top: 52px;
  }

  .panel {
    min-height: 0;
    justify-content: flex-start;
  }

  .ask {
    font-size: clamp(18px, calc(1.6dvh + 1dvw), 24px);
  }

  .pointer {
    transform: rotate(-90deg);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --lamp-gap: 4px;
  }

  .glass {
    min-height: 48px;
  }

  .logo {
    height: 30px;
  }

  .kicker {
    font-size: 14px;
  }

  .lead,
  .verdict {
    font-size: 18px;
  }

  .sub,
  .note {
    font-size: 16px;
  }

  .rail .cap {
    margin-top: 48px;
  }

  .memo {
    gap: 4px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .count {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 380px) {
  .panel {
    gap: 6px;
    padding: var(--cell) 12px;
  }

  .verdict {
    font-size: 16px;
  }

  .note {
    font-size: 15px;
  }

  .btn {
    min-height: 48px;
  }
}

/* Desktop centers the same layout, a little larger. */
@media (min-width: 1000px) and (min-height: 600px) {
  :root {
    --plate-px: 19px;
  }

  .table {
    padding:
      max(var(--safe-t), calc((100dvh - 700px) / 2))
      max(var(--safe-r), calc((100vw - 1120px) / 2));
  }

  .panel {
    align-self: start;
  }

  .field {
    gap: 12px;
  }
}

/* ---------- the ending ---------- */

.result {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: calc(var(--cell) * 2);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-y: auto;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center;
}

.result > * {
  position: relative;
}

.result-top {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 56px;
  padding: 0 64px;
  background: var(--ak-bg);
  border-bottom: var(--edge) solid var(--ak-accent);
}

.result-main,
.result-side {
  display: flex;
  flex-direction: column;
  gap: calc(var(--cell) * 1.5);
  width: min(100%, 640px);
  justify-self: center;
}

.result-main {
  padding: calc(var(--cell) * 2);
  background: var(--ak-bg);
  border: var(--edge) solid var(--ak-accent);
}

.result p {
  margin: 0;
}

.reason {
  font-size: 16px;
  line-height: 1.3;
  color: var(--ak-ink-muted);
}

.headline {
  margin: 0;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(36px, min(11dvw, 9dvh), 72px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--ak-accent);
  text-shadow: var(--edge) var(--edge) 0 var(--ak-accent-2);
}

.word {
  display: inline-block;
  white-space: nowrap;
}

.ch {
  display: inline-block;
}

.coin {
  font-family: var(--ak-font-display);
  font-size: 16px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ak-ink);
}

.result-label {
  margin: 0 0 -6px;
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ak-ink-muted);
}

.result-side .result-label {
  padding: 4px var(--cell);
  margin: 0;
  justify-self: start;
  align-self: flex-start;
  background: var(--ak-bg);
}

.says {
  font-size: 18px;
  line-height: 1.35;
  color: var(--ak-ink);
}

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

.tally li {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: var(--cell);
  padding: 4px;
  background: var(--ak-surface);
  border-left: var(--edge) solid var(--steel);
}

.tally li.is-strong {
  border-left-color: var(--ak-accent);
}

.tally li.is-weak {
  border-left-color: var(--ak-accent-2);
}

.tally .lamp {
  width: 40px;
  height: 40px;
}

.tally-words {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tally-head {
  display: flex;
  gap: var(--cell);
  font-size: 13px;
  line-height: 1.2;
  color: var(--ak-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tally-flaw {
  margin-left: auto;
}

.tally-line {
  font-size: 16px;
  line-height: 1.2;
  color: var(--ak-ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--cell) * 1.5);
}

.actions .btn {
  flex: 1 1 140px;
}

@media (orientation: portrait) and (max-height: 700px) {
  :root {
    --lamp-gap: 4px;
  }

  .field {
    gap: 4px;
  }

  .result {
    gap: 6px;
  }

  .result .says {
    font-size: 15px;
  }

  .tally-line {
    font-size: 14px;
  }

  .headline {
    font-size: 36px;
  }

  .result .coin {
    font-size: 14px;
  }
}

@media (orientation: portrait) and (max-height: 760px) {
  .result {
    gap: var(--cell);
  }

  .result-top {
    min-height: 52px;
  }

  .result-main {
    padding: 12px;
    gap: var(--cell);
  }

  .reason {
    font-size: 15px;
  }

  .says {
    font-size: 16px;
    line-height: 1.3;
  }

  .tally .lamp {
    width: 32px;
    height: 32px;
  }

  .tally li {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 2px 4px;
  }

  .tally-line {
    font-size: 15px;
  }
}

@media (orientation: landscape) {
  .result {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: calc(var(--cell) * 2);
  }

  .result-top {
    grid-column: 1 / -1;
  }

  .result-main,
  .result-side {
    width: 100%;
    max-width: 560px;
    align-self: start;
  }

  .result-main {
    justify-self: end;
  }

  .result-side {
    justify-self: start;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .result-top {
    min-height: 48px;
  }

  .result-main {
    padding: var(--cell) 12px;
    gap: var(--cell);
  }

  .says {
    font-size: 16px;
  }

  .tally .lamp {
    width: 36px;
    height: 36px;
  }

  .tally li {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 2px 4px;
  }

  .tally-line {
    font-size: 15px;
  }
}

/* The smallest screens keep the result whole on one screen; the lamps and lines speak for themselves. */
@media (orientation: portrait) and (max-height: 660px), (orientation: landscape) and (max-height: 380px) {
  .result-label {
    display: none;
  }
}

/* ---------- motion: whole steps only ---------- */

@media (prefers-reduced-motion: no-preference) {
  .ball {
    transition: transform 480ms steps(4, end);
  }

  /* First move: the two sides blink their frames in hard steps. */
  .is-invite .plate {
    animation: invite 1200ms steps(1, end) infinite;
  }

  .pointer {
    animation: nudge 800ms steps(1, end) infinite;
  }

  /* The tapped bumper flashes gold in two hard steps. */
  .card.is-flash .bumper {
    animation: flash 400ms steps(1, end) 1;
  }

  .lamp.is-new {
    animation: snap 360ms steps(1, end) 1;
  }

  /* The slip clicks into the stack one grid cell at a time. */
  .slot.is-new {
    animation: slip 360ms steps(3, end) 1;
  }

  .is-settled .tag {
    animation: snap 240ms steps(1, end) 1;
  }

  .is-dark .bumper {
    animation: lights-out 450ms steps(3, end) 1 both;
  }

  /* The result arrives letter by letter. */
  .result .ch {
    animation: appear 1ms steps(1, end) both;
    animation-delay: calc(var(--i) * 70ms);
  }

  .result .coin {
    animation: blink 1000ms steps(1, end) infinite;
  }

  .result .says,
  .result .result-side {
    animation: appear 1ms steps(1, end) 800ms both;
  }
}

@media (orientation: landscape) and (prefers-reduced-motion: no-preference) {
  .pointer {
    animation-name: nudge-side;
  }
}

@keyframes invite {
  0% { border-color: var(--ak-accent); }
  50% { border-color: var(--steel); }
}

@keyframes nudge {
  0% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes nudge-side {
  0% { transform: rotate(-90deg) translateY(0); }
  50% { transform: rotate(-90deg) translateY(-4px); }
}

@keyframes flash {
  0% { background: var(--ak-accent); }
  25% { background: transparent; }
  50% { background: var(--ak-accent); }
  75% { background: transparent; }
  100% { background: var(--ak-accent); }
}

@keyframes snap {
  0% { visibility: hidden; }
  50% { visibility: visible; }
}

@keyframes slip {
  from { transform: translateY(calc(var(--cell) * -6)); }
  to { transform: translateY(0); }
}

@keyframes lights-out {
  from { filter: none; }
  to { filter: grayscale(1) brightness(0.3); }
}

@keyframes appear {
  from { visibility: hidden; }
  to { visibility: visible; }
}

@keyframes blink {
  0% { visibility: visible; }
  50% { visibility: hidden; }
}

/* ---------- the start screen (start.js) held to the viewport ----------
   The title and premise always show, the instructions scroll inside their own column,
   and Play sits below them, never on top of them. The tripled id outranks start.js's rules. */

#activity-start#activity-start#activity-start.layout-split.is-instructions {
  overflow: hidden;
}

#activity-start#activity-start#activity-start.layout-split.is-instructions .ak-sheet {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "head"
    "howto"
    "first"
    "go";
}

#activity-start#activity-start#activity-start.layout-split.is-instructions .ak-howto {
  align-self: stretch;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#activity-start#activity-start#activity-start.layout-split.is-instructions .ak-go {
  position: static;
  margin-top: var(--ak-space-4);
}

#activity-start#activity-start#activity-start.layout-split .ak-tagline {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ak-ink);
}

@media (min-width: 541px) {
  #activity-start#activity-start#activity-start.layout-split.is-instructions .ak-sheet {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "head howto"
      "head first"
      "head go";
  }

  #activity-start#activity-start#activity-start.layout-split.is-instructions .ak-howto {
    padding-bottom: var(--ak-space-4);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #activity-start#activity-start#activity-start.layout-split.is-instructions .ak-sheet {
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head first"
      "head howto"
      "head go";
  }
}
