/* Daybreak Crossword: the player (from crossword-engine site/player) plus Today and Archive.
   Tokens from the Daybreak Club look (DESIGN.md); the crossword keeps its own wordmark and icon. */

:root {
  --ink: #102f46;
  --muted: #496270;
  --ground: #edf5f5;
  --white: #fff;
  --yellow: #f9d95f;
  --yellow-light: #ffec99;
  --line: #c8d9dc;
  --blue: #d4e9ef;
  --green: #1f6552;
  --green-pale: #e2f1e8;
  --coral: #bb4a35;
  --coral-pale: #fff0e9;
  --focus: #216d9c;
  --button-hover: #254b65;
  --pencil: #7b8c96;
  --dock: #dfe7ea;
  --key-action: #b9c6cd;
  --key-shadow: #8d9ba4;
  --display: 'Bricolage Grotesque', sans-serif;
  --body: Figtree, sans-serif;
  --key-h: 46px;
  --clue-h: 74px;
}

/* Tall phones: a roomier clue bar (the keys grow by themselves). */
@media (min-height: 760px) {
  :root { --clue-h: 86px; }
}

@media (min-height: 840px) {
  :root { --clue-h: 98px; }
}

@media (max-height: 680px) {
  :root { --key-h: 42px; --clue-h: 66px; }
}

@media (max-height: 600px) {
  :root { --key-h: 38px; --clue-h: 60px; }
}

* { box-sizing: border-box; }
/* Hidden means hidden, whatever display a class gives the element. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--white);
  color: var(--ink);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}

body[data-view='solved'], body[data-view='level'], body[data-view='missing'], body.site { background: var(--ground); }

button { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }
.error { color: var(--coral); font-weight: 600; }

.app {
  width: 100%;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
}

.view { height: 100%; }
.view[hidden] { display: none; }

/* ---------- Buttons ---------- */

.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 13px 21px;
  border: 1px solid var(--ink); border-radius: 7px;
  font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
  transition: background-color 160ms;
}
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--button-hover); }
.btn-secondary { background: var(--white); color: var(--ink); }
.btn-secondary:hover { background: var(--blue); }
.btn-link { border: 0; background: transparent; color: var(--ink); min-height: 44px; padding: 8px; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--ink);
  cursor: pointer; touch-action: manipulation;
}
.icon-btn[aria-pressed='true'] { background: var(--yellow); }

.pill {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 38px; padding: 4px 10px;
  border: 1px solid var(--ink); border-radius: 30px; background: var(--white);
  font-weight: 700; font-size: 13px; line-height: 1.15; cursor: pointer; touch-action: manipulation;
}
.pill small { font-weight: 600; font-size: 10.5px; color: var(--coral); }
.pill[aria-pressed='true'] { background: var(--green-pale); border-color: var(--green); }
.pill:disabled { border-color: var(--line); color: var(--muted); cursor: default; }

/* ---------- Solve screen ---------- */

.view-solve {
  display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px; border-bottom: 1px solid var(--line); flex: none;
  background: var(--white);
}
.bar a.icon-btn { color: var(--ink); }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 2px; }
.bar-name, .bar-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-name { font-weight: 700; font-size: 15px; }
.bar-sub { font-size: 12px; color: var(--muted); }
.timer { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; padding: 0 4px; }

@media (max-width: 380px) {
  .bar { gap: 0; padding-inline: 4px; }
  .bar .icon-btn { width: 38px; }
  .timer { padding: 0 2px; }
}

/* The grid stays square: min(width, height) of its box. It asks for a full-width square and shrinks when the
   screen is short; on a tall phone the dock below takes the spare height instead of leaving a gap. */
.board-area { flex: 0 1 calc(min(100vw, 560px) - 4px); min-height: 0; padding: 8px 10px 8px; }
.board-box {
  position: relative; width: 100%; height: 100%;
  container-type: size;
  display: grid; place-items: center;
}
.board {
  --size: min(100cqw, 100cqh);
  width: var(--size); height: var(--size);
  display: grid; grid-template-rows: repeat(var(--dims), minmax(0, 1fr)); gap: 1px;
  background: var(--ink); border: 2px solid var(--ink);
  /* 1em = one square, so letters and numbers scale with the grid. */
  font-size: calc((var(--size) - 4px) / var(--dims));
}
.row { display: grid; grid-template-columns: repeat(var(--dims), minmax(0, 1fr)); gap: 1px; min-height: 0; }

.sq {
  position: relative; min-width: 0; min-height: 0;
  display: grid; place-items: center;
  border: 0; padding: 0; margin: 0;
  background: var(--white); color: var(--ink);
  font-family: var(--body); font-size: 1em; line-height: 1;
  cursor: pointer; touch-action: manipulation;
}
.sq.block { background: var(--ink); cursor: default; }
.sq.word { background: var(--blue); }
.sq.sel { background: var(--yellow); }
.sq:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; z-index: 1; }
.num {
  position: absolute; top: 0.06em; left: 0.08em;
  font-size: clamp(7px, 0.27em, 13px); font-weight: 700; line-height: 1;
}
.ltr { font-size: 0.6em; font-weight: 700; margin-top: 0.12em; text-transform: uppercase; }
.sq.pencil .ltr { color: var(--pencil); font-weight: 500; }

/* Checked wrong: a coral slash (shape, not just color). Revealed: a coral corner. Checked right: a green tick bar. */
.sq[data-mark='wrong']::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), var(--coral) calc(50% - 1px), var(--coral) calc(50% + 1px), transparent calc(50% + 1px));
  pointer-events: none;
}
.sq[data-mark='revealed']::after {
  content: ''; position: absolute; top: 0; right: 0;
  border-style: solid; border-width: 0 0.26em 0.26em 0;
  border-color: transparent var(--coral) transparent transparent;
}
.sq[data-mark='revealed'] .ltr { color: var(--coral); }
.sq[data-mark='ok'] .ltr { color: var(--green); }

.board.paused .ltr, .board.paused .num { visibility: hidden; }
.pause-cover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgb(237 245 245 / 92%);
  font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -0.03em;
}
.pause-cover[hidden] { display: none; }
.pause-cover p { margin: 0; }

.dock {
  position: relative; flex: 1 0 auto;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: var(--dock);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.toast {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 8px); z-index: 5;
  padding: 10px 14px; border-radius: 7px;
  background: var(--ink); color: var(--white);
  font-size: 14px; font-weight: 600; text-align: center;
  box-shadow: 0 5px 22px #102f4626;
}
.toast[hidden] { display: none; }

.cluebar {
  display: flex; align-items: stretch;
  flex: none; height: var(--clue-h);
  background: var(--blue); border-top: 2px solid var(--ink);
}
.clue-arrow {
  width: 44px; flex: none; border: 0; background: transparent;
  font-size: 26px; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.clue-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 4px; border: 0; background: transparent; text-align: left;
  cursor: pointer; touch-action: manipulation;
}
.clue-label { flex: none; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--coral); }
.clue-text { flex: 1; min-height: 0; overflow: hidden; font-size: 17px; font-weight: 700; line-height: 1.22; }

.help-row { display: flex; gap: 8px; padding: 7px 8px 3px; flex: none; }
.help-row .pill { flex: 1; min-width: 0; }
.key-hint { display: none; margin: 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.key-hint kbd {
  font: inherit; font-size: 12px; font-weight: 700; color: var(--ink);
  padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--white);
}

/* Keys grow with spare height, up to a comfortable size. */
.keys { display: flex; flex-direction: column; gap: 6px; padding: 5px 3px 0; flex: 3 1 auto; max-height: 203px; }
.key-row { display: flex; gap: 5px; justify-content: center; flex: 1 1 auto; }
.key-row-1 { padding: 0 5%; }
.key {
  flex: 1 1 0; min-width: 0; min-height: var(--key-h);
  border: 0; border-radius: 6px; background: var(--white); color: var(--ink);
  box-shadow: 0 1px 0 var(--key-shadow);
  font-weight: 700; font-size: 19px; padding: 0;
  cursor: pointer; touch-action: manipulation;
}
.key:active { background: var(--yellow); }
.key-action { flex: 1.5 1 0; background: var(--key-action); font-size: 13px; }
.key-back { font-size: 20px; }
.key:disabled { opacity: 0.5; cursor: default; }

