:root {
  --felt: #0e5a3d;
  --felt-deep: #073324;
  --gold: #e9c46a;
  --gold-soft: rgba(233, 196, 106, 0.35);
  --cream: #fffdf6;
  --ink: #1d1b22;
  --red: #c1121f;
  --glass: rgba(4, 28, 19, 0.55);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f3efe2;
  --muted: rgba(243, 239, 226, 0.66);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --cw: 92px;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.09), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 5px),
    radial-gradient(ellipse at 50% 40%, var(--felt), var(--felt-deep) 85%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: 0.01em; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; }
.btn.primary {
  background: linear-gradient(180deg, #f3d489, #d9a93f);
  color: #2b2005;
  border-color: #f7e2a8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f8dea0, #e0b24a); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- cards ---------- */
.card {
  --h: calc(var(--cw) * 1.42);
  position: relative;
  flex: none;
  width: var(--cw);
  height: var(--h);
  font-size: calc(var(--cw) * 0.2);
  padding: 0;
  border: 0;
  border-radius: calc(var(--cw) * 0.1);
  background: linear-gradient(160deg, #ffffff, var(--cream) 55%, #f1ead8);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 1px rgba(0, 0, 0, 0.16), 0 3px 8px rgba(0, 0, 0, 0.32);
  font-family: var(--serif);
  user-select: none;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.3, 1.2), box-shadow 0.16s;
  overflow: hidden;
}
.card.red { color: var(--red); }
.card .idx {
  position: absolute;
  top: 0.3em;
  left: 0.36em;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-weight: 700;
}
.card .idx b { font-size: 1.12em; }
/* The corner suit is the part people read in a fanned hand, so it is drawn large. */
.card .idx i { font-style: normal; font-size: 1.4em; line-height: 0.9; }
.card .idx.br { top: auto; left: auto; bottom: 0.3em; right: 0.36em; transform: rotate(180deg); }
.card .pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.3em;
  line-height: 1;
}
.card .pip.face {
  inset: 22% 22%;
  border: 1px solid currentColor;
  border-radius: 0.3em;
  font-size: 1.7em;
  font-weight: 700;
  opacity: 0.92;
  background: rgba(0, 0, 0, 0.025);
}
.card.joker { color: #6b3fa0; }
.card.joker .pip { font-size: 2em; }
.card.joker .pip small { display: block; font-size: 0.26em; letter-spacing: 0.18em; font-family: var(--sans); font-weight: 700; }
.card .ribbon {
  position: absolute;
  top: 0;
  right: 0;
  font: 700 0.42em/1 var(--sans);
  letter-spacing: 0.08em;
  padding: 0.32em 0.5em;
  color: #3a2a00;
  background: linear-gradient(180deg, #f6dc94, #dcae45);
  border-bottom-left-radius: 0.7em;
}
.card .stands {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  font: 700 0.5em/1.5 var(--sans);
  text-align: left;
  padding-left: 0.5em;
  white-space: nowrap;
  color: #3a2a00;
  background: linear-gradient(180deg, #f6dc94, #dcae45);
}
.card.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(233, 196, 106, 0.9) 0 9%, transparent 10%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.09) 0 3px, transparent 3px 8px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.09) 0 3px, transparent 3px 8px),
    linear-gradient(160deg, #8f1d2c, #5c0f1b);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 0 0 calc(var(--cw) * 0.06) #f7efd9, 0 3px 8px rgba(0, 0, 0, 0.32);
}
button.card { cursor: pointer; }
button.card:hover { transform: translateY(-8px); z-index: 5; }
.card.selected {
  transform: translateY(-22px);
  box-shadow: 0 0 0 3px var(--gold), 0 14px 22px rgba(0, 0, 0, 0.45);
  z-index: 4;
}
.card.selected:hover { transform: translateY(-24px); }
.card.fresh { box-shadow: 0 0 0 2px #2a9d8f, 0 3px 8px rgba(0, 0, 0, 0.32); }
.card.fresh::after {
  content: 'NEW';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  font: 800 0.48em/1.7 var(--sans);
  letter-spacing: 0.12em;
  text-align: center;
  color: #fff;
  background: #2a9d8f;
}
.card.enter { animation: deal 0.36s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes deal {
  from { opacity: 0; transform: translateY(-40px) rotate(-6deg) scale(0.9); }
  to { opacity: 1; }
}

/* ---------- setup ---------- */
.setup { height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.setup-card {
  width: min(520px, 100%);
  padding: 36px 36px 30px;
  border-radius: 24px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
  text-align: center;
}
.hero { display: flex; justify-content: center; height: 120px; margin-bottom: 18px; --cw: 70px; }
.hero .card { margin: 0 -16px; transform-origin: 50% 120%; }
.hero .card:nth-child(1) { transform: rotate(-24deg); }
.hero .card:nth-child(2) { transform: rotate(-12deg); }
.hero .card:nth-child(3) { transform: rotate(0deg); }
.hero .card:nth-child(4) { transform: rotate(12deg); }
.hero .card:nth-child(5) { transform: rotate(24deg); }
.setup h1 { font-size: 44px; color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.setup .tagline { color: var(--muted); margin: 6px 0 26px; }
.field { text-align: left; margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field input[type='text'] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.field .note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.segments { display: flex; gap: 8px; }
.segments button {
  flex: 1;
  padding: 11px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
.segments button[aria-pressed='true'] { background: var(--gold); color: #2b2005; border-color: #f7e2a8; }
.setup .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.setup .actions .btn { padding: 14px; font-size: 16px; }

/* ---------- game layout ---------- */
.game { height: 100%; display: grid; grid-template-rows: auto auto 1fr auto; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); }
.topbar .brand { font-family: var(--serif); font-size: 20px; color: var(--gold); font-weight: 600; }
.round-pill { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 14px; }
.round-pill .num { background: var(--gold); color: #2b2005; font-weight: 800; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.round-pill strong { font-weight: 600; }
.topbar .spacer { flex: 1; }

.opponents { display: flex; justify-content: center; gap: 14px; padding: 14px 20px 4px; flex-wrap: wrap; }
.seat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--line);
  transition: box-shadow 0.25s, border-color 0.25s, transform 0.25s;
}
.seat.active { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), 0 10px 30px rgba(0, 0, 0, 0.35); transform: translateY(-2px); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 17px var(--serif); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.3); flex: none; }
.seat .who { flex: 1; min-width: 0; }
.seat .name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.seat .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chip { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }
.chip.dealer { background: #fff; color: #222; }
.chip.down { background: #2a9d8f; color: #fff; }
.backs { display: flex; align-items: center; --cw: 22px; }
.backs .card { margin-left: -15px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), inset 0 0 0 2px #f7efd9; }
.backs .card:first-child { margin-left: 0; }
.backs .count { margin-left: 8px; font-weight: 800; font-size: 15px; }
.thinking { display: inline-flex; gap: 3px; margin-left: 2px; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); animation: blink 1s infinite; }
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.table { overflow: auto; padding: 14px 20px; display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; min-height: 0; }
.center { position: sticky; top: 0; display: flex; flex-direction: column; gap: 14px; }
.piles { display: flex; gap: 18px; justify-content: center; padding: 18px 14px; border-radius: 18px; background: rgba(0, 0, 0, 0.2); border: 1px dashed var(--line); --cw: 104px; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.pile .stack { position: relative; }
.pile .stack .card + .card { position: absolute; top: -3px; left: -3px; }
.pile .empty { width: var(--cw); height: calc(var(--cw) * 1.42); border-radius: 9px; border: 2px dashed var(--line); display: grid; place-items: center; text-align: center; padding: 6px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.pile.offer.live .card { box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(233, 196, 106, 0.6), 0 6px 14px rgba(0, 0, 0, 0.4); }
.feed { border-radius: 16px; background: var(--glass); border: 1px solid var(--line); padding: 12px 14px; font-size: 13px; min-height: 112px; }
.feed h3 { font: 700 11px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.feed p { margin: 4px 0; color: var(--muted); }
.feed p:last-child { color: var(--text); font-weight: 600; }
.feed .r { color: #ff8a8a; }

.melds { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px 24px; min-width: 0; align-items: start; }
.owner { padding: 12px 14px; border-radius: 18px; background: rgba(0, 0, 0, 0.14); border: 1px solid rgba(255, 255, 255, 0.06); }
.melds .empty-table { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 18px; padding: 44px 20px; text-align: center; color: var(--muted); font-family: var(--serif); font-size: 18px; }
.owner h3 { font: 700 11px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.owner h3 .avatar { width: 20px; height: 20px; font-size: 11px; box-shadow: none; }
.meld-row { display: flex; flex-wrap: wrap; gap: 10px; }
.meld {
  --cw: 60px;
  padding: 8px 10px 9px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  text-align: left;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s, background 0.2s;
}
.meld .label { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; display: block; }
.meld .cards { display: flex; }
.meld .cards .card { margin-left: -27px; }
.meld .cards .card:first-child { margin-left: 0; }
.meld.accepts { border-color: var(--gold); background: rgba(233, 196, 106, 0.14); box-shadow: 0 0 0 3px var(--gold-soft); animation: pulse 1.4s infinite; }
.meld.accepts:hover { transform: translateY(-3px); }
.meld.just { animation: land 0.5s ease-out; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(233, 196, 106, 0.16); } }
@keyframes land { from { transform: scale(1.08); background: rgba(233, 196, 106, 0.3); } }

/* ---------- player dock ---------- */
.dock { border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.42)); padding: 12px 20px 16px; }
.dock.active { box-shadow: 0 -3px 0 var(--gold) inset, 0 -18px 40px rgba(233, 196, 106, 0.08); border-top-color: var(--gold); }
.dock-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.prompt { flex: 1; min-width: 240px; font-family: var(--serif); font-size: 18px; }
.prompt small { display: block; font: 400 13px var(--sans); color: var(--muted); margin-top: 2px; }
.dock .me { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.dock .me .meta { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.tray { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.slot {
  --cw: 58px;
  flex: 1;
  min-width: 190px;
  min-height: 124px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 2px dashed var(--line);
  background: rgba(0, 0, 0, 0.2);
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}
.slot.ready { border-color: var(--gold); background: rgba(233, 196, 106, 0.1); cursor: pointer; }
.slot.valid { border-style: solid; border-color: #2a9d8f; }
.slot .label { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.slot .label .ok { color: #6fe0d0; }
.slot .label .bad { color: #ffb4a8; }
.slot .cards { display: flex; min-height: 84px; align-items: center; }
.slot .cards .card { margin-left: -18px; }
.slot .cards .card:first-child { margin-left: 0; }
.slot .cards .card:hover { transform: translateY(-4px); }
.slot .hint { font-size: 12.5px; color: var(--muted); }

.hand { display: flex; justify-content: center; padding: 28px 8px 0; min-height: calc(var(--cw) * 1.42 + 30px); }
.hand .card { margin-left: var(--overlap, -30px); }
.hand .card:first-child { margin-left: 0; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2, 14, 9, 0.72); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade 0.25s; overflow: auto; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px 30px;
  border-radius: 22px;
  background: linear-gradient(180deg, #164d38, #0b2f22);
  border: 1px solid rgba(233, 196, 106, 0.35);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.3, 1.1);
}
.modal.narrow { width: min(440px, 100%); text-align: center; }
@keyframes rise { from { transform: translateY(24px) scale(0.97); opacity: 0; } }
.modal h2 { font-size: 30px; color: var(--gold); }
.modal h3 { font-size: 16px; margin: 18px 0 6px; color: var(--gold); }
.modal p, .modal li { line-height: 1.55; color: rgba(243, 239, 226, 0.88); }
.modal .sub { color: var(--muted); margin: 6px 0 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.modal.narrow .foot { justify-content: center; flex-direction: column; }
table.mini { border-collapse: collapse; }
table.mini td { padding: 3px 18px 3px 0; color: rgba(243, 239, 226, 0.88); }
table.mini td:first-child { color: var(--gold); font-weight: 700; }

table.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.scores th, table.scores td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--line); }
table.scores th { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
table.scores td:first-child, table.scores th:first-child { text-align: left; font-weight: 700; }
table.scores td.total { font-weight: 800; font-size: 17px; color: var(--gold); }
table.scores td.zero { color: #6fe0d0; font-weight: 700; }
table.scores tr.lead td:first-child::after { content: ' ★'; color: var(--gold); }
table.scores td.now { background: rgba(233, 196, 106, 0.1); }

.leftovers { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 6px; }
.leftover { display: flex; align-items: center; gap: 12px; --cw: 34px; }
.leftover .who { width: 110px; font-weight: 700; flex: none; }
.leftover .cards { display: flex; flex: 1; flex-wrap: wrap; row-gap: 4px; }
.leftover .cards .card { margin-left: -12px; }
.leftover .cards .card:first-child { margin-left: 0; }
.leftover .pts { font-weight: 800; color: var(--gold); width: 64px; text-align: right; flex: none; }
.leftover .out { color: #6fe0d0; font-weight: 700; }

.draws { display: flex; justify-content: center; gap: 18px; margin: 20px 0 8px; flex-wrap: wrap; --cw: 64px; }
.draw { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.draw.low .card { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(233, 196, 106, 0.55); }
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

#toasts { position: fixed; left: 50%; bottom: 250px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; align-items: center; }
.toast { background: #2b1a14; color: #ffd9cf; border: 1px solid #b5533c; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: rise 0.25s; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- small screens ---------- */
@media (max-height: 820px) {
  :root { --cw: 80px; }
  .piles { --cw: 88px; }
}
@media (max-width: 900px) {
  :root { --cw: 66px; }
  .table { grid-template-columns: 1fr; }
  .center { position: static; flex-direction: row; }
  .piles { --cw: 64px; padding: 12px; }
  .feed { flex: 1; min-height: 0; }
  .seat { min-width: 0; flex: 1; padding: 8px 10px; }
  .backs .card { display: none; }
  .topbar .brand { display: none; }
  .prompt { font-size: 16px; }
}
@media (max-width: 560px) {
  :root { --cw: 56px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .round-pill strong { display: none; }
  .table, .opponents, .dock { padding-left: 10px; padding-right: 10px; }
  .seat .avatar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- speed, flights and captions ---------- */
.speed { display: flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 12.5px; }
.speed .speed-label { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; color: var(--muted); }
.speed .end { color: var(--muted); }
.speed .speed-name { min-width: 68px; text-align: right; font-weight: 700; color: var(--gold); }
.speed input[type='range'] { -webkit-appearance: none; appearance: none; width: 150px; height: 6px; border-radius: 999px; background: linear-gradient(90deg, rgba(233, 196, 106, 0.25), var(--gold)); cursor: pointer; }
.speed input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.speed input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); }

.card.ghost { position: fixed; z-index: 40; margin: 0; pointer-events: none; transform-origin: 0 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 18px 30px rgba(0, 0, 0, 0.45); }
.seat .said { font-size: 12.5px; color: var(--gold); margin-top: 2px; min-height: 16px; white-space: nowrap; }
.seat .said .r, .callout .r { color: #ff9b9b; }

#callout { position: fixed; left: 0; right: 0; top: 46vh; display: flex; justify-content: center; pointer-events: none; z-index: 30; }
.callout { display: flex; align-items: center; gap: 12px; padding: 10px 22px 10px 10px; border-radius: 999px; background: rgba(6, 30, 21, 0.92); border: 1px solid rgba(233, 196, 106, 0.5); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45); font-family: var(--serif); font-size: 20px; animation: rise 0.3s; }
.callout .avatar { width: 34px; height: 34px; font-size: 15px; }
.btn.primary.alt { background: linear-gradient(180deg, #5fc7b9, #2a9d8f); border-color: #9be3d8; color: #05261f; }
.btn.primary.alt:hover:not(:disabled) { background: linear-gradient(180deg, #74d4c7, #31ab9c); }
@media (max-width: 900px) { .speed .end, .speed .speed-label { display: none; } .speed input[type='range'] { width: 90px; } .callout { font-size: 16px; } }

.tray-title { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.tray-title strong { color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; margin-right: 6px; }
.tray-title + .tray { margin-top: 6px; }

.sorter { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 12.5px; }
.sorter span { padding: 0 8px 0 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sorter button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 600; transition: background 0.15s, color 0.15s; }
.sorter button:hover { background: rgba(255, 255, 255, 0.1); }
.sorter button[aria-pressed='true'] { background: var(--gold); color: #2b2005; }

/* ---------- cards arriving in your hand ---------- */
.card.arrive { animation: arrive 1.7s cubic-bezier(0.2, 0.8, 0.3, 1) both; z-index: 6; }
@keyframes arrive {
  0% { transform: translateY(-58px) scale(1.22); box-shadow: 0 0 0 4px #5fe0cf, 0 0 44px 10px rgba(95, 224, 207, 0.85), 0 24px 30px rgba(0, 0, 0, 0.45); }
  18% { transform: translateY(-58px) scale(1.22) rotate(-3deg); }
  36% { transform: translateY(-58px) scale(1.22) rotate(3deg); }
  62% { transform: translateY(-58px) scale(1.22); box-shadow: 0 0 0 4px #5fe0cf, 0 0 44px 10px rgba(95, 224, 207, 0.85), 0 24px 30px rgba(0, 0, 0, 0.45); }
  100% { transform: none; }
}
.card.wild-arrive { animation-name: arrive-wild; }
@keyframes arrive-wild {
  0% { transform: translateY(-70px) scale(1.34) rotate(-8deg); box-shadow: 0 0 0 5px var(--gold), 0 0 60px 18px rgba(233, 196, 106, 0.95), 0 24px 30px rgba(0, 0, 0, 0.45); }
  20% { transform: translateY(-70px) scale(1.34) rotate(8deg); }
  40% { transform: translateY(-70px) scale(1.4) rotate(-5deg); }
  68% { transform: translateY(-70px) scale(1.34); box-shadow: 0 0 0 5px var(--gold), 0 0 60px 18px rgba(233, 196, 106, 0.95), 0 24px 30px rgba(0, 0, 0, 0.45); }
  100% { transform: none; }
}
.burst { position: fixed; width: 0; height: 0; z-index: 45; pointer-events: none; }
.burst b { position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--gold); animation: ring 0.9s ease-out forwards; }
.burst i { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; background: var(--gold); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: spark 1.1s ease-out forwards; }
.burst i:nth-child(odd) { background: #fff; }
@keyframes ring { from { transform: scale(0.3); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
@keyframes spark {
  from { transform: rotate(var(--a)) translateY(-20px) scale(0.4); opacity: 1; }
  to { transform: rotate(var(--a)) translateY(calc(-1 * var(--d) - 60px)) scale(1.6); opacity: 0; }
}

/* ---------- you went out ---------- */
.congrats { text-align: center; margin: 2px 0 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); animation: pop 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both; animation-delay: 0.15s; }
.congrats .stars { color: var(--gold); font-size: 26px; letter-spacing: 0.4em; padding-left: 0.4em; animation: twinkle 1.4s ease-in-out infinite; }
.congrats .big {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 7vw, 68px);
  line-height: 1.1;
  background: linear-gradient(100deg, #d9a93f 0%, #fff3c4 35%, #e9c46a 50%, #fff3c4 65%, #d9a93f 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35));
  animation: shine 2.4s linear infinite;
}
.congrats .line { font-size: 17px; color: var(--text); margin-top: 6px; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
@keyframes shine { to { background-position: -220% 0; } }
@keyframes twinkle { 50% { opacity: 0.45; transform: scale(0.94); } }

/* ---------- shuffle before the deal ---------- */
.stack.shuffling .card { animation: riffle-left var(--riffle, 300ms) ease-in-out 3; }
.stack.shuffling .card + .card { animation-name: riffle-right; }
@keyframes riffle-left { 50% { transform: translateX(-26px) rotate(-9deg); } }
@keyframes riffle-right { 50% { transform: translateX(26px) rotate(9deg); } }

/* ---------- online: account, my games, table room ---------- */
.setup-card.wide { width: min(640px, 100%); }
.setup-card h1 { font-size: 36px; }
.field input[type='email'], .field input[type='password'] { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.28); color: var(--text); font: inherit; font-size: 16px; }
.field .inline { display: flex; gap: 8px; }
/* A section that is a separate choice from the one above it. */
.field.apart { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.field .inline input { flex: 1; min-width: 0; }
.games { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 20px; text-align: left; }
.game-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); text-align: left; }
button.game-row:hover { background: rgba(255, 255, 255, 0.1); }
.game-row.mine { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.game-row .names { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row .status { font-size: 13px; color: var(--muted); }
.game-row.mine .status { color: var(--gold); font-weight: 700; }
.game-row .code { font: 700 12px ui-monospace, Menlo, monospace; letter-spacing: 0.1em; color: var(--muted); }
.setup-card .note { font-size: 12.5px; color: var(--muted); margin: 6px 0; }

/* Sound on/off: a speaker drawn with a mask so it takes the button's text colour. */
.btn.icon { width: 38px; padding: 6px 0; }
.btn.icon::before { content: ''; display: block; width: 18px; height: 18px; margin: 0 auto; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.btn.sound-on { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z' fill='black'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13'/%3E%3C/svg%3E"); }
.btn.sound-off { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z' fill='black'/%3E%3Cpath d='m16 9 6 6M22 9l-6 6'/%3E%3C/svg%3E"); opacity: 0.7; }

/* The flag beside the game's name. */
.flag { height: 0.72em; width: auto; margin-right: 0.4em; vertical-align: -0.02em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }

/* Points currently held in your hand. */
.dock .me .holding strong { color: var(--gold); font-weight: 700; font-size: 14px; }

/* ---------- tablets and phones ---------- */
.game { grid-template-columns: minmax(0, 1fr); }
.topbar .brand { white-space: nowrap; }
.topbar .controls { display: flex; align-items: center; gap: 12px; }
.menu-btn, .rotate { display: none; }
.btn, .card, .segments button, .sorter button { touch-action: manipulation; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
/* A finger has no hover: without this a tapped card stays lifted. */
@media (hover: none) { .slot .cards .card:hover, .meld.accepts:hover { transform: none; } }

/* Tablets (iPad landscape and portrait): everything stays on screen, a little tighter. */
@media (max-width: 1180px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .topbar .controls { gap: 8px; }
  .speed .end, .speed .speed-label { display: none; }
  .speed input[type='range'] { width: 100px; }
  .speed .speed-name { min-width: 58px; }
  .table { grid-template-columns: 230px minmax(0, 1fr); gap: 14px; padding: 12px 14px; }
  .piles { --cw: 84px; gap: 12px; padding: 14px 10px; }
  .melds { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
  .meld { --cw: 52px; }
  .opponents { gap: 10px; padding: 10px 14px 2px; }
  .seat { min-width: 0; }
  .backs .card:nth-child(n + 6) { display: none; }
  .dock { padding: 10px 14px 12px; }
  .slot { min-height: 104px; --cw: 50px; }
  .slot .cards { min-height: 72px; }
  .hand { padding-top: 20px; }
  .prompt { min-width: 160px; }
}
@media (max-width: 900px) {
  .table { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .topbar { position: relative; }
  .topbar .controls { display: none; }
  .topbar .controls.open { display: flex; flex-direction: column; align-items: stretch; position: absolute; right: 10px; top: calc(100% + 6px); z-index: 40; padding: 12px; border-radius: 16px; background: #0b2f22; border: 1px solid rgba(233, 196, 106, 0.4); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); }
  .topbar .controls.open .btn { padding: 10px 16px; font-size: 14px; }
  .topbar .controls.open .btn.icon { width: auto; }
  .topbar .controls.open .round-pill { justify-content: center; padding: 8px 14px; }
}

/* Phones held sideways: one slim top row, the table, then buttons and the hand. */
@media (max-height: 520px) {
  :root { --cw: 50px; }
  .game { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .topbar { grid-column: 1; grid-row: 1; padding: 5px 8px; gap: 6px; border-bottom: 0; background: none; position: static; }
  .topbar .brand, .topbar .spacer { display: none; }
  .round-pill { padding: 3px 10px 3px 3px; font-size: 12px; gap: 6px; }
  .round-pill .num { font-size: 11px; padding: 2px 7px; }
  .round-pill strong { display: inline; }
  .menu-btn { display: inline-flex; padding: 5px 10px; }
  .topbar .controls { display: none; }
  .topbar .controls.open { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; gap: 8px; position: fixed; right: 8px; left: auto; top: 40px; z-index: 40; padding: 10px; border-radius: 16px; background: #0b2f22; border: 1px solid rgba(233, 196, 106, 0.4); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); }
  .topbar .controls.open .speed { grid-column: 1 / -1; }
  .topbar .controls.open .btn { padding: 9px 14px; font-size: 13.5px; }
  .topbar .controls.open .btn.icon { width: auto; }

  .opponents { grid-column: 2; grid-row: 1; justify-content: flex-end; flex-wrap: nowrap; gap: 6px; padding: 5px 8px 5px 0; min-width: 0; overflow: hidden; }
  .seat { flex: 0 1 auto; min-width: 0; padding: 3px 9px 3px 4px; gap: 6px; border-radius: 999px; }
  .seat.active { transform: none; }
  .seat .avatar { display: grid; width: 24px; height: 24px; font-size: 12px; }
  .seat .name { font-size: 12.5px; white-space: nowrap; gap: 4px; }
  .seat .meta, .seat .said, .backs .card { display: none; }
  .backs .count { margin-left: 0; font-size: 13px; }
  .chip { font-size: 8.5px; padding: 1px 5px; }
  .chip.down { font-size: 0; padding: 0; width: 9px; height: 9px; }

  .table { grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr); gap: 8px; padding: 4px 8px; }
  .center { position: sticky; flex-direction: column; gap: 0; }
  .piles { --cw: 48px; gap: 8px; padding: 8px; border-radius: 12px; }
  .pile { gap: 3px; font-size: 8.5px; letter-spacing: 0.04em; }
  .feed { display: none; }
  .melds { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px; }
  .melds .empty-table { padding: 18px 10px; font-size: 15px; }
  .owner { padding: 5px 7px; border-radius: 12px; }
  .owner h3 { margin-bottom: 4px; font-size: 9.5px; }
  .meld-row { gap: 5px; }
  .meld { --cw: 36px; padding: 4px 6px 5px; border-radius: 10px; }
  .meld .label { font-size: 9.5px; margin-bottom: 3px; }
  .meld .cards .card { margin-left: -15px; }

  .dock { grid-column: 1 / -1; padding: 5px 8px 4px; }
  .dock-head { gap: 4px 10px; flex-wrap: wrap; }
  .dock .me .avatar { display: none; }
  .dock .me { font-size: 12px; white-space: nowrap; }
  .dock .me .meta { font-size: 10.5px; }
  .dock .me .holding strong { font-size: 12px; }
  .prompt { flex: 1 1 0; min-width: 0; font-size: 13.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock .me { display: flex; gap: 8px; align-items: baseline; }
  .dock .me > div { display: flex; gap: 8px; align-items: baseline; }
  .prompt small { display: none; }
  .buttons { order: 3; flex: 1 0 100%; flex-wrap: nowrap; gap: 5px; overflow-x: auto; scrollbar-width: none; }
  .dock-head .sorter { order: 2; flex: none; }
  .buttons .btn { padding: 7px 11px; font-size: 12.5px; white-space: nowrap; }
  .sorter span { display: none; }
  .sorter button { padding: 5px 8px; font-size: 11.5px; }
  .tray-title { display: none; }
  .tray { margin-top: 4px; gap: 6px; flex-wrap: nowrap; }
  .slot { --cw: 36px; min-width: 0; min-height: 0; padding: 4px 6px; border-radius: 10px; }
  .slot .label { font-size: 10px; margin-bottom: 2px; }
  .slot .cards { min-height: 52px; }
  .slot .hint { font-size: 11px; }
  .hand { padding: 10px 4px 0; min-height: calc(var(--cw) * 1.42 + 10px); }

  #callout { top: 34vh; }
  .callout { font-size: 14px; padding: 6px 14px 6px 6px; }
  .overlay { padding: 8px; }
  .modal { padding: 14px 16px; max-height: calc(100vh - 16px); border-radius: 16px; }
  .setup { padding: 10px; place-items: start center; }
  .setup-card .hero { display: none; }
  .setup h1 { font-size: 28px; }
  .setup .tagline { margin-bottom: 12px; }
  /* The home screen's three buttons sit side by side so the whole screen fits without scrolling. */
  .setup-card.home { width: min(560px, 100%); }
  .setup-card.home .actions { flex-direction: row; margin-top: 16px; }
  .setup-card.home .actions .btn { flex: 1; padding: 12px 6px; font-size: 14px; }
}

/* A phone held upright is too narrow for a card table. */
@media (orientation: portrait) and (max-width: 600px) {
  .rotate { display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; text-align: center; position: fixed; inset: 0; z-index: 60; padding: 30px; background: #0b2f22; color: var(--muted); font-size: 15px; }
  .rotate strong { font: 600 26px var(--serif); color: var(--gold); }
}
.round-pill .num, .round-pill strong { white-space: nowrap; }

/* ---------- live video ---------- */
.cam { width: 64px; height: 64px; flex: none; border-radius: 14px; object-fit: cover; background: #000; box-shadow: 0 0 0 2px var(--line), 0 4px 12px rgba(0, 0, 0, 0.4); }
.cam.self { transform: scaleX(-1); } /* your own picture is mirrored, as in a mirror */
.seat.active .cam { box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(0, 0, 0, 0.4); }
.dock .me .cam { width: 52px; height: 52px; }
@media (max-height: 520px) {
  .cam { width: 32px; height: 32px; border-radius: 50%; }
  .dock .me .cam { display: block; width: 30px; height: 30px; }
}

/* Guests: how to come back to a seat. */
.field.keep { text-align: left; padding: 14px; border-radius: 14px; border: 1px dashed var(--line); background: rgba(0, 0, 0, 0.18); }
.field.keep .btn { margin-top: 6px; }
