:root {
  color-scheme: dark;
  --bg: #090b1a;
  --field: #202141;
  --ink: #f8f5ff;
  --muted: #bcb7d6;
  --line: #514b7a;
  --lilac: #b88cf9;
  --mint: #85f5e4;
  --gold: #ffe3a5;
  --danger: #ffb3bd;
  --p0: #85f5e4;
  --p1: #c3a5ff;
  --p2: #ffa7b8;
  --p3: #ffda91;
  --radius: 21px;
  --avatar-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='10' r='5.5'/%3E%3Cpath d='M5.5 26.5c0-6 4.3-9 10.5-9s10.5 3 10.5 9c-6.5 2.8-14.5 2.8-21 0Z'/%3E%3C/svg%3E");
  --sound-on-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H3v6h3l5 4V5Zm4 4a4 4 0 0 1 0 6m3-9a8 8 0 0 1 0 12'/%3E%3C/svg%3E");
  --sound-off-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H3v6h3l5 4V5Zm5 5 5 5m0-5-5 5'/%3E%3C/svg%3E");
  --link-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.3' stroke-linecap='round'%3E%3Cpath d='m10 14 4-4m-5.5 6.5L7 18a3.54 3.54 0 0 1-5-5l4-4a3.54 3.54 0 0 1 5 0m4.5-1.5L17 6a3.54 3.54 0 0 1 5 5l-4 4a3.54 3.54 0 0 1-5 0'/%3E%3C/svg%3E");
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  isolation: isolate;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background:
    radial-gradient(ellipse at 15% 12%, #23204e 0, transparent 35%),
    radial-gradient(ellipse at 90% 95%, #123441 0, transparent 36%),
    var(--bg);
}

main {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px 19px calc(24px + env(safe-area-inset-bottom));
}

main::before {
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  width: 100%;
  max-width: 540px;
  height: 100dvh;
  margin: 0 auto;
  pointer-events: none;
  content: "";
  background: var(--bg) url("/art/starfield.webp") center / 100% 100% no-repeat;
  mask-image: linear-gradient(to right, transparent, black 8%, black 92%, transparent);
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
a { color: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button, summary, .back { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

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

.c0 { --c: var(--p0); }
.c1 { --c: var(--p1); }
.c2 { --c: var(--p2); }
.c3 { --c: var(--p3); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #1a1a39f5, #12142ff5);
  box-shadow: inset 0 1px 0 #b5a2ff18, 0 10px 24px #03041558;
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; }
.lbl { font-weight: 650; font-size: 14px; white-space: nowrap; }
.muted { color: var(--muted); font-size: 14px; }

.txt {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #716894;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  font-size: 16px;
  appearance: none;
}

.txt::placeholder { color: var(--muted); opacity: 1; }
.txt:focus { border-color: var(--mint); }
.txt.code { font-variant-numeric: tabular-nums; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 51px;
  padding: 9px 16px;
  border: 1px solid #dec8ff;
  border-radius: 999px;
  background: linear-gradient(180deg, #c9a5ff, #a97aee);
  box-shadow: inset 0 1px 0 #faf2ff71, 0 5px 16px #ad76ef23;
  color: #160d2a;
  font-size: 19px;
  font-weight: 800;
  transition: filter 140ms ease, transform 140ms ease;
}

.btn:hover:not(:disabled) { filter: brightness(1.09); }
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .55; }

.btn.ghost {
  min-height: 42px;
  border-color: #6ddbcf;
  border-radius: 12px;
  background: #172c3d;
  box-shadow: inset 0 0 13px #77e6d313;
  color: var(--mint);
  font-size: 15px;
}

.chip, .back {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #191a36;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover, .back:hover { border-color: var(--lilac); }
.link-icon { width: 16px; height: 16px; background: currentColor; mask: var(--link-icon) center / contain no-repeat; }

.seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #746c9d;
  border-radius: 12px;
  background: #232343;
}

.seg button {
  min-height: 39px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.seg button.on { background: var(--mint); box-shadow: inset 0 0 0 1px #bcfff6; color: #091d25; }
.seg button:hover:not(:disabled):not(.on) { background: #343258; }
.seg button:disabled { opacity: .42; }
.seg.small button { min-height: 35px; font-size: 14px; }

.orbit-art {
  display: block;
  width: 100%;
  height: auto;
  mask-image: radial-gradient(ellipse 66% 64% at 50% 49%, black 54%, transparent 100%);
}

.hero { position: relative; text-align: center; padding: 6px 0 30px; }
.hero-art {
  position: relative;
  left: 50%;
  width: min(calc(100% + 22px), 470px);
  margin-bottom: 6px;
  transform: translateX(-50%);
}
.planet-scene, .planet-scene .orbit-art { position: relative; }
.planet-scene img { display: block; width: 100%; height: auto; }
.planet-motion { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero h1, .victory h2 {
  color: #fffaff;
  font-size: clamp(42px, 13.7vw, 64px);
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1.14;
  transform: skewX(-5deg);
  text-shadow: 0 3px 0 #615087, 0 9px 24px #9b78e964;
}

.sub { margin-top: 16px; font-size: 18px; font-weight: 650; line-height: 1.55; letter-spacing: .08em; }

.launch { display: grid; gap: 15px; padding: 19px; }
.launch-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.launch-row .txt { flex: 1; }
.launch-row .lbl { min-width: 3em; }
.join-row { padding-top: 14px; border-top: 1px solid #625a883e; }
.join-row .btn { width: auto; min-width: 62px; padding-inline: 10px; }

.rules-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border-color: #a489df;
  box-shadow: inset 0 1px 0 #d6baff59, 0 0 30px #a485fe4d;
  color: var(--ink);
}
.rules-dialog::backdrop {
  background: radial-gradient(ellipse at center, #34266184, transparent 65%), #070a20bc;
}
.rules-content { padding: 20px; }
.rules-content::before {
  position: absolute;
  inset: 0 auto auto 50%;
  width: 80px;
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: 0 0 10px #ffd7838a;
  pointer-events: none;
  content: "";
}
.rules-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rules-header h2 { font-size: 22px; }
.rules-close { min-width: 36px; padding: 0; font-size: 23px; line-height: 1; }
.rules-content ol { margin: 12px 0; padding-left: 24px; color: var(--muted); }
.rules-content li + li { margin-top: 8px; }
.rules-content p { color: var(--mint); font-size: 14px; }

@media (prefers-reduced-motion: no-preference) {
  .rules-dialog {
    transition: opacity 240ms ease-out, transform 240ms cubic-bezier(.2,.7,.28,1);
  }
  .rules-dialog::backdrop { transition: opacity 240ms ease-out; }
  .rules-dialog.rules-dimmed {
    transform: translateY(12px) scale(.96);
    opacity: 0;
    transition-duration: 170ms;
  }
  .rules-dialog.rules-dimmed::backdrop { opacity: 0; transition-duration: 170ms; }
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.topbar .back { justify-self: start; }
.room-tools { display: flex; align-items: center; justify-self: end; gap: 6px; }
.sound-toggle { justify-self: end; min-width: 38px; min-height: 38px; padding: 5px 8px; color: var(--mint); }
.sound-toggle[aria-pressed="true"] { color: var(--muted); background: #111329; }
.sound-icon {
  flex: none;
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: var(--sound-on-icon) center / contain no-repeat;
}
.sound-toggle[aria-pressed="true"] .sound-icon { mask-image: var(--sound-off-icon); }
.home-help, .home-sound { position: absolute; z-index: 1; top: 0; }
.home-help { left: 0; min-width: 38px; min-height: 38px; padding: 0; color: var(--mint); font-size: 18px; }
.home-sound { right: 0; }

.roomno { font-weight: 750; font-size: clamp(16px, 5vw, 22px); white-space: nowrap; }
.roomno b, .wait-count, #inviteLink { font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.invite-action { justify-self: end; border-color: #b6fff4; background: var(--mint); color: #0a2028; }
.invite-action:hover { border-color: white; }

.entry-art { width: min(100%, 370px); margin: 12px auto 5px; }
.entry { padding: 22px; }
.entry h2 { font-size: 26px; font-weight: 800; }
#enter[data-mode="full"] #enterMsg, #enter[data-mode="gone"] #enterMsg { color: var(--danger); }

.conn {
  margin-bottom: 14px;
  padding: 7px 12px;
  border: 1px solid #f3c886;
  border-radius: 10px;
  background: #3d2b2c;
  color: #ffe4b1;
  font-size: 14px;
  text-align: center;
}

.players {
  display: grid;
  grid-template-columns: repeat(var(--seats, 2), minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 20px;
}

.pl { display: flex; flex-direction: column; align-items: center; min-width: 0; gap: 4px; text-align: center; }
.pl b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pl small { font-size: 11px; line-height: 1.25; white-space: nowrap; color: var(--muted); }
.pl small.ok { color: var(--mint); }
.pl .chip { min-height: 27px; padding: 1px 8px; font-size: 12px; }
.pl.empty, .pl.offline { color: var(--muted); }

.avatar {
  display: grid;
  place-items: center;
  width: clamp(43px, 12vw, 54px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)), white 35%);
  border-radius: 50%;
  background: linear-gradient(155deg, color-mix(in srgb, var(--c, var(--muted)), white 19%), var(--c, var(--muted)));
  box-shadow: 0 0 19px color-mix(in srgb, var(--c, var(--muted)) 20%, transparent);
}

.avatar::before { content: ""; width: 58%; height: 58%; background: #10162b; mask: var(--avatar-icon) center / contain no-repeat; }
.avatar.ready { outline: 2px solid var(--c); outline-offset: 3px; }
.empty .avatar, .offline .avatar { border: 1px dashed var(--muted); background: #1b1a35; box-shadow: none; }
.empty .avatar::before, .offline .avatar::before { background: var(--muted); }

.waiting-art { width: min(100%, 345px); margin: 2px auto 2px; }
.waiting h2 { font-size: clamp(32px, 9vw, 45px); font-weight: 900; letter-spacing: .04em; text-shadow: 0 4px 19px #c3a5ff51; }
.wait-count { margin: 5px 0 24px; font-size: 24px; font-weight: 800; }

.invite-panel { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 11px; padding: 14px; text-align: left; }
.invite-panel > span { font-weight: 700; }
#inviteLink { margin-left: 6px; color: var(--mint); font-size: 22px; }
.invite-panel .btn { width: auto; padding-inline: 10px; font-size: 14px; }

.arena {
  position: relative;
  margin-top: 31px;
  padding: 25px 15px 17px;
  border: 1px solid #c6afff;
  border-radius: 25px;
  background: linear-gradient(160deg, #14132feb, #10152eeb);
  box-shadow: 0 0 0 2px #a488e63b, 0 0 21px #9e77f84d, inset 0 0 24px #9171e129;
}

.arena::before {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  content: "✦";
  color: var(--gold);
  text-shadow: 0 0 12px #ffd783;
  font: 23px/1 system-ui, sans-serif;
}

.round, .won-round { display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; font-weight: 800; }
.round { margin-bottom: 15px; font-size: 21px; }
.round::before, .round::after, .won-round::before, .won-round::after {
  content: "";
  width: 29px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold));
}

.round::after, .won-round::after { transform: scaleX(-1); }

.words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.words.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.words .w {
  display: flex;
  min-height: 76px;
  min-width: 0;
  padding: 9px 5px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border: 1px solid color-mix(in srgb, var(--c) 72%, #1b1933);
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 20% 0, color-mix(in srgb, var(--c) 33%, transparent), transparent 65%),
    radial-gradient(ellipse at 85% 115%, color-mix(in srgb, var(--c) 27%, transparent), transparent 60%),
    #15152e;
  box-shadow: inset 0 0 13px color-mix(in srgb, var(--c) 25%, transparent);
  color: var(--c);
  text-align: center;
}

.words .w small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.words .w b { font-size: clamp(18px, 5.4vw, 26px); line-height: 1.2; overflow-wrap: anywhere; }
.words .w.blank { border-color: #514b7a; background: #1d1d3b; box-shadow: none; color: #bcb4d7; }
.words .w.dup { outline: 1px solid var(--c); outline-offset: 2px; box-shadow: 0 0 15px color-mix(in srgb, var(--c) 33%, transparent); }

.hint { min-height: 21px; margin: 13px 0; color: var(--muted); font-size: 14px; text-align: center; }
.hint.near { color: var(--mint); font-weight: 700; }
.turn-form { gap: 11px; }
.turn-form .txt {
  min-height: 45px;
  padding-left: 42px;
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d2c7eb' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 5 4 4M3 21l4.5-1 13-13a2.8 2.8 0 0 0-4-4l-13 13L3 21Z'/%3E%3C/svg%3E") 14px center / 17px 17px no-repeat;
}

.sealed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid #67c9c5;
  border-radius: 14px;
  background: #152c3b;
  color: var(--mint);
}

.sealed-value { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.sealed small { color: var(--muted); font-size: 12px; }
.sealed b { font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.sealed .chip { border-color: #5a9f9e; background: #1e3e4b; }
.status { min-height: 20px; margin-top: 12px; color: var(--muted); font-size: 13px; text-align: center; }
.status.ok { color: var(--mint); }

.victory { padding-top: 0; }
.victory-art { position: relative; isolation: isolate; width: min(100%, 400px); margin: 0 auto 1px; }
.victory-art .orbit-art { aspect-ratio: 2.2; object-fit: cover; }
.victory-orbit-flow { display: none; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.victory h2 { font-size: clamp(36px, 10vw, 52px); }
.words-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 .22em;
  margin: 14px 0 8px;
  color: #b6fff0;
  font-size: clamp(32px, 10.5vw, 51px);
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-shadow: 0 0 20px #74e8d76b;
}

.words-line b { min-width: 0; }
.words-line span { color: var(--muted); font-size: .55em; }
.won-round { margin: 12px 0 17px; font-size: 16px; }
.victory-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.victory-actions .ghost { min-height: 51px; padding-inline: 8px; border-radius: 999px; }
.victory-actions svg { flex: none; }
.victory .muted { margin-top: 9px; font-size: 13px; }

@media (prefers-reduced-motion: no-preference) {
  .victory-art { --victory-cycle: 3.3s; }
  .victory-orbit-flow { display: block; mix-blend-mode: screen; stroke-linecap: round; }
  .victory-flow-violet { --flow-color: #a784ff; --flow-light: #e7d8ff; }
  .victory-flow-mint { --flow-color: #6ff8eb; --flow-light: #d7fff5; }

  .victory-flow-glow { --length: 17px; --peak: .8; stroke: var(--flow-color); stroke-width: 18; filter: blur(5px); }
  .victory-flow-trail { --length: 7px; --peak: .72; stroke: var(--flow-light); stroke-width: 4.5; }
  .victory-flow-tip { --length: 1.8px; --peak: .98; stroke: #fffaff; stroke-width: 5; }

  .victory:not([hidden]) .victory-orbit-flow use {
    stroke-dasharray: var(--length) calc(100px - var(--length));
    opacity: var(--peak);
    animation: victory-orbit-glide var(--victory-cycle) linear infinite;
  }

  @keyframes victory-orbit-glide {
    from { stroke-dashoffset: var(--length); }
    to { stroke-dashoffset: calc(var(--length) - 100px); }
  }

  .victory-art::before,
  .victory-art::after {
    position: absolute;
    z-index: 1;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.82);
    opacity: 0;
    pointer-events: none;
    content: "";
  }

  .victory-art::before {
    width: 38%;
    aspect-ratio: 1;
    background: radial-gradient(circle, #fff1b8a8 0%, #ffca6457 15%, #fba64d1a 36%, transparent 64%);
    mix-blend-mode: screen;
  }

  .victory-art::after {
    width: 29%;
    aspect-ratio: 1;
    background: radial-gradient(ellipse, #fffbea 0%, #ffde8e 22%, #ffc26750 48%, transparent 72%);
    clip-path: polygon(50% 0%, 53% 46%, 100% 50%, 53% 54%, 50% 100%, 47% 54%, 0% 50%, 47% 46%);
  }

  .victory:not([hidden]) .victory-art::before,
  .victory:not([hidden]) .victory-art::after {
    animation: victory-starlight var(--victory-cycle) ease-in-out infinite;
  }

  @keyframes victory-starlight {
    0%, 100% { transform: translate(-50%, -50%) scale(1.16); opacity: .92; }
    50% { transform: translate(-50%, -50%) scale(.9); opacity: .18; }
  }
}

.history { margin-top: 19px; padding: 12px 15px; }
.histT { padding-bottom: 9px; font-size: 16px; font-weight: 750; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-top: 1px solid #6b648947; }
.hist .n { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.hist .ws { display: grid; flex: 1; min-width: 0; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.hist .w { padding: 3px 2px; border-radius: 6px; color: var(--c); font-weight: 650; font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.hist .w.dup { background: color-mix(in srgb, var(--c) 13%, transparent); }
.hist li.hit .w { background: #85f5e41a; color: var(--mint); }

.roomfoot { display: grid; justify-items: center; gap: 7px; margin-top: 20px; color: var(--muted); font-size: 14px; }
.sizebar { display: flex; width: 100%; max-width: 350px; align-items: center; justify-content: space-between; gap: 11px; }
.sizebar > span { color: var(--ink); font-weight: 700; white-space: nowrap; }
.sizebar .seg { width: min(70%, 230px); }
.room-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 16px; }
.link-btn { min-height: 30px; padding: 3px 0; border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }

#toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #252549;
  box-shadow: 0 5px 20px #030412a0;
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

@media (min-width: 650px) {
  main { padding-inline: 28px; }
  .hero { padding-top: 5px; }
  .launch, .arena, .entry { padding-inline: 23px; }
}

@media (max-width: 355px) {
  main { padding-inline: 13px; }
  .launch { padding-inline: 13px; }
  .launch-row { gap: 8px; }
  .topbar { gap: 5px; }
  .chip, .back { padding-inline: 9px; }
  .arena { padding-inline: 11px; }
  .words { gap: 7px; }
  .invite-panel .btn { padding-inline: 8px; }
}

/* 对局反馈只由收到的新状态触发。 */
.seat-arrive { animation: seat-arrive 490ms cubic-bezier(.16,.72,.28,1.18); }
.seat-confirm { animation: seat-confirm 460ms cubic-bezier(.2,.7,.25,1); }
.seal-confirmed { animation: seal-confirmed 350ms ease-out; }
.words.pop .w { animation: word-land 430ms calc(var(--i) * 50ms) cubic-bezier(.2,.72,.3,1.15) backwards; }
.celebrating .victory-art { animation: victory-arrive 1000ms 520ms cubic-bezier(.18,.75,.33,1.15) backwards; }
.celebrating .words-line { animation: victory-arrive 510ms 970ms cubic-bezier(.18,.75,.33,1.15) backwards; }

@keyframes seat-arrive {
  from { transform: translateY(9px) scale(.54); opacity: .2; }
  68% { transform: translateY(-2px) scale(1.1); }
}

@keyframes seat-confirm {
  35% { transform: scale(1.16); outline-offset: 7px; box-shadow: 0 0 20px var(--c); }
}

@keyframes seal-confirmed {
  from { transform: translateY(5px) scale(.976); }
  55% { box-shadow: 0 0 17px #85f5e463, inset 0 0 20px #85f5e42e; }
}

@keyframes word-land {
  from { transform: translateY(7px) scale(.93); opacity: .55; }
}

@keyframes victory-arrive {
  from { transform: scale(.86); opacity: .65; }
}

.round-transition {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  --sequence-time: 1270ms;
}

.round-transition[data-outcome="won"] { --sequence-time: 1810ms; }

.round-sequence {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: min(calc(100% - 24px), 480px);
  animation: sequence-in-out var(--sequence-time) ease-in-out both;
}

.round-transition::before {
  position: absolute;
  inset: 0;
  background: #070a20e6;
  content: "";
  animation: sequence-scrim var(--sequence-time) ease-in-out both;
}

.sequence-aura {
  position: absolute;
  z-index: -1;
  inset: -42px -24px;
  background: radial-gradient(ellipse, #9a64fa78, #4d56bc48 44%, transparent 72%);
  animation: sequence-aura 690ms 210ms ease-out both;
}

[data-outcome="won"] .sequence-aura {
  background: radial-gradient(ellipse, #ffe09b8a, #60e7e44a 39%, transparent 72%);
  animation-duration: 1070ms;
}

.sequence-content {
  padding: 18px 12px 17px;
  border: 1px solid #c9b1ff;
  border-radius: 23px;
  background: linear-gradient(154deg, #29254cf7, #131731f7);
  box-shadow: 0 0 0 3px #c4a5ff29, 0 0 38px #a485fe6c, inset 0 0 24px #946cf32c;
  text-align: center;
}

[data-outcome="won"] .sequence-content {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px #ffdb882e, 0 0 48px #fed8816e, inset 0 0 25px #75e9e72e;
}

.sequence-content > p { color: var(--gold); font-size: 14px; font-weight: 750; letter-spacing: .08em; }
.sequence-content > strong {
  display: block;
  margin: 3px 0 14px;
  color: var(--ink);
  font-size: clamp(26px, 8vw, 38px);
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 0 0 15px #a688f8a3;
}

[data-outcome="won"] .sequence-content > strong { color: #fff1cf; text-shadow: 0 0 17px #ffce6fbd; }

.sequence-cards {
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  gap: 7px;
  perspective: 620px;
}

.sequence-card {
  position: relative;
  min-width: 0;
  transform-style: preserve-3d;
  animation: sequence-flip 550ms calc(var(--flip-start) + var(--i) * 62ms) cubic-bezier(.24,.6,.25,1) both;
}

.sequence-face {
  display: flex;
  min-height: 71px;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--c) 75%, #1b1933);
  border-radius: 12px;
  backface-visibility: hidden;
  color: var(--c);
}

.sequence-answer {
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px;
  background: radial-gradient(ellipse at 50% 0, color-mix(in srgb, var(--c) 30%, #191936), #17162e 91%);
  box-shadow: inset 0 0 15px color-mix(in srgb, var(--c) 20%, transparent);
}

.sequence-answer small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sequence-answer b { font-size: clamp(16px, 5vw, 23px); line-height: 1.2; overflow-wrap: anywhere; }

.sequence-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  background: radial-gradient(ellipse, #414168, #212039);
  font-size: 27px;
  text-shadow: 0 0 12px var(--c);
}

.sequence-sparks { position: absolute; inset: 0; }
.sequence-spark {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 0;
  height: 0;
  transform: rotate(var(--angle));
}

.sequence-spark::after {
  display: block;
  width: 6px;
  height: 6px;
  background: var(--c);
  box-shadow: 0 0 9px var(--c);
  content: "";
  animation: sequence-spark 960ms calc(var(--spark-start) + var(--delay)) cubic-bezier(.12,.76,.35,1) both;
}

.sequence-spark:nth-child(3n)::after { border-radius: 50%; }
.sequence-spark:nth-child(4n)::after { background: var(--gold); box-shadow: 0 0 12px var(--gold); }

@keyframes sequence-in-out {
  0% { transform: translateY(12px) scale(.91); opacity: 0; }
  15%, 78% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-8px) scale(1.025); opacity: 0; }
}

@keyframes sequence-scrim {
  0%, 76% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes sequence-aura {
  0% { transform: scale(.65); opacity: 0; }
  36% { opacity: 1; }
  100% { transform: scale(1.26); opacity: .2; }
}

@keyframes sequence-flip {
  from { transform: rotateY(180deg) scale(.87); }
  72% { transform: rotateY(-11deg) scale(1.035); }
  to { transform: rotateY(0) scale(1); }
}

@keyframes sequence-spark {
  0% { transform: translateX(0) rotate(0) scale(.15); opacity: 0; }
  16%, 53% { opacity: 1; }
  100% { transform: translateX(var(--reach)) rotate(135deg) scale(.36); opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  :is(#home, #enter, #waitBox) {
    position: relative;
    isolation: isolate;
  }

  #home { overflow-x: clip; }

  :is(#home, #enter, #waitBox)::before,
  :is(#home, #enter, #waitBox)::after {
    position: absolute;
    z-index: -1;
    pointer-events: none;
    content: "";
  }

  :is(#home, #enter, #waitBox)::before {
    inset: 0 4% auto;
    height: 250px;
    background:
      radial-gradient(circle at 6% 36%, #bfa1ff 1px, #bfa1ff60 2px, transparent 6px),
      radial-gradient(circle at 16% 76%, #9ff8e5 1px, transparent 3px),
      radial-gradient(circle at 27% 15%, #fff1b7 1px, transparent 4px),
      radial-gradient(circle at 51% 8%, #bfa1ff 1px, transparent 3px),
      radial-gradient(circle at 72% 72%, #fff1b7 1px, transparent 4px),
      radial-gradient(circle at 84% 21%, #9ff8e5 1px, #9ff8e570 2px, transparent 7px),
      radial-gradient(circle at 94% 58%, #e4d6ff 1px, transparent 4px);
    opacity: .52;
    animation: scene-starlight 4.6s ease-in-out;
  }

  :is(#home, #enter, #waitBox)::after {
    top: 15px;
    left: 10%;
    width: 48px;
    height: 2px;
    border-radius: 50%;
    background: linear-gradient(90deg, transparent, #bfa1ff8c, #efffff);
    box-shadow: 12px 0 15px #9ff8e57a;
    opacity: 0;
    animation: scene-comet 850ms 440ms ease-out;
  }

  .hero h1, .waiting h2 {
    animation: scene-heading 560ms 100ms cubic-bezier(.22,.72,.25,1) backwards;
  }

  .hero .sub, .wait-count {
    animation: scene-heading 520ms 200ms ease-out backwards;
  }

  .launch, .entry, .invite-panel {
    animation: scene-panel 500ms 210ms cubic-bezier(.2,.68,.24,1) backwards;
  }

  :is(.launch, .entry, .invite-panel):focus-within { animation: none; }

  :is(#home, #enter, #waitBox) .btn:not(:disabled), #homeSize button, #home .chip {
    transition: filter 140ms ease, transform 140ms ease, scale 160ms ease;
  }

  :is(#home, #enter, #waitBox) .btn:active:not(:disabled), #homeSize button:active, #home .chip:active {
    scale: .97;
  }

  @keyframes scene-starlight {
    0%, 100% { translate: 0; opacity: .52; }
    25% { opacity: 1; }
    56% { translate: 7px -8px; opacity: .31; }
    76% { opacity: .88; }
  }

  @keyframes scene-comet {
    from { transform: translate(-10px, -5px) rotate(24deg) scaleX(.25); opacity: 0; }
    32% { opacity: .92; }
    to { transform: translate(84px, 42px) rotate(24deg) scaleX(.85); opacity: 0; }
  }

  @keyframes scene-heading {
    from { translate: 0 9px; opacity: .68; }
  }

  @keyframes scene-panel {
    from { translate: 0 9px; scale: .99; opacity: .94; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .round-transition, .planet-motion { display: none !important; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
