/* Block Lot: a machine console. Square keys, lit lamps, engraved labels, boxed readouts. */

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

:root {
  --steel-line: color-mix(in srgb, var(--ak-ink-muted) 28%, transparent);
  --steel-dark: color-mix(in srgb, var(--ak-bg) 80%, black);
  --lamp-off: color-mix(in srgb, var(--ak-accent-2) 22%, var(--ak-bg));
  --lamp-off-them: color-mix(in srgb, var(--ak-accent) 24%, var(--ak-bg));
  --snap: cubic-bezier(0.2, 0.9, 0.25, 1.25);
  --swing: cubic-bezier(0.34, 1.56, 0.64, 1);
  --board: min(94dvw, 54dvh);
}

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

body {
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, none), var(--ak-bg-art);
  background-size: cover, var(--ak-bg-size);
  background-position: center;
  background-repeat: no-repeat, repeat;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- Layout ---------- */

.play {
  height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  grid-template-areas:
    "mute logo help"
    "lamps lamps lamps"
    "deck deck deck"
    "console console console";
  gap: 8px;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.key--mute {
  grid-area: mute;
}

.logo {
  grid-area: logo;
  justify-self: center;
  align-self: center;
  height: 44px;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lamps {
  grid-area: lamps;
}

.deck {
  grid-area: deck;
  display: grid;
  place-items: center;
}

.console {
  grid-area: console;
  align-self: start;
}

.deed {
  grid-column: 1 / -1;
  grid-row: 3 / 5;
  align-self: end;
}

@media (orientation: landscape) {
  :root {
    --board: min(90dvh, 48dvw);
  }

  .play {
    max-width: 1280px;
    grid-template-columns: 52px auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "mute deck logo"
      "lamps deck console";
    column-gap: 14px;
    align-content: center;
  }

  .deck {
    align-self: center;
  }

  .logo {
    justify-self: start;
    height: 40px;
    margin-right: 60px;
  }

  .lamps {
    flex-direction: column;
    justify-self: center;
    align-self: start;
  }

  .console {
    align-self: start;
  }

  .deed {
    grid-column: 3;
    grid-row: 2;
    align-self: start;
  }
}

/* ---------- Keys ---------- */

.key {
  min-height: 52px;
  min-width: 48px;
  padding: 0 18px;
  border-radius: 3px;
  border: 2px solid var(--ak-btn-active);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 -5px 0 var(--ak-btn-active), inset 0 2px 0 color-mix(in srgb, var(--ak-btn-ink) 22%, transparent);
  -webkit-tap-highlight-color: transparent;
}

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

.key:active,
.key.is-clicked {
  transform: translateY(3px);
  box-shadow: inset 0 -1px 0 var(--ak-btn-active), inset 0 3px 6px color-mix(in srgb, black 40%, transparent);
}

.key:focus-visible,
.gap:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

.key--alt {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  border-color: var(--ak-choice-border);
  box-shadow: inset 0 -5px 0 var(--steel-dark), inset 0 2px 0 color-mix(in srgb, var(--ak-choice-ink) 10%, transparent);
}

.key--alt:hover {
  background: color-mix(in srgb, var(--ak-choice-bg) 80%, var(--ak-choice-border));
}

.key--mute {
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border-color: var(--steel-line);
  box-shadow: inset 0 -4px 0 var(--steel-dark);
  position: relative;
}

.key--mute:hover {
  background: color-mix(in srgb, var(--ak-surface) 85%, var(--ak-ink));
}

.key--mute svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.key--mute .spk {
  fill: currentColor;
}

.key--mute .slash {
  display: none;
  stroke: var(--ak-accent);
  stroke-width: 2.5;
}

.key--mute::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  background: var(--ak-accent-2);
  box-shadow: 0 0 6px var(--ak-accent-2);
}

.key--mute[aria-pressed="true"] .wave {
  display: none;
}

.key--mute[aria-pressed="true"] .slash {
  display: block;
}

.key--mute[aria-pressed="true"]::after {
  background: var(--lamp-off-them);
  box-shadow: none;
}

/* ---------- Engraved labels ---------- */

.eng {
  font-family: var(--ak-font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ak-ink-muted);
  text-shadow: 0 -1px 0 var(--steel-dark), 0 1px 0 color-mix(in srgb, var(--ak-ink) 10%, transparent);
}

/* ---------- Status lamps ---------- */

.lamps {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--steel-dark);
  border: 1px solid var(--steel-line);
  border-radius: 2px;
  justify-self: center;
}

