/* Quest Roller: "Night at the table" (QUEST-21).
 *
 * One stylesheet for every page. The pages carry no inline styles and no
 * inline scripts: the quest page's content security policy forbids them
 * (style-src 'self'), and the static pages use the same policy.
 *
 * Layout of this file:
 *   1. Fonts (self-hosted, web/assets/fonts, SIL Open Font License)
 *   2. Tokens (docs/design/night-at-the-table/README.md)
 *   3. Base, focus, motion
 *   4. Components: buttons, fields, panels, chips, tags, roll rows
 *   5. Site chrome: header, app bar (rendered by auth.js), footer
 *   6. Pages: home, start, quest, documents
 *   7. Legacy: web/zoom/ (kept working, not redesigned)
 *
 * The roll rows (.roll-row and its parts) and the tokens are written to be
 * reused by the stream overlay (QUEST-20): nothing in them depends on the
 * quest page.
 */

/* 1. Fonts ------------------------------------------------------------------ */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/web/assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("/web/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/web/assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("/web/assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("/web/assets/fonts/cinzel-latin-wght-normal.woff2") format("woff2-variations"),
       url("/web/assets/fonts/cinzel-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url("/web/assets/fonts/cinzel-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("/web/assets/fonts/cinzel-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 2. Tokens ----------------------------------------------------------------- */

:root {
  /* Surfaces */
  --qr-ground: #14121f;          /* page */
  --qr-raised: #1e1b2e;          /* cards and panels */
  --qr-band: #1a1729;            /* full-width bands */
  --qr-control: #2b2740;         /* secondary buttons */
  --qr-control-hover: #363152;

  /* Borders */
  --qr-border: #2b2740;          /* dividers, row rules */
  --qr-border-strong: #332e4a;   /* card edges */
  --qr-border-control: #4a4466;  /* button edges */
  --qr-border-field: #6d6690;    /* inputs: 3.48:1 against the field */

  /* Text (contrast against --qr-ground / --qr-raised) */
  --qr-text: #efeae0;            /* 15.4 / 14.0 */
  --qr-text-2: #c9c3d6;          /* 10.8 / 9.8 */
  --qr-muted: #a9a3b8;           /* 7.6 / 6.9 */
  --qr-placeholder: #8f89a3;     /* 5.5 on the field */

  /* Meaning */
  --qr-crimson: #c62d33;         /* actions; white text on it is 5.5:1 */
  --qr-crimson-hover: #a8262b;
  --qr-crimson-text: #ea6066;    /* crimson used AS text: 5.1:1 on raised */
  --qr-on-crimson: #ffffff;
  --qr-gold: #f0c35a;            /* results, links, focus */
  --qr-gold-hover: #ffd984;
  --qr-green: #7fd6a0;           /* available, connected */
  --qr-error: #ffb4b4;           /* refused rolls, errors */
  --qr-bar: #6d6690;             /* chart bars */

  /* Type */
  --qr-font-head: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --qr-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Shape */
  --qr-radius-sm: 10px;
  --qr-radius: 14px;
  --qr-radius-lg: 18px;
  --qr-radius-pill: 999px;

  /* Targets */
  --qr-target: 44px;             /* every control */
  --qr-target-primary: 48px;     /* primary buttons */

  /* Depth */
  --qr-shadow-card: 0 24px 60px rgba(0, 0, 0, 0.45);
  --qr-shadow-action: 0 8px 24px rgba(198, 45, 51, 0.35);

  /* Layout */
  --qr-page-max: 1120px;
  --qr-gutter: 32px;
}

@media (max-width: 640px) {
  :root { --qr-gutter: 16px; }
}

/* 3. Base ------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--qr-ground);
  color: var(--qr-text);
  font-family: var(--qr-font-body);
  font-size: 16px;
  line-height: 1.5;
}

img, svg { max-width: 100%; }

a { color: var(--qr-gold); text-underline-offset: 3px; }
a:hover { color: var(--qr-gold-hover); }

h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--qr-gold);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: var(--qr-target);
  padding: 0 16px;
  border-radius: var(--qr-radius-sm);
  background: var(--qr-gold);
  color: var(--qr-ground);
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--qr-ground); }

.container {
  width: 100%;
  max-width: var(--qr-page-max);
  margin: 0 auto;
  padding-left: var(--qr-gutter);
  padding-right: var(--qr-gutter);
}

.muted { color: var(--qr-muted); }
.center { text-align: center; }
.mt-1 { margin-top: 1em; }

.eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--qr-gold);
}

.label-caps {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--qr-muted);
}

/* Motion: only when the reader has not asked for less. */
@keyframes qr-pop {
  0% { transform: scale(0.7) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes qr-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
@media (prefers-reduced-motion: no-preference) {
  .pop { animation: qr-pop 0.45s ease-out; }
  .float { animation: qr-float 5s ease-in-out infinite; }
  .btn { transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Busy cursor while a roll is in flight (web/busy.js) */
body.qr-busy, body.qr-busy * { cursor: progress !important; }

/* 4. Components ------------------------------------------------------------- */

/* Buttons. `.btn` is a secondary control; `.btn.primary` is the crimson action.
   Both meet the 44 px target; primary meets 48 px. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--qr-target);
  padding: 0 16px;
  border: 1px solid var(--qr-border-control);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-control);
  color: var(--qr-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}
.btn:hover { background: var(--qr-control-hover); color: var(--qr-text); }
.btn.primary {
  min-height: var(--qr-target-primary);
  padding: 0 22px;
  border-color: var(--qr-crimson);
  background: var(--qr-crimson);
  color: var(--qr-on-crimson);
  font-weight: 700;
  box-shadow: var(--qr-shadow-action);
}
.btn.primary:hover { background: var(--qr-crimson-hover); border-color: var(--qr-crimson-hover); color: var(--qr-on-crimson); }
.btn.lg { min-height: 56px; padding: 0 28px; font-size: 17px; }
.btn.block { display: flex; width: 100%; }
.btn.compact { min-height: var(--qr-target); box-shadow: none; font-size: 14px; padding: 0 18px; }
.btn.on-crimson { border-color: var(--qr-ground); background: var(--qr-ground); color: var(--qr-on-crimson); box-shadow: none; }
.btn.on-crimson:hover { background: #000; color: var(--qr-on-crimson); }
.btn.on-crimson:focus-visible { outline-color: var(--qr-on-crimson); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn.primary:disabled:hover { background: var(--qr-crimson); }
.btn:disabled:hover { background: var(--qr-control); }
.btn.small { font-size: 14px; }
/* A destructive control that is not the confirmation itself: outlined, on the card. */
.btn.danger { border-color: var(--qr-crimson-text); background: transparent; color: var(--qr-crimson-text); }
.btn.danger:hover { background: var(--qr-ground); color: var(--qr-crimson-text); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--qr-text-2); }
.input,
.qr-input {
  width: 100%;
  min-height: var(--qr-target-primary);
  padding: 0 14px;
  border: 1px solid var(--qr-border-field);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-ground);
  color: var(--qr-text);
  font-size: 16px; /* 16 px stops iOS zooming on focus */
}
.input::placeholder, .qr-input::placeholder { color: var(--qr-placeholder); opacity: 1; }
.input:focus-visible, .qr-input:focus-visible { outline-offset: 1px; }
.hint { font-size: 13px; color: var(--qr-muted); }
.hint:empty { display: none; }
.form-error { font-size: 15px; color: var(--qr-error); }
.form-error:empty { display: none; }

/* Panels and cards */
.panel {
  background: var(--qr-raised);
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--qr-radius-lg);
  padding: 28px;
}
.card {
  background: var(--qr-raised);
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--qr-radius);
  padding: 28px;
}
@media (max-width: 640px) {
  .panel, .card { padding: 20px; }
}

/* Pills: connection state, the house rule */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--qr-radius-pill);
  background: var(--qr-raised);
  color: var(--qr-text);
  font-size: 14px;
}
.chip.quiet { color: var(--qr-text-2); }
.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--qr-gold);
}
[data-state="connected"] > .dot { background: var(--qr-green); }
[data-state="disconnected"] > .dot,
[data-state="deleted"] > .dot,
[data-state="missing"] > .dot,
[data-state="error"] > .dot { background: var(--qr-error); }

