:root {
  --gold: #f6c453;
  --gold-2: #e8963a;
  --red: #d7263d;
  --ink: #17181c;
  --text: #f3f7f4;
  --muted: rgba(243, 247, 244, 0.62);
  --glass: rgba(4, 22, 14, 0.42);
  --line: rgba(255, 255, 255, 0.1);
  --ok: #4ade80;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  /* the table stands in a painted scene (#scene); wide screens see a darkened copy at the sides */
  --map: url('/scenes/vegas.webp');
  background: linear-gradient(rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.65)), var(--map) center / cover no-repeat, #101410;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  height: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input {
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- buttons & inputs ---------- */

.btn {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  padding: 13px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  transition: transform 0.12s, filter 0.15s, opacity 0.2s;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn.primary {
  border: none;
  color: #2b1700;
  background: linear-gradient(180deg, #ffd977, var(--gold) 45%, var(--gold-2));
  box-shadow: 0 6px 20px rgba(246, 196, 83, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn.danger {
  border: none;
  background: linear-gradient(180deg, #ff5a6e, var(--red));
  box-shadow: 0 6px 20px rgba(215, 38, 61, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn.big {
  padding: 15px 20px;
  font-size: 17px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.link {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
  padding: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 17px;
  outline: none;
  text-transform: none;
  letter-spacing: normal;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.25);
}

.panel {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-weight: 800;
  text-align: center;
}

.join-row .btn {
  width: auto;
}

/* ---------- home & lobby ---------- */

.home,
.lobby {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}

/* centred while it fits; when it does not (short laptop screens), it scrolls from the top
   instead of cutting off the logo */
.home > :first-child,
.lobby > :first-child {
  margin-top: auto;
}

.home > :last-child,
.lobby > :last-child {
  margin-bottom: auto;
}

/* wide but short screens: the lobby's logo shrinks so everything fits */
@media (min-aspect-ratio: 1/1) and (max-height: 900px) {
  .lobby .logo-cards { --cw: 44px; }
  .lobby .logo h1 { font-size: 46px; }
  .lobby { gap: 12px; padding-top: 14px; padding-bottom: 14px; }
}

.logo {
  text-align: center;
}

.logo-cards {
  --cw: 62px;
  position: relative;
  height: calc(var(--cw) * 1.45);
  width: calc(var(--cw) * 2.6);
  margin: 0 auto 6px;
}

.logo-cards .card {
  position: absolute;
  left: 50%;
  top: 0;
  margin-left: calc(var(--cw) / -2);
  transform-origin: 50% 120%;
  animation: fan-in 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.logo-cards .l1 { --r: -18deg; }
.logo-cards .l2 { --r: 0deg; animation-delay: 0.08s; }
.logo-cards .l3 { --r: 18deg; animation-delay: 0.16s; }

@keyframes fan-in {
  from { transform: rotate(0) translateY(20px); opacity: 0; }
  to { transform: rotate(var(--r)); opacity: 1; }
}

.logo h1 {
  margin: 0;
  font-size: clamp(42px, 13vw, 64px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.4);
}

.gold {
  background: linear-gradient(180deg, #ffe39a, var(--gold) 50%, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.room-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.room-code span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.room-code b {
  font-size: 46px;
  letter-spacing: 0.25em;
  margin-right: -0.25em;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(246, 196, 83, 0.4);
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  animation: pop 0.3s ease-out;
}

.player-list li.offline {
  opacity: 0.5;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  font-weight: 800;
  color: #2b1700;
  background: linear-gradient(135deg, #ffe39a, var(--gold-2));
}

.pname {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pname em {
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}

.tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(246, 196, 83, 0.18);
  color: var(--gold);
  white-space: nowrap;
}

.tag.dim {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.x {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
}

.hint,
.waiting {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.waiting {
  animation: breathe 2s ease-in-out infinite;
}

.footer-links {
  display: flex;
  gap: 8px;
}

@keyframes breathe {
  50% { opacity: 0.5; }
}

@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
}

/* ---------- cards ---------- */

.card {
  position: relative;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.11);
  font-size: calc(var(--cw) * 0.27);
  line-height: 1;
  isolation: isolate; /* a shiny card's shimmer stays on that card, under the cards on top of it */
}

.card.face {
  background: linear-gradient(160deg, #ffffff 0%, #f7f4ec 60%, #ece6d6 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 0 0 1px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.card.red { color: var(--red); }
.card.black { color: var(--ink); }

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05em;
  min-width: 1em;
}

.corner b {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: 1em;
  letter-spacing: -0.06em;
}

.corner i {
  font-style: normal;
  font-size: 0.85em;
}

.corner.tl { top: 0.28em; left: 0.24em; }
.corner.br { bottom: 0.28em; right: 0.24em; transform: rotate(180deg); }

.pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.1em;
}

.pip.ace {
  font-size: 2.9em;
}

.pip.court {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 18% 16%;
  border-radius: 0.2em;
  border: 1px solid currentColor;
  background:
    repeating-linear-gradient(45deg, transparent 0 3px, rgba(0, 0, 0, 0.035) 3px 6px),
    linear-gradient(180deg, rgba(246, 196, 83, 0.25), rgba(246, 196, 83, 0.08));
  font-size: 1em;
}

.pip.court b {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.9em;
}

.pip.court i {
  font-style: normal;
  font-size: 1em;
}

.special {
  position: absolute;
  left: 0.3em;
  bottom: 0.25em;
  font-size: 0.65em;
  font-weight: 800;
  opacity: 0.7;
}

.card.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 220, 150, 0.35) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #b3263f, #6d0f22);
  border: calc(var(--cw) * 0.055) solid #fbf7ee;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.card.back::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: calc(var(--cw) * 0.06);
  border: 1px solid rgba(255, 220, 150, 0.55);
}

.card.placeholder {
  display: grid;
  place-items: center;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.3);
  font-size: calc(var(--cw) * 0.17);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* rare shiny cards: holographic foil, a glint that sweeps across, twinkling stars, a pulsing golden glow */
.card.face.shiny {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 0 0 1.5px rgba(230, 175, 50, 0.95), 0 0 16px 2px rgba(255, 210, 110, 0.85), 0 3px 8px rgba(0, 0, 0, 0.35);
  animation: shiny-glow 1.8s ease-in-out infinite alternate;
}

@keyframes shiny-glow {
  to { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 0 0 1.5px rgba(255, 235, 150, 1), 0 0 26px 6px rgba(255, 200, 90, 0.95), 0 3px 8px rgba(0, 0, 0, 0.35); }
}

.card.shiny::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 0, 140, 0.42) 0%, rgba(255, 220, 0, 0.42) 17%, rgba(0, 230, 150, 0.42) 33%, rgba(0, 160, 255, 0.42) 50%, rgba(170, 0, 255, 0.42) 67%, rgba(255, 0, 140, 0.42) 83%, rgba(255, 220, 0, 0.42) 100%) 0 0 / 250% 250%,
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.16) 0 1.5px, transparent 1.5px 5px);
  animation: holo 3.2s ease-in-out infinite;
}

.card.shiny::after {
  content: '✨';
  position: absolute;
  z-index: 3;
  top: 4%;
  right: 6%;
  font-size: 0.6em;
  pointer-events: none;
  animation: twinkle 1.6s ease-in-out infinite;
}

@keyframes holo {
  50% { background-position: 100% 100%, 0 0; }
}

/* the glint: a bright streak running over the card now and then, and little stars flashing up */
.card .shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.card .shine::before {
  content: '';
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.95) 45%, rgba(255, 250, 220, 1) 50%, rgba(255, 255, 255, 0.95) 55%, transparent);
  transform: translateX(-120%) skewX(-12deg);
  animation: glint 2.8s ease-in-out infinite;
}

@keyframes glint {
  0%, 55% { transform: translateX(-120%) skewX(-12deg); }
  85%, 100% { transform: translateX(260%) skewX(-12deg); }
}

.card .shine::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 30%, #fff 0 1.5px, rgba(255, 240, 180, 0.8) 2px, transparent 5px),
    radial-gradient(circle at 70% 62%, #fff 0 1.5px, rgba(200, 230, 255, 0.8) 2px, transparent 5px),
    radial-gradient(circle at 38% 82%, #fff 0 1px, rgba(255, 200, 240, 0.8) 1.6px, transparent 4px);
  animation: stars 1.9s steps(1) infinite;
}

@keyframes stars {
  0% { opacity: 1; transform: none; }
  33% { opacity: 0.25; transform: translate(8%, -6%); }
  66% { opacity: 0.9; transform: translate(-6%, 5%); }
}
}

@keyframes twinkle {
  50% { transform: scale(0.55) rotate(25deg); opacity: 0.5; }
}

/* ---------- game layout ---------- */

.game {
  height: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 99px;
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.chip b {
  color: var(--gold);
  letter-spacing: 0.12em;
}

.topbar {
  justify-content: space-between;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  font-size: 18px;
}

/* opponents */

.opponents {
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px 0 4px;
}

.opponents::-webkit-scrollbar {
  display: none;
}

.opp-row {
  display: flex;
  gap: 8px;
  padding: 0 12px;
  width: max-content;
  min-width: 100%;
  justify-content: center;
}

.opp {
  --cw: clamp(17px, min(5.2vw, 3.4vh), 30px);
  flex: none;
  min-width: 84px;
  max-width: 130px;
  display: grid;
  gap: 5px;
  padding: 7px 8px 6px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  transition: box-shadow 0.3s, border-color 0.3s, transform 0.3s;
}

.opp.turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(246, 196, 83, 0.45);
  transform: scale(1.04);
}

.opp.offline,
.opp.done {
  opacity: 0.55;
}

.opp-head {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  min-width: 0;
}

.opp-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  flex: none;
}

.offline .dot {
  background: #888;
  box-shadow: none;
}

.opp-table {
  display: flex;
  justify-content: center;
  gap: 3px;
  min-height: calc(var(--cw) * 1.8);
}

.opp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 18px;
}

.opp-hand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 13px;
}

.badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.badge.gold { background: rgba(246, 196, 83, 0.2); color: var(--gold); }
.badge.ok { background: rgba(74, 222, 128, 0.18); color: var(--ok); }
.badge.dim { color: var(--muted); }

.mini-back {
  --cw: 12px;
  border-width: 1.5px !important;
}

.mini-back::after {
  display: none;
}

/* tiny opponent cards: rank in the corner and a suit, nothing else */
.opp .card.face {
  font-size: calc(var(--cw) * 0.42);
}

.opp .card .corner.br,
.opp .card .special,
.opp .card .corner i {
  display: none;
}

.opp .card .corner.tl {
  top: 0.15em;
  left: 0.15em;
}

.opp .card .pip,
.opp .card .pip.court,
.opp .card .pip.ace {
  inset: auto 0 0.1em auto;
  margin: 0;
  width: 100%;
  height: auto;
  display: block;
  text-align: right;
  padding-right: 0.15em;
  border: none;
  background: none;
  font-size: 1.15em;
}

.opp .card .pip.court b {
  display: none;
}

/* table slots (face-down with face-up on top) */

.slot {
  position: relative;
  width: var(--cw);
  height: calc(var(--cw) * 1.4 + var(--cw) * 0.4);
}

.slot .card {
  position: absolute;
  left: 0;
  top: 0;
}

.slot .card.up {
  top: calc(var(--cw) * 0.4);
}

.slot.played::before {
  content: '';
  position: absolute;
  left: 0;
  top: calc(var(--cw) * 0.2);
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  box-sizing: border-box;
  border: 1.5px dashed rgba(255, 255, 255, 0.25);
  border-radius: calc(var(--cw) * 0.11);
  background: rgba(0, 0, 0, 0.12);
}

/* center table */

.table {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(40px, 14vw, 96px);
  --cw: clamp(56px, min(21vw, 13vh), 112px);
}

.deck-wrap,
.pile-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.deck-wrap {
  --cw: clamp(40px, min(12vw, 8.5vh), 74px);
}

.deck .card.stacked {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    2px 2px 0 -1px #f2ecdc, 2px 2px 0 0 rgba(0, 0, 0, 0.25),
    4px 4px 0 -1px #f2ecdc, 4px 4px 0 0 rgba(0, 0, 0, 0.25),
    6px 7px 12px rgba(0, 0, 0, 0.4);
}

/* the card a dragged card would be swapped with */
.card.swap-hot {
  transform: translateY(-8px) scale(1.08);
  box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(246, 196, 83, 0.8);
  z-index: 5;
}

