/* Colors are the launcher's palettes (src/core/config.cpp, darkPalette and lightPalette).
   index.html sets data-theme before first paint; dark is the default without JavaScript.
   The launcher's light status colors are under 4.5:1 as text, so --success, --warning,
   --soon and --link carry darker light-theme values; the P1-P4 fields keep their hues.
   One motif runs the page: the four player slots (P1 hosts, P2-P4 join). It is the field under
   the hero, the pips on every game, the player picker, the four steps and the footer blocks. */
:root {
  --bg: #15171C;
  --surface: #1E2128;
  --surface-hover: #272B34;
  --deep: #0E1014;
  --text: #E8EAED;
  --muted: #9AA1AC;
  --border: #323743;
  --border-strong: #4A5160;
  --focus: #8FB0FF;
  --link: #8FB0FF;
  --link-hover: #B5CBFF;
  --play: #C8313A;
  --play-hover: #B42A33;
  --success: #3CCB7F;
  --warning: #F2B544;
  --soon: #8FB0FF;
  --testing: #3FC9BB;
  --p1: #E5484D;
  --p2: #3E7BFA;
  --p3: #2EBD6B;
  --p4: #F5B83D;
  --on-slot: #0B0D11;
  --backdrop: rgb(6 8 12 / 0.74);
  --display: Bahnschrift, "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 4px;
  /* Five type steps: small, body, lead, heading, display. */
  --t-small: 14px;
  --t-body: 16px;
  --t-lead: 20px;
  --t-head: 36px;
  --t-display: clamp(33px, 7.4vw, 112px);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #FFFFFF;
  --surface: #F1F3F7;
  --surface-hover: #E6EAF1;
  --deep: #E9EDF3;
  --text: #1C2128;
  --muted: #5B6472;
  --border: #D5DAE1;
  --border-strong: #8B94A3;
  --focus: #2F6FEB;
  --link: #1F5BD1;
  --link-hover: #174AAE;
  --play: #B42A33;
  --play-hover: #9C232B;
  --success: #157A42;
  --warning: #8A5A0F;
  --soon: #1F5BD1;
  --testing: #086A60;
  --backdrop: rgb(20 24 32 / 0.55);
  color-scheme: light;
}

* { box-sizing: border-box; }
.theme-switch, .theme-switch * { transition: none !important; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--t-body)/1.55 var(--body);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, .brand, .btn, .slot strong { font-family: var(--display); font-weight: 600; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h2 { font-size: var(--t-head); letter-spacing: -0.01em; }
h3 { font-size: var(--t-lead); }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

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

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Buttons: flat, one fill, one radius */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--radius);
  font-size: var(--t-lead); text-decoration: none; border: 0; cursor: pointer;
  transition: transform 80ms ease, background-color 120ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: var(--t-body); }
.btn-play { background: var(--play); color: #fff; }
.btn-play:hover { background: var(--play-hover); color: #fff; }
.btn-quiet { background: var(--surface-hover); color: var(--text); font-family: var(--display); }
.btn-quiet:hover { background: var(--border); color: var(--text); }

.link-btn { background: none; border: 0; padding: 4px 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--link-hover); }

.icon-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: var(--surface-hover); color: var(--text); border: 0; border-radius: var(--radius); cursor: pointer; }
.icon-btn:hover { background: var(--border); }
/* The icon shows the theme you would switch to. */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun, :root:not([data-theme]) .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon, :root:not([data-theme]) .icon-moon { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: none; }

/* Header: a plain bar */
.top { background: var(--deep); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: var(--t-lead); font-weight: 700; }
.brand:hover { color: var(--text); }
.brand-mark { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.brand-mark i { width: 9px; height: 9px; border-radius: 2px; }
.brand-mark i:nth-child(1), .pips i:nth-child(1) { background: var(--p1); }
.brand-mark i:nth-child(2), .pips i:nth-child(2) { background: var(--p2); }
.brand-mark i:nth-child(3), .pips i:nth-child(3) { background: var(--p3); }
.brand-mark i:nth-child(4), .pips i:nth-child(4) { background: var(--p4); }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-left: auto; }
.nav-link { color: var(--muted); text-decoration: none; padding: 8px 0; }
.nav-link:hover { color: var(--text); }
@media (max-width: 640px) {
  .top { position: static; }
  nav { margin-left: 0; width: 100%; }
  .nav-link { display: none; }
  nav .btn { flex: 1; }
}

