/* hyd-bookcricket.css
   Book cricket v3 in a dialog (#hyd-bookcricket, behaviour in hyd-bookcricket.js). The window: the
   titlebar, a toolbar, an optional how-to-play panel, then the plum desk holding one of three screens:
   the notebook (the cover with the name written on its label, and beside it saving, the two modes
   and the leaderboard button); the game (a TV-style scoreboard; the open book whose sheets turn as
   the pages flip, and beside it this over, the three shots and the big flip-and-stop button, whose
   foot lines up with the book’s; under them the commentary and Riyal napping or yawning; the page
   bar); and the end over the owner’s evening sky (the result, the scorecard, the actions and the
   share box beside the best page). The level choice, the loading bar, the target and the
   leaderboard are a pop-up over the desk. On phones every screen is one column, with one page of the
   book; on phones held sideways the one page sits beside the board and the controls.
   Window chrome follows hyd-solitaire.css. Faces: the site’s own Wine Tahoma (Windows XP, the owner’s
   choice for the name and the scorecard) and Minar (the scoreboard and the result), declared here
   under the game’s own family names. Colours are the live site’s: plum panels, lilac and pink, cream
   paper. Gradients only on metal and glass controls; the ruled lines are paper. */

@font-face {
  font-family: 'Hyd Bookcricket Tahoma';
  src: url('fonts/WineTahoma-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hyd Bookcricket Minar';
  src: url('fonts/Minar-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

#hyd-bookcricket {
  --bc-plum: #2a2632;
  --bc-line: #4a4456;
  --bc-night: #15131b;
  --bc-lilac: #cbb7ff;
  --bc-pink: #fa77c5;
  --bc-silver: #e1e3ea;
  --bc-paper: #f7f2e6;
  --bc-ink: #2f3440;
  --bc-red: #b8312f;
  --bc-blue: #2b549e;
  --bc-xp: 'Hyd Bookcricket Tahoma', Tahoma, 'Lucida Grande', sans-serif;
  --bc-lcd: 'Hyd Bookcricket Minar', 'Lucida Grande', sans-serif;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(940px, calc(100vw - 24px));
  max-width: none;
  height: fit-content;
  max-height: calc(100dvh - 24px);
  padding: 3px;
  border: 1px solid;
  border-color: #f6f6f6 #5a5b60 #5a5b60 #f6f6f6;
  border-radius: 5px;
  background: #c6c6ca;
  color: #222;
  box-shadow: 0 14px 48px #0007;
  font:
    12px/1.4 'Lucida Grande',
    Tahoma,
    sans-serif;
  overflow: hidden;
  color-scheme: light;
}

#hyd-bookcricket::backdrop {
  background: #11131a70;
}

#hyd-bookcricket.is-shrinking::backdrop {
  background: transparent;
}

#hyd-bookcricket[open] {
  display: flex;
  flex-direction: column;
}

/* Script toggles hidden inside the dialog; !important stops any display rule from showing those
   parts anyway. */
#hyd-bookcricket [hidden] {
  display: none !important;
}

#hyd-bookcricket :is(button, input) {
  font: inherit;
}

#hyd-bookcricket button {
  cursor: pointer;
}

#hyd-bookcricket :is(button, input, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid #a8d4ff;
  outline-offset: 2px;
}

/* --- Titlebar and toolbar --- */
/* Three columns: the controls, the title, and a spacer as wide as the controls’ column, so the title
   stays in the middle with two discs (close, minimise) or three (the site’s zoom disc on laptops). */
#hyd-bookcricket .bc-titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 3px 8px;
  border: 1px solid #919297;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(#f0f0f1, #cbcbce 48%, #b6b6ba 50%, #d5d5d8);
  flex: none;
}

#hyd-bookcricket h2 {
  margin: 0;
  font:
    bold 12px/1.4 'Lucida Grande',
    Tahoma,
    sans-serif;
  color: #222;
  text-shadow: 0 1px #fff8;
}

#hyd-bookcricket .bc-window-controls {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
}

#hyd-bookcricket .bc-window-controls button {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #8e2b25;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #f28b80, #c9433a 70%);
  color: #5c1712;
  font-size: 14px;
  line-height: 1;
  box-shadow: inset 0 1px #fff8;
}

/* Minimise: the soft yellow disc of the desk windows’ minimise buttons. */
#hyd-bookcricket .bc-window-controls [data-bc-minimise] {
  border-color: #947844;
  background: radial-gradient(ellipse at 40% 15%, #fff9d9, #e9c774 55%, #bc994d);
  color: #624722;
}

#hyd-bookcricket .bc-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-bottom: 1px solid #64666b;
  background: #d9d9dc;
  flex: none;
}

#hyd-bookcricket .bc-toolbar button {
  min-height: 29px;
  padding: 4px 11px;
  border: 1px solid;
  border-color: #f6f6f7 #7f8188 #7f8188 #f6f6f7;
  border-radius: 3px;
  background: linear-gradient(#f7f7f8, #d9dadd);
  color: #202329;
  box-shadow: 0 1px #fff6;
  white-space: nowrap;
}

#hyd-bookcricket .bc-help {
  max-height: 30dvh;
  overflow: auto;
  padding: 4px 12px;
  border-bottom: 1px solid #a9aab0;
  background: #f1f1f2;
  flex: none;
}

#hyd-bookcricket .bc-help p {
  margin: 6px 0;
}

#hyd-bookcricket .bc-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Metal controls (the site’s Aqua buttons) --- */
#hyd-bookcricket .bc-metal {
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid #77787c;
  border-radius: 3px;
  background: linear-gradient(#fdfdfd, #d7d8dc 55%, #c9cacf);
  color: #222;
  box-shadow:
    inset 0 1px #fff,
    0 1px 1px #0002;
}

#hyd-bookcricket .bc-metal:disabled {
  background: #d6d6d9;
  color: #81838a;
  box-shadow: none;
  cursor: default;
}

#hyd-bookcricket .bc-metal small {
  display: block;
  font-size: 11px;
  line-height: 1.3;
  color: #4d4f57;
}

/* --- The desk --- */
#hyd-bookcricket .bc-desk {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid #919297;
  border-top: 0;
  background: var(--bc-plum);
  color: var(--bc-silver);
  flex: 1 1 auto;
}

/* --- The notebook: the name is written on the cover’s own label --- */
#hyd-bookcricket .bc-start {
  display: grid;
  grid-template-columns: auto minmax(0, 330px);
  justify-content: center;
  align-items: center;
  gap: 12px 44px;
  padding: 6px 0 4px;
}

