@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/inter-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02ba, U+02bd-02c5, U+02c7-02cc, U+02ce-02d7, U+02dd-02ff, U+0304,
    U+0308, U+0329, U+1d00-1dbf, U+1e00-1e9f, U+1ef2-1eff, U+2020, U+20a0-20ab,
    U+20ad-20c4, U+2113, U+2c60-2c7f, U+a720-a7ff;
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/inter-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00ff, U+0131, U+0152-0153, U+02bb-02bc, U+02c6, U+02da, U+02dc,
    U+0304, U+0308, U+0329, U+2000-206f, U+20ac, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+feff, U+fffd;
}

@font-face {
  font-family: "Zilla Slab";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/zilla-slab-medium.woff2") format("woff2");
}

@font-face {
  font-family: "Zilla Slab";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/zilla-slab-bold.woff2") format("woff2");
}

:root {
  --paper: #f7f2e7;
  --ink: #1f1b14;
  --muted: #5c5444;
  --rule: #e3d9c6;
  --rule-strong: #cdbfa6;
  --score-at: #736856;
  --card: #fbf8f1;
  --winner: #2459c4;
  --loser: #b4482b;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}

html:has(.game-dialog[open]) {
  overflow: hidden;
}

.visually-hidden,
.chart-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.slate {
  box-sizing: border-box;
  container: slate / inline-size;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

.masthead {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-bottom: 8px;
  border-bottom: 3px double var(--ink);
}

.masthead h1,
.game-score {
  margin: 0;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 700;
  line-height: 1.1;
}

.masthead h1 {
  font-size: 22px;
}

.masthead a {
  color: inherit;
  text-decoration: none;
}

.masthead .account-link {
  justify-self: start;
  text-decoration: underline;
}

.masthead .archive-link {
  text-decoration: underline;
}

.month-nav,
.day-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.month-nav a,
.day-nav a {
  display: inline-block;
  line-height: 44px;
  color: var(--muted);
  text-underline-offset: 2px;
}

.month-nav {
  max-width: 28rem;
  margin-top: 8px;
}

.calendar {
  width: 100%;
  max-width: 28rem;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.calendar caption {
  padding-bottom: 4px;
  font:
    700 20px/1.2 "Zilla Slab",
    Georgia,
    serif;
  text-align: left;
}

.calendar th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.calendar td {
  height: 40px;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

.calendar a {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 40px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.slate-date,
.game-date {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.card {
  min-width: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--card);
}

.card-trigger,
.card-score {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px 8px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.card-trigger:hover {
  background: var(--paper);
}

.free-game {
  grid-column: 1 / -1;
}

.free-game-label {
  display: block;
  margin: 10px 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.slate-teaser {
  display: grid;
  align-items: start;
  margin: 16px 0 0;
  overflow: hidden;
}

.slate-teaser > * {
  grid-area: 1 / 1;
}

.slate-teaser .teaser-games {
  margin: 0;
  filter: blur(4px);
  opacity: 0.55;
}

.signup-panel {
  position: relative;
  box-sizing: border-box;
  width: min(26rem, calc(100% - 24px));
  margin: 12px auto;
  padding: 16px 20px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--card);
  text-align: center;
}

.signup-panel h2 {
  margin: 0;
  font:
    700 26px/1.1 "Zilla Slab",
    Georgia,
    serif;
}

.signup-panel p {
  margin: 6px 0 12px;
}

.signup-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
}

.signup-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 12px;
  color: var(--ink);
  text-underline-offset: 2px;
}

.signup-actions .subscribe-link {
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  text-decoration: none;
}

.card-team {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.card-team {
  min-height: 30px;
  font-size: 20px;
  font-weight: 700;
}

.card-team small {
  margin-inline-start: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.card-team strong {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.team-icon {
  display: inline-block;
  flex: none;
  inline-size: 24px;
  block-size: 24px;
  vertical-align: middle;
}

.card-name,
.score-team {
  display: inline-flex;
  align-items: center;
}

.card-name {
  min-width: 0;
  gap: 8px;
}

[data-chart="box-score"] .team-icon {
  inline-size: 20px;
  block-size: 20px;
  margin-inline-end: 6px;
}

.card-winner {
  color: var(--winner);
  font-weight: 800;
}

.card-loser {
  color: var(--loser);
}

.card-status {
  margin-inline: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12px;
}

.game-back,
.game-share {
  color: var(--muted);
  text-underline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
.chart-picker input:focus-visible + label {
  outline: 2px solid var(--winner);
  outline-offset: 2px;
}

.game-dialog {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  color: var(--ink);
}

/* Keep the responsive game bar at the same width when charts change height. */
html:has(main > .game-view),
.game-dialog {
  overflow-y: scroll;
}

.game-dialog::backdrop {
  background: var(--paper);
}

.game-view,
.locked {
  container: game / inline-size;
}

.game-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  max-width: 1760px;
  margin-inline: auto;
  padding: 12px 24px 10px;
  border-bottom: 3px double var(--ink);
  background: var(--paper);
}

.game-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-score {
  font-size: 36px;
  line-height: 1.05;
}

.game-score .team-icon {
  inline-size: 40px;
  block-size: 40px;
}

.score-team {
  gap: 14px;
  vertical-align: middle;
}

.game-score .card-winner {
  font-weight: 700;
}

.score-at {
  padding-inline: 0.14em;
  color: var(--score-at);
  font-weight: 500;
}

.score-abbr,
.chart-picker,
.turn-phone {
  display: none;
}

.game-bar > :is(form, .game-back) {
  margin-inline-start: auto;
}

.game-back {
  display: inline-flex;
  flex: none;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: underline;
}

button.game-back {
  cursor: pointer;
}

.game-charts {
  box-sizing: border-box;
  display: grid;
  align-items: start;
  gap: 22px;
  max-width: 868px;
  margin: 0 auto;
  padding: 18px 12px 24px;
}

.chart,
[data-chart="box-score"] > .team {
  min-width: 0;
}

.chart [data-chart="box-score"] {
  padding-inline: min(6px, 1vw);
}

[data-chart="box-score"] .table-wrap {
  container-type: inline-size;
  overflow: visible;
}

[data-chart="box-score"] table {
  min-width: 0;
  table-layout: auto;
}

[data-chart="box-score"] colgroup {
  display: none;
}

[data-chart="box-score"] :is(th, td) {
  padding-inline: min(1px, 0.22cqi);
  font-size: min(1em, 2.2cqi);
  white-space: normal;
  overflow-wrap: anywhere;
}

[data-chart="box-score"] th:first-child {
  max-width: 18cqi;
}

[data-chart="box-score"] :is(thead th, .bench tr:first-child th) {
  font-size: min(10px, 2cqi);
}

[data-chart="box-score"] :is(caption, details) {
  overflow-wrap: anywhere;
}

[data-chart="box-score"] details li {
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 4px;
}

.chart-title {
  margin: 0 12px 4px;
  padding-top: 6px;
  border-top: 2px solid var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chart > p,
.locked > p {
  margin: 12px;
  color: var(--muted);
  font-size: 13px;
}

.chart-about {
  margin: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.chart-about summary {
  min-height: 24px;
  padding-block: 6px;
  font-weight: 600;
  cursor: pointer;
}

.chart-about ul {
  margin: 0;
  padding-inline-start: 18px;
}

.chart-about li + li {
  margin-top: 4px;
}

.game-share {
  display: block;
  width: fit-content;
  margin-inline: auto;
  padding-block: 8px 0;
  font-size: 13px;
}

/* Below the pinned bar, so it scrolls away with the charts instead of crowding the bar. */
.day-nav {
  box-sizing: border-box;
  max-width: 868px;
  margin: 0 auto;
  padding-inline: 12px;
}

/* The slate has 32px of horizontal padding at either orientation. */
@container slate (min-width: 770px) {
  .game-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container slate (min-width: 868px) {
  .masthead {
    display: grid;
    gap: 5px;
    padding-bottom: 12px;
  }

  .slate-date {
    grid-row: 1;
  }

  .masthead h1 {
    font-size: 40px;
    text-align: center;
  }

  .game-list {
    gap: 14px;
  }
}

@media (min-width: 1440px) {
  .game-charts {
    max-width: 1760px;
    padding-inline: 24px;
    grid-template-columns: repeat(2, minmax(0, 844px));
    grid-template-areas: "factors ranks" "atlas ranks" "box box";
    justify-content: center;
    column-gap: 24px;
    row-gap: 18px;
  }

  .chart[data-panel="win-factors"] {
    grid-area: factors;
  }

  .chart[data-panel="game-ranks"] {
    grid-area: ranks;
  }

  .chart[data-panel="shift-atlas"] {
    grid-area: atlas;
  }

  .chart[data-panel="box-score"] {
    grid-area: box;
  }

  .chart [data-chart="box-score"] {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: start;
  }

  .chart [data-chart="box-score"] > .team + .team {
    margin-top: 0;
  }
}

@container game (max-width: 1023px) {
  .game-bar {
    height: 44px;
    gap: 6px;
    padding: 0 4px 0 12px;
    border-bottom: 0;
  }

  .game-bar::after {
    content: "";
    position: absolute;
    inset: 100% 0 auto;
    border-top: 3px double var(--ink);
    pointer-events: none;
  }

  .game-heading {
    flex-direction: row;
    align-items: baseline;
    white-space: nowrap;
    gap: 8px;
  }

  .game-score {
    font-size: 20px;
  }

  .game-score .team-icon {
    inline-size: 24px;
    block-size: 24px;
  }

  .score-team {
    gap: 8px;
  }

  .score-abbr {
    display: inline;
  }

  .score-name:has(+ .score-abbr) {
    display: none;
  }

  .game-date {
    font-size: 11px;
  }

  .game-charts {
    padding: 4px 0 18px;
  }

  @supports selector(:has(*)) {
    .chart-picker {
      display: flex;
      align-self: stretch;
      align-items: stretch;
      margin: 0 0 0 auto;
      padding: 0;
      border: 0;
      min-width: 0;
    }

    .chart-picker label {
      display: flex;
      align-items: center;
      padding: 0 9px;
      color: var(--muted);
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
      cursor: pointer;
    }

    .chart-picker input:checked + label {
      color: var(--ink);
      box-shadow: inset 0 -3px var(--ink);
    }

    .game-view .game-bar > :is(form, .game-back) {
      margin-inline-start: 0;
    }

    .chart {
      display: none;
    }

    .chart-title {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: 0;
      padding: 0;
      overflow: hidden;
      clip-path: inset(50%);
      border: 0;
      white-space: nowrap;
    }

    .game-view:has([data-choice="win-factors"]:checked)
      [data-panel="win-factors"],
    .game-view:has([data-choice="game-ranks"]:checked)
      [data-panel="game-ranks"],
    .game-view:has([data-choice="shift-atlas"]:checked)
      [data-panel="shift-atlas"],
    .game-view:has([data-choice="box-score"]:checked) [data-panel="box-score"] {
      display: block;
    }
  }
}

@container game (max-width: 780px) {
  .game-heading {
    flex-direction: column;
    gap: 2px;
  }

  .chart-picker label {
    padding-inline: 5px;
  }
}

@container game (max-width: 620px) {
  .game-back {
    inline-size: 72px;
    padding-inline: 4px;
    text-align: center;
    white-space: normal;
  }

  .chart-picker label {
    padding-inline: 4px;
  }
}

@container game (max-width: 600px) {
  .game-heading .game-date {
    display: none;
  }
}

@container slate (max-width: 568px) {
  .game-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (orientation: landscape) and (max-height: 360px),
  (orientation: portrait) and (pointer: coarse) and (max-width: 360px) {
  .slate-teaser {
    margin-block-start: 8px;
  }

  .signup-panel {
    margin-block: 4px;
    padding-block: 8px;
  }

  .signup-panel h2 {
    font-size: 22px;
  }

  .signup-panel p {
    margin-block: 4px;
  }
}

@container game (max-width: 567px) {
  .chart[data-panel="win-factors"] {
    overflow-x: auto;
  }

  .game-view .game-bar {
    flex-wrap: wrap;
    height: auto;
    padding-inline: 2%;
  }

  .game-heading {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .game-view .chart-picker {
    order: 1;
    flex-basis: 100%;
  }

  .game-view .game-bar > :is(form, .game-back) {
    margin-inline-start: auto;
  }

  .chart-picker label {
    flex: 1;
    min-width: 0;
    min-height: 36px;
    justify-content: center;
    padding-inline: 2%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (hover: none) {
  [data-chart="win-factors"] .fname.hint {
    text-decoration: none;
    cursor: auto;
  }
}

@supports (height: 100svh) {
  @media (max-width: 1023px) and (orientation: landscape) and (pointer: coarse),
    (orientation: portrait) and (pointer: coarse) {
    .game-dialog,
    .game-view {
      height: 100svh;
    }

    .game-dialog {
      overflow: hidden;
    }

    html:has(main > .game-view),
    body:has(main > .game-view) {
      overflow: hidden;
      overscroll-behavior: none;
    }

    .game-view {
      display: grid;
      grid-template-rows: auto minmax(0, 1fr);
    }

    .game-view .game-bar {
      margin-inline: 0;
    }

    .game-content {
      /* The final row can scroll clear of the browser's bottom controls. */
      --game-end-space: 56px;
      overflow: auto;
      overscroll-behavior-y: contain;
      padding-block-end: var(--game-end-space);
      scroll-padding-block-end: var(--game-end-space);
    }

    .game-content :is(.chart-about, [data-chart="box-score"] details) {
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
    }

    .game-content [data-chart="box-score"] details {
      font-size: inherit;
    }

    .game-content
      :is(.chart-about, [data-chart="box-score"] details)
      > summary {
      align-content: center;
      box-sizing: border-box;
      min-height: 44px;
    }

    .game-content .game-share {
      display: flex;
      align-items: center;
      min-height: 44px;
      padding-block: 0;
    }
  }
}

@media (pointer: coarse) {
  :is(body > main:not(.account-page), .game-dialog > .game-view) {
    transform-origin: 50% 50svh;
    clip-path: inset(0 round 0);
    transition:
      rotate 650ms cubic-bezier(0.22, 0.8, 0.2, 1),
      scale 650ms cubic-bezier(0.22, 0.8, 0.2, 1),
      clip-path 200ms linear 650ms;
  }
}

@media (orientation: portrait) and (pointer: coarse) {
  :root {
    --turn-width: min(100lvh, 1100px);
    --turn-scale: 0.62;
    --turn-bezel: 9px;
    --turn-shift: -6px;
  }

  html:has(body > .turn-phone),
  body:has(> .turn-phone) {
    height: 100%;
    overflow: hidden;
  }

  :is(body > main:not(.account-page), .game-dialog > .game-view) {
    position: fixed;
    inset: 0 auto auto 0;
    width: var(--turn-width);
    min-height: 100vw;
    margin: 0;
    background: var(--paper);
    pointer-events: none;
    transform-origin: 50% 50vw;
    translate: calc(50vw - var(--turn-width) / 2)
      calc(50svh - 50vw + var(--turn-shift));
    rotate: 90deg;
    scale: var(--turn-scale);
    /* Crop the miniature to the first landscape screen. */
    clip-path: inset(0 0 calc(100% - 100vw) 0 round 6px);
    transition-delay: 0s;
    transition-duration: 650ms, 650ms, 0s;
  }

  .game-view {
    height: 100vw;
  }

  :is(body:has(> .turn-phone), .game-dialog[open])::before {
    content: "";
    position: fixed;
    z-index: -1;
    left: 50%;
    top: calc(50svh + var(--turn-shift));
    width: calc(100vw * var(--turn-scale) + 2 * var(--turn-bezel));
    height: calc(var(--turn-width) * var(--turn-scale) + 2 * var(--turn-bezel));
    translate: -50% -50%;
    border-radius: 24px;
    background: var(--ink);
    box-shadow: 0 16px 36px rgb(31 27 20 / 0.22);
  }

  .turn-phone {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    place-content: stretch;
    justify-items: center;
    gap: 0;
    padding: max(14px, env(safe-area-inset-top, 0px)) 24px
      max(20px, env(safe-area-inset-bottom, 0px));
    text-align: center;
    pointer-events: none;
  }

  .turn-phone strong {
    font:
      700 22px "Zilla Slab",
      Georgia,
      serif;
  }

  .turn-phone p {
    grid-row: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    max-width: 19em;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
  }

  .turn-phone p::before {
    content: "";
    flex: none;
    width: 26px;
    height: 26px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%235c5444' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='6' width='13' height='22' rx='3'/%3E%3Cpath d='M21 4.5a10 10 0 0 1 7 9'/%3E%3Cpath d='M24.5 13.2l3.5.3.9-3.4'/%3E%3C/svg%3E")
      center / contain no-repeat;
  }
}

@media (pointer: coarse) and (prefers-reduced-motion: reduce) {
  :is(body > main:not(.account-page), .game-dialog > .game-view) {
    transition: none;
  }
}