/* Hero: the headline, the real launcher, and the four slots as one field of colour */
.hero { background: var(--deep); }
.hero-top { padding-top: clamp(32px, 5vw, 72px); }
h1 { font-size: var(--t-display); line-height: 0.98; letter-spacing: -0.03em; max-width: 11em; text-wrap: balance; }
.hero-body { display: grid; gap: 28px; padding-top: 32px; align-items: start; }
@media (min-width: 960px) { .hero-body { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px; } }
.hero-copy { padding-bottom: 40px; }
.lead { font-size: var(--t-lead); max-width: 30em; margin: 0 0 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.fine { color: var(--muted); font-size: var(--t-small); margin: 14px 0 0; max-width: 34em; }
@media (max-width: 480px) { .actions .btn { flex: 1 1 100%; } }

.hero-shot { margin: 0 0 -96px; position: relative; z-index: 2; }
.hero-shot img { display: block; width: 100%; height: auto; border-radius: var(--radius); }
@media (min-width: 960px) { .hero-shot { margin-bottom: -150px; } }

.slots { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; }
.slot { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-height: 180px; padding: 16px; color: var(--on-slot); }
.slot:nth-child(1) { background: var(--p1); }
.slot:nth-child(2) { background: var(--p2); }
.slot:nth-child(3) { background: var(--p3); }
.slot:nth-child(4) { background: var(--p4); }
.slot strong { font-size: clamp(32px, 4vw, 56px); line-height: 1; }
.slot span { font-size: var(--t-small); line-height: 1.3; }
@media (min-width: 720px) { .slot { min-height: 260px; padding: 24px; } .slot span { font-size: var(--t-body); } }

/* Release strip: a step in tone, no lines */
.strip { background: var(--surface); }
.strip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding-top: 14px; padding-bottom: 14px; font-size: var(--t-small); }
.strip-label { font-family: var(--display); font-weight: 600; font-size: var(--t-body); }
.strip-item { display: inline-flex; gap: 10px; align-items: baseline; background: var(--surface-hover); border-radius: 999px; padding: 4px 12px; text-decoration: none; color: var(--text); font-variant-numeric: tabular-nums; }
.strip-item:hover { background: var(--border); color: var(--text); }

/* Sections */
section[id] { padding-top: 64px; padding-bottom: 64px; scroll-margin-top: 72px; }
.section-note { max-width: 34em; margin: 8px 0 0; }

/* Finder: search and filters */
.finder { display: grid; gap: 16px; margin: 24px 0 20px; }
.search { display: flex; align-items: center; gap: 12px; background: var(--deep); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 14px; color: var(--muted); }
.search:focus-within { border-color: var(--focus); }
.search input { flex: 1; min-width: 0; min-height: 56px; background: none; border: 0; color: var(--text); font: var(--t-lead) var(--body); }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme="dark"] .search input::-webkit-search-cancel-button { filter: invert(0.7); }
kbd { font: var(--t-small) var(--body); color: var(--muted); background: var(--surface-hover); border-radius: 3px; padding: 1px 8px; }
@media (hover: none) { kbd { display: none; } }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 14px; }
.filter { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: var(--t-small); color: var(--muted); }

