/* PriorityHelper — one stylesheet, no framework. Light and dark from tokens. */

:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --ink: #1c1b19;
  --ink-soft: #5c5850;
  --line: #e2ded5;
  --accent: #8a5a2b;
  --accent-soft: #f0e6da;
  --good: #2f6b4f;
  --warn: #8a6d1f;
  /* One colour per picked tag, shared by its chip and its pills on the cards.
     Soft fills with dark ink in light mode, dark fills with light ink in dark. */
  --tag0-bg: #dde9f8; --tag0-ink: #1d3b5e;
  --tag1-bg: #dcefd9; --tag1-ink: #24502c;
  --tag2-bg: #fbe3cf; --tag2-ink: #7a3b0c;
  --tag3-bg: #e9e0f5; --tag3-ink: #4a2a78;
  --tag4-bg: #d3eeec; --tag4-ink: #0f4f4c;
  --tag5-bg: #f8dde8; --tag5-ink: #7a1f48;
  --tag6-bg: #f3eac0; --tag6-ink: #5a4804;
  --tag7-bg: #f6d9d6; --tag7-ink: #7c231a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(28, 27, 25, .06), 0 4px 16px rgba(28, 27, 25, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a;
    --panel: #1f1f23;
    --ink: #ece9e3;
    --ink-soft: #a39d93;
    --line: #33333a;
    --accent: #d9a066;
    --accent-soft: #2c2620;
    --good: #7fc0a0;
    --warn: #d8bd72;
    --tag0-bg: #1f2d40; --tag0-ink: #b9d3f1;
    --tag1-bg: #1f3324; --tag1-ink: #bfe0c2;
    --tag2-bg: #3a2718; --tag2-ink: #f3c49b;
    --tag3-bg: #2c2340; --tag3-ink: #d5c2f0;
    --tag4-bg: #183433; --tag4-ink: #a6e0dc;
    --tag5-bg: #3a1f2b; --tag5-ink: #f2b8d0;
    --tag6-bg: #353018; --tag6-ink: #e8d890;
    --tag7-bg: #3b2020; --tag7-ink: #f1b5ad;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Author rules like `.field { display: block }` outrank the user-agent
   [hidden] rule, so anything toggled via the hidden attribute needs this. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.4rem; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
a { color: var(--accent); }

