/* 檀木金石 — the page around the board, shared by every heirloom game
   (象棋, 大老二, 暗棋, 麻將). The scene is the lab's Heirloom set under its
   lamp; the chrome is made of the same things: night, brass hairlines with
   an inner rule like the engraved plaques, ivory lettering, cinnabar for
   alarms. A game adds its own few rules in its own css/. */

:root {
  --night: #140E0A;
  --panel: rgba(21, 14, 10, 0.8);
  --panel-solid: #1A120C;
  --ivory: #EFE6D2;
  --ivory-dim: rgba(239, 230, 210, 0.7);
  --ivory-faint: rgba(239, 230, 210, 0.42);
  --brass: #C9A45C;
  --brass-bright: #E2C47E;
  --brass-line: rgba(201, 164, 92, 0.4);
  --brass-faint: rgba(201, 164, 92, 0.16);
  --cinnabar: #9E1B1B;
  --cinnabar-bright: #D1452F;
  --lamp: #FFD9A0;
  --ink: #1A0F08;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --caps: "Cinzel", "Noto Serif TC", serif;
  --brass-fill: linear-gradient(180deg, #F2DCA2 0%, #D7B067 46%, #AD8038 100%);
  --rule: inset 0 0 0 3px rgba(20, 14, 10, 0.55), inset 0 0 0 4px rgba(201, 164, 92, 0.14);
  --top-safe: env(safe-area-inset-top, 0px);
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --left-safe: env(safe-area-inset-left, 0px);
  --right-safe: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night);
  color: var(--ivory);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  /* the page's box: the layout below asks it (@container, cqw), not the
     screen, so it holds when the page is turned */
  container: page / size;
}
/* turned against the screen while it rotates (js/ui.js turnPage): the body
   is the screen's box turned with it, and the safe areas turn too */
:root[data-turn] body {
  position: fixed; left: 50%; top: 50%; width: var(--page-w); height: var(--page-h);
  transform: translate(-50%, -50%) rotate(var(--turn));
}
:root[data-turn="90"] { --turn: 90deg; --top-safe: env(safe-area-inset-right, 0px); --bottom-safe: env(safe-area-inset-left, 0px); --left-safe: env(safe-area-inset-top, 0px); --right-safe: env(safe-area-inset-bottom, 0px); }
:root[data-turn="180"] { --turn: 180deg; --top-safe: env(safe-area-inset-bottom, 0px); --bottom-safe: env(safe-area-inset-top, 0px); --left-safe: env(safe-area-inset-right, 0px); --right-safe: env(safe-area-inset-left, 0px); }
:root[data-turn="270"] { --turn: 270deg; --top-safe: env(safe-area-inset-left, 0px); --bottom-safe: env(safe-area-inset-right, 0px); --left-safe: env(safe-area-inset-bottom, 0px); --right-safe: env(safe-area-inset-top, 0px); }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

.stage { position: fixed; inset: 0; }

.title { font-weight: 900; letter-spacing: 0.32em; margin-right: -0.32em; }
.caps { font-family: var(--caps); font-weight: 600; text-transform: uppercase; letter-spacing: 0.42em; margin-right: -0.42em; color: var(--brass); }

/* ---------------------------------------------------------------- veil */
.veil {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 42%, #23170F 0%, var(--night) 60%, #070504 100%);
  transition: opacity 0.9s ease, visibility 0.9s;
}
.veil.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.veil-title { text-align: center; width: min(440px, 100%); }
.veil-game { margin: 0 0 18px; font-size: clamp(40px, 8cqw, 64px); font-weight: 900; letter-spacing: .2em; text-indent: .2em; text-shadow: 0 0 40px rgba(255, 217, 160, 0.15); }
.veil-title .title { font-size: 22px; color: var(--ivory-dim); }
.veil-title .caps { margin-top: 12px; font-size: 13px; }
.veil-note { margin: 28px 0 0; font-size: 14px; letter-spacing: 0.1em; color: var(--ivory-dim); }

