/* ============================================================
   Белот Онлайн — "Sofia card salon": deep emerald felt,
   warm brass, ivory cards. Forum (display) + Manrope (UI).
   ============================================================ */
:root {
  --felt-1: #0c3b2e;
  --felt-2: #0a2c22;
  --felt-edge: #06201a;
  --gold: #d9b25f;
  --gold-bright: #f1d695;
  --gold-deep: #9c7a33;
  --ivory: #f6efdd;
  --ivory-dim: #e7dcc1;
  --ink: #1c1814;
  --red: #b0282e;
  --red-soft: #c8413f;
  --shadow: rgba(0, 0, 0, .45);
  --us: #f1d695;
  --them: #79b6e6;
  --ok: #6fcf97;
  --bad: #e57373;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--ivory);
  background:
    radial-gradient(120% 90% at 50% 0%, #14513c 0%, var(--felt-1) 38%, var(--felt-2) 72%, var(--felt-edge) 100%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* subtle felt grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; height: 100vh; }

.screen { display: none; height: 100vh; }
.screen.active { display: block; }

.btn {
  font-family: 'Manrope', sans-serif;
  font-weight: 700; font-size: 15px;
  border: none; border-radius: 10px;
  padding: 13px 22px; cursor: pointer;
  letter-spacing: .02em; transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  color: #3a2c08; box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.btn-outline { background: transparent; color: var(--gold-bright); border: 1.5px solid var(--gold); }
.btn-outline:hover { background: rgba(217,178,95,.12); }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--ivory-dim); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-mini { padding: 7px 12px; font-size: 12px; border-radius: 8px; background: rgba(0,0,0,.25); color: var(--gold-bright); border: 1px solid rgba(217,178,95,.4); }
.btn-mini:hover { background: rgba(217,178,95,.15); }
.btn-mini.danger { color: #ffd9d9; border-color: rgba(200,65,63,.6); background: rgba(176,40,46,.22); }
.btn-mini.danger:hover { background: rgba(176,40,46,.4); }

/* ===================== LOBBY ===================== */
#lobby { display: none; flex-direction: column; align-items: stretch; }
#lobby.active { display: flex; }

.lobby-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 12px 0;
  overflow: hidden;
}

.lobby-ad {
  flex: 0 0 auto;
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 6px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: hidden;
}
.lobby-ad .adsbygoogle { width: 100%; }

/* Shrink the lobby card on short viewports so it + the ad always fit
   without ever forcing the page to scroll. */
@media (max-height: 760px) {
  .lobby-wrap { gap: 8px; padding-top: 6px; }
  .lobby-card { padding: 24px 24px 18px; }
  .brand-pips { margin-bottom: 4px; }
  .brand-pips img { height: 20px; }
  .brand h1 { font-size: 38px; }
  .tagline { margin-top: 6px; }
  .lobby-forms { margin-top: 16px; }
  .lobby-actions { margin-top: 14px; }
  .or { margin: 10px 0; }
}

.lobby-card {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, rgba(12,59,46,.85), rgba(6,32,26,.92));
  border: 1px solid rgba(217,178,95,.35);
  border-radius: 20px;
  padding: 40px 36px 30px;
  box-shadow: 0 30px 80px var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
  text-align: center;
}
.brand-pips { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; }
.brand-pips img { height: 25px; width: auto; display: block; background-repeat: no-repeat; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .4)); }
.brand h1 {
  font-family: 'Forum', serif; font-weight: 400;
  font-size: 52px; line-height: 1; letter-spacing: .01em;
  color: var(--ivory);
}
.brand h1 em { color: var(--gold-bright); font-style: normal; }
.tagline { color: var(--ivory-dim); font-size: 14px; margin-top: 10px; opacity: .85; }

.lobby-forms { margin-top: 28px; text-align: left; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin-bottom: 7px; }
input[type=text] {
  width: 100%; font-family: 'Manrope', sans-serif; font-size: 16px;
  padding: 13px 14px; border-radius: 10px;
  background: rgba(0,0,0,.28); color: var(--ivory);
  border: 1.5px solid rgba(217,178,95,.3); outline: none;
  transition: border-color .15s ease, background .15s ease;
}
input[type=text]:focus { border-color: var(--gold); background: rgba(0,0,0,.4); }
input::placeholder { color: rgba(246,239,221,.35); }

