/* Wild mode, landing flow, entry cinematic and the refreshed 3D layer. */

:root {
  --entry-accent: #5edfd4;
  --panel-edge: rgba(150, 224, 220, 0.2);
  --panel-edge-bright: rgba(210, 255, 250, 0.72);
  --panel-depth: rgba(1, 8, 14, 0.72);
}

.mode-chip {
  padding: 3px 8px;
  border: 1px solid rgba(94, 223, 212, 0.34);
  border-radius: 999px;
  background: rgba(94, 223, 212, 0.08);
  color: #9df5ec;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.mode-chip[data-mode="wild"] {
  border-color: rgba(255, 129, 177, 0.44);
  background: rgba(255, 111, 159, 0.1);
  color: #ffacd0;
  box-shadow: 0 0 16px rgba(255, 111, 159, 0.14);
}

.effect-chip--wild { color: #ffacd0; }
.effect-chip--danger { color: #ff9a9f; }
.effect-chip--swap { color: #8ef0d4; }

/* ------------------------------------------------------------------ */
/* Landing screen and the second-level setup menu                       */
/* ------------------------------------------------------------------ */

.setup-dialog.landing-dialog {
  width: min(96vw, 1060px);
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  /* Short windows must scroll instead of pushing the start button off-screen. */
  max-height: min(94vh, calc(100% - 12px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(94, 223, 212, 0.42) transparent;
  scrollbar-width: thin;
}

.setup-dialog.landing-dialog::-webkit-scrollbar {
  width: 8px;
}

.setup-dialog.landing-dialog::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(94, 223, 212, 0.36);
}

.setup-dialog.landing-dialog::backdrop {
  background:
    radial-gradient(circle at 50% 18%, rgba(44, 126, 140, 0.28), transparent 38%),
    radial-gradient(circle at 78% 72%, rgba(92, 62, 150, 0.2), transparent 34%),
    rgba(2, 7, 12, 0.88);
  backdrop-filter: blur(16px) saturate(1.1);
}

.landing-shell {
  position: relative;
  display: grid;
  min-height: min(82vh, 730px);
  padding: clamp(38px, 6vw, 78px) clamp(24px, 6vw, 78px);
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(151, 232, 224, 0.28);
  border-radius: 24px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.07), transparent 24%),
    radial-gradient(circle at 50% 34%, rgba(94, 223, 212, 0.17), transparent 36%),
    linear-gradient(165deg, rgba(17, 39, 54, 0.97), rgba(5, 13, 23, 0.99));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -30px 80px rgba(0, 0, 0, 0.36),
    0 30px 90px rgba(0, 0, 0, 0.58);
  isolation: isolate;
}

.landing-shell::before,
.landing-shell::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.landing-shell::before {
  inset: 14px;
  border: 1px solid rgba(163, 236, 230, 0.12);
  border-radius: 18px;
  clip-path: polygon(0 0, 30% 0, 30% 2px, 70% 2px, 70% 0, 100% 0, 100% 100%, 70% 100%, 70% calc(100% - 2px), 30% calc(100% - 2px), 30% 100%, 0 100%);
}

.landing-shell::after {
  inset: 0;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(160, 240, 230, 0.08) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, rgba(160, 240, 230, 0.06) 50%, transparent 50.2%);
  background-size: 88px 88px;
  mask-image: radial-gradient(circle at 50% 45%, transparent 12%, #000 78%);
  opacity: 0.55;
}

.landing-hero {
  position: relative;
  z-index: 3;
  display: grid;
  width: min(100%, 760px);
  justify-items: center;
  text-align: center;
}

.landing-hero h1 {
  margin: 5px 0 8px;
  color: #f3fffd;
  font-family: var(--font-display);
  font-size: clamp(56px, 10vw, 108px);
  font-weight: 950;
  line-height: 0.92;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.34),
    0 0 26px rgba(94, 223, 212, 0.35),
    0 0 82px rgba(94, 223, 212, 0.16);
}

.landing-hero > p {
  max-width: 520px;
  margin: 0;
  color: rgba(226, 245, 245, 0.74);
  font-size: 14px;
  line-height: 1.8;
}

/* English wordmark: cool white FLIP with a molten-gold 7. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.18em;
  font-family: "Bahnschrift", "Arial Black", "Segoe UI Variable Display", "Microsoft YaHei UI", sans-serif;
  font-stretch: 90%;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 0.9;
}

.wordmark em {
  display: inline-block;
  font-style: normal;
  font-size: 1.14em;
  line-height: 0.9;
  background: linear-gradient(165deg, #fff6dc 4%, #f1cf83 40%, #c98f2e 76%, #ffeeae 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(238, 200, 109, 0.42));
  transform: skewX(-9deg);
  animation: wordmarkGlint 4.8s ease-in-out infinite;
}

@keyframes wordmarkGlint {
  0%,
  100% {
    filter: drop-shadow(0 0 13px rgba(238, 200, 109, 0.34));
  }
  50% {
    filter: drop-shadow(0 0 26px rgba(255, 222, 138, 0.64));
  }
}

.landing-hero h1.wordmark--hero {
  margin: 6px 0 10px;
  font-size: clamp(54px, 11vw, 116px);
  letter-spacing: 0.07em;
  text-indent: 0;
}

/* Entry-overlay mode line: keep the wider label tight enough to read. */
#entryModeLabel {
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.entry-overlay__title strong.wordmark--entry {
  letter-spacing: 0.1em;
  text-indent: 0;
}

.brand-copy strong.wordmark--brand {
  font-size: 19px;
  letter-spacing: 0.1em;
}

.brand-copy strong.wordmark--brand em {
  font-size: 1.1em;
}

.landing-orbit {
  position: absolute;
  z-index: 1;
  border: 1px solid rgba(124, 235, 223, 0.18);
  border-radius: 50%;
  pointer-events: none;
}

.landing-orbit::before {
  position: absolute;
  top: 12%;
  left: 50%;
  width: 9px;
  aspect-ratio: 1;
  content: "";
  border-radius: 50%;
  background: #b8fff7;
  box-shadow: 0 0 26px 8px rgba(94, 223, 212, 0.55);
}

.landing-orbit--a {
  width: min(78vw, 780px);
  aspect-ratio: 1;
  transform: rotate(-18deg) scaleY(0.42);
  animation: landingOrbit 24s linear infinite;
}

.landing-orbit--b {
  width: min(62vw, 610px);
  aspect-ratio: 1;
  border-style: dashed;
  transform: rotate(32deg) scaleY(0.36);
  animation: landingOrbitReverse 18s linear infinite;
}

.landing-card-fan {
  position: relative;
  display: flex;
  width: min(90%, 560px);
  height: 142px;
  margin: 22px 0 26px;
  align-items: center;
  justify-content: center;
  perspective: 900px;
}

.landing-card-fan i {
  display: grid;
  width: clamp(48px, 8vw, 70px);
  aspect-ratio: 0.7;
  margin: 0 -5px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(208, 231, 225, 0.94));
  color: #10262e;
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.44),
    0 14px 24px rgba(0, 0, 0, 0.34);
  font-family: var(--font-display);
  font-size: clamp(17px, 2.4vw, 25px);
  font-style: normal;
  font-weight: 900;
  transform-origin: 50% 115%;
  animation: landingCardBreathe 3.8s ease-in-out infinite;
}

