/* Books and Runs: a 1970s family card table. Olive vinyl, a gold-stitched edge, a warm lamp
   over the middle, classic cards, and the scorekeeper's yellow legal pad. */

:root {
  --vinyl: #3e4925;
  --vinyl-lit: #56653a;
  --vinyl-deep: #222912;
  --vinyl-panel: #2c341a;
  --stitch: rgba(227, 170, 60, 0.42);
  --gold: #e3aa3c;
  --gold-hi: #f5cb6a;
  --gold-ink: #2b1f05;
  --cream: #f4ecd6;
  --cream-dim: #c9c1a3;
  --cream-faint: rgba(244, 236, 214, 0.14);
  --card: #fffdf7;
  --card-edge: #d8d0bb;
  --ink: #17140f;
  --red: #c4202c;
  --back: #8e1c22;
  --pad: #f9ec9f;
  --pad-rule: #9cc0e3;
  --pad-margin: #e07272;
  --pencil: #2f3a4a;
  --danger: #ff9b8a;

  --ui: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Charter, Georgia, serif;

  --cw: 58px;
  --ch: 82px;
  --mw: 34px;
  --mh: 48px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 700px) and (min-height: 640px) {
  :root { --cw: 72px; --ch: 101px; --mw: 40px; --mh: 56px; }
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.4;
  color: var(--cream);
  background: var(--vinyl-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 75% at 50% 40%, var(--vinyl-lit) 0%, var(--vinyl) 50%, var(--vinyl-deep) 100%);
  position: relative;
  isolation: isolate;
}

/* Vinyl grain */
#app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.btn {
  appearance: none;
  border: 0;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--cream-faint);
  color: var(--cream);
  font-weight: 650;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 0.08s ease, background-color 0.15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 2px 0 #966b14;
}
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #966b14; }
.btn.quiet { background: transparent; color: var(--cream-dim); padding: 0 10px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn.wide { width: 100%; }

:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 2px; }

.field {
  font: inherit;
  font-size: 18px;
  min-height: 50px;
  width: 100%;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid rgba(244, 236, 214, 0.18);
  background: rgba(0, 0, 0, 0.24);
  color: var(--cream);
}
.field::placeholder { color: rgba(244, 236, 214, 0.45); }
.field:focus { border-color: var(--gold); outline: none; }

select.field, select.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--cream-dim) 50%), linear-gradient(-45deg, transparent 50%, var(--cream-dim) 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.select {
  font: inherit;
  font-size: 16px;
  min-height: 40px;
  border-radius: 10px;
  border: 1.5px solid rgba(244, 236, 214, 0.18);
  background-color: rgba(0, 0, 0, 0.22);
  color: var(--cream);
  padding-left: 10px;
}

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

.card {
  position: relative;
  flex: none;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.13);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--card-edge), 0 2px 5px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.card.red { color: var(--red); }

.card .idx {
  position: absolute;
  top: calc(var(--cw) * 0.07);
  left: calc(var(--cw) * 0.08);
  width: calc(var(--cw) * 0.34);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-family: var(--serif);
  font-weight: 700;
  font-size: calc(var(--cw) * 0.36);
  letter-spacing: -0.06em;
}
.card .idx .pip {
  width: calc(var(--cw) * 0.25);
  height: calc(var(--cw) * 0.25);
  margin-top: calc(var(--cw) * 0.04);
  fill: currentColor;
}
.card .big {
  position: absolute;
  right: 11%;
  bottom: 10%;
  width: 46%;
  height: 46%;
  fill: currentColor;
}
.card .face {
  position: absolute;
  right: 10%;
  bottom: 5%;
  font-family: var(--serif);
  font-size: calc(var(--cw) * 0.62);
  font-weight: 600;
  line-height: 1;
}
.card.wild::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.card.joker { color: #8d1a24; }
.card.joker .idx .star { width: calc(var(--cw) * 0.3); height: calc(var(--cw) * 0.3); fill: var(--gold); stroke: #8d1a24; stroke-width: 5; }
.card .joker-word {
  position: absolute;
  right: 9%;
  bottom: 8%;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: calc(var(--cw) * 0.24);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.card .as {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--pencil);
  letter-spacing: -0.02em;
}

.card.back {
  background:
    repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, 0.16) 5px 6px),
    repeating-linear-gradient(-45deg, transparent 0 5px, rgba(255, 255, 255, 0.16) 5px 6px),
    var(--back);
  box-shadow: inset 0 0 0 calc(var(--cw) * 0.06) var(--card), 0 0 0 1px var(--card-edge), 0 2px 5px rgba(0, 0, 0, 0.35);
}