/* Status tags: "Available now", "Coming", "Coming soon" */
.tag {
  align-self: flex-start;
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tag.available { color: var(--qr-green); }
.tag.coming { color: var(--qr-gold); }
.tag.solid {
  padding: 6px 10px;
  border-color: var(--qr-gold);
  background: var(--qr-gold);
  color: var(--qr-ground);
  font-size: 12px;
  letter-spacing: 0.14em;
}

/* A rounded button that fills a field: the "Used before" reasons */
.chip-btn {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: var(--qr-target);
  padding: 0 14px;
  border: 1px solid var(--qr-border-control);
  border-radius: var(--qr-radius-pill);
  background: var(--qr-ground);
  color: var(--qr-text);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-btn:hover { background: var(--qr-control); }

/* Roll rows. Shared by the home page example, the quest page log and, later,
   the stream overlay (QUEST-20). Markup:
     .roll-row > .roll-total + .roll-body(.roll-who(.roll-name + .roll-expr) + .roll-detail) + .roll-time
   A roll without the structured fields is a .roll-row.roll-row--text holding the message. */
.roll-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--qr-border);
}
.roll-total {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--qr-radius-sm);
  background: var(--qr-ground);
  color: var(--qr-gold);
  font-family: var(--qr-font-head);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.roll-body { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.roll-who { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.roll-expr { color: var(--qr-muted); font-weight: 400; }
.roll-detail { font-size: 14px; color: var(--qr-text-2); overflow-wrap: anywhere; }
.roll-time { flex: none; font-size: 13px; color: var(--qr-muted); white-space: nowrap; }
.roll-row--text { display: block; font-size: 15px; color: var(--qr-text); overflow-wrap: anywhere; }

/* 5. Site chrome ------------------------------------------------------------ */

/* Static pages: home, privacy, terms */
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: var(--qr-target);
  color: var(--qr-text);
  text-decoration: none;
}
.site-brand:hover { color: var(--qr-text); }
.site-brand img { width: 48px; height: 48px; flex: none; }
.site-brand span {
  font-family: var(--qr-font-head);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  font-size: 15px;
}
.site-nav a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: var(--qr-target);
  color: var(--qr-text-2);
  text-decoration: none;
}
.site-nav a:not(.btn):hover { color: var(--qr-text); text-decoration: underline; }
.site-header.bordered { border-bottom: 1px solid var(--qr-border); }