#hyd-bookcricket .bc-notebook {
  position: relative;
  width: 320px;
}

#hyd-bookcricket .bc-start-side {
  display: grid;
  gap: 10px;
}

#hyd-bookcricket .bc-start-lead {
  margin: 0;
  font: 15px/1.4 var(--bc-xp);
}

#hyd-bookcricket .bc-leaders-button {
  margin-top: 10px;
}

/* The cover keeps its shape before it loads, so the label lies in place from the start. */
#hyd-bookcricket .bc-cover-art {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
}

/* The label lies exactly over the rendered one (measured on the 900 × 1200 cover), and is clear:
   the render prints the fields and their dotted lines, and the game writes on two of them, the
   name and the subject, in XP Tahoma. Line positions are measured from label.py (1100 × 680): the
   name line runs from 20.9% to 92.2% across, the subject line from 24.3%, their baselines at
   25.9% and 77.6% down. It is a label element, so a tap anywhere on it reaches the name field: the
   field alone is too small to touch. */
#hyd-bookcricket .bc-label {
  position: absolute;
  left: 21.1%;
  top: 22.1%;
  width: 61.9%;
  height: 28.7%;
  container-type: size;
  cursor: text;
}

/* One box for the field and the written name, so a saved name stays exactly where it was typed:
   1.5em tall, its baseline 1.145em down (Tahoma’s ascent and descent, centred). */
#hyd-bookcricket .bc-label :is(input, .bc-written) {
  position: absolute;
  right: 7.8%;
  display: block;
  height: 1.5em;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: #18245c;
  font: 7.6cqw/1.5em var(--bc-xp);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hyd-bookcricket .bc-label .bc-on-name {
  left: 22.2%;
  top: calc(25.9% - 1.145em);
}

#hyd-bookcricket .bc-label .bc-on-subject {
  left: 25.6%;
  top: calc(77.6% - 1.145em);
}

/* No highlight while typing (the owner’s call): the label stays paper and the caret shows where
   the name goes. Matches :focus-visible to outrank the window’s focus ring. */
#hyd-bookcricket .bc-label input,
#hyd-bookcricket .bc-label input:focus-visible {
  outline: none;
  caret-color: #18245c;
}

#hyd-bookcricket .bc-label input::placeholder {
  color: #8d93a8;
}

#hyd-bookcricket .bc-name-note {
  margin: 0;
  color: var(--bc-pink);
}

#hyd-bookcricket .bc-name-note:empty {
  display: none;
}

#hyd-bookcricket .bc-modes {
  display: grid;
  gap: 8px;
}

/* --- The game: the book on the left; beside it this over, the shots and the big button, whose foot
   lines up with the book’s; under them the commentary and Riyal --- */
#hyd-bookcricket .bc-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  grid-template-areas:
    'board board'
    'book over'
    'book shots'
    'book main'
    'comment teacher'
    'bar bar';
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 10px 14px;
}

#hyd-bookcricket .bc-board {
  grid-area: board;
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 12px;
  border: 1px solid var(--bc-line);
  border-radius: 3px;
  background: var(--bc-night);
  box-shadow: inset 0 1px 3px #000a;
}

/* A long name with no spaces wraps instead of pushing the score off the board. */
#hyd-bookcricket .bc-who {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

#hyd-bookcricket .bc-score {
  color: #fff;
  font: 30px/1 var(--bc-lcd);
}

#hyd-bookcricket .bc-overs {
  color: #c9c0d6;
  font: 15px/1 var(--bc-lcd);
}

#hyd-bookcricket .bc-overs small {
  margin-left: 3px;
  font-size: 11px;
}

#hyd-bookcricket .bc-chase {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--bc-line);
  color: var(--bc-lilac);
}

#hyd-bookcricket .bc-thisover {
  grid-area: over;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  margin: 0;
  color: #c9c0d6;
}

#hyd-bookcricket .bc-thisover i {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 12px;
  background: #3a3545;
  color: #fff;
  font: 12px/1 var(--bc-lcd);
  font-style: normal;
}

#hyd-bookcricket .bc-thisover i.bc-w {
  background: var(--bc-red);
}

#hyd-bookcricket .bc-thisover i.bc-big {
  background: #6b5aa6;
}

/* The open book: two pages, and a sheet that turns over the spine on each step. */
#hyd-bookcricket .bc-book {
  grid-area: book;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-self: start;
  perspective: 2600px;
  filter: drop-shadow(0 10px 14px #0007);
}

#hyd-bookcricket .bc-page {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 12px 12px 50px;
  background: var(--bc-paper);
  color: #2c2620;
}

#hyd-bookcricket .bc-left {
  border-radius: 4px 0 0 4px;
  box-shadow: inset -16px 0 20px -14px #3c281466;
}

#hyd-bookcricket .bc-right {
  border-radius: 0 4px 4px 0;
  box-shadow: inset 16px 0 20px -14px #3c281466;
}

#hyd-bookcricket .bc-page img,
#hyd-bookcricket .bc-big-no {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #d8cfbd;
  background: #ebe4d4;
}

#hyd-bookcricket .bc-page img {
  object-fit: cover;
}

#hyd-bookcricket .bc-big-no {
  display: grid;
  place-items: center;
  padding: 8px;
  color: #cfc4b0;
  font: 54px/1 var(--bc-lcd);
  text-align: center;
}

/* The left page’s number is the ball, so it is inked; the right page’s stays pencil-pale. */
#hyd-bookcricket .bc-left .bc-big-no {
  color: var(--bc-ink);
}

/* A page with no picture: its title, written on the paper. */
#hyd-bookcricket .bc-left.is-blank .bc-big-no {
  color: var(--bc-ink);
  font: 16px/1.4 var(--bc-xp);
}

#hyd-bookcricket .bc-page figcaption {
  min-height: 17px;
  margin-top: 6px;
  overflow: hidden;
  color: #5b5246;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hyd-bookcricket .bc-no {
  position: absolute;
  left: 14px;
  bottom: 8px;
  font: 34px/1 var(--bc-lcd);
}

#hyd-bookcricket .bc-right .bc-no {
  left: auto;
  right: 14px;
  color: #9b9182;
  font-size: 20px;
}

#hyd-bookcricket .bc-left.is-hit .bc-no {
  color: var(--bc-red);
}

