:root {
  --felt: #12563c;
  --felt-deep: #0b3224;
  --felt-ink: #082018;
  --wood: #6a3a1c;
  --wood-dark: #3a1f10;
  --cream: #f3ead8;
  --paper: #fbf7ee;
  --ink: #14241c;
  --muted: #4d5e54;
  --gold: #c8962a;
  --gold-soft: #e8c56a;
  --red: #c41e3a;
  --black: #161616;
  --line: rgba(20, 36, 28, .12);
  --shadow: 0 10px 30px rgba(8, 32, 24, .18);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  --card-w: clamp(58px, 14vw, 86px);
  --radius: 18px;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.45;
}
a { color: inherit; }
img { max-width: 100%; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
}
.brand-mark { position: relative; width: 34px; height: 28px; }
.mini-card {
  position: absolute;
  width: 20px;
  height: 28px;
  border-radius: 3px;
  background: var(--paper);
  border: 1px solid #d9cbb0;
  font-size: 9px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.mini-card.red { color: var(--red); left: 0; top: 0; transform: rotate(-12deg); }
.mini-card.blk { color: var(--black); left: 12px; top: 2px; transform: rotate(10deg); }
.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: .92rem;
}
.top-nav a { text-decoration: none; opacity: .8; }
.top-nav a:hover { opacity: 1; }
.room-pill {
  font-family: var(--font-mono);
  font-size: .82rem;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: .12em;
}

.home { max-width: 980px; margin: 0 auto; padding: 12px 22px 64px; }
.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 36px;
  align-items: center;
  padding: 18px 0 40px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  color: var(--muted);
  margin: 0 0 8px;
}
.hero h1, .prose h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.4vw, 3.2rem);
  line-height: 1.12;
  margin: 0 0 14px;
  font-weight: 700;
}
.lede { font-size: 1.12rem; color: var(--muted); margin: 0 0 22px; max-width: 38em; }

.name-row, .join-row { margin: 0 0 16px; }
.name-row label, .join-row label {
  display: grid;
  gap: 6px;
  font-size: .86rem;
  color: var(--muted);
}
input[type="text"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  width: min(100%, 280px);
}
.join-fields { display: flex; gap: 8px; align-items: center; }
.join-fields input {
  width: 8.5rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 1.05rem;
}

.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  padding: 11px 18px;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: #e4d8c2;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--felt); color: var(--cream); }
.btn-gold { background: var(--gold); color: #2a1c08; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-danger { background: #8b1e2d; color: #fff; }
.btn:hover:not(:disabled) { filter: brightness(1.06); }

.hero-table {
  background:
    radial-gradient(80% 70% at 50% 40%, #1c7a52, transparent 70%),
    var(--felt-deep);
  border: 12px solid var(--wood);
  border-radius: 28px;
  min-height: 260px;
  box-shadow: var(--shadow), inset 0 0 50px rgba(0,0,0,.28);
  display: grid;
  place-items: center;
  position: relative;
}
.fan { position: relative; width: 220px; height: 170px; }
.fan .pcard.mini {
  position: absolute;
  left: 58px;
  top: 24px;
  width: 92px;
  height: 128px;
  transform: rotate(var(--r)) translateY(-8px);
  box-shadow: 0 10px 18px rgba(0,0,0,.28);
}
.fan-caption {
  position: absolute;
  bottom: 10px;
  left: 0; right: 0;
  text-align: center;
  color: rgba(243, 234, 216, .7);
  font-size: .78rem;
  letter-spacing: .04em;
  margin: 0;
}

.how, .games { margin: 10px 0 28px; }
.how h2, .games h2, .prose h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin: 0 0 12px;
}
.steps {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  counter-increment: step;
  background: var(--paper);
  border-radius: 14px;
  padding: 14px 16px 14px 52px;
  position: relative;
  box-shadow: 0 1px 0 var(--line);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 14px; top: 14px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--felt);
  color: var(--cream);
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 700;
}
.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.game-card.soon { opacity: .72; }
.game-card h2 { margin-top: 0; }
.game-meta { color: var(--muted); font-size: .88rem; }
.game-card .cta-row { margin-top: 14px; }
.game-card .btn { font-size: .92rem; padding: 9px 14px; }
.rules .prose + .prose { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }

