:root {
  --felt: #0e4a35;
  --felt-light: #16694b;
  --felt-dark: #072619;
  --gold: #e8c46a;
  --gold-deep: #b8913a;
  --ink: #f6f1e4;
  --muted: #a8c4b6;
  --red: #c9233b;
  --card: #fffdf7;
  --card-ink: #17171a;
  --panel: rgba(0, 0, 0, 0.24);
  --line: rgba(255, 255, 255, 0.13);
  --display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 16px/1.5 var(--body);
  background-color: var(--felt);
  background-image: radial-gradient(ellipse 120% 80% at 50% 0%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); }
h2 { font-size: 1.35rem; }
p { margin: 0 0 0.9em; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

.wrap { position: relative; max-width: 480px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px 48px; }
.wrap.wide { max-width: 1040px; }

.brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 4px 0 22px;
  font-family: var(--display); font-weight: 900; font-size: clamp(1rem, 4.2vw, 1.15rem); letter-spacing: 0.04em;
  color: var(--gold); text-decoration: none; text-transform: uppercase;
}
.brand .suits { letter-spacing: 0.15em; color: var(--ink); font-family: var(--body); font-weight: 400; }
.brand .suits b { color: var(--red); font-weight: 400; }
/* The smallest phones: keep the name clear of the corner button. */
@media (max-width: 369px) { .brand .suits { display: none; } }
.game-name { text-align: center; color: var(--muted); margin: -16px 0 22px; font-size: 0.9rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  margin-bottom: 18px;
  backdrop-filter: blur(4px);
}
.panel.center .card, .panel.center .flip { margin-left: auto; margin-right: auto; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px;
  border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #f2d48a, var(--gold));
  color: #251a03; font: 700 1.05rem var(--body);
  text-decoration: none; cursor: pointer;
  box-shadow: 0 2px 0 var(--gold-deep), 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: linear-gradient(180deg, #e2475c, var(--red)); color: #fff; box-shadow: 0 2px 0 #861426, 0 8px 24px rgba(0, 0, 0, 0.25); }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 0.95rem; }
.btn.scan { min-height: 64px; font-size: 1.2rem; gap: 12px; }
.btn .icon { width: 28px; height: 28px; flex: none; }
.btn .btn-label { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.btn .btn-label small { font-size: 0.72rem; font-weight: 600; opacity: 0.7; margin-top: 2px; }

label { display: block; font-weight: 600; margin-bottom: 14px; }
input, select {
  display: block; width: 100%; margin-top: 6px;
  min-height: 50px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3); color: var(--ink);
  font: 1.05rem var(--body);
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.error { color: #ffb4bf; font-weight: 600; }

/* ---------- Cards ---------- */

.card {
  --w: 64px;
  position: relative; flex: none;
  width: var(--w); aspect-ratio: 5 / 7;
  border-radius: calc(var(--w) * 0.09);
  background: var(--card); color: var(--card-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 6px 18px rgba(0, 0, 0, 0.3);
  font-family: var(--display); font-weight: 700;
  user-select: none;
}
.card.red { color: var(--red); }
.card .corner {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  font-size: calc(var(--w) * 0.29); line-height: 1;
}
.card .corner i { font-style: normal; font-family: var(--body); font-size: 0.8em; margin-top: 1px; }
.card .tl { top: 7%; left: 8%; }
.card .br { bottom: 7%; right: 8%; transform: rotate(180deg); }
.card .pip {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--body); font-size: calc(var(--w) * 0.42);
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #a21b30, #6d0f1f);
  border: calc(var(--w) * 0.06) solid var(--card);
}
.card.slot {
  background: transparent; box-shadow: none;
  border: 2px dashed rgba(255, 255, 255, 0.22);
}
.card.best { box-shadow: 0 0 0 3px var(--gold), 0 6px 18px rgba(0, 0, 0, 0.35); }
.card.dim { opacity: 0.55; }
.card.big { --w: 150px; }
.card.mid { --w: 96px; }
.card.mini { --w: 38px; }

.hand { --hw: 56px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hand .card, .panel.center .hand .card { --w: var(--hw); margin: 0; }
.hand.two-rows { max-width: calc(4 * var(--hw) + 3 * 8px); margin-inline: auto; } /* 7 cards sit as 4 + 3 */
@media (min-width: 420px) { .hand { --hw: 62px; } }

.flip { width: 150px; aspect-ratio: 5 / 7; perspective: 900px; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1); transform-style: preserve-3d; }
.flip .card { --w: 150px; position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip .flip-front { transform: rotateY(180deg); }
.flip.flipped .flip-inner { transform: rotateY(180deg); }

.headline { font-family: var(--display); font-size: 1.5rem; color: var(--gold); margin: 18px 0 4px; }
.rank {
  display: inline-block; margin: 0 0 16px; padding: 4px 14px; border-radius: 999px;
  background: rgba(232, 196, 106, 0.16); color: var(--gold); font-weight: 700; font-size: 1.05rem;
}
.rank small { font-size: 0.72em; font-weight: 600; opacity: 0.75; margin-left: 1px; }
.bluff { font-family: var(--display); font-size: 1.6rem; line-height: 1.15; color: var(--gold); margin: 0; }
/* Names, big, because learning them is the point: whose card you just took, and yours over your QR code. */
.big-name {
  font: 800 clamp(2.6rem, 13vw, 3.4rem)/1.05 var(--body); letter-spacing: -0.01em;
  color: var(--ink); margin: 0; overflow-wrap: anywhere;
}
.qr-code { width: min(100%, 340px); margin: 0 auto 16px; padding: 18px; border-radius: 18px; background: #fff; }
.qr-code svg { display: block; width: 100%; height: auto; }
.taken-hand:not(:empty) { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--muted); font-weight: 700; }

.badge-row { display: flex; align-items: center; gap: 16px; text-align: left; }
.badge-row .card { --w: 70px; }

.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 8px; }
details.how { margin-top: 18px; text-align: left; }
details.how summary { cursor: pointer; color: var(--gold); font-weight: 600; }

.pill {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(255, 255, 255, 0.12);
}
.pill.live { background: #1f9d63; color: #fff; }
.pill.over { background: var(--gold); color: #251a03; }

/* ---------- Tables & lists ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 8px; }
.table td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mini-hand { display: flex; gap: 4px; flex-wrap: wrap; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 8px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed b { color: var(--gold); font-weight: 600; }

.grid { display: grid; gap: 18px; }
@media (min-width: 820px) { .grid.two { grid-template-columns: 1.6fr 1fr; align-items: start; } }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { flex: 1 1 120px; background: rgba(0, 0, 0, 0.2); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--display); font-size: 1.8rem; color: var(--gold); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.85rem; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { margin: 0; flex: 1 1 120px; }

.loading { text-align: center; color: var(--muted); padding: 40vh 0 0; }

/* ---------- Poker hands ---------- */

.corner-btn {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--gold); font: 700 0.62rem var(--body); letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none;
}
.corner-btn.left { left: 10px; right: auto; }
.corner-btn .icon { width: 40px; height: 40px; padding: 8px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.sheet-open, .sheet-open body { overflow: hidden; }
.sheet {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%) var(--felt);
}
.hand-ranks { list-style: none; margin: 0; padding: 0; }
.hand-ranks li {
  display: grid; grid-template-columns: 1.6em 1fr auto; align-items: center; gap: 10px;
  padding: 10px 8px; border-top: 1px solid var(--line);
}
.hand-ranks li:first-child { border-top: 0; }
.hand-ranks li.mine { background: rgba(232, 196, 106, 0.14); border-radius: 12px; border-top-color: transparent; }
.hand-ranks li.mine + li { border-top-color: transparent; }
.hand-ranks .num { font-family: var(--display); color: var(--gold); font-size: 1.2rem; text-align: center; }
.hand-ranks .what { display: flex; flex-direction: column; line-height: 1.25; }
.hand-ranks .what b { font-size: 0.98rem; }
.hand-ranks .pill { align-self: flex-start; margin: 2px 0; font-size: 0.68rem; padding: 1px 8px; }
.hand-ranks .mini-hand { display: flex; gap: 3px; }
.hand-ranks .card { --w: 31px; }
@media (min-width: 420px) { .hand-ranks .card { --w: 36px; } }
/* Too small for corners and a pip: just a big rank over its suit. */
.hand-ranks .card .pip, .hand-ranks .card .br { display: none; }
.hand-ranks .card .tl { inset: 0; justify-content: center; gap: 1px; font-size: calc(var(--w) * 0.44); }

/* ---------- Scanner ---------- */

.scanner { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #000; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: relative; width: min(72vw, 320px); aspect-ratio: 1;
  border: 3px solid var(--gold); border-radius: 28px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}
.scanner-hint {
  position: absolute; top: max(28px, env(safe-area-inset-top)); left: 16px; right: 16px; margin: 0;
  text-align: center; font-weight: 700; font-size: 1.15rem; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}
.scanner-buttons {
  position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 16px; right: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.scanner-buttons .btn { min-width: 220px; }
.scanner-buttons .btn.secondary { background: rgba(0, 0, 0, 0.55); color: #fff; }

/* ---------- Reading a badge photo ---------- */

.scan-status { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.6); }
.scan-status .panel { width: 100%; max-width: 380px; margin: 0; background: var(--felt-dark); }
.scan-status .status-text { margin: 0; font-weight: 600; font-size: 1.1rem; }

/* ---------- TV ---------- */

body.tv { overflow: hidden; }
.tv-wrap { height: 100vh; padding: 3vh 3vw; display: grid; grid-template-rows: auto 1fr auto; gap: 2.5vh; }
.tv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 2vw; }
.tv-head h1 { font-size: 4.2vh; margin: 0; }
.tv-head .brand { margin: 0; font-size: 2.6vh; }
.tv-body { display: grid; grid-template-columns: 1.7fr 1fr; gap: 2.5vw; min-height: 0; }
.tv .panel { padding: 2.5vh 2vw; margin: 0; overflow: hidden; }
.tv h2 { font-size: 3vh; }
.board { list-style: none; margin: 0; padding: 0; counter-reset: place; }
.board li { display: grid; grid-template-columns: 5vh 1fr auto; align-items: center; gap: 1.5vw; padding: 1.1vh 0; border-top: 1px solid var(--line); font-size: 2.6vh; }
.board li:first-child { border-top: 0; }
.board .place { font-family: var(--display); color: var(--gold); font-size: 3vh; }
.board .who b { display: block; }
.board .who span { color: var(--muted); font-size: 2.1vh; }
.board .count { color: var(--muted); font-size: 2vh; font-variant-numeric: tabular-nums; }
.board .mini-hand { display: flex; gap: 0.4vw; }
.board .mini-hand .card { --w: 4.2vh; }
.tv .feed li { font-size: 2.3vh; padding: 1vh 0; }
.tv-foot { display: flex; justify-content: center; gap: 4vw; color: var(--muted); font-size: 2.3vh; }
.tv-foot b { color: var(--ink); }
.winner { text-align: center; }
.winner .hand .card { --w: 13vh; }
.winner h1 { font-size: 6vh; color: var(--gold); margin: 1vh 0; }
.winner .headline { font-size: 3.4vh; margin-top: 2vh; }
@media (max-width: 820px) {
  body.tv { overflow: auto; }
  .tv-wrap { height: auto; }
  .tv-body { grid-template-columns: 1fr; }
}

/* ---------- Home: a tiny looping chat that opens "How it works" ---------- */

.teaser {
  display: block; margin: 20px 0 0; padding: 14px 14px 12px; border-radius: 16px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); color: var(--ink); text-decoration: none; text-align: left;
}
.teaser-chat { display: flex; flex-direction: column; gap: 8px; }
.teaser .row { display: flex; align-items: flex-end; gap: 7px; transform-origin: bottom left; animation: teaser1 9s ease-out infinite both; }
.teaser .row.right { align-self: flex-end; flex-direction: row-reverse; transform-origin: bottom right; animation-name: teaser2; }
.teaser .row:nth-child(3) { animation-name: teaser3; }
.teaser .face { width: 34px; height: 34px; flex: none; }
.teaser .tb {
  padding: 6px 12px; border-radius: 15px; background: var(--card); color: var(--card-ink);
  font-weight: 600; font-size: 0.9rem; line-height: 1.3; box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.3);
}
.teaser .row .tb { border-bottom-left-radius: 4px; }
.teaser .row.right .tb { background: #f2d48a; color: #251a03; border-radius: 15px 15px 4px 15px; }
.teaser-cta { display: block; margin-top: 12px; text-align: center; color: var(--gold); font-weight: 700; }
@keyframes teaser1 { 0% { opacity: 0; transform: scale(0.5); } 4%, 88% { opacity: 1; transform: none; } 95%, 100% { opacity: 0; } }
@keyframes teaser2 { 0%, 22% { opacity: 0; transform: scale(0.5); } 27%, 88% { opacity: 1; transform: none; } 95%, 100% { opacity: 0; } }
@keyframes teaser3 { 0%, 46% { opacity: 0; transform: scale(0.5); } 51%, 88% { opacity: 1; transform: none; } 95%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .teaser .row { animation: none; } }

/* ---------- Animations ---------- */

@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
.pop { animation: pop 0.35s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .pop, .flip-inner { animation: none; transition: none; }
}