.landing-card-fan i:nth-child(1) { transform: rotate(-31deg) translateY(12px); animation-delay: -0.4s; }
.landing-card-fan i:nth-child(2) { transform: rotate(-21deg) translateY(4px); animation-delay: -0.8s; }
.landing-card-fan i:nth-child(3) { transform: rotate(-11deg) translateY(0); animation-delay: -1.2s; }
.landing-card-fan i:nth-child(4) { transform: rotate(0deg) translateY(-5px); animation-delay: -1.6s; }
.landing-card-fan i:nth-child(5) { transform: rotate(11deg) translateY(0); animation-delay: -2s; }
.landing-card-fan i:nth-child(6) { transform: rotate(21deg) translateY(4px); animation-delay: -2.4s; }
.landing-card-fan i:nth-child(7) {
  background: linear-gradient(145deg, #fff1bf, #dda84e);
  transform: rotate(31deg) translateY(12px);
  animation-delay: -2.8s;
}

.landing-actions {
  display: flex;
  width: min(100%, 520px);
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.landing-launch {
  flex: 1 1 auto;
  max-width: 320px;
}

.landing-rules {
  display: inline-flex;
  min-height: 46px;
  padding: 0 16px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(152, 219, 216, 0.28);
  border-radius: 8px;
  background: rgba(10, 25, 35, 0.72);
  color: rgba(226, 245, 245, 0.82);
  cursor: pointer;
  font: inherit;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.landing-rules:hover {
  border-color: rgba(173, 245, 238, 0.62);
  background: rgba(20, 48, 59, 0.9);
  transform: translateY(-1px);
}

.landing-rules svg {
  --icon-size: 15px;
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.landing-mode {
  display: grid;
  width: min(100%, 650px);
  margin-top: 22px;
  justify-items: center;
}

.mode-choice-row {
  display: grid;
  width: 100%;
  margin-top: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-choice {
  position: relative;
  display: grid;
  min-height: 84px;
  padding: 13px 16px;
  align-content: center;
  justify-items: start;
  gap: 3px;
  overflow: hidden;
  border: 1px solid rgba(147, 219, 215, 0.24);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 52%),
    rgba(7, 20, 30, 0.78);
  color: rgba(224, 242, 242, 0.76);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.mode-choice::after {
  position: absolute;
  top: -90%;
  left: -34%;
  width: 30%;
  height: 280%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: rotate(18deg);
  transition: transform 620ms ease;
}

.mode-choice:hover::after,
.mode-choice[aria-pressed="true"]::after {
  transform: rotate(18deg) translateX(520%);
}

.mode-choice:hover,
.mode-choice[aria-pressed="true"] {
  border-color: rgba(167, 249, 239, 0.74);
  box-shadow:
    inset 0 0 28px rgba(94, 223, 212, 0.09),
    0 0 26px rgba(94, 223, 212, 0.14);
  color: #f1fffd;
  transform: translateY(-2px);
}

.mode-choice small {
  color: rgba(127, 226, 216, 0.72);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.mode-choice b {
  font-size: 15px;
}

.mode-choice span {
  color: rgba(202, 228, 229, 0.58);
  font-size: 10px;
}

.mode-choice--wild {
  background:
    radial-gradient(circle at 14% 20%, rgba(255, 111, 159, 0.18), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent 52%),
    rgba(22, 13, 31, 0.84);
}

.mode-choice--wild:hover,
.mode-choice--wild[aria-pressed="true"] {
  border-color: rgba(255, 142, 183, 0.78);
  box-shadow:
    inset 0 0 28px rgba(255, 111, 159, 0.1),
    0 0 30px rgba(255, 111, 159, 0.16);
}

.mode-choice--wild small {
  color: rgba(255, 156, 191, 0.86);
}

.setup-dialog[data-view="config"] {
  width: min(94vw, 1040px);
}

.config-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-button {
  display: inline-flex;
  min-height: 32px;
  padding: 0 10px;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(160, 224, 220, 0.28);
  border-radius: 7px;
  background: rgba(15, 35, 46, 0.76);
  color: rgba(224, 245, 243, 0.82);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
}

.back-button svg {
  width: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transform: rotate(180deg);
}

.mode-summary {
  display: grid;
  margin-top: 20px;
  padding: 12px 14px;
  gap: 4px;
  border: 1px solid rgba(94, 223, 212, 0.28);
  border-radius: 9px;
  background: rgba(9, 26, 35, 0.68);
}

.mode-summary strong {
  color: #9df5ec;
  font-size: 13px;
}

.mode-summary strong[data-mode="wild"] {
  color: #ff9fc3;
}

.mode-summary span {
  color: rgba(213, 234, 234, 0.64);
  font-size: 10px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Entry cinematic                                                      */
/* ------------------------------------------------------------------ */

.entry-overlay[hidden] {
  display: none;
}

.entry-overlay {
  position: fixed;
  z-index: 220;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--entry-accent) 18%, transparent), transparent 30%),
    linear-gradient(150deg, #07131e, #03070d 64%);
  pointer-events: none;
}

.entry-overlay__grid {
  position: absolute;
  inset: -20%;
  background:
    linear-gradient(rgba(150, 246, 236, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 246, 236, 0.1) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0 22%, transparent 68%);
  transform: perspective(600px) rotateX(62deg) translateY(22%);
  animation: entryGrid 1.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.entry-overlay__flare {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150vmax;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--entry-accent), #ffffff, var(--entry-accent), transparent);
  box-shadow: 0 0 34px 8px color-mix(in srgb, var(--entry-accent) 54%, transparent);
  transform: translate(-50%, -50%) scaleX(0);
  animation: entryFlare 0.9s 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.entry-overlay__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid color-mix(in srgb, var(--entry-accent) 70%, transparent);
  border-radius: 50%;
  box-shadow:
    inset 0 0 34px color-mix(in srgb, var(--entry-accent) 14%, transparent),
    0 0 40px color-mix(in srgb, var(--entry-accent) 18%, transparent);
  transform: translate(-50%, -50%) scale(0.1);
  animation: entryRing 1.15s cubic-bezier(0.1, 0.72, 0.2, 1) both;
}

.entry-overlay__ring--outer {
  width: min(76vw, 680px);
  aspect-ratio: 1;
}

.entry-overlay__ring--inner {
  width: min(48vw, 410px);
  aspect-ratio: 1;
  border-style: dashed;
  animation-delay: 0.12s;
}

.entry-overlay__slash {
  position: absolute;
  top: -20%;
  left: 50%;
  width: 28vw;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  filter: blur(1px);
  transform: translateX(-50%) rotate(22deg) translateX(-90vw);
  animation: entrySlash 1s 0.18s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

.entry-overlay__title {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 88%;
  justify-items: center;
  color: #ffffff;
  text-align: center;
  transform: translate(-50%, -50%);
}

.entry-overlay__title small {
  color: color-mix(in srgb, var(--entry-accent) 90%, white);
  font-family: var(--font-display);
  font-size: clamp(9px, 1.3vw, 13px);
  font-weight: 800;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  animation: entryCopy 0.7s 0.22s ease both;
}

.entry-overlay__title strong {
  margin: 10px 0 2px;
  font-family: var(--font-display);
  font-size: clamp(48px, 9vw, 102px);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-shadow:
    0 0 18px color-mix(in srgb, var(--entry-accent) 68%, transparent),
    0 0 70px color-mix(in srgb, var(--entry-accent) 36%, transparent);
  animation: entryTitle 0.9s 0.1s cubic-bezier(0.15, 0.8, 0.2, 1) both;
}

.entry-overlay__title span {
  color: rgba(228, 250, 249, 0.62);
  font-family: var(--font-display);
  font-size: clamp(11px, 1.6vw, 17px);
  font-weight: 800;
  letter-spacing: 0.62em;
  text-indent: 0.62em;
  animation: entryCopy 0.8s 0.32s ease both;
}

.entry-overlay__cards {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  gap: 10px;
  transform: translate(-50%, -50%);
}

.entry-overlay__cards i {
  width: clamp(34px, 5vw, 54px);
  aspect-ratio: 0.7;
  border: 1px solid color-mix(in srgb, var(--entry-accent) 72%, white);
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), color-mix(in srgb, var(--entry-accent) 24%, transparent));
  box-shadow: 0 0 24px color-mix(in srgb, var(--entry-accent) 28%, transparent);
  opacity: 0;
  animation: entryCards 0.86s 0.24s cubic-bezier(0.16, 0.8, 0.2, 1) both;
}

.entry-overlay__cards i:nth-child(2) { animation-delay: 0.3s; }
.entry-overlay__cards i:nth-child(3) { animation-delay: 0.36s; }
.entry-overlay__cards i:nth-child(4) { animation-delay: 0.42s; }
.entry-overlay__cards i:nth-child(5) { animation-delay: 0.48s; }

.entry-overlay.is-exiting {
  animation: entryExit 0.42s ease both;
}

@keyframes landingOrbit {
  to { transform: rotate(342deg) scaleY(0.42); }
}

@keyframes landingOrbitReverse {
  to { transform: rotate(-328deg) scaleY(0.36); }
}

@keyframes landingCardBreathe {
  0%, 100% { filter: brightness(0.94); }
  50% { filter: brightness(1.12); box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42), 0 0 22px rgba(94, 223, 212, 0.2); }
}

@keyframes entryGrid {
  from { opacity: 0; transform: perspective(600px) rotateX(62deg) translateY(32%) scale(0.8); }
  to { opacity: 1; transform: perspective(600px) rotateX(62deg) translateY(22%) scale(1); }
}

@keyframes entryFlare {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.15); }
}

@keyframes entryRing {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.1) rotate(0deg); }
  46% { opacity: 1; }
  100% { opacity: 0.18; transform: translate(-50%, -50%) scale(1) rotate(120deg); }
}