.sub { color: var(--ink-soft); font-size: 0.86rem; margin: 0.2rem 0 0; }
.hint { color: var(--ink-soft); font-size: 0.8rem; margin: 0.35rem 0 0.6rem; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

/* --------------------------------------------------------------- countdown */
.countdown { display: flex; align-items: center; gap: 0.6rem; }
.countdown-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); text-align: right; max-width: 9rem; line-height: 1.2;
}
.dice { display: flex; gap: 0.3rem; }
.d10 { width: 2.4rem; height: 2.4rem; }
.d10-body { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.d10-edge { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.55; }
.d10-pip {
  fill: var(--ink); font-size: 34px; font-weight: 700;
  text-anchor: middle; dominant-baseline: middle;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- filters bar */
/* Line the bar up with main's content box rather than its outer edge: main is
   capped at 1400px and then padded, so the same sum is subtracted here. */
#filters-bar {
  width: calc(100% - 2.5rem); max-width: calc(1400px - 2.5rem);
  margin: 1.25rem auto 0; padding: 0.9rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#filters-bar h2 { margin: 0 0 0.6rem; }
.filter-row {
  display: grid; gap: 0.75rem 1.25rem; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.filter-row .field { margin: 0; }
.filter-checks { display: grid; align-content: start; gap: 0.1rem; }
.filter-checks .check { margin: 0.1rem 0; }
#filters-bar .hint { margin: 0.25rem 0 0; }

/* The bar is wider than the sidebar it came from, so the halls can sit in a
   single wrapping row instead of a column. */
#filters-bar #halls .hall-boxes { display: flex; flex-wrap: wrap; gap: 0.15rem 0.7rem; }

/* ------------------------------------------------------------------ layout */
main {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
}

#controls {
  position: sticky; top: 4.5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.25rem 1rem 1rem;
}

#controls section { padding: 1rem 0; border-bottom: 1px solid var(--line); }
#controls section:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------ fields */
.field { display: block; margin: 0.6rem 0; }
.field > span { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; }
.field.inline { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.field.inline > span { margin: 0; }

input[type="text"], input:not([type]), select {
  width: 100%; padding: 0.45rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit;
}
.field.inline select { width: auto; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
output { font-variant-numeric: tabular-nums; color: var(--ink-soft); }

.check { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; font-size: 0.9rem; }
.check.inline { margin: 0; }
.check input { accent-color: var(--accent); }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 0.4rem 0.7rem;
}
button:hover { border-color: var(--accent); }
button.small { font-size: 0.8rem; padding: 0.3rem 0.55rem; }
#toggle-controls { display: none; }

/* -------------------------------------------------------- chips & quickpick */
.quick { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }
.quick button {
  font-size: 0.78rem; padding: 0.2rem 0.5rem; border-radius: 999px;
  color: var(--ink-soft);
}

/* One weight row: tick, slider, and the value it is measured against. An
   unticked row keeps its height but reads as switched off. */
.weight { padding: 0.5rem 0 0.7rem; border-bottom: 1px dashed var(--line); }
.weight:last-child { border-bottom: 0; }
.weight > .check { margin: 0 0 0.35rem; }
.weight.off > input[type="range"] { opacity: 0.35; }
.weight.off > .check span { color: var(--ink-soft); }
.value-field { margin: 0.5rem 0 0; }
.value-field input[type="number"] {
  width: 100%; padding: 0.45rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit;
}

.chips { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.chip {
  background: var(--accent-soft);
  border-radius: 8px; padding: 0.45rem 0.55rem;
}
.tag-c0 { --tag-bg: var(--tag0-bg); --tag-ink: var(--tag0-ink); }
.tag-c1 { --tag-bg: var(--tag1-bg); --tag-ink: var(--tag1-ink); }
.tag-c2 { --tag-bg: var(--tag2-bg); --tag-ink: var(--tag2-ink); }
.tag-c3 { --tag-bg: var(--tag3-bg); --tag-ink: var(--tag3-ink); }
.tag-c4 { --tag-bg: var(--tag4-bg); --tag-ink: var(--tag4-ink); }
.tag-c5 { --tag-bg: var(--tag5-bg); --tag-ink: var(--tag5-ink); }
.tag-c6 { --tag-bg: var(--tag6-bg); --tag-ink: var(--tag6-ink); }
.tag-c7 { --tag-bg: var(--tag7-bg); --tag-ink: var(--tag7-ink); }
.chip[class*="tag-c"], .reasons li[class*="tag-c"] { background: var(--tag-bg); color: var(--tag-ink); }
.chip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.chip-name { font-size: 0.85rem; font-weight: 600; }
.chip-drop {
  border: 0; background: transparent; color: var(--ink-soft);
  padding: 0 0.2rem; font-size: 1rem; line-height: 1;
}
.chip-drop:hover { color: var(--accent); }

/* ----------------------------------------------------------------- results */
.results-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
#results-title { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.results-actions { display: flex; align-items: center; gap: 1rem; }

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }

.card {
  display: grid;
  grid-template-columns: 3rem 64px 1fr auto;
  gap: 0.85rem;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow);
}

.rank { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink-soft); font-size: 1.05rem; }
.thumb {
  width: 64px; height: 64px; object-fit: contain;
  background: var(--bg); border-radius: 6px;
}
.thumb-missing {
  display: grid; place-items: center;
  font-size: 0.65rem; color: var(--ink-soft); text-align: center;
}

.title { margin: 0; font-size: 1rem; }
.title a { text-decoration: none; }
.title a:hover { text-decoration: underline; }
.meta { color: var(--ink-soft); font-size: 0.8rem; margin: 0.15rem 0 0; }

/* Edition languages, beside the title. Sized to the text, not the header's
   language buttons: these are information, not controls. */
.lang-flags {
  display: inline-flex; flex-wrap: wrap; gap: 0.25rem;
  margin-left: 0.45rem; vertical-align: -0.05em;
}
.lang-flag {
  display: inline-block; line-height: 0;
  border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1px var(--line);
}
.lang-flag svg { display: block; width: 18px; height: 12px; }
.lang-code {
  line-height: 12px; height: 12px; padding: 0 0.2rem;
  font-size: 0.6rem; font-weight: 700; color: var(--ink-soft); background: var(--bg);
}

.reasons { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0 0; padding: 0; list-style: none; }
.reasons li {
  font-size: 0.75rem; padding: 0.15rem 0.45rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink);
}
/* Mechanics stay round pills; categories are squarer, since colour now says
   which tag it is rather than which kind. */
.reasons li.tag-category { border-radius: 4px; }
.reasons li.dim { background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); }

