/* THE BLOCK — Rillaz Spades Club. Mobile-first; no hover-only affordances. */
@font-face {
  font-family: "Anton";
  src: url("/fonts/anton-latin-400-normal.woff2") format("woff2");
  font-display: swap;
}
:root {
  --bg: #0a0a0c;
  --bg-2: #121216;
  --panel: rgba(18, 18, 22, 0.78);
  --panel-solid: #17171c;
  --panel-2: #24242c;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.24);
  --text: #f5f4ee;
  --muted: #b8b8c0;
  --lime: #ccff00;
  --lime-ink: #101400;
  --purple: #a88bff;
  --purple-soft: #d3c5ff;
  --amber: #f0b45a;
  --red: #c81e2e;
  --card: #fbf8ef;
  --card-ink: #14141a;
  --danger: #ff7b7b;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --cw: clamp(38px, 11.4vw, 60px); /* card width */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Anton", "Arial Narrow", Impact, var(--font);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); font-family: var(--font); background: var(--bg); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
main { position: relative; z-index: 1; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--lime); color: var(--lime-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }

/* ── the courtyard: decoration only, always behind and never hit-testable ── */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: #08080a; }
.scene * { pointer-events: none; }
.scene img, .scene-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; }
.scene-video { opacity: 0; transition: opacity 0.8s ease; }
.scene-video.on { opacity: 1; }
.scene-scrim { position: absolute; inset: 0; transition: background 0.5s ease; background: linear-gradient(180deg, rgba(8, 8, 10, 0.34) 0%, rgba(8, 8, 10, 0.1) 34%, rgba(8, 8, 10, 0.5) 100%); }
body:has(#screen-lobby:not([hidden])) .scene-scrim { background: rgba(8, 8, 10, 0.62); }
body:has(#screen-table:not([hidden])) .scene-scrim { background: radial-gradient(90% 75% at 50% 50%, rgba(8, 8, 10, 0.5), rgba(8, 8, 10, 0.72)); }
@media (max-aspect-ratio: 4/5) {
  .scene img, .scene-video { object-position: 50% 0; }
}

.screen {
  max-width: 1040px; margin: 0 auto;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l));
}