@keyframes entrySlash {
  from { opacity: 0; transform: translateX(-50%) rotate(22deg) translateX(-90vw); }
  36% { opacity: 1; }
  to { opacity: 0; transform: translateX(-50%) rotate(22deg) translateX(90vw); }
}

@keyframes entryTitle {
  from { opacity: 0; transform: scale(1.35); filter: blur(12px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes entryCopy {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes entryCards {
  0% { opacity: 0; transform: translateY(90px) rotate(-20deg) scale(0.62); }
  60% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-80px) rotate(14deg) scale(1.08); }
}

@keyframes entryExit {
  to { opacity: 0; transform: scale(1.045); filter: blur(8px); }
}

/* ------------------------------------------------------------------ */
/* 3D panels, cards and buttons                                         */
/* ------------------------------------------------------------------ */

.game-view,
.player-grid {
  perspective: 1500px;
}

.topbar,
.players-zone,
.command-deck,
.event-console {
  border-color: var(--panel-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 46px rgba(0, 0, 0, 0.2),
    0 16px 38px rgba(0, 0, 0, 0.22);
}

.command-deck {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), transparent 18%),
    radial-gradient(circle at 88% 0%, rgba(94, 223, 212, 0.1), transparent 26%),
    linear-gradient(180deg, rgba(18, 35, 48, 0.96), rgba(7, 16, 26, 0.98));
}

.player-panel {
  display: flex;
  min-height: 252px;
  flex-direction: column;
  border-color: rgba(152, 213, 211, 0.2);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -18px 34px rgba(0, 0, 0, 0.18),
    0 18px 34px rgba(0, 0, 0, 0.24);
  transform-style: preserve-3d;
  transition:
    transform 220ms cubic-bezier(0.2, 0.75, 0.25, 1),
    border-color 220ms ease,
    box-shadow 220ms ease;
}

@media (hover: hover) {
  .player-panel:not(.is-current):hover {
    border-color: color-mix(in srgb, var(--accent, var(--cyan)) 52%, white);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 -18px 34px rgba(0, 0, 0, 0.18),
      0 22px 38px rgba(0, 0, 0, 0.3),
      0 0 22px color-mix(in srgb, var(--accent, var(--cyan)) 15%, transparent);
    transform: translateY(-3px) rotateX(0.8deg);
  }
}

.player-panel.is-current {
  border-radius: 10px;
}

/* Number cards are the main readout: this rail always keeps a full row.
   It used to be shrinkable with min-height 0, so a function card could
   squeeze it down to nothing. */
.card-rail--numbers {
  flex: 1 1 auto;
  min-height: calc(var(--card-width, 66px) / 0.7 + 10px);
  max-height: calc(var(--card-width, 66px) / 0.7 * 2 + 22px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
  scrollbar-color: rgba(94, 223, 212, 0.42) transparent;
  scrollbar-width: thin;
}

.card-rail--numbers::-webkit-scrollbar {
  width: 5px;
}

.card-rail--numbers::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(94, 223, 212, 0.42);
}

/* Bigger hands step the card size down so seven numbers still fit two rows. */
.card-rail--numbers.is-dense {
  gap: 6px 4px;
  min-height: calc(54px / 0.7 + 10px);
}

.card-rail--numbers.is-dense .game-card {
  flex-basis: 54px;
  width: 54px;
}

.card-rail--numbers.is-compact {
  gap: 5px 3px;
  min-height: calc(48px / 0.7 + 10px);
}

.card-rail--numbers.is-compact .game-card {
  flex-basis: 48px;
  width: 48px;
}

/* Function cards get their own smaller line so they never push numbers away. */
.card-rail--specials {
  flex: 0 0 auto;
  min-height: 0;
  max-height: calc(40px / 0.7 + 40px);
  margin-top: 6px;
  padding-top: 6px;
  border-top-color: rgba(179, 232, 226, 0.25);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.card-rail--specials .game-card {
  flex-basis: 40px;
  width: 40px;
}

.card-rail--specials .action-card__icon {
  top: 8px;
  width: 16px;
}

.card-rail--specials .action-card__icon svg {
  --icon-size: 11px;
  width: 11px;
}

.card-rail--specials .action-card__icon--flip b,
.card-rail--specials .action-card__icon--swap b {
  font-size: 10px;
}

.card-rail--specials .action-card__title {
  top: 44%;
  width: calc(100% - 4px);
  font-size: 6px;
  letter-spacing: 0;
}

.card-rail--specials .action-card__hint,
.card-rail--specials .modifier-card__caption {
  display: none;
}

.card-rail--specials .modifier-card__value {
  font-size: 14px;
}

.card-rail--specials .card-stamp {
  padding: 1px 2px;
  border-width: 1px;
  font-size: 5px;
}

.card-rail--specials .game-card.is-spent .card-stamp {
  bottom: 3px;
}

.player-status {
  margin-top: auto;
}

.player-status .current-tag {
  position: static;
  display: inline-flex;
  min-height: 25px;
  padding: 4px 9px;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent));
  color: #07141c;
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.04em;
  transform: none;
  animation: activeTagPulse 1.6s ease-in-out infinite;
}

