:root {
  --page: #f6f4ee;
  --text: #1a1916;
  --muted: #6b675f;
  --line: #dcd8ce;
  --strip: #efece4;
  --link: #2a5db0;
  --link-visited: #6a4c9c;
  --flash: #fff1cc;
  --marker: rgba(240, 162, 10, .45);

  --light-bg: #ffffff;
  --light-hover: #f7f5ef;
  --light-text: #1a1916;
  --light-muted: #6b675f;

  --dark-bg: #16151a;
  --dark-hover: #1f1e22;
  --dark-text: #ffffff;
  --dark-muted: #a19c93;
  --dark-border: transparent;

  --amber: #f0a20a;
  --amber-hover: #d98f00;
  --amber-ink: #1f1503;

  --good: #2e7d4f;
  --bad: #c0392b;
  /* the light card stays light in both themes, so it keeps the light-mode result colours */
  --light-good: #2e7d4f;
  --light-bad: #c0392b;

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-settle: cubic-bezier(.3, 1.3, .5, 1);

  --radius: 4px;
  --sans: "Libre Franklin", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #1b1a18;
    --text: #ece9e2;
    --muted: #9a958b;
    --line: #3a3732;
    --strip: #26241f;
    --link: #8fb3ef;
    --link-visited: #b9a0e0;
    --flash: #3a2f14;
    --marker: rgba(240, 162, 10, .32);

    --light-bg: #e8e5dd;
    --light-hover: #dfdcd3;
    --light-muted: #5e5a52;

    --dark-bg: #0d0c0b;
    --dark-hover: #1a1917;
    --dark-muted: #9a958b;
    --dark-border: #3a3732;

    --good: #6cc28e;
    --bad: #e8705f;
  }
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
}

::selection { background: var(--amber); color: var(--amber-ink); }

p { text-wrap: pretty; }

a { color: inherit; }
.section a, .foot a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.section a:visited, .foot a:visited { color: var(--link-visited); }
.section a:hover, .foot a:hover { text-decoration-thickness: 2px; }

kbd {
  display: inline-block;
  padding: 2px 5px 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  font: 600 12px/1 ui-monospace, Menlo, Consolas, monospace;
  vertical-align: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  max-width: 820px;
  margin: 0 auto;
  padding: 22px 16px 12px;
  border-bottom: 2px solid var(--text);
}
.brand {
  font: 700 26px/1.1 var(--serif);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.nav { display: flex; flex-wrap: wrap; gap: 18px; font-size: 15px; font-weight: 500; }
.nav a { color: var(--muted); text-decoration: none; text-underline-offset: 4px; }
.nav a:hover { color: var(--text); text-decoration: underline; }

/* ---------- main ---------- */

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 22px 16px 8px;
}

.headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}
h1 {
  margin: 0;
  font: 700 clamp(22px, 3.4vw, 28px)/1.15 var(--serif);
  text-wrap: balance;
}

/* Coin set: radios drawn as underlined text tabs */
.modes {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 15px;
  --u-left: 0px;
  --u-width: 0px;
}
.modes legend { float: left; margin-right: 0; padding: 0; color: var(--muted); }
.modes label { position: relative; cursor: pointer; white-space: nowrap; }
.modes input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.modes label > span { display: inline-block; padding: 6px 0; font-weight: 500; color: var(--muted); }
.modes label:hover > span { color: var(--text); }
.modes input:checked + span { color: var(--text); }
.modes input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 3px; }
.modes::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: var(--u-left);
  width: var(--u-width);
  height: 2px;
  background: var(--text);
  transition: left .22s var(--ease-out), width .22s var(--ease-out);
}
.modes.no-anim::after { transition: none; }
.modes:disabled label { cursor: default; }
.modes:disabled::after { opacity: 0; }

