: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%;
}

.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; }

.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); }
.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;
}

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

.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;
}

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%; }

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; }

.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;
}
.next-table { margin-left: auto; }

.class-code, .rules-of-play { font-size: 0.9rem; }
.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;
}

/* On FablesCore: the core draws the page, steps, feedback, sharing and stats. These are the few
   pieces DataFables adds around its tables. */
.share-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.df-prompt { margin: 0 0 10px; color: var(--muted); font-size: 0.92rem; }
.df-verdict { margin: 10px 0 0; font-weight: 600; }
.fables-result .purpose { margin: 8px 0 0; }
.fables-help h3.section { margin-top: 16px; }