#hyd-bookcricket .bc-stamp {
  position: absolute;
  left: 50%;
  top: 38%;
  padding: 6px 14px 2px;
  border: 4px solid var(--bc-red);
  border-radius: 8px;
  background: #f7f2e6e0;
  color: var(--bc-red);
  font: 40px/1 var(--bc-lcd);
  transform: translate(-50%, -50%) rotate(-11deg);
  animation: bc-stamp 180ms ease-out;
}

#hyd-bookcricket .bc-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  display: grid;
  place-items: end end;
  padding: 0 14px 8px;
  border-radius: 0 4px 4px 0;
  background: #efe8d8;
  box-shadow: inset 12px 0 18px -10px #3c281455;
  color: #9b9182;
  font: 20px/1 var(--bc-lcd);
  opacity: 0;
  pointer-events: none;
  transform-origin: 0 50%;
  --bc-turn-mid: -90deg;
  --bc-turn-to: -180deg;
}

#hyd-bookcricket .bc-sheet.is-stuck {
  background: #e6dcc6;
  box-shadow:
    inset 12px 0 18px -10px #3c281455,
    3px 0 0 #d8ccb2,
    6px 0 0 #cfc2a6;
}

/* Two names for one turn, so each step restarts it. The sheet stands upright at exactly half the
   turn, and the lifted page’s number goes then: its blank back lands on the left page, never a
   mirrored number. */
#hyd-bookcricket .bc-sheet[data-turn='a'] {
  animation: bc-turn-a var(--bc-turn, 150ms) both;
}

#hyd-bookcricket .bc-sheet[data-turn='b'] {
  animation: bc-turn-b var(--bc-turn, 150ms) both;
}

#hyd-bookcricket .bc-sheet[data-turn='a'] > span {
  animation: bc-face-a var(--bc-turn, 150ms) linear both;
}

#hyd-bookcricket .bc-sheet[data-turn='b'] > span {
  animation: bc-face-b var(--bc-turn, 150ms) linear both;
}

@keyframes bc-turn-a {
  from {
    opacity: 1;
    transform: rotateY(0deg);
    animation-timing-function: ease-in;
  }
  50% {
    transform: rotateY(var(--bc-turn-mid));
    animation-timing-function: ease-out;
  }
  92% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: rotateY(var(--bc-turn-to));
  }
}

@keyframes bc-turn-b {
  from {
    opacity: 1;
    transform: rotateY(0deg);
    animation-timing-function: ease-in;
  }
  50% {
    transform: rotateY(var(--bc-turn-mid));
    animation-timing-function: ease-out;
  }
  92% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: rotateY(var(--bc-turn-to));
  }
}

@keyframes bc-face-a {
  50%,
  to {
    visibility: hidden;
  }
}

@keyframes bc-face-b {
  50%,
  to {
    visibility: hidden;
  }
}

@keyframes bc-stamp {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-11deg) scale(1.5);
  }
}

/* Riyal on the desk: the sleep cell napping, the last yawn cell yawning, the sit cell awake. */
#hyd-bookcricket .bc-teacher {
  grid-area: teacher;
  display: flex;
  align-items: center;
  gap: 10px;
}

#hyd-bookcricket .bc-riyal {
  flex: none;
  width: 60px;
  height: 60px;
  background: url('assets/cat/riyal-atlas-v4.webp') 50% 100% / 300% 200% no-repeat;
  filter: drop-shadow(0 3px 3px #0008);
}

#hyd-bookcricket .bc-teacher[data-pose='sit'] .bc-riyal {
  background-position: 0 0;
}

#hyd-bookcricket .bc-teacher[data-pose='yawn'] .bc-riyal {
  background-image: url('assets/cat/riyal-yawn-v3.webp');
  background-position: 100% 100%;
}

/* Yawning is the moment to stop, so it is as pink as the stop button. */
#hyd-bookcricket .bc-teacher[data-pose='yawn'] [data-bc-teacher-label] {
  color: var(--bc-pink);
}

#hyd-bookcricket .bc-teacher[data-pose='sit'] [data-bc-teacher-label] {
  color: var(--bc-lilac);
}

/* The shots: each says its pace and its rule; the chosen one is lilac. */
#hyd-bookcricket .bc-shots {
  grid-area: shots;
  display: grid;
  gap: 6px;
}

/* The shot’s name and its pace on one line, its rule under them. */
#hyd-bookcricket .bc-shots button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 8px;
  padding: 5px 10px;
  font-size: 14px;
  text-align: left;
}

#hyd-bookcricket .bc-shots button small:not(.bc-pace) {
  grid-column: 1 / -1;
}

#hyd-bookcricket .bc-shots .bc-pace {
  color: #6b5aa6;
}

#hyd-bookcricket .bc-shots button[aria-pressed='true'] {
  border-color: #6b5aa6;
  background: var(--bc-lilac);
  box-shadow: inset 0 1px 3px #0003;
}

#hyd-bookcricket .bc-shots button[aria-pressed='true']:disabled {
  color: #3c3354;
}

/* touch-action: no double-tap zoom wait, so a phone sends the tap’s click at once and the window
   tells it from a click on its own. */
#hyd-bookcricket .bc-main {
  grid-area: main;
  align-self: end;
  min-height: 58px;
  font-size: 17px;
  touch-action: manipulation;
}

#hyd-bookcricket .bc-main.is-flipping {
  border-color: #a8346f;
  background: var(--bc-pink);
  color: #2b0a1d;
}

#hyd-bookcricket .bc-commentary {
  grid-area: comment;
  align-self: center;
  min-height: 21px;
  margin: 0;
  font: 15px/1.4 var(--bc-xp);
}

#hyd-bookcricket .bc-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #c9c0d6;
}

#hyd-bookcricket .bc-page-line {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hyd-bookcricket .bc-bar .bc-metal {
  flex: none;
  min-height: 34px;
  padding: 4px 11px;
}

/* --- The end, over the owner’s evening sky --- */
/* The result, the scorecard and the actions on the left; the best page on the right. */
#hyd-bookcricket .bc-end {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    'result best'
    'card best'
    'actions best'
    'note best';
  grid-template-rows: auto auto auto 1fr;
  align-items: start;
  gap: 12px 16px;
  padding: 16px;
  overflow: hidden;
  border-radius: 4px;
}

#hyd-bookcricket .bc-end-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}

#hyd-bookcricket .bc-end > :not(.bc-end-sky) {
  position: relative;
}