/* ---------- scoreboard ---------- */

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  margin: 14px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--text);
}
.scoreboard > div { padding-right: 22px; }
.scoreboard > div + div { padding-left: 22px; border-left: 1px solid var(--line); }
.scoreboard dt { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.scoreboard dd { margin: 2px 0 0; font: 600 24px/1.1 var(--sans); font-variant-numeric: tabular-nums; }
.roll { position: relative; display: inline-block; height: 1.1em; overflow: hidden; vertical-align: bottom; }
.roll-v { display: block; }
.roll-v.old { position: absolute; left: 0; top: 0; }
.pip {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 4px;
  border: 1.5px solid var(--text);
  vertical-align: 2px;
}
.pip.on { background: var(--bad); border-color: var(--bad); }
.is-record .roll {
  background: linear-gradient(var(--marker), var(--marker)) no-repeat 0 88% / 100% .38em;
}

/* ---------- board ---------- */

.board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.cards {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  outline: none;
}

.side {
  display: flex;
  min-width: 0;
  min-height: 340px;
  padding: 0;
  margin: 0;
  border: 0;
  font: inherit;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 0 0 0 transparent;
  transition: background-color .12s, box-shadow .16s var(--ease-out);
}
.side:disabled { cursor: default; }
.body {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 40px 24px 32px;
}
.side--light { background: var(--light-bg); color: var(--light-text); --side-muted: var(--light-muted); --plate: transparent; --good-c: var(--light-good); --bad-c: var(--light-bad); }
.side--dark { background: var(--dark-bg); color: var(--dark-text); --side-muted: var(--dark-muted); --plate: #ffffff; --good-c: var(--good); --bad-c: var(--bad); box-shadow: inset 1px 0 0 var(--dark-border), inset 0 0 0 0 transparent; }
.side:focus-visible { outline: 3px solid var(--amber); outline-offset: -6px; }
.side--light:focus-visible { outline-color: var(--light-text); }
.side[data-picked="good"] { box-shadow: inset 0 0 0 4px var(--good-c); }
.side[data-picked="bad"] { box-shadow: inset 0 0 0 4px var(--bad-c); }
/* the losing coin of a right pick steps back; small muted text keeps full contrast */
.side .logo, .side .name, .side .cap-value { transition: opacity .2s var(--ease-out); }
.side.is-dim .logo, .side.is-dim .name, .side.is-dim .cap-value { opacity: .6; }

@media (hover: hover) and (pointer: fine) {
  .side--light:not(:disabled):hover { background: var(--light-hover); }
  .side--dark:not(:disabled):hover { background: var(--dark-hover); }
  .side:not(:disabled) .logo { transition: transform .16s var(--ease-out); }
  .side:not(:disabled):hover .logo { transform: translateY(-2px); }
  .side:not(:disabled):hover .name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
}
.side:not(:disabled):active .body { transform: scale(.985); transition: transform 80ms linear; }

.logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--plate);
}
.logo img { width: 60px; height: 60px; object-fit: contain; }
.letter {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1a1916;
  color: #ffffff;
  font-weight: 700;
  font-size: 26px;
}
.board[data-state="loading"] .logo { background: var(--line); }

/* room for a two-line name and the verdict tag, so the bar doesn't move between rounds */
@media (min-width: 641px) {
  .side { min-height: 410px; }
  .body { justify-content: center; }
}
.board[data-state="loading"] .name:empty,
.board[data-state="loading"] .symbol:empty {
  width: 9em;
  max-width: 70%;
  height: 26px;
  margin-top: 18px;
  background: var(--line);
}
.board[data-state="loading"] .symbol:empty { width: 4em; height: 14px; margin-top: 8px; }