/* App pages: the bar auth.js renders into #qr-navbar (.left .brand .logo
   .brand-text, .right .nav-display and the sign-in or sign-out button). */
.qr-navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-height: 72px;
  padding: 12px max(var(--qr-gutter), calc((100% - var(--qr-page-max)) / 2 + var(--qr-gutter)));
  border-bottom: 1px solid var(--qr-border);
}
.qr-navbar .left, .qr-navbar .brand { display: flex; align-items: center; gap: 12px; }
.qr-navbar .logo { width: 44px; height: 44px; flex: none; }
.qr-navbar .brand-text a {
  display: inline-flex;
  align-items: center;
  min-height: var(--qr-target);
  color: var(--qr-text);
  font-family: var(--qr-font-head);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.qr-navbar .right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-left: auto;
}
.qr-navbar .nav-display { color: var(--qr-text-2); font-size: 15px; overflow-wrap: anywhere; }
.qr-navbar .btn { font-size: 14px; box-shadow: none; }
.qr-navbar .btn.primary { min-height: var(--qr-target); }

.site-footer { border-top: 1px solid var(--qr-border); }
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 20px;
  padding-bottom: 20px;
  font-size: 14px;
  color: var(--qr-muted);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 20px; }
.site-footer nav a { display: inline-flex; align-items: center; min-height: var(--qr-target); }

