:root {
  --paper: #f4efe4; --lift: #fbf8f1; --ink: #161412; --muted: #6d6455; --rule: #cfc5b0;
  --red: #b3261e; --green: #2f6b3a; --amber: #9a6200; --shadow: rgba(60, 40, 10, .22);
  --serif: 'Fraunces', Georgia, serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f; --lift: #221f18; --ink: #ece6d8; --muted: #a39a87; --rule: #3b362b;
    --red: #e0574c; --green: #7cc47f; --amber: #e0a84a; --shadow: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.4 var(--serif); -webkit-font-smoothing: antialiased; }
main { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.masthead { text-align: center; margin-bottom: 28px; }
.masthead h1 { margin: 0 0 8px; font-size: clamp(42px, 12vw, 64px); font-style: italic; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.dateline { display: flex; justify-content: space-between; gap: 8px; margin: 0; padding: 7px 0; border-top: 3px double var(--ink); border-bottom: 1px solid var(--ink); }
.masthead h1 a { text-decoration: none; }
.dateline, .kicker, .axis, #next, footer, .badge, .more, .tools button, .ad-label, dt, .sub, .a-no, .a-score, .a-date { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.dateline { color: var(--muted); }
.tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.tools button { padding: 8px 2px; color: var(--ink); background: none; border: 0; cursor: pointer; }
.tools button:hover { color: var(--red); }

.note { margin: 0 0 20px; padding: 10px 12px; font-size: 15px; font-style: italic; background: var(--lift); border-left: 3px solid var(--red); }
.small { font-size: 15px; color: var(--muted); }
button.link { padding: 0; font: inherit; color: var(--ink); text-decoration: underline; background: none; border: 0; cursor: pointer; }

.skeleton-text { color: var(--muted); font-style: italic; font-size: .6em; }
.item.skeleton { cursor: default; }
.item.skeleton::after { content: ''; grid-column: 2 / 4; height: 14px; width: 70%; background: var(--rule); border-radius: 2px; opacity: .6; }

.kicker { margin: 0; color: var(--red); }
.theme { margin: 6px 0 8px; font-size: clamp(32px, 8.5vw, 44px); font-weight: 400; line-height: 1.04; letter-spacing: -.02em; font-variation-settings: 'opsz' 144; text-wrap: balance; }
.lede { margin: 0 0 20px; font-style: italic; color: var(--muted); }
.axis { margin: 0; padding: 6px 0; color: var(--muted); }

#list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.item {
  position: relative; display: grid; grid-template-columns: 28px 56px 1fr auto; align-items: center; gap: 12px;
  min-height: 88px; padding: 10px 0; background: var(--paper); border-bottom: 1px solid var(--rule);
  user-select: none; -webkit-user-select: none; cursor: grab;
}
.item:last-child { border-bottom: 0; }
.grip { align-self: stretch; display: grid; place-items: center; color: var(--muted); font-size: 20px; touch-action: none; cursor: grab; }
.thumb { width: 56px; height: 56px; object-fit: cover; border: 1px solid var(--rule); background: var(--rule); filter: grayscale(1) contrast(1.05); mix-blend-mode: multiply; transition: filter .6s; }
.text { margin: 0; text-wrap: pretty; }
.moves { display: flex; flex-direction: column; }
.moves button { width: 44px; height: 34px; font: 18px var(--serif); color: var(--ink); background: none; border: 0; border-radius: 4px; cursor: pointer; }
.moves button:hover:not(:disabled) { background: var(--rule); }
.moves button:disabled { opacity: .2; cursor: default; }
.year, .badge, .more { display: none; }

.sorting .item:not(.dragging) { transition: transform .18s ease; }
.dragging { z-index: 2; background: var(--lift); box-shadow: 0 14px 30px -12px var(--shadow); cursor: grabbing; }
.dragging .grip { cursor: grabbing; }

button.primary { display: block; width: 100%; padding: 16px; font: 600 13px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--paper); background: var(--ink); border: 0; cursor: pointer; transition: background .15s; }
button.primary:hover { background: var(--red); }
#play { margin-top: 24px; }
.hint { margin: 10px 0 0; text-align: center; font-size: 14px; font-style: italic; color: var(--muted); }

/* After locking in: show years, how each card was placed, and links to read more. */
.revealed .item { grid-template-columns: 56px 1fr auto; padding-left: 14px; cursor: default; }
.revealed .grip, .revealed .moves { display: none; }
.revealed .thumb { filter: none; mix-blend-mode: normal; }
.revealed .year { display: block; font-size: 26px; font-style: italic; font-weight: 600; font-variant-numeric: lining-nums; padding-right: 4px; }
.revealed .badge, .revealed .more { display: inline-block; margin-top: 4px; }
.revealed .more { margin-left: 10px; color: var(--muted); }
.item[data-off]::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; }
.item[data-off='right']::before { background: var(--green); }
.item[data-off='near']::before { background: var(--amber); }
.item[data-off='far']::before { background: var(--red); }
.item[data-off='right'] .badge { color: var(--green); }
.item[data-off='near'] .badge { color: var(--amber); }
.item[data-off='far'] .badge { color: var(--red); }