.lamp {
  width: 14px;
  height: 7px;
  background: var(--lamp-off);
  border: 1px solid color-mix(in srgb, var(--ak-accent-2) 40%, transparent);
}

@media (orientation: landscape) {
  .lamp {
    width: 8px;
    height: 14px;
  }
}

.lamps.is-final .lamp {
  transition: background-color 120ms linear, box-shadow 120ms linear;
  transition-delay: calc(var(--i) * 70ms);
}

.play[data-winner="you"] .lamps.is-final .lamp {
  background: var(--ak-accent-2);
  box-shadow: 0 0 8px var(--ak-accent-2);
}

.play[data-winner="them"] .lamps.is-final .lamp {
  background: var(--ak-accent);
  border-color: var(--ak-accent);
  box-shadow: 0 0 8px var(--ak-accent);
}

/* ---------- Board ---------- */

.board {
  position: relative;
  width: var(--board);
  aspect-ratio: 1;
  background: url("./art/block-board.png") center / 100% 100% no-repeat;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  container-type: inline-size;
  --pitch: calc(var(--board) * 0.1729);
  --thick: calc(var(--pitch) * 0.32);
}

/* The lot grid painted in the board picture: posts at every 20% of this box. */
.grid {
  position: absolute;
  left: 6.64%;
  top: 5.6%;
  width: 86.46%;
  height: 86.07%;
}

.lot {
  position: absolute;
  left: calc(var(--c) * 20%);
  top: calc(var(--r) * 20%);
  width: 20%;
  height: 20%;
  z-index: 0;
}

.marker {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  object-fit: contain;
  pointer-events: none;
}

.post {
  position: absolute;
  left: calc(var(--x) * 20%);
  top: calc(var(--y) * 20%);
  width: calc(var(--thick) * 0.85);
  height: calc(var(--thick) * 0.85);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ak-ink);
  box-shadow: 0 0 0 2px var(--ak-bg), inset 0 -2px 0 var(--ak-ink-muted);
  z-index: 2;
  pointer-events: none;
}

.fence {
  position: absolute;
  left: calc(var(--x) * 20%);
  top: calc(var(--y) * 20%);
  width: var(--pitch);
  height: var(--thick);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  z-index: 1;
  pointer-events: none;
}

.fence > i {
  position: absolute;
  inset: 0;
  display: block;
}

/* Open gap: a faint dashed groove. */
.fence.is-open::before {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--ak-accent-2) 0 4px, transparent 4px 9px);
  opacity: 0.42;
}

.gap:hover + .fence.is-open > i,
.gap:focus-visible + .fence.is-open > i,
.fence.is-open.is-press > i {
  background: url("./art/fence-bar.png") center / 100% 100% no-repeat;
  opacity: 0.45;
}

.gap:focus-visible + .fence {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.fence.is-you > i {
  background: url("./art/fence-bar.png") center / 100% 100% no-repeat;
}

/* The neighbours' fence: hazard-striped orange bar with square dark ends. */
.fence.is-them > i {
  inset: 8% 2%;
  background:
    linear-gradient(90deg, var(--steel-dark) 0 12%, transparent 12% 88%, var(--steel-dark) 88%),
    repeating-linear-gradient(135deg, var(--ak-accent) 0 7px, var(--ak-bg) 7px 11px);
  border: 2px solid var(--ak-bg);
  outline: 1px solid var(--ak-accent);
}

.fence.is-last::after,
.fence.is-point::after {
  content: "";
  position: absolute;
  inset: -6px -4px;
  border: 3px solid var(--ak-ink);
}

.gap {
  position: absolute;
  left: calc((var(--x) - 0.5) * 20%);
  top: calc((var(--y) - 0.5) * 20%);
  width: 20%;
  height: 20%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  cursor: pointer;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
}

.gap:focus-visible {
  outline: none;
}

.play[data-turn="them"] .gap,
.play.is-over .gap {
  cursor: default;
}

.tag {
  position: absolute;
  left: calc(var(--x, 3) * 20% + var(--thick));
  top: calc(var(--y, 2.5) * 20%);
  transform: translateY(-50%);
  z-index: 4;
  margin: 0;
  padding: 6px 10px 6px 8px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border: 2px solid var(--ak-accent-2);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.tag::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-right-color: var(--ak-accent-2);
}

.tag[hidden] {
  display: none;
}

/* ---------- Console ---------- */

.console {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  min-height: 0;
  background:
    radial-gradient(circle at 7px 7px, var(--ak-ink-muted) 0 2px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 7px) 7px, var(--ak-ink-muted) 0 2px, transparent 2.5px),
    radial-gradient(circle at 7px calc(100% - 7px), var(--ak-ink-muted) 0 2px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), var(--ak-ink-muted) 0 2px, transparent 2.5px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--ak-ink) 3%, transparent) 0 1px, transparent 1px 4px),
    var(--ak-surface);
  border: 2px solid var(--steel-line);
  border-top: 3px solid var(--ak-accent);
  border-radius: 2px;
}

