:root {
  color-scheme: light dark;

  --bg: light-dark(#fff4e4, #17122b);
  --surface: light-dark(#ffffff, #241c42);
  --surface-2: light-dark(#fff0dc, #30265a);
  --ink: light-dark(#2a1f47, #f6f0ff);
  --ink-soft: light-dark(#665b82, #b9aedb);
  --line: light-dark(#f0dfc6, #40356c);

  --coral: light-dark(#e63e62, #ff7a8c);
  --violet: light-dark(#6c4cf1, #a08bff);
  --sun: light-dark(#ffc83d, #ffd466);
  --mint: light-dark(#19c3a3, #4fe0c4);
  --sky: light-dark(#3db8ff, #6ccbff);
  --ok: light-dark(#0f9d80, #4fe0c4);
  --warn: light-dark(#b86a00, #ffc83d);

  /* The board's colors. Settings overwrites these on <html>. */
  --chip-a: #ffd23f;
  --chip-b: #ee4266;
  --felt: #2a1f5c;
  --point-a: #3bceac;
  --point-b: #ff8c42;
  --frame: #6c4cf1;

  --radius: 26px;
  --shadow: 0 18px 50px -18px light-dark(rgb(90 50 160 / .35), rgb(0 0 0 / .6));
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;

  accent-color: var(--violet);
}

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

html, body { min-height: 100%; }
body {
  margin: 0;
  font: 500 1rem/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ol, ul, fieldset { margin: 0; }
fieldset { border: 0; padding: 0; min-inline-size: 0; }
button, input { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--violet); }

.visually-hidden {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

/* ── Background blobs ── */
.blobs { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; }
@media (prefers-color-scheme: dark) { .blobs i { opacity: .16; } }
.blobs i:nth-child(1) { inline-size: 42vmax; block-size: 42vmax; background: var(--sun); inset: -14vmax auto auto -10vmax; }
.blobs i:nth-child(2) { inline-size: 36vmax; block-size: 36vmax; background: var(--coral); inset: -12vmax -10vmax auto auto; }
.blobs i:nth-child(3) { inline-size: 40vmax; block-size: 40vmax; background: var(--sky); inset: auto auto -18vmax -8vmax; }
.blobs i:nth-child(4) { inline-size: 34vmax; block-size: 34vmax; background: var(--mint); inset: auto -12vmax -14vmax auto; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(.75rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 2rem) .5rem;
}
.brand-wrap { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; }
.brand {
  display: inline-flex; align-items: center; gap: .5rem; align-self: center;
  font-size: 1.6rem; font-weight: 900; letter-spacing: .02em; color: var(--ink); text-decoration: none;
}
.logo { inline-size: 2.2rem; block-size: 2.2rem; stroke: none; rotate: -8deg; }
.logo-die { fill: var(--violet); }
.logo-a { fill: var(--sun); }
.logo-b { fill: #fff; }
.credit { font-size: .82rem; color: var(--ink-soft); }
.top-actions { display: flex; gap: .5rem; }

.icon-btn {
  display: grid; place-items: center; inline-size: 2.75rem; block-size: 2.75rem;
  border: 2px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--violet); }
.icon-btn svg { inline-size: 1.3rem; block-size: 1.3rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-block-size: 2.75rem; padding: .5rem 1.3rem;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface);
  font-weight: 800; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--violet); }
.btn.primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, light-dark(#6c4cf1, #7a5cf5), light-dark(#d93a7c, #d94f8a));
  box-shadow: 0 8px 20px -8px rgb(108 76 241 / .7);
}
.btn.primary:hover { box-shadow: 0 10px 26px -8px rgb(108 76 241 / .9); }
.btn.big { min-block-size: 3.4rem; font-size: 1.15rem; inline-size: 100%; }
.btn.small { min-block-size: 2.3rem; padding: .3rem 1rem; font-size: .92rem; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--coral); border-color: transparent; color: #fff; }
.danger-text { color: var(--coral); }
.btn svg { inline-size: 1.1rem; block-size: 1.1rem; }
.toggle[aria-pressed="true"] { background: var(--violet); border-color: transparent; color: light-dark(#fff, #17122b); }
.link-btn { border: 0; background: none; padding: .4rem; color: var(--violet); font-weight: 700; text-decoration: underline; cursor: pointer; }
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .15s, border-color .15s, box-shadow .15s, scale .15s; }
  .btn:active { scale: .96; }
}

/* ── Lobby ── */
.lobby {
  display: grid; gap: clamp(1.5rem, 4vw, 3rem); align-items: center;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 24rem);
  max-inline-size: 72rem; margin-inline: auto;
  padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2rem) 3rem;
}
@media (max-width: 52rem) { .lobby { grid-template-columns: minmax(0, 1fr); } }

.pitch h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.08; font-weight: 900; text-wrap: balance; }
.pitch h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--coral), var(--violet) 60%, var(--sky));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin-block: .9rem 1.6rem; font-size: 1.15rem; color: var(--ink-soft); text-wrap: pretty; }
.preview-wrap { rotate: -2deg; filter: drop-shadow(0 24px 30px rgb(40 20 90 / .3)); }

.card {
  display: grid; gap: 1.1rem; padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.card > * { min-inline-size: 0; }
.stack { display: grid; gap: 1rem; }
.pick { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.pick legend { font-weight: 800; margin-block-end: .6rem; padding: 0; }
.pick-chip { position: relative; display: grid; cursor: pointer; border-radius: 50%; }
.pick-chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pick-chip .chip-face { inline-size: 3.4rem; outline: 3px solid transparent; outline-offset: 4px; transition: outline-color .15s; }
.pick-chip input:checked + .chip-face { outline-color: var(--violet); }
.pick-chip input:focus-visible + .chip-face { outline-color: var(--ink); }
.pick .link-btn { margin-inline-start: auto; }

/* A checker, wherever one is shown outside the board. */
.chip-face {
  --c: var(--chip-a);
  display: inline-block; inline-size: 1.7rem; aspect-ratio: 1; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle, transparent 0 42%, color-mix(in oklab, var(--c), black 22%) 44% 52%, transparent 54%),
    radial-gradient(circle at 35% 30%, color-mix(in oklab, var(--c), white 45%), var(--c) 55%, color-mix(in oklab, var(--c), black 28%));
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--c), black 35%), 0 2px 5px rgb(0 0 0 / .3);
}
.chip-face.b { --c: var(--chip-b); }

.or { display: flex; align-items: center; gap: .8rem; color: var(--ink-soft); font-size: .9rem; }
.or::before, .or::after { content: ""; flex: 1; block-size: 2px; background: var(--line); border-radius: 2px; }

.join-row { display: flex; gap: .6rem; }
.join-row input, .chat-form input {
  flex: 1; min-inline-size: 0; min-block-size: 2.75rem; padding: .4rem 1rem;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface-2);
}
.join-row input { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.1rem; letter-spacing: .08em; }

.code-row, .share-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.code {
  flex: 1; padding: .5rem 1rem; border-radius: 16px; background: var(--surface-2); white-space: nowrap;
  border: 2px dashed var(--violet); text-align: center;
  font: 800 clamp(1.6rem, 6vw, 2.1rem)/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .1em;
}
.copy { position: relative; display: inline-flex; }
.tip {
  position: absolute; inset-block-end: calc(100% + .4rem); inset-inline-start: 50%; translate: -50% 0;
  padding: .15rem .6rem; border-radius: 8px; background: var(--ink); color: var(--bg);
  font-size: .8rem; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s;
}
.tip:not(:empty) { opacity: 1; }

.waiting { display: flex; align-items: center; gap: .6rem; color: var(--ink-soft); }
.pulse { inline-size: .7rem; block-size: .7rem; border-radius: 50%; background: var(--mint); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 1.2s ease-in-out 4 alternate; }
  @keyframes pulse { to { scale: 1.6; opacity: .4; } }
}
.error { padding: .6rem .9rem; border-radius: 14px; background: color-mix(in oklab, var(--coral), transparent 85%); color: var(--coral); font-weight: 700; }
.privacy { font-size: .82rem; color: var(--ink-soft); }

/* ── Game layout ── */
.game {
  display: grid; gap: 1rem; align-items: start;
  grid-template-columns: minmax(0, 1fr) 19rem;
  padding: .25rem clamp(.5rem, 2vw, 1.5rem) 1.5rem;
}
@media (max-width: 60rem) { .game { grid-template-columns: minmax(0, 1fr); } }

.table { display: grid; gap: .6rem; justify-items: center; }
.board-wrap, .seat { inline-size: min(100%, max(20rem, (100dvh - 14.5rem) * 1.5)); }
.board-wrap { position: relative; }

.seat {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .45rem .8rem; border-radius: 18px; background: var(--surface);
  border: 2px solid transparent; box-shadow: 0 6px 18px -12px rgb(40 20 90 / .5);
  transition: border-color .2s;
}
.seat.turn { border-color: var(--sun); }
.seat-name { font-weight: 800; }
.pips { font-size: .85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.status { flex: 1; min-inline-size: 12rem; font-weight: 700; text-wrap: balance; }
.actions { display: flex; gap: .5rem; margin-inline-start: auto; min-block-size: 2.75rem; }
.link-state { display: inline-flex; align-items: center; gap: .4rem; margin-inline-start: auto; font-size: .82rem; color: var(--ink-soft); }
.link-state .dot { inline-size: .6rem; block-size: .6rem; border-radius: 50%; background: var(--ok); }
.link-state[data-state="off"] .dot { background: var(--warn); }
#seat-them .pips { order: 1; }

/* ── The board ──
   Children are placed on a 1500 × 1000 grid: --x/--y/--w/--h are grid units
   and --k converts a unit to a length that tracks the board's width. */
.board {
  position: relative; isolation: isolate; container-type: inline-size; aspect-ratio: 3 / 2;
  border-radius: 2.2% / 3.3%; overflow: hidden; user-select: none; -webkit-user-select: none;
  background: linear-gradient(160deg, color-mix(in oklab, var(--frame), white 18%), var(--frame) 45%, color-mix(in oklab, var(--frame), black 30%));
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / .18), 0 14px 34px -14px rgb(20 10 60 / .7);
}
.board * { --k: calc(100cqw / 1500); }
.felt, .spot {
  position: absolute;
  inset-inline-start: calc(var(--x) * var(--k)); inset-block-start: calc(var(--y) * var(--k));
  inline-size: calc(var(--w) * var(--k)); block-size: calc(var(--h) * var(--k));
}
.board { direction: ltr; }

.felt {
  border-radius: calc(10 * var(--k));
  background: radial-gradient(120% 90% at 50% 40%, color-mix(in oklab, var(--felt), white 10%), var(--felt) 60%, color-mix(in oklab, var(--felt), black 22%));
  box-shadow: inset 0 calc(4 * var(--k)) calc(14 * var(--k)) rgb(0 0 0 / .45);
}
.felt.well { background: color-mix(in oklab, var(--felt), black 25%); }

.spot { border: 0; padding: 0; background: none; border-radius: calc(10 * var(--k)); cursor: default; }
.spot:focus-visible { outline: calc(5 * var(--k)) solid #fff; outline-offset: calc(-5 * var(--k)); }
.spot.can, .spot.target { cursor: pointer; }
/* The triangle is a pseudo-element so that clipping it doesn't clip the button's focus ring. */
.point::before {
  content: ""; position: absolute; inset: 0 0 auto; block-size: 89%;
  --p: var(--point-a);
  background: linear-gradient(var(--p), color-mix(in oklab, var(--p), black 18%));
  clip-path: polygon(4% 0, 96% 0, 50% 100%);
}
.point.bottom::before { inset: auto 0 0; clip-path: polygon(4% 100%, 96% 100%, 50% 0); background: linear-gradient(color-mix(in oklab, var(--p), black 18%), var(--p)); }
.point.alt::before { --p: var(--point-b); }
.point.target::before { filter: brightness(1.25) saturate(1.2); }
.off-spot.target { background: rgb(255 255 255 / .16); }

.ghosts, .pieces, .dice { position: absolute; inset: 0; pointer-events: none; }

.chk, .landing, .die {
  position: absolute; inset-inline-start: 0; inset-block-start: 0;
  translate: calc(var(--x) * var(--k)) calc(var(--y) * var(--k));
}
.chk {
  --c: var(--chip-a);
  inline-size: calc(84 * var(--k)); block-size: calc(84 * var(--k)); border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 40%, color-mix(in oklab, var(--c), black 22%) 42% 50%, transparent 52%),
    radial-gradient(circle at 35% 30%, color-mix(in oklab, var(--c), white 45%), var(--c) 55%, color-mix(in oklab, var(--c), black 28%));
  box-shadow:
    inset 0 0 0 calc(2.500 * var(--k)) color-mix(in oklab, var(--c), black 38%),
    0 calc(3 * var(--k)) calc(7 * var(--k)) rgb(0 0 0 / .5);
  transition:
    translate .5s cubic-bezier(.45, .05, .2, 1),
    inline-size .5s, block-size .5s, border-radius .5s, box-shadow .2s, scale .2s;
  @media (prefers-reduced-motion: reduce) { transition: box-shadow .2s; }
}
.chk.b { --c: var(--chip-b); }
/* Borne off: the checker turns on its edge and stacks in the tray. */
.chk.off {
  inline-size: calc(100 * var(--k)); block-size: calc(22 * var(--k)); border-radius: calc(7 * var(--k));
  background: linear-gradient(color-mix(in oklab, var(--c), white 35%), var(--c) 45%, color-mix(in oklab, var(--c), black 35%));
}
.chk.hot {
  box-shadow:
    inset 0 0 0 calc(2.500 * var(--k)) color-mix(in oklab, var(--c), black 38%),
    0 0 0 calc(4 * var(--k)) #fff, 0 0 calc(18 * var(--k)) calc(6 * var(--k)) rgb(255 255 255 / .55);
}
.chk.sel {
  scale: 1.1;
  box-shadow:
    inset 0 0 0 calc(2.500 * var(--k)) color-mix(in oklab, var(--c), black 38%),
    0 0 0 calc(6 * var(--k)) var(--sun), 0 calc(10 * var(--k)) calc(22 * var(--k)) rgb(0 0 0 / .55);
}
.board.still .chk, .board.still .die { transition: none; }

.landing {
  inline-size: calc(84 * var(--k)); block-size: calc(84 * var(--k)); border-radius: 50%;
  border: calc(5 * var(--k)) dashed #fff; background: rgb(255 255 255 / .28);
  box-shadow: 0 0 calc(16 * var(--k)) rgb(255 255 255 / .5);
}
.landing.off { inline-size: calc(100 * var(--k)); block-size: calc(22 * var(--k)); border-radius: calc(7 * var(--k)); border-width: calc(3 * var(--k)); }
@media (prefers-reduced-motion: no-preference) {
  .landing { animation: pop .25s ease-out; }
  @keyframes pop { from { scale: .5; opacity: 0; } }
}

/* ── Dice ── */
.die {
  inline-size: calc(76 * var(--k)); block-size: calc(76 * var(--k)); border-radius: calc(16 * var(--k));
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: calc(11 * var(--k)); gap: calc(3 * var(--k));
  background: linear-gradient(145deg, #fff, #ece6ff 70%, #cfc4f5);
  box-shadow: inset 0 calc(-4 * var(--k)) 0 rgb(60 40 120 / .22), 0 calc(6 * var(--k)) calc(12 * var(--k)) rgb(0 0 0 / .45);
  transition: translate .45s cubic-bezier(.45, .05, .2, 1), opacity .25s;
  @media (prefers-reduced-motion: reduce) { transition: opacity .25s; }
}
.die i { border-radius: 50%; background: #2a1f47; opacity: 0; }
.die[data-v="1"] i:nth-child(5),
.die[data-v="2"] i:is(:nth-child(1), :nth-child(9)),
.die[data-v="3"] i:is(:nth-child(1), :nth-child(5), :nth-child(9)),
.die[data-v="4"] i:is(:nth-child(1), :nth-child(3), :nth-child(7), :nth-child(9)),
.die[data-v="5"] i:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7), :nth-child(9)),
.die[data-v="6"] i:is(:nth-child(1), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9)) { opacity: 1; }
.die.used { opacity: .4; }
@media (prefers-reduced-motion: no-preference) {
  .die.tumble { animation: tumble .75s cubic-bezier(.3, .6, .4, 1); }
  .die.tumble:nth-child(even) { animation-name: tumble-b; }
  @keyframes tumble {
    0% { rotate: -200deg; scale: .6; translate: calc((var(--x) - 130) * var(--k)) calc((var(--y) - 170) * var(--k)); }
    45% { scale: 1.2; translate: calc((var(--x) - 30) * var(--k)) calc((var(--y) + 26) * var(--k)); }
    70% { rotate: 20deg; scale: .96; translate: calc((var(--x) + 8) * var(--k)) calc((var(--y) - 22) * var(--k)); }
    100% { rotate: 0deg; scale: 1; }
  }
  @keyframes tumble-b {
    0% { rotate: 240deg; scale: .6; translate: calc((var(--x) + 150) * var(--k)) calc((var(--y) - 190) * var(--k)); }
    50% { scale: 1.18; translate: calc((var(--x) + 26) * var(--k)) calc((var(--y) + 30) * var(--k)); }
    75% { rotate: -16deg; scale: .96; translate: calc((var(--x) - 6) * var(--k)) calc((var(--y) - 18) * var(--k)); }
    100% { rotate: 0deg; scale: 1; }
  }
}

/* ── Game over ── */
.over {
  position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: .6rem;
  border-radius: 2.2% / 3.3%; overflow: hidden; text-align: center; color: #fff;
  background: rgb(20 12 50 / .72); backdrop-filter: blur(3px);
}
.over-title { font-size: clamp(1.6rem, 5vw, 3rem); font-weight: 900; }
.over-sub { font-size: 1.1rem; margin-block-end: .5rem; }
.over > :not(.confetti) { position: relative; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .confetti i {
    display: block; position: absolute; inset-block-start: -6%; inset-inline-start: var(--left);
    inline-size: .6rem; block-size: 1rem; border-radius: 3px;
    animation: fall 2.6s var(--delay) cubic-bezier(.3, .2, .6, 1) both;
  }
  @keyframes fall { 80% { opacity: 1; } to { translate: 0 80vh; rotate: var(--spin); opacity: 0; } }
}

/* ── Side panel: video and chat ── */
.side { display: grid; gap: .8rem; padding: .9rem; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.side > *, .social > *, .chat > * { min-inline-size: 0; }
.videos { position: relative; display: grid; gap: .5rem; }
.videos[data-them="off"][data-me="off"], .videos[data-them="off"][data-me="mic"] { display: none; }
.tile { position: relative; border-radius: 18px; overflow: hidden; background: #0d0a1c; aspect-ratio: 4 / 3; }
.tile video { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
.tile.me video { transform: scaleX(-1); }
.tile-note { position: absolute; inset: 0; display: none; place-items: center; color: #fff; font-weight: 700; }
.videos[data-them="mic"] .tile-note { display: grid; }
.videos[data-them="off"] .tile.them { display: none; }
.videos:not([data-me="cam"]) .tile.me { display: none; }
/* Both on: yours tucks into the corner of theirs. */
.videos:not([data-them="off"])[data-me="cam"] .tile.me {
  position: absolute; inset-block-end: .5rem; inset-inline-end: .5rem; inline-size: 34%;
  border: 2px solid #fff; border-radius: 12px;
}
.media-row { display: flex; gap: .5rem; }
.media-row .btn { flex: 1; }

.chat { display: grid; gap: .5rem; }
.chat-title { font-size: 1rem; font-weight: 800; }
.chat-log {
  list-style: none; padding: .2rem; display: flex; flex-direction: column; gap: .35rem;
  block-size: clamp(6rem, 26dvh, 16rem); overflow-y: auto; overscroll-behavior: contain; border-radius: 12px;
}
.chat-log:empty { display: none; }
.chat-log li { max-inline-size: 85%; padding: .35rem .75rem; border-radius: 16px; overflow-wrap: anywhere; background: var(--surface-2); align-self: start; border-end-start-radius: 4px; }
.chat-log li.me { align-self: end; background: var(--violet); color: light-dark(#fff, #17122b); border-end-start-radius: 16px; border-end-end-radius: 4px; }
.chat-empty { color: var(--ink-soft); font-size: .9rem; }
.chat-form { display: flex; gap: .5rem; }
.chat-form input { min-block-size: 2.3rem; }

/* ── Dialogs ── */
dialog.sheet {
  inline-size: min(26rem, calc(100vw - 2rem)); max-block-size: calc(100dvh - 2rem);
  padding: 1.5rem; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: .25s; transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
  @media (prefers-reduced-motion: no-preference) { transform: translateY(14px) scale(.96); }
  @media (prefers-reduced-motion: reduce) { transition-duration: .1s; }
}
dialog.sheet.wide { inline-size: min(36rem, calc(100vw - 2rem)); }
dialog.sheet[open]:where(:not([data-closing])) {
  opacity: 1;
  @starting-style { opacity: 0; }
  @media (prefers-reduced-motion: no-preference) {
    transform: none;
    @starting-style { transform: translateY(14px) scale(.96); }
  }
  &::backdrop {
    background-color: rgb(20 12 50 / .55);
    @starting-style { background-color: transparent; }
  }
}
dialog.sheet::backdrop {
  background-color: transparent;
  transition-property: background-color, display, overlay;
  transition-duration: .25s;
  transition-behavior: allow-discrete;
  overflow: hidden; overscroll-behavior: contain;
}
dialog.sheet:modal { overscroll-behavior: contain; }
dialog.sheet[open] { display: grid; gap: .9rem; }
.sheet h2 { font-size: 1.5rem; font-weight: 900; }
.sheet h3 { font-size: 1.05rem; font-weight: 800; margin-block-start: .3rem; }
.sheet :is(ol, ul) { padding-inline-start: 1.3rem; display: grid; gap: .3rem; }
.sheet legend { font-weight: 800; padding: 0; margin-block-end: .5rem; }
.sheet-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-block-start: .4rem; }
.help { font-size: .85rem; color: var(--ink-soft); }

.theme-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.theme {
  display: inline-flex; align-items: center; gap: .5rem; min-block-size: 2.5rem; padding: .25rem .9rem .25rem .3rem;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; cursor: pointer;
}
.theme[aria-pressed="true"] { border-color: var(--violet); background: var(--surface-2); }
.theme-swatch {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  inline-size: 2.6rem; block-size: 1.8rem; border-radius: 999px;
  background: linear-gradient(90deg, var(--point-a) 0 22%, var(--felt) 22% 78%, var(--point-b) 78%);
  border: 2px solid var(--frame);
}
.theme-swatch i { inline-size: .7rem; block-size: .7rem; border-radius: 50%; background: var(--chip-a); box-shadow: 0 0 0 1px rgb(0 0 0 / .3); }
.theme-swatch i + i { background: var(--chip-b); }

.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem .9rem; }
.colors legend { grid-column: 1 / -1; }
.colors label { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.colors input[type="color"] {
  inline-size: 2.6rem; block-size: 2.6rem; padding: 0; border: 2px solid var(--line); border-radius: 12px;
  background: none; cursor: pointer; flex: none;
}

/* ── Toast ── */
.toast {
  position: fixed; inset: auto 0 max(1.2rem, env(safe-area-inset-bottom)); margin: 0 auto;
  inline-size: fit-content; max-inline-size: calc(100vw - 2rem);
  padding: .6rem 1.1rem; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow);
}
.toast:not([popover]) { display: none; z-index: 10; }
.toast.show { display: block; }
.toast[popover] {
  opacity: 0;
  transition-property: opacity, display, overlay;
  transition-duration: .2s;
  transition-behavior: allow-discrete;
}
.toast:popover-open {
  opacity: 1;
  @starting-style { opacity: 0; }
}

/* Copyright notice at the foot of the page. */
.copyright { margin: 0; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); text-align: center; font-size: 0.8rem; color: var(--ink-soft); }
/* Only on the start screen: during a game or call the main view fills the window. */
body:has(#lobby[hidden]) .copyright { display: none; }

/* ── Direction of play ── */
.direction { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; }
.direction legend { padding: 0; margin-block-end: .5rem; }
.dir-option {
  position: relative; display: flex; align-items: center; gap: .6rem;
  padding: .55rem .8rem; border: 2px solid var(--line); border-radius: 18px; cursor: pointer;
  line-height: 1.3; transition: border-color .15s, background-color .15s;
}
.dir-option small { color: var(--ink-soft); font-size: .8rem; }
.dir-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.dir-option:has(input:checked) { border-color: var(--violet); background: var(--surface-2); }
.dir-option:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 3px; }
.dir-icon { font-size: 1.6rem; line-height: 1; color: var(--violet); flex: none; }

/* ── Playing the computer ── */
.levels legend { font-weight: 800; padding: 0; margin-block-end: .6rem; }
.level-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.level {
  position: relative; display: inline-flex; align-items: center; gap: .35rem;
  min-block-size: 2.4rem; padding: .3rem .85rem; border: 2px solid var(--line); border-radius: 999px;
  font-weight: 700; font-size: .92rem; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.level input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.level:has(input:checked) { border-color: var(--violet); background: var(--surface-2); }
.level:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 3px; }
.level .bars { display: inline-flex; align-items: end; gap: 2px; block-size: .8rem; }
.level .bars i { inline-size: 3px; border-radius: 2px; background: var(--line); }
.level .bars i:nth-child(1) { block-size: 30%; }
.level .bars i:nth-child(2) { block-size: 47%; }
.level .bars i:nth-child(3) { block-size: 64%; }
.level .bars i:nth-child(4) { block-size: 82%; }
.level .bars i:nth-child(5) { block-size: 100%; }
.level .bars i.on { background: var(--violet); }
.level-blurb { margin-block-start: .5rem; font-size: .88rem; color: var(--ink-soft); min-block-size: 1.3em; }
.cpu-btn { border-color: var(--violet); }
.solo-note { font-weight: 700; }
.solo-note small { display: block; font-weight: 500; color: var(--ink-soft); }
.social { display: grid; gap: .8rem; }
#setup { display: grid; gap: 1rem; }
#setup > * { min-inline-size: 0; }

/* Back to the list of all of Marc's apps, on its own line under the credit. */
.apps-link { display: block; inline-size: fit-content; margin-block-start: 0.15rem; white-space: nowrap; }
.apps-link svg { display: inline; inline-size: 1.05em; block-size: 1.05em; margin-inline-end: 0.25em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Appearance: the setting writes <meta name="color-scheme">; map it back so light-dark() follows it. */
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
/* The background blobs are fainter in dark mode, whichever way it was chosen. */
:root:has(> head > meta[name="color-scheme"][content="light"]) .blobs i { opacity: .5; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .blobs i { opacity: .16; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.segmented label { position: relative; display: grid; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-block-size: 2.5rem; padding: 0 .4rem; border-radius: 999px; font-weight: 700; font-size: .92rem; color: var(--ink-soft); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.segmented input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 1px; }