/* 6. Pages ------------------------------------------------------------------ */

/* Sections shared by the home page */
.section { padding-top: 80px; padding-bottom: 80px; }
.band { background: var(--qr-band); border-top: 1px solid var(--qr-border); border-bottom: 1px solid var(--qr-border); }
.section-title { font-family: var(--qr-font-head); font-size: clamp(26px, 4vw, 34px); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: 32px; }
.body-lg { font-size: 17px; line-height: 1.6; color: var(--qr-text-2); }
@media (max-width: 640px) {
  .section { padding-top: 56px; padding-bottom: 56px; }
}

/* Home: hero */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 56px;
  padding-top: 56px;
  padding-bottom: 72px;
}
.hero-copy { display: flex; flex: 1 1 460px; flex-direction: column; gap: 22px; min-width: 0; }
.hero-title {
  font-family: var(--qr-font-head);
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 800;
  line-height: 1.08;
}
.lede { max-width: 520px; font-size: 19px; line-height: 1.55; color: var(--qr-text-2); }
.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.hero-note { font-size: 14px; color: var(--qr-muted); }
@media (max-width: 640px) {
  .hero { gap: 40px; padding-top: 32px; padding-bottom: 48px; }
  .lede { font-size: 17px; }
}

/* Home: dice demo */
.demo {
  display: flex;
  flex: 1 1 400px;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  box-shadow: var(--qr-shadow-card);
}
.demo-head { display: flex; align-items: center; gap: 18px; }
.demo-head img { width: 96px; height: 96px; flex: none; }
.demo-title { font-family: var(--qr-font-head); font-size: 24px; font-weight: 700; }
.demo-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.demo-buttons .btn { flex: 1 1 80px; min-height: var(--qr-target-primary); font-size: 16px; font-weight: 700; box-shadow: none; }
.demo-result {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--qr-ground);
}
.demo-total {
  min-width: 84px;
  color: var(--qr-gold);
  font-family: var(--qr-font-head);
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.demo-line { font-size: 16px; font-weight: 600; }
.demo-detail { font-size: 13px; color: var(--qr-muted); }
.demo-log { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.demo-log li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--qr-border);
  font-size: 14px;
  color: var(--qr-text-2);
}
.demo-log .when { flex: none; color: var(--qr-muted); }
.demo-note { font-size: 13px; color: var(--qr-muted); }
@media (max-width: 400px) {
  .demo-head img { width: 64px; height: 64px; }
  .demo-total { min-width: 64px; font-size: 38px; }
  .demo-result { gap: 12px; padding: 14px; }
}

/* Home: three steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 24px; }
.step { display: flex; flex-direction: column; gap: 12px; }
.step-num { color: var(--qr-crimson-text); font-family: var(--qr-font-head); font-size: 40px; font-weight: 800; line-height: 1; }
.step h3 { font-size: 20px; }
.step p { font-size: 16px; line-height: 1.55; color: var(--qr-text-2); }

/* Home: two-column sections (the record, statistics) */
.split { display: flex; flex-wrap: wrap; align-items: center; gap: 48px; }
.split.reverse { flex-wrap: wrap-reverse; }
.split > .stack { flex: 1 1 380px; }
.split > .panel { flex: 1 1 480px; min-width: 0; }
.ticks { display: flex; flex-direction: column; gap: 10px; margin: 0; padding-left: 20px; font-size: 16px; line-height: 1.5; color: var(--qr-text-2); }

.book { display: flex; flex-direction: column; gap: 4px; padding: 24px; }
.book-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 12px; }
.book-title { font-family: var(--qr-font-head); font-size: 18px; font-weight: 700; }