.readouts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.tally,
.claimed {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 8px 4px;
  background: var(--ak-bg);
  border: 2px solid var(--steel-line);
  box-shadow: inset 0 2px 0 var(--steel-dark);
}

.tally-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ak-ink);
}

.play[data-turn="you"]:not(.is-over) .tally--you {
  border-color: var(--ak-accent-2);
}

.play[data-turn="them"]:not(.is-over) .tally--them {
  border-color: var(--ak-accent);
}

.play[data-winner="you"] .tally--you,
.play[data-winner="them"] .tally--them {
  border-color: var(--ak-ink);
}

.digits {
  display: flex;
  gap: 3px;
}

.digits b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 40px;
  font-family: var(--ak-font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--ak-ink);
  background:
    linear-gradient(180deg, transparent calc(50% - 1px), var(--steel-dark) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    var(--ak-surface);
  border: 1px solid var(--steel-line);
  border-radius: 2px;
}

.mark {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: none;
}

.mark--you {
  border-radius: 50%;
  border: 3px solid var(--ak-accent-2);
  background: radial-gradient(circle, var(--ak-accent-2) 0 2px, transparent 2.5px);
}

.mark--them {
  width: 11px;
  height: 11px;
  margin: 1.5px;
  border: 3px solid var(--ak-accent);
  transform: rotate(45deg);
}

/* Squares claimed: a 25-cell strip, yours from the left, Vesna's from the right. */
.claimed {
  padding: 8px 10px;
}

.claimed-count {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--ak-font-display);
  font-weight: 800;
  color: var(--ak-ink);
}

.claimed-count b {
  font-size: 24px;
}

.claimed-count span {
  font-size: 13px;
  color: var(--ak-ink-muted);
}

.claim-bar {
  display: grid;
  grid-template-columns: repeat(25, 5px);
  gap: 1px;
  height: 14px;
}

.claim-bar i {
  background: color-mix(in srgb, var(--ak-ink-muted) 22%, var(--ak-bg));
}

.claim-bar i.is-mid {
  outline: 1px solid var(--ak-ink);
  outline-offset: 1px;
}

.claim-bar i.is-you {
  background: var(--ak-accent-2);
}

.claim-bar i.is-them {
  background: var(--ak-accent);
}

.claimed-label,
.claimed-goal {
  font-size: 10px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* The turn needle lives in the turn header. */
.dial {
  flex: none;
  width: 40px;
  height: 24px;
  overflow: visible;
}

.dial path {
  fill: none;
  stroke-linecap: butt;
}

.dial-arc {
  stroke: var(--steel-line);
  stroke-width: 10;
}

.dial-you {
  stroke: var(--ak-accent-2);
  stroke-width: 10;
}

.dial-them {
  stroke: var(--ak-accent);
  stroke-width: 10;
}

.needle {
  transform-box: view-box;
  transform-origin: 60px 62px;
  transform: rotate(var(--needle, 0deg));
}

.needle path {
  stroke: var(--ak-ink);
  stroke-width: 8;
}

.needle circle {
  fill: var(--ak-ink-muted);
  stroke: var(--ak-bg);
  stroke-width: 3;
}

.ticker {
  min-height: 56px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--ak-bg);
  border: 2px solid var(--steel-line);
  box-shadow: inset 0 2px 0 var(--steel-dark);
}

