/* The greens come from the sheet: #356854 is its table headings, #93c47d its finished games. */

@font-face { font-family: Barlow; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Barlow; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --bg: #f2f5f2;
  --surface: #ffffff;
  --ink: #17211c;
  --soft: #56665d;
  --line: #d9e1db;
  --accent: #356854;
  --on-accent: #ffffff;
  --accent-soft: #e0ede6;
  --done-ink: #2f5a1b;
  --done-soft: #e6f2df;
  --warn-ink: #6b4a00;
  --warn-bg: #fff3d6;
  --danger: #b0392d;
  --bar: #356854;
  --bar-rest: #8ab5a0;
  --track: #dfe8e2;
  --shadow: 0 12px 40px rgb(15 35 25 / 0.2);

  --text: Barlow, system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1512;
    --surface: #161e1a;
    --ink: #e8f0eb;
    --soft: #9daea4;
    --line: #2b3731;
    --accent: #7cc4a2;
    --on-accent: #0c1511;
    --accent-soft: #1f3329;
    --done-ink: #bfe3ad;
    --done-soft: #22331b;
    --warn-ink: #f3d48b;
    --warn-bg: #33290f;
    --danger: #f0897c;
    --bar: #93c47d;
    --bar-rest: #47654a;
    --track: #29342e;
    --shadow: 0 12px 40px rgb(0 0 0 / 0.6);
  }
}

/* ---------------------------------------------------------------- Basics */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 400 1rem/1.45 var(--text);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1 { font: 600 2.5rem/1 var(--display); }
h2 { font: 600 1.5rem/1.1 var(--display); }
h3 { font: 600 1rem/1.3 var(--text); }
b, strong { font-weight: 600; }
small { font-size: 0.8125rem; }
a { color: var(--accent); }

.soft { color: var(--soft); }
.hint { color: var(--soft); font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

button, input, select { font: inherit; color: inherit; }
button, select, .chip { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-weight: 500;
}
button.primary { border-color: transparent; background: var(--accent); color: var(--on-accent); }
button.plain { border-color: transparent; background: none; color: var(--accent); }
button.danger { border-color: transparent; background: none; color: var(--danger); }
button.small { min-height: 36px; padding: 5px 12px; font-size: 0.9375rem; }
button.link { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; }
.icon-button {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; min-height: 0; padding: 0;
  border: 0; border-radius: 8px; background: none; color: inherit;
}
@media (hover: hover) {
  button:not(:disabled, .primary, .link):hover, .icon-button:hover { background: var(--accent-soft); }
  button.primary:not(:disabled):hover { filter: brightness(1.1); }
}

/* 16px text stops iPhones from zooming in when you tap a box. */
input:not([type="checkbox"]), select {
  width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-size: 1rem;
}
input::placeholder { color: var(--soft); opacity: 1; }
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { appearance: none; }
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--accent); }

.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 0.9375rem; font-weight: 500; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding: 3px var(--gutter); scrollbar-width: none; }
.chip { flex: none; gap: 6px; min-height: 38px; padding: 5px 12px; border-radius: 99px; font-size: 0.9375rem; }
.chip small { color: var(--soft); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip[aria-pressed="true"] small { color: inherit; }

.note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); }
.note > p { flex: 1 1 18rem; }
.note-actions { display: flex; gap: 6px; }
.note a { color: inherit; font-weight: 500; }
.note button { border-color: currentColor; background: none; color: inherit; }
.note button.plain { border-color: transparent; }
.tidy summary { padding-block: 6px; color: var(--soft); font-weight: 500; cursor: pointer; }
.tidy .note { margin-top: 8px; }
.empty { padding: 32px 0; color: var(--soft); text-align: center; }
.more { padding: 16px; text-align: center; }

/* ---------------------------------------------------------------- Covers */

.cover { display: block; width: 45px; height: 60px; flex: none; border-radius: 4px; object-fit: cover; background: var(--track); }
.cover-large { width: 108px; height: 144px; border-radius: 6px; }
.cover-blank { display: grid; place-items: center; color: var(--soft); font: 600 1.125rem/1 var(--display); }
.cover-large.cover-blank { font-size: 2.25rem; }

/* ---------------------------------------------------------------- Top bar and tabs */