/* On a tall phone there's room for the crossing clue too; tapping it switches direction. */
.cross-clue {
  display: none; align-items: baseline; gap: 8px; flex: none;
  min-height: 44px; padding: 8px 16px; border: 0; border-top: 1px solid var(--line);
  background: var(--white); color: var(--muted); text-align: left; cursor: pointer; touch-action: manipulation;
}
.cross-label { flex: none; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.cross-text { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-aspect-ratio: 10/19) and (max-width: 899px) {
  .cross-clue { display: flex; }
}
.cross-clue[hidden] { display: none; }

/* A mouse and a real keyboard: no on-screen keys, and say which keys do what. */
@media (hover: hover) and (pointer: fine) {
  .keys { display: none; }
  .key-hint { display: block; }
  .help-row { flex-wrap: wrap; padding-bottom: 10px; }
  .help-row .key-hint { flex-basis: 100%; text-align: center; }
}

.side-clues { display: none; }

/* ---------- Wide screens: grid on the left, every clue on the right ---------- */
@media (min-width: 900px) and (min-height: 560px) {
  body[data-view='solve'] .app { max-width: 1280px; }
  .view-solve {
    position: relative;
    display: grid; column-gap: 28px;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
    grid-template-areas: 'bar bar' 'tip side' 'clue side' 'board side' 'help side' 'keys side';
    padding: 0 28px 20px;
  }
  .bar { grid-area: bar; margin: 0 -28px; padding-inline: 22px; }
  .bar #open-clues { display: none; }
  .dock { display: contents; }
  .tip { grid-area: tip; margin: 14px 0 0; }
  .cross-clue { display: none; }
  .cluebar {
    grid-area: clue; margin-top: 14px; height: auto; min-height: 64px; max-height: none;
    border: 2px solid var(--ink); border-radius: 10px;
  }
  .board-area { grid-area: board; padding: 12px 0; }
  .help-row { grid-area: help; padding: 0; align-items: center; flex-wrap: nowrap; }
  .help-row .pill { flex: 0 1 200px; }
  .help-row .key-hint { flex: 1 1 auto; text-align: right; }
  .keys { grid-area: keys; margin-top: 10px; background: var(--dock); border-radius: 10px; padding: 6px 4px; max-height: none; }
  .toast { left: 28px; right: auto; bottom: 74px; max-width: 520px; }

  .side-clues {
    grid-area: side; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px;
    min-height: 0; padding: 14px 0 0;
  }
  .side-list { display: flex; flex-direction: column; min-height: 0; }
  .side-list h2 {
    flex: none; margin: 0 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--ink);
    font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  }
  .side-list ol { position: relative; list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
  .side-clue {
    width: 100%; display: flex; gap: 8px; align-items: flex-start;
    padding: 7px 8px; border: 0; border-left: 4px solid transparent; border-radius: 0 6px 6px 0;
    background: transparent; color: var(--ink); text-align: left; cursor: pointer;
  }
  .side-clue:hover { background: var(--ground); }
  .side-clue .clue-num { width: 24px; font-size: 14px; }
  .side-clue .clue-body { font-size: 14px; line-height: 1.35; }
  .side-clue[data-done='true'] { color: var(--muted); }
  .side-clue[data-cross='true'] { border-left-color: var(--blue); background: #edf6f8; }
  .side-clue[data-active='true'] { border-left-color: var(--ink); background: var(--blue); color: var(--ink); }
  .side-clue:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
}

/* ---------- All clues ---------- */

.view-clues { display: flex; flex-direction: column; background: var(--white); }
.tabs { display: flex; gap: 8px; padding: 12px 16px; flex: none; }
.tab {
  flex: 1; min-height: 44px; border: 1px solid var(--ink); border-radius: 30px;
  background: var(--white); font-weight: 700; font-size: 15px; cursor: pointer;
}
.tab[aria-selected='true'] { background: var(--ink); color: var(--white); }
.clue-list { list-style: none; margin: 0; padding: 0 8px 8px; flex: 1; min-height: 0; overflow-y: auto; }
.clue-item {
  width: 100%; min-height: 44px;
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 10px; border: 0; border-radius: 8px; background: transparent;
  text-align: left; cursor: pointer;
}
.clue-item[data-active='true'] { background: var(--blue); }
.clue-item[data-done='true'] { color: var(--muted); }
.clue-num { width: 26px; flex: none; font-weight: 800; font-size: 15px; }
.clue-body { flex: 1; font-size: 15px; line-height: 1.4; }
.clue-done { font-size: 12px; font-weight: 700; color: var(--green); padding-top: 2px; }
.clues-foot { padding: 12px 16px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
.clues-foot .btn { width: 100%; }

/* ---------- Clue level (Daily) ---------- */

.view-level { display: flex; flex-direction: column; justify-content: flex-end; background: #5b6f7c; }
.level-sheet {
  display: flex; flex-direction: column; gap: 14px;
  background: var(--white); border-radius: 18px 18px 0 0;
  padding: 12px 20px max(22px, env(safe-area-inset-bottom));
}
.grabber { align-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
.level-intro { display: flex; flex-direction: column; gap: 4px; }
.level-intro h1 { margin: 0; font-family: var(--display); font-size: 28px; line-height: 1.08; letter-spacing: -0.03em; font-weight: 700; }
.level-intro p { margin: 0; font-size: 15px; line-height: 1.5; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.level-options { display: flex; flex-direction: column; gap: 10px; }
.level-option {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--white); cursor: pointer;
}
.level-option[aria-checked='true'] { border: 2px solid var(--ink); background: #fffaf0; padding: 13px; }
.radio-dot {
  width: 22px; height: 22px; flex: none; margin-top: 2px;
  border: 2px solid var(--ink); border-radius: 50%; display: grid; place-items: center;
}
.level-option[aria-checked='true'] .radio-dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.level-text { display: flex; flex-direction: column; gap: 4px; }
.level-name { font-weight: 700; font-size: 17px; }
.level-note { font-weight: 500; font-size: 14px; color: var(--muted); }
.level-sample { font-size: 14px; line-height: 1.4; color: var(--muted); }

/* ---------- Solved ---------- */

.view-solved {
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 20px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.solved-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.solved-date { font-size: 13px; color: var(--muted); text-align: right; }
.text-link { align-self: flex-start; padding: 12px 0; font-weight: 600; font-size: 14px; color: var(--ink); }
.view-solved h1 {
  margin: 0; font-family: var(--display); font-size: 36px; line-height: 1; letter-spacing: -0.035em; font-weight: 700;
  text-wrap: balance;
}
.view-solved h1:focus { outline: none; }
.challenge-result {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--white); border: 1px solid var(--line);
  font-size: 15px; font-weight: 700; line-height: 1.4;
}
.challenge-result[data-won='true'] { background: var(--green-pale); border-color: var(--green-pale); color: var(--green); }
.challenge-result[hidden], .solved-note[hidden], .signin-box[hidden], .save-state[hidden] { display: none; }

/* The share card: navy, the grid's pattern (no letters), the time. The picture version is drawn in share.js. */
.share-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: 16px; background: var(--ink); color: var(--white);
}
.share-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.share-brand {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: -0.03em;
}
.share-date { font-size: 12px; font-weight: 600; color: #c9d6dc; white-space: nowrap; }
.share-card-body { display: flex; gap: 14px; align-items: center; }
.share-grid-box { width: 118px; flex: none; border: 2px solid var(--yellow); border-radius: 3px; line-height: 0; }
.share-grid { width: 100%; height: auto; display: block; }
.share-facts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.share-pill { background: var(--yellow); color: var(--ink); border-radius: 30px; padding: 3px 10px; font-size: 12px; font-weight: 800; }
.share-time { font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.share-lines { font-size: 13px; line-height: 1.35; color: #e4ecef; }

@media (max-width: 370px) {
  .share-grid-box { width: 96px; }
  .share-time { font-size: 30px; }
}

.share-actions { display: flex; gap: 10px; }
.share-actions .btn { flex: 1; min-width: 0; padding-inline: 10px; font-weight: 700; font-size: 15px; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.btn-yellow:hover { background: var(--yellow-light); border-color: var(--yellow-light); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn[hidden] { display: none; }
.solved-streak { margin: -4px 0 0; font-size: 15px; font-weight: 700; line-height: 1.4; color: var(--green); }
.solved-countdown { margin: 0; font-size: 15px; color: var(--ink); }
.solved-countdown a { color: var(--ink); font-weight: 700; }
.solved-streak[hidden], .solved-countdown[hidden] { display: none; }
.solved-status { margin: -4px 0 0; min-height: 0; font-size: 14px; font-weight: 600; color: var(--green); }
.solved-status:empty { display: none; }
.save-state { margin: 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.save-state[data-state='error'] { color: var(--coral); font-weight: 600; }
.save-state .btn-link { display: inline; min-height: 0; padding: 0; font-weight: 700; text-decoration: underline; cursor: pointer; }

.text-version {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; border: 1px dashed #9fb6bd; border-radius: 10px; background: var(--white);
}
.text-version-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.text-version h2 { margin: 0; font-size: 13px; font-weight: 800; color: var(--muted); }
.text-version-body { margin: 0; font-size: 13px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; user-select: text; }
.btn-small {
  min-height: 36px; padding: 0 14px; border: 1px solid var(--ink); border-radius: 30px;
  background: var(--white); font-weight: 700; font-size: 13px; cursor: pointer;
}
.btn-small:hover { background: var(--blue); }
.solved-note { margin: 0; font-size: 14px; line-height: 1.5; }
.view-solved > .btn-link { align-self: center; font-weight: 600; font-size: 14px; text-decoration: underline; cursor: pointer; }

/* Up next: the next puzzle to play (or the wait for tomorrow's), under the share buttons. */
.up-next { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.up-next[hidden] { display: none; }
.up-next h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.up-next p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.up-next p a { color: var(--ink); font-weight: 700; }
.next-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); text-decoration: none;
  transition: border-color 160ms, box-shadow 160ms;
}
.next-card:hover { border-color: var(--ink); box-shadow: 0 4px 14px #102f461f; }
.next-card:hover .btn-primary { background: var(--button-hover); }
.next-card-top { display: flex; gap: 14px; align-items: center; }
.next-card .btn { font-weight: 700; }

/* ---------- Sign-in (email + 6-digit code) ---------- */

.signin {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white);
}
.signin-title { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.signin-intro { margin: 0 0 4px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.signin-intro strong { color: var(--ink); overflow-wrap: anywhere; }
.field-label { font-size: 13px; font-weight: 700; }
.field {
  width: 100%; min-height: 48px; padding: 0 12px;
  border: 1px solid #9fb6bd; border-radius: 7px; background: var(--white); color: var(--ink);
  font-family: var(--body); font-size: 16px; caret-color: var(--coral);
}
.field::placeholder { color: #6b8290; }
.field:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--ink); }
.field-code { font-size: 26px; font-weight: 800; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 13px; line-height: 1.45; color: var(--muted); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--ink); }
.signin .btn { margin-top: 2px; }
.form-error { margin: 0; font-size: 14px; font-weight: 600; color: var(--coral); }
.form-error:empty { display: none; }
.signin-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.signin-links .btn-link, .signed-in .btn-link {
  min-height: 44px; padding: 0; border: 0; background: none;
  font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- Check / reveal sheet ---------- */

.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0; background: var(--white); color: var(--ink);
}
.sheet::backdrop { background: rgb(16 47 70 / 45%); }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 12px 20px max(20px, env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0; font-family: var(--display); font-size: 24px; letter-spacing: -0.03em; }
.sheet .small { margin: 0; }
.league-warning {
  margin: 0; padding: 10px 12px; border-radius: 7px;
  background: var(--coral-pale); font-size: 14px; line-height: 1.45;
}
.league-warning[hidden] { display: none; }
.help-group { display: flex; align-items: center; gap: 8px; }
.help-group-label { width: 58px; flex: none; font-weight: 700; font-size: 15px; }
.help-group .pill { flex: 1; min-height: 44px; font-size: 14px; }


/* ---------- Today and Archive ---------- */

::selection { background: var(--yellow); color: var(--ink); }
a { color: var(--ink); text-underline-offset: 3px; }

.site-page {
  min-height: 100vh; min-height: 100dvh;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
}

.staging-note {
  margin: 0; padding: 6px 16px;
  background: var(--ink); color: var(--white);
  font-size: 12px; font-weight: 600; text-align: center;
}
.staging-note[hidden] { display: none; }

.masthead {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.wordmark-text { display: flex; flex-direction: column; }
.wordmark-name { font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -0.04em; line-height: 1; }
.wordmark-kind { font-size: 9px; font-weight: 700; letter-spacing: 0.2em; }

.site-main { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 28px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { margin: 0; font-family: var(--display); font-size: 34px; line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; }
.page-date { font-size: 14px; font-weight: 600; color: var(--muted); }
.lede { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

.puzzle-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.puzzle-card {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); text-decoration: none;
  transition: border-color 160ms, box-shadow 160ms;
}
.puzzle-card:hover { border-color: var(--ink); box-shadow: 0 4px 14px #102f461f; }
.puzzle-card.featured { background: var(--yellow); border-color: var(--yellow); }
/* Each size its own color, as You and Them are on Duels; the grid fills itself in with it (perks.js, liveThumb). */
.puzzle-card[data-size='mini'] { --fill: #a9d4e4; background: #e8f3f8; border-color: #cfe4ec; }
.puzzle-card[data-size='midi'] { --fill: #f5d4a6; background: #fcf1e2; border-color: #f0dcc0; }
.puzzle-card[data-size='daily'] { --fill: #a9d4e4; }
.live-thumb .lt-cells rect { fill: #fff; }
.live-thumb[data-state='new'] .lt-cells rect, .live-thumb[data-state='started'] .lt-cells rect { animation: lt-fill 7s var(--d, 0s) ease-in-out infinite; }
.live-thumb[data-state='solved'] .lt-cells rect { fill: var(--fill, #a9d4e4); }
@keyframes lt-fill { 0%, 4% { fill: #fff; } 9%, 62% { fill: var(--fill, #a9d4e4); } 70%, 100% { fill: #fff; } }
.card-status[data-state='new'] { display: inline-flex; align-self: flex-start; padding: 3px 10px; border-radius: 20px; background: var(--white); color: var(--ink); }
.puzzle-card.featured .card-status[data-state='new'] { background: var(--ink); color: var(--white); }
.card-status[data-state='started'] { color: var(--focus); }
.card-status[data-state='locked'] { color: var(--muted); }
.today-head h1 { font-size: 24px; letter-spacing: -0.02em; }
.puzzle-card.featured:hover { border-color: var(--ink); }
.thumb { width: 64px; height: 64px; flex: none; display: block; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-name { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.card-meta { font-size: 13px; color: var(--muted); }
.puzzle-card.featured .card-meta { color: #3e4b3a; }
.card-status { font-size: 13px; font-weight: 700; }
.card-status[data-state='solved'] { color: var(--green); }
.puzzle-card.featured .card-status[data-state='solved'] { color: var(--ink); }
.chev { flex: none; }

.panel {
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  padding: 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--line);
}
.panel h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; line-height: 1.15; }
.panel p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.panel .btn { align-self: stretch; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.loading { color: var(--muted); font-size: 15px; }

.text-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--white); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px;
}
.text-row small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.text-row:hover { border-color: var(--ink); }

/* Archive */
.day-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.day {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
}
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day-name { margin: 0; font-size: 15px; font-weight: 700; }
.day-note { font-size: 12px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tile {
  min-height: 48px; display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 6px 8px; border: 1px solid #9fb6bd; border-radius: 8px;
  background: var(--white); color: var(--ink); text-decoration: none;
}
a.tile:hover { border-color: var(--ink); }
.tile-name { font-size: 12px; font-weight: 800; }
.tile-status { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile[data-state='solved'] { background: var(--green-pale); border-color: var(--green-pale); }
.tile[data-state='solved'] .tile-status { color: var(--green); }
.tile[data-state='missing'] { border-style: dashed; border-color: var(--line); color: var(--muted); }
.locked {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px dashed #9fb6bd; border-radius: 12px;
}
.locked-icon { width: 36px; height: 36px; flex: none; border-radius: 9px; background: #dbe8ea; display: grid; place-items: center; }
.locked-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.locked-text strong { font-size: 15px; color: var(--ink); }
a.locked { color: inherit; text-decoration: none; transition: border-color 160ms, background-color 160ms; }
a.locked:hover { border-color: var(--ink); background: var(--white); }

/* Past puzzles (/archive): a week strip with a dot per puzzle, then the picked day's puzzles. */
#archive { max-width: 640px; }
.cu-week { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px 12px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; }
.cu-week-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.cu-week-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cu-week-title strong { font-family: var(--display); font-size: 20px; letter-spacing: -0.02em; }
.cu-week-title span { font-size: 13px; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.cu-steps { display: flex; gap: 4px; }
.cu-step { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); color: var(--ink); cursor: pointer; }
.cu-step:disabled { opacity: 0.35; cursor: default; }
.cu-bar { height: 6px; margin: 0 4px; border-radius: 6px; background: var(--ground); overflow: hidden; }
.cu-bar i { display: block; height: 100%; border-radius: 6px; background: var(--green); transition: width 400ms ease; }
.cu-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cu-dayb {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 9px; min-width: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; cursor: pointer;
  transition: background-color 160ms, color 160ms;
}
.cu-dayb:hover { background: var(--ground); }
.cu-dow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.cu-num { font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.cu-dots { display: flex; gap: 3px; }
.cu-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.cu-dots i[data-s='solved'] { background: var(--green); }
.cu-dots i[data-s='started'] { background: var(--yellow); box-shadow: inset 0 0 0 1px #c9a92a; }
.cu-dots i[data-s='none'] { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.cu-dayb[data-today] .cu-dow { color: var(--ink); }
.cu-dayb[data-done]:not([aria-selected='true']) { background: var(--green-pale); }
.cu-dayb[aria-selected='true'] { background: var(--ink); color: var(--white); }
.cu-dayb[aria-selected='true'] .cu-dow { color: rgba(255, 255, 255, 0.75); }
.cu-dayb[aria-selected='true'] .cu-dots i[data-s='new'] { background: rgba(255, 255, 255, 0.3); }
.cu-dayb[aria-selected='true'] .cu-dots i[data-s='solved'] { background: #7fd3a8; }
.cu-dayb:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.cu-day { display: flex; flex-direction: column; gap: 10px; }
.cu-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px; }
.cu-day-head h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; }
.cu-day-head h2 span { font-family: var(--body); font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.cu-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 6px; border-radius: 20px; background: var(--green-pale); color: var(--green); font-size: 12px; font-weight: 800; white-space: nowrap; }
.cu-puzzles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cu-puzzle {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none;
  transition: border-color 160ms, transform 160ms;
}
a.cu-puzzle:hover { border-color: var(--ink); }
a.cu-puzzle:active { transform: scale(0.99); }
.cu-puzzle .thumb { width: 48px; height: 48px; flex: none; }
.cu-thumb-empty { width: 48px; height: 48px; flex: none; border: 1px dashed var(--line); border-radius: 4px; }
.cu-puzzle[data-state='none'] { border-style: dashed; color: var(--muted); background: transparent; }
.cu-p-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cu-p-text strong { font-family: var(--display); font-size: 19px; letter-spacing: -0.01em; }
.cu-p-text span { font-size: 13px; color: var(--muted); }
.cu-p-status { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cu-p-status[data-state='solved'] { color: var(--green); gap: 6px; }
.cu-p-status[data-state='started'] { color: var(--focus); }
.cu-p-status[data-state='new'] { padding: 7px 10px 7px 14px; border-radius: 20px; background: var(--yellow); color: var(--ink); }
.cu-puzzle[data-state='solved'] { background: var(--green-pale); border-color: var(--green-pale); }
.cu-note { margin: 0; padding: 0 2px; font-size: 13px; color: var(--muted); }
@media (max-width: 359px) { .cu-week { padding: 12px 8px 10px; } .cu-days { gap: 2px; } .cu-dow { font-size: 10px; letter-spacing: 0; } }
@media (prefers-reduced-motion: reduce) { .cu-bar i, .cu-dayb, .cu-puzzle { transition: none; } }

/* The night-ink card (like the Duels header): what a free account gets, on Today, Me and Groups (perks.js). */
.ink-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 20px; border-radius: 18px; color: var(--white);
  background: radial-gradient(120% 140% at 0% 0%, #23466a 0%, var(--ink) 55%);
}
.ink-card::after {
  content: ''; position: absolute; inset: -40% auto -40% -30%; width: 30%; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: skewX(-18deg); animation: ink-glint 7s ease-in-out infinite;
}
@keyframes ink-glint { 0%, 55% { left: -30%; } 85%, 100% { left: 120%; } }
.ink-text, .ink-art { position: relative; z-index: 1; min-width: 0; }
.ink-text { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ink-kicker { margin: 0; padding: 3px 10px; border-radius: 20px; background: var(--yellow); color: var(--ink); font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.ink-card h2 { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; color: var(--white); }
.ink-lede { margin: 0; font-size: 15px; line-height: 1.45; color: #c9dae0; max-width: 46ch; }
.ink-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 4px; }
.ink-actions span { font-size: 13px; color: #c9dae0; }
.perk-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.perk-chips li { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 8px; border-radius: 20px; background: rgba(255, 255, 255, 0.1); color: var(--white); font-size: 13px; font-weight: 700; }
.perk-chips svg { color: var(--yellow); }

.streak-art { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); }
.sa-count { display: flex; align-items: center; gap: 8px; color: var(--yellow); }
.sa-count b { font-family: var(--display); font-size: 40px; line-height: 1; color: var(--white); font-variant-numeric: tabular-nums; min-width: 1ch; }
.sa-count span { font-size: 12px; font-weight: 800; line-height: 1.1; text-transform: uppercase; letter-spacing: 0.04em; color: #c9dae0; }
.streak-art[data-full] .sa-count svg { animation: sa-flare 0.6s ease; }
@keyframes sa-flare { 50% { transform: scale(1.35) rotate(-6deg); } }
.sa-days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.sa-days li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: #9fb6c4; }
.sa-days i { width: 100%; max-width: 32px; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); transition: background-color 200ms, border-color 200ms, transform 200ms; }
.sa-days li[data-on] i { background: var(--yellow); border-color: var(--yellow); transform: scale(1.06); }
.sa-days li[data-on] { color: var(--white); }

.board-art { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: var(--white); color: var(--ink); }
.ba-head { margin: 0; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 800; }
.ba-head span:last-child { color: var(--muted); font-weight: 700; }
.board-art ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board-art li { position: relative; display: grid; grid-template-columns: 26px 40px 1fr 38px; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.ba-av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: #f5d4a6; }
.board-art li[data-you] .ba-av { background: #a9d4e4; }
.ba-bar { height: 8px; border-radius: 8px; background: var(--ground); overflow: hidden; }
.ba-bar i { display: block; height: 100%; width: 0; border-radius: 8px; background: #f5d4a6; }
.board-art li[data-you] .ba-bar i { background: #a9d4e4; }
.ba-time { text-align: right; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 200ms; }
.board-art li[data-done] .ba-time { opacity: 1; }
.ba-crown { position: absolute; left: 17px; top: -7px; font-size: 13px; color: #d9a400; opacity: 0; transform: scale(0.4); transition: opacity 200ms, transform 300ms cubic-bezier(.3, 1.6, .5, 1); }
.board-art[data-won] .ba-crown { opacity: 1; transform: scale(1); }

.perks { display: flex; flex-direction: column; gap: 10px; }
.perks h2 { margin: 0; font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; }
.perk-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.perk-grid li { display: flex; flex-direction: column; gap: 3px; padding: 12px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); font-size: 13px; line-height: 1.35; color: var(--muted); }
.perk-grid strong { font-size: 15px; color: var(--ink); }
.perk-icon { width: 34px; height: 34px; margin-bottom: 4px; border-radius: 10px; display: grid; place-items: center; background: var(--yellow-light); color: var(--ink); }

@media (min-width: 760px) {
  .ink-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; gap: 28px; padding: 28px 32px; }
  .ink-card h2 { font-size: 30px; }
  .perk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .ink-card::after, .live-thumb .lt-cells rect, .streak-art[data-full] .sa-count svg { animation: none !important; }
  .live-thumb[data-state] .lt-cells rect { fill: #fff; }
  .live-thumb[data-state='solved'] .lt-cells rect { fill: var(--fill, #a9d4e4); }
  .sa-days i, .ba-time, .ba-crown { transition: none; }
}

/* Tab bar: along the bottom on a phone, a top menu on a computer. Each tab has its color, as in the app: the sun's
   yellow for Today, the Mini's blue for Past puzzles, green for Groups, coral for Me. Duels sits in the middle as a
   raised navy disc that turns yellow on its own pages. */
.tabbar {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: flex-end; border-top: 1px solid var(--line); background: var(--white);
  border-radius: 20px 20px 0 0; box-shadow: 0 -2px 12px rgba(16, 47, 70, 0.08);
  padding: 6px 4px max(8px, env(safe-area-inset-bottom));
}
.tab-link {
  flex: 1; min-height: 52px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px;
  color: #5a7280; text-decoration: none; font-size: 11px; font-weight: 600; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab-link[aria-current='page'] { color: var(--ink); font-weight: 800; }
.tab-icon { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 30px; transition: background 0.2s; }
.tab-link[data-tab='today'] { --tab: var(--ink); --tab-pale: var(--yellow); }
.tab-link[data-tab='archive'] { --tab: var(--focus, #216d9c); --tab-pale: var(--blue); }
.tab-link[data-tab='groups'] { --tab: var(--green); --tab-pale: var(--green-pale); }
.tab-link[data-tab='me'] { --tab: var(--coral); --tab-pale: var(--coral-pale); }
.tab-link[aria-current='page'] .tab-icon { background: var(--tab-pale); color: var(--tab); }
.tab-link:active .tab-icon, .tab-link:active .tab-disc { transform: scale(0.92); }
.tab-disc {
  display: grid; place-items: center; width: 60px; height: 60px; margin-top: -30px; border-radius: 50%;
  background: radial-gradient(circle at 20% 20%, #2c5680, var(--ink) 75%); color: var(--yellow);
  border: 4px solid var(--white); box-shadow: 0 4px 10px rgba(16, 47, 70, 0.28);
  transition: transform 0.15s, background 0.2s;
}
.tab-duel[aria-current='page'] .tab-disc { background: var(--yellow); color: var(--ink); }
.tab-duel { font-weight: 700; }

@media (min-width: 760px) {
  /* The logo on the left and the main tabs on the right share one bar. */
  .site-page { max-width: 760px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; }
  .staging-note, .site-main, .site-foot { grid-column: 1 / -1; }
  .masthead { order: 1; }
  .tabbar {
    order: 2; position: static; justify-content: flex-end; gap: 4px;
    border-top: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0 8px;
  }
  .tabbar { border-radius: 0; box-shadow: none; align-items: stretch; }
  .tab-link { flex: none; flex-direction: row; justify-content: center; gap: 6px; padding: 0 8px; font-size: 15px; }
  .tab-link[aria-current='page'] { box-shadow: inset 0 -3px 0 var(--tab, var(--ink)); }
  .tab-icon { width: 34px; height: 28px; }
  .tab-disc { width: 30px; height: 30px; margin: 0; border-width: 0; box-shadow: none; }
  .tab-disc svg { width: 17px; height: 17px; }
  .tab-duel[aria-current='page'] { --tab: var(--ink); }
  .site-main { order: 3; padding-top: 28px; }
  .staging-note { order: 0; }
}

/* Today: the streak line under the heading. */
.streak-line { margin: 2px 0 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.streak-line[hidden] { display: none; }
.streak-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 1px var(--ink); flex: none; }
.streak-line[data-state='open'] .streak-dot { background: var(--white); box-shadow: 0 0 0 2px #b38a16; }

/* Me */
.me-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
}
.stat:first-child { background: var(--yellow); border-color: var(--yellow); }
.stat-value { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--muted); }
.stat:first-child .stat-label { color: #4b4a2e; }
.me-note { margin: 0; font-size: 14px; line-height: 1.5; }
.card-box { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.card-box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-box h2 { margin: 0; font-size: 15px; font-weight: 800; }
.card-box-head span { font-size: 12px; color: var(--muted); }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; text-align: center; }
.month-dow { font-size: 11px; font-weight: 700; color: var(--muted); }
.month-day {
  width: min(100%, 34px); justify-self: center;
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid var(--line); color: var(--muted);
}
.month-day[data-state='played'] { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.month-day[data-state='today'] { border: 2px solid #b38a16; color: var(--ink); }
.month-day[data-state='future'] { border-style: dashed; color: #8ea2ad; }
.month-day[data-state='blank'] { border: 0; }
.month-day[data-state='before'] { border-color: transparent; color: #8ea2ad; }
.bests { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.bests li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #e3ecee; font-size: 15px; }
.bests li:first-child { border-top: 0; }
.bests span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.bests .none { color: var(--muted); font-weight: 500; }
.bests a { color: var(--focus); font-weight: 700; }
.card-box-head a { font-size: 14px; font-weight: 700; color: var(--focus); }
.duel-name-edit { display: flex; flex-direction: column; gap: 6px; }
.duel-name-edit[hidden] { display: none; }
.duel-name-edit label { font-weight: 700; font-size: 14px; }
.duel-name-edit p { margin: 0; }
.duel-name-edit-row { display: flex; gap: 8px; }
.duel-name-edit-row input {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--ink); border-radius: 7px;
  background: var(--white); color: var(--ink); font: inherit; font-size: 16px;
}
.signed-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* Challenge link page */
.challenge-card { display: flex; flex-direction: column; gap: 14px; }
.challenge-card .share-card { max-width: 420px; }
.challenge-facts { margin: 0; font-size: 16px; line-height: 1.5; }

/* Player: shown when a puzzle can't be opened. */
.view-missing { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 24px 20px; }
.view-missing h1 { margin: 0; font-family: var(--display); font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.view-missing p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }

/* ---------- Groups (build step 5) ---------- */

.stack { display: flex; flex-direction: column; gap: 14px; }

.section-title { margin: 0 0 8px; font-size: 15px; font-weight: 800; }
.groups-section { display: flex; flex-direction: column; }
.league-badge { color: var(--muted); font-family: var(--display); font-weight: 800; font-size: 15px; }
.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.group-card {
  display: flex; align-items: center; gap: 12px; min-height: 64px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--white); color: var(--ink); text-decoration: none;
  transition: border-color 160ms;
}
.group-card:hover { border-color: var(--ink); }
.group-initial {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 16px; color: var(--ink);
}
.group-name { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.group-card .card-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-place { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.group-place strong { font-family: var(--display); font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.group-place small { font-size: 12px; color: var(--muted); }
.groups-note { margin: 0; text-align: center; }
.code-toggle { align-self: center; font-weight: 700; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.code-form, .start-form { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.code-form[hidden], .panel[hidden], .start-form[hidden] { display: none; }
.code-form p, .start-form p { margin: 0; }
.start-form { align-items: stretch; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }
.field-row .btn { flex: none; }
.field-group-code { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.plus-gate strong { color: var(--ink); }

/* A group's board */
.group-main { gap: 12px; padding-top: 10px; }
.group-head { display: flex; align-items: center; gap: 4px; margin-left: -12px; }
.back-link { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 7px; color: var(--ink); }
.back-link:hover { background: var(--blue); }
.group-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.group-title h1 {
  margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
  overflow-wrap: anywhere; text-wrap: balance;
}
.group-title span { font-size: 12px; color: var(--muted); }
.size-tabs { display: flex; gap: 6px; }
.size-tab {
  flex: 1; min-height: 44px; border: 1px solid var(--ink); border-radius: 30px; background: var(--white);
  font-weight: 700; font-size: 15px; cursor: pointer; transition: background-color 160ms;
}
.size-tab:hover { background: var(--blue); }
.size-tab[aria-pressed='true'] { background: var(--ink); color: var(--white); }
.board-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
.seg { display: inline-flex; gap: 3px; padding: 3px; border-radius: 9px; background: #dbe8ea; }
.seg button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent;
  font-weight: 700; font-size: 14px; cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--white); box-shadow: 0 1px 3px #102f461f; }
.seg-wide { display: flex; }
.seg-wide button { flex: 1; }
.level-line { font-size: 12px; color: var(--muted); text-align: right; }
.btn-inline {
  min-height: 32px; padding: 0 6px; border: 0; background: transparent; color: var(--ink);
  font-weight: 700; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.btn-inline.danger, .danger-btn { color: var(--coral); }
.danger-btn { border-color: var(--coral); }
.danger-btn:hover { background: var(--coral-pale); }
.delete-account { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; }
.delete-account .card-box { align-self: stretch; }
#delete-error:empty { display: none; }
.delete-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* The group page: its own puzzles first, then the homepage boards. */
.group-section { display: flex; flex-direction: column; gap: 10px; }
.group-section + .group-section { margin-top: 18px; }
.group-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.group-section-head h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.group-section-head span { font-size: 13px; color: var(--muted); }
.group-section .level-line { text-align: left; }
.panel-note {
  margin: 0; padding: 14px; border: 1px dashed #9fb6bd; border-radius: 14px; background: var(--white);
  font-size: 14px; line-height: 1.5; color: var(--muted);
}
/* Today: a member's group puzzles above everyone's. */
.home-groups { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.home-groups h2, .home-groups-next { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.home-groups-next { margin-bottom: 10px; }

.board-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--white);
}
.board-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 6px 4px; }
.board-card-head h2, .board-card-title { margin: 0; font-size: 15px; font-weight: 800; }
.board-card-title { padding: 6px 6px 4px; line-height: 1.35; text-wrap: balance; }
.board-card-head span { font-size: 13px; color: var(--muted); }
.board-note { margin: 0; padding: 4px 6px 6px; font-size: 12px; color: var(--muted); }
.board-empty { margin: 0; padding: 4px 6px 8px; font-size: 14px; color: var(--muted); }
.board-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.board-row, .board-you-row {
  display: flex; align-items: center; gap: 10px; min-height: 38px;
  padding: 6px 8px; border-radius: 8px; font-size: 15px;
}
.board-row[hidden] { display: none; }
.board-row[data-you='true'] { background: #fff6d6; }
.board-row[data-you='true'] .board-name { font-weight: 800; }
.board-rank { width: 22px; flex: none; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-tag { flex: none; max-width: 48%; font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }
.board-tag[data-kind='clean'] { color: var(--green); }
.board-tag[data-kind='helped'] { color: #8a6a0f; }
.board-tag[data-kind='unsaved'] { color: var(--coral); }
.board-value { flex: none; min-width: 46px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-row[data-kind='week'] .board-value { font-weight: 600; font-size: 14px; }
.board-gap { display: flex; justify-content: center; gap: 5px; padding: 4px 0; }
.board-gap span { width: 4px; height: 4px; border-radius: 50%; background: #9fb6bd; }
.board-you-row { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--line); border-radius: 0; }
.board-you-row .board-name { font-weight: 800; }
.board-you-row .board-tag { max-width: 70%; font-size: 13px; font-weight: 600; }
.see-all {
  min-height: 44px; margin-top: 4px; border: 0; border-top: 1px solid #e3ecee; background: transparent;
  font-weight: 700; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.see-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.settings-link { align-self: center; font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Sheets: invite, settings and "See all" */
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.close-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--ground); color: var(--ink); cursor: pointer;
}
.close-btn:hover { background: var(--blue); }
.sheet-lede { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.invite-url {
  margin: 0; padding: 12px; border-radius: 9px; background: var(--ground);
  font-weight: 600; font-size: 15px; overflow-wrap: anywhere; user-select: all;
}
.code-box {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px; border: 1px dashed #9fb6bd; border-radius: 12px; text-align: center;
}
.code-box span { font-size: 13px; font-weight: 700; color: var(--muted); }
.code-box strong { font-family: var(--display); font-size: 34px; letter-spacing: 0.06em; line-height: 1.1; user-select: all; }
.code-box small { font-size: 12px; color: var(--muted); }
.sheet-tall[open] { height: min(88dvh, 760px); }
.all-body { height: 100%; gap: 10px; padding-bottom: 0; }
.all-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.all-head h2 { overflow-wrap: anywhere; }
.search {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #f6fafa; color: var(--muted);
}
.search:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; outline: none; }
.all-rows { flex: 1; min-height: 0; overflow-y: auto; }
.all-empty { margin: 0; }
.all-empty[hidden] { display: none; }
.all-you { margin: 0 -20px; padding: 8px 20px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff6d6; }
.all-you .board-row { padding-inline: 0; }
.settings-block { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 12px 0 0; border: 0; border-top: 1px solid #e3ecee; }
.settings-block legend { padding: 0; margin-bottom: 8px; }
.settings-block p { margin: 0; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.member-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; border-top: 1px solid #e3ecee; }
.member-list li:first-child { border-top: 0; }
.member-name { font-weight: 600; overflow-wrap: anywhere; }
.member-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.confirm { font-size: 13px; font-weight: 600; }

/* The invite page and the Solved screen's group box */
.invite-head { display: flex; flex-direction: column; gap: 8px; }
.invite-head h1 {
  margin: 0; font-family: var(--display); font-size: 38px; line-height: 1.02; letter-spacing: -0.035em; font-weight: 700;
  overflow-wrap: anywhere; text-wrap: balance;
}
.faces { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.face-row { display: flex; padding-right: 8px; }
.face {
  width: 34px; height: 34px; margin-right: -8px; border-radius: 50%; border: 2px solid var(--ground);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--ink);
}
.invite-actions, .group-actions { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; }
.center-link { align-self: center; font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.center-link[hidden] { display: none; }
.join-form, .save-box { display: flex; flex-direction: column; gap: 10px; }
.join-name { display: flex; flex-direction: column; gap: 6px; }
.join-name p { margin: 0; }
.gate-note { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--coral-pale); font-size: 15px; line-height: 1.45; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white);
  color: var(--ink); text-decoration: none; cursor: pointer; transition: border-color 160ms;
}
.choice:hover { border-color: var(--ink); }
.choice:disabled { opacity: 0.55; cursor: default; }
.choice strong { font-size: 16px; }
.choice span { font-size: 13px; line-height: 1.4; color: var(--muted); }
.plus-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 12px; background: var(--ink); color: var(--white); }
.plus-card strong { font-size: 16px; }
.plus-card span { font-size: 13px; line-height: 1.4; color: #dbe6ea; }
a.plus-card { text-decoration: none; transition: background-color 160ms; }
a.plus-card:hover { background: var(--button-hover); }
.view-missing .btn[hidden], .plus-box .btn[hidden] { display: none; }
.plus-card .plus-soon { align-self: flex-start; margin-top: 4px; padding: 3px 10px; border-radius: 30px; background: var(--yellow); color: var(--ink); font-weight: 800; font-size: 12px; }
.solved-group { display: flex; flex-direction: column; gap: 10px; }
.solved-group[hidden] { display: none; }

/* ---------- Leagues (build step 6) ---------- */

.groups-section .locked { margin-top: 10px; color: var(--muted); }
.locked-link { color: var(--ink); text-decoration: none; transition: border-color 160ms; }
.locked-link:hover { border-color: var(--ink); }
.locked-link .locked-text { flex: 1; min-width: 0; }
.locked-link .chev { flex: none; color: var(--muted); }
.league-initial { background: var(--yellow-light); font-family: var(--display); }
.league-week { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.league-you {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white);
}
.league-you .section-title { margin: 0; }
.league-you-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.league-you-avg, .league-you-place { display: flex; flex-direction: column; gap: 2px; }
.league-you-place { align-items: flex-end; text-align: right; }
.league-you-avg strong, .league-you-place strong {
  font-family: var(--display); font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.league-you-avg strong { font-size: 34px; }
.league-you-place strong { font-size: 24px; }
.league-you-avg small, .league-you-place small { font-size: 12px; color: var(--muted); }
.league-you-text { display: flex; flex-direction: column; gap: 4px; }
.league-you-text p { margin: 0; font-size: 14px; line-height: 1.45; }
.last-week { margin: 0; padding-top: 10px; border-top: 1px solid #e3ecee; font-size: 13px; color: var(--muted); }
.board-row[data-kind='league'] .board-value { min-width: 56px; }
.zone-line {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 4px;
  font-size: 12px; font-weight: 800; white-space: nowrap;
}
.zone-line::before, .zone-line::after { content: ''; flex: 1; border-top: 1px dashed currentColor; opacity: 0.55; }
.zone-line[data-zone='up'] { color: var(--green); }
.zone-line[data-zone='down'] { color: var(--coral); }
.tier-card { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.tier-card .section-title, .tier-card p { margin: 0; }
.tier-path { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; }
.tier-path li { display: flex; align-items: center; }
.tier-step { flex: none; margin: 0 2px; color: #9fb6bd; }
.tier-path span { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 9px; border-radius: 30px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tier-path [aria-current] span { background: var(--ink); color: var(--white); font-weight: 700; }
.tier-path small { font-size: 11px; font-weight: 800; color: var(--yellow); }
.league-rules { margin: 0; }
.league-name { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.league-name p { margin: 0; }
.league-name .field-row, .league-name .form-error { flex-basis: 100%; }
.league-name .field-row[hidden] { display: none; }
.league-name .form-error:empty { display: none; }

/* Plus: the page, its plan choice and the test-mode note; the Plus card on Me */
.plus-benefits { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.plus-benefits li { display: flex; gap: 10px; align-items: flex-start; }
.plus-benefits svg { flex: none; margin-top: 1px; }
.plus-benefits span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.plus-benefits strong { font-size: 16px; color: var(--ink); }
.plus-price-line { margin: 0; font-size: 15px; font-weight: 700; }
.plan-form { display: flex; flex-direction: column; gap: 12px; }
.plan-options { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.plan-options legend { padding: 0; margin-bottom: 8px; }
.plan {
  display: flex; align-items: center; gap: 12px; padding: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--white); transition: border-color 160ms, box-shadow 160ms;
}
.plan:hover { border-color: var(--ink); }
.plan:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.plan input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--ink); }
.plan-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.plan-text strong { font-size: 16px; }
.plan-text span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-pill { flex: none; padding: 3px 10px; border-radius: 30px; background: var(--yellow); font-size: 12px; font-weight: 800; }
.test-note {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px;
  border: 1px dashed var(--coral); border-radius: 10px; background: var(--coral-pale); font-size: 14px; line-height: 1.45;
}
.test-note strong { color: var(--coral); }
.test-card { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: 0.02em; }
.plus-done { background: var(--yellow); border-color: var(--yellow); }
.plus-done p { color: var(--ink); }
.plus-box .btn { align-self: stretch; }
.plus-box-warn { border-color: var(--coral); background: var(--coral-pale); }
.plus-box .form-error:empty, .plus-have .form-error:empty { display: none; }

/* ---------- Report a problem ---------- */
.report-link, .feedback-line .btn-link {
  align-self: center; min-height: 44px; border: 0; background: none; color: var(--muted);
  font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.feedback-line { margin: 4px 0 0; display: flex; justify-content: center; align-items: center; gap: 6px; color: var(--muted); }
.feedback-line a { color: var(--muted); font-size: 14px; font-weight: 600; text-underline-offset: 3px; }
.report-kinds { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.report-kinds legend { padding: 0; margin-bottom: 8px; }
.report-kind {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 10px;
  border: 1px solid var(--line); border-radius: 30px; background: var(--white); font-size: 14px; font-weight: 600; cursor: pointer;
}
.report-kind input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.report-kind:has(input:checked) { border-color: var(--green); background: var(--green-pale); }
.report-kind:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.report-message { min-height: 88px; padding: 10px 12px; line-height: 1.45; resize: vertical; }
.report-form select.field { text-overflow: ellipsis; }

/* ---------- Beta stats (private) ---------- */
@media (min-width: 760px) {
  .site-page.stats-page { max-width: 1120px; }
}
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.stat-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.stat-value { font-family: var(--display); font-size: 32px; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat-detail { font-size: 12px; line-height: 1.4; color: var(--muted); }
.stats-totals { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.stats-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stats-table thead th { font-size: 11px; font-weight: 700; color: var(--muted); vertical-align: bottom; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table tbody th { font-weight: 700; }
.stats-table tbody tr:last-child > * { border-bottom: 0; }
.stats-table a { color: var(--ink); }
.report-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.report-item { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.report-item[data-status='open'] { border-color: var(--coral); }
.report-top { display: flex; justify-content: space-between; gap: 8px; }
.report-status { font-size: 12px; font-weight: 700; color: var(--muted); }
.report-where, .report-meta { font-size: 13px; color: var(--muted); }
.report-where a { color: var(--ink); font-weight: 700; }
.report-clue { font-style: italic; }
.report-message-text { margin: 0; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.players-csv { align-self: flex-start; }
.report-closed summary { cursor: pointer; font-size: 14px; font-weight: 700; padding: 6px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.runway-low { color: var(--coral); }

/* First-week guide (guide.js): Getting started on Today and the Solved screen, and the player's one-time tips */
.guide {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--line);
}
.guide[hidden] { display: none; }
.guide-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.guide-head h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.guide-count { flex: none; font-size: 13px; font-weight: 700; color: var(--muted); }
.guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.guide-step { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.guide-mark {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 11px;
  border-radius: 50%; border: 2px solid var(--line); color: var(--white);
}
.guide-step[data-done='true'] .guide-mark { margin-top: 0; background: var(--green); border-color: var(--green); }
.guide-step[data-next='true'] .guide-mark { background: var(--yellow); border-color: var(--ink); }
.guide-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--ink); }
a.guide-label { display: block; min-height: 44px; padding: 10px 0; text-decoration: none; }
a.guide-label:hover { text-decoration: underline; }
.guide-step[data-next='true'] .guide-label { font-weight: 800; }
.guide-step[data-done='true'] .guide-label { color: var(--muted); text-decoration: line-through; }
.guide-label small { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--muted); }
.guide-hide { align-self: flex-start; min-height: 40px; padding: 6px 0; font-size: 14px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.view-solved .guide { margin-top: 6px; }
.site-main .guide { margin: 4px 0 12px; }

/* In the dock's flow, above the clue bar, so the board shrinks to make room instead of being covered. */
.tip {
  display: flex; align-items: center; gap: 12px;
  margin: 8px; padding: 10px 10px 10px 14px; border-radius: 10px;
  background: var(--ink); color: var(--white);
}
.tip[hidden] { display: none; }
.tip-text { flex: 1; margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; }
.tip-done {
  flex: none; min-height: 40px; padding: 8px 14px; border: 0; border-radius: 8px;
  background: var(--yellow); color: var(--ink); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
}

/* Text pages (Privacy). */
.prose { max-width: 680px; line-height: 1.6; }
.prose h2 { margin: 18px 0 0; font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; }
.prose p, .prose ul { margin: 0; }
.prose ul { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.prose a { color: var(--ink); text-underline-offset: 3px; }

/* ---------- Site pages: spacing, and wide screens ---------- */

#today, .today-more, .today-links, #archive, #me, .me-cols, .me-col { display: flex; flex-direction: column; gap: 14px; }
.today-more .guide { margin: 0; }

/* Sheets (invite, settings, all members) sit in the middle of a wide screen instead of at the bottom. */
@media (min-width: 760px) {
  .sheet { margin: auto; border-radius: 18px; max-height: 88dvh; }
  .sheet .grabber { display: none; }
}

@media (min-width: 1024px) {
  /* Pages get the width of the screen. */
  .site-page { max-width: 1160px; }
  .masthead { padding: 16px 40px; }
  .tabbar { padding: 0 28px; }
  .tab-link { padding: 0 12px; }
  .site-main { padding: 36px 40px 56px; gap: 24px; }
  .site-main:not(.wide-main) { width: 100%; max-width: 840px; margin: 0 auto; }
  .page-head h1 { font-size: 44px; }
  .page-date { font-size: 15px; }

  /* Today: the puzzles side by side, then the guide beside the group lines. */
  .wide-main #today { gap: 28px; }
  .wide-main .puzzle-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
  .wide-main .puzzle-card { position: relative; flex-direction: column; align-items: flex-start; gap: 18px; padding: 22px; }
  .wide-main .puzzle-card .thumb { width: 132px; height: 132px; }
  .wide-main .puzzle-card .chev { position: absolute; top: 22px; right: 18px; }
  .wide-main .card-name { font-size: 26px; }
  .wide-main .card-meta, .wide-main .card-status { font-size: 15px; }
  .home-groups { margin-bottom: 0; }
  .today-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: start; }

  /* Archive: two days to a row. */
  .wide-main .day-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }

  /* Groups: yours on the left, the leagues on the right. Spacing comes from margins so the tall right column
     doesn't stretch the rows on the left. */
  .wide-main #groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 48px; row-gap: 0; align-items: start; }
  .wide-main #groups > * { grid-column: 1; margin-bottom: 14px; }
  .wide-main #groups > .groups-section:first-child { grid-column: 2; grid-row: 1 / span 30; }
  .wide-main #groups > .code-toggle { justify-self: center; }

  /* A group: its own puzzles and everyone's puzzles side by side. */
  .wide-main #group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; row-gap: 14px; align-items: start; }
  .wide-main #group > :not(.group-section) { grid-column: 1 / -1; }
  .wide-main #group > .settings-link { justify-self: start; }
  .wide-main #group .group-section + .group-section { margin-top: 0; }

  /* A league: your week on the left, the standings on the right. */
  .wide-main #league { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; row-gap: 0; align-items: start; }
  .wide-main #league > * { grid-column: 1; margin-bottom: 14px; }
  .wide-main #league > .group-head, .wide-main #league > .league-week { grid-column: 1 / -1; }
  .wide-main #league > .board-card { grid-column: 2; grid-row: 3 / span 30; }
  .wide-main #league:not(:has(> .board-card)) { grid-template-columns: minmax(0, 640px); }

  /* You: your days on the left; groups, Plus and best times on the right. */
  .wide-main .me-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: start; }
  .wide-main #me:not(:has(.me-cols)), .wide-main .feedback-line { max-width: 560px; }
  .wide-main .delete-account { align-items: flex-start; }
}

/* ---------- Signed out on Today: the welcome, what makes it different, the sign-in band; the site footer ---------- */

.welcome { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 6px; }
.welcome-text { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.welcome-kicker { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); }
.welcome h2 {
  margin: 0; font-family: var(--display); font-size: 34px; font-weight: 700; line-height: 1.05; letter-spacing: -0.035em;
  text-wrap: balance;
}
.welcome-lede { margin: 0; font-size: 17px; line-height: 1.5; color: var(--muted); max-width: 540px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.welcome-points { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; font-weight: 600; color: var(--muted); }
.welcome-points li { display: flex; align-items: center; gap: 6px; }
.welcome-points li::before {
  content: ''; width: 8px; height: 4px; margin-top: -3px;
  border-left: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(-45deg);
}
.welcome-art { display: none; }
.welcome-grid { display: block; width: 100%; height: auto; }
.welcome-grid text { font-family: var(--body); }
.welcome:not([hidden]) + .page-head { padding-top: 16px; border-top: 1px solid var(--line); }
/* After a first visit the puzzles are what matter on a phone, so the welcome there is just the line and Sign in. */
@media (max-width: 759px) {
  .welcome.returning h2 { font-size: 26px; }
  .welcome.returning .welcome-lede, .welcome.returning .welcome-points { display: none; }
}

.features { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.features h2 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.feature-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feature { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.feature-icon {
  width: 44px; height: 44px; margin-bottom: 4px; border-radius: 50%;
  display: grid; place-items: center; background: var(--yellow-light); color: var(--ink);
}
.feature h3 { margin: 0; font-size: 17px; font-weight: 800; }
.feature p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }


.site-foot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 20px 22px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.site-foot p { margin: 0; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; }
.foot-links a { color: var(--muted); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.foot-links a:hover { color: var(--ink); }

@media (min-width: 760px) {
  .site-foot { order: 4; flex-direction: row; justify-content: space-between; }
  .welcome { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: center; }
  .welcome h2 { font-size: 46px; }
  .welcome-art { display: block; max-width: 340px; justify-self: end; width: 100%; }
  .feature-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .site-foot { padding: 22px 40px 28px; font-size: 14px; }
  .welcome { padding: 4px 0 8px; gap: 48px; }
  .welcome h2 { font-size: 58px; }
  .welcome-lede { font-size: 20px; }
  .welcome-points { font-size: 15px; }
  .welcome-art { max-width: 380px; }
  .features { margin-top: 12px; gap: 18px; }
  .features h2 { font-size: 30px; }
  .feature-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
  .feature { padding: 22px 20px; }
  .feature p { font-size: 16px; }
  .wide-main .lede, .wide-main .text-row small { font-size: 15px; }
}

/* ---------- Big screens: the page fills the window ---------- */

@media (min-width: 760px) {
  /* The footer sits at the bottom of the window on a short page, not halfway up it. */
  .site-page { grid-template-rows: auto auto 1fr auto; align-content: stretch; }
  .staging-note { grid-row: 1; }
  .masthead { grid-row: 2; grid-column: 1; }
  .tabbar { grid-row: 2; grid-column: 2; }
  .site-main { grid-row: 3; }
  .site-foot { grid-row: 4; }
}
@media (min-width: 1024px) {
  /* The line under the tabs runs the whole width of the window. */
  html, body { overflow-x: clip; }
  .site-page::before {
    content: ''; grid-row: 2; grid-column: 1 / -1; margin-inline: calc(50% - 50vw);
    border-bottom: 1px solid var(--line); pointer-events: none;
  }
  .tabbar { border-bottom: 0; }
}
/* Wider from 1440px, then drawn larger: a laptop at 1600px+ or a monitor gets the same page at a size that fills it,
   instead of a small strip in the middle. The puzzle page (play.html) has its own layout and isn't scaled. */
@media (min-width: 1024px) {
  /* Past puzzles: the week and the notes on the left, the chosen day's puzzles on the right. */
  .wide-main #archive {
    max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    column-gap: 32px; row-gap: 14px; align-items: start;
  }
  .wide-main #archive > * { grid-column: 1; }
  .wide-main #archive > #cu-panel { grid-column: 2; grid-row: 1 / span 10; }
}
@media (min-width: 1440px) { .site-page { max-width: 1280px; } }
@media (min-width: 1600px) { .site-page { zoom: 1.125; min-height: calc(100dvh / 1.125); } }
@media (min-width: 1880px) { .site-page { zoom: 1.25; min-height: calc(100dvh / 1.25); } }
@media (min-width: 2400px) { .site-page { zoom: 1.5; min-height: calc(100dvh / 1.5); } }
