/* Farkle. The top part is the shared paper-and-ink look of the other sections (copied from
   ../shut-the-box/styles.css: header, intro, tabs, buttons, article, footer); the game and score sheet are at the bottom. */
:root {
  --paper: #faf8f2;
  --ink: #292d28;
  --muted: #697064;
  --line: #dfdfd3;
  --accent: #bd5f3e;
  --teal: #24878b;
  --pad: #fffdf8;
  --dot: #d5d3c4;
  --ink-mark: #bd5f3e;
  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
    --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
  --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 0; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.crumbs { flex: 1; color: var(--muted); font-size: 15px; min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--line); }
.crumbs [aria-current] { color: var(--ink); }
.theme-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.langs { display: flex; gap: 2px; }
.langs a { padding: 5px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); background: var(--line); }

/* ---------- intro ---------- */
.intro { padding: 34px 0 22px; }
.intro h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.02em;
}
.lede { margin: 12px 0 0; font-size: 18px; color: var(--muted); max-width: 58ch; }

.durations { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.durations a {
  padding: 7px 16px; border: 1.5px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 15px; color: var(--muted);
}
.durations a:hover { border-color: var(--ink); color: var(--ink); }
.durations a[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }

.mode-switch { display: inline-flex; margin: 0 0 18px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stop-row { margin: 14px 0 0; min-height: 0; }
.stop-row:has([hidden]) { margin: 0; }

.challenge {
  margin: 0 0 20px; padding: 12px 16px; border-left: 4px solid var(--accent);
  background: var(--pad); font-weight: 600;
}

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }
.btn {
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ---------- article ---------- */
.prose { max-width: 70ch; margin: 56px 0 0; font-size: 17px; line-height: 1.7; }
.prose h2 { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.2; margin: 44px 0 10px; letter-spacing: -0.01em; }
.prose h3 { font-size: 19px; margin: 26px 0 6px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 0 0 16px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 9px 12px 9px 0; text-align: left; vertical-align: top; }
.prose th { border-bottom: 2px solid var(--ink); font-weight: 700; }
.prose td:first-child { font-weight: 700; white-space: nowrap; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq-answer { padding: 8px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 64px; padding: 22px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.site-footer a { text-decoration: none; color: var(--ink); }
.site-footer a:hover { color: var(--accent); }
.site-footer a[aria-current] { color: var(--muted); }
.site-footer .footer-site { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.site-footer p { margin: 10px 0 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0; }
.toolbar .label { color: var(--muted); font-size: 15px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }


/* ---------- small screens (shared) ---------- */
@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { gap: 12px; padding: 14px 0; }
  .crumbs { display: none; }
  .brand { flex: 1; }
  .intro { padding: 24px 0 16px; }
  .lede { font-size: 16px; }
  .durations { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .durations::-webkit-scrollbar { display: none; }
  .durations a { white-space: nowrap; flex: none; }
  .prose { font-size: 16px; margin-top: 40px; }
  .prose h2 { font-size: 23px; }
  .prose table { display: block; overflow-x: auto; }
}

/* ---------- farkle ---------- */
:root { --die: #fffdf8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --die: #2b2e29; } }
:root[data-theme="dark"] { --die: #2b2e29; }
.btn[disabled] { opacity: .45; cursor: default; }
.fk-game { max-width: 860px; }
.fk-scores { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.fk-player { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; font-size: 15px; color: var(--muted); }
.fk-player b { color: var(--ink); font-variant-numeric: tabular-nums; }
.fk-player.is-turn { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.fk-target { color: var(--muted); font-size: 14px; margin-left: 4px; }
.fk-table { padding: clamp(14px, 3vw, 24px); border: 2px solid var(--ink); border-radius: 20px; background: #2f6b4f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fk-table { background: #224d39; } }
:root[data-theme="dark"] .fk-table { background: #224d39; }
.fk-dice { display: flex; flex-wrap: wrap; gap: clamp(8px, 2vw, 14px); min-height: 76px; align-items: center; }
.fk-die { width: clamp(52px, 11vw, 72px); height: clamp(52px, 11vw, 72px); padding: 0; border: 0; background: none; cursor: pointer; transition: transform .15s; }
.fk-die svg { display: block; width: 100%; height: 100%; }
.fk-die rect { fill: var(--die); stroke: var(--ink); stroke-width: 3; }
.fk-die circle { fill: var(--ink); }
.fk-die:disabled { cursor: default; }
.fk-die:not(:disabled):hover { transform: translateY(-3px); }
.fk-die.is-sel { transform: translateY(-6px); }
.fk-die.is-sel rect { fill: #ffd34d; stroke-width: 4; }
.fk-die.is-hint rect { stroke: var(--teal); stroke-width: 5; }
.fk-dice.is-farkle .fk-die { opacity: .45; }
.fk-dice.is-rolling .fk-die { animation: fk-roll .35s ease-out; }
@keyframes fk-roll { from { transform: rotate(-30deg) scale(.75); opacity: .3; } to { transform: none; opacity: 1; } }
.fk-kept-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .25); min-height: 44px; }
.fk-kept-label { color: rgba(255, 255, 255, .8); font-size: 14px; white-space: nowrap; }
.fk-kept { display: flex; flex-wrap: wrap; gap: 6px; }
.fk-die.is-kept { width: 34px; height: 34px; cursor: default; }
.fk-none { color: rgba(255, 255, 255, .6); font-size: 14px; }
.fk-turn { margin: 14px 0 0; font-size: 17px; min-height: 1.5em; }
.fk-turn b { font-variant-numeric: tabular-nums; }
.fk-good { color: var(--teal); font-weight: 700; margin-left: 6px; }
.fk-bad { color: var(--accent); font-weight: 600; margin-left: 6px; }
.fk-status { margin: 4px 0 0; font-weight: 600; min-height: 1.5em; }
.fk-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.fk-result { margin: 18px 0 0; padding: 16px 18px; border-left: 4px solid var(--teal); background: var(--pad); max-width: 70ch; }
.fk-result-head { margin: 0; font: 800 24px/1.3 var(--display); }
.fk-result-sub { margin: 6px 0 12px; color: var(--muted); }
.fk-bar { margin-top: 20px; }
.fk-group { display: inline-flex; align-items: center; gap: 10px; }
.fk-group[hidden] { display: none; }
.fk-stats { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.fk-chart { margin: 14px 0 0; max-width: 620px; }
.fk-chart summary { cursor: pointer; font-weight: 600; }
.fk-chart table { width: 100%; border-collapse: collapse; margin: 10px 0 6px; font-size: 15px; }
.fk-chart td { padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); }
.fk-chart td:nth-child(2), .fk-chart td:nth-child(4) { font-weight: 700; font-variant-numeric: tabular-nums; }
.fk-chart p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- score sheet ---------- */
.fs-sheet { max-width: 900px; }
.fs-setup { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.fs-names { display: flex; flex-wrap: wrap; gap: 8px; }
.fs-name { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 12px; background: var(--pad); }
.fs-name input { width: 9.5em; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 6px 0; }
.fs-name input:focus { outline: none; }
.fs-name:focus-within { border-color: var(--teal); }
.fs-x { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 8px; }
.fs-setup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.fs-add { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 0; padding: 14px 16px; border: 2px solid var(--ink); border-radius: 16px; background: var(--pad); }
.fs-add label { font-size: 16px; }
.fs-add input { width: 8em; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: 600 17px/1 system-ui, sans-serif; }
.fs-status { min-height: 1.5em; margin: 10px 0 0; font-weight: 600; }
.fs-table-wrap { overflow-x: auto; margin: 12px 0 0; }
.fs-table { border-collapse: collapse; min-width: 100%; font-variant-numeric: tabular-nums; }
.fs-table th, .fs-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.fs-table th:first-child, .fs-table td:first-child { text-align: left; color: var(--muted); width: 3em; }
.fs-table thead th { border-bottom: 2px solid var(--ink); }
.fs-table thead th.is-next { color: var(--accent); }
.fs-table td small { display: block; color: var(--muted); font-size: 12px; }
.fs-table tfoot th { border-top: 2px solid var(--ink); border-bottom: 0; font-size: 18px; }
.fs-table tfoot th.is-lead { color: var(--teal); }
.fs-f { color: var(--accent); font-size: 14px; }
.fs-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.fs-print { display: none; }
@media print {
  body.is-printing-sheet .wrap > *:not(main), body.is-printing-sheet main > *:not(.fs-sheet), body.is-printing-sheet .fs-sheet > *:not(.fs-print) { display: none !important; }
  body.is-printing-sheet { background: #fff; color: #000; }
  body.is-printing-sheet .fs-print { display: block; }
  .fs-print h2 { font: 700 20px/1.2 system-ui, sans-serif; margin: 0 0 8px; }
  .fs-print-table { width: 100%; border-collapse: collapse; font: 12px/1.2 system-ui, sans-serif; }
  .fs-print-table th, .fs-print-table td { border: 1px solid #999; height: 26px; padding: 2px 6px; text-align: right; }
  .fs-print-table th:first-child, .fs-print-table td:first-child { width: 3em; text-align: left; }
  .fs-print-chart { font: 11px/1.4 system-ui, sans-serif; margin: 10px 0 0; }
  .fs-print-foot { font: 10px/1.2 system-ui, sans-serif; color: #555; margin: 6px 0 0; }
}
@media (max-width: 560px) {
  .fk-kept-label { display: none; }
  .fk-dice { gap: 7px; }
  .fk-dice .fk-die { width: 43px; height: 43px; }
  .fs-name input { width: 7.5em; }
}
