/* Capslide: transit signage on a phosphor terminal. Flat blocks, stripes, square corners. */

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background-color: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  overscroll-behavior: none;
}

body {
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

button { font: inherit; }

.play {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.play::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  pointer-events: none;
}

/* ---------- stage: portrait is the default, the board above the controls ---------- */

.stage {
  --cols: 3;
  --rows: 2;
  --gap: 5px;
  --frame: 10px;
  --well: 4px;
  --pad: 8px;
  --cell-max: 150px;
  --stage-w: 560px;
  --chrome: 410px;
  --inset-x: calc(2 * var(--pad) + env(safe-area-inset-left) + env(safe-area-inset-right));
  --cell: min(
    calc((min(100dvw, var(--stage-w)) - var(--inset-x) - 2 * var(--frame) - 2 * var(--well) - (var(--cols) - 1) * var(--gap)) / var(--cols)),
    calc((100dvh - var(--chrome) - 2 * var(--frame) - 2 * var(--well) - (var(--rows) - 1) * var(--gap)) / var(--rows)),
    var(--cell-max)
  );
  position: relative;
  box-sizing: border-box;
  width: min(100%, var(--stage-w));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 64px;
  grid-template-rows: auto 6px auto minmax(0, 1fr) auto;
  grid-template-areas:
    "mute logo help"
    "line line line"
    "sign sign sign"
    "board board board"
    "deck deck deck";
  row-gap: 8px;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + var(--pad))
    calc(env(safe-area-inset-bottom) + 10px)
    calc(env(safe-area-inset-left) + var(--pad));
}

.stage.has-coach { --chrome: 478px; }

/* the route line under the top bar */
.stage::before {
  content: '';
  grid-area: line;
  background: repeating-linear-gradient(90deg, var(--ak-btn-fill) 0 30px, transparent 30px 38px);
}

/* ---------- top bar ---------- */

.mute {
  grid-area: mute;
  align-self: center;
  justify-self: start;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--ak-choice-border);
  border-radius: 0;
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  box-shadow: inset 0 -4px 0 var(--ak-accent);
  cursor: pointer;
}
.mute svg { width: 26px; height: 26px; margin-top: -3px; }
.mute .icon-off { display: none; }
.mute[aria-pressed="true"] .icon-on { display: none; }
.mute[aria-pressed="true"] .icon-off { display: block; }
.mute[aria-pressed="true"] { box-shadow: inset 0 -4px 0 var(--ak-choice-border); }

.logo {
  grid-area: logo;
  align-self: center;
  justify-self: start;
  height: 36px;
  width: auto;
  max-width: 100%;
  margin-left: 8px;
  object-fit: contain;
}

/* ---------- the country sign ---------- */

.sign {
  grid-area: sign;
  --sign-h: 78px;
  --point: 36px;
  container-type: inline-size;
  box-sizing: border-box;
  height: var(--sign-h);
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-rows: 24px minmax(0, 1fr);
  padding: 6px calc(var(--point) + 8px) 12px 14px;
  background:
    linear-gradient(to bottom,
      transparent calc(100% - 11px),
      var(--ak-btn-ink) calc(100% - 11px) calc(100% - 7px),
      transparent calc(100% - 7px)),
    var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  clip-path: polygon(0 0, calc(100% - var(--point)) 0, 100% 50%, calc(100% - var(--point)) 100%, 0 100%);
}

