/* crossword.css — Kana Crossword (tools/crossword/) */

:root {
  --page-color: #4c6cb3;                      /* 群青 gunjō */
  --page-ink: #3d5a9a;
  --page-color-soft: rgba(76, 108, 179, 0.10);
  --cw-word: #dbe4f5;
  --cw-cur: #f2d36b;
  --cw-wrong: #b3261e;
  --cw-reveal: #4c6cb3;
  --cw-cell: #fffdf8;
  --cw-black: var(--ink);
  --cw-line: var(--ink);
}
:root[data-theme="dark"] {
  --cw-word: #26324a;
  --cw-cur: #6e5a1c;
  --cw-wrong: #ef7a6e;
  --cw-reveal: #8ea8e0;
  --cw-cell: #1f1c18;
  --cw-black: #050404;
  --cw-line: #5a5246;
}

.cw [hidden], [hidden].cw-overlay, [hidden].cw-toast { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.cw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 18px; }
.cw-seg { display: inline-flex; border: 1px solid var(--border-strong); }
.cw-seg button { font: 500 14px var(--font-gothic); padding: 8px 14px; min-height: 40px; border: 0; border-left: 1px solid var(--border-strong); background: transparent; color: var(--ink-soft); cursor: pointer; }
.cw-seg button:first-child { border-left: 0; }
.cw-seg button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.cw-seg-sub { font-size: 11px; opacity: 0.7; margin-left: 2px; }
.cw-select-wrap { display: inline-flex; align-items: center; gap: 8px; }
.cw-label { font-size: 12px; color: var(--muted); }
.cw-select { font: 14px var(--font-gothic); padding: 8px 10px; min-height: 40px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); }
.cw-date { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.cw-date-btn { font: 14px var(--font-gothic); padding: 8px 10px; min-height: 40px; border: 0; background: none; color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 4px; }
.cw-icon { width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.cw-icon:disabled { opacity: 0.35; cursor: default; }
@media (max-width: 560px) { .cw-date { margin-left: 0; width: 100%; justify-content: space-between; } }

/* ---------------------------------------------------------------- layout */
.cw-play { display: grid; gap: 22px 36px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .cw-play { grid-template-columns: minmax(0, 560px) minmax(260px, 1fr); }
  body[data-size="mini"] .cw-play { grid-template-columns: minmax(0, 420px) minmax(260px, 1fr); }
}
.cw-board-col { min-width: 0; }
.cw-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cw-timer { font: 500 15px var(--font-gothic); font-variant-numeric: tabular-nums; border: 0; background: none; color: var(--ink); padding: 6px 2px; cursor: pointer; min-width: 64px; text-align: left; }
.cw-timer::before { content: "⏸ "; color: var(--muted); font-size: 12px; }
.cw-menus { display: flex; gap: 6px; }
.cw-menu { position: relative; }
.cw-menu summary { list-style: none; cursor: pointer; font: 13px var(--font-gothic); padding: 7px 12px; border: 1px solid var(--border-strong); background: var(--surface); min-height: 36px; display: flex; align-items: center; }
.cw-menu summary::-webkit-details-marker { display: none; }
.cw-menu[open] summary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cw-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 160px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08); }
.cw-menu-list button, .cw-auto { font: 13.5px var(--font-gothic); text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--ink); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.cw-menu-list button:hover { background: var(--page-color-soft); }
.cw-auto input { accent-color: var(--page-color); }
.cw-danger { color: var(--cw-wrong) !important; }