/* ── controls ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 46px; padding: 10px 16px; position: relative;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: linear-gradient(180deg, #2c2c35, #1f1f26); color: var(--text); font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer; touch-action: manipulation; text-decoration: none; text-align: center;
  transition: transform 0.12s ease, border-color 0.15s ease, filter 0.15s ease;
}
@media (hover: hover) { .btn:not([disabled]):hover { border-color: var(--lime); filter: brightness(1.1); } }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #dcff3d, var(--lime)); color: var(--lime-ink); border-color: var(--lime); box-shadow: 0 6px 22px rgba(204, 255, 0, 0.22); }
.btn.danger { border-color: rgba(255, 123, 123, 0.6); color: var(--danger); }
.btn.big { min-height: 60px; font-size: 1.05rem; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn .sub { font-size: 0.76rem; font-weight: 500; opacity: 0.85; }
.btn.working { opacity: 1; }
.btn.working .lbl::before, .spin {
  content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chip {
  min-height: 44px; padding: 8px 12px; border-radius: 999px;
  background: rgba(14, 14, 18, 0.72); border: 1px solid var(--line-strong); color: var(--text);
  font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; backdrop-filter: blur(8px);
}
.chip[aria-pressed="true"] { border-color: var(--lime); color: var(--lime); }
.link { background: none; border: 0; padding: 10px 2px; color: var(--lime); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 600; }
input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(6, 6, 8, 0.72); color: var(--text); font-size: 1rem;
}
input:focus { border-color: var(--lime); }
input::placeholder { color: #9a9aa4; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; backdrop-filter: blur(14px); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.center { text-align: center; }
.label { margin: 0; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; }

/* ── welcome ──────────────────────────────────────────────── */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.hq-link { color: var(--lime); font-weight: 700; text-decoration: none; padding: 10px 2px; text-shadow: 0 1px 8px #000; }
.welcome { max-width: 1180px; min-height: 100dvh; display: flex; flex-direction: column; }
.welcome-grid { flex: 1; display: grid; gap: 14px; align-content: center; padding: 10px 0; }
.hero { text-align: center; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85); }
.hero-logo { width: min(210px, 56vw); height: auto; filter: drop-shadow(0 4px 22px rgba(0, 0, 0, 0.75)); }
.kicker { margin: 4px 0 0; color: var(--lime); letter-spacing: 0.42em; font-weight: 800; font-size: 0.8rem; }
.hero h1 { margin: 2px 0 4px; font: 400 clamp(2.5rem, 11vw, 5rem)/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.tagline { color: #e6e5dd; margin: 6px auto; max-width: 34ch; }
.entry-card {
  width: 100%; max-width: 470px; margin: 0 auto; padding: 16px; display: grid; gap: 12px;
  background: rgba(13, 13, 16, 0.8); border: 1px solid var(--line); border-top: 2px solid var(--lime);
  border-radius: 18px; box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(1.2);
}
.name-panel label { font-weight: 700; display: block; margin-bottom: 6px; }
.identity { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.identity-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.identity-who > span { display: grid; }
.identity-who .avatar { width: 44px; height: 44px; flex: none; }
.identity-state { font-weight: 800; }
.identity .hint { margin: 0; font-size: 0.78rem; }
.identity .btn { flex: none; }
.actions { display: grid; gap: 10px; }
.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-pair .btn { padding-inline: 8px; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.entry-status { display: grid; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(204, 255, 0, 0.4); background: rgba(204, 255, 0, 0.07); }
.entry-status.failed { border-color: rgba(255, 123, 123, 0.7); background: rgba(255, 123, 123, 0.1); }
.entry-status.failed .spin { display: none; }
.entry-line { display: flex; align-items: center; gap: 2px; font-weight: 700; }
.entry-btns { display: flex; gap: 8px; }
.foot { text-align: center; color: #dedde0; text-shadow: 0 1px 8px #000; }
.free { font-size: 0.8rem; margin: 2px 0 0; }
@media (min-width: 900px) and (min-aspect-ratio: 4/5) {
  .welcome-grid { grid-template-columns: minmax(0, 1fr) 450px; align-items: center; gap: 4vw; }
  .hero { text-align: left; }
  .hero-logo { width: 280px; }
  .tagline { margin-left: 0; font-size: 1.1rem; }
}
/* the crew stays visible at the sides on wide screens: keep the card off them */
@media (min-width: 1200px) {
  .welcome-grid { grid-template-columns: 1fr 450px 1fr; }
  .hero { text-align: center; grid-column: 2; grid-row: 1; }
  .entry-card { grid-column: 2; grid-row: 2; }
  .tagline { margin-inline: auto; }
  .hero-logo { width: 220px; }
  .hero h1 { font-size: 3.4rem; }
}

/* ── lobby ────────────────────────────────────────────────── */
.lobby-title { text-align: center; margin: 12px 0 10px; font: 400 2rem/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; text-shadow: 0 2px 14px #000; }
#lobby-mode { color: var(--lime); }
.invite { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; max-width: 600px; margin: 0 auto; }
.invite .hint { grid-column: 1 / -1; }
.invite-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.code { margin: 2px 0 0; font: 800 1.4rem/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--lime); letter-spacing: 0.04em; }
.teams { display: grid; gap: 12px; margin: 14px auto; max-width: 820px; }
@media (min-width: 640px) { .teams { grid-template-columns: 1fr 1fr; } }
.team { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--panel); backdrop-filter: blur(14px); }
.team h3 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; }
.team.t0 { border-top: 2px solid var(--lime); }
.team.t1 { border-top: 2px solid var(--purple); }
.team.t0 h3 { color: var(--lime); }
.team.t1 h3 { color: var(--purple-soft); }
.lseat { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); margin-bottom: 8px; min-height: 72px; }
.lseat:last-child { margin-bottom: 0; }
.lseat.you { outline: 2px solid var(--lime); }
.lseat .who { min-width: 0; }
.lseat .nm { font-weight: 800; overflow-wrap: anywhere; }
.lseat .meta { font-size: 0.8rem; color: var(--muted); }
.lseat .seat-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.lseat .avatar { width: 56px; height: 56px; }
.avatar { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; background: var(--panel-2); border: 2px solid var(--line-strong); display: block; }
.avatar.holder { border-color: var(--lime); }
.avatar.empty { display: grid; place-items: center; color: var(--muted); font-size: 1.3rem; border-style: dashed; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; vertical-align: middle; margin-left: 4px; white-space: nowrap; }
.tag.bot { background: rgba(168, 139, 255, 0.2); color: var(--purple-soft); border: 1px solid rgba(168, 139, 255, 0.6); }
.tag.host { background: rgba(240, 180, 90, 0.16); color: var(--amber); border: 1px solid rgba(240, 180, 90, 0.5); }
.tag.ready { background: rgba(204, 255, 0, 0.14); color: var(--lime); border: 1px solid rgba(204, 255, 0, 0.5); }
.tag.away { background: rgba(255, 123, 123, 0.14); color: var(--danger); border: 1px solid rgba(255, 123, 123, 0.5); }
.tag.holder { background: var(--lime); color: var(--lime-ink); border: 1px solid var(--lime); }
.status-line { text-align: center; color: var(--amber); min-height: 1.4em; font-weight: 700; text-shadow: 0 1px 8px #000; }
.lobby-actions { display: grid; gap: 10px; max-width: 470px; margin: 0 auto; }

/* ── table ────────────────────────────────────────────────── */
.table-screen {
  max-width: 1240px; min-height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  gap: 6px; padding-top: calc(6px + var(--safe-t)); overflow-x: clip;
}
/* Explicit rows: the banner is often hidden, and the flexible row must stay the table's. */
.scorebar { grid-row: 1; }
.banner { grid-row: 2; }
.table-wrap { grid-row: 3; }
.turnline { grid-row: 4; }
.dock { grid-row: 5; }
.table-foot { grid-row: 6; }
.scorebar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: stretch; min-width: 0; }
.team-score { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; min-width: 0; backdrop-filter: blur(12px); display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; }
.team-score .tn { grid-column: 1; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-score .tn b { color: var(--text); }
.team-score .pts { grid-column: 2; grid-row: 1 / span 2; font: 400 1.9rem/1 var(--display); letter-spacing: 0.02em; }
.team-score .sm { grid-column: 1; display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 0.74rem; color: var(--muted); }
.team-score .sm b { color: var(--text); }
.team-score.t0 { border-left: 3px solid var(--lime); }
.team-score.t1 { border-left: 3px solid var(--purple); }
.team-score.t0 .pts { color: var(--lime); }
.team-score.t1 .pts { color: var(--purple-soft); }
.mid-score { display: grid; place-items: center; align-content: center; text-align: center; font-size: 0.68rem; color: #dcdce2; padding: 0 6px; text-transform: uppercase; letter-spacing: 0.08em; text-shadow: 0 1px 6px #000; }
.mid-score b { color: var(--lime); font: 400 1.2rem/1.1 var(--display); }
.banner { background: rgba(30, 22, 8, 0.86); border: 1px solid rgba(240, 180, 90, 0.5); color: var(--amber); padding: 8px 12px; border-radius: 12px; text-align: center; font-weight: 600; font-size: 0.88rem; }

/* the table: suede top, dark rail, a warm pool of light and a real shadow on the ground */
.table-wrap { position: relative; min-height: 0; display: grid; padding: 4px 2px 14px; }
.table-wrap::after { content: ""; position: absolute; left: 4%; right: 4%; bottom: 2px; height: 26px; border-radius: 50%; background: rgba(0, 0, 0, 0.75); filter: blur(14px); pointer-events: none; }
.felt {
  position: relative; z-index: 1; border-radius: 30px; min-width: 0; min-height: 300px;
  background: url("/art/scene/table-surface.webp") center / 100% 100% no-repeat, #15130f;
  border: 9px solid #17110c;
  box-shadow:
    0 0 0 1px rgba(255, 214, 160, 0.26),
    inset 0 0 0 1px rgba(0, 0, 0, 0.8),
    inset 0 2px 18px rgba(0, 0, 0, 0.85),
    0 3px 0 #2a1c11, 0 7px 0 #150e08, 0 22px 44px rgba(0, 0, 0, 0.72);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: ". top ." "left trick right" ". bottom .";
  padding: 12px; gap: 4px;
}
.felt::before { content: ""; position: absolute; inset: 0; border-radius: 21px; pointer-events: none; background: radial-gradient(60% 55% at 50% 44%, rgba(255, 196, 120, 0.1), transparent 70%); }
.felt::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: min(34%, 240px); aspect-ratio: 2 / 1; transform: translate(-50%, -50%);
  background: url("/brand/rillaz-logo.webp") center / contain no-repeat; opacity: 0.05; pointer-events: none;
}
.seat-slot { min-width: 0; max-width: 100%; position: relative; z-index: 2; }
.pos-top { grid-area: top; justify-self: center; }
.pos-left { grid-area: left; align-self: center; justify-self: start; }
.pos-right { grid-area: right; align-self: center; justify-self: end; }
.pos-bottom { grid-area: bottom; justify-self: center; }
.trick { grid-area: trick; position: relative; min-height: 170px; z-index: 3; }

.pseat { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; max-width: 100%; position: relative; padding: 5px 8px 5px 5px; border-radius: 14px; background: rgba(8, 8, 10, 0.62); border: 1px solid var(--line); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.pseat.turn { border-color: var(--lime); box-shadow: 0 0 22px rgba(204, 255, 0, 0.2); }
.av-wrap { position: relative; width: 48px; height: 48px; flex: none; }
.pseat .avatar { width: 48px; height: 48px; }
.pseat.t0 .avatar:not(.holder) { border-color: rgba(204, 255, 0, 0.6); }
.pseat.t1 .avatar:not(.holder) { border-color: rgba(168, 139, 255, 0.7); }
.plate { min-width: 0; display: grid; gap: 1px; }
.pseat .nm { font-weight: 800; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-tags:empty { display: none; }
.seat-tags .tag { margin-left: 0; margin-right: 3px; }
.pseat .bt { display: flex; gap: 8px; font-size: 0.74rem; color: var(--muted); white-space: nowrap; }
.pseat .bt b { color: var(--text); }
.pseat .count { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.pseat .turnflag { position: absolute; top: -8px; right: 6px; font-size: 0.62rem; font-weight: 900; color: var(--lime-ink); background: var(--lime); border-radius: 999px; padding: 1px 7px; }
.ring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); pointer-events: none; }
.ring circle { fill: none; stroke: var(--lime); stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }

/* trick cards placed by relative seat */
.tcard { position: absolute; left: 50%; top: 50%; --tx: -50%; --ty: -50%; --rot: 0deg; --fx: 0px; --fy: 0px; transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55)); }
.tcard.r0 { --ty: -8%; --fy: 150px; }
.tcard.r1 { --tx: -118%; --rot: -6deg; --fx: -170px; }
.tcard.r2 { --ty: -92%; --fy: -150px; }
.tcard.r3 { --tx: 18%; --rot: 6deg; --fx: 170px; }
.tcard.in { animation: card-in 0.28s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
@keyframes card-in {
  from { opacity: 0; transform: translate(calc(var(--tx) + var(--fx)), calc(var(--ty) + var(--fy))) rotate(calc(var(--rot) * 3)) scale(0.92); }
}
.tcard.win .card { box-shadow: 0 0 0 3px var(--lime), 0 6px 18px rgba(0, 0, 0, 0.5); }
.trick.last .tcard { opacity: 0.6; animation: collect 0.42s ease-in 0.75s forwards; }
.trick.to-r0 { --cx: 0px; --cy: 170px; }
.trick.to-r1 { --cx: -210px; --cy: 0px; }
.trick.to-r2 { --cx: 0px; --cy: -170px; }
.trick.to-r3 { --cx: 210px; --cy: 0px; }
@keyframes collect {
  to { opacity: 0; transform: translate(calc(var(--tx) + var(--cx)), calc(var(--ty) + var(--cy))) rotate(var(--rot)) scale(0.45); }
}
.trick-note { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 0.76rem; color: var(--lime); font-weight: 700; text-shadow: 0 1px 6px #000; }
.trick-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #d3d2cc; font-size: 0.82rem; text-align: center; text-shadow: 0 1px 6px #000; }

/* cards — original design: corner indices + a large centre pip */
.card {
  width: var(--cw); aspect-ratio: 5 / 7; border-radius: calc(var(--cw) * 0.09);
  background: linear-gradient(160deg, #fffdf6, var(--card) 60%, #efe9d9); color: var(--card-ink);
  border: 1px solid #cfc9b6; position: relative; display: block;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 3px 8px rgba(0, 0, 0, 0.5); user-select: none;
}
.card.red { color: var(--red); }
.card .ix { position: absolute; top: 4%; left: 7%; line-height: 0.95; text-align: center; font-weight: 900; font-size: calc(var(--cw) * 0.27); }
.card .ix .s { display: block; font-size: 0.8em; }
.card .ix.br { top: auto; left: auto; bottom: 4%; right: 7%; transform: rotate(180deg); }
.card .pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cw) * 0.55); line-height: 1; }
.card.face .pip { font-size: calc(var(--cw) * 0.36); }
.card.face .pip::before { content: ""; position: absolute; inset: 22% 18%; border-radius: 6px; border: 1.5px solid currentColor; opacity: 0.35; }
.card.spade-ace .pip { font-size: calc(var(--cw) * 0.7); }
.card .brand { position: absolute; bottom: 14%; left: 0; right: 0; text-align: center; font-size: calc(var(--cw) * 0.1); font-weight: 900; letter-spacing: 0.1em; color: #15151a; opacity: 0.55; }
.card.small { --cw: clamp(40px, 11vw, 62px); }

/* hand */
.dock { display: grid; gap: 8px; min-width: 0; max-width: 100%; }
.hand { display: flex; justify-content: center; padding: 18px 4px 4px; min-height: calc(var(--cw) * 1.4 + 22px); --overlap: calc(var(--cw) * -0.46); min-width: 0; max-width: 100%; }
.hand.spectating { min-height: 0; padding: 0; }
.hcard { padding: 0; border: 0; background: none; margin-left: var(--overlap); cursor: pointer; transition: transform 0.14s ease; touch-action: manipulation; position: relative; --lift: 0px; transform: translateY(var(--lift)); }
.hcard:first-child { margin-left: 0; }
.hcard.illegal .card { filter: brightness(0.5) saturate(0.55); }
.hcard.legal .card { box-shadow: 0 0 0 2px rgba(204, 255, 0, 0.8), 0 3px 8px rgba(0, 0, 0, 0.5); }
.hcard.sel { --lift: -18px; z-index: 2; }
.hcard.sel .card { box-shadow: 0 0 0 3px var(--lime), 0 12px 24px rgba(0, 0, 0, 0.65); }
@media (hover: hover) { .hcard:not(.sel):not(.illegal):hover { --lift: -8px; z-index: 1; } }
.hcard:focus-visible { outline: none; z-index: 3; }
.hcard:focus-visible .card { outline: 3px solid var(--amber); outline-offset: 2px; }
@keyframes deal-in {
  from { opacity: 0; transform: translate(calc(var(--mid, 0) * -16px), -180px) rotate(calc(var(--mid, 0) * 5deg)) scale(0.85); }
}
.hand.dealt .hcard { animation: deal-in 0.34s cubic-bezier(0.2, 0.75, 0.3, 1) both; animation-delay: calc(var(--i, 0) * 36ms); }
.play-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.why { margin: 0; color: var(--amber); font-size: 0.88rem; min-height: 1.2em; text-shadow: 0 1px 6px #000; }
.turnline { text-align: center; font-weight: 800; min-height: 1.4em; color: var(--text); text-shadow: 0 1px 8px #000; }
.turnline.mine { color: var(--lime); }

/* bidding */
.bid-panel { background: rgba(14, 14, 18, 0.9); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; max-width: 760px; width: 100%; margin: 0 auto; backdrop-filter: blur(12px); }
.bid-panel h3 { margin: 0; font: 400 1.15rem/1.2 var(--display); letter-spacing: 0.03em; text-transform: uppercase; }
.bid-panel .hint { margin-top: 2px; font-size: 0.8rem; }
.bid-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0; }
.bid-grid button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel-2); font-weight: 800; cursor: pointer; }
.bid-grid button[aria-pressed="true"] { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.bid-grid button.nil { color: var(--amber); }
.bid-grid button.nil[aria-pressed="true"] { background: var(--amber); color: #1b1300; border-color: var(--amber); }
.nil-explain { border: 1px solid rgba(240, 180, 90, 0.55); background: rgba(240, 180, 90, 0.09); border-radius: 12px; padding: 10px; font-size: 0.88rem; margin-bottom: 10px; }
.nil-explain p { margin: 0 0 6px; }
.nil-explain label { display: flex; gap: 8px; align-items: flex-start; font-weight: 700; }
.nil-explain input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--amber); flex: none; }
.bid-confirm { width: 100%; }
.bid-panel .btn.big { min-height: 50px; }

.table-foot { display: flex; align-items: center; gap: 8px; min-width: 0; padding-bottom: var(--safe-b); }
.reactions { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; justify-content: flex-start; }
.reactions button { flex: none; min-height: 40px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(14, 14, 18, 0.74); font-size: 0.78rem; cursor: pointer; }
.bubble { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); background: var(--lime); color: var(--lime-ink); padding: 3px 9px; border-radius: 10px; font-size: 0.72rem; font-weight: 800; white-space: nowrap; z-index: 5; }

/* dialogs */
dialog {
  border: 1px solid var(--line-strong); border-radius: 18px; padding: 0; background: var(--bg-2); color: var(--text);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px - var(--safe-t) - var(--safe-b)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.dlg-body { padding: 18px; display: grid; gap: 12px; }
.dlg-body h2 { margin: 0; font: 400 1.5rem/1.15 var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.dlg-body h3 { margin: 6px 0 0; font-size: 1rem; color: var(--lime); }
.dlg-body h3.th1 { color: var(--purple-soft); }
.menu-list { display: grid; gap: 8px; }
.rules ul, .rules ol { padding-left: 1.2em; margin: 4px 0; }
.rules li { margin: 3px 0; }
.ex { background: var(--panel-solid); border-radius: 10px; padding: 8px 10px; font-size: 0.9rem; margin: 6px 0; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.breakdown th, .breakdown td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; }
.breakdown thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.breakdown .tot td { font-weight: 900; border-bottom: 0; }
.pos { color: var(--lime); }
.neg { color: var(--danger); }
.winner-line { font: 400 1.9rem/1.1 var(--display); text-align: center; margin: 4px 0; text-transform: uppercase; }
.final { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.final .team-score { display: block; text-align: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }

/* wallet */
#wallet-body { display: grid; gap: 10px; }
.wallet-id { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.addr { margin: 2px 0; font: 700 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.net { font-size: 0.78rem; font-weight: 700; }
.net.ok { color: var(--lime); }
.net.bad { color: var(--danger); }
.wallet-id-btns, .wallet-list { display: flex; gap: 8px; flex-wrap: wrap; }
.wallet-list .btn { flex: 1 1 150px; }
.wallet-msg { margin: 0; }
.wallet-msg.err { color: var(--danger); font-weight: 600; }
.nft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.nft { position: relative; padding: 0; overflow: hidden; border-radius: 12px; border: 2px solid var(--line-strong); background: var(--panel-2); cursor: pointer; aspect-ratio: 1; min-height: 44px; }
.nft img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nft.on { border-color: var(--lime); box-shadow: 0 0 0 2px var(--lime); }
.nft[disabled] { cursor: progress; }
.nft-id { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.78); font-size: 0.75rem; font-weight: 800; }
.nft .tag { position: absolute; right: 4px; top: 4px; margin: 0; }
.nft-fallback { display: none; position: absolute; inset: 0; place-items: center; padding: 8px; font-size: 0.72rem; color: var(--muted); text-align: center; }
.nft.no-art img { visibility: hidden; }
.nft.no-art .nft-fallback { display: grid; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text);
  padding: 10px 16px; border-radius: 12px; z-index: 100; max-width: calc(100vw - 32px); text-align: center; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.toast.err { border-color: rgba(255, 123, 123, 0.7); }
.noscript { text-align: center; padding: 40px; position: relative; z-index: 2; }

/* larger screens: a bigger table, cards that fan, seats with room to breathe */
@media (min-width: 720px) { .hand { --overlap: calc(var(--cw) * -0.3); } :root { --cw: clamp(56px, 8vw, 74px); } }
@media (min-width: 900px) {
  :root { --cw: 80px; }
  .felt { min-height: 400px; padding: 20px 26px; }
  .trick { min-height: 250px; }
  .av-wrap, .pseat .avatar { width: 62px; height: 62px; }
  .pseat { gap: 10px; padding: 6px 12px 6px 6px; }
  .pseat .nm { font-size: 0.92rem; }
  .pseat .bt { font-size: 0.8rem; }
  .hcard { rotate: calc(var(--mid, 0) * 1.1deg); translate: 0 calc(var(--mid, 0) * var(--mid, 0) * 0.5px); }
  .team-score { padding: 8px 14px; }
  .team-score .pts { font-size: 2.3rem; }
  .team-score .tn { font-size: 0.78rem; }
}
/* laptops: everything including the menu fits without scrolling */
@media (min-width: 900px) and (max-height: 860px) {
  :root { --cw: 68px; }
  .felt { min-height: 300px; padding: 12px 22px; }
  .trick { min-height: 190px; --cw: 62px; }
  .av-wrap, .pseat .avatar { width: 52px; height: 52px; }
  .hand { padding-top: 14px; }
  .btn.big { min-height: 52px; }
}
/* narrow phones: seats stack so names never push the page sideways */
@media (max-width: 560px) {
  .felt { min-height: 0; padding: 7px; border-width: 6px; border-radius: 22px; }
  .felt::before { border-radius: 16px; }
  .pseat { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 2px; padding: 4px; }
  .av-wrap, .pseat .avatar { width: 36px; height: 36px; }
  .pseat .avatar { border-radius: 10px; }
  .pseat .nm { font-size: 0.74rem; max-width: 92px; }
  .pseat .bt { font-size: 0.68rem; justify-content: center; gap: 6px; }
  .pseat .count { font-size: 0.64rem; }
  .pos-top .pseat, .pos-bottom .pseat { grid-template-columns: auto minmax(0, 1fr); text-align: left; justify-items: start; gap: 6px; padding-right: 8px; }
  .pos-top .nm, .pos-bottom .nm { max-width: 130px; }
  .pos-top .bt, .pos-bottom .bt { justify-content: flex-start; }
  .seat-tags .tag { font-size: 0.58rem; padding: 0 5px; }
  .trick { min-height: 150px; }
  .team-score { padding: 5px 8px; }
  .team-score .pts { font-size: 1.5rem; }
  .team-score .tnames { display: none; }
  .team-score .sm { font-size: 0.68rem; gap: 0 6px; }
  .banner { font-size: 0.8rem; padding: 6px 10px; }
  .table-screen { gap: 4px; }
  .hand { padding-top: 16px; }
  .card .brand { display: none; }
  .identity { flex-wrap: wrap; }
  .identity .btn { flex: 1 1 100%; }
  .invite { grid-template-columns: 1fr; }
  .invite-btns { justify-content: flex-start; }
}
/* landscape phones: table and hand share the height, nothing hides */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --cw: 46px; }
  .table-screen { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto; column-gap: 10px; gap: 4px; }
  .scorebar, .banner { grid-column: 1 / -1; }
  .table-wrap { grid-column: 1; grid-row: 3 / span 3; padding: 0 0 6px; }
  .turnline { grid-column: 2; grid-row: 3; align-self: start; font-size: 0.85rem; }
  .dock { grid-column: 2; grid-row: 4; align-self: end; gap: 4px; }
  .table-foot { grid-column: 2; grid-row: 5; }
  .felt { min-height: 0; height: 100%; padding: 5px; border-width: 5px; border-radius: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr); }
  .trick { min-height: 96px; --cw: 36px; }
  .av-wrap, .pseat .avatar { width: 30px; height: 30px; }
  .pseat { grid-template-columns: auto minmax(0, 1fr); gap: 4px; padding: 2px 5px 2px 2px; text-align: left; justify-items: start; }
  .pseat .nm { font-size: 0.68rem; max-width: 74px; }
  .pseat .bt { font-size: 0.62rem; gap: 5px; }
  .pseat .count, .trick-note, .seat-tags .tag.holder { display: none; }
  .hand { padding-top: 12px; min-height: calc(var(--cw) * 1.4 + 14px); --overlap: calc(var(--cw) * -0.55); }
  .team-score { padding: 2px 8px; }
  .team-score .pts { font-size: 1.15rem; }
  .team-score .tn, .team-score .sm { font-size: 0.64rem; }
  .bid-panel { padding: 6px 8px; }
  .bid-panel .hint { display: none; }
  .bid-grid { margin: 4px 0; gap: 3px; }
  .bid-grid button { min-height: 32px; }
  .bid-panel .btn.big, .play-row .btn.big { min-height: 40px; }
  .reactions button, .chip { min-height: 34px; }
  .welcome-grid { grid-template-columns: 1fr 1fr; align-items: start; gap: 16px; }
  .hero-logo { width: 130px; }
  .hero h1 { font-size: 2.2rem; }
  .welcome { min-height: 0; }
}

/* motion */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition: none !important; animation: none !important; }
.reduce-motion .spin, .reduce-motion .btn.working .lbl::before { animation: none !important; border-right-color: currentColor; opacity: 0.6; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .spin, .btn.working .lbl::before { border-right-color: currentColor; opacity: 0.6; }
}

/* ── music ───────────────────────────────────────────────────────────── */
.music-control { display: grid; gap: 8px; }
.music-volume { display: grid; grid-template-columns: auto minmax(0, 1fr) 3.2em; align-items: center; gap: 10px; font-size: 0.85rem; }
.music-slider { width: 100%; min-height: 32px; margin: 0; accent-color: var(--lime); }
.music-value { text-align: right; font-variant-numeric: tabular-nums; }
.music-links { display: flex; flex-wrap: wrap; gap: 6px; }
.music-link { text-decoration: none; display: inline-flex; align-items: center; }
.music-note { margin: 0; font-size: 0.75rem; opacity: 0.8; }

#screen-lobby .music-control { width: 100%; max-width: 520px; margin: 4px auto 0; justify-items: center; }
#screen-lobby .music-volume { width: 100%; }
#screen-lobby .music-links { justify-content: center; }