/* ---------------------------------------------------------------- shared pieces */
.panel {
  background: var(--panel);
  border: 1px solid var(--brass-line);
  border-radius: 16px;
  box-shadow: var(--rule), 0 24px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 20px;
  font-weight: 600; font-size: 15px; letter-spacing: 0.14em;
  border-radius: 999px; border: 1px solid var(--brass-line);
  background: rgba(239, 230, 210, 0.04);
  cursor: pointer; white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.08s, opacity 0.18s;
}
.btn:hover { border-color: var(--brass-bright); background: rgba(226, 196, 126, 0.1); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }
.btn:disabled { opacity: 0.38; cursor: default; pointer-events: none; }
.btn.primary {
  color: var(--ink); border-color: #F5E0A8;
  background: var(--brass-fill);
  text-shadow: 0 1px 0 rgba(255, 244, 214, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(90, 58, 20, 0.35), 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 26px rgba(255, 217, 160, 0.12);
}
.btn.primary:hover { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(90, 58, 20, 0.35), 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 34px rgba(255, 217, 160, 0.3); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ivory-dim); }
.btn.ghost:hover { color: var(--ivory); background: rgba(239, 230, 210, 0.06); }
.btn.quiet { border-style: dashed; color: var(--ivory-dim); }
.btn.alarm { border-color: rgba(209, 69, 47, 0.6); color: #F3C9BC; }
.btn.alarm:hover { background: rgba(158, 27, 27, 0.25); border-color: var(--cinnabar-bright); }
.btn.small { min-height: 34px; padding: 6px 14px; font-size: 13px; letter-spacing: 0.1em; }
.btn.wide { width: 100%; }

.seg { display: flex; flex: 1; padding: 3px; gap: 3px; border: 1px solid var(--brass-line); border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
.seg button {
  flex: 1; min-height: 36px; padding: 6px 8px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ivory-dim); font-size: 14px; font-weight: 600; letter-spacing: 0.08em; cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.seg button:hover { color: var(--ivory); }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--brass-fill); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); }

.label { font-size: 13px; letter-spacing: 0.18em; color: var(--ivory-faint); }
input {
  width: 100%; min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--brass-line); background: rgba(0, 0, 0, 0.35);
  font-size: 16px; letter-spacing: 0.06em;
}
input::placeholder { color: var(--ivory-faint); }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.buttons .btn { flex: 1 1 auto; }

/* ---------------------------------------------------------------- lobby */
.lobby {
  position: fixed; z-index: 10; top: calc(16px + var(--top-safe)); bottom: calc(16px + var(--bottom-safe)); right: 18px;
  width: min(410px, 42cqw); display: flex; flex-direction: column; justify-content: center;
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.lobby-panel {
  max-height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--brass-faint) transparent;
  padding: 22px 20px 16px; display: flex; flex-direction: column; gap: 12px;
}
.brand { text-align: center; margin-bottom: 4px; }
.brand .title { margin: 0; font-size: clamp(23px, 2.6cqw, 30px); line-height: 1.5; letter-spacing: .08em; text-shadow: 0 0 30px rgba(255, 217, 160, 0.16); }
.brand .title > span { display: inline-block; white-space: nowrap; }
.brand .caps { margin: 10px 0 0; font-size: 11px; }
.brand .tagline { margin: 12px 0 0; font-size: 14px; line-height: 1.7; color: var(--ivory-dim); letter-spacing: 0.04em; }
/* the lobby's screens (js/lobby.js): the ways to play, then the choices of one */
.screen { display: flex; flex-direction: column; gap: 12px; animation: screen-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes screen-in { from { opacity: 0; transform: translateX(12px); } }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "icon title go" "icon note go";
  align-items: center; column-gap: 14px; row-gap: 3px;
  width: 100%; min-height: 72px; padding: 12px 16px 12px 12px; text-align: left;
  border: 1px solid var(--brass-line); border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 228, 180, 0.06), rgba(0, 0, 0, 0.18));
  box-shadow: var(--rule); cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s, transform 0.08s;
}
.choice:hover { border-color: var(--brass-bright); background: linear-gradient(180deg, rgba(255, 228, 180, 0.11), rgba(0, 0, 0, 0.12)); box-shadow: var(--rule), 0 0 26px rgba(255, 217, 160, 0.14); }
.choice:active { transform: translateY(1px); }
.choice:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }
.choice .icon {
  grid-area: icon; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  color: var(--ink); background: var(--brass-fill);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(90, 58, 20, 0.3), 0 4px 12px rgba(0, 0, 0, 0.45);
}
.choice .icon svg { width: 25px; height: 25px; }
.choice b { grid-area: title; display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 900; letter-spacing: 0.3em; }
.choice small { grid-area: note; font-size: 13px; line-height: 1.5; color: var(--ivory-faint); letter-spacing: 0.06em; }
.choice::after { content: "›"; grid-area: go; font-size: 26px; line-height: 1; color: var(--brass); }
.badge {
  padding: 2px 8px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--ink); background: var(--brass-fill);
}
/* a screen's head: back on the left, its name in the middle */
.step { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: -6px -8px 4px; }
.step .btn { justify-self: start; padding-left: 10px; }
.step h2 { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: 0.32em; margin-right: -0.32em; color: var(--brass-bright); }
.row { display: flex; align-items: center; gap: 12px; }
.row > .label { flex: none; width: 3em; }
.field { display: flex; flex-direction: column; gap: 6px; }
.hint { margin: -4px 2px 0; font-size: 12px; line-height: 1.6; letter-spacing: 0.06em; color: var(--ivory-faint); }