.side { text-align: right; display: grid; gap: 0.25rem; justify-items: end; }
.booth { font-size: 0.8rem; font-weight: 600; }
.booth.unknown { color: var(--ink-soft); font-weight: 400; }
.price { font-size: 0.8rem; color: var(--ink-soft); }
.badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem; border-radius: 4px; border: 1px solid var(--line);
  color: var(--ink-soft);
}
.badge.demo { color: var(--warn); border-color: currentColor; }
.badge.low-confidence { color: var(--ink-soft); }

.hall-group { margin: 1.25rem 0 0; }
.hall-group > h3 {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-soft); margin-bottom: 0.5rem;
  position: sticky; top: 3.6rem; background: var(--bg); padding: 0.3rem 0;
}
.hall-boxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hall-boxes label { display: flex; align-items: center; gap: 0.25rem; font-size: 0.85rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0.6rem 0 0; }
legend { font-size: 0.8rem; color: var(--ink-soft); padding: 0 0.3rem; }

.empty { color: var(--ink-soft); padding: 2rem 0; text-align: center; }

footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem; margin-top: 2rem;
  font-size: 0.85rem; color: var(--ink-soft);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem;
}
footer p { margin: 0.2rem 0; }
footer a { color: inherit; }
/* BGG ships a reversed variant for dark backgrounds; index.html picks it. */
.bgg-logo { display: inline-block; flex: none; line-height: 0; }
.bgg-logo img { width: 150px; height: auto; }
.footer-text { flex: 1 1 18rem; }

/* ------------------------------------------------------------- impressum */
.home-link { color: inherit; text-decoration: none; }
.legal {
  max-width: 40rem; margin: 2rem auto; padding: 0 1.25rem; line-height: 1.55;
}
.legal h2 {
  font-size: 1.6rem; text-transform: none; letter-spacing: 0; color: var(--ink);
}
.legal h3 { font-size: 1rem; margin: 1.5rem 0 0.3rem; }
.legal p { margin: 0.3rem 0; }
.legal a { color: var(--accent); }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  /* The topbar wraps rather than squeezing the dice into the brand — which
     makes it ~174px tall, a fifth of a phone screen, so it stops being pinned
     and scrolls away with the rest. */
  .topbar { flex-wrap: wrap; row-gap: 0.6rem; position: static; }
  .countdown { order: 3; width: 100%; justify-content: flex-start; }
  .countdown-label { text-align: left; max-width: none; }
  #toggle-controls { display: block; }
  #controls { position: static; max-height: none; }
  #controls[hidden] { display: none; }
  .card { grid-template-columns: 2.2rem 48px 1fr; }
  .thumb { width: 48px; height: 48px; }
  .side { grid-column: 2 / -1; justify-items: start; text-align: left; }
}

/* ------------------------------------------------------------------- print */
/* "Save as PDF" prints the page. The PDF keeps the list and the BGG
   attribution and drops everything that is only there to be clicked. */
.print-only { display: none; }

@media print {
  /* Paper is white whatever the screen theme is. */
  :root {
    --bg: #fff; --panel: #fff; --ink: #000; --ink-soft: #4a4740; --line: #cfcac0;
    --accent: #6e4520; --accent-soft: #f0e6da; --warn: #7a5c10;
    --mech-bg: #e2ebf6; --mech-ink: #1d3b5e; --cat-bg: #e3f0e1; --cat-ink: #25502d;
    --shadow: none;
    color-scheme: light;
  }
  @page { margin: 12mm; }
  body { font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .topbar { position: static; padding: 0 0 0.5rem; }
  .countdown, .topbar-actions, #filters-bar, #controls, .results-actions,
  footer .sub { display: none !important; }
  .print-only { display: block; }

  main { display: block; padding: 0.75rem 0 0; max-width: none; }
  /* An A4 page is narrower than the 860px phone breakpoint, which would push
     booth and price under the title. Keep them in their own column. */
  .card { grid-template-columns: 2.2rem 48px 1fr auto; break-inside: avoid; box-shadow: none; }
  .thumb { width: 48px; height: 48px; }
  .side { grid-column: auto; justify-items: end; text-align: right; }
  .title a { color: var(--ink); }
  .hall-group > h3 { position: static; break-after: avoid; }
  footer { margin-top: 1rem; padding: 0.75rem 0 0; break-inside: avoid; }
}

/* ------------------------------------------------------- language switcher */
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.langs { display: flex; gap: 0.35rem; }

.flag {
  padding: 0; border-radius: 4px; overflow: hidden; line-height: 0;
  border: 1px solid var(--line); opacity: 0.55; cursor: pointer;
  transition: opacity .12s ease;
}
.flag svg { display: block; width: 30px; height: 20px; }
.flag:hover { opacity: 0.85; }
.flag[aria-pressed="true"] {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.flag:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