/* Home: the statistics illustration. Heights are the mockup's, in px of 180. */
.chart { display: flex; flex-direction: column; gap: 14px; padding: 24px 24px 16px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.chart-caption { font-size: 15px; font-weight: 600; }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; border-bottom: 1px solid var(--qr-border-field); }
.chart-bars span { flex: 1; min-width: 0; border-radius: 4px 4px 0 0; background: var(--qr-bar); }
.chart-bars span:first-child, .chart-bars span:last-child { background: var(--qr-crimson); }
.chart-bars span:nth-child(1) { height: 156px; }
.chart-bars span:nth-child(2) { height: 144px; }
.chart-bars span:nth-child(3) { height: 165px; }
.chart-bars span:nth-child(4) { height: 150px; }
.chart-bars span:nth-child(5) { height: 141px; }
.chart-bars span:nth-child(6) { height: 159px; }
.chart-bars span:nth-child(7) { height: 147px; }
.chart-bars span:nth-child(8) { height: 153px; }
.chart-bars span:nth-child(9) { height: 138px; }
.chart-bars span:nth-child(10) { height: 162px; }
.chart-bars span:nth-child(11) { height: 150px; }
.chart-bars span:nth-child(12) { height: 144px; }
.chart-bars span:nth-child(13) { height: 156px; }
.chart-bars span:nth-child(14) { height: 147px; }
.chart-bars span:nth-child(15) { height: 159px; }
.chart-bars span:nth-child(16) { height: 141px; }
.chart-bars span:nth-child(17) { height: 153px; }
.chart-bars span:nth-child(18) { height: 150px; }
.chart-bars span:nth-child(19) { height: 144px; }
.chart-bars span:nth-child(20) { height: 156px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--qr-muted); }
@media (max-width: 480px) {
  .chart-bars { gap: 3px; }
}

/* Home: where to roll */
.places { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 20px; }
.place { display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.place h3 { font-size: 19px; }
.place p { font-size: 15px; line-height: 1.5; color: var(--qr-text-2); }

/* Home: closing call to action */
.cta-wrap { padding-bottom: 80px; }
.cta-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 48px 40px;
  border-radius: 20px;
  background: var(--qr-crimson);
  color: var(--qr-on-crimson);
}
.cta-band .stack { flex: 1 1 420px; gap: 8px; }
.cta-band h2 { font-family: var(--qr-font-head); font-size: clamp(26px, 4vw, 32px); font-weight: 800; }
.cta-band p { font-size: 17px; }
@media (max-width: 640px) {
  .cta-wrap { padding-bottom: 56px; }
  .cta-band { padding: 32px 24px; }
}

/* Start page */
.start-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 40px;
  padding-top: 48px;
  padding-bottom: 64px;
}
.create-panel { display: flex; flex: 1 1 380px; flex-direction: column; gap: 22px; min-width: 0; }
.create-panel h1 { font-family: var(--qr-font-head); font-size: clamp(26px, 4vw, 32px); font-weight: 800; line-height: 1.1; }
.create-panel .intro { font-size: 16px; line-height: 1.55; color: var(--qr-text-2); }
.create-form { display: flex; flex-direction: column; gap: 22px; }
.login-prompt { display: flex; flex-direction: column; gap: 12px; }
.your-quests { display: flex; flex: 1.3 1 440px; flex-direction: column; gap: 16px; min-width: 0; }
.your-quests h2 { font-family: var(--qr-font-head); font-size: 24px; font-weight: 700; }
@media (max-width: 640px) {
  .start-layout { gap: 32px; padding-top: 28px; padding-bottom: 48px; }
}
.account-link { margin-top: 8px; }

