:root {
  --bone: #E9E4DA;
  --ink: #1A1320;
  --amethyst: #922FDB;
  --vein: #B7AFC2;
  --wax: #9E1B2F;
  --carve: "Cinzel", "Times New Roman", serif;
  --read: "Lexend", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bone); color: var(--ink); font: 300 17px/1.65 var(--read); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, textarea { font: inherit; }
.marble { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0.5; z-index: 0; }

.crest {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 4vw, 48px);
}
.name { font: 800 26px/1 var(--carve); text-decoration: none; letter-spacing: 0.04em; }
.seal {
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
  padding: 9px 20px; border-radius: 40px; cursor: pointer; font-weight: 400;
}
.seal:hover { background: var(--ink); color: var(--bone); }
.seal.on { border-color: var(--amethyst); color: var(--amethyst); }

/* ---------- the dial: chapters sit on a ring around the lock ---------- */
.dial {
  position: relative; z-index: 1;
  width: min(92vw, 760px, 84vh); aspect-ratio: 1;
  margin: 0 auto;
}
#lock { position: absolute; inset: 9%; width: 82%; height: 82%; }
.ring { position: absolute; inset: 0; }
.ring button {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(var(--r, 300px) * -1)) rotate(calc(var(--a) * -1));
  background: var(--bone); border: 1.5px solid var(--vein); color: var(--ink);
  font: 700 15px/1 var(--carve); letter-spacing: 0.06em;
  padding: 10px 16px; border-radius: 30px; cursor: pointer; white-space: nowrap;
  transition: background .25s, color .25s, border-color .25s;
}
.ring button:hover { border-color: var(--amethyst); }
.ring button.on { background: var(--ink); color: var(--bone); border-color: var(--ink); }

/* ---------- the chamber: one chapter at a time ---------- */
.chamber { position: relative; z-index: 1; max-width: 780px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 32px) 40px; }
.ch { display: none; animation: rise .45s ease both; }
.ch.on { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.count { margin: 0 0 6px; color: #5A4E66; font-weight: 400; }
h1 { font: 700 clamp(26px, 3.4vw, 40px)/1.25 var(--carve); margin: 0 0 12px; }
h2 { font: 700 clamp(30px, 4vw, 52px)/1.1 var(--carve); margin: 0 0 22px; }
h3 { font: 700 20px/1.2 var(--carve); margin: 0 0 6px; }
.hint { margin: 0 0 26px; color: var(--amethyst); font-weight: 400; }

.answer label { display: block; font-weight: 600; margin-bottom: 8px; }
.line { display: flex; gap: 12px; flex-wrap: wrap; }
.line input {
  flex: 1 1 280px; padding: 14px 18px; border: 2px solid var(--ink); border-radius: 4px 26px 26px 4px;
  background: rgba(233, 228, 218, 0.9); color: var(--ink); font-size: 18px;
}
.line input:focus { outline: none; border-color: var(--amethyst); }
.amethyst {
  background: var(--amethyst); color: #FFF; border: 0; cursor: pointer;
  padding: 14px 28px; border-radius: 26px 4px 4px 26px;
  font: 700 17px/1 var(--carve); letter-spacing: 0.05em;
  box-shadow: 0 0 0 4px rgba(146, 47, 219, 0.16);
  transition: transform .15s, box-shadow .15s;
}
.amethyst:hover { transform: translateY(-1px); box-shadow: 0 0 0 7px rgba(146, 47, 219, 0.2); }
.amethyst:disabled { opacity: 0.45; cursor: not-allowed; }
#revealBtn { margin-top: 14px; }
.note { min-height: 1.6em; margin: 14px 0 0; font-weight: 400; }
.note.err { color: var(--wax); }
.note.won { color: var(--wax); font: 700 20px/1.3 var(--carve); }
.pager { display: flex; justify-content: space-between; margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--vein); }
.plain { background: none; border: 0; color: var(--ink); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--vein); padding: 4px 0; }
.plain:hover { text-decoration-color: var(--amethyst); }
.plain:disabled { opacity: 0.35; cursor: default; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 56px 1fr; column-gap: 14px; }
.steps li::before { content: counter(s, upper-roman); grid-row: span 2; font: 800 30px/1 var(--carve); color: var(--amethyst); }
.steps p { margin: 0; }
.aside { margin-top: 26px; padding-left: 16px; border-left: 3px solid var(--vein); }

.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.board { margin: 0; padding: 0; list-style: none; }
.board li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--vein); }
.board .rank { font: 800 20px/1 var(--carve); color: var(--amethyst); }
.board .me { font-weight: 600; color: var(--wax); }
.board .empty { display: block; color: #5A4E66; border: 0; }
.riddles { margin: 0; padding: 0; list-style: none; }
.riddles li { padding: 14px 0; border-bottom: 1px solid var(--vein); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 14px; }
.riddles li:hover .q { color: var(--amethyst); }
.riddles .solvedMark { color: var(--wax); font-weight: 600; }

.ch details { padding: 14px 0; border-bottom: 1px solid var(--vein); }
.ch summary { cursor: pointer; font-weight: 600; }
.ch details p { margin: 8px 0 0; }

.keeper { display: grid; gap: 14px; }
.keeper label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.keeper input, .keeper textarea { padding: 12px 14px; border: 2px solid var(--ink); border-radius: 6px; background: rgba(233, 228, 218, 0.9); color: var(--ink); }
.keeper button { justify-self: start; }

.colophon { position: relative; z-index: 1; text-align: center; padding: 48px 16px 56px; border-top: 1px solid var(--vein); }
.colophon p { margin: 4px 0; }
.colophon .made { font: 700 22px/1.3 var(--carve); }
.colophon a { text-decoration-color: var(--amethyst); text-underline-offset: 3px; }
.colophon .addr { word-break: break-all; }

@media (max-width: 760px) {
  .dial { width: 100vw; aspect-ratio: auto; height: 420px; max-height: none; }
  #lock { inset: 0 0 64px 0; width: 100%; height: calc(100% - 64px); }
  .ring { inset: auto 0 0 0; display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; }
  .ring button { position: static; transform: none; flex: none; }
  .boards { grid-template-columns: 1fr; }
}