.turn-head {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ak-font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ak-ink);
}


#turn-head {
  white-space: nowrap;
}

.turn-act {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 2px solid var(--ak-accent-2);
  font-size: 13px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.play[data-turn="them"] .turn-act {
  border-color: var(--ak-accent);
}

/* The square TURN lamp. */
.turn-act::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--ak-accent-2);
  box-shadow: 0 0 6px var(--ak-accent-2);
}

.play[data-turn="them"] .turn-act::before {
  background: var(--ak-accent);
  box-shadow: 0 0 6px var(--ak-accent);
}

.last {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--steel-line);
  font-size: 15px;
  line-height: 1.3;
  color: var(--ak-ink-muted);
}

.last[hidden] {
  display: none;
}

/* The suggested gap after a quiet spell on your turn. */
.fence.is-hint::before {
  opacity: 0.9;
  height: 5px;
}

.play.is-over .turn-act {
  display: none;
}

/* The board frame shows whose turn it is, and open gaps dim while Vesna builds. */
.board::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 3px solid var(--ak-accent-2);
  pointer-events: none;
}

.play[data-turn="them"] .board::after {
  border-color: var(--ak-accent);
}

.play.is-over .board::after {
  border-color: var(--steel-line);
}

.play[data-turn="them"] .fence.is-open::before {
  opacity: 0.18;
}

.play[data-turn="them"] .gap:hover + .fence.is-open > i {
  background: none;
}

.dots {
  display: none;
  gap: 4px;
}

.dots i {
  width: 7px;
  height: 7px;
  background: var(--ak-accent);
}

.play.is-thinking .dots {
  display: inline-flex;
}

.status,
.note {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ak-ink);
}

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--ak-bg);
  border: 2px solid var(--ak-accent);
  border-left-width: 8px;
  font-size: 18px;
  font-weight: 700;
}

.note::before {
  content: "";
  flex: none;
  width: 18px;
  height: 16px;
  margin-top: 3px;
  background: var(--ak-accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.note[hidden] {
  display: none;
}

/* ---------- Teaching ---------- */

.console.is-teaching .readouts,
.console.is-teaching .ticker,
.console.is-teaching .note {
  display: none;
}

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

.teach[hidden] {
  display: none;
}

.teach-cap {
  margin: 0;
  padding: 12px 14px;
  background: var(--ak-bg);
  border: 2px solid var(--ak-accent-2);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ak-ink);
}

.teach-cap .eng {
  display: block;
  margin-bottom: 4px;
  color: var(--ak-accent-2);
}

@media (orientation: portrait) and (max-height: 700px) {
  :root {
    --board: min(94dvw, 49dvh);
  }

  .play {
    gap: 6px;
  }

  .console {
    padding: 6px;
    gap: 6px;
  }

  .claimed-label,
  .claimed-goal,
  .last {
    display: none;
  }

  .claimed {
    gap: 3px;
    padding: 4px 6px;
  }

  .claimed-count b {
    font-size: 18px;
  }

  .claim-bar {
    grid-template-columns: repeat(25, 2px);
    height: 10px;
  }

  .dial {
    width: 34px;
    height: 20px;
  }

  .tally {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 4px;
  }

  .tally > .eng {
    letter-spacing: 0.06em;
  }

  .tally .digits b {
    width: 22px;
    font-size: 20px;
  }

  .turn-head {
    font-size: 15px;
  }

  .note {
    padding: 6px 10px;
    font-size: 17px;
  }

  .teach {
    gap: 8px;
  }

  .teach-cap {
    padding: 8px 10px;
  }

  .teach-cap .eng {
    display: inline;
    margin: 0 6px 0 0;
  }
}

.key--go {
  min-height: 56px;
  font-size: 17px;
}

/* ---------- Final readout ---------- */

.deed {
  z-index: 5;
  max-height: 100%;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
  background:
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--ak-ink) 3%, transparent) 0 1px, transparent 1px 4px),
    var(--ak-surface);
  border: 2px solid var(--steel-line);
  border-top: 4px solid var(--ak-accent-2);
  border-radius: 2px;
}