.player-status .current-tag i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: activeDot 1.1s ease-in-out infinite;
}

/* The state badge lives in the panel flow so it never covers a card. */
.player-panel[data-status="busted"] .card-rail,
.player-panel[data-status="frozen"] .card-rail,
.player-panel[data-status="stayed"] .card-rail {
  padding-right: 2px;
}

.status-effect {
  position: static;
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  padding: 5px 8px;
  justify-content: flex-start;
  border-radius: 6px;
}

.game-card {
  border-color: rgba(255, 255, 255, 0.68);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.74),
    inset 0 -8px 14px rgba(0, 0, 0, 0.12),
    0 8px 14px rgba(0, 0, 0, 0.28);
  transform-style: preserve-3d;
  transition: transform 200ms cubic-bezier(0.2, 0.75, 0.25, 1), box-shadow 200ms ease, filter 200ms ease;
}

@media (hover: hover) {
  .game-card:hover {
    z-index: 12;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.84),
      inset 0 -8px 14px rgba(0, 0, 0, 0.12),
      0 16px 24px rgba(0, 0, 0, 0.36),
      0 0 20px rgba(238, 200, 109, 0.16);
    filter: brightness(1.05);
    transform: translateY(-7px) rotateY(-6deg) rotateZ(-1deg) scale(1.04);
  }
}