.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(6px + env(safe-area-inset-top)) var(--gutter) 6px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 600 1.375rem/1 var(--display); text-decoration: none; }
.brand img { border-radius: 6px; }
.tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.tools a { color: inherit; }
.status { min-height: 40px; border-color: transparent; background: none; color: var(--soft); font-size: 0.875rem; font-weight: 400; }
.status:disabled { opacity: 1; }
.status.busy .icon { animation: turn 1.1s linear infinite; }
.status.problem { color: var(--danger); }
@keyframes turn { to { transform: rotate(360deg); } }

.tabs {
  position: fixed; inset: auto 0 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top: 1px solid var(--line); background: var(--surface);
}
.tabs a {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 58px; color: var(--soft);
  font-size: 0.8125rem; font-weight: 500; text-decoration: none;
}
.tabs a:focus-visible { outline-offset: -3px; }
.tabs a[aria-current], .tabs .add { color: var(--accent); }
.tabs a[aria-current] { box-shadow: inset 0 2px var(--accent); }

.page {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
  max-width: 1180px; margin: 0 auto;
  padding: 8px var(--gutter) calc(96px + env(safe-area-inset-bottom));
}
.page h2 { margin-top: 12px; }
.title, .year-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
.year-title h1 { font-size: 3.5rem; line-height: 0.9; font-variant-numeric: tabular-nums; }
.years { display: flex; gap: 2px; }
.years a { padding: 9px 10px; border-radius: 8px; color: var(--soft); font-weight: 500; text-decoration: none; }
.years a[aria-current] { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- Progress and counts */

.meter { height: 8px; overflow: hidden; border-radius: 99px; background: var(--track); }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--bar); }

.summary { display: grid; gap: 14px; }
.summary .meter { height: 12px; }
.figures { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; }
.figures p { color: var(--soft); }
.figures b { display: block; color: var(--ink); font: 600 1.875rem/1.1 var(--display); }
.figures small { color: var(--soft); font-size: 1.25rem; }

