:root {
  color-scheme: light;
  --paper: #f1f3ef;
  --sheet: #fbfbf7;
  --ink: #141414;
  --muted: #666b70;
  --line: #1f232826;
  --line-strong: #141414;
  --accent: #c93221;
  --blue: #2056a3;
  --green: #7da87b;
  --shadow: 0 22px 50px rgba(18, 21, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(20, 20, 20, 0.035) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(180deg, #f7f8f5 0%, var(--paper) 100%);
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--line-strong);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 78px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(20, 20, 20, 0.16));
}

.eyebrow,
.label,
.date,
.status,
.footnote {
  color: var(--muted);
}

.eyebrow,
.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.72rem;
  font-weight: 700;
}

h1 {
  margin: 2px 0 0;
  font-family: "Instrument Serif", serif;
  font-size: 4.75rem;
  line-height: 0.9;
  font-weight: 400;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  color: var(--sheet);
  background: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 4px 4px 0 var(--accent);
}

button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
  margin-top: 18px;
}

.winner-panel,
.context-panel {
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.winner-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.date {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.pick-view {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.pick-view.loading {
  min-height: 360px;
  place-items: center;
}

.winner-stage {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 250px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(201, 50, 33, 0.12), transparent 42%),
    linear-gradient(180deg, #ffffff, #f5f6f2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.winner-image-shell {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 170px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.winner-mark {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.winner-mark:not(.fallback) {
  object-fit: cover;
}

.winner-mark.fallback {
  width: 88%;
  height: 88%;
}

.winner-copy {
  min-width: 0;
}

.winner-name {
  display: block;
  margin: 4px 0 14px;
  font-family: "Instrument Serif", serif;
  font-size: 5rem;
  font-weight: 400;
  line-height: 0.9;
  color: var(--ink);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.08em;
  overflow-wrap: anywhere;
}

.winner-name:hover {
  color: var(--accent);
}

.score-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--sheet);
  background: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
}

.headline-list {
  display: grid;
  gap: 8px;
}

.headline-list > .label {
  padding-top: 4px;
}

.headline-item {
  display: grid;
  gap: 7px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.headline-item p {
  margin: 0;
  line-height: 1.35;
}

.headline-item a {
  width: fit-content;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 700;
}

.context-panel {
  display: grid;
  align-content: start;
  gap: 0;
}

.context-block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.context-block:last-child {
  border-bottom: 0;
}

.context-block strong {
  display: block;
  margin-top: 8px;
  font-family: "Instrument Serif", serif;
  font-size: 3.2rem;
  font-weight: 400;
  line-height: 0.95;
}

.context-block span {
  color: var(--muted);
  font-size: 0.9rem;
}

.shortlist {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.shortlist-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.shortlist-item:first-child {
  border-top: 0;
}

.shortlist-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortlist-item strong {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--accent);
}

.shortlist-item:hover span {
  color: var(--accent);
}

.history-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.history-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.history-trigger:hover {
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

.history-trigger:disabled {
  cursor: default;
  opacity: 1;
}

.history-count {
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: 0.72rem;
}

.history-item {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.history-item:first-child {
  border-top: 0;
}

.history-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}

.history-item:hover strong {
  color: var(--accent);
}

.history-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--sheet);
  box-shadow: 12px 12px 0 var(--accent);
}

.history-dialog::backdrop {
  background: rgba(20, 20, 20, 0.62);
  backdrop-filter: blur(3px);
}

.history-dialog-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
}

.history-dialog-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 3px solid var(--line-strong);
}

.history-dialog-header h2 {
  margin: 2px 0 0;
  font-family: "Instrument Serif", serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 400;
  line-height: 0.95;
}

.history-close {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.82rem;
  box-shadow: 3px 3px 0 var(--accent);
}

.full-history-list {
  display: grid;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.full-history-list > .status {
  padding: 24px;
}

.full-history-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.full-history-item:last-child {
  border-bottom: 0;
}

.full-history-item:hover {
  background: rgba(201, 50, 33, 0.07);
}

.history-rank {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.history-entry {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.history-entry strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Instrument Serif", serif;
  font-size: 1.55rem;
  font-weight: 400;
}

.history-entry span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-arrow {
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
}

.muted-list p,
.status {
  margin: 0;
}

.error {
  color: var(--accent);
}

.footnote {
  max-width: 720px;
  margin: 14px 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .masthead {
    align-items: flex-start;
    flex-direction: column;
  }

  .masthead button {
    align-self: flex-start;
  }

  h1 {
    font-size: 3.6rem;
  }

  .scoreboard {
    grid-template-columns: 1fr;
  }

  .context-panel {
    grid-template-columns: 1fr 1.4fr;
  }

  .context-block {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .context-block:last-child {
    border-right: 0;
  }

  .winner-stage {
    grid-template-columns: 120px minmax(0, 1fr);
    min-height: 210px;
  }

  .winner-name {
    font-size: 3.8rem;
  }
}

@media (max-width: 620px) {
  .page {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  .masthead {
    align-items: flex-end;
    flex-direction: row;
    gap: 14px;
    padding-bottom: 14px;
  }

  .masthead button {
    flex: 0 0 auto;
    align-self: flex-end;
    padding: 8px 12px;
    font-size: 0.86rem;
    box-shadow: 3px 3px 0 var(--accent);
  }

  .masthead button:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--accent);
  }

  .brand {
    align-items: center;
    flex: 1 1 auto;
    gap: 10px;
    min-width: 0;
  }

  .brand > div {
    min-width: 0;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  h1 {
    font-size: clamp(2.35rem, 10.5vw, 3rem);
    white-space: nowrap;
  }

  .panel-top,
  .winner-stage,
  .context-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .winner-stage {
    gap: 12px;
    min-height: 0;
    padding: 16px;
  }

  .winner-mark {
    width: 100%;
  }

  .winner-image-shell {
    max-width: 110px;
  }

  .winner-name {
    font-size: 3.2rem;
  }

  .context-block {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .history-dialog {
    width: calc(100% - 24px);
    max-height: min(520px, 72vh);
    max-height: min(520px, 72dvh);
    box-shadow: 6px 6px 0 var(--accent);
  }

  .history-dialog-header {
    align-items: center;
    gap: 12px;
    padding: 14px;
  }

  .history-dialog-header h2 {
    font-size: clamp(2rem, 10vw, 2.7rem);
  }

  .history-close {
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .full-history-item {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 11px 14px;
  }

  .history-entry strong {
    font-size: 1.35rem;
  }
}