.game-card--minus10 {
  background:
    radial-gradient(circle at 50% 37%, rgba(255, 255, 255, 0.5), transparent 28%),
    linear-gradient(150deg, #ffd3cf, #e46d75 64%, #aa3347);
  color: #421019;
}

.game-card--negativeMultiplier {
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 255, 255, 0.5), transparent 28%),
    linear-gradient(150deg, #e7d4ff, #a979e2 64%, #6442a6);
  color: #25123f;
}

.game-card--swapHands {
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.56), transparent 26%),
    linear-gradient(150deg, #d9fff3, #6dd2bd 62%, #2f9d95);
  color: #083a38;
}

.game-card--minus10 .modifier-card__halo,
.game-card--negativeMultiplier .modifier-card__halo {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.68), transparent 68%);
}

.action-card__icon--swap b {
  font-size: 14px;
}

.game-card.is-high-impact {
  filter: brightness(1.08) saturate(1.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 0 0 2px rgba(255, 225, 152, 0.46),
    0 0 34px rgb(255 194 91 / calc(0.18 + var(--impact) * 0.5)),
    0 20px 30px rgba(0, 0, 0, 0.4);
}

.primary-action,
.secondary-action,
.launch-button,
.icon-button,
.stepper button,
.ai-toggle {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 7px 16px rgba(0, 0, 0, 0.22);
}

.primary-action:not(:disabled):hover,
.secondary-action:not(:disabled):hover,
.launch-button:not(:disabled):hover {
  transform: translateY(-2px);
}

.primary-action:not(:disabled):active,
.secondary-action:not(:disabled):active,
.launch-button:not(:disabled):active {
  transform: translateY(1px);
}

/* ------------------------------------------------------------------ */
/* Frost, swap and score-impact states                                  */
/* ------------------------------------------------------------------ */

.freeze-overlay {
  position: absolute;
  z-index: 6;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: screen;
}

.freeze-overlay__sheet,
.freeze-overlay__shards {
  position: absolute;
  inset: 0;
  display: block;
}

.freeze-overlay__sheet {
  background:
    linear-gradient(150deg, rgba(225, 251, 255, 0.46), transparent 24%),
    repeating-linear-gradient(62deg, rgba(229, 251, 255, 0.14) 0 3px, transparent 3px 13px),
    radial-gradient(circle at 77% 18%, rgba(255, 255, 255, 0.62), transparent 16%),
    radial-gradient(circle at 18% 78%, rgba(168, 231, 250, 0.38), transparent 22%);
  box-shadow: inset 0 0 72px rgba(177, 235, 255, 0.36);
  animation: frostBreathe 2.8s ease-in-out infinite;
}

.freeze-overlay__shards {
  background:
    linear-gradient(28deg, transparent 38%, rgba(235, 253, 255, 0.72) 39% 40%, transparent 41%) 0 0 / 58px 58px,
    linear-gradient(151deg, transparent 46%, rgba(190, 238, 255, 0.62) 47% 48%, transparent 49%) 0 0 / 72px 72px;
  opacity: 0.72;
  animation: frostShards 5.5s linear infinite;
}

.player-panel[data-status="frozen"] {
  border-color: rgba(179, 242, 255, 0.92);
  box-shadow:
    inset 0 0 46px rgba(129, 220, 255, 0.22),
    0 0 30px rgba(111, 218, 255, 0.22),
    0 18px 38px rgba(0, 0, 0, 0.28);
}

.player-panel.is-freezing .freeze-overlay {
  animation: freezeFlash 1.18s cubic-bezier(0.18, 0.82, 0.2, 1);
}

.player-panel.is-swapping {
  animation: swapShock 1.1s cubic-bezier(0.18, 0.8, 0.2, 1) both;
}

.player-panel.is-swapping::after {
  position: absolute;
  z-index: 10;
  inset: 0;
  content: "";
  background:
    linear-gradient(105deg, transparent 32%, rgba(145, 255, 231, 0.48) 44%, rgba(255, 255, 255, 0.66) 50%, rgba(145, 255, 231, 0.48) 56%, transparent 68%);
  mix-blend-mode: screen;
  animation: swapSweep 1.05s cubic-bezier(0.2, 0.75, 0.2, 1) both;
  pointer-events: none;
}

.score-impact {
  position: fixed;
  z-index: 215;
  width: 22px;
  aspect-ratio: 1;
  border: 2px solid rgb(255 226 151 / calc(0.4 + var(--impact) * 0.5));
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgba(255, 185, 76, 0.24),
    0 0 36px rgb(255 189 84 / calc(0.22 + var(--impact) * 0.62));
  transform: translate(-50%, -50%);
  animation: scoreImpact 0.76s cubic-bezier(0.12, 0.76, 0.2, 1) both;
  pointer-events: none;
}

.score-impact--hot {
  border-color: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 0 0 3px rgba(255, 186, 76, 0.46),
    0 0 60px rgba(255, 138, 85, 0.72);
}

.player-panel.is-score-surging {
  animation: scoreSurge 0.72s ease both;
}

.game-card.is-latest {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 0 0 calc(1px + var(--score-heat, 0) * 2px) rgba(255, 228, 161, 0.72),
    0 0 calc(16px + var(--score-heat, 0) * 32px) rgba(238, 200, 109, 0.72),
    -7px 10px 20px rgba(0, 0, 0, 0.32);
}

@keyframes frostBreathe {
  50% { opacity: 0.86; filter: brightness(1.18); }
}

@keyframes frostShards {
  to { transform: translate3d(58px, 58px, 0); }
}

@keyframes freezeFlash {
  0% { opacity: 0; transform: scale(1.16); filter: brightness(2); }
  35% { opacity: 1; }
  100% { opacity: 0.85; transform: scale(1); filter: brightness(1); }
}

@keyframes swapShock {
  0% { transform: scale(1); }
  30% { transform: scale(1.035) rotate(0.8deg); filter: brightness(1.3); }
  65% { transform: scale(0.985) rotate(-0.5deg); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes swapSweep {
  from { opacity: 0; transform: translateX(-80%); }
  40% { opacity: 1; }
  to { opacity: 0; transform: translateX(80%); }
}

@keyframes scoreImpact {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.24); }
  70% { opacity: 0.55; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(9); }
}

@keyframes scoreSurge {
  0%, 100% { filter: brightness(1); }
  45% { filter: brightness(1.28) saturate(1.16); }
}

/* ------------------------------------------------------------------ */
/* Function-card target modal variants                                  */
/* ------------------------------------------------------------------ */

.target-modal__card {
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 28px 80px rgba(0, 0, 0, 0.62);
}

.target-modal__aura {
  position: absolute;
  z-index: -1;
  top: -44%;
  left: 50%;
  width: 120%;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.5;
  transform: translateX(-50%);
  animation: targetAura 3.6s ease-in-out infinite;
  pointer-events: none;
}

.target-modal__card--freeze .target-modal__aura {
  background: radial-gradient(circle, rgba(118, 220, 255, 0.34), transparent 66%);
}

.target-modal__card--flip-three .target-modal__aura {
  background: radial-gradient(circle, rgba(246, 201, 103, 0.32), transparent 66%);
}

.target-modal__card--swap .target-modal__aura {
  background: radial-gradient(circle, rgba(104, 232, 198, 0.34), transparent 66%);
}

.target-modal__card--freeze {
  border-color: rgba(136, 226, 255, 0.52);
}

.target-modal__card--flip-three {
  border-color: rgba(244, 203, 112, 0.52);
}

.target-modal__card--swap {
  border-color: rgba(109, 232, 198, 0.56);
}

.target-copy__icon {
  position: relative;
}

.target-copy__icon i {
  position: absolute;
  inset: -5px;
  border: 1px solid currentColor;
  border-radius: 9px;
  opacity: 0.28;
  animation: targetIconPulse 1.8s ease-in-out infinite;
  pointer-events: none;
}

.target-copy__icon--freeze {
  color: #a7eaff;
  box-shadow: 0 0 24px rgba(107, 214, 250, 0.3);
}

.target-copy__icon--flip-three {
  color: #f5d480;
  box-shadow: 0 0 24px rgba(240, 199, 99, 0.28);
}

.target-copy__icon--swap {
  color: #86f0d2;
  box-shadow: 0 0 26px rgba(96, 229, 190, 0.32);
}

.target-modal__card--swap .target-option:hover {
  border-color: rgba(118, 241, 207, 0.72);
  box-shadow: 0 0 24px rgba(96, 229, 190, 0.2);
}

.target-modal__card--freeze .target-option:hover {
  border-color: rgba(140, 226, 255, 0.72);
  box-shadow: 0 0 24px rgba(107, 214, 250, 0.2);
}

.target-modal__card--flip-three .target-option:hover {
  border-color: rgba(246, 209, 122, 0.72);
  box-shadow: 0 0 24px rgba(240, 199, 99, 0.2);
}

@keyframes targetAura {
  50% { opacity: 0.82; transform: translateX(-50%) scale(1.12); }
}

@keyframes targetIconPulse {
  50% { opacity: 0.66; transform: scale(1.12); }
}

/* ------------------------------------------------------------------ */
/* Dense grids and responsive tuning                                    */
/* ------------------------------------------------------------------ */

.player-grid[data-count="10"] .player-panel,
.player-grid[data-count="11"] .player-panel,
.player-grid[data-count="12"] .player-panel,
.player-grid[data-count="13"] .player-panel,
.player-grid[data-count="14"] .player-panel,
.player-grid[data-count="15"] .player-panel,
.player-grid[data-count="16"] .player-panel,
.player-grid[data-count="17"] .player-panel,
.player-grid[data-count="18"] .player-panel {
  min-height: 206px;
}

.player-grid[data-count="10"] .card-rail--numbers,
.player-grid[data-count="11"] .card-rail--numbers,
.player-grid[data-count="12"] .card-rail--numbers,
.player-grid[data-count="13"] .card-rail--numbers,
.player-grid[data-count="14"] .card-rail--numbers,
.player-grid[data-count="15"] .card-rail--numbers,
.player-grid[data-count="16"] .card-rail--numbers,
.player-grid[data-count="17"] .card-rail--numbers,
.player-grid[data-count="18"] .card-rail--numbers {
  max-height: calc(var(--card-width, 54px) / 0.7 + 14px);
}

@media (max-width: 760px) {
  .landing-shell {
    min-height: 78vh;
    padding: 32px 18px;
    border-radius: 18px;
  }

  .landing-hero h1 {
    font-size: clamp(48px, 18vw, 76px);
  }

  .landing-hero h1.wordmark--hero {
    font-size: clamp(46px, 17vw, 74px);
  }

  .brand-copy strong.wordmark--brand {
    font-size: 16px;
  }

  .landing-card-fan {
    height: 116px;
  }

  .landing-actions,
  .mode-choice-row {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .landing-actions {
    flex-direction: column;
  }

  .landing-launch,
  .landing-rules {
    width: 100%;
    max-width: none;
  }

  .player-panel {
    min-height: 226px;
  }

  .target-modal__card {
    max-height: 86vh;
    overflow-y: auto;
  }
}

/* Short viewports: let the panels shrink so every control stays reachable. */
@media (max-height: 840px) {
  .setup-shell,
  .setup-visual {
    min-height: min(560px, 84vh);
  }

  .landing-shell {
    min-height: min(78vh, 660px);
  }
}

@media (max-height: 700px) {
  .landing-shell {
    min-height: 0;
    padding-block: 24px;
  }

  .setup-shell,
  .setup-visual {
    min-height: 0;
  }

  .setup-visual {
    padding-block: 28px;
  }

  .setup-emblem {
    width: min(230px, 40%);
  }

  .setup-visual h1 {
    font-size: 38px;
  }

  .landing-card-fan {
    height: 96px;
    margin-block: 12px;
  }

  .landing-mode {
    margin-top: 12px;
  }
}


/* All-AI tables roll into the next round on their own; show how long that takes. */
.result-actions button.is-auto {
  position: relative;
  overflow: hidden;
}

.result-actions button.is-auto::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, var(--gold-bright), var(--cyan));
  transform-origin: left center;
  animation: resultAutoBar 3s linear both;
}