#hyd-bookcricket .bc-result {
  grid-area: result;
  margin: 0;
  color: #fff;
  font: 30px/1.15 var(--bc-lcd);
  text-shadow: 0 1px 3px #000a;
}

#hyd-bookcricket .bc-card {
  grid-area: card;
  padding: 0 12px 8px 14px;
  border-left: 2px solid #e2a6a6;
  border-radius: 2px;
  background: #fbfaf5 repeating-linear-gradient(#fbfaf5 0 21px, #b9cde3 21px 22px);
  box-shadow: 0 6px 12px #0006;
  color: var(--bc-ink);
  font: 13px/22px var(--bc-xp);
}

#hyd-bookcricket .bc-card p {
  margin: 0;
}

#hyd-bookcricket .bc-card-head {
  color: #1d2c6b;
}

#hyd-bookcricket .bc-card-no {
  display: inline-block;
  min-width: 36px;
  color: #6a6f7a;
}

#hyd-bookcricket .bc-card-over span:not(.bc-card-no) {
  display: inline-block;
  min-width: 24px;
  text-align: center;
}

#hyd-bookcricket .bc-card .bc-w {
  color: var(--bc-red);
}

#hyd-bookcricket .bc-card .bc-big {
  color: #6b5aa6;
}

#hyd-bookcricket .bc-best {
  grid-area: best;
  margin: 0;
  padding: 8px;
  border-radius: 3px;
  background: var(--bc-paper);
  box-shadow: 0 6px 12px #0006;
  color: #2c2620;
}

#hyd-bookcricket .bc-best img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid #d8cfbd;
}

#hyd-bookcricket .bc-best figcaption {
  margin-top: 6px;
  font-size: 12px;
}

#hyd-bookcricket .bc-end-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#hyd-bookcricket .bc-end-notes {
  grid-area: note;
  display: grid;
  align-content: start;
  gap: 6px;
}

#hyd-bookcricket :is(.bc-board-note, .bc-share-note) {
  margin: 0;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

#hyd-bookcricket :is(.bc-board-note, .bc-share-note):empty {
  display: none;
}

/* Shared text to copy by hand, where the browser offers no share sheet and no clipboard. */
#hyd-bookcricket .bc-share-text {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #8f9197;
  border-radius: 3px;
  background: #fbfaf5;
  color: var(--bc-ink);
  font: 13px/1.45 var(--bc-xp);
  resize: none;
}

/* --- Versus riyal: the pop-up over the desk --- */
/* Centred by auto margins, so a card taller than the desk scrolls from its top. */
#hyd-bookcricket .bc-pop {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  overflow: auto;
  padding: 16px;
  background: #11131acc;
}

#hyd-bookcricket .bc-pop-card {
  width: min(380px, 100%);
  margin: auto;
  overflow: hidden;
  border: 1px solid #5a5b60;
  border-radius: 6px;
  background: #ececee;
  box-shadow: 0 14px 40px #000a;
  color: #222;
}

#hyd-bookcricket .bc-pop-card h3 {
  margin: 0;
  padding: 9px 12px;
  border-bottom: 1px solid #919297;
  background: linear-gradient(#f0f0f1, #cbcbce 48%, #b6b6ba 50%, #d5d5d8);
  font:
    bold 12px 'Lucida Grande',
    Tahoma,
    sans-serif;
  text-align: center;
}

#hyd-bookcricket :is(.bc-levels, .bc-friend-panel, .bc-loading, .bc-target-card, .bc-leaders) {
  display: grid;
  gap: 8px;
  padding: 14px;
}

#hyd-bookcricket .bc-friend-panel input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid #2b549e;
  background: #f7f2e6;
  color: #2b549e;
  font: 18px/1.3 var(--bc-lcd);
}

#hyd-bookcricket .bc-friend-panel .bc-name-note {
  color: #b8312f;
}

#hyd-bookcricket .bc-levels button {
  text-align: left;
}

#hyd-bookcricket :is(.bc-loading, .bc-target-card) {
  justify-items: center;
  text-align: center;
}

#hyd-bookcricket :is(.bc-loading, .bc-target-card) p {
  margin: 0;
}

#hyd-bookcricket .bc-riyal-bat {
  width: 84px;
  height: 84px;
  background: url('assets/cat/riyal-play-v2.webp') 100% 0 / 200% 200% no-repeat;
  animation: bc-bat 0.8s steps(1) infinite;
}

@keyframes bc-bat {
  50% {
    background-position: 100% 100%;
  }
}

#hyd-bookcricket .bc-bar-track {
  display: block;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid #8f9197;
  border-radius: 5px;
  background: #d2d2d6;
}

#hyd-bookcricket .bc-bar-fill {
  display: block;
  width: var(--bc-load, 0%);
  height: 100%;
  background: linear-gradient(#e3d7ff, #9f88e6);
  transition: width 2.5s linear;
}

#hyd-bookcricket .bc-target-score {
  color: var(--bc-plum);
  font: 34px/1 var(--bc-lcd);
}

/* The leaderboard: the top ten on ruled paper, your posted score in lilac. */
#hyd-bookcricket .bc-leaders-table {
  width: 100%;
  border-collapse: collapse;
  background: #fbfaf5;
  box-shadow: 0 1px 3px #0003;
  font: 13px/24px var(--bc-xp);
}

#hyd-bookcricket .bc-leaders-table :is(th, td) {
  padding: 0 8px;
  border-bottom: 1px solid #b9cde3;
  text-align: left;
}

#hyd-bookcricket .bc-leaders-table th {
  color: #6a6f7a;
  font-weight: 400;
}

#hyd-bookcricket .bc-leaders-table :is(th, td):first-child {
  width: 28px;
  color: #6a6f7a;
  text-align: right;
}

#hyd-bookcricket .bc-leaders-table td:nth-child(2) {
  max-width: 0;
  overflow: hidden;
  color: #18245c;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hyd-bookcricket .bc-leaders-table :is(th, td):last-child {
  width: 48px;
  text-align: right;
}

#hyd-bookcricket .bc-leaders-table tr.is-you td {
  background: #e4d9ff;
}

#hyd-bookcricket .bc-leaders-state {
  margin: 0;
  color: #4d4f57;
}

#hyd-bookcricket .bc-leaders-state:empty {
  display: none;
}

/* Not the play grid’s main button: it takes no grid area here. */
#hyd-bookcricket .bc-target-card .bc-main {
  grid-area: auto;
  align-self: auto;
  width: 100%;
}

