:root {
  --ink: #2b1a10;
  --cream: #fff8e7;
  --paper: #ffffff;
  --red: #d63031;
  --yellow: #ffcb3d;
  --blue: #2f6fdb;
  --link: #1d4fae;
  --green: #3fb56a;
  --lime: #9bd14b;
  --orange: #ff8c42;
  --gray: #b8b0a0;
  --muted: #6f5d4e;
  --radius: 20px;
  --shadow: 0 6px 0 var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  background-image: radial-gradient(#f1e3c2 2px, transparent 2px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

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

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 16px 32px;
  background: var(--yellow);
  border-bottom: 6px solid var(--ink);
  flex-wrap: wrap;
}
.hero-art { width: 220px; max-width: 50vw; animation: bob 2.4s ease-in-out infinite; }
.hero-text { max-width: 640px; text-align: center; }
h1 {
  font-size: clamp(2.6rem, 9vw, 4.6rem);
  line-height: 1;
  margin: 0 0 8px;
  color: var(--paper);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink);
  letter-spacing: 1px;
}
h1 .lie { color: var(--red); display: inline-block; transform: rotate(-6deg); }
.question { font-size: clamp(1.25rem, 3.6vw, 1.6rem); line-height: 1.3; font-weight: 700; margin: 14px auto 24px; max-width: 600px; text-wrap: balance; }

.zip-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.zip-form input,
.zip-form button {
  font: inherit;
  font-size: 1.3rem;
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 10px 22px;
  box-shadow: var(--shadow);
}
.zip-form input { width: 220px; max-width: 100%; text-align: center; background: var(--paper); letter-spacing: 3px; }
.zip-form button { background: var(--red); color: var(--paper); font-weight: 700; cursor: pointer; }
.zip-form button:hover { transform: translateY(-2px); }
.zip-form button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.zip-form button:disabled { opacity: .6; cursor: wait; }
.status { min-height: 1.5em; margin: 16px 0 0; font-weight: 600; }
.status.error { color: #b3141e; }

/* ---------- Results ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; }

.summary {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 20px;
}
.summary h2 { margin: 0 0 6px; font-size: 1.5rem; }
.summary p { margin: 4px 0; }
.summary .callouts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.callout { flex: 1 1 240px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; border: 3px solid var(--ink); }
.callout svg { width: 56px; flex: none; }
.callout.best { background: #d9f6e2; }
.callout.worst { background: #ffdcdc; }

.controls { display: flex; gap: 16px 24px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; font-weight: 600; }
.controls select {
  font: inherit; margin-left: 6px; padding: 4px 10px;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--paper);
}
.controls .check { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.controls input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--red); }

.grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  --tier: var(--gray);
  width: 100%;
  height: 100%;
  font: inherit;
  color: inherit;
  text-align: center;
  cursor: pointer;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform .12s;
}
.card:hover, .card:focus-visible { transform: translateY(-4px) rotate(-1deg); outline: none; }
.card:focus-visible { box-shadow: 0 6px 0 var(--ink), 0 0 0 4px var(--blue); }
.card-top { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--muted); }
.portrait {
  background: var(--tier);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 20px 0;
  margin: 2px 0 6px;
}
.portrait svg { display: block; width: 100%; height: auto; }
.card h3 { margin: 0; font-size: 1.15rem; line-height: 1.15; }
.place { font-size: .85rem; color: var(--muted); }
.pill {
  align-self: center;
  font-size: .75rem;
  font-weight: 600;
  padding: 1px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
}
.meter { height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: #ffdcdc; overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; background: var(--green); border-right: 3px solid var(--ink); }
.pct { font-size: 1rem; }
.pct strong { font-size: 1.5rem; }
.tier-label { font-weight: 700; color: var(--ink); background: var(--tier); border: 2px solid var(--ink); border-radius: 999px; padding: 0 10px; align-self: center; font-size: .9rem; }
.record { font-size: .85rem; color: var(--muted); }

.tier-truth  { --tier: var(--green); }
.tier-mostly { --tier: var(--lime); }
.tier-coin   { --tier: var(--yellow); }
.tier-fibber { --tier: var(--orange); }
.tier-fire   { --tier: var(--red); }
.tier-new    { --tier: var(--gray); }

/* ---------- Detail dialog ---------- */
.detail {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 5px solid var(--ink);
  border-radius: 24px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 0 var(--ink);
}
.detail::backdrop { background: rgba(43, 26, 16, .55); }
.close {
  position: sticky; top: 0; float: right;
  width: 44px; height: 44px; font-size: 1.8rem; line-height: 1;
  border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); cursor: pointer;
}
.detail-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.detail-head .portrait { width: 180px; flex: none; }
.detail-head h2 { margin: 0; font-size: 1.8rem; line-height: 1.1; }
.detail-head .big { font-size: 2.6rem; font-weight: 700; margin: 4px 0; }
.detail .desc { color: var(--muted); font-size: .95rem; }

