:root {
  --felt: #0f3d22;
  --felt-dark: #0a2c18;
  --felt-light: #165a32;
  --gold: #f2b632;
  --gold-dim: #b88a22;
  --ink: #f4f1e8;
  --ink-dim: #b9c7bd;
  --panel: rgba(0, 0, 0, 0.24);
  --panel-line: rgba(255, 255, 255, 0.12);
  --card-red: #c0262d;
  --card-black: #1b1b1b;
  --danger: #ff6b5e;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 35%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%) fixed;
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh; /* older Safari without dvh */
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; }

button, input { font: inherit; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--gold);
  color: #2a1e00;
  transition: transform .08s ease, filter .15s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--panel-line); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.link { background: none; color: var(--gold); padding: 6px 8px; }

.field {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--panel-line);
  background: rgba(0,0,0,.28);
  color: var(--ink);
  outline: none;
}
.field:focus { border-color: var(--gold); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 14px;
}

.muted { color: var(--ink-dim); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.stack > .btn { width: 100%; }

/* ---------------- home ---------------- */
.home { margin: auto 0; display: flex; flex-direction: column; gap: 22px; }
.logo {
  font-size: clamp(48px, 15vw, 84px);
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 3px 0 rgba(0,0,0,.35);
  /* fixed gap under the card fan: the line box shrinks with the font on phones */
  line-height: 1.1; margin-top: 20px;
}
@media (min-width: 560px) { .logo { margin-top: 14px; } }
.logo-fan { display: flex; justify-content: center; margin-bottom: -6px; }
.logo-fan .card { margin: 0 -10px; }
.logo-fan .card:nth-child(1) { transform: rotate(-14deg) translateY(6px); }
.logo-fan .card:nth-child(3) { transform: rotate(14deg) translateY(6px); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--panel-line); }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 800; }

/* ---------------- top bar ---------------- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.topbar h2 { font-size: 18px; flex: 1; }
.banner {
  background: #b5651d;
  color: #fff;
  text-align: center;
  padding: 6px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 10px;
}

/* ---------------- lobby ---------------- */
.lobby { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.room-code {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: .25em;
  text-align: center;
  padding-left: .25em;
  user-select: all;
}
.players { list-style: none; margin: 0; padding: 0; }
.players li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--panel-line);
}
.players li:last-child { border-bottom: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--felt-light); font-weight: 800;
}
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: #2a1e00; font-weight: 700; }
.badge.off { background: #555; color: #ddd; }
.deck-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.deck-row .grow { min-width: 0; }
.deck-row .sub { font-size: 14px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby .spacer { flex: 1; }

/* ---------------- cards ---------------- */
.card {
  --w: 58px;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  border-radius: calc(var(--w) * .12);
  background: #fff;
  border: 1px solid rgba(0,0,0,.2);
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
  position: relative;
  flex: none;
  color: var(--card-black);
  user-select: none;
  transition: transform .15s ease, opacity .15s, box-shadow .15s;
}
.card.red { color: var(--card-red); }
.card .rank {
  position: absolute; top: 5%; left: 9%;
  font-weight: 800; font-size: calc(var(--w) * .28); line-height: 1;
}
.card .rank small { display: block; font-size: .8em; }
.card .pip {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: calc(var(--w) * .5);
  padding-top: 12%;
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 8px),
    #8e2430;
  border: 2px solid #fff;
}
.card.sm { --w: 26px; }
.card.md { --w: 44px; }
.card.lg { --w: 64px; }
.card.dim { opacity: .4; }
button.card { padding: 0; font: inherit; cursor: pointer; }
button.card:disabled { cursor: default; }
.card.playable { box-shadow: 0 0 0 2.5px var(--gold), 0 4px 8px rgba(0,0,0,.4); transform: translateY(-8px); }
.card.playable:active { transform: translateY(-14px); }
.card.removed { background: rgba(255,255,255,.18); box-shadow: none; border-style: dashed; border-color: rgba(255,255,255,.35); }
.card.removed > span { opacity: .3; }
.card.removed::after {
  content: "✕";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--danger);
  font-size: calc(var(--w) * .7);
  font-weight: 900;
}

