/* The Alphabet Vault: quiet, bookish look. Cream paper, ink text, one accent. */
:root {
  --paper: #faf6ee;
  --card: #fffdf8;
  --ink: #23201b;
  --muted: #6d665a;
  --line: #e2dacb;
  --accent: #7a2e2a;
  --accent-ink: #fff;
  --ok: #2f6b3a;
  --bad: #9b2c22;
  --hl: #f4d98b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
body.admin { --paper: #f4f3f0; --accent: #33415c; }
main { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h1 { font-size: 2.1rem; margin: .4em 0 .5em; }
h2 { font-size: 1.45rem; margin-top: 1.8em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.tagline { font-family: var(--serif); font-style: italic; font-size: 1.2rem; margin-top: -.6em; }
.small { font-size: .875rem; }

header.top { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-family: var(--serif); font-size: 1.35rem; color: var(--ink); text-decoration: none; letter-spacing: .02em; }
.brand span { font: 600 .7rem var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-left: 6px; }
nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; }
nav a { text-decoration: none; color: var(--ink); }
nav a:hover { color: var(--accent); }
footer.bottom { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; margin: 16px 0; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.book { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 22px; transition: border-color .15s; }
.book:hover { border-color: var(--accent); }
.book .letter { font-family: var(--serif); font-size: 3.2rem; line-height: 1; color: var(--accent); }
.flash { padding: 12px 16px; border-radius: 8px; margin: 8px 0 16px; border: 1px solid; }
.flash.ok { background: #edf6ee; border-color: #b9d8be; color: var(--ok); }
.flash.error { background: #fbeeec; border-color: #e7c1bb; color: var(--bad); }
.result { font-family: var(--serif); font-size: 1.6rem; text-align: center; padding: 26px; }
.result.ok { color: var(--ok); }
.result.bad { color: var(--bad); }

form.stack { display: grid; gap: 14px; max-width: 520px; }
label { display: block; font-weight: 600; font-size: .95rem; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 4px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  font: inherit; color: var(--ink); }
textarea { min-height: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 5px; }
button, .button { display: inline-block; padding: 9px 18px; border: 0; border-radius: 7px; background: var(--accent);
  color: var(--accent-ink); font: 600 .95rem var(--sans); cursor: pointer; text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--bad); }
button.link { background: none; color: var(--ink); padding: 0; font-weight: 400; font-size: 1rem; }
button.link:hover { color: var(--accent); }
form.inline { display: inline; }
.hp { position: absolute; left: -5000px; }

/* Answer entry: 60 two-digit boxes */
.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.answers label { font: 600 .7rem var(--sans); color: var(--muted); text-align: center; }
.answers input { text-align: center; font: 600 1.15rem ui-monospace, Menlo, Consolas, monospace; padding: 6px 2px; letter-spacing: .1em; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f6f1e6; }
body.admin table.list th { background: #ecebe7; }
table.list tr:last-child td { border-bottom: 0; }
.rank { font-family: var(--serif); font-size: 1.2rem; width: 3em; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eee6d6; color: var(--muted); white-space: nowrap; }
.badge.ok { background: #e2f0e4; color: var(--ok); }
.badge.bad { background: #f6e0dc; color: var(--bad); }
.badge.hall { background: var(--hl); color: #5b4300; }
.err { color: var(--bad); }
.warn { color: #8a5a00; }
.scroll { overflow-x: auto; }

/* Grids */
table.grid { border-collapse: collapse; font: 600 13px ui-monospace, Menlo, Consolas, monospace; margin: 8px 0; }
table.grid th { font: 500 10px var(--sans); color: var(--muted); padding: 0 3px; }
table.grid td { width: 22px; height: 22px; text-align: center; border: 1px solid var(--line); background: #fff; }
table.grid td.hl { background: var(--hl); }
table.grid td.last { box-shadow: inset 0 0 0 2px var(--bad); border-radius: 50%; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 560px) {
  h1 { font-size: 1.7rem; }
  table.grid td { width: 15px; height: 15px; font-size: 10px; }
  table.grid th { font-size: 8px; padding: 0 1px; }
}

@media print {
  header.top, footer.bottom, .noprint { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .spread { page-break-after: always; }
}

/* Cipher puzzles */
.cipher { font: 600 1.25rem/1.9 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; word-spacing: .3em; }
.cipher u { text-decoration-thickness: 2px; text-underline-offset: 5px; }

/* leaderboard Key picker */
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.keys a { display: inline-block; min-width: 2.2em; text-align: center; padding: 4px 12px; border-radius: 99px; border: 1px solid #d9cfbd; text-decoration: none; color: var(--ink); background: #fff; font-weight: 600; }
.keys a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.keychip { display: inline-block; min-width: 1.6em; text-align: center; font-size: .75rem; font-weight: 700; padding: 1px 6px; margin: 1px 2px 1px 0; border-radius: 4px; background: #eee6d6; color: var(--muted); }
.keychip.hall { background: var(--hl); color: #5b4300; }

/* homepage book adverts */
.hero { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 28px; align-items: center; background: var(--card);
        border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin: 18px 0 24px; }
.hero .cover { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.hero h2 { font-family: var(--serif); font-size: 2.4rem; margin: .1em 0 .3em; }
.hero h3 { font-family: var(--serif); font-size: 1.5rem; margin: .1em 0 .3em; }
.hero .eyebrow { font: 700 .75rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.hero.small { grid-template-columns: minmax(0, 140px) 1fr; gap: 18px; padding: 16px; margin: 0; }
.side-books { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 24px; }
.button.big { font-size: 1.1rem; padding: 12px 22px; }
.button.disabled { opacity: .7; cursor: default; }
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; padding: 16px; }
  .hero > a, .hero > .cover { max-width: 240px; margin: 0 auto; }
  .hero h2 { font-size: 1.9rem; }
  .hero.small { grid-template-columns: 100px 1fr; }
  .side-books { grid-template-columns: 1fr; }
}
.hero .tag-row { align-items: center; gap: 10px; }

/* admin preview of a draft book */
.preview-bar { background: #33415c; color: #fff; padding: 8px 16px; text-align: center; font-size: .95rem; }
.preview-bar button.link { color: #fff; text-decoration: underline; font-size: .95rem; margin-left: 8px; }

/* number code puzzles */
.numcode { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.nc-word { display: inline-flex; gap: 3px; align-items: flex-end; }
.nc-cell { display: inline-flex; flex-direction: column; align-items: center; width: 1.9em; }
.nc-cell .nc-l { width: 1.9em; height: 1.9em; border: 1px solid var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; background: #fff; }
.nc-cell .nc-n { font-size: .75em; color: var(--muted); }
.nc-cell.u .nc-l { border-bottom: 3px solid var(--accent); }
.nc-p { font-weight: 700; padding-bottom: 1.2em; }
table.nc-key { border-collapse: collapse; margin-top: 16px; }
table.nc-key th, table.nc-key td { border: 1px solid #cfc6b4; width: 1.9em; height: 1.6em; text-align: center; font-size: .85em; }
table.nc-key th { color: var(--muted); font-weight: 400; }
table.nc-key td { height: 1.9em; font-weight: 700; }
.nc-cell.u { border-bottom: 3px solid var(--ink); padding-bottom: 2px; }
