[hidden] { display: none !important; }
/* Till — receipt-and-ink aesthetic. Not a Wordle green/yellow grid. */
:root {
  --paper: #f4ede0;
  --paper-deep: #efe6d4;
  --ink: #1c1410;
  --ink-soft: #3a3028;
  --muted: #6a5c4c;
  --rule: rgba(28, 20, 16, 0.18);
  --stamp: #8f1d16;
  --steel: #1e4a6e;
  --forest: #1f4d3a;
  --shadow: rgba(40, 24, 12, 0.16);
  --focus: #1e4a6e;
  --bg: #cfc3ae;
  --radius: 2px;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at top, #ddd2bf, var(--bg) 60%);
  color: var(--ink);
  font-family: "Iowan Old Style", Palatino, Palatino Linotype, "Book Antiqua", Georgia, serif;
  line-height: 1.5;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 20;
}
.skip:focus { top: 0.75rem; }

img, svg { max-width: 100%; height: auto; display: block; }

button, input, select { font: inherit; color: inherit; }

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

.wrap {
  width: min(40rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.brand-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.wordmark {
  font-weight: 700;
  font-size: clamp(1.85rem, 6.5vw, 2.75rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
  margin: 0;
}

.tbd {
  display: inline-block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--ink);
  padding: 0.15rem 0.4rem;
  border-radius: 99px;
  color: var(--ink-soft);
}

.tagline {
  margin: 0.15rem 0 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.125rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 1rem 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
}

.meta strong { color: var(--ink); font-weight: 650; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.linkish, .header-actions button {
  background: none;
  border: 0;
  padding: 0.4rem 0.1rem;
  color: var(--steel);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
  min-height: 44px;
}

.receipt {
  background: var(--paper);
  color: var(--ink);
  padding: 1.5rem 1.25rem 2rem;
  box-shadow: 0 18px 40px var(--shadow);
  position: relative;
  /* Serrated bottom edge */
  clip-path: polygon(
    0 0, 100% 0, 100% calc(100% - 12px),
    97% 100%, 94% calc(100% - 12px), 91% 100%, 88% calc(100% - 12px),
    85% 100%, 82% calc(100% - 12px), 79% 100%, 76% calc(100% - 12px),
    73% 100%, 70% calc(100% - 12px), 67% 100%, 64% calc(100% - 12px),
    61% 100%, 58% calc(100% - 12px), 55% 100%, 52% calc(100% - 12px),
    49% 100%, 46% calc(100% - 12px), 43% 100%, 40% calc(100% - 12px),
    37% 100%, 34% calc(100% - 12px), 31% 100%, 28% calc(100% - 12px),
    25% 100%, 22% calc(100% - 12px), 19% 100%, 16% calc(100% - 12px),
    13% 100%, 10% calc(100% - 12px), 7% 100%, 4% calc(100% - 12px),
    0 100%
  );
}

.receipt h2 {
  font-size: 0.82rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 650;
  margin: 0 0 1rem;
  color: var(--muted);
}

.basket {
  list-style: none;
  margin: 0;
  padding: 0;
}

.basket li {
  display: grid;
  grid-template-columns: 2.75rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px dashed var(--rule);
}

.basket li:first-child { border-top: 0; }

.basket .icon {
  width: 2.75rem;
  height: 2.75rem;
  color: var(--ink);
}
.basket .icon svg { width: 100%; height: 100%; }

.basket .name {
  font-size: 1.05rem;
  margin: 0;
}
.basket .qty {
  display: block;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}
.basket .peek-price {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--forest);
  text-align: right;
}

.peel-btn {
  grid-column: 1 / -1;
}

.guess-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  margin: 1.25rem 0 0.75rem;
  align-items: end;
}

.guess-form label {
  grid-column: 1 / -1;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
}

.guess-form input {
  width: 100%;
  background: #fffdf7;
  border: 2px solid var(--ink);
  padding: 0.7rem 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.25rem;
  min-height: 48px;
  border-radius: var(--radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.65rem 1.1rem;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: var(--radius);
}
.btn:hover { background: #2a221c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--ink);
}
.btn.secondary:hover { background: var(--paper-deep); }
.btn.stamp {
  background: var(--stamp);
  border-color: var(--stamp);
}
.btn.stamp:hover { background: #6f1611; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.feedback {
  min-height: 1.5rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.range {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px dashed var(--rule);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem;
}
.range-bar {
  position: relative;
  height: 10px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 99px;
  margin: 0.5rem 0;
  overflow: hidden;
}
.range-bar .fill {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--steel);
  opacity: 0.35;
}
.range-caption { color: var(--muted); font-size: 0.85rem; }

.tape {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}
.tape li {
  display: grid;
  grid-template-columns: 2rem 1.6rem 1fr;
  gap: 0.5rem;
  padding: 0.35rem 0;
  align-items: center;
  border-top: 1px dotted var(--rule);
}
.mark-low { color: var(--steel); font-weight: 700; }
.mark-high { color: var(--stamp); font-weight: 700; }
.mark-exact { color: var(--stamp); font-weight: 700; }

.result-banner {
  margin: 1rem 0 0;
  padding: 1rem;
  border: 2px solid var(--stamp);
  text-align: center;
}
.result-banner h2 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
  font-family: inherit;
}
.result-banner p { margin: 0; color: var(--ink-soft); }

.reveal {
  margin-top: 1.25rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
}
.reveal table {
  width: 100%;
  border-collapse: collapse;
}
.reveal th, .reveal td {
  text-align: left;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.reveal th { font-weight: 600; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.reveal td.num, .reveal th.num { text-align: right; font-variant-numeric: tabular-nums; }
.reveal .total-row { font-weight: 700; }
.note {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.75rem 0 0;
}

.status {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9rem;
  min-height: 1.4em;
  margin: 0.5rem 0 0;
}

footer {
  margin: 2rem auto 0;
  width: min(40rem, calc(100% - 1.5rem));
  padding: 0 0 2.5rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}
footer a { color: var(--steel); }
footer p { margin: 0.4rem 0; }

dialog {
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  width: min(32rem, calc(100% - 2rem));
  padding: 1.4rem 1.3rem 1.2rem;
  box-shadow: 0 20px 50px var(--shadow);
}
dialog::backdrop { background: rgba(28, 20, 16, 0.5); }
dialog h2 { margin: 0 0 0.75rem; font-size: 1.5rem; }
dialog p, dialog li { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.95rem; }
dialog ol { padding-left: 1.2rem; }
dialog menu { margin: 1rem 0 0; padding: 0; display: flex; justify-content: flex-end; }

.archive {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin-top: 0.75rem;
}
.archive label {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  display: grid;
  gap: 0.25rem;
}
.archive input {
  border: 2px solid var(--ink);
  background: #fffdf7;
  padding: 0.45rem 0.5rem;
  min-height: 44px;
}

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

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1612;
    --focus: #8cb4d4;
    color-scheme: dark;
  }
  body {
    background: #1a1612;
    color: #f4ede0;
  }
  .wordmark, .tagline, .meta strong { color: #f4ede0; }
  .tagline, .meta, .tbd { color: #d4c4a8; }
  .tbd { border-color: #d4c4a8; }
  .linkish, .header-actions button { color: #9ec0db; }
  footer { color: #cbbba3; }
  footer a { color: #9ec0db; }
  /* The receipt stays paper-colored so the product itself is unchanged. */
}

@media print {
  body { background: white; }
  .header-actions, .guess-form, .actions, .skip, dialog { display: none !important; }
  .receipt { box-shadow: none; clip-path: none; }
}


/* First-run onboarding: short, not a wall of text. */
dialog.onboard {
  width: min(24rem, calc(100% - 2rem));
  padding: 1.35rem 1.25rem 1.15rem;
  border: 2px solid var(--ink);
  background: var(--paper, #f7f1e4);
  color: var(--ink);
}
dialog.onboard::backdrop { background: rgba(28, 20, 16, 0.45); }
dialog.onboard h2 {
  margin: 0 0 0.75rem;
  font-size: 1.45rem;
  line-height: 1.2;
}
.onboard-steps {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
  font-size: 1.02rem;
}
.onboard-steps li { margin: 0 0 0.45rem; }
dialog.onboard menu { margin: 0.85rem 0 0; padding: 0; display: flex; justify-content: flex-end; }

/* Post-solve year-earlier reveal */
.yoy {
  background: #efe4cc;
  border: 1px solid rgba(28, 20, 16, 0.12);
  padding: 0.9rem 1rem 0.75rem;
  margin: 0 0 1.1rem;
}
.yoy h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.yoy-headline { margin: 0 0 0.6rem; font-size: 1.05rem; }
.yoy .note { margin: 0.45rem 0 0; }
.missing { font-size: 0.9rem; color: var(--muted, #6a5c4c); }
.inflation-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.92rem;
}
.inflation-toggle input { margin-top: 0.2rem; flex: 0 0 auto; }

.reveal table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.reveal th, .reveal td { padding: 0.4rem 0.35rem; border-bottom: 1px solid rgba(28,20,16,0.1); vertical-align: top; }
.reveal .num { text-align: right; font-variant-numeric: tabular-nums; }
