/* crossword.css — /crossword/ (docs/crossword-plan.md).
 *
 * Built for a seven-year-old on a Chromebook or an iPad first, and a phone
 * second. FULL WIDTH: no narrow centred column (the house rule). The page is
 * a column of the viewport's height — header, the play area (which scrolls
 * if it must), and the keyboard pinned to the foot — so the keys never move
 * and nothing scrolls sideways.
 *
 * Colours come from the site's tokens (readflexes.css) plus a few of this
 * page's own, defined for dark and for light. A mark is never colour alone:
 * a wrong letter also carries a slash, a given one a dot.
 */

:root {
  --xw-cell: #1c1c4e;
  --xw-ink: #ffffff;
  --xw-edge: rgba(255, 255, 255, 0.34);
  --xw-word: #2f4aa8;
  --xw-active: #ffe100;
  --xw-active-ink: #16163a;
  --xw-block: #04041a;
  --xw-right: #35e08a;
  --xw-wrong: #ff7d93;
  --xw-given: #4df0ff;
  --xw-key: #23235c;
  --xw-key-ink: #ffffff;
  --xw-bar: #14143a;
  --xw-letter-font: 'Atkinson Hyperlegible', 'Andika', var(--font-body);
}
:root.light-mode {
  --xw-cell: #ffffff;
  --xw-ink: #16163a;
  --xw-edge: rgba(13, 13, 43, 0.42);
  --xw-word: #cfe1ff;
  --xw-active: #ffd43b;
  --xw-active-ink: #16163a;
  --xw-block: #16163a;
  --xw-right: #0a7a43;
  --xw-wrong: #c2183a;
  --xw-given: #0b62a8;
  --xw-key: #ffffff;
  --xw-key-ink: #16163a;
  --xw-bar: #ffffff;
}

[hidden] { display: none !important; }

body.xw-body {
  display: flex; flex-direction: column;
  height: 100dvh; min-height: 0; overflow: hidden;
  overscroll-behavior: none;
}