/* ---------------------------------------------------------------- grid */
.cw-board-wrap { position: relative; }
.cw-grid {
  --n: 5;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  border: 2px solid var(--cw-line); background: var(--cw-line); gap: 1px;
  width: 100%; aspect-ratio: 1; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.cw-grid.is-hidden { visibility: hidden; }
.cw-cell { position: relative; background: var(--cw-cell); display: flex; align-items: center; justify-content: center; cursor: pointer; min-width: 0; container-type: inline-size; }
.cw-cell.is-black { background: var(--cw-black); cursor: default; }
.cw-cell.is-word { background: var(--cw-word); }
.cw-cell.is-cur { background: var(--cw-cur); }
.cw-num { position: absolute; top: 2px; left: 3px; font: 500 clamp(8px, 22cqi, 13px)/1 var(--font-gothic); color: var(--ink-soft); }
.cw-letter { font: 400 clamp(14px, 58cqi, 40px)/1 'Noto Sans JP', sans-serif; color: var(--ink); margin-top: 8%; overflow: hidden; }
.cw-letter:empty::after { content: attr(data-tail); font: 400 clamp(9px, 30cqi, 16px)/1 var(--font-gothic); color: var(--muted); }
.cw-cell.is-wrong .cw-letter { color: var(--cw-wrong); }
.cw-cell.is-wrong::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1px), var(--cw-wrong) calc(50% - 1px), var(--cw-wrong) calc(50% + 1px), transparent calc(50% + 1px)); opacity: 0.55; pointer-events: none; }
.cw-cell.is-revealed .cw-letter { color: var(--cw-reveal); }
.cw-cell.is-revealed::before { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--cw-reveal) transparent transparent; }
/* 二重マス: an inner frame plus the letter label */
.cw-cell.is-kw { box-shadow: inset 0 0 0 3px var(--cw-cell), inset 0 0 0 4px var(--ink); }
.cw-cell.is-kw.is-word, .cw-cell.is-kw.is-cur { box-shadow: inset 0 0 0 3px currentColor, inset 0 0 0 4px var(--ink); color: transparent; }
.cw-cell.is-kw.is-word .cw-letter, .cw-cell.is-kw.is-cur .cw-letter { color: var(--ink); }
.cw-kw { position: absolute; right: 4px; bottom: 2px; font: 600 clamp(8px, 20cqi, 12px)/1 var(--font-gothic); color: var(--page-ink); }
.cw-cell.is-done { cursor: default; }
.cw-paused { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--surface); border: 2px solid var(--cw-line); }
.cw-paused p { font: 600 1.4rem var(--font-mincho); }

/* ---------------------------------------------------------------- clue bar + keys */
.cw-clue-bar { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 6px; align-items: stretch; margin-top: 10px; }
.cw-clue-text { text-align: left; font: 15px/1.45 var(--font-gothic); padding: 8px 12px; background: var(--cw-word); border: 0; color: var(--ink); cursor: pointer; min-height: 56px; }
.cw-clue-text strong { margin-right: 4px; }
.cw-len { color: var(--muted); font-size: 0.85em; }
.cw-keys { display: none; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
@media (pointer: coarse) { .cw-keys { display: grid; } }
.cw-key { font: 400 clamp(16px, 4.8vw, 22px)/1 'Noto Sans JP', sans-serif; padding: 0; height: clamp(38px, 10.5vw, 48px); border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 4px; cursor: pointer; touch-action: manipulation; }
.cw-key:active { background: var(--cw-word); }
.cw-key.is-fn { background: var(--paper-deep); font-size: clamp(13px, 3.8vw, 18px); }
/* Sits on the current square (moved by app.js) so a Japanese IME's candidate list opens beside it */
.cw-ime { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; font-size: 16px; caret-color: transparent; pointer-events: none; }

/* ---------------------------------------------------------------- keyword */
.cw-keyword { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); }
.cw-kw-clue { font-size: 14px; margin: 0 0 10px; color: var(--ink-soft); }
.cw-kw-boxes { display: flex; gap: 6px; flex-wrap: wrap; }
.cw-kw-box { position: relative; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font: 400 22px 'Noto Sans JP', sans-serif; background: var(--cw-cell); box-shadow: inset 0 0 0 1px var(--ink), inset 0 0 0 3px var(--cw-cell), inset 0 0 0 4px var(--ink); }
.cw-kw-label { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font: 600 11px var(--font-gothic); color: var(--page-ink); }
.cw-kw-boxes { padding-top: 16px; }
.cw-kw-answer { margin: 10px 0 0; font-size: 14px; color: var(--page-ink); }

/* ---------------------------------------------------------------- clue lists */
.cw-clues { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) and (max-width: 899px) { .cw-clues { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .cw-clues { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; } }
.cw-clue-list h2 { font: 600 0.95rem var(--font-gothic); padding-bottom: 6px; border-bottom: 1px solid var(--ink); margin-bottom: 4px; }
.cw-clue-list h2 span { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 0.85em; }
.cw-clue-list ol { list-style: none; margin: 0; padding: 0; }
.cw-clue-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 4px; padding: 7px 8px 7px 6px; font-size: 14px; line-height: 1.45; cursor: pointer; border-left: 3px solid transparent; }
.cw-clue-list li:hover { background: var(--page-color-soft); }
.cw-clue-list li.is-cur { background: var(--cw-word); border-left-color: var(--page-color); }
.cw-clue-list li.is-cross { border-left-color: var(--cw-word); }
.cw-clue-list li.is-filled .cw-clue-body { color: var(--muted); }
.cw-clue-num { font-weight: 600; text-align: right; padding-right: 4px; }
@media (pointer: coarse) and (max-width: 899px) { .cw-clues { margin-top: 4px; } }

