/* Three Fleeces. Parlor paper for a Saturday at the mill gate. */
:root {
  --cream: #f7f1e8;
  --ink: #3d3429;
  --soft: #6e5a45;
  --faint: #a89886;
  --accent: #c4785a;
  --accent-ink: #fffaf3;
  --panel: #fffaf3;
  --line: #e4d5c4;
  --shadow: rgba(61, 52, 41, 0.12);
  --gold: #c4a574;
  --focus: #c4785a;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, #fffaf3 0%, transparent 55%),
    linear-gradient(165deg, #f3eadf 0%, #e7d9c8 48%, #ddd0c0 100%);
}

.app {
  width: min(46rem, calc(100% - 1.5rem));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.mark {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px var(--shadow);
  background: #fffaf3;
}

.titles h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.tagline {
  margin: 0.12rem 0 0;
  color: var(--soft);
  font-size: 0.86rem;
}

.top-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.btn {
  appearance: none;
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  box-shadow: 0 1px 3px var(--shadow);
}

.btn:hover { filter: brightness(1.02); }

.btn:focus-visible,
.choice:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-quiet { font-size: 0.82rem; font-weight: 650; }

.btn-fill {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}

.btn-fill:hover { filter: brightness(1.05); }

.btn-text {
  background: transparent;
  box-shadow: none;
  color: var(--soft);
  padding-left: 0;
  padding-right: 0;
  font-size: 0.86rem;
}

.foot {
  margin: 1.25rem 0 0;
  text-align: center;
  color: var(--faint);
  font-size: 0.78rem;
}

.lede { font-size: 1.08rem; margin: 0 0 1rem; }

.paper {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 10px 28px var(--shadow);
  padding: 1.05rem 1.15rem 1.15rem;
  border-top: 4px solid var(--gold);
  position: relative;
  min-width: 0;
}

.paper::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  right: 0.7rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #8d3b3b;
  box-shadow: inset 0 0 0 1px rgba(61, 52, 41, 0.25);
}

.kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paper h2 {
  margin: 0 0 0.55rem;
  padding-right: 1rem;
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.2;
}

#scene-title:focus { outline: none; }

.paper p { margin: 0 0 0.75rem; }

.rule-label {
  margin: 0.15rem 0 0.3rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rule {
  background: #fff7f2;
  border: 1px solid #e7c3b6;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  margin: 0 0 0.85rem;
}

.actions, .choices { display: grid; gap: 0.55rem; margin-top: 0.85rem; }

.choice {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  min-width: 0;
}

.choice:hover { border-color: var(--accent); background: #fff7f2; }

.choice-label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.choice-math {
  display: block;
  margin-top: 0.16rem;
  font-size: 0.92rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.herd, .names {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.alpaca, .name {
  background: var(--panel);
  border-radius: 12px;
  border-top: 4px solid var(--accent);
  padding: 0.4rem 0.3rem 0.5rem;
  text-align: center;
  box-shadow: 0 3px 10px var(--shadow);
  min-width: 0;
}

.alpaca strong, .name strong { display: block; font-size: 0.92rem; }
.alpaca.turn, .name.now { outline: 2px solid var(--accent); outline-offset: 2px; }
.name.done { color: var(--soft); }

.face-mark {
  width: 2.15rem;
  height: 2.35rem;
  object-fit: contain;
  background: radial-gradient(circle at 50% 42%, #fff 0%, #f3ebe0 72%);
  border-radius: 1rem;
}

.job, .fresh, .note {
  display: block;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--soft);
}

.job { margin-top: 0.12rem; }
.speaking { color: var(--accent); font-weight: 700; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chip {
  background: var(--panel);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  box-shadow: 0 1px 3px var(--shadow);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.chip b { font-weight: 700; }
.chip.gone { color: var(--faint); }

.result-lines { margin: 0.15rem 0 0.4rem; padding-left: 1.15rem; }
.result-lines li { margin: 0.35rem 0; }

.log { margin-top: 0.85rem; color: var(--soft); font-size: 0.88rem; }
.log summary { cursor: pointer; font-weight: 650; color: var(--ink); }
.log ul { margin: 0.25rem 0 0.45rem; padding-left: 1.15rem; }
.log-name strong { color: var(--ink); }

.fairings { display: grid; gap: 0.4rem; margin-top: 0.8rem; }

.fairing {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
}

.fairing strong { display: block; font-size: 0.92rem; }
.fairing span { color: var(--soft); font-size: 0.8rem; }
.fairing.earned { border-color: #e7c3b6; background: #fff7f2; }

.fairing .new {
  display: inline-block;
  margin-left: 0.35rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

dialog {
  width: min(34rem, calc(100% - 1.5rem));
  max-width: calc(100vw - 1.5rem);
  border: none;
  border-radius: 16px;
  padding: 1.2rem 1.3rem 1.15rem;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(61, 52, 41, 0.28);
}

dialog::backdrop { background: rgba(61, 52, 41, 0.38); }
dialog h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
dialog p, dialog li { font-size: 0.95rem; }
dialog ul { margin: 0.4rem 0 0.7rem; padding-left: 1.15rem; }
dialog li { margin: 0.28rem 0; }
.how-keys { color: var(--soft); font-size: 0.85rem; }
dialog form { margin: 0.8rem 0 0; }

@container book (max-width: 36rem) {
  .titles h1 { font-size: 1.3rem; }
  .top {
    grid-template-columns: auto 1fr;
    grid-template-areas: "mark titles" "actions actions";
  }
  .mark { grid-area: mark; }
  .titles { grid-area: titles; min-width: 0; }
  .top-actions { grid-area: actions; }
  .btn { max-width: 100%; }
  .herd, .names { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
