/* Game pages, levels pages and the answers page. */

.game .wrap, .wrap.game { max-width: 44rem; }

/* top bar: back, the game's name, help */
.gbar { display: flex; align-items: center; min-height: 3rem; padding: 0 min(0.375rem, 2vw); gap: 0.125rem; }
.gtitle { flex: 1; min-width: 0; display: flex; align-items: center; gap: min(0.625rem, 3vw); }
/* however large the text is set, the three buttons leave room for the name on a 320px phone */
.gbar .iconbtn { width: min(2.75rem, 14vw); }
.gbar .badge.sm { width: min(1.75rem, 9vw); height: min(1.75rem, 9vw); }
/* the name never outgrows the bar, however large the text is set: a one-word name cannot wrap */
.gtitle h1 { font: 500 min(1.375rem, 6.9vw)/1.1 var(--serif); letter-spacing: -0.01em; }

/* second row: Today / Levels on the left, the status on the right */
.gsub {
  display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between; gap: 0 1rem; min-height: 2.75rem;
  padding: 0 var(--gutter); border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
}
.tabs { display: flex; gap: 1.25rem; }
.tab {
  display: flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.0625rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent; font: 600 0.96875rem/1 var(--sans); color: var(--stone); text-decoration: none;
}
.tab.on { color: var(--ink); border-bottom-color: var(--c); }
/* The status never asks for more room than the screen has: its parts wrap, and with very large text
   it takes a line of its own under the tabs. */
.stat { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.25rem 0.625rem; min-width: 0; max-width: 100%; min-height: 2.75rem; font: 600 0.9375rem/1.15 var(--sans); color: var(--stone); font-variant-numeric: tabular-nums; }
.stat b { color: var(--ink); font-weight: 600; }

.caption { min-height: 2.125rem; display: flex; flex-wrap: wrap; align-items: center; padding: 0 var(--gutter); font: italic 400 1.09375rem/1.2 var(--serif); color: var(--stone); }
.caption b { font-style: normal; font-weight: 500; color: var(--ink); margin-left: 0.375rem; }
.caption:empty { display: none; }
/* While the board loads ("Loading the puzzle…"), what the script will fill keeps its room, so that
   what follows is painted at once where it will stay (a layout shift otherwise):
   - the status holds the shape the script gives it, written in by the page and never seen, so that
     its row is the height it will be (beside the tabs, or under them on a narrow phone or with
     large text); the script's own status takes its place;
   - the empty caption keeps its line;
   - the board about the room its puzzle will take (each game's stylesheet sets --board-wait,
     measured on the drawn boards at the usual text size);
   - the buttons under it their one row, in rem so that it grows with the text.
   A script that cannot be fetched turns the line into a notice, and the room is given back. Where
   scripts do not run there is nothing to wait for: no room is kept, and the loading line goes. */
.stat > .wait { visibility: hidden; }
#main:has(> #board > .notice) .stat > .wait { display: none; }
#main:has(> #board > .loading) > .caption:empty { display: flex; }
#main:has(> #board > .loading) > #board { min-height: var(--board-wait, 0px); }
#main:has(> #board > .loading) > #actions { display: flex; min-height: 4.875rem; }   /* shown though still empty */
@media (scripting: none) {
  #main:has(> #board > .loading) > .caption:empty, #main:has(> #board > .loading) > #actions, #board > .loading, .stat > .wait { display: none; }
  #main:has(> #board > .loading) > #board { min-height: 0; }
  #decorate-offer { display: none; }
}

.board { padding: 0 var(--gutter); }
.board svg { display: block; width: 100%; }
.loading, .board .notice { padding: 2.5rem 0; text-align: center; color: var(--stone); }

.actions { display: flex; flex-wrap: wrap; gap: 0.625rem; padding: 0.875rem var(--gutter) 1rem; }
.actions:empty { display: none; }
.actions .btn { flex: 1 1 auto; padding: 0 0.5rem; }