.play[data-winner="them"] .deed {
  border-top-color: var(--ak-accent);
}

.deed[hidden] {
  display: none;
}

.deed-head {
  margin: 0;
}

.deed-lines {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  background: var(--ak-bg);
  border: 2px solid var(--steel-line);
  box-shadow: inset 0 2px 0 var(--steel-dark);
  min-height: 48px;
}

.deed-lines li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ak-ink);
}

.deed-reason {
  color: var(--ak-ink-muted);
}

.deed-reason span {
  color: var(--ak-ink-muted);
}

.deed-row {
  font-family: var(--ak-font-display);
  font-size: 16px;
  letter-spacing: 0.04em;
}

.leader {
  flex: 1;
  height: 0;
  border-bottom: 2px dotted var(--steel-line);
  transform: translateY(4px);
}

.deed-turn {
  padding-left: 10px;
  border-left: 3px solid var(--ak-accent-2);
  font-size: 16px;
}

.play[data-winner="them"] .deed-turn {
  border-left-color: var(--ak-accent);
}

.deed-says {
  padding-top: 8px;
  border-top: 1px dashed var(--steel-line);
  font-size: 19px;
  font-weight: 700;
}

.deed-keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  visibility: hidden;
}

.deed-keys.is-ready {
  visibility: visible;
}

.deed-keys .key {
  font-size: 14px;
  padding: 0 10px;
}

/* ---------- Burst ---------- */

.burst {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  pointer-events: none;
}

.bit {
  position: absolute;
  width: 9px;
  height: 9px;
  left: -4px;
  top: -4px;
  opacity: 0;
}

.bit--a {
  background: var(--ak-accent-2);
}

.bit--b {
  background: var(--ak-accent);
  width: 5px;
  height: 14px;
}

.bit--c {
  background: var(--ak-ink);
  width: 7px;
  height: 7px;
}

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

@media (prefers-reduced-motion: no-preference) {
  .key {
    transition: transform 70ms ease-out, background-color 120ms ease-out;
  }

  .needle {
    transition: transform 620ms var(--swing);
  }

  .fence.is-snap > i {
    animation: snap 300ms var(--snap) both;
  }

  .fence.is-press > i {
    animation: press 160ms ease-out;
  }

  .fence.is-refused::before {
    animation: refuse 360ms ease-in-out;
  }

  .fence.is-refused > i {
    animation: refuse 360ms ease-in-out;
  }

  .fence.is-last::after {
    animation: blink 400ms steps(2, jump-none) 4;
  }

  .fence.is-point::after {
    animation: ring 1100ms ease-out infinite;
  }

  .fence.is-open::before {
    animation: groove 5s linear infinite;
  }

  .lot.is-stamp .marker {
    animation: stamp 420ms cubic-bezier(0.3, 0.7, 0.3, 1.3) both;
  }

  .lot.is-chase .marker {
    animation: chase 520ms ease-in-out var(--chase, 0ms) 2 both;
  }

  .digits b.is-flip {
    animation: flip 240ms ease-in-out;
  }

  .lamp {
    animation: idle-lamp 3.6s steps(1, end) calc(var(--i) * 0.3s) infinite;
  }

  .lamps.is-final .lamp {
    animation: none;
  }

  .turn-act::before {
    animation: breathe 2.4s ease-in-out infinite;
  }

  .fence.is-hint::before {
    animation: hint-pulse 1.6s ease-in-out infinite;
  }

  .play.is-thinking .dots i {
    animation: think 600ms steps(2, jump-none) infinite;
  }

  .play.is-thinking .dots i:nth-child(2) {
    animation-delay: 200ms;
  }

  .play.is-thinking .dots i:nth-child(3) {
    animation-delay: 400ms;
  }

  .play.is-thinking .turn-act::before {
    animation: think 360ms steps(2, jump-none) infinite;
  }

  .play.is-turn-change .tally,
  .play.is-turn-change .claimed {
    animation: knock 260ms ease-out;
  }

  .play.is-over .board {
    animation: settle 700ms ease-out;
  }

  .note.is-new {
    animation: nudge 260ms ease-out;
  }

  .deed:not([hidden]) {
    animation: feed 300ms var(--snap) both;
  }

  .deed-lines li.is-printing {
    animation: print 380ms steps(12, end) both;
  }

  .deed-keys.is-ready {
    animation: rise 260ms var(--snap) both;
  }

  .bit {
    animation: fly 1500ms cubic-bezier(0.15, 0.7, 0.3, 1) var(--delay, 0ms) both;
  }

  .tag:not([hidden]) {
    animation: rise 260ms var(--snap) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bit {
    display: none;
  }
}

@keyframes snap {
  0% {
    transform: translateX(-18%) scaleX(0.35);
    opacity: 0.2;
  }

  55% {
    transform: translateX(2%) scaleX(1.06) scaleY(0.8);
    opacity: 1;
  }

  78% {
    transform: scaleX(0.98) scaleY(1.12);
  }

  100% {
    transform: none;
  }
}

@keyframes press {
  50% {
    opacity: 0.8;
    transform: scaleY(1.3);
  }
}

@keyframes refuse {
  20% { transform: translateX(-5%); }
  45% { transform: translateX(5%); }
  70% { transform: translateX(-3%); }
}

@keyframes blink {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3, 1.9); opacity: 0; }
}