@keyframes resultAutoBar {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .entry-overlay {
    display: none !important;
  }
}

/* ------------------------------------------------------------------ */
/* Hand layout: overlapped cards, wider frames, no inner scrolling      */
/* ------------------------------------------------------------------ */

/* Wider frames at every player count. min(100%, …) keeps the grid from
   overflowing when the viewport is narrower than one frame. */
.player-grid {
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.player-grid[data-count="2"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  align-content: center;
}

.player-grid[data-count="3"],
.player-grid[data-count="4"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 306px), 1fr));
  align-content: center;
}

.player-grid[data-count="5"],
.player-grid[data-count="6"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 288px), 1fr));
  align-content: center;
}

.player-grid[data-count="7"],
.player-grid[data-count="8"],
.player-grid[data-count="9"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 266px), 1fr));
}

.player-grid[data-count="10"],
.player-grid[data-count="11"],
.player-grid[data-count="12"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 244px), 1fr));
}

.player-grid[data-count="13"],
.player-grid[data-count="14"],
.player-grid[data-count="15"],
.player-grid[data-count="16"],
.player-grid[data-count="17"],
.player-grid[data-count="18"] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 222px), 1fr));
}

/* How far the next card slides over the previous one, per player count. */
.player-grid[data-count="2"],
.player-grid[data-count="3"],
.player-grid[data-count="4"],
.player-grid[data-count="5"],
.player-grid[data-count="6"] {
  --card-overlap: 15px;
}

