:root {
  --paper: #f4ede1;
  --paper-2: #f8f3ea;
  --page: #efe6d6;
  --ink: #3b332d;
  --ink-soft: #6d625a;
  --muted: #8d8177;
  --accent: #8a473c;
  --accent-dark: #6e362d;
  --line: #d8ccba;
  --frame: #8b7a67;
  --sq-cream: #f5eee1;
  --sq-tan: #eddcc2;
  --sq-grey: #e1dcd0;
  --sq-sel: #f6e2ae;
  --serif: "Cormorant Garamond", "Georgia", serif;
  --sans: "PT Sans", "Helvetica Neue", Arial, sans-serif;
  --script: "Marck Script", cursive;
  --shadow-tan: #c7ad86;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0; color: var(--ink); font-family: var(--serif); font-size: 18px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

.page { max-width: 1240px; margin: 0 auto; padding: 4px 14px 40px; }

/* ------------------------------------------------------------------ top bar (shared by the game and the bookcase) */
.topbar {
  max-width: 1240px; margin: 0 auto; padding: 18px 24px 16px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 16px;
}
.brand { font-family: var(--script); color: var(--accent); font-size: 30px; text-decoration: none; line-height: 1; }
.topnav { display: flex; gap: 44px; justify-content: flex-end; }
.topnav a {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: .12em; font-size: 15px;
  color: #4a413a; text-decoration: none; padding: 4px 0; border-bottom: 1.5px solid transparent;
}
.topnav a:hover { color: var(--accent); }
.topnav a[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); }
/* the name on the left, the links on the right; narrower: closer links; phones: the name on its own line,
   the four links spread across the width below it */
@media (max-width: 1000px) {
  .topnav { gap: 28px; }
}
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; padding: 12px 14px 8px; }
  .brand { font-size: 26px; }
  .topnav { justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
  .topnav a { font-size: 13px; letter-spacing: .06em; }
}

/* ------------------------------------------------------------------ board */
.board {
  display: grid;
  grid-template-columns: 1.02fr repeat(9, 1fr) 1.02fr;
  grid-template-rows: 1.02fr repeat(9, 1fr) 1.02fr;
  background: var(--paper);
  border: 4px solid var(--frame);
  box-shadow: 0 0 0 1px #c9baa4, 0 6px 22px rgba(80, 60, 40, .12);
  aspect-ratio: 1 / 1;
  gap: 0;
}
.sq {
  position: relative;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 4px 3px;
  font-family: var(--sans); font-weight: 700; font-size: clamp(9px, 1.25vw, 15px); line-height: 1.2;
  color: #4a413a;
  background: var(--sq-cream);
  border: 1px solid #cdbfa9;
  margin: -0.5px;
  user-select: none;
  transition: background .15s, box-shadow .15s;
  overflow-wrap: break-word;
}
.sq.tan { background: var(--sq-tan); }
.sq.grey { background: var(--sq-grey); }
.sq.filter { cursor: pointer; }
.sq.filter:hover { background: #f9f3e6; box-shadow: inset 0 0 0 2px #d9c29a; }
.sq.tan.filter:hover { background: #f2e4cd; }
.sq.passive { color: #7b7168; cursor: help; }
.sq.on {
  background: var(--sq-sel) !important;
  box-shadow: inset 0 0 0 4px var(--accent) !important;
  z-index: 2;
}
.sq .param {
  position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%);
  font-size: .82em; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 9px; padding: 0 6px; line-height: 16px; white-space: nowrap;
}

/* ------------------------------------------------------------------ center */
.center {
  grid-column: 2 / 11; grid-row: 2 / 11;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 0 5%;
  padding: 5.5% 6% 4%;
  overflow: hidden; min-height: 0;
}
.center-left, .center-right { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.center-right { border-left: 1.5px solid var(--line); padding-left: 9%; margin-top: 3%; }
/* conditions + filters scroll; the book count below stays visible */
.cr-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 6px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
  padding-bottom: 24px;
}
.kicker-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.kicker {
  font-family: var(--sans); font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); font-size: clamp(11px, 1.45vw, 17px);
}
.link {
  background: none; border: 0; padding: 2px 0; color: var(--accent);
  border-bottom: 1.5px solid var(--accent); font-family: var(--serif); font-size: clamp(14px, 1.5vw, 19px);
}
.link:hover { color: var(--accent-dark); }
h1 {
  font-family: var(--serif); font-weight: 600; margin: .12em 0 .15em; letter-spacing: .005em;
  font-size: clamp(36px, 5.6vw, 70px); line-height: 1.05;
}
hr { border: 0; border-top: 1.5px solid var(--line); margin: 0 0 6%; width: 100%; }
hr.thin { margin: 6% 0 4%; }
.turn { display: flex; align-items: baseline; gap: .45em; flex-wrap: wrap; margin-bottom: 4%; }
.turn-label { font-size: clamp(18px, 2.3vw, 28px); color: var(--ink-soft); }
.script { font-family: var(--script); color: var(--accent); font-size: clamp(24px, 3.2vw, 40px); line-height: 1; }


.btn-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 5%; }
.btn {
  background: var(--accent); color: #fbf3ea; border: 0; border-radius: 1px;
  padding: .55em 1.3em; font-family: var(--sans); font-size: clamp(14px, 1.7vw, 21px);
  box-shadow: 8px 8px 0 var(--shadow-tan); transition: transform .08s, box-shadow .08s, background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translate(3px, 3px); box-shadow: 5px 5px 0 var(--shadow-tan); }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: none; border: 1.5px solid var(--accent); padding: calc(.55em - 1.5px) 1.1em; }