.name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  max-width: 20ch;
  margin-top: 16px;
  font-size: clamp(24px, 3.6vw, 36px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.005em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.name.long { font-size: clamp(22px, 2.8vw, 28px); }
.symbol {
  min-height: 21px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--side-muted);
}
.cap { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.cap-label { font-size: 14px; color: var(--side-muted); }
.cap-value { font-size: 30px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; transition: color .7s var(--ease-out); }
.cap-value.hidden-value { color: var(--side-muted); }
.rank { min-height: 20px; margin-top: 2px; font-size: 13px; color: var(--side-muted); }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 24px; margin-top: 10px; }
.tag {
  padding: 3px 8px;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 18px;
  text-transform: uppercase;
}
.tag--bigger { background: var(--amber); color: var(--amber-ink); }
.tag--pick { border: 1px solid currentColor; padding: 2px 7px; }

.vs {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  perspective: 400px;
  z-index: 1;
  pointer-events: none;
}
.vs-face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid var(--page);
  background: var(--amber);
  color: var(--amber-ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
}
.vs-face[data-result="good"] { background: #2e7d4f; }
.vs-face[data-result="bad"] { background: #c0392b; }
.vs-face svg { width: 22px; height: 22px; fill: none; stroke: #ffffff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.bar {
  position: relative;
  display: block;
  width: 100%;
  height: 56px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--amber);
  color: var(--amber-ink);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, .14);
  font: 600 17px var(--sans);
  cursor: pointer;
  overflow: hidden;
}
.bar:hover:not(:disabled) { background: var(--amber-hover); }
.bar:active:not(:disabled) .bar-label { display: inline-block; transform: translateY(1px); }
.bar:focus-visible { outline: 3px solid var(--amber-ink); outline-offset: -5px; }
.bar:disabled { background: var(--strip); color: var(--muted); cursor: default; box-shadow: inset 0 1px 0 var(--line); }
.bar kbd { margin-left: 6px; background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .22); color: inherit; }
@media (hover: none) { .bar kbd { display: none; } }

/* loading: the only looping motion on the site */
.board[data-state="loading"] .bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 2px;
  background: var(--amber);
  animation: loading 1.1s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes loading { to { left: 100%; } }

/* ---------- status ---------- */

.status { min-height: 3.2em; margin: 16px 0 0; }
.status p { margin: 0 0 4px; }
.status .right { font-weight: 700; color: var(--good); }
.status .wrong { font-weight: 700; color: var(--bad); }
.status .note { color: var(--muted); }
.status a { color: var(--link); }

.textbtn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: 500 14px var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.textbtn:hover { text-decoration-thickness: 2px; }

/* ---------- result panel ---------- */

.result { display: grid; grid-template-rows: 1fr; margin-top: 20px; }
.result[hidden] { display: none; }
.result-inner { min-height: 0; overflow: hidden; padding-top: 16px; border-top: 1px solid var(--text); }
.result h2 { margin: 0 0 6px; font: 700 20px/1.25 var(--serif); }
.chip {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 7px;
  border-radius: 2px;
  background: var(--amber);
  color: var(--amber-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}
.chip[hidden] { display: none; }
.result-score { margin: 0; font: 700 22px/1 var(--serif); }
.result-score b { font-size: 64px; line-height: .95; font-variant-numeric: tabular-nums; }
.result-line { margin: 6px 0 12px; color: var(--muted); }
.strip { display: flex; flex-wrap: wrap; gap: 3px; margin: 0 0 14px; padding: 0; list-style: none; }
.strip li { width: 14px; height: 14px; }
.strip .ok { background: var(--good); }
.strip .miss { border: 2px solid var(--bad); }
.result-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: 15px; }
.result-facts dt { color: var(--muted); }
.result-facts dd { margin: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 18px; margin: 0; }
.result-actions .textbtn { font-size: 15px; }
.copy-fallback { display: block; width: 100%; margin-top: 10px; font: 14px var(--sans); }
.copy-fallback[hidden] { display: none; }

/* ---------- sections ---------- */

.section {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 12px;
}
.section h2 { margin: 0 0 8px; font: 700 20px/1.25 var(--serif); }
.section h3 { margin: 18px 0 6px; font-size: 16px; font-weight: 600; }
.section p { margin: 0 0 8px; max-width: 64ch; }