/* The account page (web/account.html): one panel, the width of a form. */
.account-layout { padding-top: 48px; padding-bottom: 64px; }
.account-panel { display: flex; flex-direction: column; gap: 22px; max-width: 720px; margin: 0 auto; }
.account-panel h1 { font-family: var(--qr-font-head); font-size: clamp(26px, 4vw, 32px); font-weight: 800; line-height: 1.1; }
.account-panel .intro { font-size: 16px; line-height: 1.55; color: var(--qr-text-2); }
.account-area, .account-done { display: flex; flex-direction: column; gap: 18px; }
.account-done .btn { align-self: flex-start; }
.account-panel .field-label strong { color: var(--qr-text); }
/* Two choices with a paragraph each: the title to the left, the note under it. */
.account-choices .choice-body { align-items: flex-start; justify-content: flex-start; gap: 6px; padding: 14px 16px; text-align: left; height: 100%; }
.account-choices .choice-title { padding-right: 28px; }
.account-choices .choice-note { line-height: 1.5; }
@media (max-width: 640px) {
  .account-layout { padding-top: 28px; padding-bottom: 48px; }
  .choice-grid.account-choices { grid-template-columns: minmax(0, 1fr); }
}

/* The d10 rule: two large choices on real radio inputs. The input covers its
   label, so a click anywhere picks it, and it stays focusable and announced. */
.choices { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 600; color: var(--qr-text-2); }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice { position: relative; display: block; }
.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.choice-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 10px 12px;
  border: 2px solid var(--qr-border-control);
  border-radius: 12px;
  background: var(--qr-ground);
  text-align: center;
}
.choice-title { font-family: var(--qr-font-head); font-size: 18px; font-weight: 700; }
.choice-note { font-size: 13px; color: var(--qr-text-2); }
.choice input:hover + .choice-body { border-color: var(--qr-border-field); }
.choice input:checked + .choice-body { border-color: var(--qr-gold); background: var(--qr-control); }
.choice input:checked + .choice-body::after {
  content: "\2713";
  position: absolute;
  top: 6px;
  right: 10px;
  color: var(--qr-gold);
  font-weight: 700;
}
.choice input:focus-visible + .choice-body { outline: 3px solid var(--qr-gold); outline-offset: 3px; }

/* Start page: quest cards */
.quest-cards { display: flex; flex-direction: column; gap: 16px; margin: 0; padding: 0; list-style: none; }
.quest-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border: 1px solid var(--qr-border-strong);
  border-radius: 16px;
  background: var(--qr-raised);
}
.quest-card > img { width: 44px; height: 44px; flex: none; }
.quest-card-text { display: flex; flex: 1 1 200px; flex-direction: column; gap: 4px; min-width: 0; }
.quest-card-name { font-family: var(--qr-font-head); font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.quest-card-meta { font-size: 14px; color: var(--qr-muted); }
.quest-card-code { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--qr-muted); }
.quest-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 0.06em; color: var(--qr-text); user-select: all; }
.quest-card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.quest-card.empty { display: block; color: var(--qr-text-2); }
/* Deleting a quest: the card's buttons give way to a confirmation that names
   the quest and says its rolls go with it. */