/* --- Short laptop windows --- */
@media (max-height: 720px) {
  #hyd-bookcricket .bc-desk {
    padding-block: 10px;
  }

  #hyd-bookcricket .bc-notebook {
    width: 260px;
  }
}

/* --- Phones: one column, one page --- */
@media (max-width: 620px) {
  #hyd-bookcricket {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    font-size: 11px;
  }

  #hyd-bookcricket .bc-titlebar {
    min-height: 40px;
  }

  #hyd-bookcricket .bc-window-controls button {
    width: 26px;
    height: 26px;
    font-size: 17px;
  }

  /* Close and minimise, 26 px discs 18 px apart, so their 44 px touch targets do not overlap. */
  #hyd-bookcricket .bc-window-controls {
    gap: 18px;
  }

  /* A 44px touch target around each small round button. */
  #hyd-bookcricket .bc-window-controls button::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  #hyd-bookcricket .bc-toolbar {
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px;
  }

  #hyd-bookcricket .bc-toolbar button {
    min-height: 44px;
    padding: 4px 9px;
  }

  #hyd-bookcricket .bc-desk {
    padding: 10px;
  }

  #hyd-bookcricket .bc-start {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 12px;
  }

  #hyd-bookcricket .bc-notebook {
    width: min(300px, 86%);
  }

  #hyd-bookcricket .bc-start-side {
    width: min(440px, 100%);
    text-align: center;
  }

  #hyd-bookcricket .bc-start-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #hyd-bookcricket .bc-start-side > :is(.bc-start-lead, .bc-name-note, [data-bc-save]),
  #hyd-bookcricket .bc-start-side:has([data-bc-modes][hidden]) .bc-leaders-button {
    grid-column: 1 / -1;
  }

  #hyd-bookcricket .bc-modes {
    display: contents;
  }

  #hyd-bookcricket .bc-leaders-button {
    margin-top: 0;
  }

  #hyd-bookcricket .bc-play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'board'
      'over'
      'book'
      'teacher'
      'shots'
      'main'
      'comment'
      'bar';
    grid-template-rows: none;
  }

  #hyd-bookcricket .bc-book {
    grid-template-columns: minmax(0, 1fr);
  }

  #hyd-bookcricket .bc-right {
    display: none;
  }

  #hyd-bookcricket .bc-left {
    border-radius: 4px;
  }

  /* One page: the sheet lifts off it and turns away until it is edge-on, so it never swings past
     the book. */
  #hyd-bookcricket .bc-sheet {
    left: 0;
    width: 100%;
    border-radius: 4px;
    --bc-turn-mid: -60deg;
    --bc-turn-to: -86deg;
  }

  /* Compact, so the scoreboard, the page, Riyal, the shots and stop fit on one screen. */
  #hyd-bookcricket .bc-play {
    gap: 8px;
  }

  #hyd-bookcricket .bc-board {
    padding: 6px 10px;
    gap: 2px 10px;
  }

  #hyd-bookcricket .bc-chase {
    padding-top: 4px;
  }

  #hyd-bookcricket .bc-page {
    padding: 8px 8px 34px;
  }

  #hyd-bookcricket .bc-page img,
  #hyd-bookcricket .bc-big-no {
    aspect-ratio: 16 / 9;
  }

  #hyd-bookcricket .bc-page figcaption {
    margin-top: 4px;
  }

  #hyd-bookcricket .bc-no {
    left: 10px;
    bottom: 5px;
    font-size: 26px;
  }

  #hyd-bookcricket .bc-riyal {
    width: 44px;
    height: 44px;
  }

  #hyd-bookcricket .bc-main {
    min-height: 52px;
  }

  #hyd-bookcricket .bc-shots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #hyd-bookcricket .bc-shots button {
    display: block;
    padding: 5px 4px;
    text-align: center;
  }

  #hyd-bookcricket .bc-score {
    font-size: 26px;
  }

  #hyd-bookcricket .bc-chase {
    flex-wrap: wrap;
  }

  #hyd-bookcricket .bc-end {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'result'
      'card'
      'best'
      'actions'
      'note';
    grid-template-rows: none;
  }

  #hyd-bookcricket .bc-result {
    font-size: 26px;
  }

  #hyd-bookcricket .bc-bar .bc-metal {
    min-height: 44px;
  }
}

/* --- Short phones (an iPhone SE): a wider, shorter page --- */
@media (max-width: 620px) and (max-height: 720px) {
  #hyd-bookcricket .bc-notebook {
    width: min(220px, 68%);
  }

  #hyd-bookcricket .bc-page img,
  #hyd-bookcricket .bc-big-no {
    aspect-ratio: 5 / 2;
  }

  #hyd-bookcricket .bc-big-no {
    font-size: 44px;
  }

  #hyd-bookcricket .bc-thisover {
    min-height: 22px;
  }
}

/* --- Phones held sideways: one page beside the board, Riyal, the shots and stop, all on one
   screen while the pages flip; the commentary and the page bar scroll in below --- */
