:root {
  color-scheme: light;
  --bg: #eef2ee;
  --ink: #1d2724;
  --muted: #65746d;
  --paper: #fffdf5;
  --panel: #f9faf5;
  --line: rgba(29, 39, 36, 0.16);
  --green: #2f7d5b;
  --red: #b54c3e;
  --blue: #365f8f;
  --gold: #c18b2d;
  --shadow: 0 20px 55px rgba(28, 42, 37, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-rounded, "SF Pro Rounded", "Trebuchet MS", system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(29, 39, 36, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(180deg, #f8f4e8 0%, var(--bg) 48%, #e5ece9 100%);
  color: var(--ink);
}

.shell {
  width: min(980px, 94vw);
  margin: 0 auto;
  padding: 22px 0 42px;
}

.top-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.top-nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
  background: rgba(255, 253, 245, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}

.hero {
  margin: 0 auto 22px;
  max-width: 760px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.9rem);
  line-height: 0.95;
}

.lede {
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
}

.game-panel,
.rules {
  background: rgba(249, 250, 245, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.status-row div {
  min-height: 76px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-row strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.shelf-wrap {
  background: #32261f;
  border: 6px solid #5a3d2d;
  border-radius: 8px;
  padding: 12px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.bay-labels,
.shelf {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.bay-labels {
  margin-bottom: 8px;
  color: #eadcc5;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.book {
  position: relative;
  min-height: 154px;
  border: 2px solid rgba(255, 255, 255, 0.44);
  border-radius: 7px;
  padding: 12px 8px;
  color: #fffdf5;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.book::before,
.book::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.42);
}

.book::before {
  top: 34px;
}

.book::after {
  bottom: 34px;
}

.book:hover,
.book:focus-visible {
  transform: translateY(-3px);
  outline: none;
}

.book.selected {
  border-color: #f6d271;
  box-shadow: 0 0 0 4px rgba(246, 210, 113, 0.24), 0 12px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-5px);
}

.book-code {
  display: block;
  margin-bottom: 16px;
  font-size: 1.45rem;
  font-weight: 950;
}

.book-title {
  display: block;
  min-height: 54px;
  font-size: 0.96rem;
  font-weight: 900;
  line-height: 1.12;
}

.book-author {
  display: block;
  margin-top: 18px;
  font-size: 0.76rem;
  font-weight: 800;
  opacity: 0.9;
}

.message {
  min-height: 1.45em;
  margin: 14px 0;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.clues {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.clue {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 68px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.3;
}

.clue.good {
  border-left-color: var(--green);
}

.clue-mark {
  width: 1.45rem;
  flex: 0 0 1.45rem;
  color: var(--red);
  font-weight: 950;
}

.clue.good .clue-mark {
  color: var(--green);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

#resetBtn {
  background: #5b5147;
}

#nextBtn {
  background: var(--blue);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.rules {
  margin-top: 18px;
  box-shadow: none;
}

.rules h2 {
  margin: 0 0 8px;
}

.rules li {
  margin: 0.42rem 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  .status-row {
    grid-template-columns: 1fr 1fr;
  }

  .status-row div:last-child {
    grid-column: 1 / -1;
  }

  .shelf-wrap {
    overflow-x: auto;
  }

  .bay-labels,
  .shelf {
    min-width: 620px;
  }
}

@media (max-width: 480px) {
  .shell {
    width: min(94vw, 420px);
    padding-top: 14px;
  }

  .top-nav {
    flex-wrap: wrap;
  }

  .game-panel,
  .rules {
    padding: 14px;
  }
}
