@font-face {
  font-family: Newsreader;
  src: url("./fonts/newsreader.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fcfbf8;
  --ink: #1b1916;
  --muted: #58544e;
  --rule: #dcd7ce;
  --shade: #f3f0e9;
  --accent: #82382d;
  --serif: Newsreader, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 var(--sans); }
body:has(dialog[open]) { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-underline-offset: .2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.frame { width: min(69rem, calc(100% - 5rem)); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  inset: .75rem auto auto .75rem;
  z-index: 1;
  padding: .5rem 1rem;
  background: var(--paper);
}

.masthead-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 3.2rem;
  border-bottom: 1px solid var(--rule);
}
.method-button, .fienden-link {
  padding: .25rem 0;
  border: 0;
  background: transparent;
  white-space: nowrap;
  font-size: .875rem;
  font-weight: 580;
  text-decoration: none;
}
.method-button { color: var(--muted); }
.fienden-link { color: var(--accent); font-weight: 680; }
.method-button:hover, .fienden-link:hover { text-decoration: underline; }

.masthead-title {
  padding: clamp(2.15rem, 4.8vw, 4.2rem) 0 clamp(1.7rem, 3.8vw, 2.45rem);
  border-bottom: 4px double var(--ink);
  text-align: center;
}
.masthead h1 {
  margin: 0;
  font: 650 clamp(3.2rem, 8.3vw, 7.5rem)/.87 var(--serif);
  letter-spacing: -.047em;
}
.masthead p {
  margin: clamp(.65rem, 1.6vw, 1rem) 0 0;
  color: var(--muted);
  font: 450 clamp(1.2rem, 2vw, 1.55rem)/1.2 var(--serif);
}

.main { padding-bottom: 4rem; }
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.view-switch, .period-switch { display: flex; flex-wrap: wrap; align-items: center; }
.view-switch { gap: clamp(1.05rem, 3vw, 1.7rem); }
.period-switch { gap: .25rem; padding-block: .45rem; }
.view-switch button, .period-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
}
.view-switch button {
  min-height: 3.3rem;
  margin-bottom: -1px;
  padding: .5rem 0;
  border-bottom: 2px solid transparent;
}
.view-switch button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.period-switch button {
  min-height: 2rem;
  padding: .23rem .65rem;
  border-radius: .15rem;
  font-variant-numeric: tabular-nums;
}
.period-switch button[aria-pressed="true"] { background: var(--shade); color: var(--ink); }
.view-switch button:hover, .period-switch button:hover { color: var(--accent); }
.scope {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .15rem 1.15rem;
  margin-block: 1.25rem .65rem;
  color: var(--muted);
  font-size: .875rem;
}
.scope p { margin: 0; }
.scope p:first-child { font-weight: 640; color: var(--ink); }

.table-shell { border-block: 1px solid var(--ink); }
.ranking-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.ranking-table th, .ranking-table td { text-align: left; }
.ranking-table thead {
  background: var(--shade);
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
}
.ranking-table thead th {
  height: 2.9rem;
  padding: 0 .72rem;
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
}
.ranking-table .rank { width: 3.45rem; text-align: center; }
.ranking-table .hits { width: 5.85rem; text-align: right; }
.ranking-table .guesses { width: 6rem; text-align: right; }
.ranking-table .accuracy { width: 25%; padding-inline-start: 1.75rem; }
.ranking-table .position { width: 6.7rem; text-align: right; padding-inline-end: 1rem; }
.ranking-table thead [aria-sort="descending"] { color: var(--accent); }
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: .43rem;
  min-height: 2.3rem;
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: inherit;
}
.sort-button:hover { color: var(--accent); }
.sort-mark {
  display: block;
  width: .68rem;
  height: .53rem;
  opacity: .48;
  background: linear-gradient(currentColor, currentColor) 0 0 / 100% 1px,
              linear-gradient(currentColor, currentColor) 0 50% / 70% 1px,
              linear-gradient(currentColor, currentColor) 0 100% / 40% 1px;
  background-repeat: no-repeat;
}
[aria-sort="descending"] .sort-mark, .sort-button:hover .sort-mark { opacity: 1; }

.result-row { border-top: 1px solid var(--rule); }
.result-row:hover, .result-row:focus-within, .result-row[data-open] { background: #f7f4ed; }
.result-row td { padding: .25rem .72rem; }
.result-row .rank, .result-row .hits, .result-row .guesses, .result-row .position, .accuracy-value {
  font-variant-numeric: tabular-nums;
}
.result-row .rank { color: var(--muted); font-size: .84rem; }
.result-row .hits { font-weight: 700; font-size: 1.12rem; }
.result-row .guesses, .result-row .position { color: var(--muted); }
.ranking-table .identity { padding: 0 .72rem; }
.identity-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  min-height: 3.45rem;
  padding: .56rem 0;
  border: 0;
  background: transparent;
  text-align: start;
}
.identity-button:focus-visible { outline-offset: -2px; }
.identity-text { min-width: 0; }
.identity-name {
  font: 620 1.28rem/1.12 var(--serif);
  letter-spacing: -.014em;
  overflow-wrap: anywhere;
}
.identity-source { display: block; margin-top: .11rem; color: var(--muted); font: 400 .8rem/1.3 var(--sans); }
.partial-label {
  display: inline-block;
  margin-inline-start: .5rem;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 580;
  white-space: nowrap;
}
.expand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.16rem;
  height: 1.16rem;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--muted);
}
.expand-mark::before, .expand-mark::after {
  content: "";
  width: .45rem;
  height: 1px;
  grid-area: 1 / 1;
  background: currentColor;
}
.expand-mark::after { rotate: 90deg; }
.identity-button[aria-expanded="true"] .expand-mark::after { visibility: hidden; }
.identity-button:hover .expand-mark, .identity-button[aria-expanded="true"] .expand-mark { border-color: var(--accent); color: var(--accent); }

