/* Crossword Derby — design system.
   Material: the crossword tile (ink blocks, paper cells). One accent: podium gold.
   Digits and times always monospaced — this is a stopwatch site. */
:root {
  --bg: #f6f5f1; --fg: #17161b; --muted: #6d6c75; --card: #fdfdfb; --line: #dedcd4;
  --gold: #b8860b; --gold-soft: #f4e9cf; --accent-fg: #ffffff; --ok: #1a7f37; --bad: #b42318;
  --cell: #ffffff; --cell-sel: #f2dfa9; --cell-word: #faf3df; --cell-given: #efeee8;
  --shadow: 0 1px 2px rgba(23,22,27,.07), 0 3px 10px rgba(23,22,27,.05);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141319; --fg: #ecebef; --muted: #97959f; --card: #1d1c24; --line: #312f3a;
    --gold: #d9a72e; --gold-soft: #3a3220; --accent-fg: #17161b; --ok: #4ade80; --bad: #f87171;
    --cell: #23222b; --cell-sel: #59491f; --cell-word: #2e2a20; --cell-given: #2a2932;
    --shadow: 0 1px 3px rgba(0,0,0,.45);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 720px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; } h2 { font-size: 1.1rem; }
.date, .timer, .big-time, td.t, .card-state.done { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.date { color: var(--muted); font-weight: normal; font-size: .9rem; }
.muted { color: var(--muted); }
.mono, code { font-family: var(--mono); }
.error { color: var(--bad); } .ok { color: var(--ok); }

/* Signature: the wordmark as crossword tiles — one black block between the words. */
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-bottom: 2px solid var(--fg); background: var(--card); }
.brand { display: inline-flex; gap: 2px; text-decoration: none; }
.brand .tile { width: 1.35rem; height: 1.35rem; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--fg); background: var(--cell); font: 700 .8rem/1 var(--mono); color: var(--fg); }
.brand .tile.block { background: var(--fg); border-color: var(--fg); }
.brand:hover .tile:nth-child(odd) { background: var(--cell-sel); }
.brand:hover .tile.block { background: var(--fg); }
.site-header nav { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .95rem; }
.site-header nav a { text-decoration: none; }
.site-header nav a:hover { text-decoration: underline; text-decoration-color: var(--gold); }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; }
/* 15 tiles (CROSSWORD ■ DERBY): shrink early so the wordmark never wraps on phones */
@media (max-width: 640px) { .brand .tile { width: 1.1rem; height: 1.1rem; font-size: .65rem; } .site-header { padding: .6rem .6rem; } }
@media (max-width: 400px) { .brand .tile { width: .95rem; height: .95rem; font-size: .55rem; } .brand { gap: 1px; } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; margin: 1rem 0; }
.card { display: block; position: relative; background: var(--card); border: 1.5px solid var(--fg); border-radius: 2px; padding: 1rem; color: var(--fg); box-shadow: var(--shadow); text-decoration: none; }
.card::after { content: ""; position: absolute; top: 0; right: 0; width: 10px; height: 10px; background: var(--fg); opacity: 0; }
.card:hover::after { opacity: 1; }
.card:hover { background: var(--cell-word); }
.card.disabled { opacity: .45; border-color: var(--line); }
.card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.card-state { color: var(--gold); font-weight: 700; }
.card-state.done { color: var(--ok); }
.card-state.muted { color: var(--muted); font-weight: 400; }

.streaks { display: flex; flex-wrap: wrap; gap: .7rem 1.2rem; margin: .6rem 0 1rem; font-size: .9rem; }
.btn { background: var(--card); color: var(--fg); border: 1.5px solid var(--fg); border-radius: 2px; padding: .55rem 1.2rem; font-size: 1rem; cursor: pointer; }
.btn.primary { background: var(--fg); color: var(--bg); }
.btn.primary:hover { background: var(--gold); color: var(--accent-fg); border-color: var(--gold); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .card, .btn { transition: background .12s ease, border-color .12s ease; }
}