.quest-card.confirming { border-color: var(--qr-crimson-text); }
.quest-card-confirm {
  display: flex;
  flex: 1 1 100%;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--qr-border-strong);
}
.quest-card-confirm-text { font-size: 15px; line-height: 1.55; color: var(--qr-text-2); overflow-wrap: anywhere; }
.quest-card-confirm-text strong { color: var(--qr-text); font-weight: 700; }
.quest-card-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.quest-card-status { font-size: 14px; color: var(--qr-text-2); }
.quest-card-status.error { color: var(--qr-error); }
.quest-card-status:empty { display: none; }
.your-quests h2:focus { outline: none; }
/* The name the owner must type, and the field it is typed into. */
.quest-card-confirm .field-label { font-size: 14px; font-weight: 400; overflow-wrap: anywhere; }
.quest-card-confirm .confirm-name { color: var(--qr-text); font-weight: 700; }
/* Deleted quests: a second list under the active ones. Nothing here opens a quest. */
.deleted-quests { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.quest-card.deleted { border-style: dashed; background: var(--qr-band); }
.quest-card.deleted > img { opacity: 0.5; }
.quest-card.deleted .quest-card-name { color: var(--qr-text-2); }
.quest-card-meta.removal-date { color: var(--qr-text-2); }
@media (max-width: 640px) {
  .quest-card { padding: 16px; }
  .quest-card-actions, .quest-card-confirm-actions { flex: 1 1 100%; }
  .quest-card-actions .btn, .quest-card-confirm-actions .btn { flex: 1 1 0; }
}

/* Quest page */
.quest-header { border-bottom: 1px solid var(--qr-border); }
.quest-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 1180px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.quest-heading { display: flex; flex-direction: column; min-width: 0; }
.quest-heading .label-caps { letter-spacing: 0.12em; }
.quest-heading h1 { font-family: var(--qr-font-head); font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.quest-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.copy-confirm { font-size: 14px; color: var(--qr-green); }

.quest-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 28px;
  max-width: 1180px;
  padding-top: 28px;
  padding-bottom: 48px;
}
.quest-play { display: flex; flex: 1 1 440px; flex-direction: column; gap: 20px; min-width: 0; }
.quest-book { display: flex; flex: 1 1 440px; flex-direction: column; min-width: 0; padding: 24px; }

.last-roll { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.last-who { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--qr-muted); overflow-wrap: anywhere; }
.last-total {
  display: inline-block;
  color: var(--qr-gold);
  font-family: var(--qr-font-head);
  font-size: clamp(64px, 14vw, 96px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.last-expr { font-size: 17px; font-weight: 600; }
.last-expr:empty { display: none; }
.last-detail { font-size: 15px; color: var(--qr-text-2); overflow-wrap: anywhere; }

.controls { display: flex; flex-direction: column; gap: 18px; padding: 24px; }
.inline-field { display: flex; gap: 10px; }
.inline-field .input { flex: 1 1 auto; min-width: 0; }
.quick-dice { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-dice .btn {
  min-height: 52px;
  padding: 0 6px;
  border-radius: 12px;
  font-family: var(--qr-font-head);
  font-size: 17px;
  font-weight: 700;
}
.roll-inputs { display: flex; flex-wrap: wrap; gap: 14px; }
.roll-inputs .field:first-child { flex: 1 1 150px; }
.roll-inputs .field:last-child { flex: 2 1 220px; }
.reasons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reasons-label { font-size: 13px; color: var(--qr-muted); }
.reason-buttons { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.roll-action { display: flex; flex-direction: column; gap: 10px; }
.roll-action .btn { font-size: 18px; }
.roll-error { font-size: 15px; color: var(--qr-error); }
.roll-error:empty { display: none; }
.notice {
  padding: 14px 16px;
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-raised);
  color: var(--qr-text-2);
}

.book-head h2 { font-family: var(--qr-font-head); font-size: 20px; font-weight: 700; }
.book-head .sub { font-size: 13px; color: var(--qr-muted); }
/* position: offsetTop is measured from the log. overflow-anchor: the page script keeps the reader's place. */
.roll-log { position: relative; max-height: min(70vh, 720px); overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; }
.roll-log .roll-total { width: 52px; height: 52px; font-size: 22px; color: var(--qr-text); }
.roll-log .roll-row.is-latest .roll-total { color: var(--qr-gold); }
.log-note { padding: 10px 0; border-top: 1px solid var(--qr-border); font-size: 14px; color: var(--qr-muted); overflow-wrap: anywhere; }
.debug-area { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.debug-log {
  width: 100%;
  min-height: 12em;
  padding: 10px;
  border: 1px solid var(--qr-border-field);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-ground);
  color: var(--qr-text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.offscreen { position: fixed; left: -9999px; top: 0; }
@media (max-width: 640px) {
  .quest-layout { gap: 20px; padding-top: 20px; }
  .controls, .quest-book { padding: 18px; }
  .quick-dice { gap: 8px; }
  .roll-log { max-height: 60vh; }
}

/* Documents: privacy, terms, sign-in and sign-out, the grail */
.doc { padding-top: 48px; padding-bottom: 72px; }
.doc .panel { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto; }
.doc h1 { font-family: var(--qr-font-head); font-size: clamp(28px, 5vw, 38px); font-weight: 800; }
.doc p { font-size: 17px; line-height: 1.6; color: var(--qr-text-2); }
.doc p strong { color: var(--qr-text); }
.doc h2 { margin-top: 8px; font-family: var(--qr-font-head); font-size: 21px; font-weight: 700; }
.doc ul { padding-left: 22px; font-size: 17px; line-height: 1.6; color: var(--qr-text-2); }
.doc .links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.doc.centered .panel { align-items: center; text-align: center; }

/* 7. Legacy: web/zoom/ -------------------------------------------------------
   The Zoom pages (index.html, oauth_redirect.html, legacy-zoom.js) were not
   redesigned in QUEST-21. These rules keep their classes working on the new
   ground and tokens. Remove when the Zoom app is rebuilt or dropped. */

.qr-container { width: 100%; max-width: 1200px; min-height: 100vh; margin: 0 auto; padding: 10px; display: flex; flex-direction: column; gap: 18px; }
.qr-row { display: flex; align-items: center; gap: 12px; width: 100%; margin: 8px 0; }
.qr-header-row { justify-content: center; flex-wrap: nowrap; }
.qr-header-row .logo { width: 72px; height: 72px; flex: 0 0 auto; }
.qr-title { margin: 0; min-width: 0; font-family: var(--qr-font-head); font-size: clamp(1.1rem, 2.8vw, 2.6rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-instructions { justify-content: center; padding: 0 8px; text-align: center; color: var(--qr-text-2); }
.qr-button-row { justify-content: center; flex-wrap: wrap; gap: 12px; }
.btn-large {
  min-height: var(--qr-target-primary);
  padding: 10px 14px;
  border: 0;
  border-radius: var(--qr-radius-sm);
  background: var(--qr-crimson);
  color: var(--qr-on-crimson);
  font-size: 16px;
  font-weight: 700;
}
.btn-large:hover { background: var(--qr-crimson-hover); }
.qr-button-row .btn-large { flex: 0 1 calc((100% - 36px) / 4); max-width: calc((100% - 36px) / 4); }
.qr-input-row { justify-content: center; flex-wrap: nowrap; gap: 8px; }
.qr-input-row .qr-input { flex: 1 1 auto; min-width: 5ch; }
.qr-input-row .btn-large { flex: 0 0 auto; min-width: 88px; }
.qr-results-row { flex: 1 1 auto; flex-direction: column; }
.qr-results-row textarea#chatOutput,
.qr-debug-row textarea#logOutput {
  display: block;
  width: 100%;
  min-height: 10em;
  padding: 10px;
  border: 1px solid var(--qr-border-field);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-raised);
  color: var(--qr-text);
  resize: vertical;
}
#active-quest-block { justify-content: space-between; }
.share-confirm { display: none; margin-left: 8px; color: var(--qr-green); font-size: 0.95rem; }
.qr-debug-row { flex-direction: column; }
.qr-debug-row[aria-hidden="true"] { display: none; }
.displayname-prompt {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 9999;
  padding: 12px;
  border: 1px solid var(--qr-border-strong);
  border-radius: var(--qr-radius-sm);
  background: var(--qr-raised);
  color: var(--qr-text);
  box-shadow: var(--qr-shadow-card);
}
.qr-label { margin-right: 8px; font-size: 13px; font-weight: 600; }
.qr-legacy { margin: 2em; text-align: center; }
.qr-legacy button { margin: 0.5em; padding: 1em 2em; border-radius: 8px; font-size: 1.2em; }
.oauth-redirect { padding: 5em 2em; text-align: center; }
.oauth-redirect h1 { font-family: var(--qr-font-head); color: var(--qr-gold); }
.oauth-redirect p { margin-top: 1em; font-size: 1.2em; color: var(--qr-text-2); }
.oauth-redirect #oauth-next a { font-weight: 800; text-decoration: none; }
@media (max-width: 900px) {
  .qr-button-row .btn-large { flex: 0 1 calc((100% - 12px) / 2); max-width: calc((100% - 12px) / 2); }
}
