:root {
  --bg: #14161c;
  --panel: #1e212b;
  --panel-2: #262a37;
  --line: #343a4b;
  --ink: #eef1f7;
  --muted: #99a1b5;
  --accent: #7cc4ff;
  --accent-ink: #0d1017;
  --good: #58d68d;
  --bad: #f1746b;
  --hover: rgba(124, 196, 255, .08);
  /* Dark-theme logo: black and dark blue would vanish, so the same three steps, lightened. */
  --logo-th: #eef1f7;
  --logo-wo: #a9c8ee;
  --logo-p: #5aa2ea;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --panel: #ffffff;
    --panel-2: #eef0f6;
    --line: #d5d9e4;
    --ink: #151923;
    --muted: #5d6579;
    --accent: #1f6fbf;
    --accent-ink: #ffffff;
    --good: #1e8e4f;
    --bad: #c8382d;
    --hover: rgba(31, 111, 191, .07);
    --logo-th: #111418;
    --logo-wo: #0b2447;
    --logo-p: #2563a8;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 1.25rem 1rem 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; }
a { color: var(--accent); }

header.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.brand {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
}
/* TH-WO-P: THree WOrd Puzzle */
.brand .th { color: var(--logo-th); }
.brand .wo { color: var(--logo-wo); }
.brand .p { color: var(--logo-p); }
header.top nav a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: .95rem; }
header.top nav a:hover { color: var(--accent); }

p.lede { margin: 0 0 1.25rem; color: var(--muted); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card > :first-child { margin-top: 0; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }

/* ---- Word lists: hidden radios inside clickable rows ---- */
.lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 560px) { .lists { grid-template-columns: 1fr; } }
.listgroup { border: 0; margin: 0; padding: 0; min-width: 0; }
.listgroup legend {
  padding: 0;
  margin-bottom: .4rem;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.wordlist {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.word { display: flex; align-items: stretch; position: relative; }
.word + .word { border-top: 1px solid var(--line); }
.word label { flex: 1; display: block; cursor: pointer; min-width: 0; }
.word input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.word .text {
  display: block;
  padding: .6rem .7rem;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}
.word:hover { background: var(--hover); }
.word:has(input:checked) { background: var(--accent); }
.word:has(input:checked) .text { color: var(--accent-ink); font-weight: 700; }
.word:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent); }
.word .info {
  flex: none;
  width: 2.4rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.word .info:hover { color: var(--accent); background: var(--hover); }
.word:has(input:checked) .info { color: var(--accent-ink); border-left-color: transparent; }

.listgroup.locked .wordlist { border-color: var(--good); }
.listgroup.locked .word:has(input:checked) { background: var(--good); }
.listgroup.locked .word:not(:has(input:checked)) .text { opacity: .45; }
.listgroup.locked label { cursor: default; }
.listgroup.wrong .wordlist { border-color: var(--bad); animation: shake .35s; }
.listgroup.answer .word:has(input:checked) { background: var(--good); }
@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
@media (prefers-reduced-motion: reduce) { .listgroup.wrong .wordlist { animation: none; } }

.define {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.define strong { color: var(--accent); }
.define .none { color: var(--muted); }
.define a { white-space: nowrap; }

/* ---- Clue ---- */
.clue-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  margin-bottom: 1.25rem;
}
.label {
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.clue { font-size: 1.9rem; font-weight: 800; color: var(--accent); overflow-wrap: anywhere; line-height: 1.2; }

/* ---- Controls ---- */
label.field { display: block; margin-bottom: .4rem; font-weight: 600; }
input[type=text], input[type=email] {
  width: 100%;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .75rem;
  font: inherit;
}
input[type=text]:focus, input[type=email]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .4rem .5rem;
  font: inherit;
}
button, a.btn {
  display: inline-block;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: .65rem 1.2rem;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
button.primary, a.btn.primary, form > .row button[type=submit] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
button:hover, a.btn:hover { filter: brightness(1.08); background-color: var(--hover); }
button.primary:hover, a.btn.primary:hover { background: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: 400;
  text-decoration: underline;
}
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }
.toolbar label { display: inline-flex; gap: .4rem; align-items: center; }
.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }
.feedback { min-height: 1.5em; margin: 0; font-weight: 600; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }
.error {
  background: rgba(241, 116, 107, .12);
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin: 0 0 1rem;
}
.verdict { font-size: 1.4rem; font-weight: 800; margin: 0 0 .75rem; }
.verdict.win { color: var(--good); }
.link-out {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .75rem;
  font: .9rem/1.4 ui-monospace, "Cascadia Code", Consolas, monospace;
  word-break: break-all;
  text-decoration: none;
}
pre.result {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem 1rem;
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
}
.identify { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.identify .row { margin-top: .5rem; }
.identify input { flex: 1 1 12rem; width: auto; }

/* ---- History ---- */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
table.list tr.detail td { background: var(--panel-2); }
table.list td.date { white-space: nowrap; }
table.list .toggle-cell { width: 2rem; padding-left: 0; padding-right: 0; text-align: center; }
table.list th.toggle-cell .icon { width: 1rem; height: 1rem; fill: var(--muted); vertical-align: middle; }
button.toggle {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 6px;
}
.empty { color: var(--muted); }
.muted { color: var(--muted); }

footer { color: var(--muted); font-size: .8rem; margin-top: 2rem; text-align: center; }
footer a { color: var(--muted); }
.prose p, .prose li { color: var(--ink); }
.prose h1 { font-size: 1.5rem; margin-top: 0; }
[hidden] { display: none !important; }