@media (min-width: 621px) and (max-height: 500px) {
  #hyd-bookcricket {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
  }

  #hyd-bookcricket .bc-titlebar {
    min-height: 34px;
    padding-block: 2px;
  }

  /* Close and minimise, 24 px discs 20 px apart, so their 44 px touch targets do not overlap. */
  #hyd-bookcricket .bc-window-controls {
    gap: 20px;
  }

  /* A 44px touch target around each small round button. */
  #hyd-bookcricket .bc-window-controls button::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  #hyd-bookcricket .bc-toolbar {
    gap: 5px;
    padding: 4px 8px;
  }

  #hyd-bookcricket .bc-toolbar button {
    min-height: 44px;
  }

  #hyd-bookcricket .bc-desk {
    padding: 8px;
  }

  #hyd-bookcricket .bc-notebook {
    width: 190px;
  }

  #hyd-bookcricket .bc-play {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas:
      'book board'
      'book over'
      'book teacher'
      'book shots'
      'book main'
      'comment comment'
      'bar bar';
    grid-template-rows: auto auto auto auto 1fr auto auto;
    gap: 6px 10px;
  }

  #hyd-bookcricket .bc-board {
    padding: 4px 10px;
    gap: 2px 10px;
  }

  #hyd-bookcricket .bc-score {
    font-size: 22px;
  }

  #hyd-bookcricket .bc-chase {
    padding-top: 3px;
  }

  #hyd-bookcricket .bc-thisover {
    min-height: 22px;
  }

  #hyd-bookcricket .bc-book {
    grid-template-columns: minmax(0, 1fr);
  }

  #hyd-bookcricket .bc-right {
    display: none;
  }

  #hyd-bookcricket .bc-left {
    border-radius: 4px;
  }

  #hyd-bookcricket .bc-sheet {
    left: 0;
    width: 100%;
    border-radius: 4px;
    --bc-turn-mid: -60deg;
    --bc-turn-to: -86deg;
  }

  #hyd-bookcricket .bc-page {
    padding: 6px 6px 30px;
  }

  #hyd-bookcricket .bc-page img,
  #hyd-bookcricket .bc-big-no {
    height: 150px;
    aspect-ratio: auto;
  }

  #hyd-bookcricket .bc-big-no {
    font-size: 44px;
  }

  #hyd-bookcricket .bc-no {
    left: 8px;
    bottom: 4px;
    font-size: 24px;
  }

  #hyd-bookcricket .bc-riyal {
    width: 36px;
    height: 36px;
  }

  #hyd-bookcricket .bc-shots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  #hyd-bookcricket .bc-shots button {
    display: block;
    padding: 3px 4px;
    font-size: 13px;
    text-align: center;
  }

  #hyd-bookcricket .bc-shots button small {
    font-size: 10px;
    line-height: 1.2;
  }

  #hyd-bookcricket .bc-main {
    min-height: 48px;
  }

  #hyd-bookcricket .bc-best img {
    height: 150px;
    aspect-ratio: auto;
  }

  #hyd-bookcricket .bc-result {
    font-size: 24px;
  }

  #hyd-bookcricket .bc-bar .bc-metal {
    min-height: 44px;
  }
}

/* --- Touch screens wider than a phone (tablets either way up, touch laptops): close and minimise keep their 24 px
   discs with 44 px targets 20 px apart, as on phones, so a tap meant for minimise never lands on close. The title
   bar is 44 px tall so the targets stay inside the window --- */
@media (any-pointer: coarse) and (min-width: 621px) and (min-height: 501px) {
  #hyd-bookcricket .bc-titlebar {
    min-height: 44px;
  }

  #hyd-bookcricket .bc-window-controls {
    gap: 20px;
  }

  #hyd-bookcricket .bc-window-controls > :is([data-bc-close], [data-bc-minimise])::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }
}

/* Reduced motion, from the system or the site’s animations switch: the sheets do not turn, the
   stamp lands without a thump and the loading bar jumps. The script also skips the turn and the
   loading wait in both cases. */
@media (prefers-reduced-motion: reduce) {
  #hyd-bookcricket * {
    animation: none !important;
    transition: none !important;
  }
}

body.motion-off #hyd-bookcricket * {
  animation: none !important;
  transition: none !important;
}

/* --- Celebrations --- */
#hyd-bookcricket .bc-play,
#hyd-bookcricket .bc-end,
#hyd-bookcricket .bc-board {
  position: relative;
}

#hyd-bookcricket .bc-fx-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}

/* -- red pencil: the loop round a number, the line through an out -- */
#hyd-bookcricket .bc-fx-ring,
#hyd-bookcricket .bc-fx-strike {
  position: absolute;
  overflow: visible;
  fill: none;
  stroke: var(--bc-red);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#hyd-bookcricket .bc-fx-ring path,
#hyd-bookcricket .bc-fx-strike path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: bc-fx-draw 300ms ease-out forwards;
}

#hyd-bookcricket .bc-fx-strike path {
  stroke-width: 3.4;
  animation-duration: 200ms;
}

@keyframes bc-fx-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* -- the words: big Minar letters with an ink outline and a hard shadow -- */
#hyd-bookcricket .bc-fx-word {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font: 68px/1 var(--bc-lcd);
  letter-spacing: 0.02em;
  color: var(--bc-lilac);
  text-shadow:
    -2px -2px 0 var(--bc-night), 2px -2px 0 var(--bc-night), -2px 2px 0 var(--bc-night), 2px 2px 0 var(--bc-night),
    0 -2px 0 var(--bc-night), 0 2px 0 var(--bc-night), -2px 0 0 var(--bc-night), 2px 0 0 var(--bc-night),
    6px 6px 0 var(--bc-night);
  animation: bc-fx-pop 220ms cubic-bezier(.2, .8, .5, 1) both;
}

#hyd-bookcricket .bc-fx-w4 {
  font-size: 40px;
  color: var(--bc-paper);
}

#hyd-bookcricket .bc-fx-w8 {
  font-size: 74px;
  color: var(--bc-pink);
}

#hyd-bookcricket .bc-fx-w12 {
  font-size: 80px;
  color: var(--bc-pink);
}

#hyd-bookcricket .bc-fx-w16 {
  font-size: 84px;
  color: var(--bc-paper);
  text-shadow:
    -2px -2px 0 var(--bc-night), 2px -2px 0 var(--bc-night), -2px 2px 0 var(--bc-night), 2px 2px 0 var(--bc-night),
    0 -2px 0 var(--bc-night), 0 2px 0 var(--bc-night), -2px 0 0 var(--bc-night), 2px 0 0 var(--bc-night),
    5px 5px 0 var(--bc-pink), 8px 8px 0 var(--bc-night);
}

#hyd-bookcricket .bc-fx-word.is-gone {
  animation: bc-fx-out 200ms ease-in forwards;
}

#hyd-bookcricket .bc-fx-word.is-still {
  animation: none;
}

@keyframes bc-fx-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-8deg);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(2deg);
  }
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes bc-fx-out {
  to {
    opacity: 0;
    transform: translate(-50%, -80%) scale(0.85) rotate(-2deg);
  }
}

/* -- eight: the page’s own number lifts off the paper -- */
#hyd-bookcricket .bc-fx-lift {
  position: absolute;
  color: var(--bc-red);
  font: 34px/1 var(--bc-lcd);
  text-shadow: 3px 3px 0 var(--bc-night);
}

/* -- the score ticks over as the runs land -- */
#hyd-bookcricket .bc-fx-roll {
  display: inline-block;
  animation: bc-fx-roll 260ms ease-out;
}

@keyframes bc-fx-roll {
  from {
    opacity: 0.15;
    transform: translateY(55%);
  }
}

/* -- the book jolts, a few pixels, for a slog or a wicket -- */
#hyd-bookcricket .bc-book.bc-fx-jolt {
  animation: bc-fx-jolt 220ms steps(1) both;
}