/* ---------------------------------------------------------------- after solving */
.cw-section { margin-top: clamp(40px, 7vh, 72px); }
.cw-words { width: 100%; border-collapse: collapse; font-size: 14px; }
.cw-words th, .cw-words td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.cw-words th { font-size: 12px; font-weight: 500; color: var(--muted); border-bottom-color: var(--ink); }
.cw-word { font-size: 16px; white-space: nowrap; }
@media (max-width: 600px) { .cw-words th:last-child, .cw-words td:last-child { display: none; } }
.cw-muted { color: var(--muted); }
.cw-howto { max-width: var(--measure); padding-left: 1.1em; display: grid; gap: 8px; color: var(--ink-soft); }
.cw-stats { margin-top: 18px; font-size: 14px; color: var(--ink-soft); }
.cw-credit { margin-top: 10px; font-size: 12px; color: var(--muted); max-width: var(--measure); }
.cw-empty { padding: 48px 0; text-align: center; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- overlays */
.cw-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: var(--scrim, color-mix(in srgb, #1f1c18 35%, transparent)); }
.cw-sheet { position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); padding: clamp(22px, 4vw, 32px); display: flex; flex-direction: column; gap: 10px; }
.cw-sheet-title { font: 600 1.7rem var(--font-mincho); margin: 0; }
.cw-sheet-actions { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; margin-top: 8px; }
.cw-done-time { font: 600 2.2rem var(--font-mincho); font-variant-numeric: tabular-nums; margin: 0; }
.cw-done-kw { font-size: 15px; }
.cw-date-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.cw-date-list button { width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px; border: 0; border-bottom: 1px solid var(--border); background: none; font: 14px var(--font-gothic); color: var(--ink); cursor: pointer; text-align: left; }
.cw-date-list button.is-on { font-weight: 600; }
.cw-date-done { color: var(--page-ink); font-size: 12px; }
.cw-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; background: var(--ink); color: var(--paper); font-size: 14px; white-space: pre-line; }
.cw-next { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- settings + language */
html[data-ui="ja"] [data-ui-only="en"], html:not([data-ui="ja"]) [data-ui-only="ja"] { display: none !important; }
.cw-gear { font-size: 18px; }
@media (max-width: 560px) { .cw-date { flex: 1 1 auto; width: auto; } }
.cw-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; border-bottom: 1px solid var(--border); }
.cw-toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-soft); padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.cw-toggle input { accent-color: var(--page-color); width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }
.cw-toggle strong { color: var(--ink); font-weight: 600; }
.cw-key { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.cw-key-r { display: none; font: 400 9px var(--font-gothic); opacity: 0.7; }
.cw-keys.show-romaji .cw-key-r { display: block; }
.cw-play.no-assist .cw-menus { display: none; }
/* A word being composed with a Japanese IME, before it's committed */
.cw-cell.is-preview .cw-letter { color: var(--page-ink); text-decoration: underline dotted; text-underline-offset: 0.12em; text-decoration-thickness: 2px; }

/* Today's loose theme, under the options bar */
.cw-theme { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 14px; padding: 8px 12px; border-left: 3px solid var(--page-color); background: var(--page-color-soft, var(--paper-deep)); font: 14px var(--font-gothic); color: var(--ink); }
.cw-theme[hidden] { display: none; }
.cw-theme-k { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
:root[lang="ja"] .cw-theme-k, .cw-theme-k:lang(ja) { text-transform: none; letter-spacing: .02em; }
.cw-theme-name { font-weight: 600; font-size: 15px; }
.cw-theme-ja { color: var(--muted); }

/* Crossword+ waitlist (plus.js): quiet, never over the grid */
.cw-plus { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.cw-plus.is-compact { margin-top: 20px; }
.cw-plus-title { margin: 0 0 4px; font-weight: 600; font-size: 15px; }
.cw-plus-body { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.cw-plus-wants { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cw-plus-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cw-plus-chip { font: 13px var(--font-gothic); padding: 6px 10px; min-height: 34px; border: 1px solid var(--border-strong); border-radius: 999px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.cw-plus-chip[aria-pressed="true"] { background: var(--page-color); border-color: var(--page-color); color: #fff; }
.cw-plus-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cw-plus-email { flex: 1 1 200px; min-width: 0; font: 15px var(--font-gothic); padding: 9px 10px; min-height: 42px; border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); }
.cw-plus-submit { flex: 0 0 auto; }
.cw-plus-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.cw-plus-status { margin: 6px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.cw-plus-status:empty { display: none; }
.cw-plus-fine { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.cw-plus-not { font-size: 12px; }
.cw-plus.is-open .cw-plus-not { margin-left: 18px; }
.cw-plus-thanks { margin: 0; font-size: 14px; }
.cw-plus-about p { margin: 0 0 10px; line-height: 1.75; }
.cw-plus .cw-plus-submit { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.cw-plus .cw-plus-submit:hover { background: var(--ink); color: var(--paper); }
.cw-plus-onlist { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.cw-plus.is-compact { margin-top: 6px; padding: 12px 14px; }

/* ---------------------------------------------------------------- modes: かな · 漢字 · My deck */
.cw-modes { margin: 0 0 12px; }
.cw-modes button { min-width: 5.5em; }
.cw-plus-mark { font-size: 12px; color: var(--page-ink); margin-left: 1px; }
.cw-modes button[aria-checked="true"] .cw-plus-mark { color: inherit; }

/* Freeform grids (kanji and deck puzzles): words cross where they share a
   character, so the empty squares are just paper, not black squares */
.cw-grid.is-free { background: transparent; border-color: transparent; gap: 2px; }
.cw-grid.is-free .cw-cell.is-black { background: transparent; }
.cw-grid.is-free .cw-cell:not(.is-black) { box-shadow: 0 0 0 1px var(--cw-line); }
.cw-grid.is-free .cw-cell.is-kw { box-shadow: 0 0 0 1px var(--cw-line), inset 0 0 0 3px var(--cw-cell), inset 0 0 0 4px var(--ink); }
.cw-grid.is-kanji .cw-letter { font-family: 'Noto Sans JP', sans-serif; font-size: clamp(14px, 62cqi, 44px); }

/* Kanji tiles under the grid (every device: a mouse can tap them too) */
.cw-keys.is-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(40px, 11vw, 52px), 1fr)); }
.cw-tile { font-size: clamp(20px, 6vw, 26px); height: clamp(44px, 12vw, 52px); }

/* ---------------------------------------------------------------- My deck (deck.js) */
.cw-deck { margin: 0 0 22px; padding: 18px 20px; border: 1px solid var(--border-strong); background: var(--surface); }
.cw-deck h2 { margin: 0 0 6px; font-family: var(--font-mincho); font-weight: 600; font-size: 1.25rem; }
.cw-deck p { margin: 0 0 10px; font-size: 14px; line-height: 1.75; color: var(--ink-soft); }
.cw-deck .cw-deck-muted { font-size: 13px; color: var(--muted); }
.cw-deck-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.cw-deck input[type="text"], .cw-deck select, .cw-deck textarea { font: 15px var(--font-gothic); padding: 8px 10px; min-height: 42px; border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); max-width: 100%; }
.cw-deck input[type="text"] { flex: 1 1 220px; min-width: 0; }
.cw-deck textarea { width: 100%; min-height: 110px; font-size: 13px; box-sizing: border-box; }
.cw-deck .btn { min-height: 42px; }
.cw-deck-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.cw-deck-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.cw-deck-preview { width: 100%; overflow-x: auto; margin: 8px 0 4px; }
.cw-deck-preview table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.cw-deck-preview th, .cw-deck-preview td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-deck-preview th { background: var(--paper-deep); font-weight: 500; }
.cw-deck-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.cw-deck-list button { width: 100%; text-align: left; font: 14px var(--font-gothic); padding: 8px 10px; border: 1px solid var(--border); background: var(--paper); color: var(--ink); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.cw-deck-list button:hover { border-color: var(--ink); }
.cw-deck-status { min-height: 1.4em; font-size: 13px; color: var(--muted); }
.cw-deck-status.is-error { color: var(--cw-wrong); }
.cw-deck-sub { margin: 14px 0 6px; font-size: 15px; font-weight: 600; }
.cw-deck details { margin: 6px 0; }
.cw-deck summary { cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.cw-deck .cw-seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.cw-deck-member { font-weight: 500; color: var(--ink); }
.cw-deck-or { margin: 8px 0; font-size: 13px; color: var(--muted); }
.cw-google { min-height: 44px; margin: 6px 0; }
.cw-plans .btn { min-height: 46px; }
.cw-signin { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.cw-deck input[type="email"] { font: 15px var(--font-gothic); padding: 8px 10px; min-height: 42px; border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); flex: 1 1 220px; min-width: 0; }
.cw-empty .cw-locked { display: block; margin-bottom: 12px; }
.cw-locked-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-plusblock { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- Crossword+: its own colour (紫), so the paid
   parts read as paid, apart from the free puzzle (群青) and the sponsor ad (orange) */
:root { --plus: #7a4bb5; --plus-ink: #6a3fa3; --plus-tint: #f5effc; --plus-line: #d9c6f0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --plus: #b392e8; --plus-ink: #c7adf0; --plus-tint: #231b31; --plus-line: #4a3866; }
}
:root[data-theme="dark"] { --plus: #b392e8; --plus-ink: #c7adf0; --plus-tint: #231b31; --plus-line: #4a3866; }

.cw-plus-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--plus);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
}
:root[data-theme="dark"] .cw-plus-badge { color: #1a1324; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cw-plus-badge { color: #1a1324; } }
.cw-perks { margin: 10px 0 12px; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.cw-perks li { display: grid; align-content: start; gap: 2px; padding: 10px 12px; border: 1px solid var(--plus-line); border-radius: 6px; background: var(--paper); }
.cw-perks strong { font-size: 14px; line-height: 1.4; color: var(--ink); }
.cw-perks strong::before { content: "＋"; margin-right: 4px; color: var(--plus); font-weight: 700; }
.cw-perks span { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.cw-plus-price { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); }
.cw-plus-price strong { color: var(--plus-ink); font-size: 15px; }
.cw-plus-help { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
/* Links in the Crossword+ boxes (support email, YouTube) should look like links */
.cw-plus a, .cw-plusblock a, .cw-paywall a {
  color: var(--plus-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.cw-plus a:hover, .cw-plusblock a:hover, .cw-paywall a:hover { color: var(--plus); }
.cw-credit a { color: var(--page-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cw-plus-help { font-size: 13px; color: var(--ink-soft); }
.btn.btn-plus { background: var(--plus); border-color: var(--plus); color: #fff; font-weight: 600; }
.btn.btn-plus:hover { background: var(--plus-ink); border-color: var(--plus-ink); color: #fff; }
:root[data-theme="dark"] .btn.btn-plus, :root[data-theme="dark"] .btn.btn-plus:hover { color: #1a1324; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.btn-plus, :root:not([data-theme="light"]) .btn.btn-plus:hover { color: #1a1324; } }

/* The boxes: page section, solved screen, My deck block, past-day lock */
.cw-plus.is-section, .cw-plus.is-open, .cw-plusblock {
  border: 1px solid var(--plus-line);
  border-left: 4px solid var(--plus);
  border-radius: 8px;
  background: var(--plus-tint);
}
.cw-plus.is-section { padding: 18px 20px; }
.cw-plus.is-section .cw-plus-title { font-family: var(--font-mincho); font-size: 1.2rem; margin-bottom: 6px; }
.cw-plus.is-section .cw-plus-body { color: var(--ink-soft); }
.cw-plusblock { padding: 14px 16px; }
.cw-plusblock > p { margin-bottom: 4px; }
.cw-plusblock-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cw-plusblock-head .cw-plus-badge { margin: 0; font-size: 13px; padding: 3px 11px; }
.cw-deck .cw-plusblock-head .cw-plus-price { margin: 0; }
.cw-modes .cw-plus-mark { display: inline-block; min-width: 1.4em; padding: 0 4px; border-radius: 999px; background: var(--plus); color: #fff; font-weight: 700; line-height: 1.5; }
.cw-modes button[aria-checked="true"] .cw-plus-mark { color: #fff; }
.cw-locked { padding: 14px 16px; border: 1px solid var(--plus-line); border-left: 4px solid var(--plus); border-radius: 8px; background: var(--plus-tint); text-align: left; }
.cw-locked-msg { display: block; line-height: 1.7; }
.cw-plus.is-section .cw-plus-submit { background: var(--plus); border-color: var(--plus); color: #fff; }

/* A free player hit a limit (plus.js paywall) */
.cw-paywall { margin: 12px 0; padding: 14px 16px; border: 1px solid var(--plus-line); border-left: 4px solid var(--plus); border-radius: 8px; background: var(--plus-tint); }
.cw-deck .cw-paywall .cw-paywall-msg, .cw-paywall-msg { margin: 0 0 6px; font-size: 15px; font-weight: 700; line-height: 1.6; color: var(--ink); }
.cw-paywall .cw-plus-price { margin-bottom: 10px; }
.cw-paywall.is-nudge { animation: cw-nudge .7s ease 2; }
@keyframes cw-nudge { 50% { box-shadow: 0 0 0 4px var(--plus-line); transform: translateX(3px); } }
@media (prefers-reduced-motion: reduce) { .cw-paywall.is-nudge { animation: none; outline: 3px solid var(--plus); } }
.cw-see-all { margin-top: 8px; font-size: 14px; }

/* Puzzle history: calendar or list (browse.js) */
.cw-browse-sheet { max-width: 460px; }
.cw-browse-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.cw-browse-filter { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.cw-cal-head { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.cw-cal-head strong { font-size: 15px; }
.cw-cal-head .cw-icon:disabled { opacity: .3; cursor: default; }
.cw-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cw-cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cw-cal-day { position: relative; aspect-ratio: 1; display: grid; place-items: center; font: 14px var(--font-gothic); border-radius: 6px; color: var(--muted); }
.cw-cal-day.is-empty { opacity: .45; }
button.cw-cal-day { border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); cursor: pointer; }
button.cw-cal-day:hover { border-color: var(--ink); }
button.cw-cal-day.is-some { background: var(--page-color-soft); }
button.cw-cal-day.is-done { background: var(--page-color); border-color: var(--page-color); color: #fff; }
button.cw-cal-day.is-locked { color: var(--muted); background: transparent; border-style: dashed; }
button.cw-cal-day.is-on { box-shadow: 0 0 0 2px var(--ink); }
button.cw-cal-day.is-picked { outline: 2px solid var(--plus); outline-offset: 1px; }
.cw-cal-n { position: absolute; top: 2px; right: 4px; font-size: 10px; line-height: 1; color: inherit; opacity: .8; }
.cw-browse-list { max-height: 55vh; overflow-y: auto; }
.cw-browse-month { margin: 12px 0 2px; font-size: 14px; font-weight: 600; }
.cw-browse .cw-date-list { max-height: none; }

/* Intro: the two modes on their own lines, then How to play */
.cw-intro p { margin: 0 0 10px; }
.cw-intro-modes { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 6px; }
.cw-intro-modes li { padding-left: 14px; border-left: 3px solid var(--page-color); }
.cw-howto-btn { display: inline-flex; align-items: center; min-height: 40px; margin-top: 2px; }
#howto { scroll-margin-top: 16px; }

/* Settings: typing */
.cw-set-head { margin: 14px 0 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cw-set-radio { margin: 0; padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.cw-set-radio legend { padding: 0 0 6px; font-weight: 600; color: var(--ink); }
.cw-set-radio label { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.cw-set-radio input { accent-color: var(--page-color); width: 18px; height: 18px; margin: 0; }
.cw-timer.is-hidden { visibility: hidden; }
.cw-date-btn { display: inline-flex; align-items: center; gap: 6px; }
.cw-cal-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--page-ink); }

/* The top row: modes on the left; who's signed in and ⚙ on the right (wraps on narrow screens) */
.cw-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 14px; }
.cw-top .cw-modes { margin: 0; }
.cw-top-end { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.cw-top + .cw-bar { margin-top: 0; }
.cw-account { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 10px; min-width: 0; font-size: 13px; color: var(--muted); }
.cw-account .btn-link { font-size: 13px; }
.cw-acct-email { max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-acct-badge { margin: 0; font-size: 11px; padding: 1px 8px; }
.cw-account .cw-acct-in { min-height: 40px; padding: 6px 14px; font-size: 14px; }
/* Phones: just the badge and Sign out (the email stays in the tooltip) */
@media (max-width: 520px) { .cw-acct-email { display: none; } }

/* My deck: title with the member's status on the right; the Free strip for everyone else */
.cw-deck-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 4px 16px; margin-bottom: 6px; }
.cw-deck .cw-deck-head h2 { margin: 0; }
.cw-deck-acct { display: grid; justify-items: end; gap: 0; text-align: right; font-size: 13px; }
.cw-deck-acct .cw-deck-member { color: var(--plus-ink); font-weight: 600; }
.cw-deck-acct .btn-link { font-size: 13px; }
@media (max-width: 520px) { .cw-deck-acct { justify-items: start; text-align: left; } }
.cw-free { margin: 4px 0 14px; padding: 10px 14px; border: 1px solid var(--border); border-left: 4px solid var(--page-color); border-radius: 8px; background: var(--page-color-soft); }
.cw-free-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cw-deck .cw-free-row p { flex: 1 1 260px; margin: 0; color: var(--ink-soft); }
.cw-free-row strong { color: var(--ink); }
.cw-free-tag { padding: 2px 10px; border-radius: 999px; background: var(--page-color); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.cw-free .cw-signin { margin-top: 10px; padding-top: 10px; }
.cw-free .cw-signin > p:first-child { margin-bottom: 6px; }
.cw-plusblock.is-nudge { animation: cw-nudge .7s ease 2; }
@media (prefers-reduced-motion: reduce) { .cw-plusblock.is-nudge { animation: none; outline: 3px solid var(--plus); } }

/* My deck's main action stands out from the size/answer toggles */
.cw-deck .btn.cw-make { background: var(--page-color); border-color: var(--page-color); color: #fff; }
.cw-deck .btn.cw-make:hover { background: var(--page-ink); border-color: var(--page-ink); color: #fff; }
.cw-deck .btn.cw-make:disabled { opacity: .6; }

/* Settings: a wide popup in three columns (one on phones) */
.cw-sheet.cw-settings { max-width: 980px; gap: 0; padding: clamp(18px, 3vw, 28px) clamp(18px, 3vw, 32px); }
.cw-set-top { display: flex; align-items: center; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-strong); }
.cw-set-top .cw-sheet-title { margin-right: auto; }
.cw-set-x { width: 40px; height: 40px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--ink); cursor: pointer; border-radius: 6px; }
.cw-set-x:hover { background: var(--page-color-soft); }
.cw-set-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
.cw-set-col { min-width: 0; }
.cw-set-col .cw-set-head { margin: 14px 0 2px; }
.cw-set-col .cw-toggle:last-child, .cw-set-col .cw-set-radio:last-child { border-bottom: 0; }
@media (max-width: 860px) { .cw-set-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .cw-set-grid { grid-template-columns: 1fr; } .cw-set-top { gap: 8px; } .cw-set-top .cw-sheet-title { font-size: 1.35rem; } .cw-set-top .cw-seg button { padding-left: 10px; padding-right: 10px; } .cw-set-x { width: 34px; flex-shrink: 0; } }

/* Stripe's payment form, in a window on the page */
.cw-pay { z-index: 300; }
.cw-pay-sheet { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 10px; padding: 44px 8px 8px; }
.cw-pay-close { position: absolute; top: 6px; right: 8px; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; line-height: 1; color: #333; cursor: pointer; border-radius: 6px; }
.cw-pay-close:hover { background: #f0f0f0; }
.cw-set-grid { align-items: start; }
.cw-set-grid > .cw-set-col { margin: 0; padding: 0; }


/* Popups on phones: the popup scrolls, the page behind it doesn't (app.js adds
   .cw-lock to <html> while any popup is open). 100dvh is the visible height on
   phones (100vh includes the space behind the browser bars). */
html.cw-lock, html.cw-lock body { overflow: hidden; }
.cw-overlay { overscroll-behavior: contain; touch-action: pan-y; }
.cw-sheet, .cw-pay-sheet { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.cw-sheet.cw-settings { padding-top: 0; }
.cw-set-top { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-top: clamp(14px, 3vw, 24px); }
@media (max-width: 560px) {
  .cw-overlay { padding: 10px; }
  .cw-sheet, .cw-pay-sheet { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
}

/* Less empty paper above the puzzle than the other pages: the puzzle is the point */
.cw .page-head { padding: clamp(16px, 4vh, 44px) 0 clamp(18px, 3vh, 32px); gap: 20px; }
.cw .page-head-copy { padding-top: 0; margin-left: clamp(0px, 4vw, 60px); }
.cw .page-head .page-title { margin-bottom: 14px; }
@media (max-width: 899px) { .cw .page-head-copy { margin-left: 0; } }

/* My deck in four steps (deck.js steps()): a numbered list; done steps fold into one line */
.cw-steps { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
/* A deck with lots of fields scrolls sideways inside step 2 instead of widening the box */
.cw-step, .cw-step-body { min-width: 0; }
.cw-step-body .cw-deck-preview { max-width: 100%; }
.cw-deck-fields > label { min-width: 0; }
.cw-deck-fields select { width: 100%; }
.cw-step { padding: 10px 0; border-top: 1px solid var(--border); }
.cw-step:first-child { border-top: 0; }
.cw-step-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cw-step-n { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--page-color); color: var(--page-ink); font-size: 13px; font-weight: 700; line-height: 1; transform: translateY(-1px); align-self: center; }
.cw-step-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.cw-step-sum { font-size: 13px; color: var(--muted); }
.cw-step-note { display: block; }
.cw-step-act { margin-left: auto; font-size: 13px; }
.cw-step.is-done .cw-step-n { background: var(--page-color); color: #fff; }
.cw-step.is-done .cw-step-title { font-weight: 500; color: var(--ink-soft); }
.cw-step.is-later .cw-step-n { border-color: var(--border-strong); color: var(--muted); }
.cw-step.is-later .cw-step-title { font-weight: 500; color: var(--muted); }
.cw-step-body { padding-left: 34px; }
.cw-step-body > :first-child { margin-top: 8px; }
.cw-step-body > :last-child { margin-bottom: 0; }
.cw-steps.is-preview .cw-step { padding: 6px 0; }
@media (max-width: 520px) { .cw-step-body { padding-left: 0; } .cw-step-sum { flex-basis: 100%; padding-left: 34px; } .cw-step-act { margin-left: 34px; } }

/* The solved screen has room for the perk tiles on a computer */
.cw-sheet.cw-done-sheet { max-width: 560px; }

/* Sign in (and "Get Crossword+: 1 sign in, 2 pay") in a popup */
.cw-signin-sheet { max-width: 460px; }
.cw-signin-sheet .cw-sheet-title { margin: 0; }
.cw-signin-sheet .cw-plus-badge { margin: 0; }
.cw-signin-sheet p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ink-soft); }
.cw-signin-sheet .cw-deck-muted { font-size: 13px; color: var(--muted); }
.cw-signin-sheet .cw-deck-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cw-signin-sheet input[type="email"] { font: 15px var(--font-gothic); padding: 8px 10px; min-height: 42px; border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); flex: 1 1 200px; min-width: 0; }
.cw-signin-sheet a { color: var(--plus-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cw-pop-x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.cw-pop-x:hover { color: var(--ink); }
.cw-pop-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.cw-pop-steps li { counter-increment: s; display: flex; align-items: center; gap: 10px; }
.cw-pop-steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid var(--border-strong); font-size: 12px; font-weight: 700; }
.cw-pop-steps li.is-now { color: var(--ink); font-weight: 600; }
.cw-pop-steps li.is-now::before { border-color: var(--plus); background: var(--plus); color: #fff; }

/* A message that floats over the page (welcome, no charge, signed in) */
.cw-notice { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 12px; width: max-content; max-width: min(520px, calc(100vw - 32px)); padding: 12px 10px 12px 16px; border: 1px solid var(--plus-line); border-left: 4px solid var(--plus); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 14px; line-height: 1.5; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); animation: cw-notice-in .25s ease; }
.cw-notice.is-error { border-color: var(--cw-wrong); border-left-color: var(--cw-wrong); }
.cw-notice-x { flex: none; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
@keyframes cw-notice-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* The Crossword+ tab: "Crossword" with the purple ＋ */
.cw-modes .cw-plus-mark { margin-left: 4px; }
/* Its box: My deck and Bonus puzzles as its two parts */
.cw-deck .cw-deck-part { margin: 18px 0 4px; font-family: var(--font-mincho); font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.cw-deck .cw-deck-head + .cw-deck-part, .cw-deck .cw-deck-head + * + .cw-deck-part { margin-top: 6px; }

/* Phones: fewer rows above the puzzle. Modes, Sign in and ⚙ share a row; size and level
   share the next; then the date. */
@media (max-width: 560px) {
  .cw-top { gap: 8px; margin-bottom: 10px; }
  .cw-top-end { gap: 6px; }
  .cw-modes button { min-width: 0; padding: 8px 11px; }
  .cw-modes .cw-seg-sub { display: none; }
  .cw-account .cw-acct-in { min-height: 38px; padding: 6px 10px; font-size: 13px; letter-spacing: .02em; }
  .cw-top .cw-gear { width: 38px; height: 38px; }
  .cw-bar { gap: 8px; margin-bottom: 12px; }
  .cw-bar #size-seg button { padding: 8px 10px; }
  .cw-select-wrap { flex: 1 1 140px; min-width: 0; }
  .cw-select-wrap .cw-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .cw-select { width: 100%; min-width: 0; border-radius: 0; -webkit-appearance: none; appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 12px center, right 7px center; background-size: 5px 5px; background-repeat: no-repeat; }
  .cw-date { flex-basis: 100%; }
}

/* The page ends with the Crossword+ box; the footer follows closer than on the essay pages */
.colophon { margin-top: clamp(40px, 7vh, 72px); }

/* The free trial, above the plan buttons */
.cw-deck .cw-trial-line { margin: 12px 0 0; font-size: 14px; font-weight: 600; color: var(--plus-ink); }