.card.mini {
  width: var(--mw);
  height: var(--mh);
  border-radius: 5px;
  box-shadow: 0 0 0 1px var(--card-edge), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.card.mini .idx { top: 3px; left: 2px; width: 20px; font-size: 16px; }
.card.mini .idx .pip { width: 12px; height: 12px; margin-top: 2px; }
.card.mini .idx .star { width: 13px; height: 13px; }
.card.mini.wild::after { top: 3px; right: 3px; width: 5px; height: 5px; }

/* ------------------------------------------------------------ home */

.home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(28px + var(--safe-t)) 22px calc(24px + var(--safe-b));
}

.fan {
  position: relative;
  width: 300px;
  height: 178px;
  margin-top: 8px;
}
.fan .card {
  --cw: 70px;
  --ch: 98px;
  position: absolute;
  left: calc(50% - 35px);
  bottom: 0;
  transform-origin: 50% 240%;
  transform: rotate(var(--a));
  animation: spread 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 45ms);
}
@keyframes spread {
  from { transform: rotate(0deg); }
}

.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 11vw, 58px);
  line-height: 1;
  letter-spacing: -0.025em;
  text-align: center;
  margin-top: 22px;
}
.tagline {
  margin: 10px 0 28px;
  font-size: 18px;
  color: var(--cream-dim);
  text-align: center;
  max-width: 28ch;
}

.home-form {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
}
.home-form label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; color: var(--cream-dim); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.join-row .field { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; }
.or { text-align: center; color: var(--cream-dim); font-size: 14px; }
.form-error { color: var(--danger); font-weight: 600; min-height: 1.4em; text-align: center; }
.home-foot {
  margin-top: auto;
  padding-top: 28px;
  font-size: 14px;
  color: var(--cream-dim);
  text-align: center;
  max-width: 34ch;
}

/* ------------------------------------------------------------ lobby */

.lobby {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(10px + var(--safe-t)) 18px calc(110px + var(--safe-b));
}
.lobby-top { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.lobby h2 { font-size: 21px; font-weight: 700; margin: 26px 0 10px; }
.code-block { text-align: center; margin-top: 4px; }
.code-block p { color: var(--cream-dim); }
.code-cards { display: flex; justify-content: center; gap: 10px; margin: 10px 0 16px; }
.code-card {
  --cw: 58px;
  --ch: 80px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 700;
}
.code-card:nth-child(even) { color: var(--red); }
.code-hint { margin-top: 10px; font-size: 14px; color: var(--cream-dim); }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 8px 6px 6px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}
.person .who { flex: 1; min-width: 0; }
.person .who b { display: block; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .who small { color: var(--cream-dim); font-size: 13px; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: #1d1a12;
  position: relative;
}
.avatar .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #7fd17a;
  box-shadow: 0 0 0 2px var(--vinyl-panel);
}
.avatar .dot.off { background: #8b8774; }

.c0 { background: #e3aa3c; } .c1 { background: #e07a52; } .c2 { background: #6fb6a8; } .c3 { background: #b98ac2; }
.c4 { background: #8fb3e0; } .c5 { background: #a9c46a; } .c6 { background: #ef9fa0; } .c7 { background: #c9b48c; }

.hands-list { list-style: none; padding: 0; margin: 0; counter-reset: hand; display: grid; gap: 2px; }
.hands-list li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--cream-faint);
}
.hands-list .n { color: var(--cream-dim); font-variant-numeric: tabular-nums; font-weight: 700; }
.hands-list .deal { color: var(--cream-dim); font-size: 14px; }

.settings { display: grid; gap: 10px; }
.settings details {
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  padding: 0 14px;
}
.settings summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: "+"; margin-left: auto; font-size: 22px; color: var(--cream-dim); }
.settings details[open] summary::after { content: "–"; }
.settings .opts { display: grid; gap: 12px; padding: 4px 0 16px; }
.opt { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; font-size: 15px; }
.opt > span { flex: 1 1 150px; }
.opt .select { flex: 0 1 auto; max-width: 100%; }
.opt small { display: block; color: var(--cream-dim); font-size: 13px; }
.opt input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--gold); }
.opt input[type="number"] { width: 76px; min-height: 40px; font-size: 16px; text-align: center; }