@keyframes bc-fx-jolt {
  0% { transform: translate(0, 3px); }
  25% { transform: translate(-3px, -1px); }
  50% { transform: translate(3px, 1px); }
  75% { transform: translate(-1px, 0); }
  100% { transform: none; }
}

/* -- caught by riyal: her paw, in ink, on the page -- */
#hyd-bookcricket .bc-fx-paw {
  position: absolute;
  color: var(--bc-blue);
  transform: translate(-50%, -50%) rotate(18deg);
  animation: bc-fx-paw 180ms ease-out both;
}

@keyframes bc-fx-paw {
  from {
    opacity: 0;
    transform: translate(-50%, -90%) rotate(18deg) scale(1.5);
  }
}

/* -- a golden duck waddles along the foot of the book -- */
#hyd-bookcricket .bc-fx-duck {
  position: absolute;
  left: -90px;
  bottom: 2px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  animation: bc-fx-walk 2200ms linear forwards;
}

#hyd-bookcricket .bc-fx-duck span {
  margin-bottom: 8px;
  color: var(--bc-blue);
  font: 14px/1 var(--bc-xp);
}

#hyd-bookcricket .bc-fx-duck-art {
  animation: bc-fx-waddle 260ms steps(1) infinite;
}

#hyd-bookcricket .bc-fx-duck.is-still {
  left: 30%;
  animation: none;
}

#hyd-bookcricket .bc-fx-duck.is-still .bc-fx-duck-art {
  animation: none;
}

@keyframes bc-fx-walk {
  to {
    transform: translateX(var(--bc-fx-walk, 900px));
  }
}

@keyframes bc-fx-waddle {
  0% { transform: rotate(-6deg) translateY(0); }
  50% { transform: rotate(6deg) translateY(-2px); }
}

/* -- the scoreboard’s sting: a flat band wipes across with a line, then wipes away -- */
#hyd-bookcricket .bc-fx-band {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-items: center;
  padding: 0 16px;
  border-radius: inherit;
  background: var(--bc-lilac);
  color: var(--bc-night);
  font: 24px/1 var(--bc-lcd);
  clip-path: inset(0 100% 0 0);
  animation: bc-fx-wipe-in 260ms ease-out forwards;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#hyd-bookcricket .bc-fx-band-pink {
  background: var(--bc-pink);
}

#hyd-bookcricket .bc-fx-band span.is-new {
  animation: bc-fx-line 200ms ease-out;
}

#hyd-bookcricket .bc-fx-band.is-gone {
  animation: bc-fx-wipe-out 260ms ease-in forwards;
}

@keyframes bc-fx-wipe-in {
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes bc-fx-wipe-out {
  from {
    clip-path: inset(0 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 100%);
  }
}

@keyframes bc-fx-line {
  from {
    opacity: 0;
    transform: translateY(40%);
  }
}

/* -- a pencil star by the name for each milestone, kept for the innings -- */
#hyd-bookcricket .bc-fx-star {
  position: absolute;
  z-index: 2;
  overflow: visible;
  fill: none;
  stroke: var(--bc-pink);
  stroke-width: 2;
  stroke-linejoin: round;
}

#hyd-bookcricket .bc-fx-star path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: bc-fx-draw 500ms ease-out forwards;
}

/* -- crackers: square pixels on a small canvas, never in the way of a press -- */
#hyd-bookcricket .bc-fx-canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  pointer-events: none;
  image-rendering: pixelated;
}

/* -- Riyal’s yawn in its drawn frames: small, wide, full -- */
#hyd-bookcricket .bc-teacher[data-pose='yawn'] .bc-riyal {
  animation: bc-fx-yawn 600ms steps(1) forwards;
}

@keyframes bc-fx-yawn {
  0% { background-position: 100% 0; }
  33% { background-position: 0 100%; }
  66% { background-position: 50% 100%; }
  100% { background-position: 100% 100%; }
}

/* -- the end: the result drops in, the scorecard writes itself, the best page lands like a print -- */
#hyd-bookcricket .bc-end.bc-fx-enter .bc-result {
  animation: bc-fx-drop 360ms cubic-bezier(.2, 1.4, .5, 1) both;
}

#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p {
  animation: bc-fx-write 260ms ease-out both;
}

#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(1) { animation-delay: 200ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(2) { animation-delay: 380ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(3) { animation-delay: 560ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(4) { animation-delay: 740ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(5) { animation-delay: 920ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(6) { animation-delay: 1100ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(7) { animation-delay: 1280ms; }
#hyd-bookcricket .bc-end.bc-fx-enter .bc-card p:nth-child(8) { animation-delay: 1460ms; }

#hyd-bookcricket .bc-end.bc-fx-enter .bc-best {
  animation: bc-fx-print 520ms 300ms cubic-bezier(.2, 1.2, .5, 1) both;
}

@keyframes bc-fx-drop {
  from {
    opacity: 0;
    transform: translateY(-24px);
  }
}

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

@keyframes bc-fx-print {
  from {
    opacity: 0;
    transform: translateY(30px) rotate(-6deg);
  }
}

#hyd-bookcricket .bc-fx-end-riyal {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  color: var(--bc-paper);
  font: 13px/1.3 var(--bc-xp);
  text-shadow: 1px 1px 0 var(--bc-night);
}

#hyd-bookcricket .bc-fx-end-cat {
  flex: none;
  width: 84px;
  height: 84px;
  background: url('assets/cat/riyal-atlas-v4.webp') no-repeat;
  background-size: 300% 200%;

}

#hyd-bookcricket .bc-fx-end-cat[data-atlas='yawn'] {
  background-image: url('assets/cat/riyal-yawn-v3.webp');
  background-size: 300% 200%;
}

#hyd-bookcricket .bc-fx-end-cat[data-atlas='play'] {
  background-image: url('assets/cat/riyal-play-v2.webp');
  background-size: 200% 200%;
}

/* Phones: one page, so the words are smaller and sit over the picture’s lower half. */
@media (max-width: 620px) {
  #hyd-bookcricket .bc-fx-word { font-size: 50px; }
  #hyd-bookcricket .bc-fx-w4 { font-size: 32px; }
  #hyd-bookcricket .bc-fx-w12,
  #hyd-bookcricket .bc-fx-w16 { font-size: 56px; }
  #hyd-bookcricket .bc-fx-band { font-size: 17px; }
}