.accuracy-wrap { display: flex; align-items: center; gap: .7rem; }
.accuracy-value { min-width: 3.35rem; font-weight: 580; white-space: nowrap; }
.accuracy-track { width: min(8.7rem, 100%); height: .26rem; background: #e8e2d9; }
.accuracy-fill { display: block; height: 100%; background: var(--accent); }
.compact-only { display: none; }
.guess-denominator { color: var(--muted); font-size: .85rem; font-weight: 500; }
.empty-state { padding: 1rem; color: var(--muted); }

.ranking-table .detail-row td { padding: 0; }
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 1.5rem 2rem;
  padding: 1.4rem 1.5rem 1.6rem 4.15rem;
  border-top: 1px solid var(--rule);
  background: var(--shade);
}
.detail h3, .detail h4 { margin: 0; }
.detail h3 { font: 650 1.25rem/1.1 var(--serif); }
.detail h4 { margin-top: .75rem; color: var(--muted); font-size: .875rem; font-weight: 650; }
.detail p { margin: .45rem 0 0; color: var(--muted); font-size: .875rem; }
.detail ul, .periods { margin: .55rem 0 0; padding: 0; list-style: none; }
.detail li {
  display: grid;
  gap: .12rem;
  padding: .48rem 0;
  border-top: 1px solid var(--rule);
  font-size: .9rem;
}
.detail li small { color: var(--muted); font-size: .82rem; }
.detail li a { width: fit-content; }
.detail a:hover, .method-dialog a:hover { color: var(--accent); }

.method-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: clamp(1.15rem, 4vw, 2rem);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 70px rgb(27 25 22 / .18);
}
dialog::backdrop { background: rgb(27 25 22 / .48); }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: .7rem; }
.dialog-heading h2 {
  margin: 0;
  font: 620 clamp(1.9rem, 5vw, 2.7rem)/.98 var(--serif);
  letter-spacing: -.035em;
}
.close-button {
  padding: .35rem .58rem;
  border: 1px solid var(--rule);
  background: transparent;
  font-size: .875rem;
  font-weight: 620;
}
.close-button:hover { background: var(--shade); }
.method-dialog p { margin: .85rem 0 0; }
.periods { margin-top: .95rem; }
.periods li { padding: .55rem 0; border-top: 1px solid var(--rule); }
.periods li span { display: block; color: var(--muted); font-size: .875rem; }
.definitions { margin: .55rem 0 0; }
.definitions div { display: grid; grid-template-columns: 6.3rem 1fr; gap: .65rem; border-top: 1px solid var(--rule); padding: .54rem 0; font-size: .875rem; }
.definitions dt { font-weight: 675; }
.definitions dd { margin: 0; color: var(--muted); }
.method-note { color: var(--muted); font-size: .875rem; }

@media (max-width: 44rem) {
  .frame { width: calc(100% - 2rem); }
  .masthead-tools { min-height: 2.85rem; }
  .masthead-title { padding-block: 1.95rem 1.45rem; }
  .ranking-table .wide-only { display: none; }
  .compact-only { display: inline; }
  .ranking-table .rank { width: 2.2rem; }
  .ranking-table .hits { width: 6.65rem; }
  .ranking-table .accuracy { width: 23%; padding-inline-start: .8rem; }
  .ranking-table th, .ranking-table td { padding-inline: .5rem; }
  .ranking-table .identity { padding-inline: .5rem; }
  .accuracy-wrap { flex-direction: column; align-items: flex-start; gap: .14rem; }
  .accuracy-value { min-width: 0; }
  .accuracy-track { width: min(100%, 4.35rem); height: .2rem; }
  .identity-button { gap: .4rem; min-height: 3.25rem; }
  .identity-name { font-size: 1.12rem; }
  .partial-label { display: block; margin: .2rem 0 0; }
  .detail { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
}

@media (max-width: 30rem) {
  .masthead h1 { font-size: clamp(2.8rem, 11vw, 4rem); }
  .controls { gap: 0 .65rem; }
  .view-switch { gap: .9rem; }
  .view-switch button { min-height: 2.9rem; }
  .period-switch { padding-block: .3rem; }
  .period-switch button { padding-inline: .37rem; }
  .scope { margin-top: .9rem; font-size: .81rem; }
  .ranking-table .rank { display: none; }
  .ranking-table .identity { padding-inline-start: .6rem; }
  .ranking-table .accuracy { width: 4.55rem; padding-inline-start: .58rem; }
  .sort-button { gap: .25rem; }
  .sort-mark { width: .56rem; }
  #hits-header .sort-mark { display: none; }
  .definitions div { grid-template-columns: 5.15rem 1fr; gap: .45rem; }
}