.custom-hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-faint);
}
.custom-hand .label { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.custom-hand label { display: grid; gap: 2px; font-size: 12px; color: var(--cream-dim); }
.custom-hand .select { width: 100%; min-height: 38px; }
.custom-hand .check { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--cream); }

.rules-text { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; color: var(--cream); }
.rules-text li { padding-left: 16px; position: relative; }
.rules-text li::before { content: ""; position: absolute; left: 2px; top: 0.6em; width: 6px; height: 6px; border-radius: 1px; background: var(--gold); transform: rotate(45deg); }

.lobby-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 18px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--vinyl-deep) 55%, transparent);
  display: flex;
  justify-content: center;
}
.lobby-foot > * { width: min(524px, 100%); }
.lobby-foot p { text-align: center; color: var(--cream-dim); padding: 10px 0; }

/* ------------------------------------------------------------ table */

.table {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(6px + var(--safe-t)) 10px 2px 14px;
}
.hand-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: left;
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
}
.hand-info .contract { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ladder { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--cream-dim); }
.ladder i { width: 14px; height: 5px; border-radius: 3px; background: var(--cream-faint); }
.ladder i.done { background: rgba(227, 170, 60, 0.45); }
.ladder i.now { background: var(--gold); width: 22px; }
.ladder span { margin-left: 4px; }
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--cream-faint);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; stroke: var(--cream); stroke-width: 2.2; fill: none; stroke-linecap: round; }

.seats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 12px 8px;
  scrollbar-width: none;
}
.seats::-webkit-scrollbar { display: none; }
.seat {
  flex: none;
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.seat .avatar { width: 32px; height: 32px; font-size: 14px; }
.seat .name { font-weight: 700; font-size: 14px; line-height: 1.15; max-width: 8ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cream-dim); line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.seat .meta .cc { display: inline-flex; align-items: center; gap: 3px; }
.seat .meta .cc::before { content: ""; width: 7px; height: 10px; border-radius: 2px; border: 1.5px solid currentColor; opacity: 0.8; }
.seat .meta .down { color: #9fe39a; font-weight: 700; }
.seat.turn { background: var(--gold); color: var(--gold-ink); }
.seat.turn .meta, .seat.turn .meta .down { color: rgba(43, 31, 5, 0.78); }
.seat.turn .avatar { box-shadow: 0 0 0 2px rgba(43, 31, 5, 0.45); }
.seat.turn .avatar .dot { box-shadow: 0 0 0 2px var(--gold); }
.seat.offline .name { opacity: 0.6; }
.bubble {
  position: fixed;
  z-index: 95;
  font-size: 30px;
  line-height: 1;
  pointer-events: none;
  animation: bubble 2.2s ease-out forwards;
}
@keyframes bubble {
  0% { transform: translate(-50%, 10px) scale(0.5); opacity: 0; }
  15% { transform: translate(-50%, 0) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -26px) scale(1); opacity: 0; }
}

.felt {
  position: relative;
  margin: 2px 10px 4px;
  border: 2px dashed var(--stitch);
  border-radius: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 14px;
}
.felt-empty {
  height: 100%;
  min-height: 80px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--cream-dim);
  padding: 12px;
}
.felt-empty b { display: block; font-family: var(--serif); font-size: 20px; color: var(--cream); margin-bottom: 4px; }