/* ── header ─────────────────────────────────────────────────────────────── */
.xw-top {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 12px;
  /* The right padding clears the site's 🌐 switcher, which is fixed there. */
  padding: 6px 128px 6px clamp(10px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.xw-logo img { height: 34px; width: auto; display: block; }
.xw-title { font-size: 1.15rem; line-height: 1; }
.xw-tabs, .xw-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.xw-easy-opts { display: inline-flex; gap: 6px 14px; flex-wrap: wrap; }
.xw-tab, .xw-chip {
  font: 800 0.9rem/1 var(--font-body);
  color: var(--muted); background: transparent;
  border: 1.5px solid var(--xw-edge); border-radius: 999px;
  padding: 0 14px; min-height: 40px; cursor: pointer;
}
.xw-tab[aria-selected="true"], .xw-chip[aria-checked="true"] {
  color: var(--xw-active-ink); background: var(--xw-active); border-color: var(--xw-active);
}
.xw-top-tools { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.xw-icon {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--xw-edge); background: transparent; color: var(--text);
  font-size: 1.1rem; cursor: pointer;
}
.xw-timer { font: 700 1rem/1 var(--xw-letter-font); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 3.2em; text-align: right; }

/* ── the play area ──────────────────────────────────────────────────────── */
.xw-main {
  flex: 1 1 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 8px clamp(10px, 2vw, 24px) 6px;
  display: flex; flex-direction: column;
}
.xw-play { flex: 1 0 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
/* One column (a phone, a narrow window): the side column dissolves and the
   order is clue, grid, word bank, buttons. */
.xw-side { display: contents; }
.xw-meta { order: 0; } .xw-note { order: 1; } .xw-done { order: 2; }
.xw-cluebar { order: 3; } .xw-board { order: 4; } .xw-bank { order: 5; } .xw-actions { order: 6; }
.xw-short { display: none; }
.xw-muted { color: var(--muted); font-size: 0.9rem; }
.xw-note {
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--xw-edge); background: var(--xw-bar); font-weight: 700;
}

.xw-days { order: 0; display: flex; align-items: center; gap: 6px; }
.xw-days[hidden] { display: none; }
.xw-day-step, .xw-day-select {
  min-height: 40px; border-radius: 12px; border: 2px solid var(--xw-edge); background: var(--xw-panel, transparent);
  color: var(--text); font: inherit; font-weight: 800; cursor: pointer;
}
.xw-day-step { width: 44px; }
.xw-day-step:disabled { opacity: 0.35; cursor: default; }
.xw-day-select { padding: 0 10px; max-width: min(70vw, 300px); }
:root.light-mode .xw-day-select, :root.light-mode .xw-day-step { background: #fff; color: #1b2430; }
.xw-day-select option { color: #1b2430; background: #fff; }
.xw-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; font-size: 0.95rem; color: var(--muted); }
.xw-meta strong { color: var(--text); font-size: 1.05rem; }
.xw-meta a { color: var(--neon-cyan); font-weight: 800; }
:root.light-mode .xw-meta a { color: #0b5cab; }

.xw-cluebar { display: flex; align-items: stretch; gap: 8px; flex: 0 0 auto; }
.xw-nav {
  flex: 0 0 auto; width: 52px; min-height: 52px;
  border-radius: var(--radius); border: 1.5px solid var(--xw-edge);
  background: var(--xw-bar); color: var(--text); font-size: 1.3rem; cursor: pointer;
}
.xw-clue {
  flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  background: var(--xw-bar); border: 2px solid var(--xw-active); border-radius: var(--radius);
  padding: 8px 10px;
}
.xw-clue-img {
  flex: 0 0 auto;
  height: clamp(72px, 17vh, 168px); width: auto; max-width: 38%;
  aspect-ratio: 1 / 1; object-fit: contain;
  border-radius: var(--radius-sm); background: #fff;
}
.xw-clue-words { flex: 1 1 0; min-width: 0; }
.xw-clue-label { font: 800 0.8rem/1.2 var(--font-body); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.xw-clue-text { font: 700 clamp(1.15rem, 2.6vw, 1.9rem)/1.25 var(--xw-letter-font); overflow-wrap: anywhere; }
.xw-clue-sentence { font: 400 clamp(1rem, 2vw, 1.35rem)/1.3 var(--xw-letter-font); color: var(--muted); margin-top: 2px; }
.xw-clue-answer {
  margin-top: 4px; padding: 2px 12px; min-height: 34px;
  font: 700 1.15rem/1 var(--xw-letter-font);
  color: var(--xw-right); background: transparent;
  border: 1.5px solid var(--xw-right); border-radius: 999px; cursor: pointer;
}
.xw-clue { position: relative; }
.xw-say {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  border: 1.5px solid var(--xw-edge); background: transparent; font-size: 1.4rem; cursor: pointer;
}

.xw-board { flex: 1 0 auto; min-height: 0; display: flex; gap: 14px; }
.xw-stage {
  flex: 1 1 0; min-width: 0; min-height: var(--xw-stage-min, 228px);
  display: flex; overflow: auto;
}
.xw-grid {
  --cell: 44px;
  margin: auto; /* centred while it fits, flush to the top-left once it does not */
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px; padding: 2px;
  flex: 0 0 auto;
}
.xw-cell {
  position: relative; padding: 0;
  width: var(--cell); height: var(--cell);
  background: var(--xw-cell); color: var(--xw-ink);
  border: 1.5px solid var(--xw-edge); border-radius: calc(var(--cell) * 0.12);
  font: 700 calc(var(--cell) * 0.6)/1 var(--xw-letter-font);
  text-transform: uppercase; cursor: pointer;
  display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.xw-cell .xw-num {
  position: absolute; top: 3%; left: 7%;
  font: 700 calc(var(--cell) * 0.24)/1 var(--font-body); opacity: 0.8;
}
.xw-cell.in-word { background: var(--xw-word); }
.xw-cell.active {
  background: var(--xw-active); color: var(--xw-active-ink);
  border-color: var(--xw-active-ink); box-shadow: 0 0 0 3px var(--xw-active);
  z-index: 1;
}
.xw-cell.wrong { color: var(--xw-wrong); }
.xw-cell.wrong::after {
  content: ''; position: absolute; inset: 12%;
  background: linear-gradient(to top right, transparent 46%, var(--xw-wrong) 46%, var(--xw-wrong) 54%, transparent 54%);
  pointer-events: none;
}
.xw-cell.active.wrong { color: #a3122f; }
.xw-cell.right { color: var(--xw-right); }
.xw-cell.active.right { color: #075c32; }
.xw-cell.given::before {
  content: ''; position: absolute; top: 8%; right: 8%;
  width: 16%; height: 16%; border-radius: 50%; background: var(--xw-given);
}
.xw-cell:focus-visible { outline: 3px solid var(--neon-cyan); outline-offset: 1px; }
/* A paper's blocks are black squares; an easy puzzle's are simply empty. */
.xw-blockcell { background: var(--xw-block); border-radius: 2px; }
.xw-grid.freeform .xw-blockcell { background: transparent; }

.xw-cluelist {
  flex: 0 1 34%; min-width: 260px; max-height: 100%; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start;
  background: var(--xw-bar); border: 1px solid var(--xw-edge); border-radius: var(--radius); padding: 10px;
}
.xw-cluecol h2 { font-size: 1rem; margin-bottom: 4px; }
.xw-cluecol ol { list-style: none; display: grid; gap: 2px; }
.xw-cluecol button {
  width: 100%; text-align: left; background: transparent; color: var(--text);
  border: 0; border-radius: 8px; padding: 6px 8px; cursor: pointer;
  font: 400 0.98rem/1.3 var(--xw-letter-font);
}
.xw-cluecol button b { margin-right: 6px; }
.xw-cluecol button.current { background: var(--xw-word); }
.xw-cluecol button.solved { color: var(--muted); text-decoration: line-through; }

.xw-bank { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; flex: 0 0 auto; }
.xw-bank-words { display: flex; flex-wrap: wrap; gap: 6px; }
.xw-bank-word {
  font: 700 1.1rem/1 var(--xw-letter-font);
  min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: var(--xw-bar); color: var(--text); border: 1.5px solid var(--xw-edge);
}
.xw-bank-word.used { opacity: 0.55; text-decoration: line-through; }

.xw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 0 0 auto; }
.xw-btn {
  font: 800 0.95rem/1 var(--font-body);
  min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  background: var(--xw-bar); color: var(--text); border: 1.5px solid var(--neon-cyan);
}
:root.light-mode .xw-btn { border-color: #0b62a8; }
.xw-btn--quiet, .xw-btn--toggle { border-color: var(--xw-edge); }
.xw-btn--toggle[aria-pressed="true"] { background: var(--xw-word); border-color: var(--xw-active); }
.xw-status { font-weight: 800; margin-left: 6px; }

.xw-done {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 8px 12px; border-radius: var(--radius);
  border: 2px solid var(--xw-right); background: var(--xw-bar); flex: 0 0 auto;
}
.xw-done-title { font: 800 1.25rem/1.1 var(--font-heading); }
.xw-done-burst { font-size: 1.6rem; display: inline-block; animation: xw-pop 0.9s ease-out 1; }
.xw-done-next { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
@keyframes xw-pop { 0% { transform: scale(0.2) rotate(-25deg); } 60% { transform: scale(1.5) rotate(12deg); } 100% { transform: scale(1) rotate(0); } }
.xw-grid.celebrate .xw-cell { animation: xw-wave 0.6s ease-out 1; animation-delay: calc(var(--i, 0) * 28ms); }
@keyframes xw-wave { 40% { transform: translateY(-14%); background: var(--xw-right); } }
@media (prefers-reduced-motion: reduce) {
  .xw-done-burst, .xw-grid.celebrate .xw-cell { animation: none; }
}

/* ── Today's Papers ─────────────────────────────────────────────────────── */
.xw-papers { display: flex; flex-direction: column; gap: 12px; }
.xw-papers-intro { font-size: 1.05rem; max-width: 80ch; }
.xw-paper-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.xw-paper {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--xw-bar); border: 1.5px solid var(--xw-edge); border-radius: var(--radius); padding: 14px;
}
.xw-paper h2 { font-size: 1.25rem; }
.xw-paper-go { align-self: flex-start; }
.xw-paper-earlier { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.9rem; }
.xw-paper-earlier button {
  background: transparent; color: var(--text); border: 1px solid var(--xw-edge);
  border-radius: 999px; min-height: 32px; padding: 0 10px; cursor: pointer; font: 700 0.85rem/1 var(--font-body);
}
.xw-paper a { color: var(--neon-cyan); font-weight: 800; }
:root.light-mode .xw-paper a { color: #0b5cab; }
.xw-open-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 6px; }

/* ── the keyboard ───────────────────────────────────────────────────────── */
.xw-keys {
  flex: 0 0 auto;
  display: grid; gap: 5px;
  padding: 6px clamp(4px, 1.2vw, 24px) max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
/* The Focus Sounds pill is fixed bottom-left; give it a row of its own
   rather than letting it sit on the Z key. */
body:has(#rf-focus-sounds:not([style*="display: none"])) .xw-keys { padding-bottom: 64px; }
.xw-keyrow { display: flex; justify-content: center; gap: clamp(3px, 0.7vw, 8px); }
.xw-key {
  flex: 1 1 0; max-width: 84px; min-width: 0;
  height: clamp(46px, 7.2vh, 62px);
  border-radius: 10px; border: 1.5px solid var(--xw-edge);
  background: var(--xw-key); color: var(--xw-key-ink);
  font: 700 clamp(1.05rem, 2.6vw, 1.5rem)/1 var(--xw-letter-font);
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.xw-key:active { background: var(--xw-active); color: var(--xw-active-ink); }
.xw-key--wide { flex: 1.6 1 0; max-width: 130px; font-size: 1.2rem; }

/* ── settings ───────────────────────────────────────────────────────────── */
/* The site reset zeroes a dialog's margin, which is what centres a modal one. */
dialog.xw-dialog {
  margin: auto; padding: 18px; width: min(92vw, 440px);
  background: var(--panel); color: var(--text);
  border: 1.5px solid var(--xw-edge); border-radius: var(--radius);
}
dialog.xw-dialog::backdrop { background: rgba(4, 4, 26, 0.6); }
.xw-dialog h2 { margin-bottom: 10px; }
.xw-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 1.05rem; cursor: pointer; }
.xw-check input { width: 22px; height: 22px; }
.xw-dialog-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }

/* ── a laptop, a Chromebook, an iPad on its side ────────────────────────────
   Two columns: the clue (its picture large — the picture IS the clue) with
   the word bank under it, and the grid filling everything to its right. */
@media (min-width: 900px) {
  .xw-main { overflow-y: hidden; }
  .xw-play {
    flex: 1 1 0; display: grid;
    grid-template-columns: minmax(340px, 36%) minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    gap: 8px 18px;
  }
  .xw-days, .xw-meta, .xw-note, .xw-done, .xw-actions { grid-column: 1 / -1; }
  .xw-side { display: flex; flex-direction: column; gap: 10px; grid-column: 1; grid-row: 4; min-height: 0; overflow-y: auto; }
  .xw-board { grid-column: 2; grid-row: 4; min-height: 0; }
  .xw-actions { grid-row: 5; }
  .xw-clue { flex-direction: column; align-items: stretch; text-align: center; padding: 10px 12px; }
  .xw-clue-img { align-self: center; height: clamp(96px, 19vh, 230px); max-width: 100%; }
  .xw-clue-text { font-size: clamp(1.1rem, 1.85vw, 1.7rem); }
  .xw-clue-sentence { font-size: clamp(0.95rem, 1.4vw, 1.25rem); }
  .xw-clue-answer { align-self: center; }
  .xw-say { position: absolute; top: 8px; right: 8px; background: var(--xw-bar); }
  /* With no picture the words sit where the 🔊 is: keep them clear of it. */
  .xw-clue.no-img .xw-clue-words { padding: 0 54px; }
  .xw-nav { width: 46px; }
  .xw-stage { min-height: 0; }
  .xw-cluelist { flex-basis: 40%; }
  .xw-cluecol button.current { scroll-margin: 40px; }
  /* A newspaper grid: the clue card needs less of the row, the grid more. */
  .xw-play.large { grid-template-columns: minmax(250px, 22%) minmax(0, 1fr); }
  .xw-play.large .xw-cluelist { flex-basis: 34%; }
  .xw-play.large .xw-clue-text { font-size: clamp(1.05rem, 1.5vw, 1.4rem); }
}

/* ── a phone ────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Row one sits beside the site's 🌐 switcher (fixed, top right); the tabs
     and the chips each get a row of their own under it. */
  .xw-top { padding: 8px 10px 6px; gap: 6px 6px; }
  /* The back pill is the way out on a phone; the logo's room goes to the tools. */
  .xw-logo, .xw-title { display: none; }
  .xw-top-tools { margin-left: 0; margin-right: 118px; order: 1; }
  .xw-icon { width: 36px; height: 36px; font-size: 1rem; }
  .xw-tabs { order: 2; flex: 1 0 100%; }
  .xw-tab { flex: 1 1 0; }
  .xw-easy-opts { order: 3; flex: 1 0 100%; justify-content: space-between; gap: 6px; }
  .xw-tab, .xw-chip { padding: 0 12px; font-size: 0.85rem; min-height: 36px; }
  .xw-long { display: none; }
  .xw-short { display: inline; }
  .xw-main { padding-top: 6px; }
  .xw-meta { font-size: 0.82rem; }
  .xw-meta strong { font-size: 0.9rem; }
  /* The clue card on a phone: a top strip of [◀] label [🔊] [▶], and the
     picture beside the words under it — the words get the width the side
     arrows used to take. */
  .xw-cluebar { position: relative; display: block; }
  .xw-clue { gap: 10px; padding: 50px 10px 8px; align-items: flex-start; }
  .xw-nav { position: absolute; top: 5px; width: 44px; height: 40px; min-height: 0; z-index: 1; font-size: 1.1rem; }
  #xw-prev { left: 6px; }
  #xw-next { right: 6px; }
  .xw-say { position: absolute; top: 5px; right: 56px; width: 44px; height: 40px; border-radius: var(--radius); font-size: 1.15rem; }
  .xw-clue-label { position: absolute; top: 5px; left: 58px; right: 108px; height: 40px; display: flex; align-items: center; font-size: 0.72rem; }
  .xw-clue-img { height: 88px; max-width: 30%; }
  .xw-clue-text { font-size: 1.12rem; line-height: 1.2; }
  .xw-clue-sentence { font-size: 0.95rem; }
  .xw-clue-answer { min-height: 30px; font-size: 1rem; }
  /* The buttons come before the word bank: Check and Hint stay on the first screen. */
  .xw-actions { order: 5; flex-wrap: nowrap; gap: 5px; }
  .xw-bank { order: 6; }
  .xw-status { display: none; }
  .xw-board { flex-direction: column; }
  .xw-cluelist { flex: 0 0 auto; min-width: 0; max-height: 40vh; }
  .xw-btn { padding: 0 9px; font-size: 0.8rem; min-height: 42px; white-space: nowrap; flex: 1 1 auto; }
  .xw-key { border-radius: 8px; height: clamp(44px, 6.2vh, 56px); }
  .xw-keys { gap: 4px; padding-top: 5px; }
}

/* ── /crossword/make/: a crossword from a set ───────────────────────────── */
body.xw-make-body { height: auto; min-height: 100dvh; overflow: auto; overscroll-behavior: auto; }
.xw-make { gap: 14px; overflow: visible; }
.xm-gate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 1.05rem; }
.xm-gate[hidden], .xm-pick[hidden], .xm-work[hidden] { display: none; }
.xm-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.xm-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.xm-col h2 { font-size: 1.15rem; }
.xm-setlist { display: flex; flex-direction: column; gap: 6px; }
.xm-set {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; text-align: left;
  min-height: 46px; padding: 8px 14px; border-radius: 12px; cursor: pointer; text-decoration: none;
  background: var(--xw-bar); color: var(--text); border: 1.5px solid var(--xw-edge); font: inherit; flex: 1 1 auto;
}
.xm-set:hover, .xm-set:focus-visible { border-color: var(--neon-cyan); }
.xm-mine-row { display: flex; gap: 6px; align-items: stretch; }
.xm-input {
  min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--xw-edge);
  background: var(--xw-bar); color: var(--text); font: inherit; min-width: 0;
}
:root.light-mode .xm-input { background: #fff; color: #1b2430; }
.xm-work { display: flex; flex-direction: column; gap: 12px; }
.xm-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.xm-field { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 0.9rem; }
.xm-field--name { flex: 1 1 220px; max-width: 420px; }
.xm-notices { display: flex; flex-direction: column; gap: 4px; }
.xm-notice { color: var(--muted); font-size: 0.95rem; }
.xm-board { display: grid; grid-template-columns: minmax(260px, 520px) minmax(0, 1fr); gap: 18px; align-items: start; }
.xm-grid {
  display: grid; grid-template-columns: repeat(var(--xm-cols, 13), 1fr); gap: 2px;
  width: 100%; aspect-ratio: 1 / 1;
}
.xm-grid[hidden], .xm-clues[hidden], .xm-write[hidden] { display: none; }
.xm-cell {
  position: relative; display: grid; place-items: center; border-radius: 3px;
  background: var(--xw-cell, #fff); color: var(--xw-ink, #111); border: 1px solid var(--xw-edge);
  font: 700 clamp(9px, 1.5vw, 18px)/1 var(--xw-letter-font); container-type: size;
}
.xm-cell b { font-weight: 700; }
.xm-cell i { position: absolute; top: 1px; left: 2px; font: 700 clamp(6px, 0.8vw, 10px)/1 var(--font-body); font-style: normal; opacity: 0.75; }
.xm-cell--off { background: transparent; border-color: transparent; }
.xm-clues { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.xm-cluecol h2 { font-size: 1rem; margin-bottom: 4px; }
.xm-clues ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.xm-write { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.xm-clue { display: flex; align-items: center; gap: 8px; }
.xm-clue-n { font-weight: 800; min-width: 1.6em; text-align: right; }
.xm-clue-img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.xm-clue-pic {
  flex: 0 0 auto; width: 44px; height: 44px; padding: 0; border-radius: 8px; cursor: pointer; overflow: hidden;
  background: transparent; color: var(--text); border: 1.5px solid var(--xw-edge); font-size: 1.1rem; line-height: 1;
}
.xm-clue-pic--empty { border-style: dashed; opacity: 0.8; }
.xm-clue-pic .xm-clue-img { display: block; width: 100%; height: 100%; border-radius: 0; }
.xm-clue-text { flex: 1 1 auto; }
dialog.xm-picker { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
.xm-picker h3 { font-size: 0.95rem; margin: 12px 0 6px; }
.xm-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.xm-pic { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 0.8rem; overflow-wrap: anywhere; }
.xm-pic-use { padding: 0; border: 2px solid var(--xw-edge); border-radius: 10px; overflow: hidden; cursor: pointer; background: transparent; aspect-ratio: 1 / 1; }
.xm-pic-use:hover, .xm-pic-use:focus-visible { border-color: var(--accent, #ffe100); }
.xm-pic-use img { display: block; width: 100%; height: 100%; object-fit: cover; }
.xm-pic-form { display: flex; gap: 8px; }
.xm-pic-form .xm-input { flex: 1 1 auto; }
.xw-credit { font-size: 0.72rem; color: var(--muted); }
.xw-credit a { color: inherit; text-decoration: underline; }
.xm-clue-word { font: 700 0.95rem/1.1 var(--xw-letter-font); color: var(--muted); flex: 0 0 auto; max-width: 30%; overflow-wrap: anywhere; }
.xm-clue-x {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--text); border: 1.5px solid var(--xw-edge); font-size: 1.1rem;
}
.xm-actions { flex-wrap: wrap; }
.xm-link { flex: 1 1 260px; }
@media (max-width: 760px) {
  .xm-board { grid-template-columns: 1fr; }
  /* A phone: the number, picture, word and × on one line, the clue box under them at full width. */
  .xm-clue { display: grid; grid-template-columns: auto auto 1fr auto; gap: 6px 8px; }
  .xm-clue-text { grid-column: 1 / -1; grid-row: 2; }
  .xm-clue-word { max-width: none; grid-column: 3; }
  .xm-clue-n { grid-column: 1; }
  .xm-clue-pic { grid-column: 2; }
  .xm-clue-x { grid-column: 4; }
}

/* ── printing a crossword (the solver's Print button builds #xw-print) ──── */
.xw-print { display: none; }
@media print {
  body.xw-printing > *:not(.xw-print) { display: none !important; }
  body.xw-printing { height: auto; overflow: visible; background: #fff; color: #000; display: block; }
  body.xw-printing .xw-print { display: block; font-family: var(--xw-letter-font); color: #000; }
  .xwp-page { break-after: page; padding: 0.2in 0; }
  .xwp-page:last-child { break-after: auto; }
  .xwp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 0.15in; }
  .xwp-head h1 { font-size: 20pt; margin: 0; color: #000; }
  .xwp-name { flex: 0 0 2.6in; border-bottom: 1.5px solid #000; font-size: 11pt; padding-bottom: 2px; }
  .xwp-grid { display: grid; gap: 0; width: min(6.4in, 100%); margin: 0 auto 0.2in; }
  .xwp-cell { position: relative; aspect-ratio: 1 / 1; border: 1px solid #000; margin: -0.5px; display: grid; place-items: center; font-size: 13pt; font-weight: 700; }
  .xwp-cell i { position: absolute; top: 1px; left: 2px; font: 700 7pt/1 sans-serif; font-style: normal; }
  .xwp-off { border-color: transparent; }
  .xwp-clues { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.3in; font-size: 11pt; line-height: 1.35; }
  .xwp-clues h2 { font-size: 12pt; margin: 0 0 4px; color: #000; }
  .xwp-clues ol { list-style: none; margin: 0; padding: 0; }
  .xwp-clues li { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; break-inside: avoid; }
  .xwp-clues li b { min-width: 1.6em; text-align: right; }
  .xwp-clues img { width: 0.55in; height: 0.55in; object-fit: cover; border: 1px solid #999; }
  .xwp-clues .xw-credit { font-size: 7pt; color: #444; }
  .xwp-clues .xw-credit a { color: inherit; text-decoration: none; }
  .xwp-foot { margin-top: 0.2in; font-size: 8.5pt; text-align: center; color: #333; }
}

/* ── Learn: the lesson ladder, the demonstration, the coach ─────────────── */
.xw-learn { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.xw-learn[hidden] { display: none; }
.xw-unit h2 { font-size: 1.05rem; margin: 6px 0 8px; }
.xw-unit h2 span { color: var(--muted); font-weight: 700; margin-right: 6px; }
.xw-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.xw-lesson-row { display: flex; gap: 6px; min-width: 0; }
.xw-lesson {
  flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-height: 52px; min-width: 0; text-align: left;
  padding: 8px 12px; border-radius: var(--radius); cursor: pointer; font: inherit; color: var(--text);
  background: var(--xw-bar); border: 1.5px solid var(--xw-edge);
}
:root.light-mode .xw-lesson { background: #fff; color: #1b2430; }
.xw-lesson:hover, .xw-lesson:focus-visible { border-color: var(--accent, #ffe100); }
.xw-lesson b { flex: 0 0 auto; min-width: 1.8em; text-align: right; color: var(--muted); }
.xw-lesson span { flex: 1 1 auto; font-weight: 700; overflow-wrap: anywhere; }
.xw-lesson i { flex: 0 0 auto; font-style: normal; font-size: 0.75rem; font-weight: 800; }
.xw-lesson.done { opacity: 0.8; }
.xw-lesson.done i { color: var(--xw-right); font-size: 1.05rem; }
.xw-lesson.next { border-color: var(--accent, #ffe100); box-shadow: 0 0 0 2px rgba(255, 225, 0, 0.25); }
.xw-lesson.checkpoint { border-style: dashed; }
.xw-lesson-link { flex: 0 0 auto; width: 40px; border-radius: var(--radius); cursor: pointer; background: transparent; color: var(--text); border: 1.5px solid var(--xw-edge); }
.xw-wall h2 { font-size: 1.05rem; margin: 6px 0 4px; }
.xw-wall[hidden] { display: none; }
.xw-lessonbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; order: -1; grid-column: 1 / -1; }
.xw-lessonbar[hidden], .xw-demo[hidden], .xw-endings[hidden] { display: none; }
.xw-tell {
  flex: 1 1 320px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: transparent; border: 0; padding: 4px 0; opacity: 0.9;
}
.xw-tell::before { content: '🔊 '; }
.xw-demo {
  order: 2; grid-column: 1 / -1; align-self: start;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 18px clamp(12px, 3vw, 28px); border-radius: var(--radius);
  background: var(--xw-bar); border: 1.5px solid var(--xw-edge);
}
:root.light-mode .xw-demo { background: #fff; color: #1b2430; }
.xw-demo-title { font: 800 1.3rem/1.15 var(--font-heading); }
.xw-demo-tell { font-size: 1.1rem; max-width: 46ch; }
.xw-demo-clue { font-size: 1.25rem; font-weight: 700; min-height: 1.6em; }
.xw-demo-clue img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; display: block; margin: 0 auto 6px; }
.xw-demo-squares { display: flex; gap: 3px; }
.xw-demo-squares.down { flex-direction: column; }
.xw-demo-squares span {
  width: 54px; height: 54px; display: grid; place-items: center; border-radius: 5px;
  background: var(--xw-cell, #fff); color: var(--xw-ink, #111); border: 1.5px solid var(--xw-edge);
  font: 700 1.8rem/1 var(--xw-letter-font);
}
.xw-demo-squares span.ghost, .xw-cell.ghost { outline: 3px dashed var(--accent, #ffe100); outline-offset: -3px; }
.xw-demo-squares span.drop { animation: xw-drop 0.35s ease-out 1; }
@keyframes xw-drop { from { transform: translateY(-18px); opacity: 0; } to { transform: none; opacity: 1; } }
mark.xw-mark { background: transparent; color: inherit; border-bottom: 3px solid var(--accent, #ffe100); padding-bottom: 1px; }
mark.xw-mark.pulse { animation: xw-markpulse 0.9s ease-in-out 2; }
@keyframes xw-markpulse { 50% { background: rgba(255, 225, 0, 0.35); } }
.xw-endings { display: flex; flex-wrap: wrap; gap: 6px; order: 3; }
.xw-ending {
  min-width: 52px; min-height: 44px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  font: 800 1rem/1 var(--xw-letter-font); letter-spacing: 0.04em;
  background: transparent; color: var(--text); border: 2px dashed var(--accent, #ffe100);
}
@media (prefers-reduced-motion: reduce) {
  .xw-demo-squares span.drop, mark.xw-mark.pulse { animation: none; }
}
@media (max-width: 760px) {
  .xw-demo-squares span { width: 44px; height: 44px; font-size: 1.5rem; }
  .xw-lessons { grid-template-columns: 1fr; }
}