/* the rooms open now: tap one to sit down, or watch */
.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  width: 100%; min-height: 58px; padding: 8px 8px 8px 14px; text-align: left;
  border: 1px solid var(--brass-faint); border-radius: 14px; background: rgba(0, 0, 0, 0.22);
  cursor: pointer; transition: border-color 0.18s, background 0.18s, transform 0.08s;
}
.room-row:hover { border-color: var(--brass-line); background: rgba(226, 196, 126, 0.07); }
.room-row:active { transform: translateY(1px); }
.room-row:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }
.room-code { width: 4.3em; font-family: var(--caps); font-size: 16px; letter-spacing: 0.16em; color: var(--brass-bright); }
.room-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-who b { font-size: 15px; font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-who small { font-size: 12px; line-height: 1.5; color: var(--ivory-faint); letter-spacing: 0.06em; }
.room-go {
  min-width: 4.2em; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--brass-line); text-align: center;
  font-size: 13px; font-weight: 600; letter-spacing: 0.12em; color: var(--ivory-dim);
}
.room-row.open { border-color: var(--brass-line); }
.room-row.open .room-go { color: var(--ink); border-color: #F5E0A8; background: var(--brass-fill); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.room-empty {
  margin: 0; padding: 20px 12px; text-align: center; font-size: 13px; line-height: 1.8; letter-spacing: 0.06em; color: var(--ivory-faint);
  border: 1px dashed var(--brass-faint); border-radius: 14px;
}
/* 快速配對 (js/quick.js): a seat for each at the table, lit as people come */
.quick-wait {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 14px 20px; text-align: center;
  border: 1px solid var(--brass-faint); border-radius: 16px; background: rgba(0, 0, 0, 0.22); box-shadow: var(--rule);
}
.quick-seats { display: flex; gap: 12px; margin-bottom: 6px; }
.quick-seats i {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px dashed var(--brass-line); background: rgba(239, 230, 210, 0.05);
  animation: quick-wait 1.8s ease-in-out infinite;
}
.quick-seats i:nth-child(2) { animation-delay: 0.3s; }
.quick-seats i:nth-child(3) { animation-delay: 0.6s; }
.quick-seats i:nth-child(4) { animation-delay: 0.9s; }
.quick-seats i.here {
  border: 1px solid #F5E0A8; background: var(--brass-fill); animation: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 0 16px rgba(255, 217, 160, 0.25);
}
@keyframes quick-wait { 50% { border-color: var(--brass-bright); box-shadow: 0 0 14px rgba(255, 217, 160, 0.18); } }
.quick-title { font-size: 17px; font-weight: 900; letter-spacing: 0.2em; margin-right: -0.2em; color: var(--brass-bright); }
.quick-note { min-height: 1.6em; font-size: 13px; line-height: 1.6; letter-spacing: 0.06em; color: var(--ivory-dim); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .quick-seats i { animation: none; } }