.group + .group { margin-top: 10px; }
.group-name { font-size: 13px; font-weight: 700; color: var(--cream-dim); margin: 0 0 4px 2px; }
.group-melds { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.meld {
  display: flex;
  padding: 5px;
  margin: -5px;
  border-radius: 10px;
  border: 0;
  background: none;
  cursor: default;
  transition: background-color 0.15s ease;
}
.meld .card + .card { margin-left: calc(var(--mw) * -0.42); }
.meld.can-add, .meld.can-swap { cursor: pointer; background: rgba(227, 170, 60, 0.22); box-shadow: 0 0 0 2px var(--gold); }
.meld.can-swap .card.joker, .meld.can-swap .card.wild { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 12px var(--gold); }
.meld.drop-hover { background: rgba(227, 170, 60, 0.45); }
.meld .card.new { animation: land 0.45s ease-out; }
@keyframes land {
  from { transform: translateY(-14px); opacity: 0; }
}

.pit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  min-height: calc(var(--ch) + 16px);
}
.pile {
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  border-radius: calc(var(--cw) * 0.13);
  cursor: default;
}
.pile .count {
  position: absolute;
  right: -7px;
  bottom: -7px;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--vinyl-deep);
  color: var(--cream);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.pile.empty { width: var(--cw); height: var(--ch); border: 2px dashed var(--cream-faint); }
.pile.live { cursor: pointer; animation: live 1.8s ease-in-out infinite; }
@keyframes live {
  0%, 100% { box-shadow: 0 0 0 2px var(--gold), 0 0 0 rgba(227, 170, 60, 0); }
  50% { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px rgba(245, 203, 106, 0.7); }
}
.pile.drop-hover { box-shadow: 0 0 0 3px var(--gold-hi); }
.discard-pile .card.arrive { animation: arrive 0.35s ease-out; }
@keyframes arrive {
  from { transform: translateY(-18px) rotate(-6deg); opacity: 0.2; }
}

.status { flex: 1; min-width: 0; display: grid; gap: 6px; align-content: center; }
.status .main { font-weight: 700; font-size: 16px; line-height: 1.25; }
.status .sub { color: var(--cream-dim); font-size: 14px; line-height: 1.3; }
.status .btn { justify-self: start; }

.tray {
  padding: 4px 0 calc(8px + var(--safe-b));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.28) 30%);
}
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 10px;
  min-height: 54px;
}
.actions .spacer { flex: 1; }
.actions .hint { flex: 1; color: var(--cream-dim); font-size: 14px; line-height: 1.25; }
.sort-btn { width: 44px; padding: 0; flex: none; }
.sort-btn svg { width: 22px; height: 22px; stroke: var(--cream); stroke-width: 2.2; fill: none; stroke-linecap: round; }

.hand {
  position: relative;
  padding: 16px 8px 4px;
  min-height: calc(var(--ch) + 22px);
  touch-action: none;
}
.hand-row { display: flex; justify-content: center; }
.hand-row + .hand-row { margin-top: calc(var(--ch) * -0.4); }
.hand-row .card + .card { margin-left: calc(var(--step, 30px) - var(--cw)); }
.hand .card { cursor: pointer; transition: transform 0.12s ease, opacity 0.12s ease; }
.hand .card.sel { transform: translateY(-14px); box-shadow: 0 0 0 2.5px var(--gold), 0 6px 14px rgba(0, 0, 0, 0.45); }
.hand .card.fresh { animation: arrive 0.4s ease-out; }
.hand .card.drawn::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  box-shadow: 0 0 0 2.5px var(--gold-hi), 0 0 12px rgba(245, 203, 106, 0.6);
  pointer-events: none;
}
.hand .card.lifted { opacity: 0.25; }
.hand-empty { text-align: center; color: var(--cream-dim); padding-top: 20px; }
.caret {
  position: absolute;
  width: 4px;
  border-radius: 2px;
  background: var(--gold-hi);
  pointer-events: none;
  box-shadow: 0 0 10px var(--gold);
}
.ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -60%) rotate(-4deg) scale(1.08);
  box-shadow: 0 0 0 1px var(--card-edge), 0 14px 26px rgba(0, 0, 0, 0.5);
}