.seg { position: relative; display: inline-flex; flex-wrap: wrap; background: var(--deep); border-radius: var(--radius); padding: 3px; gap: 2px; }
/* The pill slides to the pressed button. Before the script places it, the button fills itself. */
.seg-pill { position: absolute; left: 0; top: 0; width: var(--w, 0); height: var(--h, 0); transform: translate(var(--x, 0), var(--y, 0)); background: var(--text); border-radius: 2px; opacity: 0; pointer-events: none; }
.seg.is-ready .seg-pill { opacity: 1; transition: transform 340ms cubic-bezier(0.34, 1.35, 0.5, 1), width 340ms cubic-bezier(0.34, 1.35, 0.5, 1), height 200ms ease; }
/* The pressed button takes the pill's fill only once the pill has arrived, so its text always sits on a fill. */
.seg.is-ready button[aria-pressed="true"], .seg.is-ready button[aria-pressed="true"]:hover { background: var(--text); transition: color 120ms ease 200ms, background-color 0s 360ms; }
.seg button { position: relative; z-index: 1; transition: color 200ms ease; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; background: none; border: 0; border-radius: 2px; color: var(--muted); font: var(--t-body) var(--body); cursor: pointer; }
.seg button:hover { color: var(--text); background: var(--surface-hover); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.seg .pips i { width: 8px; height: 8px; }
.filters .seg { min-height: 46px; align-items: center; }
@media (max-width: 480px) { .select-wrap, .select { width: 100%; } .filter { flex: 1 1 100%; } }

.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select {
  min-height: 46px; width: 190px; padding: 0 36px 0 12px; text-overflow: ellipsis;
  background: var(--deep); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text); font: var(--t-body) var(--body);
  appearance: none; cursor: pointer;
}
.select:hover { border-color: var(--muted); }

.results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 24px; }
.results { margin: 0; color: var(--muted); }
.results strong { color: var(--text); font-weight: 600; }
.view { margin-left: auto; }

/* Status labels */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-small); font-weight: 600; white-space: nowrap; }
.status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-available { color: var(--success); }
.status-testing { color: var(--testing); }
.status-not-on-server { color: var(--warning); }
.status-coming-soon { color: var(--soon); }
.status-coming-soon::before { background: none; border: 2px solid currentColor; width: 6px; height: 6px; }

.pips { display: inline-flex; gap: 3px; }
.pips i { width: 10px; height: 10px; border-radius: 2px; }

