:root {
  --bg: #000;
  --fg: #ededed;
  --muted: #9a9a9a;
  --line: rgba(237, 237, 237, 0.24);
  --serif: Didot, "Bodoni 72", "Bodoni MT", "Didot LT STD", "Playfair Display", Georgia, "Times New Roman", serif;
  /* SF Pro on Apple devices through the system stack (its licence does not allow
     self-hosting); the platform UI font elsewhere. */
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --gx: clamp(18px, 3.4vw, 56px);
  --gy: clamp(18px, 3.2vw, 44px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 400 10px/1.6 var(--ui);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  overflow: hidden;
  touch-action: pinch-zoom;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.art {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* A soft shade behind the title column; the art still runs underneath. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.38) 24%, transparent 46%);
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The interface over the art: corners on a grid, the title centred on the
   left. Glass must not sit inside anything faded or filtered, or its blur
   loses the art behind it, so only leaf elements animate their opacity. */
.ui {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template: ". mode" auto ". ." 1fr "stats invite" auto / 1fr auto;
  padding: max(var(--gy), env(safe-area-inset-top)) max(var(--gx), env(safe-area-inset-right)) max(var(--gy), env(safe-area-inset-bottom)) max(var(--gx), env(safe-area-inset-left));
  pointer-events: none;
  text-shadow: 0 0 2px #000, 0 0 12px #000;
}

.ui a,
.ui button,
.ui .glass {
  pointer-events: auto;
}

/* Everything arrives once the glyphs start to settle. */
.reveal {
  animation: reveal 1100ms var(--ease) 650ms backwards;
}

.mode.reveal {
  animation-delay: 950ms;
}

.community .stat:first-child {
  animation-delay: 1050ms;
}

.community .stat:last-child {
  animation-delay: 1130ms;
}

.invite .discord {
  animation-delay: 1210ms;
}

.year.reveal {
  animation-delay: 1300ms;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Title block: the serif wordmark, a rule, and the labels. */
.title {
  position: absolute;
  left: max(var(--gx), env(safe-area-inset-left));
  top: 50%;
  translate: 0 -48%;
}

.wordmark {
  font-weight: 400;
  text-transform: none;
}

.wordmark .paris {
  display: block;
  font: 400 clamp(34px, 4.6vw, 76px) / 1 var(--serif);
  letter-spacing: 0.52em;
  margin-right: -0.52em;
  text-transform: uppercase;
}

.wordmark .forza {
  display: block;
  margin-top: 14px;
  font: 500 10.5px/1 var(--ui);
  letter-spacing: 0.9em;
  text-transform: uppercase;
  color: var(--muted);
}

.rule {
  display: block;
  width: 16px;
  height: 1px;
  margin: 26px 0 22px;
  background: var(--fg);
}

.label {
  font-size: 10.5px;
}

.label + .label {
  margin-top: 22px;
}

.code {
  letter-spacing: 0.4em;
}

.home {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 200ms ease, border-color 200ms ease;
}

.home:hover {
  color: var(--fg);
  border-color: var(--fg);
}

/* The year sits under the Discord invite, its rule leading in from the left. */
.year {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}

.rule.long {
  width: clamp(60px, 9vw, 120px);
  margin: 0;
  background: var(--line);
}

/* Liquid glass, after Den Dionigi's "Apple Liquid Glass Switcher"
   (codepen.io/DedaloD, via 21st.dev): a faint glass fill whose thickness
   comes from a stack of inset bevels, light reflexes along the top-left and
   bottom-right edges and dark reflexes inside them. A light blur keeps text
   legible over the moving glyphs, and the renderer bends the glyphs beneath
   each surface. --rl and --rd set the strength of the light and dark reflexes. */
.glass {
  --rl: 0.75;
  --rd: 2;
  position: relative;
  isolation: isolate;
  border: 0;
  color: var(--fg);
  font-family: var(--ui);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  background-color: rgba(187, 187, 188, 0.12);
  -webkit-backdrop-filter: blur(4px) saturate(150%);
  backdrop-filter: blur(4px) saturate(150%);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / calc(var(--rl) * 10%)),
    inset 1.8px 3px 0 -2px rgb(255 255 255 / calc(var(--rl) * 90%)),
    inset -2px -2px 0 -2px rgb(255 255 255 / calc(var(--rl) * 80%)),
    inset -3px -8px 1px -6px rgb(255 255 255 / calc(var(--rl) * 60%)),
    inset -0.3px -1px 4px 0 rgb(0 0 0 / calc(var(--rd) * 12%)),
    inset -1.5px 2.5px 0 -2px rgb(0 0 0 / calc(var(--rd) * 20%)),
    inset 0 3px 4px -2px rgb(0 0 0 / calc(var(--rd) * 20%)),
    inset 2px -6.5px 1px -4px rgb(0 0 0 / calc(var(--rd) * 10%)),
    0 1px 5px 0 rgb(0 0 0 / calc(var(--rd) * 10%)),
    0 6px 16px 0 rgb(0 0 0 / calc(var(--rd) * 8%));
  transition: transform 320ms var(--ease), background-color 0.4s cubic-bezier(1, 0, 0.4, 1);
}

.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(130px circle at var(--mx, 50%) var(--my, -40%), rgba(255, 255, 255, 0.16), transparent 64%);
  opacity: 0;
  transition: opacity 360ms ease;
  pointer-events: none;
}

