/* Trivia — shared styles. Tokens first; every colour has a light and dark value. */

:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1c1b19;
  --muted: #5b5850;
  --border: #dcd6c9;
  --accent: #0b6e7f;
  --accent-strong: #08535f;
  --accent-contrast: #ffffff;
  --good: #1d7a3b;
  --bad: #b3222b;
  --shadow: 0 1px 2px rgb(28 27 25 / 0.08), 0 8px 24px rgb(28 27 25 / 0.08);
  --radius: 14px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #1a1d20;
    --surface-2: #23272b;
    --text: #ecebe7;
    --muted: #a8a49b;
    --border: #343a40;
    --accent: #5cc8d6;
    --accent-strong: #8bdbe5;
    --accent-contrast: #06252a;
    --good: #62d48c;
    --bad: #ff8080;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

img {
  max-width: 100%;
}

/* Components set their own display; `hidden` must still win. */
[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Headings focused by script (to move screen readers along) aren't controls. */
[tabindex="-1"]:focus {
  outline: none;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  top: 8px;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 26px;
  height: 26px;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-2);
}

main {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 40px;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  padding: 16px 0 24px;
}

.site-footer p {
  margin: 6px 0;
}

/* ---------- Shared bits ---------- */

h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 62ch;
  margin: 0 0 20px;
}

.muted {
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-contrast);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.actions.start {
  justify-content: flex-start;
}

kbd {
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font: 0.85em var(--mono);
}

.status {
  min-height: 1.5em;
  text-align: center;
  color: var(--muted);
}

.status button {
  margin-left: 8px;
}

/* ---------- Hub ---------- */

.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  margin-top: 24px;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.game-card h2 {
  margin: 0;
  font-size: 1.35rem;
}

.game-card .tag {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.game-card p {
  margin: 0;
  color: var(--muted);
}

.game-card .actions {
  justify-content: flex-start;
  margin-top: auto;
  padding-top: 8px;
}

.game-card.soon {
  border-style: dashed;
  box-shadow: none;
  background: transparent;
}

/* ---------- Salt duel ---------- */

.modes {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  text-align: center;
}

.modes legend {
  margin: 0 auto 6px;
  padding: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.mode-options label {
  position: relative;
}

.mode-options input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.mode-options span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.mode-options input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.mode-options input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.mode-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.prompt {
  text-align: center;
  margin: 12px 0 4px;
}

.prompt em {
  color: var(--accent);
  font-style: normal;
}

.hint {
  text-align: center;
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.duel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  max-width: 580px;
  margin: 0 auto;
}

.vs {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pick {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 3px solid transparent;
  border-radius: calc(var(--radius) + 3px);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.pick:hover:not([aria-disabled="true"]) {
  transform: translateY(-3px);
}

.pick[aria-disabled="true"] {
  cursor: default;
}

.art {
  position: relative;
  display: block;
  aspect-ratio: 488 / 680;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 18% 12px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}

.art.no-image img {
  display: none;
}

.art.no-image .fallback {
  display: flex;
}

.card-name {
  display: block;
  margin-top: 6px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.pick.chosen {
  border-color: var(--accent);
}

.reveal {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgb(10 12 14 / 0.86);
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.reveal .share {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  font-weight: 800;
}

.reveal .caption {
  margin-top: -2px;
  opacity: 0.85;
  font-size: clamp(0.62rem, 2.3vw, 0.75rem);
}

.reveal .salt,
.reveal .rank {
  font-size: clamp(0.7rem, 2.6vw, 0.85rem);
}

.reveal .badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: #ffffff;
  color: #0b1416;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.zoom {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.verdict {
  min-height: 1.6em;
  margin: 16px 0 0;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
}

.crowd {
  min-height: 1.5em;
  margin: 4px 0 0;
  text-align: center;
}

.verdict.agree {
  color: var(--good);
}

.verdict.disagree {
  color: var(--bad);
}

dialog.zoomed {
  max-width: min(92vw, 488px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

dialog.zoomed::backdrop {
  background: rgb(0 0 0 / 0.75);
}

dialog.zoomed img {
  display: block;
  width: 100%;
  border-radius: var(--radius);
}

dialog.zoomed form {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* ---------- Results ---------- */

.results {
  text-align: center;
}

.big-score {
  margin: 8px 0;
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.big-score .of {
  font-size: 0.35em;
  color: var(--muted);
  margin-left: 6px;
}

.best {
  font-weight: 700;
  color: var(--accent);
}

.history {
  max-width: 560px;
  margin: 20px auto 0;
  padding: 0;
  list-style: none;
  text-align: start;
}

.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.history .pair {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history .points {
  flex: none;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.history .agree {
  color: var(--good);
}

.history .disagree {
  color: var(--bad);
}

/* ---------- Rankings ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
}

.toolbar input {
  flex: 1 1 220px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: middle;
}

thead th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: end;
  white-space: nowrap;
}

.card-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card-cell img {
  flex: none;
  width: 34px;
  height: 47px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface-2);
}

.up {
  color: var(--good);
}

.down {
  color: var(--bad);
}

@media (max-width: 480px) {
  .card-cell img,
  .col-record {
    display: none;
  }

  th,
  td {
    padding: 8px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