/* Games, grouped by status. Playable games are large; the rest are compact rows. */
.group + .group { margin-top: 56px; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 16px; }
.group-head p { margin: 0; color: var(--muted); font-size: var(--t-small); }
.grid, .rows-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.rows-list { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
@media (max-width: 420px) { .rows-list { grid-template-columns: minmax(0, 1fr); } }

.card { position: relative; background: var(--surface); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: background-color 120ms ease, transform 120ms ease; }
.card:hover { background: var(--surface-hover); }
.card:active { transform: translateY(1px); }
/* The title is the real link; its ::after stretches over the whole card so any click opens the game. */
.card-link { color: var(--text); text-decoration: none; }
.card-link:hover { color: var(--text); }
.card-link::after { content: ""; position: absolute; inset: 0; }
.card-link:focus-visible { outline: none; }
.card:has(.card-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.cover { aspect-ratio: 16 / 9; background: var(--deep); display: block; width: 100%; }
img.cover { object-fit: cover; }
svg.cover { shape-rendering: crispEdges; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { font-size: var(--t-lead); }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--t-small); margin: 0; }
.desc { margin: 0; font-size: var(--t-body); }
.card-foot { margin-top: auto; padding-top: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.card-foot .meta { white-space: nowrap; }
.card.is-soon .cover { opacity: 0.7; }

/* Compact row: a small cover beside the text */
.card.is-row { flex-direction: row; align-items: stretch; }
.card.is-row .cover { width: 120px; aspect-ratio: auto; flex: none; height: auto; min-height: 100%; }
.card.is-row .card-body { padding: 12px 16px; gap: 4px; }
.card.is-row .desc { font-size: var(--t-small); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.is-row .card-foot { padding-top: 6px; }

/* Table view: fills instead of lines */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.table th { text-align: left; font-size: var(--t-small); font-weight: 600; color: var(--muted); padding: 6px 16px; }
.table td { padding: 10px 16px; background: var(--surface); vertical-align: middle; }
.table td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.table td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.table tbody tr:hover td { background: var(--surface-hover); }
.game-cell { display: flex; align-items: center; gap: 14px; min-width: 260px; }
.game-cell .cover { width: 80px; flex: none; border-radius: 2px; }
.game-cell strong { display: block; font-family: var(--display); font-weight: 600; font-size: var(--t-lead); }
.game-cell a { color: var(--text); text-decoration: none; }
.game-cell a:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.game-cell span { color: var(--muted); font-size: var(--t-small); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.players-cell { white-space: nowrap; color: var(--muted); font-size: var(--t-small); }
.players-cell .pips { vertical-align: -1px; margin-right: 8px; }

.empty { color: var(--muted); padding: 32px 0; text-align: center; }

/* How to play: four fields, the four slot colours */
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0; }
.steps li { padding: 24px 24px 28px; color: var(--on-slot); }
@media (min-width: 720px) { .steps li { padding-top: 28px; padding-bottom: 32px; min-height: 220px; } }
.steps li:nth-child(1) { background: var(--p1); }
.steps li:nth-child(2) { background: var(--p2); }
.steps li:nth-child(3) { background: var(--p3); }
.steps li:nth-child(4) { background: var(--p4); }
.steps + .section-note { margin-top: 24px; }
.steps h3 { font-size: var(--t-lead); margin-bottom: 8px; }
.steps p { margin: 0; font-size: var(--t-body); }
.steps a { color: var(--on-slot); }

/* Call to action */
.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 32px; background: var(--surface); border-radius: var(--radius); padding: 32px; }
.cta p { margin: 8px 0 0; max-width: 32em; color: var(--text); }

/* Footer: the four slots return as blocks */
.foot { padding-top: 32px; padding-bottom: 40px; color: var(--muted); font-size: var(--t-small); }
.foot-mark { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-bottom: 28px; }
.foot-mark i { flex: 1; max-width: 120px; }
.foot-mark i:nth-child(1) { height: 100%; background: var(--p1); }
.foot-mark i:nth-child(2) { height: 78%; background: var(--p2); }
.foot-mark i:nth-child(3) { height: 58%; background: var(--p3); }
.foot-mark i:nth-child(4) { height: 40%; background: var(--p4); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.foot p { margin: 0; }
.foot-links a { margin-left: 16px; }
.foot-links a:first-child { margin-left: 0; }

/* Game detail dialog: header, quality, facts, how to play, and a footer that stays in view */
body:has(dialog[open]) { overflow: hidden; }
.detail { width: min(760px, calc(100% - 32px)); max-height: min(92dvh, 860px); padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); overflow: auto; overscroll-behavior: contain; }
.detail::backdrop { background: var(--backdrop); }
/* The window springs in and eases out; the backdrop fades with it. */
.detail[open] { animation: detail-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1.12); }
.detail[open]::backdrop { animation: backdrop-in 220ms ease-out; }
.detail.is-closing { animation: detail-out 150ms ease-in forwards; }
.detail.is-closing::backdrop { animation: backdrop-out 150ms ease-in forwards; }
@keyframes detail-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@keyframes detail-out { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
.detail-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: var(--deep); color: var(--text); border: 0; border-radius: var(--radius); cursor: pointer; }
.detail-close:hover { background: var(--surface-hover); }
.detail .cover { border-radius: var(--radius); }
.detail-head { display: grid; gap: 16px; padding: 20px 24px 8px; }
@media (min-width: 640px) { .detail-head { grid-template-columns: 240px minmax(0, 1fr); gap: 24px; padding-right: 72px; } }
.detail-title-block { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.detail h2 { font-size: var(--t-head); }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0; color: var(--muted); font-size: var(--t-small); }
.detail-desc { margin: 0; }
.detail-body { padding: 12px 24px 20px; display: flex; flex-direction: column; gap: 20px; }

.quality-tile { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--deep); border-radius: var(--radius); }
.quality-tile strong { font-family: var(--display); font-weight: 600; font-size: var(--t-lead); }
.quality-tile p { margin: 2px 0 0; }
.quality-letter { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: var(--radius); background: var(--text); color: var(--bg); font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1; }
.quality-tile.is-unrated .quality-letter { background: var(--surface-hover); color: var(--muted); }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
@media (min-width: 560px) { .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fact dt { font-size: var(--t-small); color: var(--muted); margin-bottom: 2px; }
.fact dd { margin: 0; }
.fact dd.is-empty { color: var(--muted); }
.fact .pips { display: flex; margin-bottom: 4px; }
.coop { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.coop-bar { width: 72px; height: 8px; border-radius: 4px; background: var(--deep); overflow: hidden; }
.coop-bar i { display: block; height: 100%; background: var(--success); }

.synced-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.synced-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--deep); border-radius: var(--radius); color: var(--muted); }
.synced-row.is-on { color: var(--text); font-weight: 600; }
.synced-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; }
.synced-row.is-on .synced-dot { background: var(--success); border-color: var(--success); }
.synced-name { flex: 1; }
.synced-state { font-size: var(--t-small); font-weight: 400; color: var(--muted); }