@media (hover: hover) {
  .glass:hover {
    background-color: rgba(187, 187, 188, 0.18);
  }

  .glass:hover::after {
    opacity: 1;
  }
}

.glass:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.92);
  outline-offset: 3px;
}

/* The bead: denser glass with a tighter bevel (the switch's lens, the
   Discord arrow). */
.bead {
  background-color: rgba(187, 187, 188, 0.36);
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / calc(var(--rl) * 10%)),
    inset 2px 1px 0 -1px rgb(255 255 255 / calc(var(--rl) * 90%)),
    inset -1.5px -1px 0 -1px rgb(255 255 255 / calc(var(--rl) * 80%)),
    inset -2px -6px 1px -5px rgb(255 255 255 / calc(var(--rl) * 60%)),
    inset -1px 2px 3px -1px rgb(0 0 0 / calc(var(--rd) * 20%)),
    inset 0 -4px 1px -2px rgb(0 0 0 / calc(var(--rd) * 10%)),
    0 3px 6px 0 rgb(0 0 0 / calc(var(--rd) * 8%));
}

/* Colour switch: ⚪ mono, ✨ colour. The bead snaps across and stretches
   from its trailing edge as it goes. */
.mode[hidden] {
  display: none; /* ui.js shows the switch; without JavaScript it would do nothing */
}

.mode {
  grid-area: mode;
  justify-self: end;
  align-self: start;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  width: 112px;
  height: 52px;
  padding: 5px;
  border-radius: 99em;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mode-lens {
  position: absolute;
  top: 4px;
  bottom: 6px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 99em;
  z-index: -1;
  transform-origin: 100% 50%;
  transition: translate 0.4s cubic-bezier(1, 0, 0.4, 1), background-color 0.4s cubic-bezier(1, 0, 0.4, 1);
  animation: stretch-back 0.44s ease;
}

.mode[aria-checked="true"] .mode-lens {
  translate: 100% 0;
  transform-origin: 0 50%;
  background-color: rgba(255, 214, 228, 0.32);
  animation-name: stretch;
}

/* Same keyframes under two names, so every toggle restarts the stretch. */
@keyframes stretch {
  50% {
    scale: 1.2 1;
  }
}

@keyframes stretch-back {
  50% {
    scale: 1.2 1;
  }
}

.mode-emoji {
  position: relative;
  font: 400 19px/1 "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  letter-spacing: 0;
  text-shadow: none;
  transition: opacity 320ms ease, filter 320ms ease, scale 480ms var(--spring);
}

.mode[aria-checked="false"] .chroma,
.mode[aria-checked="true"] .mono {
  opacity: 0.4;
  filter: grayscale(1);
  scale: 0.8;
}

.mode[aria-checked="true"] .chroma {
  animation: twinkle 3.2s ease-in-out infinite;
}

@media (hover: hover) {
  .mode:hover .mode-emoji {
    scale: 1.12;
  }
}

@keyframes twinkle {
  50% {
    rotate: 14deg;
    scale: 1.12;
  }
}

/* Community stats, bottom left; the invite and the year, bottom right. */
.community {
  grid-area: stats;
  align-self: end;
  width: clamp(290px, 23vw, 344px);
}

.invite {
  grid-area: invite;
  align-self: end;
  display: grid;
  justify-items: end;
  gap: 16px;
}

/* Longhands, so the staggered delays set above are kept. */
.community .stat,
.invite .discord {
  animation-name: reveal;
  animation-duration: 1100ms;
  animation-timing-function: var(--ease);
  animation-fill-mode: backwards;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 13px 14px 14px;
  border-radius: 18px;
}

.stat dt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font: 600 10px/1 var(--ui);
  letter-spacing: 0.2em;
  color: var(--muted);
}

.stat-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font: 600 8px/1 var(--ui);
  letter-spacing: 0.16em;
  color: rgba(237, 237, 237, 0.62);
  white-space: nowrap;
}

.stat dd {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.stat-value {
  font: 500 26px/1 var(--ui);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  transition: color 400ms ease, opacity 400ms ease;
}

/* States (set by stats.js): current shows a live dot; stale dims the last
   good count and the tag carries its age; loading breathes; unavailable and
   placeholder show only a quiet dash. */
.stat[data-state="current"] .stat-tag {
  color: rgba(237, 237, 237, 0.86);
  border-color: rgba(255, 255, 255, 0.24);
}

.stat[data-state="current"] .stat-tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f2f2f2;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
  }
}

.stat[data-state="stale"] .stat-value {
  color: rgba(237, 237, 237, 0.62);
}

.stat[data-state="stale"] .stat-tag {
  letter-spacing: 0.08em;
  text-transform: none;
}