.lobby-actions { margin-top: 22px; }
.lobby-actions .btn-gold { width: 100%; }
.or { text-align: center; color: var(--ivory-dim); font-size: 12px; margin: 16px 0; position: relative; opacity: .6; }
.or::before, .or::after { content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: rgba(217,178,95,.25); }
.or::before { left: 0; } .or::after { right: 0; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.join-row .btn { white-space: nowrap; }
.hint { font-size: 12px; color: var(--ivory-dim); opacity: .7; }

/* ===================== WAITING ===================== */
#waiting { display: none; place-items: center; }
#waiting.active { display: grid; }
.waiting-card {
  width: min(460px, 92vw); text-align: center;
  background: linear-gradient(180deg, rgba(12,59,46,.85), rgba(6,32,26,.92));
  border: 1px solid rgba(217,178,95,.35); border-radius: 20px;
  padding: 34px 32px; box-shadow: 0 30px 80px var(--shadow);
}
.waiting-card h2 { font-family: 'Forum', serif; font-weight: 400; font-size: 28px; color: var(--gold-bright); }
.code-box { margin: 16px 0 6px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.code {
  font-family: 'Forum', serif; font-size: 56px; letter-spacing: .18em;
  color: var(--ivory); background: rgba(0,0,0,.3); padding: 6px 22px 10px;
  border-radius: 14px; border: 1px dashed rgba(217,178,95,.5);
}
.share-hint { color: var(--ivory-dim); font-size: 13px; opacity: .8; margin-bottom: 22px; }
.seat-list { display: grid; gap: 10px; margin-bottom: 24px; }
.seat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.06);
}
.seat-row .dot { width: 10px; height: 10px; border-radius: 50%; background: #555; }
.seat-row.filled .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.seat-row .who { flex: 1; min-width: 0; text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-row .team-tag { flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.team-tag.a { background: rgba(241,214,149,.16); color: var(--us); }
.team-tag.b { background: rgba(121,182,230,.16); color: var(--them); }
.seat-row .host-tag { font-size: 11px; color: var(--gold); }
.waiting-foot { display: grid; gap: 12px; }
.waiting-foot .btn-gold { width: 100%; }
.wait-msg { font-size: 13px; color: var(--ivory-dim); opacity: .8; min-height: 1em; }

/* ===================== TABLE ===================== */
#table { display: none; flex-direction: column; }
#table.active { display: flex; }

.hud {
  display: flex; align-items: center;
  padding: 12px 18px; gap: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(0,0,0,0));
  z-index: 5;
}
/* three equal sections so the centre (current game) is dead-centre */
.hud-left   { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 12px; justify-content: flex-start; }
.hud-center { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
/* only this section (burger + its dropdown) sits above the result modal (z 50) */
.hud-right  { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 12px; justify-content: flex-end; position: relative; z-index: 60; }
.scoreboard {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,.32); border: 1px solid rgba(217,178,95,.3);
  border-radius: 14px; padding: 8px 18px;
}
.scoreboard .team { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.scoreboard .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin-bottom: 3px; }
.scoreboard .val { font-family: 'Forum', serif; font-size: 26px; }
.scoreboard .us .val { color: var(--us); }
.scoreboard .them .val { color: var(--them); }
.team-sep { font-size: 20px; opacity: .4; }
.pill { font-size: 12px; padding: 6px 12px; border-radius: 20px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.1); color: var(--ivory-dim); }
.contract-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.contract-by {
  font-size: 13px; font-weight: 700; color: var(--gold-bright); letter-spacing: .04em; white-space: nowrap;
  background: rgba(0,0,0,.32); border: 1px solid rgba(217,178,95,.35);
  padding: 2px 12px; border-radius: 20px; text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.contract-badge {
  font-family: 'Forum', serif; font-size: 20px; letter-spacing: .03em;
  padding: 8px 20px; border-radius: 30px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  color: #3a2c08; box-shadow: 0 6px 18px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 8px;
}
.contract-badge .ct-suit.red { color: var(--red); }
.contract-badge .ct-x { font-size: 13px; background: var(--red); color: #fff; padding: 2px 8px; border-radius: 12px; font-family: 'Manrope'; font-weight: 800; }

.felt {
  position: relative; flex: 1;
  margin: 4px 26px; border-radius: 50% / 26%;
  background:
    radial-gradient(80% 80% at 50% 45%, rgba(28,96,72,.65), rgba(8,40,30,.2) 70%, transparent 80%);
  box-shadow: inset 0 0 90px rgba(0,0,0,.5), inset 0 0 0 2px rgba(217,178,95,.18);
  min-height: 0;
}

/* seats */
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 3; }
.seat-top { top: 8px; left: 50%; transform: translateX(-50%); }
.seat-bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 14px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 14px; top: 50%; transform: translateY(-50%); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #1a6b50, #0a2c22);
  border: 2px solid rgba(217,178,95,.4);
  display: grid; place-items: center; font-family: 'Forum', serif; font-size: 22px; color: var(--gold-bright);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.nameplate {
  font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 20px;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.nameplate .badge { font-size: 10px; padding: 1px 6px; border-radius: 10px; }
.badge.dealer { background: var(--gold); color: #3a2c08; }
.badge.dc { background: var(--bad); color: #fff; }
.seat.team-a .avatar { border-color: var(--us); }
.seat.team-b .avatar { border-color: var(--them); }
.seat.active .avatar { box-shadow: 0 0 0 3px var(--gold-bright), 0 0 22px var(--gold-bright); }
.seat.active .nameplate { background: rgba(217,178,95,.25); }
.mini-hand { display: flex; gap: -8px; height: 26px; }
.mini-hand .cardback { width: 18px; height: 26px; margin-left: -10px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #7a1f23, #7a1f23 3px, #5c1418 3px, #5c1418 6px);
  border: 1px solid rgba(217,178,95,.4); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mini-hand .cardback:first-child { margin-left: 0; }

/* trick */
/* Played cards sit above the seats' mini-hands (z-index 3) but below the player's
   own hand (z-index 4, later in the DOM so it wins the tie). */
.trick-area { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.trick-slot { position: absolute; left: 50%; top: 50%; transition: all .25s ease; }
.trick-slot[data-pos=top] { transform: translate(-50%, -118%); }
.trick-slot[data-pos=bottom] { transform: translate(-50%, 18%); }
.trick-slot[data-pos=left] { transform: translate(-128%, -50%); }
.trick-slot[data-pos=right] { transform: translate(28%, -50%); }

.center-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-family: 'Forum', serif; font-size: 22px; color: var(--gold-bright);
  text-align: center; text-shadow: 0 2px 10px rgba(0,0,0,.6); pointer-events: none;
  opacity: .9; max-width: 60%;
}

/* cards */
.card {
  width: 62px; height: 90px; border-radius: 8px;
  background: linear-gradient(160deg, #fffdf6, var(--ivory) 70%, var(--ivory-dim));
  color: var(--ink); box-shadow: 0 6px 14px rgba(0,0,0,.4), inset 0 0 0 1px rgba(0,0,0,.06);
  position: relative; user-select: none; flex: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 6px 7px;
}
.card.red { color: var(--red); }
.card .corner { font-weight: 800; line-height: .9; font-size: 17px; display: flex; flex-direction: column; align-items: center; width: fit-content; }
.card .corner .pip { font-size: 15px; }
.card .corner.br { align-self: flex-end; transform: rotate(180deg); }
.card .center-pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; opacity: .9; }
.card.sm { width: 46px; height: 66px; padding: 4px 5px; }
.card.sm .corner { font-size: 13px; } .card.sm .corner .pip { font-size: 11px; } .card.sm .center-pip { font-size: 22px; }

/* player's hand */
.hand {
  display: flex; justify-content: center; align-items: flex-end;
  padding: 8px 20px 20px; gap: 0; z-index: 4;
  /* Reserve the FILLED height (card 90 + 8+20 padding = 118) even when empty, so the
     felt above doesn't reflow — the table used to jump ~8px between deals on desktop. */
  min-height: 118px;
  transition: transform .2s ease, filter .2s ease;
}
/* Not the player's turn to call/play: shrink to 90% and darken ~10% (black overlay). */
.hand.dim { transform: scale(.9); filter: brightness(.9); transform-origin: center bottom; }
.hand .card {
  margin-left: -14px; transition: transform .15s ease, box-shadow .15s ease, margin .15s ease;
  cursor: default;
}
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { cursor: pointer; }
/* hover-lift is defined later inside @media (hover: hover) so it never sticks on
   touch devices (a stuck :hover was eating card taps on Android). */
.hand .card.disabled { filter: grayscale(.4) brightness(.82); }
.hand .card.belot::after {
  content: "♛"; position: absolute; top: -10px; left: 6px; right: auto; font-size: 14px;
  color: var(--gold-deep); background: var(--gold-bright); border-radius: 50%;
  width: 20px; height: 20px; display: grid; place-items: center; z-index: 12;
  box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
/* Belot held but not declarable right now (Всичко коз: not the asked suit). */
.hand .card.belot-gray::after {
  color: #4a4a4a; background: #9a9a9a; box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

/* bidding panel */
.bid-panel {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%);
  width: min(560px, 94vw); z-index: 12;
  background: linear-gradient(180deg, rgba(10,44,34,.96), rgba(6,32,26,.98));
  border: 1px solid rgba(217,178,95,.4); border-radius: 16px;
  padding: 16px 18px; box-shadow: 0 20px 60px var(--shadow);
}
.bid-info { text-align: center; font-size: 14px; color: var(--ivory-dim); margin-bottom: 12px; }
.bid-info b { color: var(--gold-bright); }
.bid-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bid-btn {
  font-family: 'Manrope'; font-weight: 700; font-size: 15px;
  padding: 11px 16px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.06); color: var(--ivory); border: 1.5px solid rgba(217,178,95,.3);
  display: flex; align-items: center; gap: 6px; transition: all .12s ease;
}
.bid-btn:hover { background: rgba(217,178,95,.18); border-color: var(--gold); transform: translateY(-2px); }
.bid-btn .suit.red { color: var(--red-soft); }
.bid-btn.pass { color: var(--ivory-dim); }
.bid-btn.contra { background: rgba(176,40,46,.3); border-color: var(--red-soft); color: #ffd9d9; }
.bid-btn.recontra { background: rgba(176,40,46,.5); border-color: var(--red); color: #fff; }

/* log */
.log-feed {
  position: absolute; left: 18px; bottom: 16px; width: 250px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.log-feed .line {
  font-size: 12px; color: var(--ivory-dim); background: rgba(0,0,0,.3);
  padding: 5px 10px; border-radius: 8px; opacity: .85;
  border-left: 2px solid rgba(217,178,95,.4);
}

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(3,16,12,.72); backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 92vw);
  background: linear-gradient(180deg, #103f30, #08281f);
  border: 1px solid rgba(217,178,95,.4); border-radius: 18px;
  padding: 28px 30px; box-shadow: 0 30px 90px var(--shadow);
  max-height: 86vh; overflow: auto;
}
.modal h2 { font-family: 'Forum', serif; font-weight: 400; font-size: 30px; color: var(--gold-bright); text-align: center; margin-bottom: 6px; }
.modal .sub { text-align: center; color: var(--ivory-dim); margin-bottom: 18px; font-size: 14px; }
.result-tag { text-align: center; font-family: 'Forum', serif; font-size: 22px; margin-bottom: 16px; }
.result-tag.made { color: var(--ok); } .result-tag.down { color: var(--bad); } .result-tag.hanging { color: var(--gold-bright); }
.score-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; margin: 12px 0; font-size: 14px; }
.score-grid .h { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .6; }
.score-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.decl-line { font-size: 13px; color: var(--ivory-dim); margin: 3px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.rules-list { font-size: 14px; line-height: 1.6; color: var(--ivory-dim); }
.rules-list h3 { color: var(--gold-bright); font-family: 'Forum', serif; font-weight: 400; font-size: 18px; margin: 14px 0 4px; }
.rules-list table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.rules-list td { padding: 2px 6px; border-bottom: 1px solid rgba(255,255,255,.06); }

/* toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(176,40,46,.95); color: #fff; padding: 12px 22px; border-radius: 12px;
  z-index: 60; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px var(--shadow);
  opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

@keyframes dealIn { from { opacity: 0; transform: translateY(20px) scale(.9); } to { opacity: 1; } }
.card.deal { animation: dealIn .3s ease both; }
/* Cards slide up into the hand (no fade-out). */
@keyframes handReveal { from { transform: translateY(46px) scale(.96); } to { transform: none; } }
.hand .card.reveal { animation: handReveal .3s cubic-bezier(.2,.85,.25,1) both; }

/* ---- Bot controls (waiting room) ---- */
.bot-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }
.bot-controls .btn { flex: 1; padding: 10px 12px; font-size: 14px; }
.bot-controls.hidden { display: none !important; }
.seat-row .bot-tag { font-size: 11px; color: var(--them); display: inline-flex; align-items: center; gap: 4px; }
.nameplate .badge.bot { background: rgba(121,182,230,.25); color: #cfe6fb; }

/* ---- Dealer deck ---- */
.deck { position: absolute; z-index: 2; width: 64px; height: 92px; pointer-events: none; transition: opacity .3s ease; }
.deck-stack { position: relative; width: 62px; height: 90px; }
.deck-layer {
  position: absolute; left: 0; width: 62px; height: 90px; border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, #7a1f23 0 5px, #5c1418 5px 10px);
  border: 1.5px solid rgba(217,178,95,.55);
  box-shadow: 0 1px 0 rgba(0,0,0,.3);
  bottom: calc(var(--i) * 2px); left: calc(var(--i) * -1px);
}
.deck-layer::after {
  content: "❦"; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(217,178,95,.5); font-size: 26px;
}
.deck-count {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--gold-bright); background: rgba(0,0,0,.5);
  padding: 1px 8px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
/* deck anchored beside whichever seat is dealing */
.deck-top    { top: 64px;  left: calc(50% + 60px); }
.deck-bottom { bottom: 18px; left: calc(50% + 70px); }
.deck-left   { left: 92px;  top: calc(50% - 46px); }
.deck-right  { right: 92px; top: calc(50% - 46px); }

/* ---- Flying cards overlay ---- */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.fly-card {
  position: fixed; width: 56px; height: 82px; border-radius: 7px;
  background: repeating-linear-gradient(45deg, #7a1f23 0 5px, #5c1418 5px 10px);
  border: 1.5px solid rgba(217,178,95,.6);
  box-shadow: 0 8px 18px rgba(0,0,0,.45);
  transition: transform .42s cubic-bezier(.2,.75,.25,1), opacity .42s ease;
  will-change: transform; opacity: .98;
}
.fly-card::after { content: "❦"; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(217,178,95,.5); font-size: 22px; }

/* ---- Per-seat announcement bubbles (calls + declarations) ---- */
.seat .bubble {
  position: absolute; z-index: 6; display: none;
  flex-direction: column; gap: 3px; align-items: center;
  max-width: 150px; pointer-events: none;
}
.seat .bubble.show { display: flex; animation: bubblePop .22s cubic-bezier(.2,.8,.2,1.2) both; }
.seat .bubble span {
  font-size: 12px; font-weight: 700; white-space: nowrap;
  padding: 4px 11px; border-radius: 14px;
  background: linear-gradient(180deg, #fffdf6, var(--ivory) 80%);
  color: var(--ink); box-shadow: 0 4px 12px rgba(0,0,0,.4);
  border: 1px solid rgba(156,122,51,.5);
}
.seat .bubble .b-call { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #3a2c08; }
.seat .bubble .b-call.pass { background: rgba(0,0,0,.5); color: var(--ivory-dim); border-color: rgba(255,255,255,.15); }
.seat .bubble .b-call.dbl { background: linear-gradient(180deg, #d8504e, var(--red)); color: #fff; border-color: var(--red); }
.seat .bubble .b-decl { background: linear-gradient(180deg, #eafff1, #cdeedd); color: #15412c; }
.seat .bubble .b-belot { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #3a2c08; }
.seat .bubble .b-belot.red { color: var(--red); }
.seat .bubble .b-call .s.red { color: var(--red); }
/* place the bubble on the center-facing side of each seat */
.seat-top .bubble    { top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px; }
.seat-bottom .bubble { bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 10px; }
.seat-left .bubble   { left: 100%; top: 50%; transform: translateY(-50%); margin-left: 10px; align-items: flex-start; }
.seat-right .bubble  { right: 100%; top: 50%; transform: translateY(-50%); margin-right: 10px; align-items: flex-end; }
@keyframes bubblePop { from { opacity: 0; transform: translateX(-50%) scale(.6); } }
.seat-left .bubble.show, .seat-right .bubble.show { animation: bubblePopSide .22s cubic-bezier(.2,.8,.2,1.2) both; }
@keyframes bubblePopSide { from { opacity: 0; transform: translateY(-50%) scale(.6); } }

/* ---- A played card flies in from its player's side ---- */
@keyframes flyTop    { from { opacity: .15; transform: translateY(-210px) rotate(-8deg) scale(.82); } }
@keyframes flyBottom { from { opacity: .15; transform: translateY(210px)  rotate(8deg)  scale(.82); } }
@keyframes flyLeft   { from { opacity: .15; transform: translateX(-300px) rotate(8deg)  scale(.82); } }
@keyframes flyRight  { from { opacity: .15; transform: translateX(300px)  rotate(-8deg) scale(.82); } }
.trick-slot .card.fly-top    { animation: flyTop    .34s cubic-bezier(.2,.75,.25,1) both; }
.trick-slot .card.fly-bottom { animation: flyBottom .34s cubic-bezier(.2,.75,.25,1) both; }
.trick-slot .card.fly-left   { animation: flyLeft   .34s cubic-bezier(.2,.75,.25,1) both; }
.trick-slot .card.fly-right  { animation: flyRight  .34s cubic-bezier(.2,.75,.25,1) both; }

/* ---- Announce bar + declaration chips ---- */
.announce-panel {
  position: absolute; left: 50%; bottom: 132px; transform: translateX(-50%);
  width: min(560px, 94vw); z-index: 12; text-align: center;
  background: linear-gradient(180deg, rgba(10,44,34,.97), rgba(6,32,26,.98));
  border: 1px solid rgba(217,178,95,.45); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 20px 60px var(--shadow);
}
.announce-info { color: var(--ivory-dim); font-size: 14px; margin-bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.announce-actions { display: flex; gap: 10px; justify-content: center; }
.announce-actions .btn { padding: 9px 18px; }
.decl-chip, .decl-item { display: inline-flex; align-items: center; gap: 5px; }
/* Little playing-card chips (look like real cards, not squares) */
.mini-card {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 26px; height: 36px; padding: 3px 5px; gap: 1px;
  background: linear-gradient(160deg, #fffdf6, var(--ivory) 72%, var(--ivory-dim));
  color: var(--ink); border: 1px solid rgba(0,0,0,.22); border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.5);
  font-weight: 800; font-size: 12px; line-height: 1;
}
.mini-card.red { color: var(--red); }
.mini-card i { font-style: normal; font-size: 16px; }
.decl-pts { color: var(--gold-bright); font-weight: 800; font-size: 13px; }

/* ---- Hand-result modal extras ---- */
.big-score { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 14px 0 6px; }
.big-score .bs-team { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.big-score .bs-lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; opacity: .75; margin-bottom: 7px; }
.big-score .bs-num { font-family: 'Forum', serif; font-size: 56px; }
.big-score .us .bs-num { color: var(--us); }
.big-score .them .bs-num { color: var(--them); }
.big-score .bs-sep { font-family: 'Forum', serif; font-size: 36px; opacity: .35; }
/* ---- Game-over / win screen ---- */
.gameover { text-align: center; }
.gameover h2 { margin: 2px 0 2px; }
/* Last-hand breakdown embedded in the game-over modal. */
.go-lasthand { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(217,178,95,.22); text-align: left; }
.go-lasthand h3 {
  font-family: 'Forum', serif; font-weight: 400; font-size: 20px; color: var(--gold-bright);
  text-align: center; margin-bottom: 10px;
}
.go-trophy { font-size: 56px; line-height: 1; margin-bottom: 4px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); animation: trophyPop .5s cubic-bezier(.2,.8,.2,1.3) both; }
@keyframes trophyPop { from { opacity: 0; transform: scale(.4) rotate(-12deg); } }
.gameover .go-sub { color: var(--ivory-dim); font-size: 14px; margin-bottom: 4px; }
.gameover.win h2 { color: var(--gold-bright); }
.gameover.lose h2 { color: var(--ivory-dim); }
.final-score { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 16px 0 6px; }
.final-score .fs-team {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 24px; border-radius: 16px; min-width: 110px;
  border: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.2);
}
.final-score .fs-lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; opacity: .8; }
.final-score .fs-num { font-family: 'Forum', serif; font-size: 60px; line-height: 1; }
.final-score .us .fs-num { color: var(--us); }
.final-score .them .fs-num { color: var(--them); }
.final-score .fs-sep { font-family: 'Forum', serif; font-size: 40px; opacity: .3; }
.final-score .winner {
  background: rgba(217,178,95,.14); border-color: rgba(217,178,95,.55);
  box-shadow: 0 0 34px rgba(217,178,95,.28), inset 0 0 0 1px rgba(217,178,95,.2);
}
.final-score .winner .fs-lbl::after { content: ' 👑'; }
.go-target { font-size: 12px; color: var(--ivory-dim); opacity: .6; letter-spacing: .05em; margin-bottom: 4px; }

.score-grid4 { display: grid; grid-template-columns: 1fr auto auto auto; gap: 7px 16px; margin: 10px 0; font-size: 14px; align-items: center; }
.score-grid4 .h { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
.score-grid4 .num { text-align: right; font-variant-numeric: tabular-nums; }
.score-grid4 .mine { color: var(--gold-bright); font-weight: 700; }
.decl-block { margin-top: 8px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; }
.decl-head { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .6; margin-bottom: 6px; }
.decl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 5px 0; font-size: 13px; }
.decl-row .decl-who { font-weight: 700; min-width: 70px; }
.decl-row.us .decl-who { color: var(--us); }
.decl-row.them .decl-who { color: var(--them); }
.decl-item { position: relative; background: rgba(0,0,0,.2); padding: 3px 8px; border-radius: 10px; }
/* discarded declaration (lost its category contest) — scratched out */
.decl-item.discarded { opacity: .5; filter: grayscale(.4); }
.decl-item.discarded::after {
  content: ''; position: absolute; left: 4px; right: 4px; top: 50%;
  height: 2px; background: var(--bad); transform: rotate(-4deg);
  box-shadow: 0 0 3px rgba(0,0,0,.5); pointer-events: none;
}
.sub .red-ic { color: var(--red-soft); }

/* responsive */
@media (max-width: 720px) {
  .felt { margin: 2px 6px; }
  .card { width: 50px; height: 72px; }
  .brand h1 { font-size: 42px; }
  .seat-left { left: 2px; } .seat-right { right: 2px; }
  /* stack name + dealer/bot/offline badges vertically */
  .nameplate { flex-direction: column; gap: 3px; padding: 4px 9px; }
  /* Calling banner / announcements sit ON TOP of the player circle. The top
     seat keeps its bubble below the avatar so it doesn't hit the HUD. */
  .seat-left .bubble, .seat-right .bubble, .seat-bottom .bubble {
    bottom: 100%; top: auto; left: 50%; right: auto;
    transform: translateX(-50%); margin: 0 0 5px 0; align-items: center; max-width: 120px;
  }
  .seat-top .bubble {
    top: 100%; bottom: auto; left: 50%; right: auto;
    transform: translateX(-50%); margin: 5px 0 0 0; align-items: center; max-width: 120px;
  }
  .seat .bubble.show { animation: bubblePop .22s cubic-bezier(.2,.8,.2,1.2) both; }
  /* HUD must not cause horizontal scroll; keep one row so centre stays centred */
  .hud { gap: 6px; padding: 8px 8px; }
  .hud-left, .hud-right { gap: 6px; }
  .scoreboard { padding: 6px 10px; gap: 8px; }
  .scoreboard .val { font-size: 20px; }
  .contract-badge { font-size: 16px; padding: 6px 14px; }

  /* Compact bidding panel so it doesn't bury the seats; buttons in ≤2 rows.
     4 per row lets the worst case (6 contracts + Пас = 7) fit in exactly 2 rows. */
  .bid-panel { bottom: 116px; width: 96vw; padding: 9px 8px; border-radius: 14px; }
  .bid-info { font-size: 12px; margin-bottom: 7px; }
  .bid-buttons { gap: 5px; }
  .bid-btn { font-size: 12px; padding: 8px 4px; border-radius: 8px; flex: 1 1 22%; justify-content: center; min-width: 0; gap: 3px; }
}
/* kill any horizontal overflow everywhere */
html, body { max-width: 100%; overflow-x: hidden; }
#app, .screen, .felt, .hud { max-width: 100vw; }

/* Portrait phones: spread the hand so cards are easy to tap */
@media (max-width: 720px) and (orientation: portrait) {
  .card { width: 46px; height: 67px; }
  .hand { padding: 8px 6px 16px; }
  .hand .card { margin-left: -8px; }
  .hand .card:first-child { margin-left: 0; }
}
@media (max-width: 720px) and (orientation: landscape) {
  .hand .card { margin-left: -16px; }
}

/* ---- Gold toast (belot announcement) ---- */
.toast.gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  color: #3a2c08; font-family: 'Forum', serif; font-size: 19px; letter-spacing: .02em;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; line-height: 1.15;
}

/* ---- Full dynamic viewport height (no mobile vertical scroll) ---- */
#app, #table.screen { height: 100vh; }
@supports (height: 100dvh) {
  #app, #table.screen { height: 100dvh; }
}

/* ---- Burger menu (mobile) for до 151 / Правила / Приключи ---- */
.hud-right { position: relative; }
.burger { display: none; }
.hud-menu { display: flex; gap: 10px; align-items: center; }
@media (max-width: 720px) {
  /* card internals scale with the smaller cards (same look as desktop) */
  .card .corner { font-size: 13px; }
  .card .corner .pip { font-size: 12px; }
  .card .center-pip { font-size: 24px; }
  .burger {
    display: inline-grid; place-items: center; width: 40px; height: 34px;
    background: rgba(0,0,0,.32); color: var(--gold-bright);
    border: 1px solid rgba(217,178,95,.4); border-radius: 9px; font-size: 18px; cursor: pointer;
    transition: transform .28s cubic-bezier(.3,1.4,.5,1), background .2s ease, color .2s ease;
  }
  .burger:active { transform: scale(.92); }
  /* Morph the ☰ glyph into an ✕ and spin as the menu opens. */
  .burger.open { transform: rotate(90deg); background: rgba(217,178,95,.18); color: #fff; }
  .burger::before { content: "☰"; transition: opacity .18s ease; }
  .burger.open::before { content: "✕"; }
  .hud-menu {
    /* Stays in the DOM (no display:none) so it can animate open/closed. */
    display: flex; position: absolute; right: 0; top: calc(100% + 8px);
    flex-direction: column; align-items: stretch; gap: 8px; z-index: 30; min-width: 150px;
    background: linear-gradient(180deg, #103f30, #08281f);
    border: 1px solid rgba(217,178,95,.4); border-radius: 12px; padding: 12px;
    box-shadow: 0 16px 40px var(--shadow);
    transform-origin: top right;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(-8px) scale(.94);
    transition: opacity .22s ease, transform .24s cubic-bezier(.2,.9,.3,1.1), visibility .22s;
  }
  .hud-menu.open {
    opacity: 1; visibility: visible; pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .hud-menu .pill, .hud-menu .btn { width: 100%; text-align: center; }
}
@media (max-width: 720px) and (orientation: portrait) {
  .card .corner { font-size: 12px; }
  .card .corner .pip { font-size: 11px; }
  .card .center-pip { font-size: 22px; }
}

/* ---- Room code button in the top-right menu ---- */
.menu-room {
  font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 700; cursor: pointer;
  background: rgba(0,0,0,.3); color: var(--ivory-dim);
  border: 1px solid rgba(217,178,95,.35); border-radius: 8px; padding: 7px 12px; letter-spacing: .03em;
}
.menu-room b { color: var(--gold-bright); letter-spacing: .14em; margin-left: 4px; }
.menu-room:hover { background: rgba(217,178,95,.15); }

/* ---- "You are dealing" indicator (bottom centre) ---- */
.dealer-tag {
  position: absolute; left: 50%; bottom: 116px; transform: translateX(-50%); z-index: 6;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--gold-bright);
  background: rgba(0,0,0,.42); border: 1px solid rgba(217,178,95,.4);
  padding: 4px 14px; border-radius: 20px; box-shadow: 0 4px 14px rgba(0,0,0,.4);
  pointer-events: none; white-space: nowrap;
}
@media (max-width: 720px) { .dealer-tag { bottom: 104px; font-size: 11px; padding: 3px 11px; } }

/* ---- One-click "claim the rest" (all remaining cards are sure winners) ---- */
.claim-all {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 14;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: claimPulse 1.4s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes claimPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(0,0,0,.5); }
  50% { box-shadow: 0 6px 26px rgba(217,178,95,.7); }
}
@media (max-width: 720px) { .claim-all { bottom: 138px; font-size: 13px; padding: 8px 16px; } }

/* ---- "Сваля всички" showcase (claimant's cards laid on the table + Продължи) ---- */
.claim-layer {
  position: absolute; inset: 0; z-index: 15; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.claim-banner {
  background: rgba(0,0,0,.6); color: var(--gold-bright);
  border: 1px solid rgba(217,178,95,.5); padding: 7px 18px; border-radius: 22px;
  font-weight: 700; letter-spacing: .02em; box-shadow: 0 6px 22px rgba(0,0,0,.55);
}
.claim-cards { display: flex; align-items: flex-end; }
.claim-cards .claim-card {
  margin-left: -20px; box-shadow: 0 10px 24px rgba(0,0,0,.5);
  animation: claimInBottom .42s cubic-bezier(.2,.8,.25,1) both;
  animation-delay: calc(var(--i) * 85ms);
}
.claim-cards .claim-card:first-child { margin-left: 0; }
.claim-cards.from-top .claim-card   { animation-name: claimInTop; }
.claim-cards.from-left .claim-card  { animation-name: claimInLeft; }
.claim-cards.from-right .claim-card { animation-name: claimInRight; }
@keyframes claimInBottom { from { opacity: 0; transform: translateY(150px)  scale(.7) rotate(6deg); } }
@keyframes claimInTop    { from { opacity: 0; transform: translateY(-180px) scale(.7) rotate(-6deg); } }
@keyframes claimInLeft   { from { opacity: 0; transform: translateX(-230px) scale(.7) rotate(-6deg); } }
@keyframes claimInRight  { from { opacity: 0; transform: translateX(230px)  scale(.7) rotate(6deg); } }
.claim-actions { pointer-events: auto; }
.claim-wait { color: var(--ivory-dim); font-size: 14px; }
@media (max-width: 720px) { .claim-cards .claim-card { margin-left: -26px; } }

/* ---- Team-swap button in the lobby seat list ---- */
.swap-btn {
  flex: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  font-size: 15px; line-height: 1; color: var(--gold-bright);
  background: rgba(0,0,0,.3); border: 1px solid rgba(217,178,95,.4);
  transition: transform .12s ease, background .12s ease;
}
.swap-btn:hover { background: rgba(217,178,95,.18); transform: rotate(180deg); }
.swap-btn.selected {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep)); color: #3a2c08;
  box-shadow: 0 0 0 3px rgba(217,178,95,.35), 0 0 16px rgba(217,178,95,.4);
}

/* ---- End-of-round chronological score ledger ---- */
.score-history { display: flex; gap: 14px; margin: 12px 0 4px; }
.score-history .sh-col {
  flex: 1; text-align: center; background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 10px 8px;
}
.score-history .sh-head { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin-bottom: 6px; }
.score-history .us .sh-head { color: var(--us); }
.score-history .them .sh-head { color: var(--them); }
.score-history .sh-line { font-size: 13px; color: var(--ivory-dim); font-variant-numeric: tabular-nums; line-height: 1.5; }
.score-history .sh-total {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(217,178,95,.25);
  font-family: 'Forum', serif; font-size: 30px; line-height: 1;
}
.score-history .us .sh-total { color: var(--us); text-shadow: 0 0 12px rgba(241,214,149,.4); }
.score-history .them .sh-total { color: var(--them); text-shadow: 0 0 12px rgba(121,182,230,.35); }

/* ---- Touch/Android: reliable card taps ---- */
.card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hand .card.playable { cursor: pointer; }
/* the hover-lift is only for real pointers; on touch it made taps miss */
@media (hover: hover) {
  .hand .card.playable:hover { transform: translateY(-16px); z-index: 20; }
}
@media (hover: none) {
  .hand .card.playable { transform: translateY(-6px); } /* raise slightly so each is tappable */
  .hand .card.playable:active { transform: translateY(-16px); z-index: 20; }
}

/* ---- Mobile: compact waiting room so it fits without clipping ---- */
@media (max-width: 720px) {
  /* let the panel scroll if it's still taller than the screen (nothing hidden) */
  #waiting.active { place-items: safe center; overflow-y: auto; padding: 10px 0; }
  .waiting-card { width: 94vw; padding: 16px 14px; border-radius: 16px; }
  .waiting-card h2 { font-size: 22px; }
  .code-box { margin: 8px 0 4px; gap: 8px; }
  .code { font-size: 38px; letter-spacing: .12em; padding: 4px 12px 6px; }
  .share-hint { margin-bottom: 12px; font-size: 12px; }
  .seat-list { gap: 7px; margin-bottom: 12px; }
  .seat-row { padding: 8px 11px; gap: 8px; }
  .seat-row .who { font-size: 15px; }
  .bot-controls { margin-bottom: 10px; gap: 8px; }
  .waiting-foot { gap: 8px; }
  .waiting-foot .btn-gold, .bot-controls .btn, #leaveBtn { padding: 11px 14px; }
}
