.board,
.blank,
.clock {
  /* A cell is 2.5rem on a desktop; on a phone the cells share the width
     of the screen, less the margins of the page and the column of labels */
  --label: 1.5rem;
  --cell: min(2.5rem, (100vw - 2rem - var(--label)) / var(--size));
}

/* The place of the cells before Start and in a pause */
.blank {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--label);
  width: calc(var(--size) * var(--cell));
  aspect-ratio: 1;
  background: #eee;
  border: 1px dashed #999;
  box-sizing: border-box;
}

.blank button {
  font-size: 1.25rem;
  padding: 0.5rem 1.5rem;
}

.board {
  display: grid;
  /* A column and a row of labels, then the cells; the edge cells draw
     the outer border themselves, so the labels stay outside it */
  grid-template-columns: var(--label) repeat(var(--size), var(--cell));
  grid-template-rows: var(--label) repeat(var(--size), var(--cell));
  gap: 0;
  width: max-content;
  /* A drag with the mouse selects no text; Safari knows the prefix only */
  -webkit-user-select: none;
  user-select: none;
  /* A double tap on the labels must not zoom the page; the cells below
     take no touch gesture at all */
  touch-action: manipulation;
}

.label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #666;
}

.cell {
  /* A flex box centers the glyph regardless of the font metrics */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #999;
  padding: 0;
  font-size: calc(var(--cell) * 0.6);
  line-height: 1;
  cursor: pointer;
  background: hsl(calc(var(--zone) * 360 / var(--size)) 60% 85%);
  /* A finger dragged from a cell marks the cells, it does not scroll the
     page; the labels around the board still do */
  touch-action: none;
}

/* The cell the keys work on, above its neighbours so the ring is whole */
.cell:focus-visible {
  outline: 3px solid #1d5fd1;
  outline-offset: 1px;
  z-index: 1;
}

.cell.border-top { border-top: 3px solid #222; }
.cell.border-right { border-right: 3px solid #222; }
.cell.border-bottom { border-bottom: 3px solid #222; }
.cell.border-left { border-left: 3px solid #222; }

.cell.queen::after { content: "\265B"; }
/* A unit with two queens or more, or two queens touching: red hatching
   over the zone colour, the marks on top of it */
.cell.conflict {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(208, 52, 44, 0.4) 0 3px,
    transparent 3px 9px
  );
}
/* A cross drawn with CSS: a glyph would sit where its font puts it */
.cell.empty::after {
  content: "";
  width: 25%;
  height: 25%;
  opacity: 0.35;
  background:
    linear-gradient(45deg, transparent calc(50% - 1px), #000 0, #000 calc(50% + 1px), transparent 0),
    linear-gradient(-45deg, transparent calc(50% - 1px), #000 0, #000 calc(50% + 1px), transparent 0);
}

.status {
  min-height: 1.5rem;
  font-weight: bold;
}

/* The evidence of a hint is what to look at, the target is what to do */
.cell.hint-evidence {
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.45);
}

.cell.hint-target {
  outline: 3px solid #d0342c;
  outline-offset: -4px;
}

/* The number of a zone, in the corner of its first cell */
.zone-label {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 0.6rem;
  line-height: 1;
  color: rgba(0, 0, 0, 0.55);
}

/* The clock over the middle of the cells, the Pause button at their
   right edge, the link that hides the clock at their left one */
.clock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-left: var(--label);
  width: calc(var(--size) * var(--cell));
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.clock .reading {
  grid-column: 2;
}

.clock .link {
  grid-column: 1;
  justify-self: start;
  /* Small, to fit beside the clock of a small board on a phone */
  font-size: 0.8rem;
}

/* Hidden by the player, the clock keeps its place and its count */
.clock.quiet .reading {
  visibility: hidden;
}

.clock form {
  grid-column: 3;
  justify-self: end;
}

/* The best times, below the board once solved */
.leaderboard table {
  border-collapse: collapse;
}

.leaderboard td {
  padding: 0.15rem 1rem 0.15rem 0;
}

.leaderboard td:first-child,
.leaderboard td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leaderboard .mine {
  font-weight: bold;
}

/* Invitations and two-player results, below the board. */
.challenges {
  overflow-wrap: anywhere;
}

.challenges table {
  border-collapse: collapse;
}

.challenges th,
.challenges td {
  padding: 0.15rem 1rem 0.15rem 0;
  text-align: left;
}

.challenges .mine {
  font-weight: bold;
}

.challenge-error {
  color: #a00;
}