@keyframes groove {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}

@keyframes hint-pulse {
  0%,
  100% { opacity: 0.55; }
  50% { opacity: 1; height: 7px; }
}

@keyframes stamp {
  0% { transform: scale(1.45); opacity: 0; }
  50% { transform: scale(0.86); opacity: 1; }
  72% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes chase {
  50% {
    transform: scale(1.1);
    filter: brightness(1.45);
  }
}

@keyframes flip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0.05); }
  100% { transform: scaleY(1); }
}

@keyframes idle-lamp {
  0% { background: var(--ak-accent-2); }
  8% { background: var(--lamp-off); }
}

@keyframes breathe {
  50% { box-shadow: 0 0 2px currentColor; filter: brightness(0.8); }
}

@keyframes think {
  from { opacity: 1; }
  to { opacity: 0.25; }
}

@keyframes knock {
  40% { transform: translateY(2px); }
}

@keyframes settle {
  30% { filter: brightness(1.25); }
}

@keyframes nudge {
  30% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
}

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

@keyframes print {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

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

@keyframes fly {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); opacity: 0; }
}

/* ---------- Small and short screens ---------- */

/* Tall phones: the console takes the rest of the height and the readouts grow into it. */
@media (orientation: portrait) and (min-height: 760px) {
  .console {
    align-self: stretch;
    gap: 10px;
  }

  .tally,
  .claimed {
    padding: 12px 6px;
    gap: 8px;
  }

  .tally-name {
    font-size: 13px;
  }

  .digits b {
    width: 36px;
    height: 58px;
    font-size: 36px;
  }

  .claimed-count b {
    font-size: 32px;
  }

  .claim-bar {
    grid-template-columns: repeat(25, 4px);
    height: 24px;
  }

  .dial {
    width: 50px;
    height: 30px;
  }

  .ticker {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .last {
    margin-top: auto;
  }

  .status,
  .note {
    font-size: 18px;
  }

  .turn-head {
    font-size: 18px;
  }
}

@media (max-height: 700px) and (orientation: portrait) {
  .logo {
    height: 36px;
  }

  .digits b {
    height: 34px;
    width: 26px;
    font-size: 22px;
  }

  .ticker {
    min-height: 48px;
    padding: 6px 10px;
  }

  .status {
    font-size: 16px;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .console {
    gap: 6px;
    padding: 8px;
  }

  .digits b {
    height: 34px;
    width: 26px;
    font-size: 22px;
  }

  .claimed-goal {
    display: none;
  }

  .deed {
    gap: 6px;
    padding: 8px 10px 10px;
  }

  .deed-head {
    display: none;
  }

  .deed-lines {
    gap: 4px;
    padding: 6px 10px;
  }

  .deed-lines li {
    font-size: 15px;
    line-height: 1.25;
  }

  .deed-row {
    font-size: 14px;
  }

  .deed-says {
    padding-top: 4px;
  }

  .deed-keys .key {
    min-height: 48px;
  }
}