/* Laying down: one slot per meld the contract needs */
.staging { padding: 0 12px 8px; display: grid; gap: 8px; }
.staging[hidden] { display: none; }
.slots { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.slot {
  flex: 1 1 0;
  min-width: 108px;
  min-height: calc(var(--mh) + 34px);
  border-radius: 12px;
  border: 2px dashed rgba(244, 236, 214, 0.3);
  background: rgba(0, 0, 0, 0.18);
  padding: 6px 8px;
  text-align: left;
  display: grid;
  gap: 4px;
  align-content: start;
  cursor: pointer;
}
.slot.ok { border-style: solid; border-color: #9fe39a; }
.slot.target { border-color: var(--gold); background: rgba(227, 170, 60, 0.16); }
.slot.drop-hover { background: rgba(227, 170, 60, 0.35); }
.slot .slot-name { font-size: 13px; font-weight: 700; color: var(--cream-dim); display: flex; justify-content: space-between; gap: 6px; }
.slot.ok .slot-name { color: #9fe39a; }
.slot .slot-cards { display: flex; min-height: var(--mh); }
.slot .slot-cards .card + .card { margin-left: calc(var(--mw) * -0.42); }
.slot .slot-msg { font-size: 12px; color: var(--cream-dim); line-height: 1.2; max-width: 22ch; }
.staging-buttons { display: flex; gap: 8px; align-items: center; }
.staging-buttons .note { flex: 1; font-size: 13px; color: var(--cream-dim); line-height: 1.25; }

.net-banner {
  position: fixed;
  top: calc(8px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 8px 16px;
  border-radius: 999px;
  background: #1a1f0e;
  color: var(--cream);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------ toasts */

#toasts {
  position: fixed;
  z-index: 90;
  left: 50%;
  top: calc(124px + var(--safe-t));
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  justify-items: center;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 14px;
  background: rgba(24, 28, 13, 0.94);
  color: var(--cream);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  animation: toast-in 0.2s ease-out;
}
.toast.big { background: var(--gold); color: var(--gold-ink); }
.toast.error { background: #5b1d18; color: #ffe1db; }
.toast.leaving { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-8px); opacity: 0; } }

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

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(14, 17, 7, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: scrim-in 0.15s ease-out;
}
@keyframes scrim-in { from { opacity: 0; } }
.sheet {
  width: min(560px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--vinyl-panel);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.4);
  animation: sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } }
.scrim.still, .scrim.still .sheet { animation: none; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; font-size: 22px; font-family: var(--serif); font-weight: 700; }
.sheet .stack { display: grid; gap: 10px; }
.sheet p.lead { color: var(--cream-dim); margin-bottom: 14px; }
.menu-list { display: grid; gap: 6px; }
.menu-list .btn { justify-content: flex-start; width: 100%; min-height: 50px; font-weight: 600; }
.menu-list .btn .right { margin-left: auto; color: var(--cream-dim); font-weight: 500; }
.menu-list .btn.danger { color: var(--danger); }
.section-label { font-size: 14px; font-weight: 700; color: var(--cream-dim); margin: 14px 0 4px; }
.reactions { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 8px; }
.reactions button { font-size: 28px; width: 52px; height: 52px; border: 0; border-radius: 14px; background: var(--cream-faint); cursor: pointer; }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 15px; }
.log-list li { padding: 6px 2px; border-bottom: 1px solid var(--cream-faint); }
.log-list li.mine { color: var(--gold-hi); }