#result { margin-top: 32px; padding-top: 20px; border-top: 3px double var(--ink); text-align: center; }
#score { margin: 4px 0; font-size: 36px; font-weight: 400; letter-spacing: -.02em; }
#verdict { margin: 0 0 12px; font-style: italic; color: var(--muted); }
#grid { margin: 0 0 20px; font-size: 24px; letter-spacing: 4px; }
#next { margin: 14px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }

footer { margin-top: 48px; text-align: center; color: var(--muted); }

@media (prefers-color-scheme: dark) {
  .thumb { mix-blend-mode: normal; opacity: .85; }
}
@media (max-width: 400px) {
  body { font-size: 16px; }
  .item { grid-template-columns: 24px 48px 1fr auto; gap: 10px; }
  .thumb { width: 48px; height: 48px; }
  .revealed .item { grid-template-columns: 48px 1fr auto; }
  .revealed .year { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Buttons */
button.secondary, button.danger { display: block; width: 100%; padding: 14px; font: 600 13px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink); background: none; border: 1px solid var(--ink); cursor: pointer; }
button.secondary:hover { background: var(--lift); }
button.danger { color: var(--red); border-color: var(--red); }
button:disabled.primary { opacity: .5; cursor: default; }

/* Results extras */
#result .small { margin: 14px 0 0; }
.ad { margin-top: 28px; min-height: 120px; }
.ad-label { margin: 0 0 6px; color: var(--muted); font-size: 10px; }

/* Dialogs */
dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; color: var(--ink); background: var(--paper); border: 0; border-top: 3px double var(--ink); box-shadow: 0 30px 60px -20px var(--shadow); }
dialog::backdrop { background: rgba(22, 20, 18, .45); }
.sheet { position: relative; padding: 22px 20px 24px; }
.sheet h2 { margin: 4px 40px 12px 0; font-size: 28px; font-weight: 400; line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.close { position: absolute; top: 8px; right: 8px; margin: 0; }
.close button { width: 40px; height: 40px; font: 28px/1 var(--serif); color: var(--muted); background: none; border: 0; cursor: pointer; }
.close button:hover { color: var(--ink); }
.rules { padding-left: 20px; margin: 0 0 12px; }
.rules li { margin-bottom: 8px; }
.sheet form:last-child .primary { margin-top: 16px; }

.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 20px; text-align: center; }
.numbers dd { margin: 0 0 2px; font-size: 32px; font-variant-numeric: lining-nums tabular-nums; }
.numbers div { display: flex; flex-direction: column-reverse; }
dt { color: var(--muted); font-size: 10px; }
.sub { margin: 0 0 8px; padding-top: 12px; border-top: 1px solid var(--rule); color: var(--muted); font-weight: 400; }
.dist { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 2px; }
.dist li { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.dist .n { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
.dist .track { display: flex; align-items: center; gap: 6px; height: 22px; }
.dist .bar { height: 100%; min-width: 2px; background: var(--ink); border-radius: 0 4px 4px 0; }
.dist .mine .bar { background: var(--red); }
.dist .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.dist .mine .count, .dist .mine .n { color: var(--ink); font-weight: 600; }

.archive-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.archive-list a { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'no theme score' 'no date score'; column-gap: 12px; padding: 10px 2px; text-decoration: none; border-bottom: 1px solid var(--rule); }
.archive-list a:hover { background: var(--lift); }
.archive-list a[aria-current] { box-shadow: inset 3px 0 0 var(--red); padding-left: 10px; }
.a-no { grid-area: no; align-self: center; color: var(--muted); }
.a-theme { grid-area: theme; }
.a-date { grid-area: date; color: var(--muted); font-size: 10px; }
.a-score { grid-area: score; align-self: center; }
.muted { color: var(--muted); padding: 12px 0; }

.providers { display: grid; gap: 10px; margin: 16px 0; }
.or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-style: italic; font-size: 14px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--rule); }
#email-form { display: grid; gap: 10px; }
#email-form input { padding: 13px 12px; font: 16px var(--serif); color: var(--ink); background: var(--lift); border: 1px solid var(--rule); border-radius: 0; }
#email-form input:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: transparent; }
.fine { margin: 16px 0 0; font-size: 13px; color: var(--muted); }

/* Legal pages */
.legal h2 { margin: 28px 0 8px; font-size: 22px; font-weight: 600; }
.legal p, .legal li { color: var(--ink); }
.legal .updated { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
