/* Party Cards: a warm card table. Felt green, walnut and brass; ivory cards. Sizes follow the viewport so the same
   page works on a phone, a tablet, a laptop and a TV across the room. */
:root {
  --felt: #17573f; --felt-deep: #0c3324; --felt-light: #2a7a58;
  --wood: #3a2216; --wood-deep: #1e110b;
  --brass: #d8b765; --brass-deep: #9c7c36; --ivory: #fbf5e6; --ink: #1c2230;
  --text: #f4ecd8; --muted: #bfb39a; --danger: #d95a4a; --ok: #6fcf8f;
  --radius: 14px;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
  --fs: clamp(14px, 1.05vw + 9px, 26px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 10%, #2a1a10 0%, var(--wood-deep) 70%) fixed;
  color: var(--text); font: 400 var(--fs)/1.35 var(--ui);
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; overflow: hidden;
}
#app { height: 100dvh; display: flex; flex-direction: column; }
button, select, input { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid rgba(216, 183, 101, 0.55); border-radius: 999px; padding: 0.55em 1.1em;
  background: linear-gradient(180deg, #34271c, #21170f); color: var(--text); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  min-height: 2.6em; transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
button:hover:not([disabled]) { border-color: var(--brass); }
button:active:not([disabled]) { transform: translateY(1px); }
button[disabled] { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(180deg, #e9cf86, #b8933f); color: #2a1b08; border-color: #f3dc9a; font-weight: 700; }
button.danger { border-color: rgba(217, 90, 74, 0.7); }
button.ghost { background: transparent; box-shadow: none; }
button.small { padding: 0.3em 0.8em; min-height: 2.1em; font-size: 0.88em; }
button.big { font-size: 1.15em; padding: 0.7em 1.8em; }
button.link { background: none; border: none; box-shadow: none; color: var(--brass); text-decoration: underline; text-underline-offset: 3px; }
button:focus-visible, select:focus-visible, input:focus-visible, .card:focus-visible { outline: 3px solid #ffe08a; outline-offset: 3px; }
select, input { background: #1a120c; border: 1px solid rgba(216, 183, 101, 0.5); border-radius: 10px; padding: 0.45em 0.7em; min-height: 2.4em; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0 0 0.4em; color: var(--ivory); }
h1 { font-size: clamp(2rem, 5vw, 4.4rem); letter-spacing: 0.02em; background: linear-gradient(180deg, #fff3cf, #d8b765 60%, #a7853c); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { font-size: 1.4em; } h3 { font-size: 1.05em; color: var(--brass); }
.quiet { color: var(--muted); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(216, 183, 101, 0.25); border-top-color: var(--brass); animation: spin 0.9s linear infinite; margin: 1em auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- home and forms */
.home, .form { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; padding: max(16px, env(safe-area-inset-top)) 16px 24px; text-align: center;
  background: radial-gradient(80% 70% at 50% 45%, var(--felt-light), var(--felt) 45%, var(--felt-deep)); }
.brand .logo svg { width: clamp(90px, 14vw, 180px); height: auto; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45)); }
.tagline { max-width: 34em; margin: 0 auto; color: var(--muted); }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15em), 1fr)); gap: 0.9em; width: min(100%, 64em); }
.mode { border-radius: var(--radius); padding: 1.1em 1.2em; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.8em; text-align: left; min-height: 6em;
  background: linear-gradient(160deg, rgba(14, 50, 36, 0.92), rgba(9, 34, 24, 0.95)); border: 1.5px solid rgba(216, 183, 101, 0.55); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.mode:hover { border-color: var(--brass); background: linear-gradient(160deg, rgba(22, 70, 50, 0.95), rgba(9, 34, 24, 0.95)); }
.mode-icon { grid-row: 1 / span 2; font-size: 2em; align-self: center; }
.mode-title { font-family: var(--serif); font-size: 1.2em; font-weight: 700; color: var(--ivory); }
.mode-hint { color: var(--muted); font-size: 0.85em; }
.home-links { display: flex; gap: 1.5em; }
.field { display: flex; flex-direction: column; gap: 0.4em; align-items: stretch; width: min(100%, 22em); text-align: left; }
.name-row { display: flex; gap: 0.5em; align-items: center; }
.name-input, .code-input { flex: 1; font-size: 1.3em; padding: 0.5em 0.7em; min-width: 0; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; text-align: center; font-family: var(--serif); }
.tag { color: var(--muted); font-family: var(--serif); }
.form.warn p { max-width: 30em; }
.error { color: #ffb2a6; font-weight: 600; }

/* ---------------------------------------------------------------- the table shell */
.shell { flex: 1; display: grid; grid-template-rows: auto 1fr auto; min-height: 0; position: relative;
  background: radial-gradient(85% 75% at 50% 45%, var(--felt-light) 0%, var(--felt) 45%, var(--felt-deep) 100%); }
.shell::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.8 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>"); }
.top { position: relative; display: flex; align-items: center; gap: 0.6em; padding: max(6px, env(safe-area-inset-top)) 10px 6px; background: linear-gradient(180deg, rgba(20, 12, 7, 0.85), rgba(20, 12, 7, 0.55)); border-bottom: 1px solid rgba(216, 183, 101, 0.35); z-index: 300; min-height: 3em; }
.top-left { display: flex; align-items: center; gap: 0.5em; min-width: 0; }
.title { font-family: var(--serif); font-weight: 700; color: var(--ivory); display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.mode-tag { font-family: var(--ui); font-weight: 400; font-size: 0.7em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-mid { flex: 1; display: flex; flex-wrap: wrap; gap: 0.35em; justify-content: center; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 0.5em; }
.icon-btn { padding: 0; width: 2.4em; height: 2.4em; min-height: 0; display: grid; place-items: center; font-size: 1em; }
.mic.on { background: linear-gradient(180deg, #4b8f5f, #275c3a); }
.info-chip { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.15em 0.6em; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(216, 183, 101, 0.35); font-size: 0.82em; white-space: nowrap; }
.info-chip.hot { background: rgba(150, 30, 20, 0.6); border-color: #e7867a; }
.suit-icon svg { display: block; filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff); }
.turn { font-family: var(--serif); font-size: 0.95em; color: var(--muted); white-space: nowrap; }
.turn.mine { color: #ffe08a; font-weight: 700; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { text-shadow: 0 0 12px rgba(255, 224, 138, 0.8); } }
.main { position: relative; min-height: 0; overflow: hidden; }
.status { position: absolute; left: 50%; top: 3.6em; transform: translate(-50%, -12px); opacity: 0; transition: 0.3s; background: rgba(120, 30, 20, 0.92); padding: 0.4em 1em; border-radius: 999px; z-index: 500; pointer-events: none; }
.status.show { opacity: 1; transform: translate(-50%, 0); }
.toast { position: fixed; left: 50%; bottom: 7em; transform: translate(-50%, 20px); opacity: 0; transition: 0.3s; background: rgba(20, 12, 7, 0.94); border: 1px solid var(--brass); padding: 0.5em 1.1em; border-radius: 999px; z-index: 900; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- felt, cards, seats */
.table-wrap { position: absolute; inset: 0; }
.felt { position: absolute; inset: 0; }
.felt::before { content: ''; position: absolute; left: 4%; right: 4%; top: 6%; bottom: 8%; border-radius: 50%; pointer-events: none;
  border: 2px solid rgba(216, 183, 101, 0.22); box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28), 0 0 0 10px rgba(0, 0, 0, 0.06); }
.stage, .plates, .labels { position: absolute; inset: 0; }
.plates, .labels { pointer-events: none; }
.card { position: absolute; left: 0; top: 0; background-size: 100% 100%; border-radius: 7%; will-change: transform;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.22);
  transition: transform 0.44s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.35s, filter 0.2s, box-shadow 0.2s; touch-action: none; }
.card[role=button] { cursor: pointer; }
.card.small { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.card.under { filter: brightness(0.86); }
.card.dim { filter: brightness(0.74) saturate(0.7); }
.card.playable:hover { box-shadow: 0 0 0 2px rgba(255, 224, 138, 0.9), 0 8px 18px rgba(0, 0, 0, 0.35); }
.card.selected { box-shadow: 0 0 0 3px #ffe08a, 0 12px 20px rgba(0, 0, 0, 0.4); }
.card.new { animation: arrive 1.2s ease-out 1; }
@keyframes arrive { 0%, 40% { box-shadow: 0 0 0 3px rgba(130, 220, 160, 0.95), 0 8px 16px rgba(0, 0, 0, 0.3); } }
.card.active { box-shadow: 0 0 0 3px #ffe08a, 0 6px 14px rgba(0, 0, 0, 0.3); }
.card.out-bust, .card.out-lose { filter: brightness(0.7) saturate(0.7); }
.card.dragging { transition: none; z-index: 999 !important; box-shadow: 0 18px 30px rgba(0, 0, 0, 0.5); }
.plate { position: absolute; left: 0; top: 0; padding: 0.25em 0.7em; border-radius: 12px; background: rgba(12, 8, 5, 0.78); border: 1px solid rgba(216, 183, 101, 0.4);
  text-align: center; font-size: 0.82em; max-width: 13em; transition: transform 0.4s, box-shadow 0.3s, border-color 0.3s; z-index: 200; }
.plate.turn { border-color: #ffe08a; box-shadow: 0 0 0 2px rgba(255, 224, 138, 0.5), 0 0 22px rgba(255, 224, 138, 0.45); }
.plate.me { background: rgba(12, 8, 5, 0.6); }
.plate.out { opacity: 0.6; }
.plate.away .plate-name { color: var(--muted); }
.plate-name { font-weight: 700; color: var(--ivory); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate-name .bot { color: var(--brass); font-weight: 400; }
.plate-name .you { font-weight: 400; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 0.25em; justify-content: center; margin-top: 0.15em; }
.badge { font-size: 0.82em; padding: 0 0.45em; border-radius: 999px; background: rgba(255, 255, 255, 0.08); white-space: nowrap; }
.badge.chips { background: rgba(216, 183, 101, 0.22); color: #ffe7a6; }
.badge.lives { color: #ff8f8f; letter-spacing: 0.08em; }
.badge.swim { color: #8fd3ff; }
.badge.role, .badge.flag { background: rgba(216, 183, 101, 0.28); color: #ffe7a6; }
.badge.dealer { background: #f3ead2; color: #2a1b08; font-weight: 700; }
.badge.warn { background: rgba(150, 30, 20, 0.6); }
.badge.quiet { color: var(--muted); }
.timer { position: absolute; right: -0.7em; top: -0.7em; width: 1.9em; height: 1.9em; border-radius: 50%; background: #b8933f; color: #2a1b08; font-weight: 700; display: grid; place-items: center; font-size: 0.85em; }
.zone-label { position: absolute; left: 0; top: 0; font-weight: 700; font-family: var(--serif); color: #ffe7a6; text-shadow: 0 1px 2px #000; display: flex; align-items: center; gap: 0.3em; font-size: 0.9em; }
.zone-label.chips, .zone-label.bet { background: rgba(0, 0, 0, 0.45); padding: 0.1em 0.6em; border-radius: 999px; }
.zone-label.chips { font-size: 1.15em; }
.chip { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: radial-gradient(circle, #f6e2a3 0 30%, #b8933f 31% 55%, #f6e2a3 56% 64%, #8f2a2a 65%); box-shadow: 0 1px 2px #000; }
.caption { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); padding: 0.25em 0.9em; border-radius: 999px; background: rgba(0, 0, 0, 0.4); color: var(--ivory); font-size: 0.85em; opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; max-width: 96%; overflow: hidden; text-overflow: ellipsis; z-index: 150; }
.caption.show { opacity: 1; }

/* ---------------------------------------------------------------- the action bar */
.bar { z-index: 300; padding: 0 8px max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 0.35em; align-items: center; min-height: 0.5em; }
.bar.active { padding-top: 6px; background: linear-gradient(0deg, rgba(20, 12, 7, 0.75), rgba(20, 12, 7, 0)); }
.bar-row { display: flex; flex-wrap: wrap; gap: 0.45em; justify-content: center; align-items: center; }
.bar-hint { color: var(--muted); font-size: 0.82em; }
.bar .bid { min-width: 2.8em; font-family: var(--serif); font-weight: 700; font-size: 1.1em; }
.toggle.on { background: linear-gradient(180deg, #e9cf86, #b8933f); color: #2a1b08; }
.chip-btn { font-family: var(--serif); font-weight: 700; min-width: 3.4em; background: radial-gradient(circle at 50% 40%, #3b2a1c, #1e140c); border-width: 2px; border-style: dashed; }
.bet { display: flex; flex-direction: column; gap: 0.25em; align-items: center; }
.slider { width: min(60vw, 18em); accent-color: var(--brass); }
.bet-quick { display: flex; gap: 0.3em; }
.chooser { position: fixed; left: 50%; bottom: 7.5em; transform: translateX(-50%); z-index: 800; background: rgba(18, 11, 6, 0.96); border: 1.5px solid var(--brass); border-radius: var(--radius); padding: 0.8em 1em; display: flex; flex-direction: column; gap: 0.6em; align-items: center; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); max-width: 96vw; }
.chooser-title { font-family: var(--serif); color: var(--brass); }
.chooser-row { display: flex; gap: 0.6em; flex-wrap: wrap; justify-content: center; }
.choice { border-radius: 14px; padding: 0.4em; min-width: 3.6em; display: flex; flex-direction: column; align-items: center; gap: 0.2em; background: #f8f0dc; color: var(--ink); }
.mini-card svg { width: 3.4em; height: auto; display: block; }
.choice-label { font-size: 0.75em; }

/* ---------------------------------------------------------------- lobby */
.lobby { position: absolute; inset: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(16em, 24em); gap: 1.2em; padding: 1em max(16px, 2vw) 2em; align-content: start; }
.lobby:has(.join.big) { grid-template-columns: minmax(14em, 22em) minmax(0, 1fr) minmax(16em, 24em); }
.lobby-main, .lobby-side { min-width: 0; }
.lobby-side { background: rgba(10, 6, 3, 0.45); border: 1px solid rgba(216, 183, 101, 0.3); border-radius: var(--radius); padding: 1em; display: flex; flex-direction: column; gap: 0.7em; align-self: start; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5em), 1fr)); gap: 0.8em; }
.game-tile { border-radius: var(--radius); padding: 0.8em; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto 1fr; column-gap: 0.7em; text-align: left; align-items: start; background: linear-gradient(160deg, rgba(10, 40, 28, 0.9), rgba(6, 26, 18, 0.92)); min-height: 7.5em; }
.game-tile.chosen { border: 2px solid #ffe08a; box-shadow: 0 0 0 3px rgba(255, 224, 138, 0.25), 0 10px 20px rgba(0, 0, 0, 0.35); background: linear-gradient(160deg, rgba(30, 90, 62, 0.95), rgba(10, 40, 28, 0.95)); }
.game-tile[disabled] { opacity: 0.55; }
.tile-card { grid-row: 1 / span 3; }
.tile-card svg { width: 3.3em; height: auto; display: block; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45)); transform: rotate(-6deg); }
.tile-name { font-family: var(--serif); font-weight: 700; color: var(--ivory); }
.tile-meta { font-size: 0.75em; color: var(--brass); }
.tile-blurb { font-size: 0.78em; color: var(--muted); }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3em; }
.people li { display: flex; align-items: center; gap: 0.45em; flex-wrap: wrap; }
.people li.away { color: var(--muted); }
.people select { min-height: 1.9em; padding: 0.1em 0.4em; font-size: 0.85em; }
.dot { width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--ok); }
.people li.away .dot { background: #777; }
.dot.botdot { background: var(--brass); }
.add-bots { display: flex; gap: 0.4em; flex-wrap: wrap; }
.options { display: flex; flex-direction: column; gap: 0.45em; }
.option { display: flex; justify-content: space-between; align-items: center; gap: 0.7em; font-size: 0.9em; }
.option select { max-width: 55%; }
.option-value { color: var(--brass); }
.deal { align-self: stretch; }
.wait { color: var(--brass); font-family: var(--serif); text-align: center; }

/* ---------------------------------------------------------------- join (screen) */
.join { text-align: center; }
.join.big { background: rgba(10, 6, 3, 0.45); border: 1px solid rgba(216, 183, 101, 0.35); border-radius: var(--radius); padding: 1em; align-self: start; }
.join .qr svg { width: 100%; max-width: 16em; height: auto; border-radius: 12px; display: block; margin: 0 auto; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); }
.join p { margin: 0.3em 0; }
.join .scan { font-family: var(--serif); font-size: 1.2em; color: var(--ivory); }
.join .link { font-weight: 700; word-break: break-all; color: #ffe7a6; }
.join .code { font-family: var(--serif); font-size: 2.6em; letter-spacing: 0.18em; color: #fff3cf; font-weight: 700; }
.join-corner { position: absolute; right: 12px; bottom: 12px; width: clamp(7em, 10vw, 12em); background: rgba(10, 6, 3, 0.6); border-radius: 12px; padding: 0.5em; z-index: 250; font-size: 0.7em; }
.join-corner .qr svg { max-width: 100%; }
.join-corner .code { font-size: 1.8em; }
.join-corner .scan, .join-corner .quiet, .join-corner .link { display: none; }

/* ---------------------------------------------------------------- results and overlays */
.result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 400; width: min(94%, 34em); max-height: 88%; overflow: auto;
  background: linear-gradient(180deg, #fbf3de, #efe2c1); color: var(--ink); border-radius: var(--radius); padding: 1em 1.2em; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6); border: 2px solid var(--brass-deep); animation: pop 0.35s ease-out; }
@keyframes pop { from { transform: translate(-50%, -46%) scale(0.94); opacity: 0; } }
.result h2 { color: #3a2410; text-align: center; }
.result.final h2 { font-size: 1.8em; }
.result .notes { text-align: center; color: #6b4e1f; margin: 0 0 0.5em; }
.result table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
.result td { padding: 0.3em 0.4em; border-bottom: 1px solid rgba(60, 40, 10, 0.15); }
.result tr.me td { background: rgba(216, 183, 101, 0.3); font-weight: 700; }
.result .rank { width: 2em; text-align: center; font-family: var(--serif); font-weight: 700; }
.result .note { color: #6b4e1f; font-size: 0.85em; }
.result .delta, .result .total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result .total { font-weight: 700; }
.result .countdown { text-align: center; color: #6b4e1f; margin: 0.6em 0 0; }
.result-buttons { display: flex; gap: 0.6em; justify-content: center; margin-top: 0.8em; flex-wrap: wrap; }
.result button:not(.primary) { color: var(--text); }
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 850; display: grid; place-items: center; padding: 16px; }
.overlay-box { background: linear-gradient(180deg, #2b1d13, #1a110b); border: 1.5px solid var(--brass); border-radius: var(--radius); padding: 1.2em; width: min(100%, 36em); max-height: 90dvh; overflow: auto; display: flex; flex-direction: column; gap: 0.7em; }
.rules-overlay .overlay-box { width: min(100%, 46em); }
.rules p { margin: 0.35em 0; color: #e8dcc0; }

/* ---------------------------------------------------------------- sizes */
@media (max-width: 760px) {
  .lobby { grid-template-columns: 1fr; }
  .lobby:has(.join.big) { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; row-gap: 4px; }
  .top-mid { order: 3; flex-basis: 100%; }
  .top-mid:empty { display: none; }
  .title { font-size: 0.95em; }
  .plate { font-size: 0.72em; max-width: 9em; padding: 0.15em 0.5em; }
  .chooser { bottom: 9em; }
}
@media (orientation: landscape) and (max-height: 500px) {
  :root { --fs: 13px; }
  .top { min-height: 2.4em; padding-top: 2px; padding-bottom: 2px; }
  .icon-btn { width: 2em; height: 2em; }
  .bar.active { padding-top: 2px; }
  button { min-height: 2.2em; padding: 0.35em 0.9em; }
  .bar { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .bar-hint { display: none; }
}
@media (min-width: 1600px) {
  .plate { font-size: 0.9em; }
  .join .qr svg { max-width: 20em; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .plate { transition: none; }
  .turn.mine { animation: none; }
}