table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th {
  padding: 0 8px 5px 0;
  border-bottom: 1px solid var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
}
td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.num { text-align: right; padding-right: 0; }
.log td:first-child { width: 4.5em; color: var(--muted); white-space: nowrap; }
.log img { width: 18px; height: 18px; margin-right: 6px; border-radius: 50%; vertical-align: -3px; }
.log a, .log a:visited { color: inherit; text-decoration: none; }
.log a:hover { text-decoration: underline; }
.log .win a { font-weight: 600; }
.log .sub { display: none; color: var(--muted); }
.log .miss-word { margin-left: 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--bad); }
.log tr.miss .num { color: var(--bad); }
.log tr.fresh td { background: var(--flash); }
.log .gap { color: var(--muted); }
.log .cap { display: inline; margin: 0; white-space: nowrap; }
.log td { overflow-wrap: anywhere; }

.your-stats { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 8px; }
.your-stats dt { color: var(--muted); }
.your-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.recent { margin-bottom: 10px; }
.small { font-size: 14px; color: var(--muted); }

.coins summary { cursor: pointer; font-weight: 500; }
.coins ul {
  columns: 3 14em;
  column-gap: 24px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}
.coins li { break-inside: avoid; padding: 1px 0; }
.coins .tk { color: var(--muted); }

/* ---------- footer ---------- */

.foot {
  max-width: 820px;
  margin: 32px auto 0;
  padding: 14px 16px 28px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.foot p { margin: 0 0 4px; }
.foot kbd { font-size: 11px; }
.keys { display: none; }
@media (hover: hover) { .keys { display: block; } }

/* ---------- phone ---------- */

@media (max-width: 640px) {
  .top { padding-top: 16px; }
  .nav { width: 100%; gap: 14px; font-size: 14px; }
  .cards { grid-template-columns: 1fr; }
  .side { min-height: 0; }
  .body { padding: 18px 16px 16px; }
  /* room for the VS badge on the seam */
  .side--light .body { padding-bottom: 30px; }
  .side--dark .body { padding-top: 32px; }
  .side--dark { box-shadow: inset 0 1px 0 var(--dark-border); }
  .symbol:empty { display: none; }
  /* rank and tag lines keep their space so the verdict doesn't push the bar down */
  .tags { margin-top: 6px; }
  .logo { width: 48px; height: 48px; }
  .logo img, .letter { width: 36px; height: 36px; font-size: 18px; }
  .name { margin-top: 8px; font-size: 24px; }
  .name.long { font-size: 21px; }
  .cap { margin-top: 8px; }
  .cap-value { font-size: 24px; }
  .vs { top: var(--seam, 50%); width: 48px; height: 48px; }
  .vs-face { font-size: 14px; }
  .vs-face svg { width: 18px; height: 18px; }
  .bar { height: 52px; }
  .result-score b { font-size: 48px; }
  .log .col-small { display: none; }
  .log .sub { display: block; }
}
@media (max-width: 400px) {
  .scoreboard { grid-template-columns: repeat(4, 1fr); }
  .scoreboard > div { padding-right: 12px; }
  .scoreboard > div + div { padding-left: 12px; }
  .scoreboard dd { font-size: 20px; }
  .pip { width: 10px; height: 10px; margin-right: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .nav, .board, .scoreboard, #copy, .modes { display: none; }
  body { background: #fff; color: #000; }
}

#history h2:focus { outline: none; }

/* ---------- text pages (privacy) ---------- */

.page h1 { margin-bottom: 4px; }
.page ul { margin: 0 0 8px; padding-left: 20px; max-width: 64ch; }
.page li { margin-bottom: 4px; }
.page code { font: 14px ui-monospace, Menlo, Consolas, monospace; }
.fill { background: var(--marker); padding: 0 3px; border-radius: 2px; }