.detail-extra-title { font-family: var(--display); font-weight: 600; font-size: var(--t-lead); margin: 0 0 6px; }
.detail-steps { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.detail-steps li::marker { color: var(--muted); }
.detail-aside { margin: 0; padding: 12px 14px; background: var(--deep); border-radius: var(--radius); }

.detail-foot { position: sticky; bottom: 0; padding: 16px 24px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.detail-foot .btn { min-height: 44px; font-size: var(--t-body); }
.detail-note { margin: 0; min-height: 1.55em; font-size: var(--t-small); }
/* On a phone the pinned footer would cover most of the facts, so it scrolls with them. */
@media (max-width: 640px) { .detail-foot { position: static; } }
@media (max-width: 480px) { .detail-head, .detail-body, .detail-foot { padding-left: 16px; padding-right: 16px; } .detail h2 { font-size: 28px; } h2 { font-size: 28px; } }

/* The grade square on cards and in the table */
.grade { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 8px; border-radius: 3px; background: var(--text); color: var(--bg); font-family: var(--display); font-weight: 700; font-size: var(--t-small); line-height: 1; vertical-align: -5px; }
.grade-X { background: var(--surface-hover); color: var(--muted); }
.quality-cell { white-space: nowrap; font-size: var(--t-small); color: var(--muted); }
.quality-cell .grade { margin: 0 4px 0 0; }

/* Motion: slots arrive one after another, then each section's parts rise once as they enter.
   Only transform and opacity; the content is visible without script and under reduced motion. */
.js .rise { opacity: 0; transform: translateY(24px); }
.js .rise.in { opacity: 1; transform: none; transition: opacity 520ms ease, transform 520ms cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(var(--i, 0) * 70ms); }
.js .slot.rise { transform: translateY(48px); }
.js .slot.rise.in { transform: none; transition-duration: 640ms; transition-delay: calc(var(--i, 0) * 110ms + 150ms); }
/* After its entrance a part answers hover and press at once, without the stagger delay. */
.js .rise.in.settled { transition-delay: 0s; transition-duration: 200ms; }
.js .card.rise.in.settled:active { transform: translateY(1px); }
.card img.cover { transition: transform 480ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@media (hover: hover) {
  .js .card.rise.in.settled:hover { transform: translateY(-3px); }
  .card:hover img.cover { transform: scale(1.04); }
}

/* Ripple: a soft circle from the pointer when a button is pressed. */
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: 0.22; transform: scale(0); pointer-events: none; animation: ripple 620ms ease-out forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* The copy button draws a check mark. */
.check path { stroke-dasharray: 22; stroke-dashoffset: 22; animation: draw 380ms 40ms ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* The theme switch: the new theme grows from the button as a circle (script drives the clip). */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* The title rolls letter by letter. Every phrase sits in the same grid cell, so the title never changes height. */
.roll { display: grid; }
.phrase { grid-area: 1 / 1; visibility: hidden; }
.phrase.is-on { visibility: visible; }
.w { display: inline-block; white-space: nowrap; }
.c { display: inline-block; opacity: 0; transform: translateY(0.4em); transition: opacity 360ms ease, transform 520ms cubic-bezier(0.2, 0.8, 0.2, 1); transition-delay: calc(var(--k) * 14ms); }
.phrase.is-on .c { opacity: 1; transform: none; }
.phrase.is-on.is-leaving .c { opacity: 0; transform: translateY(-0.4em); transition-duration: 260ms; transition-delay: calc(var(--k) * 8ms); }

@media (prefers-reduced-motion: reduce) {
  .js .rise, .js .rise.in { opacity: 1; transform: none; transition: none; }
  .detail[open], .detail[open]::backdrop, .detail.is-closing, .detail.is-closing::backdrop { animation: none; }
  .ripple { display: none; }
  .check path { animation: none; stroke-dashoffset: 0; }
  .seg.is-ready .seg-pill, .card img.cover { transition: none; }
}
