:root {
  --paper: #faf7f0;
  --surface: #ffffff;
  --ink: #1f2a37;
  --muted: #5b6573;
  --line: #ddd6c8;
  --accent: #0e7c86;
  --accent-soft: #d5ecee;
  --accent-ink: #0a5f67;
  --answer: #c2410c;
  --answer-soft: #fde4d6;
  --select: #fff1b8;
  --radius: 10px;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181d;
    --surface: #1c2229;
    --ink: #e6e9ed;
    --muted: #9aa4b0;
    --line: #313a44;
    --accent: #4fc3cc;
    --accent-soft: #19393d;
    --accent-ink: #4fc3cc;
    --answer: #fb923c;
    --answer-soft: #42261a;
    --select: #4a3f12;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font: 700 1.6rem/1.1 var(--serif);
  letter-spacing: 0.01em;
}

h1 a { color: inherit; text-decoration: none; }

.tabs {
  display: flex;
  gap: 4px;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 12px 0;
}
.tabs a {
  padding: 8px 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current='page'] { color: var(--ink); border-bottom-color: var(--accent); }

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.about-link {
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}
.about-link:hover { text-decoration: underline; }
.about-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.about {
  max-width: min(360px, calc(100vw - 32px));
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.2);
}
.about::backdrop { background: rgb(0 0 0 / 0.35); }
.about p { margin: 0 0 8px; font-size: 0.92rem; }
.about a { color: var(--accent-ink); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}

.guess-pips { display: flex; gap: 6px; }
.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}
.pip.used { background: var(--accent); }

.puzzle-head h2 {
  margin: 4px 0 2px;
  font: 600 1.2rem/1.2 var(--serif);
}
.puzzle-head p { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }

.table-hint {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: opacity 0.2s;
}
.table-hint.done { opacity: 0; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font: 0.82rem/1.2 var(--mono);
}

th, td {
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}

thead th {
  padding: 8px 8px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
}

tbody tr:last-child > * { border-bottom: none; }

th.rownum {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 0 8px;
  min-width: 2.2em;
  text-align: right;
  color: var(--muted);
  font-weight: 400;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

td { padding: 0; }

td button {
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
}

td button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.in-sel-row td, .in-sel-col { background: color-mix(in srgb, var(--select) 40%, transparent); }
td.selected { background: var(--select); }
td.answer, tr.answer-row td { background: var(--answer-soft); }
td.answer button { box-shadow: inset 0 0 0 2px var(--answer); }

th .badge { margin-left: 4px; }

td button .badge {
  position: absolute;
  top: 3px;
  right: 3px;
}

.empty-cell { color: var(--muted); }

td .cell { padding: 8px; min-height: 36px; }
td.changed { background: var(--accent-soft); }
td.changed s { color: var(--muted); }
tr.dropped td .cell { text-decoration: line-through; color: var(--muted); }
.dtag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  font: 700 0.7rem/1.3 system-ui, sans-serif;
  text-decoration: none;
  vertical-align: middle;
}
.dtag.wrong { background: var(--answer); }

.choices { margin-top: 14px; }
.choices fieldset { border: 0; margin: 0; padding: 0; }
.choices legend { font-weight: 600; margin-bottom: 8px; }
.choices .sheet-buttons { justify-content: space-between; align-items: center; margin-top: 10px; }
.choice.tried > span { opacity: 0.6; }
.choice.is-answer > span { border-color: var(--answer); background: var(--answer-soft); opacity: 1; }

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.hint { color: var(--muted); font-size: 0.88rem; margin: 0; }

button.primary, button.secondary {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  font: 600 0.95rem/1 system-ui, sans-serif;
  cursor: pointer;
}
button.primary { border: 0; background: var(--accent); color: var(--paper); }
button.primary:disabled { opacity: 0.4; cursor: default; }
button.secondary { border: 1.5px solid var(--ink); background: transparent; color: var(--ink); }

.mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  vertical-align: middle;
}
.mark.exact { background: var(--accent); }
.mark.near { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.mark.small { width: 10px; height: 10px; border-width: 1.5px; border-radius: 2px; }

.tmark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  font: 700 11px/1 system-ui, sans-serif;
  vertical-align: middle;
}
.tmark.right { background: var(--ink); color: var(--paper); }

.history { list-style: none; margin: 12px 0 0; padding: 0; }
.history li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.history .what { flex: 1; }
.history .legend { color: var(--muted); font-size: 0.8rem; }