/* A supplied still preference also stops nested pencil, star, band and duck animations. */
#hyd-bookcricket .is-still:is([class*='bc-fx-']),
#hyd-bookcricket .is-still:is([class*='bc-fx-']) * {
  animation: none !important;
  transition: none !important;
  stroke-dashoffset: 0;
}
#hyd-bookcricket .bc-fx-band.is-still { clip-path: inset(0); }
#hyd-bookcricket .bc-fx-band { pointer-events: none; box-sizing: border-box; }
#hyd-bookcricket .bc-fx-band span { overflow: hidden; text-overflow: ellipsis; }
@media (max-height: 500px) and (min-width: 621px) {
  #hyd-bookcricket .bc-fx-word { font-size: 48px; }
  #hyd-bookcricket .bc-fx-w4 { font-size: 32px; }
  #hyd-bookcricket .bc-fx-band { font-size: 17px; }
}
/* CSS motion switches leave the pencil and band at their final frame too. */
@media (prefers-reduced-motion: reduce) {
  #hyd-bookcricket :is(.bc-fx-ring, .bc-fx-strike, .bc-fx-star) path { stroke-dashoffset: 0; }
  #hyd-bookcricket .bc-fx-band { clip-path: inset(0); }
}
body.motion-off #hyd-bookcricket :is(.bc-fx-ring, .bc-fx-strike, .bc-fx-star) path { stroke-dashoffset: 0; }
body.motion-off #hyd-bookcricket .bc-fx-band { clip-path: inset(0); }

/* The end’s content rule is relative; the crackers must stay out of its grid layout. */
#hyd-bookcricket .bc-end > .bc-fx-canvas { position: absolute; }
#hyd-bookcricket .bc-end:has(> .bc-fx-end-riyal) {
  grid-template-areas:
    'result best'
    'card best'
    'actions best'
    'riyal best'
    'note best';
  grid-template-rows: auto;
}
#hyd-bookcricket .bc-fx-end-riyal { grid-area: riyal; }
@media (max-width: 620px) {
  #hyd-bookcricket .bc-end:has(> .bc-fx-end-riyal) {
    grid-template-areas: 'result' 'card' 'best' 'actions' 'riyal' 'note';
  }
}
@media (min-width: 621px) and (max-height: 500px) {
  #hyd-bookcricket .bc-end:has(> .bc-fx-end-riyal) { gap: 6px 16px; padding: 10px 16px; }
  #hyd-bookcricket .bc-fx-end-riyal { margin-top: 0; }
  #hyd-bookcricket .bc-fx-end-cat { width: 44px; height: 44px; }
}

/* the still duck and paw share one page without covering the label or each other. */
@media (max-width: 620px), (min-width: 621px) and (max-height: 500px) {
  #hyd-bookcricket .bc-fx-duck.is-still {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }
  #hyd-bookcricket .bc-fx-duck.is-still span { margin-bottom: 0; }
  #hyd-bookcricket .bc-fx-paw.is-still { transform: translate(-50%, -100%) rotate(18deg); }
}

/* --- Aqua title bar (owner, 21 oct: the same bar as flyovers & u-turns, option B). The site’s blue Aqua glass under
   faint pinstripes, a rim of the same blue, the title in dark blue ink over a white emboss, centred; red and yellow
   round discs. Copied from hyd-flyovers.css and scoped to this window. On a phone the bar is slim (36 px) and each
   disc is drawn at 24 px in a 44 × 44 target (the rest of the target is a transparent border). --- */
#hyd-bookcricket .bc-titlebar {
  border: 0;
  border-bottom: 1px solid #6896ba;
  background:
    repeating-linear-gradient(0deg, #ffffff17 0 1px, #68686809 1px 2px),
    linear-gradient(#e3f5ff, #aed8f7 49%, #78b5e2 50%, #a2d2f5);
  box-shadow: inset 0 1px #fff;
  color: #143f62;
  gap: 10px;
  min-height: 32px;
}
#hyd-bookcricket .bc-titlebar h2 {
  color: #143f62;
  font: 700 12px/1.2 var(--desktop-font, 'Lucida Grande', Tahoma, sans-serif);
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px #fff8;
}
#hyd-bookcricket .bc-window-controls [data-bc-close] {
  box-sizing: border-box;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid #aa514a;
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 15%, #ffdcd4 0%, #ed867a 45%, #cf645c 74%, #f6a499 100%);
  color: #792f2a;
  box-shadow: inset 0 1px #ffece7, 0 1px #fffc;
  font: 16px/1 Arial, sans-serif;
  text-shadow: none;
}
#hyd-bookcricket .bc-window-controls [data-bc-minimise] {
  box-sizing: border-box;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid #a17a2b;
  border-radius: 50%;
  color: #6b4a0a;
  background: radial-gradient(ellipse at 40% 15%, #fff3c0, #f2ce65 45%, #d7a637 74%, #ffe292);
  box-shadow: inset 0 1px #fff3c0, 0 1px #fffc;
  font: 16px/1 Arial, sans-serif;
  text-shadow: none;
}

#hyd-bookcricket .bc-window-controls {
  gap: 4px;
}

@media (max-width: 620px), (pointer: coarse) and (max-height: 450px) {
  #hyd-bookcricket .bc-titlebar {
    position: relative;
    z-index: 1;
    min-height: 36px;
    padding: 0 4px;
  }
  #hyd-bookcricket .bc-window-controls {
    gap: 0;
    margin: 0 0 -8px;
  }
  #hyd-bookcricket .bc-window-controls button,
  #hyd-bookcricket .bc-window-controls [data-bc-close],
  #hyd-bookcricket .bc-window-controls [data-bc-minimise] {
    box-sizing: border-box;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    border-width: 6px 10px 14px;
    border-color: transparent;
    border-radius: 22px / 18px 18px 26px 26px;
    background-clip: padding-box;
    box-shadow:
      inset 0 0 0 1px #aa514a,
      inset 0 2px #ffece7;
    font-size: 15px;
  }
  #hyd-bookcricket .bc-window-controls [data-bc-minimise] {
    border-color: transparent;
    background-clip: padding-box;
    box-shadow:
      inset 0 0 0 1px #a17a2b,
      inset 0 2px #fff3c0;
  }
  #hyd-bookcricket .bc-window-controls button::after {
    content: none;
  }
  #hyd-bookcricket .bc-window-controls > :is([data-bc-close], [data-bc-minimise])::after {
    content: none;
  }
  #hyd-bookcricket .bc-titlebar h2 {
    font-size: 15px;
  }
}