.player-grid[data-count="7"],
.player-grid[data-count="8"],
.player-grid[data-count="9"] {
  --card-overlap: 14px;
}

.player-grid[data-count="10"],
.player-grid[data-count="11"],
.player-grid[data-count="12"] {
  --card-overlap: 12px;
}

.player-grid[data-count="13"],
.player-grid[data-count="14"],
.player-grid[data-count="15"],
.player-grid[data-count="16"],
.player-grid[data-count="17"],
.player-grid[data-count="18"] {
  --card-overlap: 11px;
}

/* A hand is one or two rows of overlapped cards: no inner scrollbar hides
   cards any more. The extra padding-right absorbs the overlap that the last
   card of a row pushes past the content box. */
#playerGrid .card-rail {
  column-gap: 0;
  row-gap: 10px;
  padding-right: calc(var(--card-overlap, 15px) + 8px);
  overflow: visible;
  max-height: none;
  scrollbar-width: none;
}

#playerGrid .card-rail--numbers,
#playerGrid .card-rail--specials {
  overflow: visible;
  max-height: none;
}

#playerGrid .card-rail .game-card {
  margin-right: calc(var(--card-overlap, 15px) * -1);
}

/* Function cards are narrower, so they overlap far less. */
#playerGrid .card-rail--specials {
  padding-right: calc(min(var(--card-overlap, 12px), 7px) + 8px);
}

#playerGrid .card-rail--specials .game-card {
  margin-right: calc(min(var(--card-overlap, 12px), 7px) * -1);
}

/* One centred digit per number card; 10/11/12 step down a size so an
   overlapping neighbour never covers them. */
.number-card__value {
  font-size: 30px;
}

.number-card__value--wide {
  font-size: 23px;
}