/* how many cards of the top rank lie there together */
.pile-run {
  position: absolute;
  z-index: 30;
  right: calc(var(--cw) * -0.55);
  top: calc(var(--cw) * -0.2);
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  color: #2b1700;
  background: linear-gradient(180deg, #ffe39a, var(--gold-2));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.pile-info {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.pile-info b {
  color: var(--text);
}

.pile {
  position: relative;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
}

.pile > .card {
  position: absolute;
  inset: 0;
  transform: translate(var(--x), var(--y)) rotate(var(--rot));
}

.pile > .card.enter {
  animation: drop 0.38s cubic-bezier(0.2, 0.8, 0.3, 1.15);
}

@keyframes drop {
  from {
    transform: translate(var(--x), calc(var(--y) - 40px)) rotate(calc(var(--rot) - 25deg)) scale(1.35);
    opacity: 0;
  }
}

.burning {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.burning .card {
  position: absolute;
  inset: 0;
  transform: rotate(var(--rot));
  animation: blast-card 0.9s cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}

@keyframes blast-card {
  0% { filter: brightness(2) sepia(1) saturate(4); }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(calc(var(--rot) + var(--spin))) scale(0.4);
    opacity: 0;
    filter: brightness(0.3);
  }
}

/* 7s on the pile are see-through */
.pile > .card.ghost {
  opacity: 0.55;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 16px rgba(180, 220, 255, 0.5);
}

.boom {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: 70;
  width: 0;
  height: 0;
  pointer-events: none;
}

.boom .flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 45%), rgba(255, 245, 200, 0.9), rgba(255, 140, 30, 0.35) 40%, transparent 70%);
  animation: boom-flash 0.6s ease-out forwards;
}