.prose { max-width: 40em; }
.prose ul { padding-left: 1.2em; }
.prose h2 { margin-top: 1.6em; }

.foot {
  padding: 24px 22px 40px;
  color: var(--muted);
  font-size: .88rem;
  text-align: center;
}

/* Felt table */
.felt-page {
  min-height: 100dvh;
  background:
    radial-gradient(900px 480px at 50% -8%, #1b6d4c, transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px),
    var(--felt-deep);
  color: var(--cream);
}
.felt-page .top { color: var(--cream); }
.felt-page .top-nav a { opacity: .85; }
.felt-page .brand-name { text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.table {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 14px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.boot, .noscript { text-align: center; opacity: .8; }

.board {
  background: linear-gradient(180deg, rgba(20, 107, 72, .55), rgba(8, 40, 28, .25));
  border: 10px solid var(--wood);
  border-bottom-color: var(--wood-dark);
  border-radius: 28px;
  box-shadow: inset 0 0 80px rgba(0,0,0,.28), 0 16px 40px rgba(0,0,0,.28);
  padding: 14px 12px 18px;
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  gap: 8px;
  position: relative;
}

.opp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .92rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #7a8c82;
}
.dot.on { background: #9ee6b8; box-shadow: 0 0 8px #9ee6b8; }
.badge-last {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--gold);
  color: #2a1c08;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.opp-hand {
  display: flex;
  justify-content: center;
  min-height: 70px;
}
.opp-hand .pcard.back {
  width: 48px;
  height: 68px;
  margin-left: -28px;
}
.opp-hand .pcard.back:first-child { margin-left: 0; }

.centre {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  position: relative;
}
.pile { display: grid; justify-items: center; gap: 6px; }
.pile-label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.deck-stack {
  width: var(--card-w);
  height: calc(var(--card-w) * 1.4);
  position: relative;
}
.deck-stack .pcard.back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.deck-stack .pcard.back:nth-child(1) { transform: translate(2px, 2px); }
.deck-stack .pcard.back:nth-child(2) { transform: translate(1px, 1px); }
.suit-chip {
  min-width: 52px;
  text-align: center;
  font-size: 1.6rem;
  background: rgba(0,0,0,.22);
  border-radius: 12px;
  padding: 6px 10px;
}
.suit-chip.red { color: #ff8a9a; }
.suit-chip.black { color: #f3ead8; }

.status {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.08rem;
  min-height: 1.4em;
  padding: 4px 8px;
}
.status.warn { color: var(--gold-soft); }

.you-hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 4px 2px;
  min-height: calc(var(--card-w) * 1.5);
}
.you-hand .pcard { width: var(--card-w); height: calc(var(--card-w) * 1.4); }
.you-hand .pcard.legal { box-shadow: 0 0 0 2px rgba(232, 197, 106, .7), 0 8px 16px rgba(0,0,0,.28); }
.you-hand .pcard.selected {
  transform: translateY(-14px);
  box-shadow: 0 0 0 2px #fff, 0 14px 24px rgba(0,0,0,.35);
}
.you-hand .pcard:disabled { opacity: .55; cursor: default; }

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 4px;
}
.actions .btn { min-width: 7.2rem; }
.felt-page .btn-ghost { border-color: rgba(243,234,216,.28); color: var(--cream); }

.log {
  max-width: 920px;
  margin: 10px auto 0;
  padding: 0 8px;
  font-size: .84rem;
  color: rgba(243,234,216,.72);
  display: grid;
  gap: 2px;
}
.log li { list-style: none; }
.log { padding-left: 8px; margin-left: 0; }

.overlay {
  position: absolute;
  inset: 10px;
  background: rgba(8, 24, 18, .78);
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  z-index: 3;
}
.overlay h2 { font-family: var(--font-display); font-size: 2rem; margin: 0 0 10px; }
.overlay .code {
  font-family: var(--font-mono);
  font-size: 2rem;
  letter-spacing: .28em;
  margin: 8px 0 16px;
}
.overlay .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suit-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(320px, 100%); }
.suit-pick button {
  font-size: 2.2rem;
  padding: 16px;
  border-radius: 16px;
  border: 0;
  cursor: pointer;
  background: var(--paper);
}
.suit-pick button.red { color: var(--red); }
.suit-pick button.black { color: var(--black); }

.panel.error-panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: 28px;
  max-width: 420px;
  margin: 40px auto;
}