/* ---------------- table ---------------- */
/* flex: 1 0 auto — must not shrink below its content (Safari collapsed it to 0 height) */
.table { display: flex; flex-direction: column; flex: 1 0 auto; gap: 10px; }
.opponents { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.opp {
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-width: 110px;
}
.opp.turn { border-color: var(--gold); }
.opp .name { font-weight: 700; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .meta { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--ink-dim); margin-top: 4px; }

/* Centre area is a plain block as tall as its content (it can never overflow onto
   the hand); auto margins centre it vertically in the free space. Safari mis-sized
   the earlier stretched grid version. */
.center-area { display: block; flex: 0 0 auto; margin: auto 0; padding: 16px 0; text-align: center; }
.trick { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.trick .slot { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-dim); }
.trick.last { opacity: .55; }
.trick-note { margin-top: 10px; color: var(--ink-dim); font-size: 14px; text-align: center; }

.status { text-align: center; font-weight: 800; }
.status.mine { color: var(--gold); }
.my-score { text-align: center; font-size: 14px; color: var(--ink-dim); }

.hand {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 16px 4px 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.hand::-webkit-scrollbar { display: none; }
.hand .card { scroll-snap-align: start; }
@media (min-width: 560px) {
  .hand { flex-wrap: wrap; justify-content: center; overflow: visible; }
}

.results { text-align: center; }
.results .winner { font-size: 34px; font-weight: 900; color: var(--gold); margin-bottom: 14px; }
.results ol { list-style: none; padding: 0; margin: 0 0 20px; }
.results li { padding: 4px 0; font-size: 18px; }

/* ---------------- deck dialog ---------------- */
dialog {
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  background: var(--felt);
  color: var(--ink);
  padding: 16px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.deck-head { display: flex; align-items: baseline; gap: 10px; }
.deck-head h3 { flex: 1; }
.deck-head { align-items: center; }
.dlg-x { flex: none; width: 34px; height: 34px; margin: -4px -6px 0 0; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--panel-line); background: transparent; color: var(--ink);
  font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.dlg-x:hover { border-color: var(--gold); color: var(--gold); }
.deck-count { color: var(--gold); font-weight: 800; }
.rank-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip {
  border: 1.5px solid var(--panel-line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.suit-row { display: flex; gap: 4px; margin-bottom: 8px; }
/* one row of 9 per suit, sized to the dialog width */
.suit-row .card { --w: clamp(28px, calc((min(100vw, 560px) - 100px) / 9), 50px); }
.deck-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }

/* ---------------- toast ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  z-index: 10;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--panel-line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------- garba ---------------- */
.coins { font-size: 14px; color: var(--gold); font-weight: 700; white-space: nowrap; }
.ante, .stepper-val { min-width: 64px; text-align: center; color: var(--gold); }
.sub.warn { color: var(--danger); }
.small { font-size: 13px; }
.infobar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 8px 12px; font-size: 14px;
}
.infobar .ib { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; text-align: center; }
.infobar .ib > .muted { font-size: 11.5px; line-height: 1.15; }
.infobar:has(.ib) { align-items: flex-start; }
.infobar .ib > b, .infobar .ib > span:last-child { min-height: 37px; display: flex; align-items: center; gap: 6px; }
.infobar .ib .suit { font-size: 26px; line-height: 1; }
.infobar .ib.changed .suit { text-shadow: 0 0 8px rgba(242,182,50,.7); }
@media (min-width: 640px) { .infobar .ib > .muted { font-size: 12.5px; } }
/* trump suit in the middle of the table */
.trump-mark { display: inline-grid; grid-auto-flow: row; justify-items: center; align-items: center;
  column-gap: 6px; pointer-events: none; }   /* phones: stacked (side cards are close); wider screens: see below */
.trump-mark .sym, .trump-mark .nm { opacity: .55; }
.trump-mark .kind { font-size: 15px; font-weight: 900; letter-spacing: .08em; color: var(--gold); }
.trump-mark .sym { font-size: 40px; line-height: 1; color: var(--ink); }
.trump-mark.red .sym { color: #ff8a80; }
.trump-mark .nm { text-align: center; font-size: 11px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .06em; }
@media (min-width: 640px) {  /* РАЗ/ДВА beside the suit: keeps the centre low, clear of the top / bottom cards */
  .trump-mark { grid-auto-flow: column; }
  .trump-mark .nm { grid-row: 2; grid-column: 1 / -1; }
}
.suit { font-size: 20px; color: var(--ink); }
.suit.red { color: #ff8a80; }
/* dealer badge on the seat's top edge */
.opp { position: relative; }
.opp:has(> .chip-d) { padding-top: 11px; }
.chip-d {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -55%); z-index: 1;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--ink); color: var(--felt); font-size: 11px; font-weight: 800; line-height: 1.5;
}
.opp.decl { background: rgba(242,182,50,.14); }
.bid-tag { display: inline-block; font-size: 12px; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.1); color: var(--ink-dim); }
.bid-tag.all { background: var(--gold); color: #2a1e00; font-weight: 700; }
.bid-tag.half { background: #3d6b8f; color: #fff; }
.decl-line { text-align: center; font-size: 14px; color: var(--ink-dim); }
.bid-panel { display: flex; flex-direction: column; gap: 10px; }
.half-row { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.suits { display: flex; gap: 10px; }
.suit-btn {
  width: 56px; height: 56px; border-radius: 12px; border: 0;
  background: #fff; color: var(--card-black); font-size: 30px; cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.suit-btn.red { color: var(--card-red); }
.suit-btn:disabled { opacity: .35; cursor: default; }
.my-line { text-align: center; font-size: 14px; color: var(--ink-dim); }
.results .winner.lost { color: var(--danger); }
.results p { margin: 0 0 16px; }

/* ready badges */
.badge.ready { background: #2e8b57; color: #fff; }
.badge.off { background: rgba(255,255,255,.12); color: var(--ink-dim); font-weight: 600; }

/* opponents' hands as a fan of card backs */
.fan { display: flex; justify-content: center; margin-top: 6px; padding-left: 9px; height: 30px; }
.fan.empty { font-size: 12px; color: var(--ink-dim); padding: 0; height: auto; }
.mini-back {
  width: 20px; height: 29px; margin-left: -9px; flex: none;
  border-radius: 3px; border: 1.5px solid #fff;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 3px, transparent 3px 6px), #8e2430;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}

/* Safari: never let iOS/macOS draw native button chrome over cards and suit buttons */
button.card, .suit-btn, .chip, .btn {
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: none;
  user-select: none;
}
button.card { color: var(--card-black); background: #fff; text-align: left; font-family: inherit; }
button.card.red { color: var(--card-red); }
button.card.removed { background: rgba(255,255,255,.18); }
.hand { padding-bottom: max(8px, env(safe-area-inset-bottom)); }

.btn.icon { padding: 6px 10px; font-size: 18px; line-height: 1; }
.deck-summary { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--panel); font-size: 14px; }
.deck-summary div + div { margin-top: 2px; color: var(--ink-dim); }

/* top-up dialog */
.players li.pick { cursor: pointer; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.players li.picked { background: rgba(242,182,50,.18); box-shadow: inset 0 0 0 2px var(--gold); }
.topup-amount { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--panel); }
.topup-value { color: var(--gold); font-size: 20px; }
.topup-preview { margin-top: 10px; text-align: center; color: var(--ink-dim); min-height: 1.4em; }
.topup-preview b { color: var(--gold); }
.topup-log { margin-top: 14px; border-top: 1px solid var(--panel-line); padding-top: 10px; }
.topup-log-title { font-size: 13px; font-weight: 700; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.topup-log ul { list-style: none; margin: 0; padding: 0; max-height: 168px; overflow-y: auto;
  display: grid; grid-template-columns: auto 1fr auto; }
.topup-log li { display: contents; font-size: 14px; }
.topup-log li > * { padding: 5px 12px 5px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.topup-log li:last-child > * { border-bottom: 0; }
.topup-log .when { color: var(--ink-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.topup-log li b { color: var(--gold); white-space: nowrap; text-align: right; padding-right: 2px; }
.add-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.add-row .btn { padding-left: 4px; padding-right: 4px; }
.deck-row .sub { white-space: normal; }

/* language switch */
.lang-switch { display: flex; justify-content: center; gap: 6px; }
.deck-actions .lang-switch { justify-content: flex-start; }
.chip.on { background: var(--gold); border-color: var(--gold); color: #2a1e00; }
.topbar h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .btn { flex: none; }

/* Kazakh ornament: қошқар мүйіз (ram's horn) pattern over the felt */
body {
  background:
    url("ornament.svg") center top / 120px 120px repeat,
    radial-gradient(ellipse at 50% 35%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%) fixed;
  background-attachment: fixed;
}
.orn-band {
  height: 26px;
  width: min(280px, 80%);
  margin: 2px auto 0;
  background: url("ornament-band.svg") center / 56px 26px repeat-x;
  opacity: .85;
}
dialog {
  background: url("ornament.svg") center / 120px 120px repeat, var(--felt);
}
/* РАЗ button: hint under the main label */
.bid-btn small { display: block; font-size: 12px; font-weight: 600; opacity: .75; margin-top: 2px; }
/* unplayable cards: darken instead of see-through, so the ornament doesn't show through */
.card.dim { opacity: 1; filter: brightness(.62) saturate(.7); }
/* centre the open trump card above its caption */
.center-area .center > .card { margin: 0 auto 6px; }

/* push-to-talk button: floats at the right edge while in voice */
#voice-dock {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
}
#voice-dock[hidden] { display: none; }
/* narrow screens: shift the page left so the button never covers anything */
@media (max-width: 860px) {
  body.voice-on #app { padding-right: 82px; }
}
.vtop.on { background: var(--gold); color: #2a1e00; border-color: var(--gold); font-size: 14px; }
.vtop.off { opacity: .45; }
.ptt {
  -webkit-appearance: none; appearance: none;
  width: 68px; height: 68px; border-radius: 50%;
  border: 3px solid var(--gold);
  background: rgba(10, 44, 24, .92);
  color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  box-shadow: 0 3px 12px rgba(0,0,0,.45);
  transition: transform .08s, background .08s;
}
.ptt span { font-size: 24px; line-height: 1; }
.ptt small { font-size: 8.5px; font-weight: 700; margin-top: 3px; max-width: 60px; line-height: 1.1; }
.ptt.on { background: var(--gold); color: #2a1e00; transform: scale(1.08); box-shadow: 0 0 0 8px rgba(242,182,50,.25); }
.vmark { font-size: .85em; }
.vmark.talking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
/* take-the-trump option */
.bid-btn.take { background: #e8d9a8; color: #2a1e00; }
.bid-btn.dva { background: #2f6fb3; color: #fff; }
.bid-btn.dva.open { box-shadow: 0 0 0 3px var(--gold); }
.bid-btn.dva:disabled { opacity: .45; }
.take-note { color: var(--gold); font-weight: 700; }
.suit-chip { font-size: 18px; padding: 2px 14px; }
.suit-chip.red { color: #ff8a80; }
.suit-chip[aria-pressed="true"] { color: #fff; }

/* deck editor: a suit with a single card left */
.deck-warn { margin: 8px 0 0; color: var(--danger); font-size: 14px; font-weight: 600; }

/* open games on the home screen */
.open-games:empty { display: none; }
.open-games { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px; padding: 12px 14px; text-align: left; }
.open-games p { margin: 8px 0 2px; }
.games { list-style: none; margin: 8px 0 0; padding: 0; }
.games li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--panel-line); }
.games li:first-child { border-top: 0; }
.games .sub { font-size: 13px; margin-top: 2px; }

/* lobby: host removes a player (two taps) */
.players .kick { padding: 4px 10px; min-width: 36px; font-size: 14px; }
.players .kick.confirm { border-color: var(--danger); color: var(--danger); }

/* on/off switch (public room) */
.switch { position: relative; width: 52px; height: 30px; border-radius: 15px; border: 0; padding: 0;
  background: rgba(255, 255, 255, 0.18); cursor: pointer; flex: 0 0 auto; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform .15s; }
.switch.on { background: var(--gold); }
.switch.on span { transform: translateX(22px); }

/* players who left mid-game */
.opp.left { opacity: .55; }
.left-tag { font-size: 12px; color: var(--danger); margin-top: 2px; }
.opp .kick { margin-top: 6px; padding: 2px 10px; font-size: 13px; min-height: 0; }
.opp .kick.confirm { border-color: var(--danger); color: var(--danger); opacity: 1; }
.btn.link.warn { color: var(--danger); }
.warn-text { color: var(--danger); font-weight: 600; }

/* home: ornament on top, tagline under the logo */
.tagline { margin: 4px 0 6px; text-align: center; color: var(--gold); opacity: .85; font-size: 18px; font-weight: 600; letter-spacing: .02em; }

/* rules (Ережелер) */
#rules-dialog { max-width: 640px; }
.rules-body { max-height: min(68vh, 640px); overflow-y: auto; margin-top: 6px; padding-right: 4px; font-size: 15px; line-height: 1.5; }
.rules-body h4 { margin: 16px 0 6px; color: var(--gold); font-size: 16px; }
.rules-body h4:first-child { margin-top: 4px; }
.rules-body ul { margin: 0; padding-left: 20px; }
.rules-body li { margin: 3px 0; }
.rules-body p { margin: 6px 0; }
.rules-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13.5px; }
.rules-body th, .rules-body td { border: 1px solid var(--panel-line); padding: 5px 6px; text-align: left; vertical-align: top; }
.rules-body th { color: var(--gold); font-weight: 700; }
/* home: rules icon top left, language flag top right */
.home-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.home-top .orn-band { flex: 1; width: auto; max-width: 280px; height: auto; aspect-ratio: 280 / 26; margin: 0;
  background-size: 20% 100%; background-repeat: repeat-x; background-position: left center; } /* always the full 5 motifs, scaled down on narrow screens */
.icon-btn { display: grid; place-items: center; width: 44px; height: 36px; padding: 0; border-radius: 10px;
  border: 1.5px solid var(--panel-line); background: transparent; font-size: 20px; line-height: 1; cursor: pointer; }
.icon-btn:hover { border-color: var(--gold); }
.lang-menu { position: relative; }
.lang-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.lang-menu > summary::-webkit-details-marker { display: none; }
.flag-btn { display: grid; place-items: center; width: 44px; height: 36px; border-radius: 10px;
  border: 1.5px solid var(--panel-line); }
.lang-menu[open] > .flag-btn, .flag-btn:hover { border-color: var(--gold); }
.flag { display: inline-block; width: 28px; height: 19px; border-radius: 3px; overflow: hidden; flex: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25); line-height: 0; }
.flag svg { width: 100%; height: 100%; display: block; }
.lang-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; flex-direction: column; gap: 4px;
  padding: 6px; border-radius: 12px; background: var(--felt-dark); border: 1px solid var(--panel-line);
  box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.lang-opt { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 8px; white-space: nowrap;
  background: transparent; color: var(--ink); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.lang-opt:hover { background: rgba(255,255,255,.07); }
.lang-opt.on { background: rgba(242,182,50,.18); color: var(--gold); font-weight: 700; }

/* deal history + replay */
#history-dialog { max-width: 560px; }
.games.history { max-height: min(62vh, 560px); overflow-y: auto; }
.games.history .card.sm { vertical-align: middle; margin-left: 4px; }
.sub.good, p.good { color: #8fdc8f; }
.sub.warn, p.warn { color: var(--danger); }
.replay { min-height: 220px; display: flex; flex-direction: column; justify-content: center; gap: 8px; margin: 10px 0; }
.replay-trick { justify-content: center; }
.replay-trick .slot.won .card { outline: 3px solid var(--gold); outline-offset: 2px; }
.replay-bids { list-style: none; padding: 0; margin: 10px 0 0; text-align: center; }
.replay-bids li { margin: 4px 0; }

/* deck presets */
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chip.preset { font-size: 14px; }
.chip.preset.match { border-color: var(--gold); }

/* suit name under the symbol on the ДВА buttons */
.suit-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.suit-btn small { font-size: 11px; font-weight: 700; margin-top: 3px; letter-spacing: .01em; }
.suits-legend { font-weight: 600; }

/* ---------------- round table: opponents on a circle around the centre ---------------- */
.ring { position: relative; width: 100%; max-width: 680px; margin: 4px auto 0;
  height: clamp(360px, 54vh, 560px); }
.ring::before { /* the table felt */
  content: ""; position: absolute; inset: 8% 6%; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,.06), rgba(0,0,0,.18));
  border: 2px solid rgba(242,182,50,.25); pointer-events: none; }
.ring .opp { position: absolute; transform: translate(-50%, -50%); z-index: 2;
  min-width: 0; width: 104px; padding: 6px 6px 5px; font-size: 13px; }
.ring .opp .name { max-width: 92px; margin: 0 auto; font-size: 13.5px; }
.ring .opp .meta { font-size: 11.5px; margin-top: 2px; white-space: nowrap; }
.ring .opp .fan { height: 24px; margin-top: 4px; }
.ring .opp .mini-back { width: 16px; height: 23px; margin-left: -10px; }
.ring .opp .bid-tag { font-size: 11.5px; margin-top: 3px; }
.ring .opp .kick { position: absolute; top: -8px; right: -2px; margin: 0; padding: 0; width: 24px; height: 24px;
  min-width: 0; border-radius: 50%; font-size: 12px; background: var(--felt, #0f3d24); }
.ring .opp .kick.confirm { width: auto; padding: 0 8px; border-radius: 12px; }
.ring .opp .left-tag { font-size: 11px; }
.ring .center-area { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52%; margin: 0; padding: 0; z-index: 1; }
.ring .center-area .card.lg { --w: 56px; }
.ring .trick-note { font-size: 12.5px; margin-top: 6px; }
.ring .trick { gap: 6px; }
.ring .trick .slot { font-size: 11px; }
@media (min-width: 640px) {
  .ring .opp { width: 128px; font-size: 14px; }
  .ring .opp .name { max-width: 116px; }
  .ring .center-area { width: 48%; }
}

.ring .me-seat { width: auto; min-width: 104px; padding: 5px 10px; }
.ring .me-seat .name { max-width: none; }
.ring.ring-1, .ring.ring-2 { height: clamp(300px, 44vh, 460px); }

/* played cards in front of each player: earlier tricks fanned, this trick's card on top */
.ring { --drop-x: 17%; --drop-y: 19%; }
.ring .drop { position: absolute; transform: translate(-50%, -50%); z-index: 1;
  display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.ring .drop .pile { display: flex; padding-left: 13px; }
.ring .drop .pile .card { --w: 24px; margin-left: -13px; box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.ring .drop .pile .card .rank { font-size: 9px; left: 6%; }
.ring .drop .pile .card .pip { display: none; }
.ring .drop .card.now { --w: 40px; }
.ring .drop .now, .ring .drop .now-empty { margin-top: -18px; }
/* phones, 6-7 players: smaller cards spread wider; the suit name goes (the trump is in the top bar) */
.ring.ring-5, .ring.ring-6 { --drop-x: 20%; --drop-y: 23%; }
.ring.ring-5 .drop .card.now, .ring.ring-6 .drop .card.now { --w: 34px; }
.ring.ring-5 .drop .pile .card, .ring.ring-6 .drop .pile .card { --w: 21px; margin-left: -13px; }
.ring.ring-5 .drop .pile .card .rank, .ring.ring-6 .drop .pile .card .rank { font-size: 8px; }
.ring.ring-5 .drop .pile, .ring.ring-6 .drop .pile { padding-left: 13px; }
.ring.ring-5 .drop .now, .ring.ring-6 .drop .now { margin-top: -15px; }
/* above / below the centre: pile to the left of the card, card overlapping its right part */
.ring .drop.row { flex-direction: row; align-items: flex-end; }
.ring .drop.row .now, .ring .drop.row .now-empty { margin-top: 0; margin-left: -10px; }
.ring .drop.row .now-empty { height: auto; width: 10px; }
.ring .drop .now-empty { height: 20px; }
.ring .drop .card.fresh { animation: drop-in .18s ease-out; }
.ring .drop .card.done { filter: brightness(.9); }
.ring .drop .card.won { box-shadow: 0 0 0 3px var(--gold), 0 3px 8px rgba(0,0,0,.45); }
@keyframes drop-in { from { transform: scale(1.25); opacity: .3; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .ring { --drop-x: 21%; --drop-y: 19%; height: clamp(460px, 62vh, 600px); }  /* short laptop windows scroll a bit */
  .ring .drop .pile { padding-left: 15px; }
  .ring .drop .pile .card { --w: 30px; margin-left: -15px; }
  .ring .drop .pile .card .rank { font-size: 10px; }
  .ring .drop .card.now { --w: 54px; }
  .ring .drop .now, .ring .drop .now-empty { margin-top: -20px; }
  .ring .drop.row .now, .ring .drop.row .now-empty { margin-top: 0; margin-left: -12px; }
  /* 6-7 players: smaller cards, spread wider, so neighbours' stacks don't touch */
  .ring.ring-5, .ring.ring-6 { --drop-x: 26%; --drop-y: 18%; }
  .ring.ring-5 .drop .card.now, .ring.ring-6 .drop .card.now { --w: 42px; }
  .ring.ring-5 .drop .pile .card, .ring.ring-6 .drop .pile .card { --w: 25px; margin-left: -14px; }
  .ring.ring-5 .drop .pile, .ring.ring-6 .drop .pile { padding-left: 14px; }
  .ring.ring-5 .drop .now, .ring.ring-6 .drop .now { margin-top: -17px; }
  .ring.ring-5 .drop .pile .card .rank, .ring.ring-6 .drop .pile .card .rank { font-size: 10px; }
}

/* replay / history button next to the deal number */
.deal-no { display: flex; align-items: center; gap: 6px; }
.replay-btn { border: 1.5px solid var(--panel-line); background: transparent; color: var(--gold);
  border-radius: 50%; width: 30px; height: 30px; padding: 0; font-size: 18px; line-height: 1; cursor: pointer;
  display: inline-grid; place-items: center; }
.replay-btn:hover { border-color: var(--gold); }

/* gold coin (replaces the 🪙 emoji, which is silver on some systems) */
.coin { width: 1.05em; height: 1.05em; vertical-align: -0.17em; flex: none; display: inline-block; }

/* the card the open-card taker put face down, tucked against his seat */
.closed-card { position: absolute; left: -12px; top: -14px; z-index: 3; transform: rotate(-16deg); pointer-events: auto; }
.closed-card .card { --w: 24px; box-shadow: 0 2px 5px rgba(0,0,0,.5); }
@media (min-width: 640px) { .closed-card .card { --w: 28px; } }

/* ГАРБА: won holding the top trumps — a red stamp over the table */
.garba-stamp { position: absolute; left: 50%; top: 50%; z-index: 6; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-9deg);
  font-size: clamp(40px, 12vw, 68px); font-weight: 900; letter-spacing: .08em; line-height: 1;
  color: #e3262f; padding: 6px 18px 8px; border: 5px solid #e3262f; border-radius: 14px;
  background: rgba(20, 10, 6, .55); box-shadow: 0 0 0 3px rgba(242,182,50,.75), 0 10px 30px rgba(0,0,0,.5);
  text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.garba-stamp.fresh { animation: garba-in .7s cubic-bezier(.2, 1.6, .4, 1) both, garba-glow 1.2s ease-in-out .7s 3; }
@keyframes garba-in {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-30deg) scale(3); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-9deg) scale(1); } }
@keyframes garba-glow {
  50% { box-shadow: 0 0 0 3px rgba(242,182,50,.95), 0 0 34px 10px rgba(227,38,47,.65); color: #ff4a4a; } }
.garba-line { margin: 0; text-align: center; color: #ff6b6b; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .garba-stamp.fresh { animation: none; } }
.garba-tag { color: #ff4a4a; letter-spacing: .05em; }

/* replay: a smaller copy of the round table inside the history dialog */
.ring.replay-ring { height: clamp(300px, 52vh, 440px); margin: 8px auto 0; --drop-x: 19%; --drop-y: 20%; }
/* 6-7 players: a taller replay table, or stacks run into each other on short screens */
.ring.replay-ring.ring-5, .ring.replay-ring.ring-6 { height: clamp(420px, 56vh, 480px); --drop-x: 21%; --drop-y: 22%; }
.ring.replay-ring .opp { width: 92px; padding: 5px 4px 4px; }
.ring.replay-ring .opp .name { max-width: 84px; font-size: 13px; }
.ring.replay-ring .center-area { width: auto; }
.ring.replay-ring .center-area .card.lg { --w: 48px; }
.ring.replay-ring .garba-stamp { font-size: clamp(30px, 9vw, 48px); }
.replay-note { min-height: 1.3em; margin: 6px 0 0; font-size: 14px; }
@media (min-width: 640px) { .ring.replay-ring .opp { width: 110px; } }
.replay-controls { gap: 6px; }
.replay-controls .btn.small { padding: 8px 10px; min-width: 40px; }
.replay-controls .rp-auto { min-width: 72px; }

/* turn clock on the seat of the person the game waits for */
.turn-timer { position: absolute; right: -10px; bottom: -10px; z-index: 4; min-width: 28px; height: 28px; padding: 0 5px;
  border-radius: 14px; display: grid; place-items: center; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--gold); color: #2a1e00; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.turn-timer.low { background: #e3262f; color: #fff; animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { transform: scale(1.15); } }
/* a card the bot played for someone whose time ran out */
.card.auto { background: #c9ccce; border-color: #a9adb0; }

/* phones: the coins button is just the coin, so the room code keeps its room */
@media (max-width: 520px) { .coins-btn .lbl { display: none; } .coins-btn { padding-left: 10px; padding-right: 10px; } }

/* quick reactions */
.react-btn { position: absolute; right: 0; bottom: 0; z-index: 7; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--panel-line); background: rgba(0,0,0,.35); font-size: 21px; cursor: pointer;
  display: grid; place-items: center; padding: 0; }
.react-btn.open, .react-btn:hover { border-color: var(--gold); }
.react-pop { position: absolute; right: 0; bottom: 52px; z-index: 8; width: min(300px, 92%); padding: 10px;
  border-radius: 14px; background: var(--felt-dark); border: 1px solid var(--panel-line); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.react-emojis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.react-emojis button { font-size: 24px; padding: 6px 0; border-radius: 10px; border: 0; background: rgba(255,255,255,.06); cursor: pointer; }
.react-phrases { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.react-phrases button { font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--panel-line); background: transparent; color: var(--ink); }
.react-emojis button:hover, .react-phrases button:hover { background: rgba(242,182,50,.18); }
.react-bubble { position: absolute; left: 50%; bottom: calc(100% + 16px); z-index: 9; transform: translateX(-50%);
  padding: 4px 10px; border-radius: 14px; background: #fff; color: #1b1b1b; font-size: 26px; line-height: 1.2;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.4); animation: bubble-in .25s cubic-bezier(.2, 1.6, .4, 1) both; pointer-events: none; }
.react-bubble.phrase { font-size: 14px; font-weight: 700; padding: 6px 12px; }
.react-bubble::after { content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #fff; }
@keyframes bubble-in { from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.6); } }
@media (max-width: 420px) {
  .topbar { gap: 5px; }
  .topbar .btn.icon, .topbar .coins-btn { padding: 6px 8px; }
  .topbar .btn.link { padding-left: 2px; padding-right: 4px; }
}


/* bots panel in the lobby */
.bots-panel { display: flex; flex-direction: column; gap: 8px; }
.bots-panel .row { gap: 8px; flex-wrap: wrap; }
.seg { display: flex; gap: 4px; }
.seg .chip { padding: 5px 10px; font-size: 13px; }
.seg .chip:disabled { opacity: 1; cursor: default; }
.seg .chip:disabled:not(.on) { opacity: .45; }
/* lobby on phones: the big room code is right below, the small one in the top bar can go */
@media (max-width: 520px) { .topbar h2.lobby-code { visibility: hidden; } }
#link-dialog { max-width: 420px; }
.link-field { width: 100%; font-size: 15px; user-select: all; -webkit-user-select: all; }
/* surrender after taking the open card */
.surrender-btn.ghost { border-color: rgba(227,38,47,.6); color: #ff8a80; }
.btn.danger { background: #c0262d; color: #fff; }
/* a deal stopped early: remaining cards face up in the seat */
.reveal { display: flex; justify-content: center; padding-left: 12px; margin-top: 4px; }
.reveal .card { --w: 24px; margin-left: -12px; box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.reveal .card .rank { font-size: 9px; left: 6%; }
.reveal .card .pip { display: none; }
@media (min-width: 640px) { .reveal .card { --w: 28px; } .reveal .card .rank { font-size: 10px; } }

/* "not for money" note: home screen + top of the rules */
.not-money { margin: 0; text-align: center; font-size: 12.5px; line-height: 1.4; color: var(--muted, #b9c9bd); opacity: .85; }
.linkish { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; text-decoration: underline; cursor: pointer; }
.rules-body .fair { border: 1px solid var(--panel-line); border-left: 3px solid #e2574c; border-radius: 10px; padding: 4px 12px 8px; margin-bottom: 10px; background: rgba(0,0,0,.15); }