.sign-label {
  align-self: center;
  font-family: var(--ak-font-display);
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sign-text {
  --len: 6;
  grid-column: 1 / -1;
  align-self: center;
  min-width: 0;
  font-family: var(--ak-font-display);
  font-size: min(46px, calc((100cqw - 64px) * 2.1 / var(--len)));
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* where we are: three stops on a line */
.stops {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
  align-self: center;
  margin-left: 14px;
}
.stops li {
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  line-height: 1;
}
.stops li[data-state="now"] { background: var(--ak-btn-ink); color: var(--ak-btn-fill); }
.stops li[data-state="done"] { background: var(--ak-btn-ink); color: var(--ak-btn-fill); opacity: 0.55; }
.stops li[data-state="next"] { background: transparent; }

/* ---------- the board ---------- */

.board-zone {
  grid-area: board;
  min-height: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  row-gap: 8px;
}

.board-frame {
  box-sizing: content-box;
  padding: var(--well);
  border: var(--frame) solid transparent;
  border-image: url('./art/board-frame.png') 26 / var(--frame) round;
  background-color: var(--ak-bg);
}

.board {
  position: relative;
  width: calc(var(--cols) * var(--cell) + (var(--cols) - 1) * var(--gap));
  height: calc(var(--rows) * var(--cell) + (var(--rows) - 1) * var(--gap));
}

/* a platform-edge stripe under the board */
.edge {
  position: relative;
  box-sizing: border-box;
  width: calc(var(--cols) * var(--cell) + (var(--cols) - 1) * var(--gap) + 2 * var(--well) + 2 * var(--frame));
  height: 28px;
  background: repeating-linear-gradient(135deg, var(--ak-btn-fill) 0 10px, var(--ak-bg) 10px 20px) top / 100% 10px no-repeat;
}

/* stamped across the board's foot once the capital is verified; it never sits on a tile */
.seal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid var(--ak-accent-2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
.seal svg { width: 16px; height: 16px; color: var(--ak-accent-2); }

.tile,
.gap {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  width: var(--cell);
  height: var(--cell);
  margin: 0;
  padding: 0;
  transform: translate(
    calc(var(--c) * (var(--cell) + var(--gap)) + var(--dx, 0px)),
    calc(var(--r) * (var(--cell) + var(--gap)) + var(--dy, 0px))
  );
}

.gap {
  z-index: 0;
  background: url('./art/gap-slot.png') center / 100% 100% no-repeat;
  pointer-events: none;
}

.gap-arrow {
  position: absolute;
  width: 20%;
  height: 20%;
  background: var(--ak-accent-2);
}
.gap-arrow[data-dir="left"]  { left: 21%; top: 40%; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.gap-arrow[data-dir="right"] { right: 21%; top: 40%; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.gap-arrow[data-dir="up"]    { top: 21%; left: 40%; clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.gap-arrow[data-dir="down"]  { bottom: 21%; left: 40%; clip-path: polygon(0 0, 50% 100%, 100% 0); }

.tile {
  z-index: 1;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ak-btn-ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* an enamel plate: bezel, a thin darker inner border, one capital letter */
.plate {
  --bezel: calc(var(--cell) * 0.08);
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border: var(--bezel) solid color-mix(in srgb, var(--ak-ink-muted) 40%, var(--ak-bg));
  background: var(--ak-btn-fill);
  box-shadow: inset 0 0 0 calc(var(--cell) * 0.035) var(--ak-choice-border);
}

/* bolts in the four corners of the bezel */
.plate::before {
  content: '';
  position: absolute;
  inset: calc(-1 * var(--bezel));
  --bolt: calc(var(--bezel) * 0.22);
  --m: calc(var(--bezel) / 2);
  background:
    radial-gradient(circle at var(--m) var(--m), var(--ak-bg) var(--bolt), transparent calc(var(--bolt) + 0.5px)),
    radial-gradient(circle at calc(100% - var(--m)) var(--m), var(--ak-bg) var(--bolt), transparent calc(var(--bolt) + 0.5px)),
    radial-gradient(circle at var(--m) calc(100% - var(--m)), var(--ak-bg) var(--bolt), transparent calc(var(--bolt) + 0.5px)),
    radial-gradient(circle at calc(100% - var(--m)) calc(100% - var(--m)), var(--ak-bg) var(--bolt), transparent calc(var(--bolt) + 0.5px));
  pointer-events: none;
}

.letter {
  position: relative;
  font-family: var(--ak-font-body);
  font-weight: 600;
  font-size: calc(var(--cell) * 0.56);
  line-height: 1;
  color: var(--ak-btn-ink);
}

/* after a check: lit and ticked is right, crossed is wrong */
.tile.is-right { z-index: 2; box-shadow: 0 0 0 4px var(--ak-accent-2); }
.tile.is-right::after,
.tile.is-wrong::after {
  content: '';
  position: absolute;
  top: calc(var(--cell) * 0.1);
  right: calc(var(--cell) * 0.1);
  width: calc(var(--cell) * 0.22);
  height: calc(var(--cell) * 0.22);
  background: var(--ak-btn-ink);
  pointer-events: none;
}
.tile.is-right::after { clip-path: polygon(0 55%, 16% 38%, 38% 62%, 84% 8%, 100% 24%, 38% 94%); }
.tile.is-wrong::after { clip-path: polygon(0 16%, 16% 0, 50% 34%, 84% 0, 100% 16%, 66% 50%, 100% 84%, 84% 100%, 50% 66%, 16% 100%, 0 84%, 34% 50%); }
.tile.is-wrong .plate { background: color-mix(in srgb, var(--ak-btn-fill) 78%, var(--ak-bg)); }

/* the first move, or a hint: a ring that never covers the letter */
.tile.is-pointed { z-index: 3; outline: 4px solid var(--ak-accent-2); outline-offset: 0; }

.gap.is-wrong::after {
  content: '';
  position: absolute;
  top: calc(var(--cell) * 0.14);
  right: calc(var(--cell) * 0.14);
  width: calc(var(--cell) * 0.22);
  height: calc(var(--cell) * 0.22);
  background: var(--ak-ink);
  clip-path: polygon(0 16%, 16% 0, 50% 34%, 84% 0, 100% 16%, 66% 50%, 100% 84%, 84% 100%, 50% 66%, 16% 100%, 0 84%, 34% 50%);
}

.tile.is-dragging { z-index: 4; cursor: grabbing; }

.tile:focus-visible { outline: none; z-index: 5; }
.tile:focus-visible .plate { box-shadow: inset 0 0 0 calc(var(--cell) * 0.07) var(--ak-bg); }

/* ---------- the controls ---------- */

.deck {
  grid-area: deck;
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

.coach {
  margin: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--ak-surface);
  border-left: 8px solid var(--ak-accent-2);
  color: var(--ak-ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.coach-arrow { flex: none; width: 30px; height: 30px; color: var(--ak-accent-2); }
.coach[data-aim="check"] .coach-arrow { transform: rotate(180deg); }

.message,
.result {
  box-sizing: border-box;
  min-width: 0;
  background: var(--ak-surface);
  border-left: 8px solid var(--ak-accent);
  padding: 8px 12px;
}

.message {
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.message.is-quiet { align-items: center; }
.message.is-quiet .status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* one slot per letter, then the gap: the shape of the answer, nothing more */
.slots {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  flex: 0 1 auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  --slot: 28px;
}
.message.is-quiet .slots { display: flex; }
.slots li {
  flex: 0 1 var(--slot);
  width: var(--slot);
  height: var(--slot);
  min-width: 14px;
  box-sizing: border-box;
  border: 2px solid var(--ak-choice-border);
  border-bottom: 5px solid var(--ak-accent);
  background: var(--ak-bg);
}
.slots li.is-gap {
  border: 2px solid var(--ak-ink-muted);
  background: var(--ak-surface);
  box-shadow: inset 0 0 0 3px var(--ak-bg);
}
.slots li.row-start { margin-left: 10px; }
.message.is-quiet .cursor { align-self: center; margin: 0 0 0 6px; }

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

.cursor {
  flex: none;
  align-self: flex-end;
  width: 0.62em;
  height: 1.05em;
  margin-bottom: 2px;
  font-size: 15px;
  background: var(--ak-accent);
}

.result { border-left-color: var(--ak-accent-2); display: grid; gap: 4px; align-content: center; min-height: 58px; }
.result-reason { margin: 0; font-size: 15px; line-height: 1.4; color: var(--ak-ink-muted); }
.result-copy {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0.03em;
  color: var(--ak-ink);
}

.actions { display: grid; gap: 8px; }
.main-wrap { display: grid; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1 1 0; min-width: 0; }
.row #second { flex: 1.7 1 0; }

.btn {
  box-sizing: border-box;
  min-height: 52px;
  border: 0;
  border-radius: 0;
  font-family: var(--ak-font-display);
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:focus-visible { outline: none; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* the main button is a sign with a pointed end */
.btn-main {
  position: relative;
  --point: 20px;
  padding: 0 calc(var(--point) + 14px) 6px 16px;
  text-align: left;
  background:
    linear-gradient(to bottom,
      transparent calc(100% - 9px),
      var(--ak-btn-ink) calc(100% - 9px) calc(100% - 5px),
      transparent calc(100% - 5px)),
    var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  clip-path: polygon(0 0, calc(100% - var(--point)) 0, 100% 50%, calc(100% - var(--point)) 100%, 0 100%);
}
.btn-main:focus-visible { box-shadow: inset 0 -9px 0 var(--ak-bg); }

/* the next step lights the button's own bottom stripe */
.btn-main.is-pointed::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 9px;
  background: var(--ak-accent-2);
}

.btn-main:active:not(:disabled) { background-color: var(--ak-btn-active); }

.btn-side {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 8px 4px;
  border: 2px solid var(--ak-choice-border);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  box-shadow: inset 0 -5px 0 var(--ak-accent);
}
.btn-side svg { flex: none; width: 20px; height: 20px; margin-bottom: -2px; }
.btn-side:active:not(:disabled) { background: var(--ak-surface); }
.btn-side:focus-visible,
.mute:focus-visible {
  outline: none;
  border-color: var(--ak-focus);
  box-shadow: inset 0 -5px 0 var(--ak-focus);
}

@media (hover: hover) {
  .btn-main:hover:not(:disabled) { background-color: var(--ak-btn-hover); }
  .btn-side:hover:not(:disabled) { border-color: var(--ak-choice-selected-border); }
  .mute:hover { border-color: var(--ak-choice-selected-border); }
}

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

@media (orientation: landscape) {
  .stage {
    --stage-w: 920px;
    --rail: 56px;
    --side: clamp(270px, 40dvw, 430px);
    --vpad: calc(env(safe-area-inset-top) + env(safe-area-inset-bottom) + 20px);
    --cell: min(
      calc((min(100dvw, var(--stage-w)) - var(--inset-x) - var(--rail) - var(--side) - 2 * var(--frame) - 2 * var(--well) - (var(--cols) - 1) * var(--gap)) / var(--cols)),
      calc((100dvh - var(--vpad) - 2 * var(--frame) - 2 * var(--well) - (var(--rows) - 1) * var(--gap) - 32px) / var(--rows)),
      var(--cell-max)
    );
    grid-template-columns: var(--rail) auto minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "mute board logo"
      "line board sign"
      "line board deck";
    column-gap: 12px;
    row-gap: 8px;
    align-content: stretch;
    padding-top: calc(env(safe-area-inset-top) + 6px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 6px);
  }

  .coach[data-aim="board"] .coach-arrow { transform: rotate(-90deg); }

  .stage::before {
    justify-self: center;
    width: 8px;
    background: repeating-linear-gradient(180deg, var(--ak-btn-fill) 0 30px, transparent 30px 38px);
  }

  .logo { margin-left: 0; margin-right: 64px; max-width: calc(100% - 64px); height: 34px; }
  .sign { --sign-h: 68px; --point: 30px; grid-template-rows: 20px minmax(0, 1fr); max-width: 440px; }
  .sign-text { font-size: min(40px, calc((100cqw - 58px) * 2.1 / var(--len))); }
  .deck { max-width: 440px; gap: 6px; }
  .message, .result { min-height: 44px; }
  .btn { min-height: 48px; }
  .board-zone { align-self: center; }
}

@media (orientation: landscape) and (max-height: 420px) {
  .stage { row-gap: 4px; padding-top: calc(env(safe-area-inset-top) + 4px); padding-bottom: calc(env(safe-area-inset-bottom) + 4px); }
  .logo { height: 28px; }
  .sign { --sign-h: 60px; margin-top: 4px; padding-top: 3px; padding-bottom: 9px; grid-template-rows: 18px minmax(0, 1fr); }
  .sign-label { font-size: 17px; }
  .sign-text { font-size: min(34px, calc((100cqw - 58px) * 2.1 / var(--len))); }
  .coach { padding: 4px 10px; line-height: 1.22; }
  .message, .result { padding: 4px 10px; min-height: 40px; }
  .slots { --slot: 22px; }
  .seal { height: 24px; font-size: 18px; }
  .edge { height: 26px; }
  .status, .result-reason { font-size: 14px; line-height: 1.3; }
  .result-copy { font-size: 23px; }
  .deck { gap: 4px; }
  .actions { gap: 6px; }
  .btn { font-size: 22px; }
}

@media (orientation: landscape) and (max-height: 350px) {
  .sign { --sign-h: 52px; padding-top: 2px; padding-bottom: 8px; grid-template-rows: 16px minmax(0, 1fr); }
  .sign-text { font-size: min(30px, calc((100cqw - 58px) * 2.1 / var(--len))); }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .tile, .gap { transition: transform 170ms cubic-bezier(0.3, 1.5, 0.5, 1); }
  .tile.is-dragging { transition: none; }

  /* a tile that lands settles with a flip-board snap */
  .tile.is-landed .plate { animation: settle 220ms ease-out; }
  .plate.is-flap { animation: flap 280ms ease-in-out both; animation-delay: var(--delay, 0ms); }

  .tile.is-pointed { animation: ring 1000ms ease-in-out infinite; }
  .btn-main.is-pointed::after { animation: nudge 1000ms ease-in-out infinite; }
  .seal { animation: stamp 360ms cubic-bezier(0.3, 1.4, 0.5, 1) both; }
  .gap-arrow { animation: nudge 1000ms ease-in-out infinite; }
  .coach-arrow { animation: bob 1000ms ease-in-out infinite; }

  .cursor { animation: blink 1000ms steps(1, end) infinite; }
  .cursor.is-twice { animation: blink 520ms steps(1, end) 2; }

  .sign.is-flipping { animation: flipsign 640ms ease-in-out both; transform-origin: 50% 0; }
  .result.is-new { animation: flipsign 520ms ease-in-out both; transform-origin: 50% 0; }
  .stops li.is-new { animation: flap 360ms ease-in-out both; }
  .tile.is-nope .plate { animation: nope 260ms ease-in-out; }
}

@keyframes settle {
  0% { transform: scaleY(0.78); }
  55% { transform: scaleY(1.06); }
  100% { transform: scaleY(1); }
}
@keyframes flap {
  0% { transform: scaleY(1); }
  48% { transform: scaleY(0.04); }
  100% { transform: scaleY(1); }
}
@keyframes flipsign {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0.02); }
  100% { transform: scaleY(1); }
}
@keyframes ring {
  0%, 100% { outline-width: 3px; }
  50% { outline-width: 6px; }
}
@keyframes stamp {
  0% { transform: scale(1.25, 1.6); opacity: 0; }
  55% { transform: scale(0.97); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes nudge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes nope {
  0%, 100% { translate: 0 0; }
  25% { translate: -4px 0; }
  75% { translate: 4px 0; }
}

/* ---------- the start screen, kept in the same signage ---------- */

#activity-start#activity-start .ak-badge { display: none; }

#activity-start#activity-start .ak-label {
  display: inline-block;
  margin: 0 0 6px;
  padding: 3px 8px 2px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.14em;
}

/* Instructions: the title, the first move and Play are fixed; only the rules scroll,
   inside their own box, so the button never floats over any text. */
#activity-start#activity-start.is-instructions {
  overflow: hidden;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
#activity-start#activity-start.is-instructions .ak-sheet {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
}
#activity-start#activity-start.is-instructions .ak-head { flex: none; }
#activity-start#activity-start.is-instructions .ak-howto {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
  padding-bottom: 12px;
  overflow-y: auto;
  justify-content: flex-start;
  align-content: flex-start;
  -webkit-mask-image: linear-gradient(to bottom, var(--ak-bg) calc(100% - 12px), transparent);
  mask-image: linear-gradient(to bottom, var(--ak-bg) calc(100% - 12px), transparent);
}
#activity-start#activity-start.is-instructions .ak-section { flex: 0 0 auto; }
#activity-start#activity-start.is-instructions .ak-first {
  flex: none;
  order: 0;
  width: min(100%, 720px);
  margin: 4px auto 0;
  padding: 8px 12px;
  font-size: 17px;
}
#activity-start#activity-start.is-instructions .ak-first-label { margin-bottom: 0; }
#activity-start#activity-start.is-instructions .ak-go {
  position: static;
  flex: none;
  order: 2;
  align-self: center;
  margin: 12px 0 0;
  min-height: 52px;
}
#activity-start#activity-start.is-instructions .ak-tagline { margin-top: 8px; padding: 6px 16px; }

@media (max-width: 540px) {
  #activity-start#activity-start .ak-logo { max-height: 84px; }
  #activity-start#activity-start .ak-tagline { margin-inline: -16px; font-size: 12px; }
  #activity-start#activity-start .ak-howto { gap: 10px; }
  #activity-start#activity-start .ak-body { font-size: 15px; line-height: 1.4; }
  #activity-start#activity-start .ak-controls li + li { margin-top: 2px; }
  #activity-start#activity-start.is-instructions .ak-go { width: 100%; max-width: none; min-width: 0; }
  #activity-start#activity-start.is-setup .ak-go { bottom: 0; margin-top: 24px; }
}

/* short phones, either way up: a smaller title, no tagline */
@media (max-height: 700px) {
  #activity-start#activity-start.is-instructions .ak-logo { max-height: 50px; }
  #activity-start#activity-start.is-instructions .ak-tagline { display: none; }
  #activity-start#activity-start.is-instructions .ak-body { font-size: 14px; line-height: 1.35; }
  #activity-start#activity-start.is-instructions .ak-first { font-size: 15px; padding: 6px 12px; }
  #activity-start#activity-start.is-instructions .ak-howto { margin-top: 8px; gap: 8px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #activity-start#activity-start.is-instructions .ak-section { flex: 1 1 0; }
  #activity-start#activity-start.is-instructions { padding: 8px 20px calc(8px + env(safe-area-inset-bottom)); }
  #activity-start#activity-start.is-instructions .ak-logo { max-height: 44px; }
  #activity-start#activity-start.is-instructions .ak-howto { margin-top: 8px; gap: 20px; }
  #activity-start#activity-start.is-instructions .ak-go { margin-top: 8px; min-height: 48px; width: min(100%, 320px); }
}