.play-head { display: flex; justify-content: space-between; align-items: baseline; }
.timer { font: 700 1.3rem ui-monospace, Menlo, monospace; }
.start-gate { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2rem 1rem; margin: 1rem 0; }
.feedback { margin-left: .8rem; font-weight: 600; }
.feedback.bad { color: var(--bad); } .feedback.ok { color: var(--ok); }
.play-actions { margin: .9rem 0; display: flex; align-items: center; }

.puzzle-root { margin: 1rem 0 0; touch-action: manipulation; }
.grid { display: grid; gap: 2px; background: var(--line); border: 2px solid var(--fg); border-radius: 4px; width: min(92vw, 440px); user-select: none; }
.grid .cell { position: relative; background: var(--cell); aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font: 600 clamp(14px, 4.5vw, 26px)/1 ui-monospace, Menlo, monospace; cursor: pointer; }
.grid .cell.block { background: var(--fg); cursor: default; }
.grid .cell.sel { background: var(--cell-sel); }
.grid .cell.word { background: var(--cell-word); }
.grid .cell.given { background: var(--cell-given); font-weight: 800; cursor: default; }
.grid .cell .num { position: absolute; top: 1px; left: 3px; font-size: .55rem; font-weight: 400; color: var(--muted); }
.grid .cell .notes { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3,1fr); font-size: .5rem; color: var(--muted); line-height: 1; padding: 1px; }
.grid .cell.box-r { border-right: 2px solid var(--fg); }
.grid .cell.box-b { border-bottom: 2px solid var(--fg); }
.grid .cell.cage-t { border-top: 2px solid var(--fg); }
.grid .cell.cage-l { border-left: 2px solid var(--fg); }
.grid .cell .cage-label { position: absolute; top: 1px; left: 3px; font-size: .55rem; font-weight: 700; color: var(--fg); }
.grid .cell.ws-found { background: var(--cell-word); }
.grid .cell.ws-sel { background: var(--cell-sel); }

.clue-bar[hidden] { display: none; } /* author display:flex would otherwise beat the hidden attribute — the empty sticky bar swallowed pointer events over the bottom of the jigsaw canvas (2026-08-24) */
.clue-bar { position: sticky; bottom: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-top: .7rem; padding: .5rem .8rem; display: flex; align-items: center; gap: .6rem; }
.clue-bar .nav { cursor: pointer; border: none; background: none; color: var(--gold); font-size: 1.2rem; padding: .2rem .5rem; }
.clue-bar .txt { flex: 1; }
.clue-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; font-size: .92rem; }
.clue-lists h3 { margin: 0 0 .3rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.clue-lists li { cursor: pointer; padding: .15rem .3rem; border-radius: 4px; list-style: none; }
.clue-lists li.active { background: var(--cell-word); }
.clue-lists li .n { font-weight: 700; margin-right: .3rem; }
.clue-lists ul { margin: 0; padding: 0; }

.numpad { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; margin-top: .8rem; width: min(92vw, 440px); }
.numpad button { font-size: 1.2rem; padding: .6rem 0; }
.numpad .notes-on { outline: 2px solid var(--gold); }

.ws-words { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: .8rem; width: min(92vw, 480px); }
.ws-words span { font-family: ui-monospace, Menlo, monospace; font-size: .95rem; }
.ws-words span.found { text-decoration: line-through; color: var(--muted); }

.post-solve { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem; margin: 1rem 0; }
.post-solve h2 { margin-top: 0; }
.post-solve .big-time { font: 700 2rem ui-monospace, Menlo, monospace; }
.post-solve .unverified-note { color: var(--bad); font-size: .9rem; }
table.board { width: 100%; border-collapse: collapse; margin: .8rem 0; background: var(--card); border: 1.5px solid var(--fg); }
table.board th { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
table.board th, table.board td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--line); }
table.board tbody tr:first-child { background: var(--gold-soft); }
table.board tbody tr:first-child td:first-child { color: var(--gold); font-weight: 800; }
table.board tr.you td { font-weight: 700; }
table.board tr.you td:nth-child(2)::after { content: " ◂ you"; color: var(--gold); font-size: .8rem; }
.unverified { color: var(--bad); font-size: .85rem; }