.lead { padding: 1.25rem var(--gutter) 0; color: var(--stone); }

/* the solved screen */
.solved { padding: 1.625rem var(--gutter) 0; }
.solved:focus { outline: none; }

/* levels page */
.track { padding: 1.5rem var(--gutter) 0; }
.track h2 { font: 500 1.5rem/1.15 var(--serif); margin-bottom: 0.75rem; }
.track-note { margin: -0.25rem 0 0.875rem; color: var(--stone); }
.levels { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); gap: 0.5rem; }
.level {
  display: grid; place-items: center; min-height: 2.75rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet);
  font: 600 1rem/1 var(--sans); text-decoration: none; font-variant-numeric: tabular-nums;
}
.level:hover { border-color: var(--ink); }
.level.done { background: var(--c); border-color: var(--c); color: #fff; }
/* played to the end without being solved: a dashed edge, so it is told apart from one not yet tried */
.level.ended, .prose .dates a.date.ended { border-style: dashed; border-color: var(--stone); color: var(--stone); }
.level { position: relative; }
.level .ic { position: absolute; top: 2px; right: 2px; width: 0.6875rem; height: 0.6875rem; stroke-width: 3.2; }

/* earlier puzzles by month (shell.js drawEarlier): a month's name is its own 44px-tall button to open or close it */
.prose details.month summary { cursor: pointer; padding: 0.625rem 0; font: 600 1rem/1.5rem var(--sans); }

/* earlier puzzles: one chip for each past day, filled once it is solved */
.prose .dates { list-style: none; padding: 0; margin: 0.75rem 0 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.5rem; }
.prose .dates li { margin: 0; }
.prose .dates a.date {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem; min-height: 2.75rem;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet);
  font: 600 1rem/1 var(--sans); text-decoration: none; font-variant-numeric: tabular-nums;
}
.prose .dates a.date:hover { border-color: var(--ink); }
.prose .dates a.date.done { background: var(--c); border-color: var(--c); color: #fff; }
.date .ic { width: 1rem; height: 1rem; stroke-width: 2.4; }

/* answers lookup */
.lookup { margin: 1.25rem 0 1.5rem; }
.lookup label { display: block; font: 600 1rem/1.3 var(--sans); margin-bottom: 0.375rem; }
.lookup-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.lookup input {
  flex: 1; min-width: min(11rem, 100%); min-height: 3rem; padding: 0 0.875rem; border: 1px solid var(--stone); border-radius: 6px; background: var(--sheet);
  font: 600 1.125rem/1 var(--sans); letter-spacing: 0.04em; color: var(--ink); text-transform: uppercase;
}
.lookup input::placeholder { color: #6F6C65; font-weight: 400; }

/* On a wide screen the game keeps one 36rem column in the middle. The rail beside it appears
   only when it holds an advertisement; the bar, the game and the footer then share the left
   column, so everything stays in line. An empty rail takes no space. */
.go-print { padding: 0 var(--gutter); margin: 0.5rem 0 0; }
.go-print a { display: inline-block; padding: 0.6875rem 0; font-weight: 600; text-decoration: underline; }   /* a line of its own, 44px tall to press */
.rail { display: none; }
@media (min-width: 64rem) {
  .wrap.game { max-width: 36rem; }
  .wrap.game:has(.rail .ad:not([hidden])) { max-width: calc(36rem + 150px + 300px); }
  .wrap.game:has(.rail .ad:not([hidden])) .game-layout { display: grid; grid-template-columns: minmax(0, 36rem) 300px; column-gap: 150px; }   /* AdSense: at least 150px from a game */
  .wrap.game:has(.rail .ad:not([hidden])) .rail { display: block; padding-top: 3rem; }
  .wrap.game:has(.rail .ad:not([hidden])) > .gbar { max-width: 36rem; }
  .wrap.game:has(.rail .ad:not([hidden])) > .foot { max-width: calc(36rem - 2 * var(--gutter)); }
  .rail .ad { margin: 0; min-height: 600px; position: sticky; top: 1rem; }
  .rail .ad.live ins { min-height: 600px; }
}

/* status: lives, progress, clock */
/* the hearts are signs, not text: they stop growing at 24px however large the text is set */
.lives { display: inline-flex; gap: 0.1875rem; }
.lives .ic { width: min(1.1875rem, 24px); height: min(1.1875rem, 24px); stroke: var(--c); fill: var(--c); }
.lives .ic.lost { fill: none; stroke: var(--rule); }
.time b { color: var(--ink); }
.caption .which { font-style: normal; font-family: var(--sans); font-size: 0.9375rem; font-weight: 600; color: var(--ink); margin-right: 0.625rem; }

/* notices in the board area */
.board .notice { padding: 2.5rem 0 1rem; }
.notice-action { text-align: center; padding-bottom: 2rem; }
.fail { flex: 1; align-self: center; font: 600 1.0625rem/1.2 var(--sans); }

/* the solved screen */
.solved h2 { font: 500 2.875rem/1 var(--serif); letter-spacing: -0.02em; }
.solved h2:focus { outline: none; }
.solved-sub { color: var(--stone); margin-top: 0.5rem; }
.trio { display: flex; margin: 1.375rem 0 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.trio div { flex: 1; min-width: 0; padding: 0.8125rem 0 0.75rem; text-align: center; border-right: 1px solid var(--hair); display: flex; flex-direction: column-reverse; }   /* the label comes first in the page and sits under its value */
.trio div:last-child { border-right: 0; }
.trio dd { margin: 0; font: 500 1.75rem/1 var(--serif); font-variant-numeric: tabular-nums; }
.trio dt { margin-top: 0.3125rem; }
/* the seven days: one row as a rule; at large text as many as fit, the rest on a second row in
   the same columns, rather than crowding each other */
.week { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(2.25rem, 1fr)); gap: 0.75rem 0.25rem; padding: 1.125rem 0 0; margin: 0; }
.day { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.375rem; font: 600 0.78125rem/1 var(--sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--stone); }
.dot { width: min(1.875rem, 11vw); height: min(1.875rem, 11vw); border-radius: 50%; border: 1.5px solid var(--rule); display: grid; place-items: center; color: #fff; }
.dot.on { background: var(--c); border-color: var(--c); }
.dot .ic { width: 1rem; height: 1rem; stroke-width: 2.4; }
.sharebox { margin: 1.25rem 0 0; border: 1px solid var(--hair); background: var(--sheet); padding: 0.875rem 1rem; font: 500 0.96875rem/1.5 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 0.625rem; padding-top: 0.875rem; }
.share-note { min-height: 1.5rem; margin-top: 0.5rem; color: var(--stone); font-size: 0.9375rem; }
.next { margin-top: 1rem; padding-top: 1.125rem; border-top: 3px double var(--ink); }
.next-row { display: flex; align-items: center; gap: 0.75rem; min-height: 4rem; padding: 0.625rem 0; border-bottom: 1px solid var(--hair); text-decoration: none; }
.next-row:hover .row-title { text-decoration: underline; text-decoration-thickness: 1px; }
.btn.pill { min-height: 2.5rem; padding: 0 1.125rem; }

/* a square icon-only button, and the restart button waiting for its second tap */
.btn.square { flex: none; width: 3rem; padding: 0; }
.btn.armed { background: var(--ink); color: var(--paper); }
.action-note { min-height: 1.5rem; margin: -0.5rem var(--gutter) 0.25rem; color: var(--stone); font-size: 0.9375rem; }
.action-note:empty { min-height: 0; margin: 0; }

/* the answers page */
.answer-list { margin: 0.5rem 0 1rem; padding-left: 1.375rem; }
.answer-list li { margin-bottom: 0.375rem; }
#answer h2:focus { outline: none; }
#answer .ws { margin: 1rem 0 1.5rem; max-width: 30rem; }

/* On the narrowest phones the board gets more of the width, so a 12-column grid's squares stay 24px. */
@media (max-width: 22.5rem) {
  .board { padding: 0 0.625rem; }
}

/* a game's finished picture on its solved screen (meta.revealPicture: the Jigsaw's) */
.reveal-picture { margin: 1rem 0 0; }
.reveal-picture img { display: block; width: 100%; max-width: 32rem; height: auto; border: 1px solid var(--hair); }
.reveal-picture figcaption { margin-top: 0.375rem; color: var(--stone); font-size: 0.9375rem; }
/* what the answer was, on the solved screen */
.reveal { margin-top: 1rem; padding: 0.875rem 1rem; border-left: 3px solid var(--c); background: var(--sheet); }
.reveal p { font: 400 1.25rem/1.4 var(--serif); }
.reveal p + p { margin-top: 0.5rem; font: 400 1.0625rem/1.4 var(--sans); color: var(--stone); }

/* the on-screen key pad shared by the games that need one */
.keys {
  --gap: 6px; display: flex; flex-direction: column; gap: var(--gap);   /* fixed sizes: ten keys must fit a row however large the text is set */
  padding: 0.75rem var(--gutter) 0.625rem; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  container-type: inline-size;
}
.keys-row { display: flex; justify-content: center; gap: var(--gap); }
.key {
  flex: 0 1 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); min-width: 0; min-height: 2.75rem; padding: 0;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); color: var(--ink);
  font: 500 1.25rem/1 var(--sans); display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.key.wide { flex-grow: 1; }
.key.tool { grid-auto-flow: column; gap: 0.375rem; font: 600 0.9375rem/1 var(--sans); background: transparent; }
/* a word on a key never outgrows the key, however large the text is set */
.key.tool span { font-size: min(0.9375rem, 5.2cqw); }
.key { font-size: min(1.25rem, 7cqw); }
.key.tool .ic { width: 1.25rem; height: 1.25rem; }
/* a spent key is marked by its border as well as its colour */
.key.used { color: #6F6C65; background: transparent; border-style: dashed; }
.key[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.key:disabled { opacity: 0.45; cursor: default; }

/* On the narrowest phones a row of ten letter keys needs every pixel: 28px keys at 320px wide. */
@media (max-width: 22.5rem) {
  .keys { --gap: 3px; padding-left: 4px; padding-right: 4px; }
  .board .keys { margin-left: -6px; margin-right: -6px; }
}
/* Where the system sets the colours, a switched-on key keeps a sign. */
@media (forced-colors: active) {
  .key[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .key.used { border-style: dashed; }
}

/* an answer told in three lines or more (four groups, say) is a list, not a quotation and its credit */
.reveal p:first-child:nth-last-child(n+3), .reveal p:first-child:nth-last-child(n+3) ~ p { margin-top: 0; font: 400 1.0625rem/1.45 var(--sans); color: var(--ink); }
.reveal p:first-child:nth-last-child(n+3) ~ p { margin-top: 0.375rem; }

/* a library puzzle's way back to its own page: a link of its own at the end of the caption, tall enough to press */
.caption .which-link { margin-left: auto; padding: 0.8125rem 0 0.8125rem 0.75rem; font: 600 0.9375rem/1.2 var(--sans); color: var(--ink); text-decoration: underline; text-underline-offset: 0.15em; white-space: nowrap; }

/* the link to decorate the puzzle, under its Print button */
.decorate-offer { min-height: 2.75rem; margin: 0.25rem 0 0; text-align: center; }   /* its room kept before its link is in */
#main:has(> #board > .notice) > #decorate-offer { display: none; }   /* no puzzle, nothing to decorate */
.decorate-offer a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.5rem; color: var(--ink); font: 600 0.9375rem/1.2 var(--sans); }