.boom .ring {
  position: absolute;
  left: -40px;
  top: -40px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 6px solid #ffd66b;
  box-shadow: 0 0 30px #ff8a1f, inset 0 0 20px #ff8a1f;
  animation: boom-ring 0.7s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.boom .ring.r2 {
  border-color: #ff6a2b;
  animation-delay: 0.08s;
  animation-duration: 0.9s;
}

.boom .spark {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6c8, #ffb020 50%, #ff4d1a);
  box-shadow: 0 0 10px #ff9a1f;
  transform: rotate(var(--a)) translateX(0) scale(var(--s));
  animation: spark 0.85s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.boom-text {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: clamp(64px, 22vw, 150px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #fff3c4;
  -webkit-text-stroke: 3px #b3261e;
  paint-order: stroke fill;
  text-shadow: 0 0 20px #ff8a1f, 0 0 50px #ff4d1a, 0 6px 0 #7a1410;
  animation: boom-text 1.3s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

@keyframes boom-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes boom-ring {
  from { transform: scale(0.2); opacity: 1; }
  to { transform: scale(9); opacity: 0; border-width: 1px; }
}

@keyframes spark {
  to { transform: rotate(var(--a)) translateX(var(--d)) scale(0); }
}

@keyframes boom-text {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(-6deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(1.1) rotate(-6deg); opacity: 0; }
}

.game.quake {
  animation: quake 0.8s ease-out;
}

@keyframes quake {
  10%, 50% { transform: translate(-10px, 5px); }
  30%, 70% { transform: translate(10px, -6px); }
  90% { transform: translate(-3px, 1px); }
}

.game.quake-heavy {
  animation: quake-heavy 1.6s ease-out;
}

@keyframes quake-heavy {
  5%, 25% { transform: translate(-14px, 8px) rotate(-1deg); }
  15%, 35% { transform: translate(14px, -10px) rotate(1deg); }
  45%, 65% { transform: translate(-7px, 4px); }
  55%, 75% { transform: translate(7px, -4px); }
  85% { transform: translate(-2px, 1px); }
}

/* ---------- 10: bigger blast with lametta ---------- */

.boom .fireball {
  position: absolute;
  left: -30vmin;
  top: -30vmin;
  width: 60vmin;
  height: 60vmin;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #fff3b0 18%, #ffb000 38%, #ff5a00 58%, rgba(180, 20, 0, 0.6) 72%, transparent 80%);
  filter: blur(4px);
  animation: fireball 1s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes fireball {
  0% { transform: scale(0.1); opacity: 1; }
  40% { opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.boom .ring.r3 {
  border-color: #fff;
  border-width: 3px;
  animation-delay: 0.16s;
  animation-duration: 1.1s;
}

.boom .ring.r2,
.boom .ring.r3 {
  animation-fill-mode: both;
}

.boom .tinsel {
  position: absolute;
  left: -2px;
  top: -9px;
  width: 5px;
  height: 18px;
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 240, 200, 0.6);
  animation: tinsel 3s cubic-bezier(0.15, 0.6, 0.4, 1) both;
}

.tinsel.t-gold { background: linear-gradient(90deg, #8a6a12, #fff3b0 50%, #c9971c); }
.tinsel.t-silver { background: linear-gradient(90deg, #6f747a, #ffffff 50%, #a9aeb5); }
.tinsel.t-red { background: linear-gradient(90deg, #7a0b16, #ff8a9a 50%, #c41e3a); }
.tinsel.t-green { background: linear-gradient(90deg, #0b5a2a, #8dffb5 50%, #1f9d55); }

@keyframes tinsel {
  0% { transform: translate(0, 0) rotate(0) rotateY(0) scale(0.3); opacity: 1; }
  22% {
    transform: translate(var(--dx), var(--dy)) rotate(calc(var(--r) * 0.3)) rotateY(540deg) scale(1);
    opacity: 1;
    animation-timing-function: ease-in-out;
  }
  85% { opacity: 1; }
  100% {
    transform: translate(calc(var(--dx) + var(--sway)), calc(var(--dy) + var(--fall))) rotate(var(--r)) rotateY(2160deg) scale(1);
    opacity: 0;
  }
}

/* flames left on the table, dying down over 9 seconds */
.table-fire {
  position: absolute;
  z-index: 0;
  left: -70%;
  right: -70%;
  bottom: -14%;
  height: 95%;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: fire-die 9s linear forwards;
}

.table-fire .scorch {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 26%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(20, 8, 0, 0.75), rgba(40, 15, 0, 0.4) 50%, transparent 72%);
}

.table-fire .tongue {
  position: absolute;
  bottom: 6%;
  width: 20%;
  margin-left: -10%;
  height: calc(var(--h) * 75%);
  border-radius: 50% 50% 35% 35% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse 50% 60% at 50% 85%, #fffbe0 0%, #ffd23a 22%, #ff7a00 50%, rgba(220, 40, 0, 0.7) 68%, transparent 78%);
  filter: blur(2px);
  transform-origin: 50% 100%;
  animation: flicker 0.45s ease-in-out infinite alternate;
}

@keyframes flicker {
  from { transform: scale(1.05, 0.85) skewX(-5deg); }
  to { transform: scale(0.9, 1.12) skewX(6deg) translateY(-3%); }
}

@keyframes fire-die {
  0% { opacity: 1; transform: scale(1.15, 1.3); }
  15% { opacity: 1; transform: scale(1, 1); }
  70% { opacity: 0.75; transform: scale(0.9, 0.6); }
  100% { opacity: 0; transform: scale(0.8, 0.2); }
}

/* ---------- four of a kind: nuke ---------- */

.boom.nuke .whiteout {
  position: fixed;
  inset: 0;
  background: #fff;
  animation: whiteout 2.4s ease-out forwards;
}

@keyframes whiteout {
  0%, 12% { opacity: 1; background: #fff; }
  35% { opacity: 0.85; background: #ffe7a8; }
  100% { opacity: 0; background: #ff7a1a; }
}

.boom.nuke .dust {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 120% 70% at var(--fx, 50%) var(--fy, 45%), rgba(255, 140, 40, 0.5), rgba(90, 40, 20, 0.55) 45%, rgba(20, 10, 5, 0.7) 100%);
  animation: dust 5.4s ease-in-out both;
}

@keyframes dust {
  0% { opacity: 0; }
  25%, 65% { opacity: 1; }
  100% { opacity: 0; }
}

.boom.nuke .shock {
  position: absolute;
  left: -6vmin;
  top: -6vmin;
  width: 12vmin;
  height: 12vmin;
  border-radius: 50%;
  border: 1.2vmin solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 40px #fff, inset 0 0 30px rgba(255, 200, 120, 0.8);
  animation: shock 1.6s cubic-bezier(0.1, 0.7, 0.3, 1) 0.1s both;
}

@keyframes shock {
  from { transform: scale(0.3); opacity: 1; }
  to { transform: scale(22); opacity: 0; }
}

.mushroom {
  position: absolute;
  left: 0;
  top: 0;
  scale: var(--ns, 1);
  transform-origin: 0 0;
  animation: nuke-fade 5.4s ease-in forwards;
}

.mushroom > * {
  position: absolute;
}

.mushroom .stem {
  left: -7vmin;
  bottom: -6vmin;
  width: 14vmin;
  height: 50vmin;
  border-radius: 45% 45% 20% 20% / 20% 20% 10% 10%;
  background: linear-gradient(to top, #fff1b8, #ffae2e 20%, #ff6a1a 45%, #9a3a14 75%, rgba(80, 30, 15, 0.2));
  filter: blur(3px);
  transform-origin: 50% 100%;
  animation: stem 1.8s cubic-bezier(0.2, 0.8, 0.3, 1) 0.15s both;
}

@keyframes stem {
  from { transform: scale(2.5, 0); }
  to { transform: scale(1, 1); }
}

.mushroom .cap {
  left: -36vmin;
  top: -70vmin;
  width: 72vmin;
  height: 40vmin;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse 60% 55% at 50% 65%, #fff6c8 0%, #ffc43a 18%, #ff6a00 42%, #a8330e 66%, #4a1c10 88%, transparent 100%);
  box-shadow: 0 0 80px rgba(255, 110, 0, 0.7);
  filter: blur(2px);
  transform-origin: 50% 100%;
  animation: cap 2.4s cubic-bezier(0.15, 0.75, 0.3, 1) 0.2s both;
}

.mushroom .cap.c2 {
  left: -24vmin;
  top: -66vmin;
  width: 48vmin;
  height: 26vmin;
  background: radial-gradient(ellipse at 50% 60%, rgba(255, 250, 220, 0.95), rgba(255, 180, 40, 0.6) 40%, transparent 72%);
  box-shadow: none;
  animation: cap 2.4s cubic-bezier(0.15, 0.75, 0.3, 1) 0.3s both, boil 0.9s ease-in-out 2.7s infinite alternate;
}

@keyframes cap {
  from { transform: translateY(55vmin) scale(0.1); opacity: 0; }
  15% { opacity: 1; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes boil {
  from { transform: scale(1); }
  to { transform: scale(1.08, 0.94); }
}

.mushroom .collar {
  left: -20vmin;
  top: -30vmin;
  width: 40vmin;
  height: 8vmin;
  border-radius: 50%;
  border: 0.9vmin solid rgba(255, 220, 180, 0.55);
  filter: blur(1.5px);
  animation: collar 2.5s ease-out 0.9s both;
}

@keyframes collar {
  from { transform: scale(0.2); opacity: 0; }
  30% { opacity: 1; }
  to { transform: scale(1.4); opacity: 0.2; }
}

@keyframes nuke-fade {
  0%, 70% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-8vmin); }
}

.boom .ember {
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffcf6b;
  box-shadow: 0 0 8px #ff7a1a, 0 0 2px #fff;
  animation: ember 3s ease-out both;
}

@keyframes ember {
  from { transform: translate(0, 0) scale(1.4); opacity: 0; }
  10% { opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

.boom-text.nuke-text {
  left: calc(50vw - var(--fx, 50vw)); /* centered on the screen, not on the pile */
  top: 22vmin;
  font-size: clamp(24px, 7.5vw, 72px);
  color: #fff7d6;
  -webkit-text-stroke: 2px #3a1a00;
  text-shadow: 0 0 24px #ffb000, 0 0 60px #ff4d1a, 0 5px 0 #3a1a00;
  animation: boom-text 4.4s cubic-bezier(0.2, 1.4, 0.4, 1) 0.5s both;
}

.status {
  flex: none;
  height: 52px;
  overflow: hidden;
  text-align: center;
  padding: 2px 16px 6px;
}

.status-text,
.status-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-text {
  font-size: 18px;
  font-weight: 800;
}

.status-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.status.mine-turn .status-text {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(246, 196, 83, 0.55);
  animation: breathe-glow 1.6s ease-in-out infinite;
}

@keyframes breathe-glow {
  50% { text-shadow: 0 0 4px rgba(246, 196, 83, 0.2); }
}

/* my area */

.mine {
  flex: none;
  padding: 10px 0 calc(10px + max(0px, 4px - env(safe-area-inset-bottom)));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.28) 30%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 28px 28px 0 0;
  transition: box-shadow 0.3s;
}

.mine.my-turn {
  box-shadow: inset 0 2px 0 rgba(246, 196, 83, 0.55), 0 -12px 40px -12px rgba(246, 196, 83, 0.35);
}

.tablecards {
  --cw: clamp(44px, min(13.5vw, 8.6vh), 84px);
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
}

.hand {
  --cw: clamp(52px, min(17vw, 10.8vh), 100px);
  display: grid;
  justify-content: center;
  padding: 22px 8px 8px;
  min-height: calc(var(--cw) * 1.4 + 30px);
}

.hand.rows {
  --cw: clamp(46px, min(14.5vw, 8.6vh), 88px);
}

.hand > .card,
.tablecards .card {
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2), box-shadow 0.18s, filter 0.2s;
}

/* my cards can be grabbed in any direction, so the browser must not scroll or zoom on them */
.hand > .card,
.tablecards .card {
  cursor: pointer;
  touch-action: none;
  -webkit-touch-callout: none;
}

.card.dragging {
  opacity: 0.2;
}

.drag-ghost {
  position: fixed;
  z-index: 60;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  pointer-events: none;
  will-change: transform;
}

/* a card flying around can be caught again */
.drag-ghost.loose {
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.drag-ghost .card {
  position: absolute;
  top: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 18px 40px rgba(0, 0, 0, 0.55);
}

.pile-wrap.drop-hot .pile::after {
  content: '';
  position: absolute;
  z-index: 40;
  inset: -12px;
  border-radius: 18px;
  border: 2px dashed var(--gold);
  background: rgba(246, 196, 83, 0.12);
  box-shadow: 0 0 34px rgba(246, 196, 83, 0.55);
  animation: breathe 0.9s ease-in-out infinite;
}

.card.playable {
  cursor: pointer;
}

.card.blocked {
  filter: brightness(0.6) saturate(0.6);
}

.card.selected {
  transform: translateY(-18px);
  box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(0, 0, 0, 0.45), 0 0 24px rgba(246, 196, 83, 0.6);
  z-index: 5 !important;
}

.slot .card.up.selected {
  transform: translateY(-14px);
}

.tablecards.pick-down .card.down {
  cursor: pointer;
  animation: wiggle 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(246, 196, 83, 0.55);
}

.tablecards.pick-down .slot:nth-child(2) .card.down { animation-delay: 0.2s; }
.tablecards.pick-down .slot:nth-child(3) .card.down { animation-delay: 0.4s; }

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-3deg) translateY(-3px); }
  75% { transform: rotate(3deg) translateY(-3px); }
}

.card.shake {
  animation: shake 0.35s;
}

@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* always takes the space of a button, so buttons coming and going never move the cards */
.actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 2px 16px 0;
  max-width: 460px;
  margin: 0 auto;
}

.btn.side {
  flex: none;
  width: auto;
  padding: 13px 18px;
}

/* "Hold to pick up" keeps its place and size on the right while cards are picked;
   the play button appears in the free space to its left */
.actions.with-hold {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.actions.with-hold [data-hold] {
  grid-column: 2;
  grid-row: 1;
}

.actions.with-hold > .btn {
  height: 52px;
  padding: 0 12px;
  font-size: 15px;
  white-space: nowrap;
}

.phase-swap .slot .card.up,
.phase-swap .hand .card {
  cursor: pointer;
}

@keyframes fade {
  from { opacity: 0; }
}

/* ---------- sheets ---------- */

.sheet-bg {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  animation: fade 0.2s;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 88%;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #164a31, #0a2c1c);
  border: 1px solid var(--line);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  animation: slide-up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  user-select: text;
  -webkit-user-select: text;
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.sheet p,
.sheet li {
  margin: 0;
  line-height: 1.45;
  color: rgba(243, 247, 244, 0.88);
  font-size: 15px;
}

.sheet ul:not(.player-list) {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

.sheet-sub {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
}

@media (min-width: 700px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 26px; }
}

/* ---------- the scene around the table (changed by the ace slot machine) ---------- */

body[data-felt='backroom'] { --map: url('/scenes/backroom.webp'); }
body[data-felt='tv'] { --map: url('/scenes/tv.webp'); }
body[data-felt='saloon'] { --map: url('/scenes/saloon.webp'); }
body[data-felt='stammtisch'] { --map: url('/scenes/stammtisch.webp'); }
body[data-felt='yacht'] { --map: url('/scenes/yacht.webp'); }

#scene,
.scene-cloth {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  container-type: size;
}

/* the painted picture covers the screen on phones; wide screens see all of it in the middle */
.scene-box {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: max(100cqw, 61.3cqh);
  height: max(100cqh, 163.1cqw);
  box-shadow: 0 0 80px 30px rgba(0, 0, 0, 0.6);
}

@media (min-aspect-ratio: 3/4) {
  .scene-box {
    width: 61.3cqh;
    height: 100cqh;
  }
}

/* wide screens: each scene painted in landscape (WIDE in app.js picks the matching props),
   covering the whole screen */
@media (min-aspect-ratio: 1/1) {
  body[data-felt='vegas'], body:not([data-felt]) { --map: url('/scenes/vegas-wide.webp'); }
  body[data-felt='backroom'] { --map: url('/scenes/backroom-wide.webp'); }
  body[data-felt='tv'] { --map: url('/scenes/tv-wide.webp'); }
  body[data-felt='saloon'] { --map: url('/scenes/saloon-wide.webp'); }
  body[data-felt='stammtisch'] { --map: url('/scenes/stammtisch-wide.webp'); }
  body[data-felt='yacht'] { --map: url('/scenes/yacht-wide.webp'); }

  .scene-box {
    width: max(100cqw, 177.7cqh);
    height: max(100cqh, 56.3cqw);
    box-shadow: none;
  }
}

.scene-img,
.prop {
  background-image: var(--map);
  background-repeat: no-repeat;
}

.scene-img {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
}

.scene-shade {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 65% at 50% 46%, rgba(0, 0, 0, 0.05) 35%, rgba(0, 0, 0, 0.42) 100%);
}

/* a tappable thing: a copy of that bit of the picture, feathered so it lifts off cleanly */
.prop {
  position: absolute;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent);
  mask-image: radial-gradient(closest-side, #000 72%, transparent);
  transform-origin: 50% 60%;
}

.prop.p-jump { animation: p-jump 0.8s cubic-bezier(0.3, 0.7, 0.4, 1); }
.prop.p-wobble { animation: p-wobble 0.8s ease-out; }
.prop.p-shake { animation: p-shake 0.7s linear; }
.prop.p-spin { animation: p-spin 0.85s cubic-bezier(0.2, 0.8, 0.3, 1); }
.prop.p-flip { animation: p-flip 0.85s ease-out; }
.prop.p-glow { animation: p-glow 0.85s ease-out; }
.prop.p-swing { animation: p-swing 0.9s ease-out; transform-origin: 50% 0; }
.prop.p-recoil { animation: p-recoil 0.6s cubic-bezier(0.2, 0.9, 0.3, 1); }

@keyframes p-jump {
  30% { transform: translateY(-35%) scale(1.3) rotate(-8deg); filter: drop-shadow(0 18px 10px rgba(0, 0, 0, 0.5)); }
  55% { transform: scale(1.15, 0.85); }
  75% { transform: translateY(-8%) scale(1.04); }
}

@keyframes p-wobble {
  15% { transform: rotate(-12deg) scale(1.12); }
  35% { transform: rotate(10deg) scale(1.1); }
  55% { transform: rotate(-6deg); }
  75% { transform: rotate(3deg); }
}

@keyframes p-shake {
  10%, 30%, 50%, 70% { transform: translateX(-7%) rotate(-3deg) scale(1.08); }
  20%, 40%, 60%, 80% { transform: translateX(7%) rotate(3deg) scale(1.08); }
}

@keyframes p-spin {
  40% { transform: scale(1.35) rotate(300deg); filter: drop-shadow(0 14px 8px rgba(0, 0, 0, 0.5)); }
  to { transform: rotate(360deg); }
}

@keyframes p-flip {
  45% { transform: translateY(-60%) rotateY(900deg) scale(1.3); }
  to { transform: rotateY(1440deg); }
}

@keyframes p-glow {
  0%, 40% { filter: brightness(2.2) saturate(1.4) drop-shadow(0 0 16px #fff); transform: scale(1.15); }
}

@keyframes p-swing {
  15% { transform: rotate(16deg); }
  40% { transform: rotate(-11deg); }
  65% { transform: rotate(6deg); }
  85% { transform: rotate(-2deg); }
}

@keyframes p-recoil {
  15% { transform: translateX(10%) rotate(-14deg) scale(1.05); }
}

.scene-cloth {
  box-shadow: -30px 0 50px rgba(0, 0, 0, 0.5);
  animation: cloth-pull 0.75s cubic-bezier(0.6, -0.3, 0.9, 0.6) forwards;
}

@keyframes cloth-pull {
  20% { transform: translateX(-3%); }
  100% { transform: translateX(125%) skewX(-18deg) scaleY(0.9); }
}

/* ---------- what keeps each scene alive ---------- */
/* Phones have little graphics memory: every animated layer here is only as big as its effect,
   moves by transform or opacity only (no repainting), and nothing uses blend modes or blur.
   Full-screen effect layers made cards flicker and vanish on phones. */

.amb {
  position: absolute;
  pointer-events: none;
}

/* vegas: a gleam runs over the felt, the slot machines flicker */
.amb.sweep {
  left: 0;
  top: 0;
  width: 30%;
  height: 100%;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 240, 200, 0.12) 50%, transparent 80%);
  animation: sweep 8s ease-in-out infinite;
}

@keyframes sweep {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(340%); }
}

.amb.neon-a,
.amb.neon-b {
  top: -4%;
  width: 36%;
  height: 17%;
}

.amb.neon-a {
  left: 4%;
  background: radial-gradient(closest-side, rgba(255, 70, 200, 0.4), transparent);
  animation: neon 2.3s steps(1) infinite;
}

.amb.neon-b {
  left: 60%;
  background: radial-gradient(closest-side, rgba(255, 200, 70, 0.4), transparent);
  animation: neon 3.1s steps(1) infinite reverse;
}

@keyframes neon {
  0%, 100% { opacity: 1; }
  8% { opacity: 0.3; }
  12% { opacity: 1; }
  50% { opacity: 0.65; }
  54% { opacity: 1; }
}

/* backroom: the bulb hums and flickers, smoke curls up */
.amb.lamplight {
  left: 10%;
  top: 2%;
  width: 80%;
  height: 46%;
  background: radial-gradient(closest-side, rgba(255, 205, 130, 0.22), transparent);
  transform-origin: 50% 10%;
  animation: bulb 5s linear infinite;
}

.scene-box.lamp-swing .amb.lamplight {
  animation: lamp-swing 2.6s ease-out;
}

@keyframes bulb {
  0%, 31%, 35%, 70%, 100% { opacity: 1; }
  32%, 34% { opacity: 0.35; }
  71% { opacity: 0.7; }
}

@keyframes lamp-swing {
  10% { transform: rotate(14deg); }
  30% { transform: rotate(-10deg); }
  50% { transform: rotate(6deg); }
  70% { transform: rotate(-3deg); }
}

.amb.smoke-a,
.amb.smoke-b {
  width: 16%;
  height: 10%;
  background: radial-gradient(closest-side, rgba(225, 225, 225, 0.25), transparent);
  animation: smoke 6s ease-out infinite;
}

.amb.smoke-a { left: 70%; top: 5%; }
.amb.smoke-b { left: 22%; top: 79%; animation-duration: 7.5s; animation-delay: -3s; }

@keyframes smoke {
  0% { transform: translateY(20%) scale(0.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(30%, -120%) scale(1.8) rotate(40deg); opacity: 0; }
}

/* tv: spotlights sweep over the table, the camera is recording */
.amb.beam-a,
.amb.beam-b {
  top: 3%;
  width: 30%;
  height: 90%;
  background: linear-gradient(to bottom, rgba(190, 225, 255, 0.22), transparent 75%);
  clip-path: polygon(45% 0, 55% 0, 100% 100%, 0 100%);
  transform-origin: 50% 0;
}

.amb.beam-a { left: 4%; animation: beam 9s ease-in-out infinite; }
.amb.beam-b { left: 66%; animation: beam 11s ease-in-out infinite reverse; }

@keyframes beam {
  0%, 100% { transform: rotate(-35deg); }
  50% { transform: rotate(30deg); }
}

.amb.tally {
  left: 52.5%;
  top: 2.2%;
  width: 1.6%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ff2a2a;
  box-shadow: 0 0 8px 3px rgba(255, 40, 40, 0.8);
  animation: tally 1.4s steps(1) infinite;
}

@keyframes tally {
  50% { opacity: 0.15; }
}

/* saloon: sun falls in through the window (painted once), dust drifts in it */
.amb.sunbeams {
  inset: 0;
  background: repeating-linear-gradient(115deg, transparent 0 6%, rgba(255, 220, 150, 0.09) 6% 9%, transparent 9% 14%);
  -webkit-mask-image: linear-gradient(to left, #000, transparent 75%);
  mask-image: linear-gradient(to left, #000, transparent 75%);
}

.amb.motes {
  left: 50%;
  top: 0;
  width: 50%;
  height: 50%;
  overflow: hidden;
}

/* dust, glitter and bubbles: a pattern one tile larger than its box slides by one tile */
.amb.motes::before,
.amb.moonsea::before,
.amb.beer-a::before,
.amb.beer-b::before {
  content: '';
  position: absolute;
}

.amb.motes::before {
  inset: -106px -74px 0 0;
  background:
    radial-gradient(circle, rgba(255, 232, 170, 0.7) 0 1.4px, transparent 2px) 0 0 / 37px 53px,
    radial-gradient(circle, rgba(255, 232, 170, 0.5) 0 1px, transparent 1.6px) 11px 17px / 37px 53px;
  animation: motes 14s linear infinite;
}

@keyframes motes {
  to { transform: translate(74px, 106px); }
}

/* stammtisch: the candle flickers, the beer fizzes */
.amb.candlelight {
  left: 60%;
  top: -8%;
  width: 52%;
  height: 30%;
  background: radial-gradient(closest-side, rgba(255, 180, 80, 0.3), transparent), radial-gradient(6% 7% at 50% 45%, rgba(255, 240, 200, 0.7), transparent);
  animation: glow-flicker 0.9s ease-in-out infinite alternate;
}

@keyframes glow-flicker {
  0% { opacity: 0.7; }
  30% { opacity: 1; }
  55% { opacity: 0.82; }
  80% { opacity: 0.95; }
  100% { opacity: 0.75; }
}

.amb.beer-a,
.amb.beer-b {
  width: 9%;
  height: 7%;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
}

.amb.beer-a { left: 11.5%; top: 12%; }
.amb.beer-b { left: 79.5%; top: 79%; }

.amb.beer-a::before,
.amb.beer-b::before {
  inset: 0 0 -22px 0;
  background:
    radial-gradient(circle, rgba(255, 250, 220, 0.85) 0 1px, transparent 1.6px) 0 0 / 9px 11px,
    radial-gradient(circle, rgba(255, 250, 220, 0.6) 0 0.8px, transparent 1.3px) 4px 5px / 7px 11px;
  animation: bubbles 2.2s linear infinite;
}

@keyframes bubbles {
  to { transform: translateY(-22px); }
}

/* yacht: moonlight glitters on the sea, the deck lamps glow, the boat rocks gently */
.scene-box.yacht {
  scale: 1.03;
  animation: rock 10s ease-in-out infinite;
}

@keyframes rock {
  0%, 100% { rotate: -0.6deg; }
  50% { rotate: 0.6deg; }
}

.amb.moonsea {
  left: 30%;
  top: 5.5%;
  width: 70%;
  height: 7%;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(45% 60% at 38% 50%, #000, transparent);
  mask-image: radial-gradient(45% 60% at 38% 50%, #000, transparent);
  animation: sea-twinkle 0.7s steps(2) infinite;
}

.amb.moonsea::before {
  inset: 0 0 0 -34px;
  background:
    radial-gradient(circle, rgba(255, 255, 230, 0.95) 0 1px, transparent 1.8px) 0 0 / 17px 7px,
    radial-gradient(circle, rgba(200, 220, 255, 0.8) 0 0.8px, transparent 1.4px) 6px 3px / 17px 9px;
  animation: glitter 5s linear infinite;
}

@keyframes glitter {
  to { transform: translateX(34px); }
}

@keyframes sea-twinkle {
  50% { opacity: 0.55; }
}

.amb.caustics {
  left: -6%;
  top: 10%;
  width: 112%;
  height: 12%;
  background: radial-gradient(9% 50% at 9% 50%, rgba(255, 200, 120, 0.5), transparent), radial-gradient(9% 50% at 92% 66%, rgba(255, 200, 120, 0.5), transparent);
  animation: glow-flicker 1.3s ease-in-out infinite alternate;
}

/* ---------- what tapping the scene throws around ---------- */

.bit2 {
  position: fixed;
  z-index: 66;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  pointer-events: none;
  animation: particle var(--t) cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}

.bit2.chip { width: 15px; height: 15px; margin: -7px 0 0 -7px; border: 3px dashed rgba(255, 255, 255, 0.9); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4); }
.bit2.bubble { width: 8px; height: 8px; border: 1.5px solid rgba(255, 255, 255, 0.85); background: rgba(255, 255, 255, 0.15); }
.bit2.foam { width: 12px; height: 12px; background: #fffbe8; }
.bit2.fizz { width: 5px; height: 5px; background: #fff7c0; box-shadow: 0 0 6px #ffe680; }
.bit2.coin { width: 14px; height: 14px; background: radial-gradient(circle at 35% 35%, #fff3a0, #d4a017 60%, #8a6508); }
.bit2.bill { width: 24px; height: 12px; border-radius: 2px; background: linear-gradient(#b8e0a8, #6fa868); border: 1px solid #3c6b37; }
.bit2.spark { width: 6px; height: 6px; background: #fff; box-shadow: 0 0 8px 2px #ffd24a; }
.bit2.ember { width: 5px; height: 5px; background: #ffb347; box-shadow: 0 0 8px 2px #ff6a00; }
.bit2.smoke { width: 34px; height: 34px; margin: -17px 0 0 -17px; background: radial-gradient(closest-side, rgba(230, 230, 230, 0.5), transparent); }
.bit2.puff { width: 14px; height: 14px; background: radial-gradient(closest-side, rgba(235, 222, 196, 0.85), transparent); }
.bit2.drop { width: 6px; height: 9px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: rgba(170, 220, 255, 0.9); }
.bit2.rainbow { width: 8px; height: 8px; }

.tap-ring {
  position: fixed;
  z-index: 54;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: tap-ring 0.7s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.tap-ring.gold { border-color: #ffd24a; }
.tap-ring.water { border-width: 2px; border-color: rgba(170, 220, 255, 0.85); }
.tap-ring.rainbow { border-color: #ff6ef3; box-shadow: 0 0 18px #4dd0ff, inset 0 0 18px #7dff7a; }

@keyframes tap-ring {
  from { transform: scale(0.3); opacity: 1; }
  to { transform: scale(calc(2.2 * var(--p))); opacity: 0; }
}

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 59;
  pointer-events: none;
  animation: fade-out var(--t) ease-out forwards;
}

.bullet-hole {
  position: fixed;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: radial-gradient(circle, #000 0 30%, #3a2a1a 42%, transparent 70%);
  pointer-events: none;
  rotate: var(--r);
  animation: hole 5s ease-in forwards;
}

@keyframes hole {
  0% { transform: scale(1.8); }
  5% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- ace slot machine ---------- */

.slot-machine {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: 65;
  width: 0;
  height: 0;
  pointer-events: none;
}

.slot-machine .cabinet {
  --sh: clamp(34px, 9vw, 46px);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 8px;
  border-radius: 18px;
  text-align: left;
  background: linear-gradient(180deg, #4a0d1a, #1a0308);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 3px #7a4a0a, 0 0 40px rgba(246, 196, 83, 0.6), 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
  animation: cabinet-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

.reels {
  flex: none;
  display: flex;
  gap: 4px;
}

.slot-text {
  min-width: 0;
  max-width: min(56vw, 240px);
}

.reel {
  width: calc(var(--sh) * 1.05);
  height: var(--sh);
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #b9b9b9, #fff 30%, #fff 70%, #b9b9b9);
  box-shadow: inset 0 5px 8px rgba(0, 0, 0, 0.45), inset 0 -5px 8px rgba(0, 0, 0, 0.45);
}

.strip {
  transition: transform var(--t) cubic-bezier(0.12, 0.6, 0.2, 1.03);
}

.spin .strip {
  transform: translateY(calc(var(--n) * var(--sh) * -1));
}

.strip span {
  display: grid;
  place-items: center;
  height: var(--sh);
  font-size: calc(var(--sh) * 0.62);
  line-height: 1;
}

.slot-result {
  min-height: 18px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  color: #fff3c4;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.landed .slot-result {
  opacity: 1;
  transform: none;
}

.landed .reel {
  animation: reel-win 0.6s ease-out;
}

@keyframes reel-win {
  30% { box-shadow: inset 0 0 0 3px var(--gold), 0 0 24px var(--gold); }
}

.slot-machine.landed::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at var(--fx, 50%) var(--fy, 45%), rgba(255, 255, 255, 0.55), transparent 60%);
  animation: boom-flash 0.7s ease-out forwards;
}

.slot-machine.jackpot .cabinet {
  animation: cabinet-in 0.35s both, jackpot 0.3s 0.1s 6 alternate;
}

@keyframes jackpot {
  to {
    box-shadow: 0 0 0 3px #fff, 0 0 90px #ffd700, 0 20px 50px rgba(0, 0, 0, 0.6);
    filter: brightness(1.25);
  }
}

.slot-machine.out .cabinet {
  animation: cabinet-out 0.45s ease-in forwards;
}

@keyframes cabinet-in {
  from { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); opacity: 0; }
}

@keyframes cabinet-out {
  to { transform: translate(-50%, -40%) scale(0.5); opacity: 0; }
}

/* ---------- Shithead ceremony and crown of shame ---------- */

.tag.shame {
  background: rgba(139, 69, 19, 0.45);
  color: #ffd8a8;
}

.shame-crown {
  flex: none;
  font-size: 13px;
  animation: crown-wobble 1.6s ease-in-out infinite;
}

@keyframes crown-wobble {
  50% { transform: rotate(-14deg) translateY(-2px); }
}

.ceremony {
  position: fixed;
  inset: 0;
  z-index: 85;
  pointer-events: none;
  overflow: hidden;
}

.ceremony i {
  position: absolute;
  top: -70px;
  left: var(--x);
  font-size: var(--s);
  font-style: normal;
  line-height: 1;
  animation: poop-fall var(--d) cubic-bezier(0.45, 0, 0.8, 0.6) var(--delay) both;
}

@keyframes poop-fall {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(calc(100vh + 140px)) rotate(var(--r)); }
}

.shame-stamp {
  position: absolute;
  left: 50%;
  top: 18%;
  padding: 10px 18px;
  border: 5px solid #8b4513;
  border-radius: 14px;
  font-size: clamp(26px, 9vw, 64px);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  color: #8b4513;
  background: rgba(255, 236, 200, 0.92);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: stamp 4.8s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

@keyframes stamp {
  0% { transform: translateX(-50%) scale(3) rotate(-25deg); opacity: 0; }
  10% { transform: translateX(-50%) scale(1) rotate(-10deg); opacity: 1; }
  80% { transform: translateX(-50%) scale(1) rotate(-10deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.9) rotate(-10deg); opacity: 0; }
}

.particle {
  position: fixed;
  z-index: 66;
  margin: -0.5em 0 0 -0.5em;
  font-style: normal;
  line-height: 1;
  pointer-events: none;
  animation: particle 0.95s cubic-bezier(0.15, 0.7, 0.4, 1) forwards;
}

@keyframes particle {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.3); opacity: 0; }
}

/* ---------- the bomb falling before a burn ---------- */

.bomb-drop {
  position: fixed;
  z-index: 69;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bomb-drop .tension {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at var(--fx) var(--fy), transparent 0 16%, rgba(0, 0, 0, 0.62) 75%);
  animation: tension var(--total) ease-in both;
}

@keyframes tension {
  from { opacity: 0; }
}

.bomb-drop .alarm {
  position: fixed;
  inset: 0;
  box-shadow: inset 0 0 140px 50px rgba(255, 20, 20, 0.75);
  animation: alarm 0.5s ease-in-out infinite alternate;
}

@keyframes alarm {
  from { opacity: 0.2; }
}

.alarm-text {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font-size: clamp(28px, 10vw, 64px);
  font-weight: 900;
  white-space: nowrap;
  color: #ffd400;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
  text-shadow: 0 0 24px #ff2020;
  animation: alarm-text 0.25s steps(2) infinite;
}

@keyframes alarm-text {
  50% { opacity: 0.15; }
}

.bomb-shadow {
  position: absolute;
  left: -45px;
  top: 34px;
  width: 90px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.65), transparent 70%);
  animation: bomb-shadow var(--fall) ease-in var(--delay) both;
}

@keyframes bomb-shadow {
  from { transform: scale(0.15); opacity: 0; }
}

.bomb-fall {
  position: absolute;
  left: 0;
  top: 0;
  animation: bomb-fall var(--fall) cubic-bezier(0.5, 0, 1, 1) var(--delay) both;
}

@keyframes bomb-fall {
  from { transform: translateY(-80vh) rotate(-30deg); }
}

.bomb-body {
  position: absolute;
  left: 0;
  top: 0;
  translate: -50% -62%;
  transform-origin: 50% 100%;
  animation:
    bomb-land 0.35s ease-out calc(var(--delay) + var(--fall)) both,
    bomb-pulse calc(var(--step) / 2) ease-in-out calc(var(--delay) + var(--fall) + 0.35s) infinite alternate;
}

@keyframes bomb-land {
  0%, 100% { transform: none; }
  30% { transform: scale(1.35, 0.65); }
  65% { transform: scale(0.9, 1.15) translateY(-10px); }
}

@keyframes bomb-pulse {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.2) rotate(5deg); filter: drop-shadow(0 0 16px #ff2a00) brightness(1.35); }
}

.cartoon-bomb {
  position: relative;
  font-size: 76px;
  line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.5));
}

.fuse-spark {
  position: absolute;
  right: 4%;
  top: 0;
  width: 20px;
  height: 20px;
  margin: -8px -6px 0 0;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 20%, #ffe066 35%, #ff8a00 60%, transparent 70%);
  box-shadow: 0 0 16px 5px rgba(255, 170, 0, 0.8);
  animation: fuse 0.09s steps(2) infinite;
}

@keyframes fuse {
  50% { transform: scale(0.55) rotate(45deg); opacity: 0.6; }
}

.nuke-bomb {
  position: relative;
  width: 70px;
  height: 116px;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.55));
}

.nuke-bomb i {
  position: absolute;
  font-style: normal;
}

.nuke-bomb .fin {
  left: 11px;
  top: 0;
  width: 48px;
  height: 36px;
  background: linear-gradient(90deg, #2c3112, #6b7232 50%, #2c3112);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
}

.nuke-bomb .body {
  left: 0;
  top: 28px;
  width: 70px;
  height: 88px;
  border-radius: 46% 46% 50% 50% / 38% 38% 62% 62%;
  background: radial-gradient(circle at 35% 35%, #a3aa66, #5a6126 55%, #2a2e10);
}

.nuke-bomb .sym {
  left: 50%;
  top: 64%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  color: #111;
  background: #ffd400;
  box-shadow: 0 0 0 2px #111;
}

.nuke-bomb .light {
  left: 50%;
  top: 36px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: #ff2020;
  box-shadow: 0 0 10px 3px #ff2020;
  animation: fuse calc(var(--step) / 2) steps(2) infinite;
}

.countdown span {
  position: absolute;
  left: calc(var(--cw-pile, 80px) * 0.5 + 34px);
  top: 0;
  translate: -50% -50%;
  font-size: 54px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px #8a0b00;
  paint-order: stroke fill;
  text-shadow: 0 0 18px #ff3b1a;
  opacity: 0;
  animation: count var(--step) ease-out both;
}

@keyframes count {
  0% { transform: scale(2.2); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: scale(0.7); opacity: 0; }
}

/* ---------- ace: tablecloth trick and quips ---------- */

.game.cloth-jump .opp-row,
.game.cloth-jump .table,
.game.cloth-jump .mine {
  animation: cloth-jump 0.7s ease-out;
}

.game.cloth-jump .table { animation-delay: 0.08s; }
.game.cloth-jump .mine { animation-delay: 0.16s; }

@keyframes cloth-jump {
  25% { transform: translateY(-16px) rotate(-1.5deg); }
  55% { transform: translateY(3px) rotate(1deg); }
  80% { transform: translateY(-3px); }
}

.slot-quip {
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  font-style: italic;
  color: rgba(255, 243, 196, 0.85);
  opacity: 0;
  transition: opacity 0.25s 0.15s;
}

.landed .slot-quip {
  opacity: 1;
}

/* ---------- end of the round: winner finale ---------- */

.finale {
  position: fixed;
  inset: 0;
  z-index: 88;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(2, 10, 6, 0.93);
  animation: finale 5.6s ease-in-out both;
}

@keyframes finale {
  0% { opacity: 0; }
  6%, 90% { opacity: 1; }
  100% { opacity: 0; }
}

.spotlight {
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 160deg at 50% 0%, transparent 0 8deg, rgba(255, 240, 190, 0.22) 14deg 26deg, transparent 32deg);
  transform-origin: 50% 0;
  animation: spotlight 2.4s ease-in-out infinite alternate;
}

@keyframes spotlight {
  from { transform: rotate(-12deg); }
  to { transform: rotate(12deg); }
}

.confetti i {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: poop-fall var(--d) linear var(--delay) both;
}

.finale-inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(92vw, 440px);
  text-align: center;
}

.trophy {
  font-size: 84px;
  line-height: 1;
  filter: drop-shadow(0 0 30px rgba(255, 210, 80, 0.8));
  animation: trophy 0.9s cubic-bezier(0.3, 1.5, 0.5, 1) 0.15s both;
}

@keyframes trophy {
  from { transform: translateY(-60vh) rotate(-30deg) scale(0.6); }
}

.finale-title {
  font-size: clamp(28px, 9vw, 46px);
  font-weight: 900;
  line-height: 1.05;
  color: #fff3c4;
  text-shadow: 0 0 24px rgba(246, 196, 83, 0.9), 0 4px 0 rgba(0, 0, 0, 0.4);
  animation: pop-in 0.6s cubic-bezier(0.2, 1.5, 0.4, 1) 0.6s both;
}

.finale-loser {
  font-size: 15px;
  font-weight: 700;
  color: rgba(243, 247, 244, 0.85);
  animation: pop-in 0.5s ease-out 1.2s both;
}

.finale-loser {
  margin-top: 4px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(139, 69, 19, 0.45);
  color: #ffe1b8;
  animation-delay: 3.3s;
}

@keyframes pop-in {
  from { transform: scale(0.4); opacity: 0; }
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.podium-step {
  width: 108px;
  display: grid;
  gap: 6px;
  animation: podium 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.podium-step.p1 { animation-delay: 2.6s; }
.podium-step.p2 { animation-delay: 2.3s; }
.podium-step.p3 { animation-delay: 2.0s; }

@keyframes podium {
  from { transform: translateY(160px); opacity: 0; }
}

.podium-name {
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-block {
  display: grid;
  place-items: center;
  border-radius: 10px 10px 0 0;
  font-size: 30px;
  font-weight: 900;
  color: rgba(0, 0, 0, 0.45);
}

.p1 .podium-block { height: 92px; background: linear-gradient(180deg, #ffe39a, #e8963a); }
.p2 .podium-block { height: 66px; background: linear-gradient(180deg, #f2f4f7, #9aa3ad); }
.p3 .podium-block { height: 46px; background: linear-gradient(180deg, #f0b98a, #a8642f); }

/* ---------- toasts & connection ---------- */

#toasts {
  position: fixed;
  z-index: 100;
  top: calc(56px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  background: rgba(10, 20, 15, 0.88);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  transition: opacity 0.4s, transform 0.4s;
}

.toast.error { background: rgba(120, 18, 32, 0.92); }
.toast.burn { background: linear-gradient(90deg, rgba(200, 40, 10, 0.95), rgba(240, 120, 20, 0.95)); }
.toast.pickup { background: rgba(90, 40, 120, 0.92); }
.toast.finish,
.toast.over { background: linear-gradient(90deg, #ffd977, var(--gold-2)); color: #2b1700; }

.toast.out {
  opacity: 0;
  transform: translateY(-8px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.9); }
}

.offline-bar {
  position: fixed;
  z-index: 110;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(180, 30, 50, 0.92);
  animation: fade 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- moves: cards fly in, land with a thud, get sucked into a hand ---------- */

.pile > .card.fly {
  z-index: 100 !important;
  animation: fly-in var(--fd) cubic-bezier(0.35, 0.1, 0.55, 1) var(--fdl) both;
}

/* rises towards the camera on the way, then slams down and squashes */
@keyframes fly-in {
  0% { transform: translate(calc(var(--x) + var(--fx)), calc(var(--y) + var(--fy))) rotate(var(--fr)) scale(var(--fs)); }
  50% { transform: translate(calc(var(--x) + var(--fx) * 0.3), calc(var(--y) + var(--fy) * 0.3 - 30px)) rotate(calc(var(--rot) + 25deg)) scale(var(--peak, 1.5)); box-shadow: 0 40px 50px rgba(0, 0, 0, 0.45); }
  78% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(0.86, 0.8); }
  90% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1.06); }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1); }
}

/* the last hand card hangs in the air above the pile, winds up, and comes down like a hammer */
.pile > .card.fly.slam {
  animation-name: fly-nine;
  animation-timing-function: ease-in-out;
}

@keyframes fly-nine {
  0% { transform: translate(calc(var(--x) + var(--fx)), calc(var(--y) + var(--fy))) rotate(var(--fr)) scale(var(--fs)); }
  35% { transform: translate(var(--x), calc(var(--y) - 60px)) rotate(calc(var(--rot) - 14deg)) scale(2.2); box-shadow: 0 60px 60px rgba(0, 0, 0, 0.5); filter: brightness(1.1); }
  64% { transform: translate(var(--x), calc(var(--y) - 90px)) rotate(calc(var(--rot) + 10deg)) scale(2.5); box-shadow: 0 90px 70px rgba(0, 0, 0, 0.5); filter: drop-shadow(0 0 18px rgba(255, 60, 60, 0.9)); }
  74% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(0.8, 0.68); animation-timing-function: ease-out; }
  86% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1.12); }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1); }
}

/* a 9 is lifted a little and pressed down onto the pile */
.pile > .card.fly.press {
  animation-name: fly-press;
  animation-timing-function: ease-in-out;
}

@keyframes fly-press {
  0% { transform: translate(calc(var(--x) + var(--fx)), calc(var(--y) + var(--fy))) rotate(var(--fr)) scale(var(--fs)); }
  45% { transform: translate(var(--x), calc(var(--y) - 34px)) rotate(calc(var(--rot) - 8deg)) scale(1.45); box-shadow: 0 36px 36px rgba(0, 0, 0, 0.45); }
  60% { transform: translate(var(--x), calc(var(--y) - 42px)) rotate(calc(var(--rot) + 5deg)) scale(1.55); box-shadow: 0 44px 40px rgba(0, 0, 0, 0.45); }
  72% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(0.9, 0.82); animation-timing-function: ease-out; }
  86% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1.05); }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--rot)) scale(1); }
}

/* a 7 drifts in like a ghost, flickering in and out of sight */
.pile > .card.fly.ghost-fly {
  animation:
    fly-in var(--fd) cubic-bezier(0.35, 0.1, 0.55, 1) var(--fdl) both,
    ghost-flicker var(--fd) linear var(--fdl) both;
}

@keyframes ghost-flicker {
  0% { opacity: 1; }
  25% { opacity: 0.3; }
  40% { opacity: 0.85; }
  55% { opacity: 0.2; }
  70% { opacity: 0.7; }
  100% { opacity: 0.55; }
}

.bit2.wisp {
  width: 26px;
  height: 34px;
  margin: -17px 0 0 -13px;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(closest-side, rgba(225, 240, 255, 0.75), rgba(190, 220, 255, 0.25) 60%, transparent);
  animation-name: wisp;
  animation-timing-function: ease-out;
}

@keyframes wisp {
  0% { transform: scale(0.3); opacity: 0; }
  20% { opacity: 1; }
  60% { transform: translate(calc(var(--dx) * 0.6), calc(var(--dy) * 0.6)) scale(1.1, 1.3) rotate(10deg); }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.7, 1.6) rotate(-12deg); opacity: 0; }
}

/* a 2 resets the pile: a rewind swirl spins once around it */
.reset-swirl {
  position: fixed;
  z-index: 57;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0 55%, rgba(120, 255, 230, 0.15) 70%, rgba(150, 255, 235, 0.85) 98%, #fff 100%);
  -webkit-mask-image: radial-gradient(closest-side, transparent 58%, #000 62%, #000 80%, transparent 84%);
  mask-image: radial-gradient(closest-side, transparent 58%, #000 62%, #000 80%, transparent 84%);
  animation: reset-swirl 0.95s cubic-bezier(0.3, 0.6, 0.3, 1) forwards;
}

@keyframes reset-swirl {
  0% { transform: rotate(0deg) scale(0.5); opacity: 0; }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: rotate(-720deg) scale(1.1); opacity: 0; }
}

.tap-ring.reset {
  border-color: #7dffe6;
  box-shadow: 0 0 16px rgba(125, 255, 230, 0.8);
}

.shockwave {
  position: fixed;
  z-index: 55;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.3);
  pointer-events: none;
  animation: shockwave 0.6s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

@keyframes shockwave {
  from { transform: scale(0.5, 0.35); opacity: 1; }
  to { transform: scale(calc(2.4 * var(--p)), calc(1.4 * var(--p))); opacity: 0; border-width: 1px; }
}

.dust {
  position: fixed;
  z-index: 54;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(235, 222, 196, 0.9), rgba(235, 222, 196, 0) 70%);
  pointer-events: none;
  animation: particle 0.85s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

.pile-wrap.jolt .pile {
  animation: jolt 0.35s ease-out;
}

@keyframes jolt {
  20% { transform: translateY(5px) scale(1.04, 0.94); }
  50% { transform: translateY(-2px) scale(0.98, 1.03); }
}

.game.thump {
  animation: thump 0.4s ease-out;
}

@keyframes thump {
  15% { transform: translate(calc(var(--shake) * -0.5), var(--shake)); }
  35% { transform: translate(calc(var(--shake) * 0.5), calc(var(--shake) * -0.6)); }
  60% { transform: translate(calc(var(--shake) * -0.25), calc(var(--shake) * 0.3)); }
}

/* the seat a 9 came down on */
.opp.squashed,
.mine.squashed {
  animation: squashed 0.9s cubic-bezier(0.2, 0.8, 0.3, 1);
  transform-origin: 50% 100%;
}

@keyframes squashed {
  0% { transform: scale(1.1, 0.65); filter: brightness(0.8) sepia(0.6) hue-rotate(-40deg) saturate(2.5); }
  35% { transform: scale(1.06, 0.78); }
  60% { transform: scale(0.97, 1.04); }
}

.hurt {
  position: fixed;
  inset: 0;
  z-index: 58;
  pointer-events: none;
  box-shadow: inset 0 0 90px 16px rgba(255, 30, 30, 0.4);
  animation: fade-out 0.7s ease-out forwards;
}

@keyframes fade-out {
  to { opacity: 0; }
}

/* a pickup: the pile is sucked card by card into a hand */
.pickup-stream {
  position: fixed;
  z-index: 56;
  width: 0;
  height: 0;
  pointer-events: none;
}

.pickup-stream .card {
  position: absolute;
  left: calc(var(--cw) / -2);
  top: calc(var(--cw) * -0.7);
  transform: rotate(var(--rot));
  animation: suck 0.45s cubic-bezier(0.5, 0, 0.75, 0.4) var(--d) forwards;
}

@keyframes suck {
  25% { transform: translateY(-14px) rotate(var(--rot)) scale(1.1); }
  100% { transform: translate(var(--tx), var(--ty)) rotate(var(--tr)) scale(0.3); opacity: 0.4; }
}

.pickup-stream .card.thrown {
  animation: thrown 0.45s cubic-bezier(0.35, 0.1, 0.55, 1) both, suck 0.45s cubic-bezier(0.5, 0, 0.75, 0.4) var(--d) forwards;
}

@keyframes thrown {
  0% { transform: translate(var(--fx), var(--fy)) rotate(-40deg) scale(0.4); }
  70% { transform: rotate(var(--rot)) scale(1.3); }
  85% { transform: rotate(var(--rot)) scale(0.9); }
  100% { transform: rotate(var(--rot)); }
}

.pickup-stream.reject .card {
  filter: drop-shadow(0 0 10px rgba(255, 40, 40, 1)) brightness(0.9);
}

.pickup-stream.reject {
  animation: reject 0.4s linear;
}

@keyframes reject {
  20% { transform: translateX(-9px) rotate(-3deg); }
  40% { transform: translateX(8px) rotate(3deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.opp.gulp,
.mine.gulp {
  animation: gulp 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes gulp {
  30% { transform: scale(1.14, 0.88); }
  60% { transform: scale(0.95, 1.06); }
}

/* after a 9 forced a pickup */
.opp.shamed,
.mine.shamed {
  animation: shamed 1.8s ease-out;
}

@keyframes shamed {
  0%, 100% { filter: none; }
  10%, 80% { filter: grayscale(1) brightness(0.65); }
  15% { transform: rotate(-4deg) translateY(4px); }
  25% { transform: rotate(3deg) translateY(4px); }
  35% { transform: rotate(-2deg) translateY(4px); }
  60% { transform: translateY(4px); }
}

.opp.gloat,
.mine.gloat {
  animation: gloat 1.8s ease-out;
}

@keyframes gloat {
  0%, 100% { box-shadow: none; }
  15% { transform: scale(1.15) rotate(-3deg); box-shadow: 0 0 0 2px var(--gold), 0 0 40px rgba(246, 196, 83, 0.9); }
  30% { transform: scale(1.1) rotate(3deg); }
  45% { transform: scale(1.12) rotate(-2deg); box-shadow: 0 0 0 2px var(--gold), 0 0 30px rgba(246, 196, 83, 0.7); }
  70% { transform: scale(1); }
}

.victory-glow {
  position: fixed;
  inset: 0;
  z-index: 57;
  pointer-events: none;
  background: radial-gradient(ellipse 90% 60% at 50% 100%, rgba(255, 210, 74, 0.55), transparent 70%);
  animation: victory-glow 1.6s ease-out forwards;
}

@keyframes victory-glow {
  0% { opacity: 0; }
  15% { opacity: 1; }
  100% { opacity: 0; }
}

.bit {
  position: fixed;
  z-index: 66;
  width: 8px;
  height: 13px;
  margin: -6px 0 0 -4px;
  border-radius: 2px;
  pointer-events: none;
  animation: bit 1.4s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

@keyframes bit {
  70% { opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; }
}

/* a player who is out sees the other hands face up, squeezed into the panel */
.opp {
  grid-template-columns: minmax(0, 1fr);
}

.opp-hand {
  min-width: 0;
}

.opp-cards {
  display: flex;
  min-width: 0;
  max-width: 100%;
  padding-right: 2px;
}

.opp-cards .hc {
  flex: 0 1 var(--cw);
  min-width: 3px;
}

.opp-cards .hc:last-child {
  flex-shrink: 0;
}

/* a shiny card glows in rainbow colours on its way to the pile */
.pile > .card.fly.shiny-fly {
  box-shadow: 0 0 18px 4px rgba(255, 110, 243, 0.8), 0 0 36px 10px rgba(77, 208, 255, 0.6);
}

/* the last card from the hand: everything shakes and jumps, the felt is scorched */
.game.slam-shake,
#scene.slam-shake {
  animation: slam-shake 0.95s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes slam-shake {
  0% { transform: scale(1.06) translate(0, 14px); }
  8% { transform: scale(1.04) translate(-18px, -10px) rotate(-1.2deg); }
  16% { transform: scale(1.03) translate(16px, 9px) rotate(1deg); }
  26% { transform: scale(1.02) translate(-12px, -6px) rotate(-0.6deg); }
  38% { transform: translate(9px, 5px) rotate(0.4deg); }
  52% { transform: translate(-5px, -3px); }
  68% { transform: translate(3px, 2px); }
  84% { transform: translate(-1px, 0); }
}

.slam-jump {
  animation: slam-jump 0.75s cubic-bezier(0.3, 0.8, 0.4, 1) var(--jd, 0ms) both;
}

@keyframes slam-jump {
  0% { transform: none; }
  20% { transform: translateY(-22px) rotate(-2deg); }
  42% { transform: translateY(3px) scale(1.02, 0.96); }
  60% { transform: translateY(-6px); }
  80% { transform: translateY(1px); }
}

.scorch-mark {
  position: fixed;
  z-index: 0; /* on the felt, under the cards */
  width: var(--s);
  height: calc(var(--s) * 0.8);
  margin: calc(var(--s) * -0.4) 0 0 calc(var(--s) / -2);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 170, 60, 0.55), rgba(40, 20, 5, 0.55) 35%, rgba(0, 0, 0, 0.35) 60%, transparent);
  animation: scorch 3.2s ease-out forwards;
}

@keyframes scorch {
  0% { transform: scale(0.3); opacity: 1; }
  8% { transform: scale(1.05); }
  15% { transform: scale(1); }
  60% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* ---------- match history and stats ---------- */

.sheet.stats {
  gap: 12px;
  background: radial-gradient(ellipse 120% 60% at 50% 0%, #2b6b47, transparent 60%), linear-gradient(180deg, #164a31, #071f14);
}

.stats-title {
  margin: 0;
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.04em;
}

.stats-title span {
  background: linear-gradient(180deg, #fff6d0, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stats-sub {
  margin-top: -8px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.stats-empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
}

.stats-empty .big {
  font-size: 52px;
  animation: pop-in 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.sheet.stats h3 {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.awards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}

.award {
  min-width: 0;
  padding: 10px 6px 9px;
  border-radius: 16px;
  text-align: center;
  background: linear-gradient(160deg, rgba(255, 227, 154, 0.22), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(246, 196, 83, 0.35);
  animation: award-in 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) calc(var(--i) * 0.1s) both;
}

.award .aicon {
  font-size: 28px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}

.award .atitle {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

.award .aname {
  margin-top: 2px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.award .awhat {
  font-size: 11.5px;
  color: var(--muted);
}

@keyframes award-in {
  from { transform: translateY(16px) scale(0.7) rotate(-6deg); opacity: 0; }
}

.leaders,
.matches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.leader {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  animation: row-in 0.45s cubic-bezier(0.2, 1, 0.3, 1) calc(0.15s + var(--i) * 0.07s) both;
}

.leader:first-child {
  background: linear-gradient(90deg, rgba(246, 196, 83, 0.24), rgba(255, 255, 255, 0.05));
  border-color: rgba(246, 196, 83, 0.45);
  box-shadow: 0 0 24px -6px rgba(246, 196, 83, 0.6);
}

.leader.me {
  border-color: rgba(255, 255, 255, 0.35);
}

@keyframes row-in {
  from { transform: translateX(-30px); opacity: 0; }
}

.lpos {
  width: 24px;
  flex: none;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--muted);
}

.lmain {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.lname {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lname em {
  font-weight: 600;
  color: var(--muted);
}

/* win rate */
.lbar {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.lbar i {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-2), #ffe39a);
  box-shadow: 0 0 8px rgba(246, 196, 83, 0.7);
  animation: grow 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) 0.4s both;
}

@keyframes grow {
  from { width: 0; }
}

/* the last places, oldest left: gold, silver, bronze, the rest, Shithead */
.lform {
  display: flex;
  gap: 3px;
}

.lform i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.lform .p1 { background: #ffd24a; box-shadow: 0 0 6px #ffd24a; }
.lform .p2 { background: #d9dde3; }
.lform .p3 { background: #d08a4a; }
.lform .sh { background: #8b4513; box-shadow: inset 0 0 0 1.5px #c57b3c; }
.lform .left { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.3); }

.lnums {
  flex: none;
  display: flex;
  gap: 8px;
  text-align: center;
}

.lnums div {
  display: grid;
  min-width: 26px;
}

.lnums b {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
}

.lnums .avg b {
  color: var(--gold);
  font-size: 20px;
}

.lnums span {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.match {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
  animation: row-in 0.4s ease-out calc(0.3s + min(var(--i), 10) * 0.05s) both;
}

.mhead {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

.mhead span {
  color: var(--muted);
}

.mrow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mchip {
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.mchip.win {
  color: #2b1700;
  background: linear-gradient(180deg, #ffe39a, var(--gold-2));
}

.mchip.sh {
  background: rgba(139, 69, 19, 0.55);
  color: #ffe1b8;
}

.mchip.me {
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
}

/* ---------- poking another player ---------- */

.opp {
  cursor: pointer;
}

.poke-finger {
  position: fixed;
  z-index: 72;
  width: 0;
  height: 0;
  pointer-events: none;
  animation: poke-fly 1.25s cubic-bezier(0.3, 0.7, 0.4, 1) forwards;
}

.poke-finger span {
  position: absolute;
  right: -6px;
  top: 0;
  translate: 0 -50%;
  rotate: var(--a);
  transform-origin: 100% 50%;
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.45));
}

.poke-finger.big span {
  font-size: 72px;
}

/* flies in, jabs twice, pulls back */
@keyframes poke-fly {
  0% { transform: translate(var(--dx), var(--dy)) scale(0.5); opacity: 0; }
  12% { opacity: 1; }
  28% { transform: translate(calc(var(--dx) * 0.12), calc(var(--dy) * 0.12)); }
  32% { transform: translate(0, 0) scale(0.95); }
  40% { transform: translate(calc(var(--dx) * 0.08), calc(var(--dy) * 0.08)); }
  50% { transform: translate(0, 0) scale(0.95); }
  62% { transform: translate(calc(var(--dx) * 0.1), calc(var(--dy) * 0.1)); opacity: 1; }
  100% { transform: translate(calc(var(--dx) * 0.6), calc(var(--dy) * 0.6)) scale(0.6); opacity: 0; }
}

.opp.poked,
.mine.poked {
  animation: poked 0.45s cubic-bezier(0.2, 1.5, 0.4, 1);
}

@keyframes poked {
  0% { transform: scale(0.86, 0.8) rotate(-3deg); box-shadow: 0 0 0 2px #ffd24a, 0 0 30px rgba(255, 210, 74, 0.8); }
  50% { transform: scale(1.06, 1.08) rotate(2deg); }
}

.opp.poking,
.mine.poking {
  animation: poking 0.6s ease-out;
}

@keyframes poking {
  30% { transform: translateY(-4px) scale(1.05); }
}

/* ---------- a wisecrack after a blast ---------- */

.boom-quip {
  position: fixed;
  z-index: 92;
  left: 50%;
  max-width: min(86vw, 420px);
  padding: 8px 16px;
  border-radius: 14px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  font-style: italic;
  line-height: 1.15;
  color: #1a1a1a;
  background: #fff6c8;
  border: 3px solid #1a1a1a;
  box-shadow: 5px 6px 0 #1a1a1a;
  pointer-events: none;
  translate: -50% 0;
  animation: quip 3.1s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

.boom-quip.nuke {
  color: #1a1a1a;
  background: #ffe14d;
  animation-duration: 3.6s;
}

@keyframes quip {
  0% { transform: scale(0) rotate(-20deg); }
  12% { transform: scale(1.15) rotate(-4deg); }
  20%, 85% { transform: scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: translateY(-30px) scale(0.9) rotate(-3deg); opacity: 0; }
}

/* ---------- throwing more cards of the same rank after the first ---------- */

@property --left {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}

.follow-timer {
  position: fixed;
  z-index: 53;
  width: var(--s);
  height: var(--s);
  margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(rgba(255, 210, 74, 0.95) calc(var(--left) * 360deg), rgba(255, 255, 255, 0.08) 0);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(closest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  filter: drop-shadow(0 0 8px rgba(255, 210, 74, 0.8));
  animation: follow-timer var(--t) linear forwards;
}

@keyframes follow-timer {
  from { --left: 1; }
  to { --left: 0; }
}

/* the cards that can still be thrown after it */
.card.follow {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(246, 196, 83, 0.9);
  animation: follow-pulse 0.45s ease-in-out infinite alternate;
}

@keyframes follow-pulse {
  to { box-shadow: 0 0 0 3px #fff3c4, 0 0 34px rgba(246, 196, 83, 1); }
}

/* ---------- scribbles on the felt ---------- */

#doodles {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* a finger on the free table draws instead of scrolling or zooming */
.table,
.status,
.mine {
  touch-action: none;
}

#doodles.on {
  display: block;
}

/* ---------- picking up voluntarily: hold the button until it is full ---------- */

.btn[data-hold] {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  -webkit-touch-callout: none;
}

.btn[data-hold]::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(230, 70, 60, 0.75), rgba(255, 150, 90, 0.9));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease-out;
}

.btn[data-hold].holding::before {
  transform: scaleX(1);
  transition: transform 0.8s linear;
}

.btn[data-hold].holding {
  transform: scale(0.96);
}

.btn.nudge {
  animation: nudge 0.45s ease-in-out;
}

@keyframes nudge {
  20% { transform: translateX(-6px) rotate(-2deg); }
  45% { transform: translateX(5px) rotate(1.5deg); }
  70% { transform: translateX(-3px); }
}

/* ---------- Shinydex: every shiny card there is, the caught ones shine ---------- */

.dex-count {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(246, 196, 83, 0.2);
  color: var(--gold);
  font-size: 13px;
}

.dex-bar {
  height: 8px;
  margin: 0 10%;
}

.dex {
  display: grid;
  gap: 10px;
  --cw: clamp(32px, calc((min(100vw, 520px) - 110px) / 7), 50px);
}

.dex-row {
  display: grid;
  grid-template-columns: repeat(7, var(--cw));
  justify-content: center;
  gap: 7px 6px;
  padding: 8px 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.dex-cell {
  position: relative;
  animation: dex-in 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) calc(0.1s + var(--i) * 0.012s) both;
}

.dex-cell .card {
  font-size: calc(var(--cw) * 0.32);
}

.dex-missing {
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.28);
  line-height: 1;
}

.dex-missing i {
  font-style: normal;
  font-size: 0.8em;
}

.dex-n {
  position: absolute;
  right: -4px;
  bottom: -5px;
  z-index: 3;
  padding: 1px 5px;
  border-radius: 99px;
  background: var(--gold);
  color: #3a2600;
  font-size: 10px;
}

.dex-hint {
  margin: 0;
  text-align: center;
  font-size: 13px;
  opacity: 0.6;
}

@keyframes dex-in {
  from { transform: scale(0.3); opacity: 0; }
}

/* a shiny card caught for the first time spins in and flies into the menu */
.dex-catch {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.dex-rays {
  position: absolute;
  width: 90vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, rgba(255, 240, 180, 0.55), transparent 70%),
    repeating-conic-gradient(rgba(255, 220, 120, 0.35) 0 8deg, transparent 8deg 22deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent);
  mask-image: radial-gradient(closest-side, #000 30%, transparent);
  animation: dex-rays 2s ease-out both;
}

@keyframes dex-rays {
  0% { transform: scale(0.2) rotate(0deg); opacity: 0; }
  20% { opacity: 1; }
  70% { opacity: 1; }
  100% { transform: scale(1.2) rotate(90deg); opacity: 0; }
}

.dex-flyer {
  position: relative;
  --cw: 120px;
  animation: dex-fly 2.3s cubic-bezier(0.5, 0, 0.3, 1) both;
}

.dex-flyer .card {
  box-shadow: 0 0 0 2px rgba(255, 220, 120, 0.9), 0 0 40px rgba(255, 210, 110, 0.9), 0 12px 30px rgba(0, 0, 0, 0.5);
}

@keyframes dex-fly {
  0% { transform: scale(0) rotate(-540deg); }
  22% { transform: scale(1.18) rotate(8deg); }
  32% { transform: scale(1) rotate(0deg); }
  66% { transform: scale(1.04) rotate(-3deg); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.12) rotate(200deg); opacity: 0.4; }
}

.dex-new {
  position: absolute;
  left: 50%;
  top: -16px;
  z-index: 4;
  translate: -50% 0;
  padding: 3px 12px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff1b8, var(--gold));
  color: #3a2600;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.icon-btn.dex-bump {
  animation: dex-bump 0.7s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes dex-bump {
  30% { transform: scale(1.45); box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(246, 196, 83, 0.9); }
}

/* ---------- a 7: the lights go cold, a ghost loops the pile and slips into the next player ---------- */

.ghost-dim {
  position: fixed;
  inset: 0;
  z-index: 57;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 70, 140, 0.25), rgba(5, 10, 35, 0.6));
  animation: ghost-dim 1.5s steps(1) forwards;
}

@keyframes ghost-dim {
  0% { opacity: 0; }
  8% { opacity: 1; }
  14% { opacity: 0.2; }
  20% { opacity: 0.9; }
  34% { opacity: 0.4; }
  40% { opacity: 1; }
  80% { opacity: 0.8; }
  90% { opacity: 0.3; }
  100% { opacity: 0; }
}

.spook {
  position: fixed;
  z-index: 62;
  width: 0;
  height: 0;
  pointer-events: none;
}

.spook-body {
  position: absolute;
  left: -27px;
  top: -36px;
  width: 54px;
  height: 62px;
  border-radius: 27px 27px 0 0;
  background: linear-gradient(180deg, #fbfdff, rgba(220, 235, 255, 0.92));
  filter: drop-shadow(0 0 12px rgba(150, 205, 255, 0.95));
  animation: spook-bob 0.5s ease-in-out infinite alternate;
}

/* the wavy hem */
.spook-body::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 9px;
  background: radial-gradient(circle at 50% 0, rgba(220, 235, 255, 0.92) 9px, transparent 9.5px) 0 0 / 18px 9px repeat-x;
}

.spook .eye {
  position: absolute;
  top: 34%;
  left: 27%;
  width: 9px;
  height: 13px;
  border-radius: 50%;
  background: #1a1f33;
  box-shadow: inset 2px 3px 0 -1px #fff;
}

.spook .eye.r {
  left: auto;
  right: 27%;
}

.spook .mouth {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 11px;
  height: 14px;
  margin-left: -5.5px;
  border-radius: 50%;
  background: #1a1f33;
  animation: spook-mouth 0.6s ease-in-out infinite alternate;
}

@keyframes spook-bob {
  from { transform: translateY(-3px) skewX(-4deg); }
  to { transform: translateY(3px) skewX(4deg); }
}

@keyframes spook-mouth {
  to { transform: scale(0.75, 1.25); }
}

/* the card under the 7 is what counts now: it shines through */
.pile > .card.seen-through {
  animation: seen-through 1.5s ease-in-out;
}

@keyframes seen-through {
  20%, 70% { box-shadow: 0 0 0 3px #aee3ff, 0 0 30px 8px rgba(140, 210, 255, 0.9); filter: brightness(1.15); }
}

/* whoever the ghost slipped into shivers with cold */
.opp.chilled,
.mine.chilled {
  animation: chilled 1.2s linear;
}

@keyframes chilled {
  0%, 100% { filter: none; }
  10%, 80% { filter: hue-rotate(160deg) saturate(0.6) brightness(1.15); }
  10%, 30%, 50%, 70% { transform: translateX(-3px); }
  20%, 40%, 60%, 80% { transform: translateX(3px); }
}

.frost {
  position: fixed;
  inset: 0;
  z-index: 58;
  pointer-events: none;
  box-shadow: inset 0 0 90px 22px rgba(160, 215, 255, 0.65);
  animation: fade-out 1.6s ease-in forwards;
}

/* ---------- a 2: the table rewinds like a video tape ---------- */

.vhs {
  position: fixed;
  inset: 0;
  z-index: 57;
  pointer-events: none;
  overflow: hidden;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 2px, transparent 2px 4px);
  animation: vhs 1.1s steps(1) forwards;
}

@keyframes vhs {
  0% { opacity: 1; }
  10% { opacity: 0.6; }
  20% { opacity: 1; }
  70% { opacity: 0.9; }
  85% { opacity: 0.3; }
  100% { opacity: 0; }
}

.vhs-osd {
  position: absolute;
  left: 22px;
  top: 18%;
  font-style: normal;
  font-family: ui-monospace, monospace;
  font-weight: 900;
  font-size: 42px;
  color: #fff;
  text-shadow: 3px 0 rgba(255, 0, 80, 0.8), -3px 0 rgba(0, 220, 255, 0.8);
  animation: osd-blink 0.25s steps(2) infinite;
}

@keyframes osd-blink {
  50% { opacity: 0.3; }
}

/* tracking stripes rolling over the screen */
.vhs-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 26px;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.35) 40%, rgba(180, 255, 240, 0.25) 60%, transparent);
  animation: vhs-bar 0.55s linear infinite;
}

.vhs-bar.b2 {
  height: 12px;
  animation-duration: 0.8s;
  animation-delay: -0.3s;
}

@keyframes vhs-bar {
  from { transform: translateY(-30px); }
  to { transform: translateY(100vh); }
}

.game.rewinding {
  animation: rewinding 0.7s steps(7);
}

@keyframes rewinding {
  0%, 100% { transform: none; }
  15% { transform: translateX(-6px) skewX(3deg); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-8px) skewX(-2deg); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-4px) skewX(2deg); }
}

/* the cards under the 2 run backwards and fade: they do not count anymore */
.pile > .card.rewound {
  animation: rewound 1.8s ease-out;
}

@keyframes rewound {
  0% { transform: translate(var(--x), var(--y)) rotate(var(--rot)); }
  8% { transform: translate(calc(var(--x) - 10px), var(--y)) rotate(calc(var(--rot) + 12deg)); }
  16% { transform: translate(calc(var(--x) + 6px), var(--y)) rotate(calc(var(--rot) - 8deg)); }
  24% { transform: translate(calc(var(--x) - 8px), var(--y)) rotate(calc(var(--rot) + 6deg)); }
  32% { transform: translate(var(--x), var(--y)) rotate(var(--rot)); filter: grayscale(1) brightness(0.55); }
  80% { filter: grayscale(1) brightness(0.55); }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--rot)); filter: none; }
}

/* the 2 spins like a coin on the pile */
.pile > .card.coin-spin {
  animation: coin-spin 0.8s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes coin-spin {
  from { transform: translate(var(--x), var(--y)) rotate(var(--rot)) rotateY(0deg) scale(1.15); box-shadow: 0 0 0 3px #7dffe6, 0 0 28px rgba(125, 255, 230, 0.9); }
  to { transform: translate(var(--x), var(--y)) rotate(var(--rot)) rotateY(720deg) scale(1); }
}

.bit2.mint {
  width: 7px;
  height: 7px;
  background: #c8fff4;
  box-shadow: 0 0 8px 2px #4dffd8;
}

/* several aces at once: the machine shows its multiplier and pays out */
.slot-mult {
  position: absolute;
  left: -12px;
  top: -14px;
  z-index: 2;
  padding: 1px 9px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff3b0, var(--gold));
  color: #4a0d1a;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 0 0 2px #fff, 0 0 20px rgba(255, 210, 80, 0.9);
  animation: mult-in 0.5s cubic-bezier(0.2, 1.8, 0.4, 1) 1s both, mult-pulse 0.35s ease-in-out 1.5s 4 alternate;
}

@keyframes mult-in {
  from { transform: scale(0) rotate(-40deg); }
}

@keyframes mult-pulse {
  to { transform: scale(1.3) rotate(8deg); }
}

/* a card I am fiddling with that may be played now: tap it or throw it on the pile */
.drag-ghost.ready > .card {
  box-shadow: 0 0 0 3px var(--gold), 0 0 22px rgba(246, 196, 83, 0.9);
  animation: follow-pulse 0.45s ease-in-out infinite alternate;
}

/* ---------- all four 10s at once: four bombs, a chain of blasts, then the mega blast ---------- */

.mega-slot {
  position: absolute;
  width: 0;
  height: 0;
}

.bomb-drop.mega .cartoon-bomb {
  font-size: 54px;
}

.bomb-drop.mega .alarm {
  box-shadow: inset 0 0 160px 60px rgba(255, 120, 0, 0.8);
  animation-duration: 0.3s;
}

.boom.mini {
  scale: 0.55;
}

/* the mushroom cloud glows hotter and the fireworks burst through it */
.boom.mega .mushroom {
  filter: saturate(1.6) hue-rotate(-12deg) brightness(1.15);
}

.boom.mega .boom-text.nuke-text {
  -webkit-text-stroke: 3px #7a1410;
  text-shadow: 0 0 30px #ffd000, 0 0 70px #ff3b00, 0 6px 0 #5a0d00;
}

/* ---------- Extreme mode: switch, chaos wheel and what it leaves on the table ---------- */

.extreme-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.extreme-toggle .switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.2s;
}

.extreme-toggle .switch::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.extreme-toggle.on {
  border-color: #ff4d6d;
  background: linear-gradient(90deg, rgba(255, 60, 100, 0.28), rgba(255, 170, 0, 0.2));
  box-shadow: 0 0 18px rgba(255, 60, 100, 0.35);
}

.extreme-toggle.on .switch {
  background: linear-gradient(90deg, #ff3c64, #ffaa00);
}

.extreme-toggle.on .switch::after {
  transform: translateX(18px);
}

.extreme-on {
  margin: 4px 0;
  text-align: center;
  font-weight: 800;
  color: #ff8fa3;
}

/* the table glows red at the edges while the chaos is on */
.game.extreme::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 50px rgba(255, 40, 90, 0.3);
  animation: extreme-pulse 3s ease-in-out infinite;
}

@keyframes extreme-pulse {
  50% { box-shadow: inset 0 0 80px rgba(255, 120, 0, 0.35); }
}

/* the direction of play: a ring around the pile, its arrows go the way the turn goes */
.dir-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  width: calc(var(--cw) * 2.2);
  height: calc(var(--cw) * 2.2);
  margin: calc(var(--cw) * -1.1) 0 0 calc(var(--cw) * -1.1);
  border: 2px dashed rgba(255, 120, 150, 0.45);
  border-radius: 50%;
  pointer-events: none;
  animation: dir-spin 9s linear infinite;
}

.dir-ring::before,
.dir-ring::after {
  content: '➤';
  position: absolute;
  left: 50%;
  font-size: calc(var(--cw) * 0.28);
  line-height: 1;
  color: #ff8fa3;
  text-shadow: 0 0 8px #ff3c64;
}

.dir-ring::before { top: 0; transform: translate(-50%, -55%); }
.dir-ring::after { bottom: 0; transform: translate(-50%, 55%) scaleX(-1); }
.ccw .dir-ring { animation-direction: reverse; }
.ccw .dir-ring::before { transform: translate(-50%, -55%) scaleX(-1); }
.ccw .dir-ring::after { transform: translate(-50%, 55%); }
.reverse-flip .dir-ring { animation-duration: 0.6s; }

@keyframes dir-spin {
  to { transform: rotate(360deg); }
}

.game.reverse-flip .opp-row {
  animation: reverse-flip 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes reverse-flip {
  from { transform: perspective(700px) rotateY(0); }
  to { transform: perspective(700px) rotateY(360deg); }
}

/* the upside-down world: the cards on the pile stand on their heads while it lasts
   (their own rotation, so cards still fly in from the right side) */
.game.extreme .pile > .card {
  transition: rotate 0.7s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.game.inverted .pile > .card:not(.fly) {
  rotate: 180deg;
}

.game.inverted .pile-info b {
  color: #d6b4ff;
  text-shadow: 0 0 10px #7b2ff7;
}

.game.upside-flip .table {
  animation: upside-flip 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes upside-flip {
  from { transform: perspective(700px) rotateX(0); }
  to { transform: perspective(700px) rotateX(360deg); }
}

/* X-ray: a green scan runs over the table, and the opponents glow while their hands are open */
.game.xray .opp {
  outline: 2px solid rgba(80, 255, 160, 0.55);
  outline-offset: 1px;
}

.game.xray .opp-cards {
  filter: drop-shadow(0 0 4px rgba(80, 255, 160, 0.8));
}

.xray-beam {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 66;
  height: 90px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(80, 255, 160, 0.45) 45%, #b6ffd9 50%, rgba(80, 255, 160, 0.45) 55%, transparent);
  mix-blend-mode: screen;
  animation: xray-scan 1.2s ease-in-out forwards;
}

@keyframes xray-scan {
  from { transform: translateY(-90px); }
  to { transform: translateY(100vh); }
}

.fly-card,
.robin-arrow {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 67;
  pointer-events: none;
}

.fly-card {
  --cw: 40px;
  width: var(--cw);
}

.robin-arrow {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

/* uses its full width instead of squeezing the text into a narrow column */
.chaos-wheel .slot-text {
  width: max-content;
}

.chaos-wheel .cabinet {
  background: linear-gradient(180deg, #3a0d4a, #12031a);
  border-color: #ff4d6d;
  box-shadow: 0 0 0 3px #6a0a2a, 0 0 40px rgba(255, 60, 120, 0.55), 0 20px 50px rgba(0, 0, 0, 0.6);
}

.wheel-box {
  position: relative;
  flex: none;
  width: calc(var(--sh) * 1.7);
  height: calc(var(--sh) * 1.7);
}

.wheel {
  position: absolute;
  inset: 0;
  border: 3px solid #fff3c4;
  border-radius: 50%;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.55);
  transition: transform 1.4s cubic-bezier(0.15, 0.6, 0.2, 1.02);
}

.spin .wheel {
  transform: rotate(var(--to));
}

.wheel span {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: calc(var(--sh) * 0.27);
  line-height: 1;
  transform: translate(-50%, -50%) rotate(var(--a)) translateY(calc(var(--sh) * -0.58)) rotate(calc(var(--a) * -1));
}

.wheel-pin {
  position: absolute;
  left: 50%;
  top: -7px;
  z-index: 1;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 13px solid #fff;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
}

.chaos-wheel.landed .wheel {
  animation: wheel-win 0.6s ease-out;
}

@keyframes wheel-win {
  30% { box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.55), 0 0 26px #ff4d6d; }
}

/* soul swap: the two seats spin around each other's cards */
.opp.soul-spin,
.mine.soul-spin {
  animation: soul-spin 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes soul-spin {
  50% { filter: hue-rotate(180deg) brightness(1.3); }
  to { transform: perspective(700px) rotateY(360deg); }
}

/* tornado: the table whirls */
.game.tornado .table {
  animation: tornado 1.4s cubic-bezier(0.5, 0, 0.3, 1);
}

@keyframes tornado {
  40% { transform: rotate(200deg) scale(0.75); filter: blur(1px); }
  to { transform: rotate(360deg); }
}

/* skip: a big stop sign is stamped on the skipped seat */
.skip-stamp {
  position: fixed;
  z-index: 67;
  font-size: 64px;
  line-height: 1;
  pointer-events: none;
  translate: -50% -50%;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
  animation: skip-stamp 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

@keyframes skip-stamp {
  0% { transform: scale(3) rotate(-30deg); opacity: 0; }
  15% { transform: scale(1) rotate(-12deg); opacity: 1; }
  75% { transform: scale(1) rotate(-12deg); opacity: 1; }
  100% { transform: scale(0.8) rotate(-12deg); opacity: 0; }
}

/* ---------- wide screens: the moving bits sit where the landscape scenes paint their things ---------- */

@media (min-aspect-ratio: 1/1) {
  .amb.neon-a { left: 8%; width: 24%; height: 18%; }
  .amb.neon-b { left: 68%; width: 24%; height: 18%; }
  .amb.lamplight { left: 25%; top: 6%; width: 50%; height: 60%; }
  .amb.smoke-a { left: 78%; top: 3%; width: 10%; height: 12%; }
  .amb.smoke-b { left: 2%; top: 72%; width: 10%; height: 12%; }
  .amb.beam-a { left: 0; width: 22%; height: 95%; }
  .amb.beam-b { left: 78%; width: 22%; height: 95%; }
  .amb.tally { left: 53.6%; top: 3.2%; width: 0.9%; }
  .amb.candlelight { left: 72%; top: -10%; width: 30%; height: 30%; }
  .amb.beer-a { left: 11.5%; top: 5%; width: 5%; height: 6%; }
  .amb.beer-b { left: 84.5%; top: 67.5%; width: 6%; height: 7%; }
  .amb.moonsea { left: 35%; top: 9%; width: 45%; }
  .amb.caustics { top: 20%; }
  .amb.motes { left: 62%; width: 38%; height: 36%; }
}

/* ---------- desktop: a wider table, bigger opponents, and the mouse shows what it can grab ---------- */

@media (min-aspect-ratio: 1/1) and (min-width: 900px) {
  .game {
    max-width: 1080px;
  }

  .opp {
    --cw: clamp(17px, 3.8vh, 42px);
    max-width: 190px;
  }

  .opp-row {
    gap: 14px;
  }

  /* my seat is a mat in front of me, not a band across the whole table */
  .mine {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
  }
}

@media (hover: hover) and (pointer: fine) {
  .hand > .card,
  .tablecards .card {
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2), translate 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2), box-shadow 0.18s, filter 0.2s;
  }

  .hand > .card.playable:hover:not(.selected),
  .tablecards .card.playable:hover:not(.selected),
  .phase-swap .hand > .card:hover,
  .phase-swap .tablecards .card.up:hover {
    translate: 0 -10px;
    filter: brightness(1.08);
    box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.7), 0 12px 26px rgba(0, 0, 0, 0.45);
  }

  .hand > .card:active,
  .drag-ghost.loose:active {
    cursor: grabbing;
  }

  .opp {
    cursor: pointer;
  }

  .opp:hover:not(.turn) {
    border-color: rgba(255, 255, 255, 0.28);
  }

  .btn:hover:not(:disabled) {
    filter: brightness(1.12);
  }
}
