:root {
  --ink: #16202b;
  --muted: #5b6b7b;
  --line: #d8dee6;
  --bg: #f4f1ea;       /* newsprint cream */
  --card: #ffffff;
  --accent: #11304e;   /* Times-ish navy */
  --accent-2: #b1442d; /* solver's red */
  --good: #1f7a4d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 43, .06), 0 8px 24px rgba(16, 32, 43, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 16px/1.55 "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
}

.wrap { width: min(880px, 92vw); margin: 0 auto; }

.site-header {
  background: var(--accent);
  color: #fff;
  padding: 2.4rem 0 2rem;
  border-bottom: 4px double rgba(255, 255, 255, .35);
}
.site-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  letter-spacing: .5px;
}
.site-header h1 .version {
  font: 600 .8rem/1 system-ui, sans-serif;
  vertical-align: middle;
  color: #cdd9e6;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  padding: .2em .55em;
  border-radius: 99px;
  letter-spacing: .02em;
  margin-left: .5rem;
}
.tagline { margin: .5rem 0 0; color: #cdd9e6; font-size: 1.05rem; }

main { padding: 2rem 0 3rem; }

/* Controls */
.controls {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.4rem 1.2rem;
  margin-bottom: 1.6rem;
}
.field label {
  display: block;
  font-weight: 700;
  margin-bottom: .35rem;
  font-family: system-ui, sans-serif;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
#answer {
  width: 100%;
  padding: .7rem .85rem;
  font-size: 1.3rem;
  font-family: inherit;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfbf8;
}
#answer:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
/* Practice mode: obscure the typed answer (best-effort; Blink/WebKit). */
#answer.masked { -webkit-text-security: disc; text-security: disc; }
button.ghost {
  white-space: nowrap;
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font: 600 .95rem/1 system-ui, sans-serif;
  padding: .8rem 1.1rem;
  transition: background .15s ease, border-color .15s ease;
}
button.ghost:hover { background: #f3f5f8; border-color: var(--accent); }
.toggle {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  margin: .7rem 0 0; font: 400 .9rem system-ui, sans-serif;
  color: var(--ink); text-transform: none; letter-spacing: 0;
}
.toggle input { margin: 0; }
.hint { margin: .4rem 0 0; color: var(--muted); font-size: .85rem; font-family: system-ui, sans-serif; }
.hint code, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef0f3; padding: .05em .35em; border-radius: 4px; font-size: .85em;
}

.devices-toggle { margin: 1rem 0 .4rem; }
.devices-toggle summary {
  cursor: pointer; font-family: system-ui, sans-serif; font-size: .85rem;
  font-weight: 600; color: var(--accent); user-select: none;
}
.device-grid {
  border: none; margin: .7rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .4rem .9rem;
  font-family: system-ui, sans-serif; font-size: .92rem;
}
.device-grid label { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.exp-tag {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent-2); border: 1px solid var(--accent-2);
  border-radius: 99px; padding: .1em .5em; margin-left: .35rem; vertical-align: middle;
}

.actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
button.primary {
  background: var(--accent-2);
  color: #fff; border: none; cursor: pointer;
  font: 600 1rem/1 system-ui, sans-serif;
  padding: .8rem 1.4rem; border-radius: 8px;
  transition: transform .04s ease, background .15s ease;
}
button.primary:hover { background: #9c3826; }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .55; cursor: progress; }
.status { color: var(--muted); font-family: system-ui, sans-serif; font-size: .9rem; }

/* Results */
.results { display: grid; gap: 1rem; }
.clue-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  animation: rise .25s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.clue-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.clue-device {
  font: 600 .72rem/1 system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .08em;
  color: #fff; background: var(--accent);
  padding: .3rem .55rem; border-radius: 99px;
}
.clue-score {
  font: 600 .72rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  background: #f3f5f8;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: .25rem .6rem;
  cursor: help;
  white-space: nowrap;
}
.clue-text { font-size: 1.32rem; line-height: 1.4; margin: .55rem 0 .2rem; }
.clue-text .enum { color: var(--accent-2); font-weight: 700; }
.clue-actions { margin-top: .5rem; display: flex; gap: .8rem; align-items: center; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font: 600 .85rem system-ui, sans-serif;
  padding: 0; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-2); }
.explanation {
  margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line);
  font-family: system-ui, sans-serif; font-size: .94rem; color: #2c3a48;
}
.explanation .def-label { font-weight: 700; color: var(--good); }
.notes { color: var(--accent-2); font-size: .85rem; }

.empty, .error {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; font-family: system-ui, sans-serif; color: var(--muted);
}
.error { border-left: 4px solid var(--accent-2); color: var(--accent-2); }

/* About */
.about { margin-top: 2.4rem; }
.about h2 { font-size: 1.4rem; border-bottom: 2px solid var(--line); padding-bottom: .4rem; }
.device-glossary { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; align-items: baseline; }
.device-glossary dt { font-weight: 700; color: var(--accent); }
.device-glossary dd { margin: 0; }
.disclaimer { color: var(--muted); font-size: .9rem; }

.site-footer { border-top: 1px solid var(--line); padding: 1.4rem 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: .85rem; }

@media (max-width: 520px) {
  .device-glossary { grid-template-columns: 1fr; gap: .15rem; }
  .device-glossary dt { margin-top: .5rem; }
}
