/* Белот — a felt table at night. One bold element: the embroidered card back.
   Palette: felt green, cream card stock, embroidery red, brass, slate. */
:root {
  --felt: #1f4d3a;
  --felt-deep: #143327;
  --felt-edge: #0e241c;
  --cream: #f6efe2;
  --ink: #1c1a17;
  --red: #b3262e;
  --brass: #c9a24a;
  --slate: #8fb8c9;
  --muted: #a9bfb3;
  --focus: #ffd66b;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, "Segoe UI", Roboto, sans-serif;
  --card-w: clamp(46px, 6.4vw, 92px);
  --gap: clamp(8px, 1.4vw, 18px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt-deep) 70%, var(--felt-edge) 100%) fixed;
  color: var(--cream);
  font: 16px/1.5 var(--sans);
}
a { color: var(--brass); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

h1, .wordmark, .wordmark-small, .score, .summary h2 { font-family: var(--serif); font-weight: normal; }

/* ---- buttons and forms ---- */
.btn {
  font: inherit; cursor: pointer; border-radius: 999px; padding: .5em 1.2em;
  border: 1px solid transparent; text-decoration: none; display: inline-block; text-align: center;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brass); color: var(--ink); font-weight: 600; }
.btn-primary:not(:disabled):hover { background: #d8b25a; }
.btn-quiet { background: transparent; color: var(--cream); border-color: rgba(246,239,226,.35); }
.btn-quiet:not(:disabled):hover { border-color: var(--cream); }
input[type=text], input[type=password], select {
  font: inherit; color: var(--ink); background: var(--cream); border: 0; border-radius: 8px; padding: .5em .75em;
}
label { color: var(--muted); }
.form-error { color: #ffb3a8; min-height: 1.5em; margin: .25em 0; }
.hint { color: var(--muted); font-size: .9rem; margin: .5em 0 0; }
.tag { font-size: .75rem; padding: .05em .5em; border-radius: 999px; background: rgba(246,239,226,.15); }
.tag-muted { color: #ffb3a8; }

/* ---- home ---- */
.home { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1rem; padding: 2rem 16px; text-align: center; }
.wordmark { font-size: clamp(4rem, 14vw, 9rem); line-height: 1; margin: 0; letter-spacing: .02em; color: var(--cream); }
.tagline { margin: 0 0 1rem; color: var(--muted); font-family: var(--serif); font-size: 1.2rem; }
.name-form { display: grid; gap: .5rem; width: min(320px, 100%); text-align: left; }
.home-links { margin-top: 1rem; }
.notice { max-width: 36ch; }
.rooms-summary { margin: 0; }
.btn-play { font-size: 1.4rem; padding: .7em 2.8em; border-radius: 999px; }
.play-modes { display: grid; gap: .75rem; width: min(360px, 100%); }
.online-count { margin: 0; font-size: .9rem; color: #9be39b; }
.online-count:not(:empty)::before { content: ''; display: inline-block; width: .55em; height: .55em; border-radius: 50%; background: #9be39b; margin-right: .45em; vertical-align: middle; box-shadow: 0 0 6px #9be39b; }
.play-modes .btn-play { width: 100%; font-size: 1.2rem; }
.play-modes .hint { margin: -.4rem 0 0; }
.home-links { display: flex; gap: 1.25rem; justify-content: center; }

/* Queue page: waiting to be matched. */
.queue-title { font-family: var(--serif); font-weight: normal; margin: 0; font-size: clamp(1.6rem, 4vw, 2.4rem); }
.queue-card { display: grid; justify-items: center; gap: .35rem; padding: 1.5rem 2rem; border-radius: 18px; background: rgba(0,0,0,.28); min-width: min(320px, 100%); }
.queue-status { margin: 0; font-weight: 700; color: var(--focus); }
.queue-timer { margin: 0; font-size: 2.6rem; font-variant-numeric: tabular-nums; color: var(--cream); }
.queue-card .hint { margin: 0; }
.queue-spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(246,239,226,.2); border-top-color: var(--focus); animation: spin 1s linear infinite; }
.queue-page.found .queue-spinner { animation: none; border-color: var(--focus); }
.queue-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-spinner { animation: none; } }

/* End of a queued match. */
.queued-end { display: grid; gap: .5rem; justify-items: center; }
.rating-change { margin: 0; font-weight: 800; font-size: 1.2rem; }
.rating-change.up { color: #9be39b; }
.rating-change.down { color: #ffb3a8; }
.rating-change.same { color: var(--cream); }
.tag-mode { background: var(--focus); color: var(--ink); font-weight: 700; }

/* Класиране. */
.board { width: 100%; }
.board .me-row th, .board .me-row td { color: var(--focus); font-weight: 700; }
.board .me-outside th, .board .me-outside td { border-top: 2px dashed rgba(246,239,226,.3); }

/* Welcome page: log in, register or play as a guest. */
.welcome-card { width: min(380px, 100%); display: grid; gap: 1rem; padding: 1.25rem; border-radius: 18px; background: rgba(0,0,0,.28); }
.welcome-tabs { justify-content: center; }
.welcome-panel .name-form { width: 100%; }
.name-form .btn-quiet { justify-self: stretch; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Lobby page: every open table as a list. */
.rooms-page { padding: 1.25rem 16px 2rem; display: grid; gap: 1rem; align-content: start; }
.rooms-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.rooms-head h1 { margin: 0; flex: 1; font-family: var(--serif); font-weight: normal; font-size: 1.6rem; }
.rooms-page .account-bar { justify-content: flex-start; }
.view-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.view-tab { font: inherit; font-size: .9rem; color: var(--cream); background: transparent; cursor: pointer;
  border: 1px solid rgba(246,239,226,.35); border-radius: 999px; padding: .35em 1em; }
.view-tab[aria-pressed="true"] { background: var(--cream); color: var(--ink); font-weight: 700; border-color: var(--cream); }
.room-table { width: 100%; border-collapse: separate; border-spacing: 0 .4rem; }
.room-table th { text-align: left; font-weight: normal; color: var(--muted); font-size: .85rem; padding: 0 1rem; }
.room-table td { background: rgba(0,0,0,.25); padding: .7rem 1rem; vertical-align: middle; }
.room-table td:first-child { border-radius: 12px 0 0 12px; }
.room-table td:last-child { border-radius: 0 12px 12px 0; text-align: right; width: 1%; white-space: nowrap; }
.room-name strong, .room-name .hint, .room-players .hint { display: block; margin: .15rem 0 0; }
.seat-dots .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--cream); margin-right: 4px; vertical-align: middle; }
.seat-dots .dot-free { background: transparent; border: 2px dashed var(--focus); box-sizing: border-box; }
.room-status { white-space: nowrap; }
.room-status.is-open { color: var(--focus); }
.room-status.is-playing { color: #9be39b; }
.btn-off { opacity: .55; cursor: default; }
.tag-private { display: inline-flex; align-items: center; gap: .3em; margin-top: .25rem; width: fit-content; }
.lock-icon { width: .85em; height: .85em; fill: currentColor; }
.tag-pin { background: var(--focus); color: var(--ink); }
.pin-field { display: grid; gap: .4rem; }
.pin-field[hidden] { display: none; }
.pin-input { font-size: 1.4rem; letter-spacing: .4em; text-align: center; width: 7.5em; justify-self: start; }
.rooms-empty { display: grid; justify-items: center; gap: .75rem; padding: 2.5rem 1rem; text-align: center; background: rgba(0,0,0,.2); border-radius: 16px; }
.rooms-empty p { margin: 0; }

/* "Създай маса" window. */
.create-dialog { border: 0; border-radius: 18px; padding: 1.25rem 1.5rem 1.5rem; background: var(--felt-deep); color: var(--cream);
  box-shadow: 0 20px 60px rgba(0,0,0,.6); width: min(360px, calc(100vw - 32px)); box-sizing: border-box; }
.create-dialog::backdrop { background: rgba(0,0,0,.55); }
.create-dialog h2 { margin: 0 0 .75rem; font-family: var(--serif); font-weight: normal; }
.create-dialog .name-form { width: 100%; }

/* Phones: each table becomes a small card. */
@media (max-width: 600px) {
  .room-table thead { display: none; }
  .room-table, .room-table tbody, .room-table tr { display: block; }
  .room-table tr { display: grid; grid-template-columns: 1fr auto; gap: .35rem .75rem; background: rgba(0,0,0,.25);
    border-radius: 12px; padding: .75rem 1rem; margin-bottom: .5rem; }
  .room-table td { display: block; background: none; padding: 0; border-radius: 0 !important; }
  .room-table td.room-action { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
  .room-table td.room-status { grid-column: 1; }
  .room-table td.room-players { grid-column: 1; }
}

.visibility { border: 0; padding: 0; margin: .25rem 0; display: flex; flex-direction: column; gap: .2rem; }
.visibility legend { color: var(--muted); padding: 0; }
.visibility label { color: var(--cream); }
.account-bar { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; justify-content: center; }
.link-btn { all: unset; cursor: pointer; color: var(--brass); text-decoration: underline; }
.link-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.stats td.won { color: #9be39b; } .stats td.lost { color: #ffb3a8; }
.rejoin { display: grid; gap: .5rem; justify-items: center; padding: .9rem 1.2rem; border-radius: 16px;
  background: rgba(0,0,0,.3); border: 2px solid var(--focus); margin-bottom: .5rem; }
.rejoin-title { margin: 0; color: var(--focus); font-weight: 700; }

/* ---- banners ---- */
.banner { margin: 0; padding: .5rem 16px; text-align: center; background: rgba(0,0,0,.35); color: var(--cream); }
.banner-error { background: rgba(179,38,46,.85); }

/* ---- lobby ---- */
.lobby, .stats { padding: 16px var(--gap) 32px; display: grid; gap: var(--gap); }
.lobby-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); justify-content: space-between; }
.wordmark-small { font-size: 2rem; color: var(--cream); text-decoration: none; }
.link-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.link-bar input { width: min(28ch, 60vw); }
.copy-status { color: var(--muted); min-width: 6ch; }

.felt {
  position: relative; border-radius: 48px;
  background: radial-gradient(ellipse at center, #26604a 0%, var(--felt) 60%, var(--felt-deep) 100%);
  box-shadow: inset 0 0 0 10px #5b3b22, inset 0 0 0 13px #3d2716, inset 0 0 60px rgba(0,0,0,.5);
}
.lobby-felt {
  display: grid; gap: var(--gap); padding: clamp(20px, 4vw, 48px);
  grid-template-areas: ". top ." "left center right" ". bottom .";
  grid-template-columns: 1fr minmax(0, 1.2fr) 1fr; align-items: center; min-height: 420px;
}
.seat-tile {
  display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
  padding: 1rem; border-radius: 16px; background: rgba(0,0,0,.22); border-top: 3px solid var(--brass);
}
.seat-tile.team-b { border-top-color: var(--slate); }
.seat-tile.is-me { background: rgba(0,0,0,.38); }
.seat-team { font-size: .8rem; color: var(--muted); }
.team-a .seat-team { color: var(--brass); }
.team-b .seat-team { color: var(--slate); }
.seat-name { font-family: var(--serif); font-size: 1.35rem; overflow-wrap: anywhere; }
.seat-empty { color: var(--muted); font-style: italic; }
.bot-add { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.pos-top { grid-area: top; } .pos-bottom { grid-area: bottom; } .pos-left { grid-area: left; } .pos-right { grid-area: right; }
.felt-center { grid-area: center; display: flex; flex-direction: column; align-items: center; gap: .75rem; text-align: center; }

.options { border: 1px solid rgba(246,239,226,.2); border-radius: 16px; padding: 1rem 1.25rem; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem 1.5rem; }
.options legend { font-family: var(--serif); font-size: 1.2rem; padding: 0 .5rem; color: var(--cream); }
.option { display: flex; gap: .5rem; align-items: flex-start; }
.option label { color: var(--cream); }
.options:disabled .option label { color: var(--muted); }
.options .hint { grid-column: 1 / -1; }

/* ---- stats ---- */
.stats h1 { margin: 0; font-size: 2.4rem; }
.table-scroll { overflow-x: auto; }
.stats table { border-collapse: collapse; width: 100%; min-width: 560px; }
.stats th, .stats td { padding: .5rem .75rem; text-align: right; border-bottom: 1px solid rgba(246,239,226,.15); }
.stats th:first-child { text-align: left; }
.stats thead th { color: var(--muted); font-weight: normal; }

/* ---- cards ---- */
.card { width: var(--card-w); aspect-ratio: 5 / 7; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
.card svg { width: 100%; height: 100%; display: block; }
.hand { display: flex; justify-content: center; flex-wrap: nowrap; padding: 0 16px; }
.hand .card-btn { margin-left: calc(var(--card-w) * -0.28); }
.hand .card-btn:first-child { margin-left: 0; }
.card-btn { all: unset; cursor: pointer; border-radius: 8px; transition: transform .12s ease; }
.card-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.card-btn.legal:hover, .card-btn.legal:focus-visible { transform: translateY(-14px); }
.card-btn.dim { cursor: default; filter: brightness(.55); }
.card-btn:disabled { cursor: default; }
.backs { display: flex; }
.backs .card { --card-w: clamp(26px, 3.2vw, 48px); margin-left: calc(var(--card-w) * -0.55); }
.backs .card:first-child { margin-left: 0; }

/* ---- table ---- */
.table-wrap { padding: 8px var(--gap) 16px; display: grid; gap: var(--gap); min-height: calc(100vh - 8px); grid-template-rows: auto 1fr auto; }
.table-top { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; justify-content: space-between; }
.score { display: flex; gap: 1.25rem; align-items: baseline; font-size: 1.15rem; }
.score .team-a { color: var(--brass); } .score .team-b { color: var(--slate); }
.score strong { font-size: 1.7rem; font-weight: normal; }
.contract-badge { font-family: var(--serif); font-size: 1.1rem; padding: .2rem .9rem; border-radius: 999px; background: rgba(0,0,0,.3); }
.contract-badge .mod { color: var(--red); margin-left: .4em; font-weight: 600; }
.table-felt { display: grid; padding: clamp(16px, 3vw, 40px); gap: var(--gap);
  grid-template-areas: ". top ." "left center right"; grid-template-columns: minmax(70px, 1fr) minmax(0, 2fr) minmax(70px, 1fr);
  grid-template-rows: auto 1fr; align-items: center; }
.player { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; }
.player-name { font-family: var(--serif); font-size: 1.1rem; overflow-wrap: anywhere; }
.player.turn .player-name { color: var(--focus); }
/* Whose turn: the active seat glows; the top bar names them. */
.player, .me { border-radius: 18px; padding: .4rem .6rem; transition: box-shadow .25s ease, background-color .25s ease; }
.player.turn, .me.turn { background: rgba(255,214,107,.08); box-shadow: 0 0 0 2px var(--focus), 0 0 22px rgba(255,214,107,.35); animation: turn-glow 1.6s ease-in-out infinite; }
@keyframes turn-glow { 50% { box-shadow: 0 0 0 2px var(--focus), 0 0 8px rgba(255,214,107,.15); } }
.turn-tag { font-size: .75rem; color: var(--ink); background: var(--focus); padding: 0 .55em; border-radius: 999px; }
.turn-line { font-family: var(--serif); font-size: 1.05rem; padding: .2rem .9rem; border-radius: 999px; background: rgba(0,0,0,.3); }
.turn-line.mine { background: var(--focus); color: var(--ink); }
.me .player-name.turn { color: var(--focus); }
/* Announcing with your card: toggle chips above the hand. */
.say-panel { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; justify-content: center; }
.say-hint { color: var(--cream); font-weight: 600; }
.say-chip { font: inherit; font-weight: 700; cursor: pointer; padding: .3rem .9rem; border-radius: 999px;
  background: rgba(0,0,0,.35); color: var(--cream); border: 2px dashed var(--focus); }
.say-chip.on { background: var(--focus); color: var(--ink); border-style: solid; box-shadow: 0 0 12px rgba(255,214,107,.6); }
.say-chip.red:not(.on) { border-color: #ff8a80; }
.btn-claim { background: var(--focus); box-shadow: 0 0 14px rgba(255,214,107,.6); }
.player.team-a .player-name::before, .player.team-b .player-name::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: .4em; vertical-align: middle; }
.player.team-a .player-name::before { background: var(--brass); }
.player.team-b .player-name::before { background: var(--slate); }
.player .tags { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; }
/* What a player said (bid or announcement): a bright card-stock label. */
.speech { font-size: 1rem; font-weight: 700; color: var(--ink); background: var(--cream); padding: .15rem .75rem;
  border-radius: 999px; border: 1px solid #cbbfa8; box-shadow: 0 2px 6px rgba(0,0,0,.45); line-height: 1.35; white-space: nowrap; }
.speech .suit-red { color: var(--red); }
.speech .suit-black { color: var(--ink); }
/* The newest bid or announcement: pops in large and gold, glows, then settles
   into the usual chip (2.6 s; table.js keeps it going across re-draws). */
.speech.fresh { position: relative; z-index: 3; animation: speech-pop 2.6s ease-out both; }
@keyframes speech-pop {
  0% { transform: scale(.4); opacity: 0; background: var(--focus); }
  8% { transform: scale(1.5); opacity: 1; background: var(--focus); box-shadow: 0 0 0 6px rgba(255,214,107,.55), 0 0 24px rgba(255,214,107,.85); }
  16% { transform: scale(1.35); }
  72% { transform: scale(1.35); background: var(--focus); box-shadow: 0 0 0 3px rgba(255,214,107,.45), 0 0 16px rgba(255,214,107,.6); }
  100% { transform: none; background: var(--cream); box-shadow: 0 2px 6px rgba(0,0,0,.45); }
}
@media (prefers-reduced-motion: reduce) { .speech.fresh { background: var(--focus); box-shadow: 0 0 0 3px rgba(255,214,107,.5); } }

/* The game being played: a sign in the felt's corner and a faint suit symbol
   behind the cards. */
.table-felt { position: relative; }
.contract-emblem { position: absolute; top: clamp(20px, 2.8vw, 32px); left: clamp(20px, 2.8vw, 34px); z-index: 1;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: .4rem .8rem; border-radius: 14px;
  background: var(--cream); color: var(--ink); box-shadow: 0 3px 10px rgba(0,0,0,.45); max-width: 46%; }
.contract-emblem .emblem-game { font-family: var(--serif); font-size: clamp(1.2rem, 2.4vw, 1.7rem); font-weight: 700; line-height: 1.1; display: flex; align-items: center; gap: .3em; }
.contract-emblem .suit-red { color: var(--red); }
.contract-emblem .suit-black { color: var(--ink); }
.contract-emblem .emblem-mod { font-size: .8em; color: var(--cream); background: var(--red); border-radius: 999px; padding: 0 .45em; }
.contract-emblem .emblem-by { font-size: .8rem; color: #5b554b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.contract-watermark { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 0; pointer-events: none;
  font-size: calc(var(--tc, 80px) * 3.4); line-height: 1; opacity: .13; user-select: none; }
.contract-watermark.suit-red { color: #ff6b63; } .contract-watermark.suit-black { color: #0b1a14; opacity: .3; }
.trick-slot { z-index: 1; }
/* Trick cards are placed from the centre of the table (so they can gather
   into one pile): --px/--py is each seat's offset, --tc the trick card width. */
.trick-area { grid-area: center; position: relative; --tc: clamp(52px, 7vw, 100px); --spread: 1.45;
  min-height: calc(var(--tc) * 4.2); display: grid; place-items: center; }
.trick-slot { position: absolute; left: 50%; top: 50%; display: flex; flex-direction: column; align-items: center; gap: 2px;
  --px: 0px; --py: 0px; transform: translate(-50%, -50%) translate(var(--px), var(--py)); }
.trick-slot.at-top { --py: calc(var(--tc) * -1.2); }
.trick-slot.at-bottom { --py: calc(var(--tc) * 1.2); }
.trick-slot.at-left { --px: calc(var(--tc) * var(--spread) * -1); }
.trick-slot.at-right { --px: calc(var(--tc) * var(--spread)); }
.trick-slot .card, .peek-card .card { --card-w: var(--tc); }
.peek-card .card { --card-w: clamp(52px, 7vw, 100px); }

/* Collecting a won trick: gather into a slightly fanned pile, then fly to
   the winner's seat, shrinking and fading. */
.trick-area.win-bottom { --wx: 0px; --wy: calc(var(--tc) * 3.4); }
.trick-area.win-top { --wx: 0px; --wy: calc(var(--tc) * -3.4); }
.trick-area.win-left { --wx: calc(var(--tc) * -4.2); --wy: 0px; }
.trick-area.win-right { --wx: calc(var(--tc) * 4.2); --wy: 0px; }
.trick-slot[data-order="0"] { --rot: -6deg; } .trick-slot[data-order="1"] { --rot: 3deg; }
.trick-slot[data-order="2"] { --rot: -2deg; } .trick-slot[data-order="3"] { --rot: 6deg; }
.trick-slot.collecting { animation: collect-trick 600ms cubic-bezier(.4, 0, .2, 1) forwards; }
.trick-slot.collecting .slot-name, .trick-slot.collecting .slot-win { visibility: hidden; }
.trick-slot.collecting .card { filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
@keyframes collect-trick {
  0% { transform: translate(-50%, -50%) translate(var(--px), var(--py)); opacity: 1; }
  40% { transform: translate(-50%, -50%) translate(0px, 0px) rotate(var(--rot, 0deg)); opacity: 1; }
  82% { transform: translate(-50%, -50%) translate(calc(var(--wx) * .7), calc(var(--wy) * .7)) rotate(var(--rot, 0deg)) scale(.55); opacity: .95; }
  100% { transform: translate(-50%, -50%) translate(var(--wx), var(--wy)) rotate(var(--rot, 0deg)) scale(.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .trick-slot.collecting { animation: none; opacity: 0; } }

/* "Хвърли картите": every hand face up, the thrower's glowing. */
.revealed { display: flex; justify-content: center; align-items: flex-end; padding-top: 10px; }
.revealed .card { animation: reveal-in .35s ease-out both; }
.revealed .card + .card { margin-left: calc(var(--card-w) * -0.22); }
.player .revealed .card { --card-w: clamp(30px, 3.8vw, 56px); }
.revealed.other .card { opacity: .5; filter: grayscale(.45) drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
.revealed.thrower .card { transform: translateY(-6px);
  filter: drop-shadow(0 0 2px #ffd66b) drop-shadow(0 0 12px rgba(255,214,107,.9)); }
.revealed.claim-out .card { animation: claim-out .6s ease-in forwards; }
@keyframes reveal-in { from { opacity: 0; transform: rotateY(90deg); } }
@keyframes claim-out { to { opacity: 0; transform: translateY(-40px) scale(.6); } }
.is-thrower { color: var(--focus); text-shadow: 0 0 12px rgba(255,214,107,.8); }
.player.is-thrower { border-radius: 14px; box-shadow: 0 0 0 2px var(--focus), 0 0 28px rgba(255,214,107,.35); background: rgba(255,214,107,.1); }
.claim-banner { background: var(--focus); color: var(--ink); font-weight: 800; font-size: clamp(1rem, 2.2vw, 1.5rem);
  padding: .45em 1.2em; border-radius: 999px; box-shadow: 0 0 30px rgba(255,214,107,.6); white-space: nowrap; z-index: 2;
  animation: banner-in .4s ease-out both; }
@keyframes banner-in { from { opacity: 0; transform: scale(.7); } }
@media (max-width: 720px) { .claim-banner { font-size: .85rem; white-space: normal; max-width: 46vw; text-align: center; padding: .4em .9em; } }
@media (prefers-reduced-motion: reduce) { .revealed .card, .claim-banner { animation: none; } .revealed.claim-out .card { animation: none; opacity: 0; } }
.slot-name { font-size: .78rem; color: var(--cream); background: rgba(0,0,0,.45); padding: 0 .5em; border-radius: 999px; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-win { font-size: .72rem; font-weight: 700; color: var(--ink); background: var(--focus); padding: 0 .5em; border-radius: 999px; }
.trick-done .trick-slot:not(.winner) .card { filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)) brightness(.8); }
.trick-slot.winner .card, .peek-card.winner .card { filter: drop-shadow(0 0 10px rgba(255,214,107,.9)); }
.peek-cards { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.peek-card { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.contract-badge { font-size: 1.15rem; display: inline-flex; align-items: baseline; gap: .35em; flex-wrap: wrap; }
.contract-badge .badge-label { color: var(--muted); font-size: .95rem; }
.contract-badge strong { font-weight: normal; font-size: 1.3rem; }
.contract-badge .badge-by { color: var(--muted); font-size: .9rem; }
.center-panel { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center;
  background: rgba(14,36,28,.88); border-radius: 18px; padding: 1rem 1.25rem; max-width: min(520px, 92vw); }
.bid-grid { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.bid-grid .btn { min-width: 6.5em; }
/* Suit symbols coloured like the cards. On dark felt the red is lightened so
   it stays readable; on cream (card stock) it is the card red. */
.suit-symbol { font-size: 1.15em; line-height: 1; }
.suit-red { color: #ff7a72; }
.suit-black { color: var(--cream); }
.btn-suit { background: var(--cream); color: var(--ink); font-weight: 600; border-color: #cbbfa8; }
.btn-suit:not(:disabled):hover { background: #fffaf0; }
.btn-suit .suit-red { color: var(--red); }
.btn-suit .suit-black { color: var(--ink); }
.me { display: grid; gap: .5rem; justify-items: center; }
.me-line { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: center; }

.summary { display: grid; gap: .3rem; }
/* The breakdown and the last-trick view float above the table at any width. */
.table-felt .center-panel.summary, .table-felt .center-panel.peek {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 10;
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
}
.summary h2 { margin: 0 0 .3rem; font-size: 1.4rem; }
.summary-row { display: grid; grid-template-columns: 1fr 4.5em 4.5em; gap: .5rem; text-align: right; }
.summary-row span:first-child { text-align: left; color: var(--muted); }
.summary-row.head span { color: var(--muted); font-size: .85rem; }
.summary-row.total span { font-family: var(--serif); font-size: 1.3rem; color: var(--cream); }
.summary .note { color: var(--focus); margin: .3rem 0; }
.combo-cards { display: flex; gap: .25rem; justify-content: center; flex-wrap: wrap; }
.combo-cards .card { --card-w: 34px; }

.settings { position: relative; }
.settings-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--felt-edge); border-radius: 14px; padding: .9rem 1rem; display: grid; gap: .5rem; min-width: 250px; }
.settings-panel .option label { color: var(--cream); }

/* ---- phones ---- */
@media (max-width: 720px) {
  :root { --card-w: clamp(38px, 11.2vw, 64px); }
  .lobby-felt { grid-template-areas: "top" "left" "right" "bottom" "center"; grid-template-columns: 1fr; border-radius: 28px; }
  .table-felt { grid-template-columns: minmax(56px, 1fr) minmax(0, 2.6fr) minmax(56px, 1fr); padding: 12px; }
  .hand { flex-wrap: wrap; row-gap: 6px; }
  .hand .card-btn { margin-left: -6px; }
  .hand .card-btn:nth-child(5) { margin-left: 0; }
  .player-name { font-size: .95rem; }
  .trick-area { --spread: 1.05; }
  /* On phones the top corner is next to the top player: use the bottom one. */
  .contract-emblem { top: auto; bottom: 20px; left: 20px; }
}

/* Shuffle and dealing: the deck in front of the dealer riffles, then packets
   of cards fly to each player; my cards slide into my hand as they land. */
.deal-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.deal-layer .card { --card-w: clamp(34px, 4.2vw, 60px); }
.deal-deck, .deal-packet { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); display: grid; }
.deck-half { grid-area: 1 / 1; display: grid; }
.deck-half .card, .deal-packet .card { grid-area: 1 / 1; }
.deck-half .card + .card { transform: translate(2px, -2px); }
.deal-deck.shuffling .left-half { animation: riffle-left .45s ease-in-out 2 both; }
.deal-deck.shuffling .right-half { animation: riffle-right .45s ease-in-out 2 both; }
@keyframes riffle-left { 0%, 100% { transform: none; } 40% { transform: translateX(-75%) rotate(-12deg); } 70% { transform: translateX(-12%) rotate(-3deg); } }
@keyframes riffle-right { 0%, 100% { transform: none; } 40% { transform: translateX(75%) rotate(12deg); } 70% { transform: translateX(12%) rotate(3deg); } }
.deal-packet { animation-name: deal-fly; animation-timing-function: cubic-bezier(.3, .7, .4, 1); animation-fill-mode: both; }
.deal-packet .card:nth-child(2) { transform: translate(3px, -2px) rotate(5deg); }
.deal-packet .card:nth-child(3) { transform: translate(6px, -4px) rotate(10deg); }
@keyframes deal-fly {
  from { left: var(--x); top: var(--y); opacity: 1; }
  85% { opacity: 1; }
  to { left: var(--tx); top: var(--ty); opacity: 0; }
}
.card-btn.arrived { animation: card-arrive .35s ease-out both; }
@keyframes card-arrive { from { opacity: 0; transform: translateY(-26px) scale(.8); } }
@media (prefers-reduced-motion: reduce) { .deal-layer { display: none; } .card-btn.arrived { animation: none; } }
