/* Crosswire. The word you're on gets a blue wash, the square you're on gets the highlighter. */
.gm-page .wrap:has(.gm-crosswire) { max-width: 1040px; }
.gm-crosswire { --cw-word: #DCE4F7; --cw-bad: #B00020; --cw-bad-bg: #FBE5E8; --cs: 36px; }

.cw { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

/* Current clue + clock */
.cw-top { position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 6px 0 10px; }
.cw-meta { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--quiet);
  margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.cw-time { font-weight: 700; color: var(--ink); font-size: 16px; }
.cw-bar { display: flex; align-items: stretch; min-height: 56px; border: 2px solid var(--ink); border-radius: 8px; background: var(--paper); }
.cw-nav { flex: 0 0 44px; border: 0; background: none; font: 400 28px/1 var(--sans); color: var(--ink); cursor: pointer; }
.cw-nav:hover { background: var(--wash); }
.cw-nav:first-child { border-right: 1px solid var(--rail); border-radius: 6px 0 0 6px; }
.cw-nav:last-child { border-left: 1px solid var(--rail); border-radius: 0 6px 6px 0; }
.cw-cur { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 16px; line-height: 1.3; }
.cw-cnum { flex: 0 0 auto; background: var(--hl); padding: 2px 6px; font-weight: 800; font-size: 14px; border-radius: 3px; }

/* Grid */
.cw-gwrap { padding: 4px 0; }
.cw-grid { display: grid; grid-auto-rows: var(--cs); width: max-content; margin: 0 auto; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; border-radius: 2px; }
.cw-grid:focus { outline: none; }
.cw-grid:focus-visible { outline: 3px solid var(--cite); outline-offset: 6px; }
@media (pointer: coarse) { .cw-grid:focus-visible { outline: none; } }
.cw-x { width: var(--cs); height: var(--cs); }
.cw-c { position: relative; width: var(--cs); height: var(--cs); border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
  background: var(--paper); cursor: pointer;
  transition: background-color .45s var(--ease), color .45s var(--ease); }
.cw-c.bt { border-top: 1.5px solid var(--ink); }
.cw-c.bl { border-left: 1.5px solid var(--ink); }
.cw-n { position: absolute; top: 1px; left: 2px; font-size: max(8px, calc(var(--cs) * .28)); line-height: 1; font-weight: 600; pointer-events: none; }
.cw-l { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: calc(var(--cs) * .1);
  font-size: calc(var(--cs) * .56); font-weight: 700; line-height: 1; pointer-events: none; }
.cw-c.hw { background: var(--cw-word); transition: none; }
.cw-c.on { background: var(--hl); transition: none; }
.cw-c.rev .cw-l { color: var(--cite); }
.cw-c.rev::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 calc(var(--cs) * .26) calc(var(--cs) * .26) 0;
  border-color: transparent var(--cite) transparent transparent; }
/* Wrong letters: red, and struck through so it doesn't rest on color alone. */
.cw-c.bad .cw-l { color: var(--cw-bad);
  background: linear-gradient(to top right, transparent calc(50% - 1px), var(--cw-bad) calc(50% - 1px), var(--cw-bad) calc(50% + 1px), transparent calc(50% + 1px)); }
.cw-c.bad { background: var(--cw-bad-bg); }
.cw-c.bad.on { background: var(--hl); }
.cw-c.good { animation: cw-good .6s var(--ease); }
@keyframes cw-good { 40% { background: #CFE3D6; } }
.cw-c.ok { background: var(--cite); color: #fff; cursor: default; transition-delay: calc(var(--k) * 35ms); }
.cw-c.ok .cw-l { color: #fff; transition: color .45s var(--ease) calc(var(--k) * 35ms); }
.cw-still .cw-c, .cw-still .cw-c .cw-l { transition: none !important; }
.cw-c.ok.rev::after { border-right-color: var(--hl); }

/* Check / reveal */
.cw-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin-top: 18px; }
.cw-grp { display: flex; align-items: center; gap: 6px; }
.cw-grp > span { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--quiet); margin-right: 2px; }

.cw-kb { margin-top: 0; }
.cw-kb button { -webkit-tap-highlight-color: transparent; }

/* Clues */
.cw-clues { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.cw-sec h2 { margin: 0 0 4px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); font-size: 13px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; }
.cw-list { list-style: none; margin: 0; padding: 0; }
.cw-cl { display: flex; gap: 8px; width: 100%; text-align: left; padding: 7px 8px; border: 0; border-left: 4px solid transparent; background: none;
  font: 400 15px/1.35 var(--sans); color: var(--ink); cursor: pointer; }
.cw-cl:hover { background: var(--wash); }
.cw-cl b { flex: 0 0 1.6em; text-align: right; font-weight: 800; }
.cw-cl.full span { color: var(--quiet); }
.cw-cl.x { background: var(--cw-word); }
.cw-cl.cur { background: var(--hl); border-left-color: var(--ink); }
.cw-cl.cur span { color: var(--ink); }

/* Result dialog */
.cw-res .cw-big { font-size: 44px; font-weight: 800; letter-spacing: -.02em; line-height: 1; margin: 0 0 6px; font-variant-numeric: tabular-nums; }
.cw-res .cw-words { font-size: 13px; color: var(--quiet); }

/* Keyboard on touch screens only; a real keyboard does the job elsewhere. */
@media (hover: hover) and (pointer: fine) { .cw-kb { display: none; } }

/* Phones: the clue bar stays pinned while you scroll the grid and the clue list. */
@media (max-width: 899px) {
  .cw-board { display: contents; }
  .cw-clues { order: 5; }
  /* The keyboard rides along the bottom of the screen, under the grid and the clue list. */
  .cw-kb { order: 6; position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: var(--paper); border-top: 1px solid var(--rail); max-width: none; gap: 6px; }
  .cw .sr { order: 7; }
}
@media (max-width: 640px) {
  .cw-top { margin: 0 -16px; padding: 6px 16px 10px; }
  .cw-cur { font-size: 15px; padding: 6px 10px; }
  .cw-kb button { height: 46px; }
  .cw-acts { gap: 10px 14px; }
}

/* Desktop: grid on the left, both clue lists in a column beside it. */
@media (min-width: 900px) {
  .cw { grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 40px; align-items: start; }
  .cw-clues { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; padding-right: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .cw-c, .cw-c.ok, .cw-c.ok .cw-l { transition: none; }
  .cw-c.good { animation: none; }
}