.btn-ghost:hover { background: #efe2cf; color: var(--accent-dark); }
.btn-ghost:active { transform: translate(1px, 1px); box-shadow: none; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 3%; font-family: var(--sans); font-size: clamp(11px, 1.15vw, 14px); color: var(--muted); letter-spacing: .03em; }
.field input[type=search], .field input[type=number], .field input[type=text] {
  font-family: var(--serif); font-size: clamp(16px, 1.7vw, 21px); color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--line); padding: .25em .5em; outline: none;
}
.field input:focus { border-color: var(--accent); }
.slider b { color: var(--ink-soft); font-weight: 700; }
.slider input { accent-color: var(--accent); width: 100%; }
.slider-ends { display: flex; justify-content: space-between; }
.slider-ends i { font-style: normal; }

.landed-kicker { font-family: var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-size: clamp(11px, 1.2vw, 15px); margin-bottom: .3em; }
.landed-title { font-size: clamp(17px, 2.1vw, 27px); line-height: 1.2; font-weight: 500; }
.landed-title b { font-weight: 700; }

.center-right h2 { font-weight: 600; font-size: clamp(28px, 3.5vw, 44px); margin: 0 0 .25em; }
.criteria { list-style: none; margin: 0; padding: 0; flex: none; }
.criteria li {
  display: flex; align-items: flex-start; gap: .55em; padding: .55em 0 .6em;
  border-bottom: 1.5px solid var(--line); font-size: clamp(15px, 1.65vw, 20px);
}
.criteria .dot { flex: none; width: .7em; height: .7em; border-radius: 50%; margin-top: .35em; }
.criteria .c-body { flex: 1; min-width: 0; }
.criteria .c-name { font-family: var(--sans); font-weight: 700; font-size: .9em; }
.criteria .c-extra { display: flex; gap: .4em; align-items: center; margin-top: .3em; flex-wrap: wrap; color: var(--ink-soft); }
.criteria .c-extra input, .criteria .c-extra select {
  font-family: var(--serif); font-size: 1em; background: var(--paper-2); border: 1.5px solid var(--line);
  padding: 0 .35em; width: 6.5em; color: var(--ink); max-width: 100%;
}
.criteria .c-extra select { width: auto; max-width: 12em; }
.criteria .c-extra input.wide { width: 100%; }
.criteria .mini {
  background: none; border: 1.5px solid var(--line); border-radius: 3px; padding: 0 .4em; font-size: .9em; line-height: 1.5;
}
.criteria .mini:hover { border-color: var(--accent); color: var(--accent); }
.criteria .x { background: none; border: 0; color: var(--muted); font-size: 1.1em; padding: 0 .2em; line-height: 1; }
.criteria .x:hover { color: var(--accent); }
.criteria .empty { color: var(--muted); font-style: italic; font-size: clamp(13px, 1.35vw, 16px); }
.free { flex: none; margin-top: .9em; }
.ff-title { font-family: var(--sans); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-size: clamp(11px, 1.15vw, 14px); margin: 0 0 .2em; }
.ff-row { display: grid; grid-template-columns: 7.2em 1fr; gap: .5em; align-items: center; padding: .38em 0; border-bottom: 1.5px solid var(--line); font-size: clamp(12px, 1.25vw, 15.5px); }
.ff-label { font-family: var(--sans); font-weight: 700; color: #4a413a; line-height: 1.15; font-size: .92em; }
.ff-ctl { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.ff-ctl input, .ff-ctl select {
  font-family: var(--serif); font-size: 1.05em; background: var(--paper-2); border: 1.5px solid var(--line);
  padding: 0 .35em; color: var(--ink); width: 5.4em; min-width: 0; outline: none;
}
.ff-ctl input:focus, .ff-ctl select:focus { border-color: var(--accent); }
.ff-ctl input.wide, .ff-ctl select { width: 100%; }
.ff-ctl .dash { color: var(--muted); }
.chip {
  font-family: var(--sans); font-weight: 700; font-size: .82em; padding: 1px 7px; line-height: 1.5;
  border: 1px solid #cdbfa9; background: var(--sq-cream); color: #5a5047; border-radius: 0;
}
.chip:hover { border-color: var(--accent); }
.chip[data-st="inc"] { background: var(--sq-sel); border-color: var(--accent); color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent); }
.chip[data-st="inc"]::before { content: "✓ "; }
.chip[data-st="exc"] { background: #e6ded3; color: #8d8177; text-decoration: line-through; }
.chip[data-st="exc"]::before { content: "✕ "; text-decoration: none; display: inline-block; }
.ff-foot { padding-top: .5em; font-size: .9em; }
.count { flex: none; border-top: 1.5px solid var(--line); padding-top: .5em; margin-top: .2em; font-size: clamp(15px, 1.6vw, 20px); color: var(--ink-soft); }
.count b { color: var(--accent); font-size: 1.25em; }

/* ------------------------------------------------------------------ results */
.results {
  margin-top: 26px; background: var(--paper); border: 4px solid var(--frame);
  box-shadow: 0 0 0 1px #c9baa4; padding: 28px 34px 30px;
}
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1.5px solid var(--line); padding-bottom: 10px; }
.results-head h2 { margin: 0; font-weight: 600; font-size: 40px; }
.results-sub { color: var(--ink-soft); font-size: 18px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 0 38px; }
.card { display: flex; gap: 18px; padding: 20px 0; border-bottom: 1.5px solid var(--line); min-width: 0; }
.cover { flex: none; width: 92px; height: 138px; position: relative; background: var(--sq-tan); border: 1px solid #cdbfa9; box-shadow: 3px 4px 0 rgba(120, 95, 60, .16); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 1; }
.cover img.bad { display: none; }
.cover-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; font-family: var(--serif); font-weight: 700; font-size: 14px; line-height: 1.1; color: var(--accent-dark); background: repeating-linear-gradient(45deg, #ecdcc2, #ecdcc2 6px, #eee0c8 6px, #eee0c8 12px); }
.card-body { min-width: 0; flex: 1; }
.card-title { font-size: 25px; font-weight: 700; line-height: 1.1; }
.card-orig { color: var(--muted); font-style: italic; font-size: 17px; margin-top: 2px; }
.card-orig:empty { display: none; }
.card-author { font-size: 19px; margin-top: 4px; }
.card-meta { font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft); margin-top: 4px; }
.card-ratings { font-family: var(--sans); font-size: 13.5px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.card-ratings span { white-space: nowrap; }
.card-ratings b { color: var(--accent); }
.card-ratings .pop { color: var(--muted); }.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { font-family: var(--sans); font-weight: 700; font-size: 11.5px; padding: 2px 7px; border: 1px solid #cdbfa9; background: var(--sq-cream); color: #5a5047; }
.tag.tan { background: var(--sq-tan); }
.tag.hit { background: var(--sq-sel); border-color: var(--accent); color: var(--accent-dark); }
.details-btn { margin-top: 10px; font-size: 16px; }
.details { margin-top: 12px; font-size: 17px; line-height: 1.35; }
.details p { margin: 0 0 .7em; }
.details h4 { font-family: var(--sans); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 1em 0 .4em; }
.details .rev { border-left: 3px solid var(--sq-tan); padding: 2px 0 2px 12px; margin-bottom: 12px; }
.details .rev-head { font-family: var(--sans); font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.details .rev-head b { color: var(--accent); }
.details .links a { color: var(--accent); margin-right: 14px; font-family: var(--sans); font-size: 14px; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 44px; margin: 4px 0 2px; }
.hist div { flex: 1; background: var(--accent); opacity: .8; min-height: 1px; }
.hist-labels { display: flex; gap: 3px; font-family: var(--sans); font-size: 10.5px; color: var(--muted); }
.hist-labels span { flex: 1; text-align: center; }
.hist-wrap { display: inline-block; width: 190px; margin-right: 28px; vertical-align: top; }
.hist-cap { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }
.more-row { text-align: center; margin-top: 22px; }
.none { padding: 30px 0; font-size: 22px; color: var(--ink-soft); }

.foot { margin-top: 16px; font-family: var(--sans); font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.6; }
.foot a { color: var(--muted); }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 860px) {
  .page { padding: 8px 6px 30px; }
  .board { display: flex; flex-wrap: wrap; aspect-ratio: auto; padding: 6px; gap: 4px; }
  .center { order: -1; width: 100%; display: block; padding: 18px 14px 12px; }
  .center-right { border-left: 0; padding-left: 0; margin-top: 18px; }
  .cr-scroll { overflow: visible; -webkit-mask-image: none; mask-image: none; padding-bottom: 0; }
  .sq { flex: 1 1 30%; min-height: 54px; margin: 0; font-size: 12.5px; }
  .sq .param { position: static; transform: none; margin-left: 4px; }
  .sq { flex-direction: column; gap: 3px; }
  .cards { grid-template-columns: 1fr; }
  .results { padding: 16px 14px; }
  .card-title { font-size: 21px; }
  .cover { width: 72px; height: 108px; }
}