.stat[data-state="loading"] .stat-value,
.stat[data-state="placeholder"] .stat-value {
  color: rgba(237, 237, 237, 0.72);
  animation: idle 2.8s ease-in-out infinite;
}

.stat[data-state="unavailable"] .stat-value,
.stat[data-state="disabled"] .stat-value {
  color: rgba(237, 237, 237, 0.4);
}

.stat[data-state="unavailable"] .stat-tag {
  border-style: dashed;
}

/* An approximate count gets a small ≈ in front. */
.stat[data-approximate="true"]:is([data-state="current"], [data-state="stale"]) .stat-value::before {
  content: "≈";
  margin-right: 0.14em;
  font-size: 0.6em;
  vertical-align: 0.18em;
  opacity: 0.55;
}

@keyframes idle {
  50% {
    opacity: 0.45;
  }
}

.stat-unit {
  overflow: hidden;
  text-overflow: ellipsis;
  font: 500 9.5px/1 var(--ui);
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* Discord invite: a compact glass capsule with the mark, the label and an
   arrow bead that lights up on hover. */
.discord {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 46px;
  padding: 0 5px 0 16px;
  border-radius: 99em;
  text-decoration: none;
}

.discord-mark {
  flex: none;
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.discord-label {
  font: 600 11px/1 var(--ui);
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.discord-arrow {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font: 500 15px/1 var(--ui);
  letter-spacing: 0;
  transition: background-color 280ms ease, color 280ms ease;
}

@media (hover: hover) {
  .discord:hover {
    transform: translateY(-1px);
  }

  .discord:hover .discord-arrow {
    background: #f4f4f4;
    color: #000;
    text-shadow: none;
  }
}

.glass:active {
  transform: scale(0.98);
}

.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font: 400 clamp(32px, 7vw, 80px) / 1 var(--serif);
  letter-spacing: 0.5em;
  color: #333;
}

/* Portrait phones and tall screens: the art takes the top, the interface
   stacks at the bottom over a scrim. Landscape phones keep the title column.
   Must match stackedLayout() in concepts.js (test/layout.test.js checks it). */
@media (max-width: 719.98px) and (max-aspect-ratio: 1/1), (max-aspect-ratio: 5/6) {
  body::after {
    inset: auto 0 0 0;
    height: 64%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.94) 40%, rgba(0, 0, 0, 0.62) 70%, transparent);
  }

  .ui {
    grid-template: "mode" auto "." 1fr "title" auto "stats" auto "invite" auto / minmax(0, 1fr);
    row-gap: 18px;
  }

  .title {
    position: static;
    grid-area: title;
    translate: none;
    margin-bottom: 4px;
  }

  .wordmark .paris {
    font-size: clamp(32px, 9vw, 54px);
  }

  .rule {
    margin: 18px 0 14px;
  }

  .label + .label {
    margin-top: 10px;
  }

  .community {
    width: 100%;
    max-width: 560px;
  }
}

/* Short landscape screens (phones on their side): tighter everywhere. The
   conditions are the complement of the stacked layout above; 1001/1000 keeps
   an exactly square narrow screen stacked only. */
@media (max-height: 560px) and (min-width: 720px) and (min-aspect-ratio: 5/6), (max-height: 560px) and (max-width: 719.98px) and (min-aspect-ratio: 1001/1000) {
  .wordmark .paris {
    font-size: clamp(28px, 7vh, 46px);
  }

  .rule {
    margin: 14px 0 12px;
  }

  .label + .label {
    margin-top: 12px;
  }

  .community {
    width: 290px;
    gap: 8px;
  }

  .stats {
    gap: 8px;
  }

  .stat {
    gap: 7px;
    padding: 10px 12px 11px;
  }

  .stat-value {
    font-size: 21px;
  }

  .discord {
    height: 42px;
  }

  .discord-arrow {
    width: 32px;
    height: 32px;
  }

  .mode {
    width: 80px;
    height: 40px;
  }
}

/* The smallest landscape phones (568 x 320): lift the title clear of the tiles.
   Stacked layouts place the title in the grid, where top has no effect. */
@media (max-height: 340px) {
  .title {
    top: 45%;
  }
}

/* Very small phones. */
@media (max-width: 359.98px) {
  .stat {
    padding: 11px 11px 12px;
  }

  .stat-value {
    font-size: 22px;
  }

  .discord {
    gap: 10px;
    padding-left: 14px;
  }

  .discord-label {
    letter-spacing: 0.1em;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .glass {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(18, 18, 20, 0.94);
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgba(18, 18, 20, 0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .community .stat,
  .invite .discord,
  .stat[data-state="placeholder"] .stat-value,
  .stat[data-state="loading"] .stat-value,
  .stat[data-state="current"] .stat-tag::before,
  .mode[aria-checked] .mode-lens,
  .mode[aria-checked="true"] .chroma {
    animation: none;
  }

  .mode-lens,
  .mode-emoji,
  .glass {
    transition-duration: 1ms;
    animation: none;
  }
}