.mix { border-block: 1px solid var(--line); }
.mix summary { padding: 12px 0; font-weight: 500; cursor: pointer; }
.legend { display: flex; align-items: center; gap: 6px; padding-bottom: 12px; color: var(--soft); font-size: 0.875rem; }
.legend .key { width: 12px; height: 12px; border-radius: 3px; }
.legend .key.planned { margin-left: 10px; }
.finished.key, .mix-bar .finished { background: var(--bar); }
.planned.key, .mix-bar .planned { background: var(--bar-rest); }
.mix-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px 36px; padding-bottom: 18px; }
.mix table { width: 100%; margin-top: 4px; border-collapse: collapse; }
.mix th { width: 7.5rem; padding: 0 8px 0 0; font-weight: 400; text-align: left; }
.mix-bar { display: flex; align-items: center; gap: 2px; height: 1.75rem; padding: 0; }
.mix-bar span { height: 12px; }
.mix-bar span:last-child { border-radius: 0 4px 4px 0; }
.mix-count { width: 2rem; padding: 0; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.mix .soft { margin-top: 6px; font-size: 0.875rem; }

.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px;
  padding: 10px 12px; text-align: left;
}
.level-number { font: 600 2rem/1 var(--display); }
.level-name { font-size: 0.9375rem; line-height: 1.2; }
.level-count { grid-column: 1 / -1; color: var(--soft); font-size: 0.875rem; font-weight: 400; }
.level .meter { grid-column: 1 / -1; width: 100%; height: 6px; }
.level[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- Lists of games */

.toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.toolbar select { padding-inline: 8px 4px; text-overflow: ellipsis; }
.toolbar select.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.search { position: relative; display: block; grid-column: 1 / -1; }
.search .icon { position: absolute; top: 12px; left: 12px; color: var(--soft); pointer-events: none; }
.search input { padding-left: 40px; }

.game-list { --rank-column: 1.5rem; }
.game-list.unranked { --rank-column: ; }
.unranked .rank, .unranked .list-head > :first-child { display: none; }
.game-list ol { border-top: 1px solid var(--line); }
.game-list li { content-visibility: auto; contain-intrinsic-size: auto 85px; border-bottom: 1px solid var(--line); }
.game {
  display: grid; grid-template-columns: var(--rank-column) 45px [name] minmax(0, 1fr) [score] auto; align-content: center; gap: 1px 10px;
  min-height: 84px; padding: 11px 0; color: inherit; text-decoration: none;
}
.game:focus-visible { outline-offset: -2px; }
.list-head { display: none; }
.game .rank { grid-row: 1 / 4; align-self: center; color: var(--soft); font: 600 1.125rem/1 var(--display); font-variant-numeric: tabular-nums; text-align: center; }
.game.finished .rank { color: var(--done-ink); }
.game .cover { grid-row: 1 / 4; align-self: center; }
.game-name { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; grid-column: name; line-height: 1.25; }
.game .score { grid-area: 1 / score; align-self: end; font: 600 1.5rem/1 var(--display); font-variant-numeric: tabular-nums; text-align: right; }
.excitement, .facts { color: var(--soft); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.excitement { grid-area: 2 / score; text-align: right; }
.facts { grid-column: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts:not(:has(span:not(:empty))) { display: none; }
.badge { padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
.badge.done { background: var(--done-soft); color: var(--done-ink); }

/* ---------------------------------------------------------------- Panels */

.panel {
  /* Starts near the top, so a phone's keyboard doesn't cover the box you're typing in. */
  position: fixed; inset: calc(14px + env(safe-area-inset-top)) 0 0; display: flex; flex-direction: column;
  width: 100%; max-width: none; height: auto; max-height: none; margin: 0; padding: 0;
  border: 0; border-radius: 16px 16px 0 0;
  background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
  animation: rise 0.2s ease-out;
}
.panel::backdrop { background: rgb(5 15 10 / 0.5); }
@keyframes rise { from { translate: 0 32px; opacity: 0; } }
.panel-body {
  display: grid; align-content: start; gap: 20px; grid-template-columns: minmax(0, 1fr);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px var(--gutter) calc(28px + env(safe-area-inset-bottom));
}
/* Leave room to scroll everything out from under a message. */
.panel:has(.toast) .panel-body { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.panel section, .panel form, .finish { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.panel h3 { margin-top: 4px; }
.panel-head { display: flex; align-items: flex-start; gap: 16px; }
.panel-head > div { flex: 1; display: grid; gap: 6px; min-width: 0; }
.panel-head h2 { flex: 1; font-size: 1.75rem; overflow-wrap: anywhere; }
.panel-head .close { margin: -8px -8px 0 0; }
.big-score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.big-score b { font: 600 2.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.new-game-head { display: flex; gap: 16px; }
.new-game-head > div { flex: 1; display: grid; align-content: start; gap: 8px; min-width: 0; }
.finish { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }

.rating { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.rating button { min-width: 0; padding: 0; border-radius: 6px; font-variant-numeric: tabular-nums; }
.rating .filled { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.rating [aria-pressed="true"] { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.found { display: grid; gap: 6px; }

.links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.links a { display: inline-flex; align-items: center; gap: 5px; min-height: 40px; font-weight: 500; }
.links .icon { width: 1rem; height: 1rem; }
.match { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.panel footer { border-top: 1px solid var(--line); padding-top: 12px; }
.panel footer button { margin-left: -14px; }

.search.big input { min-height: 52px; font-size: 1.125rem; }
.search.big .icon { top: 16px; }
.results { display: grid; gap: 2px; grid-template-columns: minmax(0, 1fr); margin-inline: -8px; }
.results > .soft:empty { display: none; }
.results > .soft { padding-inline: 8px; }
.result {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  width: 100%; padding: 8px; border: 0; border-radius: 8px;
  background: none; color: inherit; font-weight: 400; text-align: left; text-decoration: none;
}
.result > span:last-child { display: grid; min-width: 0; }
.result small { color: var(--soft); }
@media (hover: hover) { .result:hover { background: var(--accent-soft); } }

/* ---------------------------------------------------------------- Messages */

.toasts { position: fixed; inset: auto 0 calc(70px + env(safe-area-inset-bottom)); z-index: 10; display: grid; justify-items: center; padding: 0 12px; pointer-events: none; }
.panel .toasts { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); }
.toast {
  display: flex; align-items: center; gap: 4px;
  max-width: 520px; padding: 4px 4px 4px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow); pointer-events: auto;
}
.toast span { flex: 1; padding-block: 8px; }
.toast button { border: 0; background: none; color: inherit; font-weight: 600; }
.toast button:not(.icon-button) { text-decoration: underline; text-underline-offset: 3px; }
.toast button:hover { background: rgb(128 128 128 / 0.3) !important; }
.toast.error { background: var(--danger); color: var(--surface); }

/* ---------------------------------------------------------------- Settings and connecting */

.card { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); grid-template-columns: minmax(0, 1fr); justify-items: start; }
.card > * { max-width: 100%; }
.card h2 { margin: 0; }
.card summary { padding-block: 8px; cursor: pointer; }
.choose { columns: 16rem; }
.choose a { display: inline-block; padding-block: 6px; }
.credits { font-size: 0.875rem; }

.connect { display: grid; gap: 16px; max-width: 480px; margin: 0 auto; padding: calc(12vh + env(safe-area-inset-top)) var(--gutter) 40px; }
.connect img { border-radius: 16px; }
.connect form { display: grid; gap: 16px; margin-top: 8px; }

/* ---------------------------------------------------------------- Bigger screens */

@media (min-width: 900px) {
  .top { gap: 28px; max-width: 1180px; margin: 0 auto; padding-block: 12px; }
  .tabs { position: static; display: flex; gap: 4px; padding: 0; border: 0; background: none; }
  .tabs a { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 1rem; }
  .tabs a[aria-current] { background: var(--accent-soft); box-shadow: none; }
  .tabs .add { margin-left: 12px; background: var(--accent); color: var(--on-accent); }
  .page { gap: 20px; padding-top: 16px; padding-bottom: 64px; }
  .figures { justify-content: flex-start; gap: 56px; }
  .figures b { font-size: 2.25rem; }
  .toolbar { grid-template-columns: minmax(220px, 1fr) repeat(3, 170px); }
  .search { grid-column: auto; }
  .chips.scroll { flex-wrap: wrap; margin: 0; padding: 0; }
  .level { grid-template-columns: auto 1fr auto; padding: 14px 16px; }
  .level-count { grid-column: auto; }

  /* The details line up in columns, like the sheet. */
  .game-list { --rank-column: 2rem; }
  .game {
    grid-template-columns: var(--rank-column) 45px minmax(200px, 1fr) 4.75rem 4rem 3.25rem 5rem minmax(0, 13rem) minmax(0, 9.5rem) 4rem;
    align-items: center; gap: 14px; min-height: 0; padding: 8px 8px 8px 0;
  }
  .game > *, .game .rank, .game .cover, .game .score { grid-area: auto; align-self: center; }
  .facts, .facts:not(:has(span:not(:empty))) { display: contents; }
  .excitement, .facts span { text-align: right; }
  .facts.words span { padding-left: 10px; overflow-wrap: anywhere; line-height: 1.25; text-align: left; white-space: normal; }
  .list-head { display: grid; padding-block: 0 6px; color: var(--soft); }
  .list-head > *, .list-head .score { font: 400 0.875rem/1.4 var(--text); }
  .game-list li { contain-intrinsic-size: auto 77px; }

  .panel {
    inset: 0 0 0 auto; width: 500px; height: 100dvh;
    border-radius: 16px 0 0 16px; animation-name: slide;
  }
  .panel-body { padding-inline: 28px; }
  @keyframes slide { from { translate: 32px 0; opacity: 0; } }
  .toasts { bottom: 24px; }
}

@media (min-width: 900px) and (hover: hover) {
  a.game:hover { background: var(--surface); }
}

@media (max-width: 899px) {
  /* There are no column headings here, so these numbers need labels. */
  .excitement:not(:empty)::after { content: "/10"; }
  .metacritic:not(:empty)::before { content: "MC "; }
  .facts span:not(:empty) ~ span:not(:empty)::before { content: " \00b7  "; }
  .facts span:not(:empty) ~ .metacritic:not(:empty)::before { content: " \00b7  MC "; }
  .level-name { grid-column: 1 / -1; min-height: 2.4em; }
  .level { align-content: start; }
}

@media (max-width: 480px) {
  .status span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cover-large { width: 90px; height: 120px; }
}

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