.years { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
.years span { width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--ink); }
.years .truth { background: var(--green); }
.years .lie { background: var(--red); }
.years .unknown { background: #eee; }
.legend { display: flex; gap: 16px; font-size: .85rem; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; margin-top: 8px; }
th, td { padding: 6px 8px; border-bottom: 2px dashed #e6d9bf; text-align: left; }
th { position: sticky; top: 0; background: var(--paper); }
td.truth { color: #1d7d43; font-weight: 700; }
td.lie { color: #b3141e; font-weight: 700; }
td.unknown { color: var(--muted); }

/* ---------- Footer ---------- */
.footer { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; font-size: .95rem; }
.footer summary { font-weight: 700; cursor: pointer; font-size: 1.1rem; }
.credits { color: var(--muted); font-size: .85rem; }
a { color: var(--link); }
:focus-visible { outline: 4px solid var(--link); outline-offset: 2px; }
.skip-link { position: absolute; left: 16px; top: -60px; z-index: 10; padding: 8px 16px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; font-weight: 700; }
.skip-link:focus { top: 12px; }

@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) {
  .hero-art { animation: none; }
  .card { transition: none; }
}
@media (max-width: 520px) {
  .hero { padding-top: 24px; }
  .hero-art { width: 150px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .detail { padding: 16px; }
  .detail-head .portrait { width: 130px; }
}

.callout { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.callout:hover { transform: translateY(-2px); }

/* ---------- Kit tooltip + factoid ---------- */
.kit-tip { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.kit-q {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; font-size: .75rem; font-weight: 700;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow);
}
.kit-tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translate(-50%, 4px);
  width: 190px; padding: 8px 10px;
  font-size: .85rem; font-weight: 600; line-height: 1.25;
  background: var(--yellow); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5;
}
.card:hover .kit-tip::after,
.card:focus-visible .kit-tip::after { opacity: 1; transform: translate(-50%, 0); }

.factoid {
  margin: 14px 0 4px; padding: 12px 14px;
  background: #fff3c4; border: 3px solid var(--ink); border-radius: 14px;
  font-size: .95rem;
}
.factoid-badge {
  display: inline-block; margin-right: 6px; padding: 0 8px;
  background: var(--yellow); border: 2px solid var(--ink); border-radius: 999px;
  font-weight: 700; font-size: .8rem; transform: rotate(-3deg);
}
@media (prefers-reduced-motion: reduce) { .kit-tip::after { transition: none; } }

.byline { margin: 10px 0 0; font-weight: 700; font-size: clamp(1.15rem, 3.4vw, 1.45rem); }
.byline a { color: #b3141e; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.byline a:hover { color: var(--ink); }
.copyright { margin-top: 20px; padding-top: 14px; border-top: 3px dashed #e6d9bf; text-align: center; font-size: .9rem; font-weight: 600; }

/* ---------- Legend ---------- */
.legend-wrap {
  margin: 32px 0 0; padding: 22px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
}
.legend-wrap h2 { margin: 0 0 4px; font-size: 1.6rem; }
.legend-wrap h3 { margin: 18px 0 10px; font-size: 1.2rem; }
.legend-tiers { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.legend-tiers li { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.legend-tiers .portrait { width: 100%; padding: 4px 14px 0; margin: 0; }
.legend-tiers small { color: var(--muted); font-weight: 600; }
.kit-note { margin: 14px 0 0; padding: 10px 14px; background: #f3efe6; border: 3px solid var(--ink); border-radius: 14px; }
.kit-note .tier-label { display: inline-block; margin-right: 6px; }
.legend-gear { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.legend-gear li { display: flex; gap: 10px; align-items: center; padding: 8px; border: 3px solid var(--ink); border-radius: 14px; background: var(--cream); }
.gear-art { width: 72px; flex: none; }
.gear-art svg { display: block; width: 100%; }
.legend-small { color: var(--muted); font-size: .9rem; margin: 10px 0 0; }

/* ---------- Contact ---------- */
.contact { margin-top: 24px; padding: 18px; background: #fff3c4; border: 3px solid var(--ink); border-radius: 16px; }
.contact h3 { margin-top: 0; }
.contact-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.contact-form .full { grid-column: 1 / -1; }
.contact-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.contact-form input, .contact-form textarea {
  font: inherit; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; background: var(--paper);
}
.contact-form textarea { resize: vertical; }
.contact-form .hp { position: absolute; left: -9999px; }
.contact-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.contact-actions button {
  font: inherit; font-weight: 700; font-size: 1.1rem; padding: 8px 24px; cursor: pointer;
  background: var(--red); color: var(--paper); border: 4px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
}
.contact-actions button:disabled { opacity: .6; cursor: wait; }
.contact .status { margin: 0; }
@media (max-width: 520px) { .contact-form { grid-template-columns: 1fr; } }
.tier-fire .tier-label, .tier-label.tier-fire { color: #fff; }
.q-lie { color: #b3141e; }

/* ---------- Homepage: one big call to action ---------- */
body:not(.has-results) .hero { min-height: 72vh; padding-top: 56px; padding-bottom: 56px; }
body:not(.has-results) main { padding: 0; }
.zip-form input, .zip-form button { font-size: 1.6rem; padding: 14px 30px; }
.zip-form input { width: 260px; }
@media (max-width: 520px) {
  body:not(.has-results) .hero { min-height: 0; }
  .zip-form input, .zip-form button { font-size: 1.35rem; padding: 12px 22px; }
  .zip-form input, .zip-form button { width: 100%; }
}