.coach {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.coach h3 { margin: 0 0 4px; font: 600 1.15rem/1.2 var(--serif); }
.coach .verdict { margin: 0 0 12px; color: var(--muted); }
.coach .purpose { margin: 12px 0 0; font-style: italic; color: var(--muted); }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.35);
  z-index: 10;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  max-width: 560px;
  max-height: 85vh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgb(0 0 0 / 0.2);
}
.sheet h2 { margin: 0 0 4px; font: 600 1.1rem/1.2 var(--serif); }
.sheet .sub { margin: 0 0 12px; color: var(--muted); font-size: 0.88rem; }
.sheet fieldset { border: 0; margin: 0 0 12px; padding: 0; }
.sheet legend { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice > span {
  display: block;
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}
.choice small { display: block; color: var(--muted); font-size: 0.8rem; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.types { display: grid; gap: 6px; }

.sheet-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.loading, .notice { color: var(--muted); }

.intro {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.help-switch { display: inline-flex; gap: 4px; margin: 0 0 12px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.help-switch button {
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.help-switch button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.intro h2 { margin: 0 0 6px; font: 600 1.15rem/1.2 var(--serif); }
.intro p, .intro li { font-size: 0.93rem; }
.how { padding-left: 1.2em; margin: 8px 0; }
.how li { margin: 6px 0; }
.purpose { font-style: italic; color: var(--muted); }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.practice-banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 0.9rem;
}

.share { margin-top: 16px; }
.streak { margin: 0 0 8px; font: 600 1rem/1.2 var(--serif); }
.share-text {
  margin: 0 0 10px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  font: 0.85rem/1.5 var(--mono);
  white-space: pre-wrap;
  user-select: all;
}
.share-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.archive { list-style: none; margin: 0; padding: 0; }
.archive a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.archive .status { color: var(--muted); font-size: 0.9rem; }
.archive .status.won { color: var(--accent); }
.archive .status.lost { color: var(--answer); }

h3.section { margin: 20px 0 6px; font: 600 1.05rem/1.2 var(--serif); }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.tile-value { font: 700 1.3rem/1.1 var(--serif); }
.tile-label { color: var(--muted); font-size: 0.72rem; }

.bar-track { display: block; flex: 1; height: 10px; }
.bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dist li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.dist-n { width: 1.2em; color: var(--muted); text-align: right; }
.dist-count { min-width: 1.5em; }

table.skills { font: inherit; font-size: 0.9rem; margin-top: 6px; }
table.skills th, table.skills td { padding: 6px 4px; white-space: normal; }
table.skills thead th { color: var(--muted); font-weight: 600; }
table.skills tbody th { font-weight: 400; }
table.skills td.num { white-space: nowrap; color: var(--muted); }
table.skills td.bar-cell { width: 35%; }

.kicker {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Outcome: icon + word + color, never color alone. */
.result {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border-left: 6px solid var(--accent);
  background: var(--accent-soft);
}
.result.lost { border-left-color: var(--answer); background: var(--answer-soft); }
.result:focus { outline: none; }
.result-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--paper);
  font: 700 1.5rem/1 system-ui, sans-serif;
}
.result.lost .result-icon { background: var(--answer); }
.result-verdict { margin: 0; font: 700 1.6rem/1.1 var(--serif); }
.result-count { font: 400 1rem/1 system-ui, sans-serif; color: var(--ink); }
.result-sub { margin: 4px 0 0; font-size: 0.9rem; }

th.answer-col { color: var(--answer); }

@keyframes reveal-pulse {
  0% { box-shadow: inset 0 0 0 0 var(--answer); }
  40% { box-shadow: inset 0 0 0 4px var(--answer); background-color: var(--answer-soft); }
  100% { box-shadow: inset 0 0 0 2px var(--answer); }
}
td.answer.reveal, tr.answer-row.reveal td { animation: reveal-pulse 600ms ease-out 1; }
@media (prefers-reduced-motion: reduce) {
  td.answer.reveal, tr.answer-row.reveal td { animation: none; }
}

.tmark.close { border-style: dashed; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend > span { white-space: nowrap; }

.coach-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.feedback-link { font-size: 0.85rem; color: var(--muted); }

.moral { margin: 16px 0 0; padding: 0; }
.moral figcaption {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.moral blockquote {
  margin: 6px 0 0;
  padding: 4px 0 4px 16px;
  border-left: 4px solid var(--accent);
  font: italic 1.15rem/1.4 var(--serif);
}

.toggle { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.toggle input { width: 20px; height: 20px; }

.button-label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font: 600 0.95rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.archive-number { margin-right: 8px; }

/* Daily set progress in the tab bar. State is carried by glyph and label, not color alone. */
.tabs { align-items: center; }
.set-steps { display: flex; gap: 6px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.step {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 44px;
  min-height: 36px;
  justify-content: center;
  padding: 4px 8px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 0.85rem/1 system-ui, sans-serif;
  cursor: pointer;
}
.step-letter { text-transform: lowercase; }
.step.solved { border-color: var(--accent); color: var(--ink); }
.step.solved .step-glyph { color: var(--accent); }
.step.missed { border-color: var(--answer); color: var(--ink); }
.step.missed .step-glyph { color: var(--answer); }
.step.current { border-color: var(--ink); color: var(--ink); }
.step.viewing { background: var(--accent-soft); }
.step:disabled { cursor: default; opacity: 0.5; border-style: dashed; }

.result { flex-wrap: wrap; }
.result-body { flex: 1 1 200px; }
.next-table { margin-left: auto; }

.class-code, .rules-of-play { font-size: 0.9rem; }

.tiles.tiles-3 { grid-template-columns: repeat(3, 1fr); }
.unlimited-banner p { margin: 0; }
.unlimited-banner p + p { margin-top: 4px; }
.rules-of-play { color: var(--muted); }

.update-notice {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
