  :root {
    color-scheme: dark;
    --bg: #07080c;
    --ink: #f4efe4;
    --muted: #9a9286;
    --gold: #e4b15a;
    --gold-dim: rgba(228, 177, 90, 0.18);
    --line: rgba(244, 239, 228, 0.1);
    --rail: 252px;
    --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
    --serif: "Iowan Old Style", Palatino, Georgia, serif;
  }
  html, body { height: 100%; }
  html.rail-collapsed { --rail: 76px; }
  html.rail-collapsed .rail { width: 76px; }
  html.rail-collapsed .app { margin-left: 76px; }
  html.rail-collapsed .play { left: 76px; }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    color: var(--ink);
    font: 16px/1.45 var(--sans);
    background: #07091a;
  }
  body.is-playing { height: 100vh; overflow: hidden; }
  .sky {
    position: fixed;
    z-index: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    isolation: isolate;
  }
  .sky canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
  }
  button, input { font: inherit; color: inherit; }
  button { cursor: pointer; }
  .rail {
    position: fixed;
    z-index: 2;
    top: 0;
    left: 0;
    bottom: 0;
    width: 252px;
    display: flex;
    flex-direction: column;
    padding: 14px 10px 12px;
    background: rgba(8, 8, 14, 0.82);
    border-right: 1px solid var(--gold-dim);
    backdrop-filter: blur(18px);
    transition: width 180ms ease;
  }
  .who { display: flex; flex-direction: column; gap: 8px; padding: 6px 6px 12px; }
  .who-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .who-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .avatar, .mark {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(228, 177, 90, 0.28), rgba(255, 255, 255, 0.04));
    border: 1px solid var(--gold-dim);
    overflow: hidden;
  }
  .avatar { font: 600 14px/1 var(--serif); color: var(--gold); }
  .who-copy { min-width: 0; }
  .who-line { flex: 1; margin: 0; min-width: 145px; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #logout {
    margin-top: 2px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  #logout:hover { color: var(--gold); }
  #rail-toggle {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
  }
  #rail-toggle svg { width: 12px; height: 12px; display: block; }
  #rail-toggle:hover { color: var(--ink); border-color: var(--gold-dim); }
  html.rail-collapsed .who-line {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
  html.rail-collapsed #rail:not(.rail-peek) { padding-left: 4px; padding-right: 4px; }
  html.rail-collapsed #rail:not(.rail-peek) .who { padding-left: 0; padding-right: 0; }
  html.rail-collapsed #rail:not(.rail-peek) .who-main { flex-direction: row; gap: 4px; justify-content: center; }
  html.rail-collapsed #rail:not(.rail-peek) .who-copy { flex: 0 0 auto; }
  html.rail-collapsed #rail:not(.rail-peek) .who-row { justify-content: center; }
  html.rail-collapsed #rail:not(.rail-peek) #logout,
  html.rail-collapsed #rail:not(.rail-peek) #add-pass,
  html.rail-collapsed #rail:not(.rail-peek) #set-pass { display: none; }
  #add-pass {
    display: block;
    margin-top: 2px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  #add-pass:hover { color: var(--gold); }
  #set-pass { margin-top: 8px; }
  #set-pass label { margin-top: 0; }
  #set-pass label:not([hidden]) + label { margin-top: 8px; }
  #set-pass .error { min-height: 0; margin-top: 6px; font-size: 12px; }
  #set-pass button {
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--gold);
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  .rail nav { display: flex; flex-direction: column; gap: 4px; overflow: auto; padding: 8px 4px; }
  .rail-label-head {
    margin: 8px 10px 6px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
  }
  html.rail-collapsed #rail:not(.rail-peek) .rail-label-head { display: none; }
  .rail-game {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 4px 6px;
    border-radius: 12px;
    color: inherit;
    text-decoration: none;
  }
  .rail-game:hover, .rail-game.is-on { background: rgba(228, 177, 90, 0.14); }
  .rail-game.is-on { box-shadow: inset 0 0 0 1px rgba(228, 177, 90, 0.35); }
  .rail-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
  html.rail-collapsed #rail:not(.rail-peek) .rail-label { display: none; }
  html.rail-collapsed #rail:not(.rail-peek) .rail-game { justify-content: center; padding: 4px 0; }
  #rail.rail-peek {
    width: 252px;
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.45);
  }
  html.rail-collapsed #rail.rail-peek .who-line {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip: auto;
    overflow: hidden;
  }
  .mark img, .card-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .mono { font: 600 13px/1 var(--serif); color: var(--gold); }
  .app {
    position: relative;
    z-index: 1;
    margin-left: 252px;
    height: 100vh;
    overflow: hidden;
    transition: margin-left 180ms ease;
  }
  .stage { height: 100%; overflow: auto; padding: 48px 56px 80px; scrollbar-width: thin; }
  .play {
    position: fixed;
    z-index: 1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 252px;
    transition: left 180ms ease;
  }
  .play iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: #07080c;
  }
  /* A game uses the full viewport. The menu returns only after the player icon is pressed. */
  body.is-playing .app { margin-left: 0; }
  body.is-playing .play { left: 0; }
  html.rail-open body.is-playing .app { margin-left: 252px; }
  html.rail-open body.is-playing .play { left: 252px; }
  html:not(.rail-open) body.is-playing #rail {
    top: 12px;
    left: 12px;
    bottom: auto;
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
    overflow: visible;
    pointer-events: none;
    transition: none;
  }
  html:not(.rail-open) body.is-playing #rail .who { padding: 0; }
  html:not(.rail-open) body.is-playing #rail .who-main { gap: 0; }
  html:not(.rail-open) body.is-playing #rail .who-copy,
  html:not(.rail-open) body.is-playing #rail .rail-label-head,
  html:not(.rail-open) body.is-playing #rail nav { display: none; }
  html:not(.rail-open) body.is-playing #rail .avatar {
    pointer-events: auto;
    cursor: pointer;
    background: #14120c;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  }
  html:not(.rail-open) body.is-playing #rail .avatar:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
  }
  [hidden] { display: none !important; }
  .eyebrow { margin: 0 -4px 13px; color: var(--gold); font-size: 8px; letter-spacing: 0.22em; text-transform: uppercase; }
  h1 { margin: 0; font: 560 clamp(40px, 5vw, 68px)/0.95 var(--serif); letter-spacing: -0.04em; text-align: center;}
  .lede { max-width: 36rem; margin: 14px 0 0; color: var(--muted); }
  .eyebrow, h1, .lede, .empty { text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75); }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 28px; }
  a.card {
    display: flex;
    flex-direction: row;
    width: 205px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    background: linear-gradient(180deg, rgba(14, 12, 18, 0.58), rgba(8, 8, 14, 0.46));
    border: 1px solid rgba(154, 118, 62, 0.62);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  }
  a.card:hover, a.card.is-on { border-color: rgba(228, 177, 90, 0.55); transform: translateY(-2px); }
  .card-copy { min-width: 0; flex: 1; }
  .card-icon { width: 44px; height: 44px; border-radius: 12px; }
  .card-icon.mark { width: 44px; height: 44px; flex: 0 0 44px; }
  .card-icon .mono { font-size: 18px; }
  a.card strong { display: block; font-size: 18px; font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; }
  a.card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
  .empty { margin-top: 28px; color: var(--muted); }
  .boards { display: grid; gap: 16px; max-width: 640px; margin-top: 28px; }
  .board {
    padding: 16px 18px 8px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(14, 12, 18, 0.58), rgba(8, 8, 14, 0.46));
    border: 1px solid rgba(154, 118, 62, 0.62);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  }
  .board h2 { margin: 0 0 8px; font: 560 22px/1.2 var(--serif); letter-spacing: -0.03em; }
  .board .none { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
  .board ol { list-style: none; margin: 0; padding: 0; }
  .board li {
    display: grid;
    grid-template-columns: 2.4rem minmax(0, 1fr) auto;
    gap: 12px;
    align-items: baseline;
    padding: 8px 0;
    border-top: 1px solid var(--line);
  }
  .board .rank, .board .pts { font-variant-numeric: tabular-nums; }
  .board .rank { color: var(--muted); }
  .board li:first-child .rank { color: var(--gold); }
  .board .player { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .board li.is-you .player { color: var(--gold); }
  #board .empty { margin-top: 28px; }
  .gate {
    position: relative;
    z-index: 1;
    height: 100%;
    overflow: auto;
    display: grid;
    justify-items: center;
    align-items: safe center;
    padding: 32px 20px;
  }
  .panel {
    width: min(420px, 100%);
    padding: 15px 28px 24px;
    border-radius: 28px;
    background: rgba(10, 16, 22, 0.58);
    border: 1px solid var(--gold-dim);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
  }
  .panel h1 { font-size: 56px; }
  label { display: block; margin-top: 13px; font-size: 13px; color: var(--muted); }
  input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.35);
  }
  input:focus { outline: 2px solid rgba(228, 177, 90, 0.45); border-color: transparent; }
  .actions { display: flex; gap: 10px; margin-top: 5px; margin-left: 0; }
  .actions button {
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: var(--gold);
    color: #1a1404;
    font-weight: 650;
  }
  .actions button.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
  .actions.link-actions { margin-left: 0; flex-wrap: wrap; }
  .link-copy { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
  .pass-note { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
  .link-via { display: grid; gap: 8px; margin-top: 12px; }
  .link-via a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 650;
    border: 1px solid var(--line);
  }
  .link-via a.via-x { background: #111; color: var(--ink); }
  .link-via a.via-tesla { background: var(--gold); color: #1a1404; border-color: transparent; }
  .link-via a.via-github { background: #f4efe4; color: #1a1408; border-color: transparent; }
  .error { min-height: 1.2em; margin: 12px 0 0; color: #ff8b7b; }
  .or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  .or::before, .or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
  }
  .oauth { display: grid; gap: 8px; margin-top: 14px; }
  .oauth a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 650;
    border: 1px solid var(--line);
  }
  .oauth a.oauth-x { background: #111; color: var(--ink); }
  .oauth a.oauth-tesla { background: var(--gold); color: #1a1404; border-color: transparent; }
  .oauth a.oauth-github { background: #f4efe4; color: #1a1408; border-color: transparent; }
  .oauth a:hover { filter: brightness(1.08); }
  .oauth svg { flex: 0 0 auto; }
  a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  @media (max-width: 800px) {
    .stage { padding: 28px 18px 64px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .rail, .app, .play, a.card { transition: none; }
  }