.auth-form, .inline-form { display: flex; flex-direction: column; gap: .8rem; max-width: 340px; background: var(--card); padding: 1.2rem; border: 1px solid var(--line); border-radius: 10px; }
.auth-form label, .inline-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.auth-form input, .inline-form input { font-size: 1rem; padding: .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.group-list li, .archive-list li { margin: .35rem 0; }
.scope-nav .active { font-weight: 700; text-decoration: underline; }
.how { margin-top: 2rem; color: var(--muted); font-size: .92rem; }
.share-row { display: flex; gap: .6rem; margin-top: .8rem; align-items: center; }
#hidden-input { position: fixed; opacity: 0; pointer-events: none; left: -9999px; }

/* ---- 15x15 crossword: the grid needs the whole phone width and, on desktop, a clue column ---- */
main.wide { max-width: 1040px; }
.grid.wide { width: min(100%, 520px); gap: 1px; }
.grid.wide .cell { font-size: clamp(11px, 2.4vw, 22px); }
.grid.wide .cell .num { font-size: .45rem; top: 0; left: 2px; }
@media (max-width: 640px) {
  main.wide { padding-left: 4px; padding-right: 4px; }
  main.wide h1, main.wide .play-actions, main.wide .post-solve, main.wide .start-gate { margin-left: .6rem; margin-right: .6rem; }
  .grid.wide { width: calc(100vw - 8px); border-radius: 0; }   /* 15 cells × ≥24px at 390px */
  .grid.wide .cell { font-size: clamp(12px, 4vw, 18px); }
  main.wide .clue-lists { grid-template-columns: 1fr; font-size: .9rem; padding: 0 .6rem; }
}
@media (min-width: 900px) {
  main.wide .puzzle-root[data-type="crossword"] { display: grid; grid-template-columns: 520px minmax(0, 1fr); gap: 1.4rem; align-items: start; }
  main.wide .puzzle-root[data-type="crossword"] .clue-lists { margin-top: 0; max-height: 540px; overflow-y: auto; padding-right: .3rem; }
  main.wide .puzzle-root[data-type="crossword"] .clue-lists h3 { position: sticky; top: 0; background: var(--bg); padding: .2rem 0; margin: 0; }
}

/* ---- Jigsaw ---- */
.jigsaw { margin-top: .6rem; }
.jigsaw-board { display: block; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; border: 1.5px solid var(--fg); border-radius: 2px; background: var(--card); cursor: grab; }
.jigsaw-tools { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin: .4rem 0 .6rem; font-size: .9rem; }
.jigsaw-tools label { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.jigsaw-tools .btn.small { padding: .25rem .7rem; font-size: .85rem; }
.jig-status { margin-left: auto; font-family: var(--mono); color: var(--muted); }
.tier-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: .8rem 0; }
.tier { display: flex; flex-direction: column; align-items: center; gap: .1rem; min-width: 96px; padding: .5rem .8rem; border: 1.5px solid var(--fg); border-radius: 2px; background: var(--card); color: var(--fg); text-decoration: none; font: 700 1.1rem/1.2 var(--mono); }
.tier small { font: 400 .7rem/1.2 system-ui, sans-serif; opacity: .85; }
.tier.active { background: var(--fg); color: var(--bg); }
.tier:hover:not(.active) { background: var(--cell-word); }
.tier-note { display: none; font-size: .85rem; }
.credit { font-size: .8rem; margin: .5rem 0 0; }
.card-note { font-size: .8rem; font-weight: 400; }
@media (max-width: 640px) { .tier.desktop-tier { display: none; } .tier-note { display: block; } }