/* the button under a list that may be long: it stays at the bottom of the panel */
.dock { position: sticky; bottom: -16px; margin: 0 -20px -16px; padding: 10px 20px 16px; background: linear-gradient(180deg, rgba(21, 14, 10, 0), rgba(21, 14, 10, 0.94) 38%); }
.rules { margin: 2px 4px 0; font-size: 12px; line-height: 1.8; color: var(--ivory-faint); letter-spacing: 0.04em; }
.back {
  position: fixed; z-index: 10; left: 18px; top: calc(16px + var(--top-safe));
  color: var(--ivory-faint); font-size: 13px; letter-spacing: 0.16em; text-decoration: none;
}
.back:hover { color: var(--brass-bright); }
.lobby[hidden] ~ .back { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------------------------------------------------------------- in a game */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.bar {
  position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 12px;
  padding: 12px calc(16px + var(--right-safe)) 12px calc(16px + var(--left-safe)); pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar.top { top: 0; padding-top: calc(12px + var(--top-safe)); background: linear-gradient(180deg, rgba(8, 5, 3, 0.7), rgba(8, 5, 3, 0)); }
.bar.bottom { bottom: 0; padding-bottom: calc(14px + var(--bottom-safe)); justify-content: space-between; background: linear-gradient(0deg, rgba(8, 5, 3, 0.72), rgba(8, 5, 3, 0)); }

.status {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: calc(100cqw - 32px); padding: 9px 22px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--brass-line); box-shadow: var(--rule);
  font-size: 15px; font-weight: 600; letter-spacing: 0.16em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.status:empty { display: none; }
.status.yours { color: var(--ink); border-color: #F5E0A8; background: var(--brass-fill); box-shadow: 0 0 28px rgba(255, 217, 160, 0.28); }
.status.alarm { color: #FFE2D6; border-color: rgba(209, 69, 47, 0.75); background: rgba(92, 16, 12, 0.85); box-shadow: 0 0 28px rgba(209, 69, 47, 0.35); }

.player {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 5px 16px 5px 5px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--brass-line); box-shadow: var(--rule);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.player:empty { display: none; }
.player.active { border-color: var(--brass-bright); box-shadow: var(--rule), 0 0 0 1px rgba(226, 196, 126, 0.35), 0 0 26px rgba(255, 217, 160, 0.22); }
.disc {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 36% 30%, #FFF8E8 0%, #EADBB9 55%, #CDB78C 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25), inset 0 0 0 4.5px currentColor, inset 0 -3px 4px rgba(80, 50, 20, 0.25), 0 3px 6px rgba(0, 0, 0, 0.5);
  font-size: 19px; font-weight: 900; line-height: 1; color: #2A1B10;
}
.disc.red { color: var(--cinnabar); }
.disc.black { color: #1B1712; }
.disc.down { color: rgba(90, 46, 31, 0.55); font-family: var(--caps); }
/* an ebony piece (西洋棋's black), and the stones of 圍棋 and 五子棋 (slate and shell) */
.disc.ebony {
  color: #EFE3C8; background: radial-gradient(circle at 36% 30%, #5E4B3B 0%, #251A12 55%, #0E0906 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.07), inset 0 0 0 4.5px rgba(226, 196, 126, 0.55), inset 0 -3px 4px rgba(0, 0, 0, 0.4), 0 3px 6px rgba(0, 0, 0, 0.5);
}
.disc.slate, .disc.shell { font-size: 15px; font-family: var(--caps); }
.disc.slate {
  color: rgba(239, 230, 210, 0.75); background: radial-gradient(circle at 34% 28%, #707070 0%, #2A2A2A 28%, #0C0C0C 68%, #000 100%);
  box-shadow: inset 0 -2px 4px rgba(255, 255, 255, 0.06), 0 3px 6px rgba(0, 0, 0, 0.55);
}
.disc.shell {
  color: rgba(40, 30, 20, 0.7); background: radial-gradient(circle at 34% 28%, #FFFFFF 0%, #F5F1E7 34%, #DDD6C5 78%, #BDB4A0 100%);
  box-shadow: inset 0 -2px 4px rgba(120, 100, 70, 0.25), 0 3px 6px rgba(0, 0, 0, 0.5);
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who b { font-size: 15px; font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
.who small { font-size: 12px; color: var(--ivory-faint); letter-spacing: 0.08em; white-space: nowrap; }
.who small.warn { color: #F0A58F; }
.thinking .who small::after { content: "…"; display: inline-block; width: 1.2em; animation: breathe 1.2s ease-in-out infinite; }

.room-chip {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--brass-line); box-shadow: var(--rule);
}
.room-chip b { font-family: var(--caps); font-size: 17px; letter-spacing: 0.24em; color: var(--brass-bright); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }
/* Shared touch orientation lock and music controls. */
.btn.icon { width: 40px; min-height: 34px; padding: 0; color: var(--ivory-dim); }
.btn.icon svg { width: 22px; height: 22px; }
.btn.icon .lock { opacity: 0; transition: opacity 0.2s; }
.btn.icon[aria-pressed="true"] { color: var(--brass-bright); border-color: var(--brass-line); background: var(--panel); }
.btn.icon[aria-expanded="true"] { color: var(--brass-bright); }
.btn.icon[aria-pressed="true"] .lock { opacity: 1; }
.btn.icon[aria-pressed="true"] .turn { opacity: 0.35; }
.actions .btn:not(.primary) { background: var(--panel); }

/* ---------------------------------------------------------------- panels over the board */
.waiting, .over {
  position: fixed; z-index: 20; left: 50%; bottom: calc(86px + var(--bottom-safe));
  width: min(440px, calc(100cqw - 24px)); transform: translateX(-50%);
  padding: 22px 22px 20px; text-align: center;
  animation: lift 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.waiting h2, .over h2, .dialog h2, .fatal h2 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: 0.24em; }
.waiting p, .over p, .dialog p, .fatal p { margin: 10px 0 16px; font-size: 14px; line-height: 1.8; color: var(--ivory-dim); letter-spacing: 0.05em; }
.big-code { font-family: var(--caps); font-size: 46px; letter-spacing: 0.36em; margin: 4px -0.36em 2px 0; color: var(--brass-bright); text-shadow: 0 0 26px rgba(255, 217, 160, 0.25); }
.link { margin-bottom: 16px; font-size: 12px; color: var(--ivory-faint); word-break: break-all; user-select: all; }
.over h2 { font-size: 30px; letter-spacing: 0.3em; margin-right: -0.3em; }
.over h2.won { color: var(--brass-bright); text-shadow: 0 0 30px rgba(255, 217, 160, 0.35); }
@keyframes lift { from { opacity: 0; transform: translate(-50%, 16px); } }

.toasts {
  position: fixed; z-index: 30; left: 50%; top: calc(70px + var(--top-safe)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  width: min(460px, calc(100cqw - 24px));
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  padding: 10px 18px; border-radius: 14px; font-size: 14px; letter-spacing: 0.08em; text-align: center;
  animation: drop 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.toast.leaving { opacity: 0; transform: translateY(-8px); transition: opacity 0.3s, transform 0.3s; }
.toast .buttons { gap: 8px; }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }

.dialog-back { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5, 3, 2, 0.55); backdrop-filter: blur(3px); }
.dialog { width: min(400px, 100%); padding: 24px 22px 20px; text-align: center; }
.fatal { position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100cqw - 24px)); padding: 26px 22px; text-align: center; }

/* ---------------------------------------------------------------- the table games (大老二, 暗棋, 麻將) */
/* the seats while a room gathers */
.seats {
  position: fixed; z-index: 20; left: 50%; bottom: calc(86px + var(--bottom-safe));
  width: min(460px, calc(100cqw - 24px)); transform: translateX(-50%);
  padding: 20px 20px 18px; text-align: center;
  animation: lift 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.seats h2 { margin: 0; font-size: 21px; font-weight: 900; letter-spacing: 0.24em; }
.seats .big-code { font-size: 36px; margin-top: 6px; }
.seats .link { margin-bottom: 12px; }
.seat-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; text-align: left; }
.seat-row {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 8px 6px 6px;
  border: 1px solid var(--brass-faint); border-radius: 14px; background: rgba(0, 0, 0, 0.2);
}
.seat-row.you { border-color: var(--brass-line); background: rgba(226, 196, 126, 0.07); }
.seat-row.empty { border-style: dashed; }
.seat-no {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--caps); font-size: 15px; color: var(--ink); background: var(--brass-fill);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.seat-row.empty .seat-no { background: rgba(239, 230, 210, 0.08); color: var(--ivory-faint); box-shadow: none; }
.seat-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.seat-name b { font-size: 15px; font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-name small { font-size: 12px; color: var(--ivory-faint); letter-spacing: 0.08em; }
.seat-row.empty .seat-name b { color: var(--ivory-faint); font-weight: 400; }
.seats .note { margin: 0 0 14px; font-size: 13px; line-height: 1.7; color: var(--ivory-dim); letter-spacing: 0.05em; }

/* the running scores along the bottom */
.scores { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.score {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--brass-faint); box-shadow: var(--rule);
  font-size: 13px; letter-spacing: 0.06em; white-space: nowrap;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.score i { font-style: normal; color: var(--ivory-dim); max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
.score b { font-family: var(--caps); font-size: 14px; color: var(--brass-bright); letter-spacing: 0.04em; }
.score.you i { color: var(--ivory); }
.score.active { border-color: var(--brass-bright); box-shadow: var(--rule), 0 0 18px rgba(255, 217, 160, 0.2); }
.score.away i { color: #F0A58F; }
.score.round { background: transparent; border-color: transparent; box-shadow: none; }
.score.round i { max-width: none; }

/* a player's avatar left of their name (common/player-avatar.js): in the lobby's rooms, the seats, the plates and the
   scores, a brass-rimmed coin standing on the bottom of the name's letters (text-bottom: the same for a picture and an
   emoji, whose own baselines differ), inside its line (the names clip what overflows, for the ellipsis) */
.room-who b .player-avatar, .seat-name b .player-avatar, .who b .player-avatar, .score .player-avatar {
  --player-avatar-size: 1.4em; --player-avatar-gap: 0.4em; --player-avatar-ring: var(--brass-line); --player-avatar-bg: var(--ivory);
  vertical-align: text-bottom;
}
.room-who b .player-avatar ~ .player-avatar { margin-inline-start: 0.15em; }
.score .player-avatar { --player-avatar-size: 20px; --player-avatar-gap: -2px; align-self: center; font-size: 12px; }

/* the result rows on the panel at the end */
.over-rows { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; text-align: left; }
.over-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: 12px;
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--brass-faint); background: rgba(0, 0, 0, 0.18);
}
.over-row .who { font-weight: 600; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.over-row .what { font-size: 12px; color: var(--ivory-faint); letter-spacing: 0.06em; }
.over-row b { font-family: var(--caps); font-size: 18px; color: var(--ivory); min-width: 3.5em; text-align: right; }
.over-row.best { border-color: var(--brass-line); background: rgba(226, 196, 126, 0.08); }
.over-row.best b { color: var(--brass-bright); }
.over-row.you .who::after { content: "（你）"; color: var(--ivory-faint); font-weight: 400; }

/* ---------------------------------------------------------------- phones and narrow windows */
@container page (width <= 760px) or (aspect-ratio <= 4/5) {
  .lobby { top: auto; left: 10px; right: 10px; bottom: calc(10px + var(--bottom-safe)); width: auto; max-height: 62cqh; }
  .lobby-panel { padding: 20px 16px 14px; }
  .dock { bottom: -14px; margin: 0 -16px -14px; padding: 10px 16px 14px; }
  .room-row { gap: 10px; padding-left: 12px; }
  .room-code { width: 4em; font-size: 14px; letter-spacing: 0.12em; }
  .choice { min-height: 64px; }
  .brand .title { font-size: clamp(22px, 7cqw, 32px); }
  .brand .tagline { display: none; }

  .bar.top { flex-wrap: wrap; row-gap: 8px; }
  .bar.top .status { position: static; transform: none; order: 2; margin: 0 auto; }
  .bar.top #leave { order: 1; }
  .bar.top #orient-lock, .bar.top .music-toggle { order: 1; }
  .bar.top .room-chip { order: 3; margin-left: 0; }
  .bar.top .player { order: 4; flex-basis: auto; margin: 0 auto; }
  .bar.bottom { flex-wrap: wrap; row-gap: 10px; justify-content: center; }
  .bar.bottom .player { margin: 0 auto; }
  .actions { margin: 0 auto; justify-content: center; }
  .room-chip b { font-size: 15px; }
  .big-code { font-size: 40px; }
  .waiting, .over, .seats { bottom: calc(118px + var(--bottom-safe)); }
  .seats .big-code { font-size: 30px; }
  .bar.bottom .scores { justify-content: center; }
}
@container page (width <= 400px) {
  .bar.top .room-chip .label { display: none; }
  .actions .btn.small { padding: 6px 11px; letter-spacing: 0.06em; }
}

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