/* Playing cards */
.pcard {
  --card-red: #c41e3a;
  --card-blk: #161616;
  position: relative;
  width: var(--card-w);
  height: calc(var(--card-w) * 1.4);
  border-radius: 8px;
  background:
    linear-gradient(#fff, var(--paper));
  border: 1px solid #d7c8aa;
  box-shadow: 0 6px 14px rgba(0,0,0,.28);
  color: var(--card-blk);
  font-family: var(--font-display);
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.pcard.red { color: var(--card-red); }
.pcard.black { color: var(--card-blk); }
.c-index {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-weight: 700;
}
.c-index b { font-size: .78rem; }
.c-index i { font-style: normal; font-size: .7rem; }
.c-index.tl { top: 4px; left: 5px; }
.c-index.br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.c-face {
  position: absolute;
  inset: 22% 16% 18%;
  display: grid;
  place-items: center;
}
.c-face .pip { font-size: 1.7rem; line-height: 1; }
.c-face .pip.ace { font-size: 2.2rem; }
.c-face .court {
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1;
}
.c-face .court em {
  font-style: normal;
  font-size: 1.45rem;
  font-weight: 700;
}
.c-face .court i { font-style: normal; font-size: 1.1rem; }

.pcard.back {
  cursor: default;
  background:
    repeating-linear-gradient(45deg, #1b4f3a 0 7px, #143c2c 7px 14px);
  border-color: var(--gold-soft);
  box-shadow: inset 0 0 0 4px rgba(20, 60, 44, .5), 0 6px 14px rgba(0,0,0,.28);
}
.pcard.back::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(232, 197, 106, .45);
  border-radius: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #2a1c08;
  color: var(--gold-soft);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 9;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .hero, .games { grid-template-columns: 1fr; }
  .hero-table { min-height: 220px; }
  .top { padding: 10px 12px; }
  .brand-name { font-size: .95rem; }
  .board { min-height: 0; border-width: 8px; }
  .you-hand { gap: 6px; }
}

@media (prefers-reduced-motion: no-preference) {
  .you-hand .pcard { transition: transform .15s ease, box-shadow .15s ease; }
  .btn-last.pulse { animation: pulse 1.6s ease-in-out infinite; }
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 4px rgba(232, 197, 106, .35); }
}

/* Stockpile */
.stock-board {
  grid-template-rows: auto auto auto auto auto;
  min-height: 0;
  gap: 10px;
}
.pile-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.slot {
  display: grid;
  justify-items: center;
  gap: 4px;
}
.slot .tag {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .72;
}
.build-slot, .disc-slot {
  width: var(--ncard-w, 56px);
  height: calc(var(--ncard-w, 56px) * 1.4);
  border-radius: 8px;
  border: 2px dashed rgba(243, 234, 216, .28);
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .14);
  position: relative;
}
.build-slot .need {
  font-family: var(--font-display);
  font-size: 1.35rem;
  opacity: .45;
}
.build-slot.legal, .disc-slot.end-legal {
  border-style: solid;
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 2px rgba(232, 197, 106, .35);
  cursor: pointer;
}
.centre-builds {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.stock-hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.ncard {
  --ncard-w: clamp(50px, 12vw, 72px);
  width: var(--ncard-w);
  height: calc(var(--ncard-w) * 1.4);
  border-radius: 8px;
  background: linear-gradient(#fff, var(--paper));
  border: 1px solid #d7c8aa;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .28);
  color: var(--ink);
  font-family: var(--font-display);
  padding: 0;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.ncard.sm { --ncard-w: clamp(44px, 10vw, 58px); }
.ncard .num {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}
.ncard .sub {
  position: absolute;
  top: 4px;
  left: 5px;
  font-size: .7rem;
  font-weight: 700;
}
.ncard.wild {
  background: linear-gradient(#f7e7b0, #e0b84a);
  color: #3d2112;
  border-color: #c8962a;
}
.ncard.wild .num { font-size: .72rem; letter-spacing: .08em; }
.ncard.selected {
  transform: translateY(-10px);
  box-shadow: 0 0 0 2px #fff, 0 12px 20px rgba(0, 0, 0, .35);
}
.ncard.legal { box-shadow: 0 0 0 2px rgba(232, 197, 106, .7), 0 6px 14px rgba(0, 0, 0, .28); }
.ncard:disabled { cursor: default; }
.count-pip {
  position: absolute;
  right: -6px;
  top: -6px;
  background: var(--gold);
  color: #2a1c08;
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}
.hint {
  text-align: center;
  font-size: .82rem;
  opacity: .75;
  margin: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .ncard { transition: transform .15s ease, box-shadow .15s ease; }
}

.hearts-board { grid-template-rows: auto auto auto auto auto auto; min-height: 0; }
.scoreboard {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  flex-wrap: wrap;
}
.scoreboard .sep { opacity: .45; }
.hearts-opp { min-height: 54px; }
.hearts-opp .pcard.back {
  width: 38px;
  height: 54px;
  margin-left: -22px;
}
.hearts-opp .pcard.back:first-child { margin-left: 0; }
.trick-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}
.trick-slot {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 72px;
}
.trick-slot .tag {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .7;
}
.trick-meta {
  text-align: center;
  font-size: .8rem;
  opacity: .8;
  min-width: 7rem;
}
.pcard.back.ghost { opacity: .22; }
.pcard.qs { box-shadow: 0 0 0 2px rgba(232, 197, 106, .55), 0 6px 14px rgba(0, 0, 0, .28); }
.hearts-board .you-hand { --card-w: clamp(48px, 10.5vw, 70px); }
.score-line { opacity: .9; }

.rummy-board { grid-template-rows: auto auto auto auto auto auto; min-height: 0; }
.rummy-board .you-hand { --card-w: clamp(50px, 11vw, 72px); }
.rummy-centre { padding: 8px 0; }
.pile.clickable { cursor: pointer; }
.pile.clickable:hover .pcard { transform: translateY(-4px); }
.pcard.drawn { box-shadow: 0 0 0 2px var(--gold-soft), 0 8px 16px rgba(0, 0, 0, .3); }

.crib-board { grid-template-rows: auto auto auto auto auto auto; min-height: 0; }
.crib-board .you-hand { --card-w: clamp(52px, 12vw, 76px); }
.pegboard { display: grid; gap: 6px; padding: 4px 8px 8px; }
.lane { display: grid; grid-template-columns: 5.5rem 1fr 2.4rem; gap: 8px; align-items: center; }
.lane-name { font-size: .82rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: rgba(0,0,0,.28); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); border-radius: 999px; }
.lane b { font-family: var(--font-display); text-align: right; }
.crib-centre { display: grid; justify-items: center; gap: 8px; }
.count-pip-big {
  font-family: var(--font-display);
  font-size: 2rem;
  min-width: 3rem;
  text-align: center;
}
.played-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 2rem; }
.played-row .pcard { --card-w: clamp(44px, 9vw, 60px); }
.starter-wrap { display: grid; justify-items: center; gap: 4px; }
.overlay-show { overflow: auto; }