@media (max-width: 1100px) {
  .number-card__value {
    font-size: 28px;
  }

  .number-card__value--wide {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .player-grid[data-count] {
    --card-overlap: 10px;
  }

  .number-card__value {
    font-size: 26px;
  }

  .number-card__value--wide {
    font-size: 20px;
  }
}

/* ------------------------------------------------------------------ */
/* Narrow windows: phones and split screens                             */
/* A phone should still read like a table: tighter seats, smaller cards */
/* and a target sheet that always fits on screen.                       */
/* ------------------------------------------------------------------ */

@media (max-width: 860px) {
  /* Setup pane: the giant 7 emblem used to sit on top of “建立牌桌”. */
  .setup-visual {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    align-items: center;
    gap: 2px 14px;
    min-height: 0;
    padding: 18px 22px 20px;
  }

  .setup-emblem {
    position: relative;
    top: auto;
    left: auto;
    width: 104px;
    margin: 0;
    grid-row: 1 / span 2;
    transform: none;
  }

  .setup-emblem strong {
    font-size: 40px;
  }

  .setup-visual > .eyebrow,
  .setup-visual > h2 {
    grid-column: 2;
  }

  .setup-visual > .mode-summary,
  .setup-visual > .setup-facts {
    grid-column: 1 / -1;
  }

  .setup-visual h2 {
    margin: 4px 0 0;
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 800;
    line-height: 1.06;
  }

  .setup-visual .eyebrow {
    align-self: end;
    font-size: 9px;
  }

  .setup-visual .mode-summary {
    margin-top: 14px;
  }

  .setup-facts {
    margin-top: 12px;
  }
}

@media (max-width: 760px) {
  /* Seats get a tighter frame so more of the table fits one screen. */
  .player-grid {
    gap: 7px;
    padding: 0 2px 10px 0;
  }

  #playerGrid {
    --card-width: 46px;
    --card-overlap: 9px;
  }

  .player-panel {
    min-height: 0;
    padding: 8px 9px 9px;
    border-radius: 8px;
  }

  .player-header {
    grid-template-columns: 27px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .player-sigil {
    width: 27px;
    font-size: 12px;
  }

  .player-sigil::after {
    width: 17px;
  }

  .player-nameplate h3 {
    font-size: 12.5px;
  }

  .player-nameplate p {
    margin-top: 2px;
    gap: 4px;
    font-size: 7px;
  }

  .score-lockup {
    min-width: 42px;
  }

  .score-lockup b {
    font-size: 17px;
  }

  .score-lockup small {
    margin-top: 2px;
    font-size: 6px;
  }

  .score-lockup .round-score {
    margin-top: 3px;
    padding: 2px 6px;
  }

  .score-lockup .round-score b {
    font-size: 14px;
  }

  .card-rail {
    margin-top: 6px;
    min-height: 0;
    gap: 5px 4px;
    padding: 2px 1px 3px;
  }

  .card-rail--numbers {
    min-height: calc(var(--card-width, 46px) / 0.7 + 6px);
    max-height: calc(var(--card-width, 46px) / 0.7 * 2 + 14px);
  }

  .card-rail--specials {
    max-height: calc(var(--card-width, 46px) / 0.7 + 24px);
  }

  .card-rail:empty::after {
    min-height: 42px;
  }

  .number-card__value {
    font-size: 22px;
  }

  .number-card__value--wide {
    font-size: 17px;
  }

  .player-status {
    margin-top: 6px;
    font-size: 9px;
  }

  .player-status .status-pill {
    padding: 3px 7px;
    font-size: 9px;
  }

  .player-panel .current-tag {
    min-height: 20px;
    padding: 2px 7px;
    font-size: 8px;
  }

  /* The docked action window gives some height back to the table. */
  .command-deck {
    padding: 10px;
  }

  .deck-header {
    padding-bottom: 9px;
  }

  .turn-readout {
    min-height: 54px;
  }

  .action-stack {
    margin-top: 9px;
  }

  .probability-strip {
    margin-top: 8px;
    padding-top: 9px;
  }
}

@media (max-width: 760px) {
  /* Target sheet: candidates scroll inside the sheet instead of running  */
  /* off the bottom of a phone screen.                                   */
  /* Must not out-specify [hidden], or the empty overlay lingers on top. */
  .target-panel:not([hidden]) {
    display: block;
  }

  .target-modal__card {
    position: absolute;
    top: auto;
    right: 10px;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    /* 76dvh still clears the pinned 查看牌桌 bar at the bottom and the      */
    /* top of the screen, but lets seven-plus candidates fit unscrolled.    */
    max-height: min(76dvh, 640px);
    padding: 15px 14px 16px;
    overflow: hidden auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(94, 223, 212, 0.42) transparent;
    scrollbar-width: thin;
    border-radius: 12px;
  }

  .target-modal__header h3 {
    font-size: 17px;
  }

  .target-copy {
    margin: 12px 0 10px;
    padding: 9px 10px;
  }

  .target-copy p {
    font-size: 10px;
    line-height: 1.6;
  }

  .target-options {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }

  .target-option {
    min-height: 50px;
    padding: 7px 8px;
  }

  .target-modal__hint {
    display: none;
  }

  /* 查看牌桌 stays where the flip button normally sits, so it never     */
  /* covers the candidate list.                                          */
  .peek-toggle {
    position: absolute;
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    height: 46px;
    justify-content: center;
    border-radius: 9px;
    font-size: 13px;
  }

  .peek-toggle svg {
    --icon-size: 17px;
    width: 17px;
  }
}

@media (max-width: 400px) {
  #playerGrid {
    --card-width: 42px;
    --card-overlap: 8px;
  }

  .player-panel {
    padding: 7px 8px 8px;
  }

  .number-card__value {
    font-size: 20px;
  }

  .number-card__value--wide {
    font-size: 15px;
  }

  .setup-visual h2 {
    font-size: 24px;
  }
}

@media (max-width: 860px) {
  /* Peek mode keeps the table readable: the docked action window leaves  */
  /* completely, and the grid reserves room for the pinned 返回选人 key.   */
  .has-target-peek .command-deck {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .has-target-peek .game-view {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 760px) and (max-height: 720px) {
  /* Short phones: trim the sheet chrome so a full candidate list still    */
  /* fits without hunting for the scrollbar.                              */
  .target-modal__card {
    padding: 12px 12px 13px;
  }

  .target-modal__header h3 {
    margin-top: 3px;
    font-size: 15px;
  }

  .target-copy {
    margin: 9px 0 8px;
    padding: 8px 9px;
  }

  .target-copy strong {
    font-size: 13px;
  }

  .target-copy p {
    font-size: 9px;
    line-height: 1.45;
  }

  .target-options {
    gap: 6px;
  }

  .target-option {
    min-height: 44px;
    padding: 5px 7px;
  }
}

/* ------------------------------------------------------------------ */
/* Beat-driven state effects                                            */
/* Bust motion now waits for its beat instead of running at render time, */
/* and the second-chance save finally has a flash to match its cue.      */
/* ------------------------------------------------------------------ */

.player-panel.is-busting .game-card.is-bust-card {
  animation: bustCardIn 700ms cubic-bezier(0.18, 0.9, 0.2, 1) both;
}

.player-panel.is-busting .status-effect--busted {
  animation: bustBadge 760ms cubic-bezier(0.18, 0.86, 0.24, 1) both;
}

.player-panel.is-shielding {
  animation: shieldFlash 620ms ease both;
}

@keyframes shieldFlash {
  0% {
    filter: brightness(1);
  }
  30% {
    filter: brightness(1.5) saturate(1.2);
    box-shadow:
      0 0 42px rgba(141, 229, 173, 0.5),
      inset 0 0 40px rgba(141, 229, 173, 0.2);
  }
  100% {
    filter: brightness(1);
  }
}