/* The scorekeeper's legal pad */
.pad {
  position: relative;
  background-color: var(--pad);
  color: var(--pencil);
  border-radius: 3px 3px 10px 10px;
  padding: 26px 0 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  overflow-x: auto;
  background-image:
    linear-gradient(to right, transparent 38px, var(--pad-margin) 38px 39px, transparent 39px 42px, var(--pad-margin) 42px 43px, transparent 43px),
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--pad-rule) 31px 32px);
  background-position: 0 0, 0 26px;
}
.pad::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  border-radius: 3px 3px 0 0;
  background: #6b2a1f;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.pad h3 {
  font-family: var(--serif);
  font-size: 21px;
  line-height: 32px;
  padding: 0 14px 0 52px;
  white-space: nowrap;
}
.pad .pad-note { line-height: 32px; padding: 0 14px 0 52px; font-size: 15px; }
.pad table { border-collapse: collapse; min-width: 100%; font-variant-numeric: tabular-nums; }
.pad th, .pad td { height: 32px; padding: 0 10px; text-align: right; white-space: nowrap; font-size: 16px; }
.pad th:first-child, .pad td:first-child { text-align: left; padding-left: 52px; }
.pad thead th { font-weight: 700; }
.pad td.contract { color: rgba(47, 58, 74, 0.7); font-size: 14px; }
.pad tr.total td { font-weight: 800; box-shadow: inset 0 2px 0 var(--pencil), inset 0 5px 0 var(--pad), inset 0 6px 0 var(--pencil); }
.pad tr.now td { background: rgba(227, 170, 60, 0.25); }
.pad .lead-mark { color: #b0441f; font-weight: 800; }
.pad .left-cards { display: flex; align-items: center; height: 64px; padding: 0 14px 0 52px; overflow: hidden; }
.pad .left-cards .card + .card { margin-left: calc(var(--mw) * -0.5); }
.pad .result-row { display: flex; align-items: baseline; gap: 10px; line-height: 32px; padding: 0 14px 0 52px; }
.pad .result-row b { flex: 1; font-size: 17px; }
.pad .result-row .pts { font-weight: 800; font-size: 17px; }
.pad .result-row .out { font-style: italic; color: #b0441f; font-weight: 700; }
.pad .result-row small { font-size: 13px; color: rgba(47, 58, 74, 0.7); min-width: 64px; text-align: right; }

.winner {
  text-align: center;
  padding: 6px 0 18px;
}
.winner .name {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  display: inline-block;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--gold);
}
.winner p { color: var(--cream-dim); margin-top: 10px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 16px; }
.waiting { text-align: center; color: var(--cream-dim); padding: 8px 0; }

/* ------------------------------------------------------------ trash talk */

.taunt-open { font-size: 22px; }
.taunt-targets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(244, 236, 214, 0.25);
  background: transparent;
  color: var(--cream);
  font-weight: 650;
  cursor: pointer;
}
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.taunt-custom { display: grid; gap: 8px; margin-bottom: 4px; }
.taunt-custom-row { display: flex; gap: 8px; }
.taunt-custom-row .select { flex: 1; }
.taunt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.taunt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  border: 0;
  border-radius: 14px;
  background: var(--cream-faint);
  color: var(--cream);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}
.taunt-btn span { font-size: 24px; flex: none; }
.taunt-btn.sent { animation: sent 0.5s ease-out; }
@keyframes sent {
  0% { background: var(--gold); color: var(--gold-ink); transform: scale(0.96); }
  100% { background: var(--cream-faint); }
}

.taunt-splash {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 97;
  width: min(86vw, 380px);
  display: grid;
  justify-items: center;
  gap: 6px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: taunt-in 2.6s ease forwards;
}
.taunt-emoji { font-size: 84px; line-height: 1; animation: wobble 0.5s ease-in-out 3; }
.taunt-bubble {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 16px 20px 14px;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  transform: rotate(-2deg);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}
.taunt-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  border: 11px solid transparent;
  border-top: 0;
  border-bottom-color: var(--card);
  transform: translateX(-50%);
}
.taunt-text { font-family: var(--serif); font-size: 27px; font-weight: 700; line-height: 1.15; }
.taunt-who { font-size: 13px; font-weight: 700; color: #7a6f5b; }
@keyframes taunt-in {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.5); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  18% { transform: translate(-50%, -50%) scale(1); }
  85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(0.98); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg) scale(1.1); }
  75% { transform: rotate(14deg) scale(1.1); }
}
.seat.shake { animation: shake 0.45s ease-in-out 2; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-3deg); }
  40% { transform: translateX(6px) rotate(3deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

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