:root {
  --felt: #0f3d2e;
  --felt-2: #176247;
  --ink: #f3efe4;
  --muted: #b9c9c0;
  --gold: #e7c15a;
  --panel: rgba(8, 30, 22, 0.85);
  --card-w: 58px;
  --card-h: 84px;
  --red: #c8352c;
  --black: #1c1c24;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: radial-gradient(ellipse at 50% 30%, var(--felt-2), var(--felt) 70%); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.code { letter-spacing: 0.2em; font-family: ui-monospace, monospace; color: var(--gold); }

.screen { min-height: 100%; padding: 16px; padding-bottom: env(safe-area-inset-bottom); }

/* ---------- buttons / inputs ---------- */
.btn { border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: var(--ink); padding: 10px 16px; border-radius: 10px; cursor: pointer; transition: background .15s, transform .05s; }
.btn:hover { background: rgba(255,255,255,0.16); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); color: #2b2203; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #f0d073; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); color: #fff; border-color: transparent; font-weight: 700; }
.pf-danger summary { color: #ff9a8f; }
.btn.tiny { padding: 6px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.4; cursor: default; }
input { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); color: var(--ink); padding: 10px 12px; border-radius: 10px; width: 100%; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 120px; }

/* ---------- login ---------- */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; }
.login-card { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid rgba(255,255,255,0.12); border-radius: 18px; padding: 26px 24px 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.5); animation: rise .35s ease-out; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.login-hero { text-align: center; margin-bottom: 20px; }
.login-hero h1 { margin: 6px 0 4px; font-size: 2rem; letter-spacing: 0.02em; }
.login-hero p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.login-cards { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.lc { width: 40px; height: 56px; border-radius: 6px; background: #fff; color: var(--black); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; box-shadow: 0 4px 10px rgba(0,0,0,0.4); transform: rotate(-8deg) translateY(4px); }
.lc:nth-child(2) { transform: rotate(-3deg); }
.lc:nth-child(3) { transform: rotate(3deg); }
.lc:nth-child(4) { transform: rotate(8deg) translateY(4px); }
.lc.red { color: var(--red); }
.login input { font-size: 1.05rem; padding: 12px 14px; }
.avatar-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.av { aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent; background: rgba(255,255,255,0.06); cursor: pointer; transition: transform .1s, border-color .15s, background .15s; padding: 0; overflow: hidden; }
.av .av-img { width: 100%; height: 100%; display: block; }
.av:hover { transform: scale(1.1); background: rgba(255,255,255,0.12); }
.av.sel { border-color: var(--gold); background: rgba(231,193,90,0.2); transform: scale(1.1); }
.btn.wide { width: 100%; padding: 13px; font-size: 1rem; margin-top: 6px; }
.txt-center { text-align: center; margin: 10px 0 0; }


/* ---------- auth / profile ---------- */
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,0.3); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px 6px; border-radius: 9px; cursor: pointer; font-size: 0.9rem; }
.tab.sel { background: rgba(255,255,255,0.12); color: var(--ink); font-weight: 600; }
.profile-card { max-width: 520px; }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: rgba(255,255,255,0.06); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.stat small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat b { font-size: 1.05rem; }
.stat.big b { font-size: 1.5rem; color: var(--gold); }
.recent { grid-column: 1 / -1; display: grid; gap: 4px; margin-top: 4px; }
.recent > small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.rg { display: grid; grid-template-columns: 20px 1fr 40px 50px 80px; gap: 8px; font-size: 0.82rem; align-items: center; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 4px 8px; }
.pf-more { margin: 6px 0 12px; }
.pf-more summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }

/* ---------- lobby ---------- */
.lobby-head { display: flex; justify-content: space-between; align-items: center; margin: 0 auto 18px; max-width: var(--lobby-w); padding: 0 2px; }
.lobby-right { display: flex; align-items: center; gap: 12px; }
.profile-btn { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15); color: var(--ink); border-radius: 30px; padding: 4px 12px 4px 4px; cursor: pointer; }
.profile-btn:hover { border-color: var(--gold); }
.profile-btn .avatar { width: 30px; height: 30px; background: rgba(255,255,255,0.12); color: var(--ink); font-size: 1rem; }
.mode-switch { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mode-switch .mode { flex: 1; }
.mode { flex: 1; text-align: center; background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.12); color: var(--muted); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 0.9rem; font-weight: 600; line-height: 1; }
.mode:disabled { cursor: default; }
.mode.sel { color: var(--gold); }
.mode.sel { border-color: var(--gold); background: rgba(231,193,90,0.12); }
.mode.sel b { color: var(--gold); }
.brand { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-mark { color: var(--gold); }
:root { --lobby-w: 1100px; }
.lobby-grid { display: grid; gap: 16px; grid-template-columns: 1fr; max-width: var(--lobby-w); margin: 0 auto; align-items: start; }
.lobby-side { display: grid; gap: 16px; }
@media (min-width: 860px) { .lobby-grid:has(.lobby-side:not(.hidden)) { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); } }
.panel-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 2px 10px; }
.lobby-main > .panel-head h3 { font-size: 1.25rem; }
.panel-head h3 { margin: 0; }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius); padding: 18px; }
.panel h3 { margin: 0 0 10px; font-weight: 600; }
.games { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .games { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .games { grid-template-columns: 1fr 1fr 1fr; } }
.game-card { position: relative; border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; padding: 14px; background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(0,0,0,0.25)); display: flex; flex-direction: column; gap: 10px; }
.game-head { display: flex; gap: 14px; align-items: center; }
.game-title { min-width: 0; }
.game-logo { width: 72px; height: 72px; flex-shrink: 0; border-radius: 16px; background: radial-gradient(circle at 30% 25%, #1f7a57, #0b3326); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 6px 14px rgba(0,0,0,0.4); padding: 6px; }
.game-logo svg { width: 100%; height: 100%; display: block; }
.game-body { flex: 1; min-width: 0; }
.game-card h4 { margin: 0 0 6px; font-size: 1.35rem; letter-spacing: 0.01em; }
.game-card h4 small { color: var(--gold); font-weight: 400; margin-left: 8px; font-size: 1rem; }
.game-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.35; }
.game-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.75rem; color: var(--muted); }
.game-meta span { background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 8px; }
.game-card .row { margin-top: 0; }
.game-card .row .btn { flex: 1; white-space: nowrap; }
.game-card.soon { opacity: 0.72; border-style: dashed; background: rgba(0,0,0,0.2); }
.game-card.soon .game-logo { filter: saturate(0.4); background: radial-gradient(circle at 30% 25%, #3a4a44, #151f1b); }
.soon-tag { position: absolute; top: 10px; right: 10px; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: #2b2203; background: var(--gold); padding: 3px 8px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
@media (max-width: 480px) { .game-logo { width: 60px; height: 60px; } }
.rooms { display: grid; gap: 8px; }
.room-row { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); border-radius: 10px; padding: 10px 12px; }
.room-row .meta { font-size: 0.85rem; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }

/* ---------- invitations ---------- */
.invite { background: rgba(231,193,90,0.07); border: 1px solid rgba(231,193,90,0.3); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.invite-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.invite .invite-head { margin: 0; }
.invite-url { font-family: ui-monospace, monospace; font-size: 0.85rem; text-align: center; text-overflow: ellipsis; padding: 10px; }
.invite .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.invite .btn svg { width: 19px; height: 19px; flex-shrink: 0; }
.invite-btns { display: flex; gap: 8px; }
.invite-btns .btn { flex: 1 1 0; min-width: 0; padding-inline: 10px; }
/* WhatsApp: the green button with the WhatsApp logo, no word (the name is there for screen readers and as the tooltip) */
.btn.wa { background: #25d366; color: #fff; border-color: transparent; text-decoration: none; }
.btn.wa:hover { background: #3be07a; }
.btn.wa svg { width: 25px; height: 25px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.invite-banner { background: rgba(231,193,90,0.15); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.92rem; }

/* ---------- waiting room: one calm card — the table with its seats, the invite, the buttons ---------- */
.room-panel { max-width: 520px; margin: 28px auto; padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.room-panel > * { margin: 0; }
.room-panel > .room-friends { margin: 0; }
.room-head { text-align: center; }
.room-head h2 { margin: 0 0 6px; font-size: 1.35rem; line-height: 1.25; }
.room-meta { margin: 0; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.room-panel > .room-stake { margin: 0; text-align: center; }

/* the table, drawn in the player's table theme (html[data-table]); a seat's picture sits on the rim, its name on a plate
   outside the table (over it at the top, under it at the bottom), so the felt keeps the table code */
.seat-table { --av: 54px; --top: 78px; --bot: 78px; --th: 168px; --side: 46px; position: relative; width: 100%; max-width: 460px; height: calc(var(--top) + var(--th) + var(--bot)); margin: 0 auto; }
.seat-table.n2 { --side: 14px; }
.seat-table.n3 { --top: 24px; }
.mini-table { position: absolute; top: var(--top); bottom: var(--bot); left: var(--side); right: var(--side); border-radius: 50%; padding: 9px;
  background: linear-gradient(160deg, var(--tbl-rim-2), var(--tbl-rim) 45%, var(--tbl-rim-3));
  box-shadow: 0 16px 34px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.12) inset, 0 -6px 12px rgba(0,0,0,0.4) inset; }
.mini-felt { position: relative; width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 38%, var(--tbl-felt-2), var(--tbl-felt) 72%);
  box-shadow: inset 0 0 36px rgba(0,0,0,0.5), inset 0 0 0 1.5px color-mix(in srgb, var(--tbl-line) 70%, transparent); }
.mini-felt::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1px dashed var(--tbl-line); opacity: 0.35; pointer-events: none; }
.mt-code { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 14px 7px; border-radius: 12px; background: rgba(0,0,0,0.32); }
.mt-code small { font-size: 0.68rem; color: rgba(255,255,255,0.72); }
.mt-code .code { font-size: 1.3rem; letter-spacing: 0.18em; padding-left: 0.18em; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.mt-mark { font-size: 1.3rem; letter-spacing: 0.15em; color: rgba(255,255,255,0.16); font-weight: 700; }

.tseat { --ring: rgba(255,255,255,0.4); position: absolute; z-index: 1; width: 108px; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tseat.at-b, .tseat.at-t { left: 50%; translate: -50% 0; }
.tseat.at-t { flex-direction: column-reverse; bottom: calc(100% - var(--top) - var(--av) / 2); }
.tseat.at-b { top: calc(var(--top) + var(--th) - var(--av) / 2); }
.tseat.at-l, .tseat.at-r { width: 92px; top: calc(var(--top) + var(--th) / 2 - var(--av) / 2); }
.tseat.at-l { left: calc(var(--side) - 46px); }
.tseat.at-r { right: calc(var(--side) - 46px); }
.tseat.t0 { --ring: #8fd3ff; }
.tseat.t1 { --ring: #ffb37a; }
.tseat.me { cursor: default; }
.tseat.me:not(.t0):not(.t1) { --ring: var(--gold); }
.ts-pic { position: relative; width: var(--av); height: var(--av); border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 3px var(--ring), 0 6px 14px rgba(0,0,0,0.45); transition: transform .15s, background .15s; }
.ts-pic .avatar { width: 100%; height: 100%; background: #1f7a57; }
.ts-pic .avatar.bot { background: #2c4a3f; }
.ts-lvl { position: absolute; top: -5px; inset-inline-end: -7px; margin: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.ts-name { max-width: 100%; padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,0.6); font-size: 0.82rem; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tseat.me .ts-name { box-shadow: inset 0 0 0 1.5px var(--gold); }
.ts-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 100%; margin-top: -1px; }
.ts-tags .tag { font-size: 0.64rem; line-height: 1; padding: 3px 6px; border-radius: 6px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.14); white-space: nowrap; }
.ts-tags .tag.you, .ts-tags .tag.gold { background: var(--gold); color: #2b2203; border-color: transparent; font-weight: 700; }
.ts-tags .tag.off { color: #ffb4ad; }
.tseat.off .ts-pic { opacity: 0.55; }
/* an empty seat: a dashed ring in its team's colour, a plus, "Sit here" */
.tseat.empty .ts-pic { box-shadow: none; border: 2px dashed var(--ring); background: rgba(0,0,0,0.3); color: var(--ring); display: flex; align-items: center; justify-content: center; }
.tseat.empty .ts-pic svg { width: 22px; height: 22px; }
.tseat.empty .ts-name { background: rgba(0,0,0,0.42); color: var(--muted); font-weight: 500; }
.tseat.empty:hover .ts-pic, .tseat.empty:focus-visible .ts-pic { background: rgba(255,255,255,0.12); transform: scale(1.06); }
.tseat:not(.me):not(.empty):hover .ts-pic { transform: scale(1.05); }
.tseat:focus-visible { outline: none; }
.tseat:focus-visible .ts-name { outline: 2px solid var(--gold); outline-offset: 1px; }
.tseat.pop .ts-pic { animation: ts-in .3s ease-out; }
@keyframes ts-in { from { scale: 0.6; opacity: 0.2; } to { scale: 1; opacity: 1; } }

.seat-hint { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 0.82rem; text-align: center; margin-top: -6px !important; }
.team-legend { display: inline-flex; gap: 12px; }
.team-legend:empty { display: none; }
.tl { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.tl::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.tl.t0 { color: #8fd3ff; }
.tl.t1 { color: #ffb37a; }
.room-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.room-actions #btn-leave { min-width: 96px; }
.room-actions #btn-start { grid-column: 1 / -1; padding: 13px; font-size: 1.02rem; }
.room-note { text-align: center; margin-top: -6px !important; }
@media (max-width: 480px) {
  .room-panel { margin: 4px auto 16px; padding: 16px 14px 14px; gap: 12px; }
  .room-head h2 { font-size: 1.2rem; }
  .seat-table { --av: 50px; --top: 74px; --bot: 74px; --th: 160px; --side: 44px; }
  .seat-table.n2 { --side: 12px; }
  .seat-table.n3 { --top: 22px; }
  .mt-code .code { font-size: 1.12rem; }
}
.team.t0, .tm.t0 b { color: #8fd3ff; }
.team.t1, .tm.t1 b { color: #ffb37a; }
.badge.gold { background: var(--gold); color: #2b2203; }
.player.team0 .avatar { box-shadow: 0 0 0 2px #8fd3ff; }
.player.team1 .avatar { box-shadow: 0 0 0 2px #ffb37a; }
.hud-teams { gap: 10px !important; }
.hud-teams .tm { display: flex; flex-direction: column; line-height: 1.1; }
.hud-teams .tm b, .team-sum .tm b { font-size: 1.1rem; }
.hud-teams .vs, .team-sum .vs { color: var(--muted); font-size: 0.75rem; }
.team-sum { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
.team-sum .tm { text-align: center; background: rgba(255,255,255,0.06); border-radius: 10px; padding: 8px 14px; display: flex; flex-direction: column; }
.team-sum .tm small { color: var(--muted); font-size: 0.72rem; }
.team-sum .tm b { font-size: 1.4rem; }
.team-sum .tm span { font-size: 0.75rem; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #2b2203; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.avatar .av-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar.tiny { width: 22px; height: 22px; vertical-align: middle; }
.avatar.bot { background: rgba(255,255,255,0.12); }

/* ---------- table ---------- */
#screen-table { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 8px; }
/* an admin watching a table (body.watching): a badge in the bar, nothing to play with */
#watch-badge { display: none; align-self: center; white-space: nowrap; }
body.watching #watch-badge { display: inline-flex; }
body.watching .hand-wrap, body.watching #race-actions, body.watching #hand-actions, body.watching #wahed-actions, body.watching #tawla-actions, body.watching #domino-actions, body.watching #chess-actions, body.watching .choose-bar, body.watching #btn-auto, body.watching #btn-table, body.watching #btn-emote, body.watching .die-label { display: none !important; }
body.watching .center, body.watching .seat, body.watching .die-box { pointer-events: none; }
/* an admin looking at a saved table (body.replay): the real table with the seat's own hand, nothing to play with, and
   every seat's hand in a panel at the top (tap a player there to see the table from their seat) */
body.replay #btn-auto, body.replay #btn-table, body.replay #btn-emote { display: none !important; }
body.replay .hand-wrap, body.replay .center, body.replay .seat, body.replay .choose-bar, body.replay .die-box, body.replay [id$="-actions"] { pointer-events: none; }
#replay-panel { position: fixed; top: 58px; left: 8px; right: 8px; margin: 0 auto; max-width: 640px; max-height: 46vh; overflow: auto; z-index: 40; background: rgba(6, 22, 16, 0.95); border: 1px solid rgba(231, 193, 90, 0.45); border-radius: var(--radius); padding: 8px 10px; font-size: 0.82rem; color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
#replay-panel summary { cursor: pointer; font-weight: 700; color: var(--gold); }
#replay-panel .rp-note { color: var(--muted); font-size: 0.74rem; margin: 4px 0 6px; }
.rp-seat { display: flex; gap: 8px; align-items: baseline; width: 100%; text-align: start; background: rgba(255, 255, 255, 0.04); border: 1px solid transparent; border-radius: 8px; color: var(--ink); padding: 5px 8px; margin-top: 4px; cursor: pointer; font: inherit; }
.rp-seat.sel { border-color: var(--gold); background: rgba(231, 193, 90, 0.12); }
.rp-seat b { flex: 0 0 auto; min-width: 76px; }
.rp-hand { display: flex; flex-wrap: wrap; gap: 3px; }
.rp-c { display: inline-block; padding: 0 4px; border-radius: 4px; background: #f3efe4; color: var(--black); font-weight: 700; font-size: 0.78rem; line-height: 1.5; }
.rp-c.red { color: var(--red); }
.rp-c.w-R { background: #d8473d; color: #fff; }
.rp-c.w-G { background: #3c9a5f; color: #fff; }
.rp-c.w-B { background: #3b6fd1; color: #fff; }
.rp-c.w-Y { background: #e8c23a; color: var(--black); }
.rp-c.w-X { background: var(--black); color: #fff; }
/* the table's top bar: the same dark band as the app's own bars, edge to edge (over the screen's padding and the notch), the buttons and the status on it */
.table-top { display: flex; gap: 8px; align-items: center; position: relative; z-index: 25; /* stays clickable above modal backdrops, so Leave / Sound always work */
  margin: calc(-8px - var(--sat)) calc(-8px - var(--sar)) 0 calc(-8px - var(--sal)); padding: calc(6px + var(--sat)) calc(10px + var(--sar)) 6px calc(10px + var(--sal));
  background: #071f16; border-bottom: 1px solid rgba(231, 193, 90, 0.2); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }
.table-top .btn { margin-top: 0; }
.table-top .hud > div { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
/* the room around the table: the table's own colour, but darker than the felt, so the table stands out */
#screen-table { background: #0a271d; background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--tbl-felt) 72%, #000), color-mix(in srgb, var(--tbl-felt) 45%, #000) 75%); }
/* the score box is the scoreboard's button: while it is on the table, the Scores button leaves the bar */
#screen-table.scorebox-on #btn-scores { display: none; }
.scorebox { cursor: pointer; }
.hud { flex: 1; display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.hud > div { background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 6px 12px; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.hud small { color: var(--muted); font-size: 0.72rem; }
.hud b { color: var(--ink); }
.hud-round { flex-direction: row; gap: 4px; }
.hud-round b { font-size: 1.25rem; line-height: 1; }
.hud-contract { flex-direction: column; align-items: flex-start !important; gap: 0 !important; justify-content: center; max-width: 420px; }
.hud-contract b { color: var(--gold); font-size: 1rem; }
.hud-contract .ar { color: var(--gold); opacity: 0.85; margin-left: 8px; font-size: 0.9rem; }
.hud-contract .rule { display: block; line-height: 1.2; margin-top: 2px; }
.hud-king .crown { font-size: 1.2rem; }
.hud-king > div { display: flex; flex-direction: column; line-height: 1.1; }
.hud-king > .kdots { flex-direction: row !important; display: flex; gap: 4px; margin-left: 6px; }
.kdot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.45); background: transparent; }
.kdot.done { background: rgba(255,255,255,0.45); }
.kdot.cur { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 6px var(--gold); }
@media (max-width: 760px) { .hud { gap: 6px; } .hud-contract .rule { display: none; } .hud > div { min-height: 32px; padding: 3px 9px; border-radius: 9px; } .hud-contract b { font-size: 0.85rem; } .hud-contract .ar { font-size: 0.8rem; margin-left: 6px; } .hud-round b { font-size: 1rem; } .hud-king small { display: none; } .hud-king .crown { font-size: 1rem; } .hud-king > div b { font-size: 0.85rem; } }

.table { position: relative; flex: 1; min-height: 260px; margin: 6px 0; }
/* the physical table: wooden rim + felt top. Theme colours come from html[data-table]. */
.table-surface { position: absolute; left: 70px; right: 70px; top: 38px; bottom: 38px; border-radius: 50%; padding: 14px;
  background: linear-gradient(160deg, var(--tbl-rim-2), var(--tbl-rim) 45%, var(--tbl-rim-3) 100%);
  box-shadow: 0 24px 50px rgba(0,0,0,0.55), 0 2px 0 rgba(255,255,255,0.12) inset, 0 -8px 16px rgba(0,0,0,0.45) inset; }
.table-surface::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.14); pointer-events: none; }
.felt { width: 100%; height: 100%; border-radius: 50%; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 38%, var(--tbl-felt-2), var(--tbl-felt) 72%);
  box-shadow: inset 0 0 48px rgba(0,0,0,0.5), inset 0 0 0 2px var(--tbl-line), inset 0 0 0 7px transparent, inset 0 0 0 8px rgba(255,255,255,0.05); }
.felt::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; border: 1px dashed var(--tbl-line); opacity: 0.55; }
.felt::after { content: "♠ ♥ ♣ ♦"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(40px, 9vw, 96px); letter-spacing: 0.15em; color: var(--tbl-mark); font-weight: 700; pointer-events: none; }
.seat { z-index: 2; }
.center { z-index: 1; }
@media (max-width: 760px) { .table-surface { left: 24px; right: 24px; top: 44px; bottom: 44px; padding: 9px; } }

/* ---- themes: the felt and the rim, on the page (html[data-table]) and on any swatch or store card with data-table ---- */
:root { --tbl-felt: #0f4a35; --tbl-felt-2: #1f7a57; --tbl-rim: #5a3a1e; --tbl-rim-2: #8a5b31; --tbl-rim-3: #3b2411; --tbl-line: #d8b85a; --tbl-mark: rgba(255,255,255,0.06); }
[data-table="classic"] { --tbl-felt: #0f4a35; --tbl-felt-2: #1f7a57; --tbl-rim: #5a3a1e; --tbl-rim-2: #8a5b31; --tbl-rim-3: #3b2411; --tbl-line: #d8b85a; --tbl-mark: rgba(255,255,255,0.06); }
[data-table="royal"] { --tbl-felt: #10305e; --tbl-felt-2: #1f5aa8; --tbl-rim: #2b2b33; --tbl-rim-2: #4a4a55; --tbl-rim-3: #16161b; --tbl-line: #c9d6ef; --tbl-mark: rgba(255,255,255,0.07); }
[data-table="burgundy"] { --tbl-felt: #4a0f1c; --tbl-felt-2: #8a1f36; --tbl-rim: #3a2416; --tbl-rim-2: #6b4328; --tbl-rim-3: #22140b; --tbl-line: #e3c27a; --tbl-mark: rgba(255,255,255,0.06); }
[data-table="midnight"] { --tbl-felt: #0c0f1a; --tbl-felt-2: #232a45; --tbl-rim: #1b1d26; --tbl-rim-2: #34384a; --tbl-rim-3: #0b0c12; --tbl-line: #6fa8ff; --tbl-mark: rgba(111,168,255,0.08); }
[data-table="desert"] { --tbl-felt: #8a5a2b; --tbl-felt-2: #c98a45; --tbl-rim: #2f2a26; --tbl-rim-2: #5a5047; --tbl-rim-3: #1a1714; --tbl-line: #ffe6b0; --tbl-mark: rgba(255,230,176,0.12); }
[data-table="emerald"] { --tbl-felt: #053d2c; --tbl-felt-2: #0e7a55; --tbl-rim: #a8832e; --tbl-rim-2: #e2c15b; --tbl-rim-3: #6b511a; --tbl-line: #f1d77a; --tbl-mark: rgba(241,215,122,0.08); }
[data-table="sunset"] { --tbl-felt: #5a1f4a; --tbl-felt-2: #d9693a; --tbl-rim: #3a2416; --tbl-rim-2: #6b4328; --tbl-rim-3: #22140b; --tbl-line: #ffd9a0; --tbl-mark: rgba(255,217,160,0.1); }
[data-table="ocean"] { --tbl-felt: #0b3f54; --tbl-felt-2: #1d8aa8; --tbl-rim: #3e3e3e; --tbl-rim-2: #6a6a6a; --tbl-rim-3: #242424; --tbl-line: #bfeeff; --tbl-mark: rgba(191,238,255,0.09); }
[data-table="rose"] { --tbl-felt: #6e1f3f; --tbl-felt-2: #b8456f; --tbl-rim: #2b2b33; --tbl-rim-2: #4a4a55; --tbl-rim-3: #16161b; --tbl-line: #ffd1e0; --tbl-mark: rgba(255,209,224,0.1); }
[data-table="olive"] { --tbl-felt: #3a4414; --tbl-felt-2: #7a8a2e; --tbl-rim: #3a2416; --tbl-rim-2: #6b4328; --tbl-rim-3: #22140b; --tbl-line: #e8e0a0; --tbl-mark: rgba(232,224,160,0.1); }
[data-table="charcoal"] { --tbl-felt: #1c1c21; --tbl-felt-2: #3b3b45; --tbl-rim: #0e0e12; --tbl-rim-2: #2a2a33; --tbl-rim-3: #06060a; --tbl-line: #c9a84a; --tbl-mark: rgba(201,168,74,0.1); }
[data-table="majlis"] { --tbl-felt: #6e1414; --tbl-felt-2: #b53a2e; --tbl-rim: #a8832e; --tbl-rim-2: #e2c15b; --tbl-rim-3: #6b511a; --tbl-line: #f1d77a; --tbl-mark: rgba(241,215,122,0.1); }

/* ---- theme picker ---- */
.table-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.table-picker.big { grid-template-columns: repeat(3, 1fr); margin: 10px 0 14px; }
.swatch { background: transparent; border: 2px solid transparent; border-radius: 10px; padding: 6px 4px; cursor: pointer; color: var(--muted); font-size: 0.68rem; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: border-color .15s, transform .1s; }
.swatch:hover { transform: translateY(-2px); color: var(--ink); }
.swatch.sel { border-color: var(--gold); color: var(--ink); background: rgba(231,193,90,0.1); }
.swatch-rim { display: block; width: 100%; aspect-ratio: 5 / 3; border-radius: 50%; padding: 4px; background: linear-gradient(160deg, var(--tbl-rim-2), var(--tbl-rim) 45%, var(--tbl-rim-3)); box-shadow: 0 4px 10px rgba(0,0,0,0.45); }
.swatch-felt { display: block; width: 100%; height: 100%; border-radius: 50%; background: radial-gradient(ellipse at 50% 38%, var(--tbl-felt-2), var(--tbl-felt) 72%); box-shadow: inset 0 0 0 1px var(--tbl-line), inset 0 0 10px rgba(0,0,0,0.5); }
.table-picker.big .swatch { font-size: 0.8rem; }
@media (max-width: 480px) { .table-picker { grid-template-columns: repeat(3, 1fr); } }
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 90px; }
.seat-top { top: 20px; left: 50%; transform: translateX(-50%); } /* low enough that the partner's fan of card backs stays inside the table, under the top bar */
.seat-left { left: 6px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 6px; top: 50%; transform: translateY(-50%); }
.seat-bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.player { position: relative; background: rgba(6, 14, 10, 0.72); border-radius: 40px 16px 16px 40px; padding: 5px 14px 5px 5px; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,0.12); box-shadow: 0 6px 16px rgba(0,0,0,0.35); transition: border-color .2s, box-shadow .2s; }
.player.turn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(231,193,90,0.55); }
.player.me { background: rgba(10, 24, 18, 0.85); }
.player.offline { opacity: 0.65; }
.ring { --p: 0; position: relative; width: 46px; height: 46px; border-radius: 50%; padding: 3px; flex-shrink: 0;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(255,255,255,0.12) 0); transition: background .1s linear; }
.ring.urgent { background: conic-gradient(var(--red) calc(var(--p) * 1%), rgba(255,255,255,0.12) 0); animation: pulse .5s infinite alternate; }
.ring .avatar { width: 100%; height: 100%; font-size: 1.05rem; border: 2px solid rgba(0,0,0,0.5); background: #1f7a57; }
.crown-badge { position: absolute; top: -9px; right: -6px; font-size: 15px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.off-badge { position: absolute; bottom: -4px; right: -4px; font-size: 11px; background: var(--red); color: #fff; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }
.pinfo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pname { font-weight: 600; font-size: 0.92rem; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.pname small { color: var(--muted); font-weight: 400; }
.pmeta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; line-height: 1; }
.pmeta .score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.pmeta .score.neg { color: #ff9b94; }
.pmeta .score.pos { color: #8fe3a8; }
.pmeta .delta { font-size: 0.72rem; padding: 1px 5px; border-radius: 6px; background: rgba(255,255,255,0.1); }
.pmeta .delta.neg { color: #ff9b94; }
.pmeta .delta.pos { color: #8fe3a8; }
.pmeta .cards { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cb { display: inline-block; width: 11px; height: 15px; border-radius: 2px; background: repeating-linear-gradient(135deg, #2b4f9e 0 2px, #4a6fc0 2px 4px); border: 1px solid #dfe6ff; box-shadow: 2px 0 0 -1px #dfe6ff, 2px 0 0 0 #2b4f9e; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.55; } }
.seat-bottom .pname { max-width: 200px; }
.penalties { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 170px; }
.mini { font-size: 0.7rem; background: #fff; color: var(--black); border-radius: 3px; padding: 1px 4px; font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.mini.red { color: var(--red); }
.chip { font-size: 0.68rem; background: rgba(0,0,0,0.5); color: var(--ink); border-radius: 8px; padding: 2px 7px; border: 1px solid rgba(255,255,255,0.15); }
.chip.gold { background: var(--gold); color: #2b2203; font-weight: 600; border-color: transparent; }
.chip.proj { background: #c9b6ff; color: #1f0f4a; font-weight: 700; border-color: transparent; }
.chip.rank { background: #8fe3a8; color: #0b2a14; font-weight: 700; border-color: transparent; }
.cards-left { font-size: 0.75rem; color: var(--muted); }

.center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.trick { position: relative; width: 200px; height: 200px; }
.trick .card { position: absolute; left: 50%; top: 50%; margin-left: calc(var(--card-w) / -2); margin-top: calc(var(--card-h) / -2); animation: drop .25s ease-out; }
.trick .card[data-rel="0"] { transform: translateY(44px); }
.trick .card[data-rel="1"] { transform: translateX(-54px); }
.trick .card[data-rel="2"] { transform: translateY(-44px); }
.trick .card[data-rel="3"] { transform: translateX(54px); }
@keyframes drop { from { opacity: 0; scale: 1.15; } to { opacity: 1; scale: 1; } }

/* trix board: one column per suit (♠ ♥ ♣ ♦), A at the top down to 2; each card overlaps the one above and leaves its corner (rank + suit) visible.
   The smallest card is 40px, less on a short phone (under ~660px tall), so a full column stays between the top player's name and your seat */
.board { --bc-w: clamp(min(40px, calc((100dvh - 410px) / 6.4)), min(calc((100vw - 236px) / 4), calc((100dvh - 380px) / 6.4)), 64px); --bc-h: calc(var(--bc-w) * 1.4); --step: calc(var(--bc-h) * 0.3);
  display: flex; gap: calc(var(--bc-w) * 0.14); direction: ltr; height: calc(var(--step) * 12 + var(--bc-h)); }
.board-col { position: relative; width: var(--bc-w); height: 100%; }
.bslot { position: absolute; left: 0; top: calc(var(--i) * var(--step)); }
.bslot .card { width: var(--bc-w); height: var(--bc-h); border-radius: calc(var(--bc-w) * 0.1); box-shadow: 0 1px 4px rgba(0,0,0,0.45); }
.bslot .card .c { left: calc(var(--bc-w) * 0.08); top: calc(var(--bc-h) * 0.04); font-size: calc(var(--bc-w) * 0.3); }
.bslot .card .c small { display: inline; margin-inline-start: 1px; font-size: calc(var(--bc-w) * 0.24); }
.bslot .card .m { font-size: calc(var(--bc-w) * 0.5); padding-top: calc(var(--bc-h) * 0.18); }
.bslot .card .c2 { display: none; }
.bslot .card.end { box-shadow: 0 0 0 2px var(--gold), 0 2px 6px rgba(0,0,0,0.5); }
.bslot .card.fresh { animation: drop .25s ease-out; }
.bslot .ghost-j { background: rgba(255,255,255,0.06); border: 1.5px dashed rgba(255,255,255,0.45); box-shadow: none; color: rgba(255,255,255,0.7); }
.bslot .ghost-j.red { color: rgba(255,155,148,0.85); }
/* the faint suit watermark would show through the columns */
.board-mode .felt::after { opacity: 0; }

/* ---------- cards ---------- */
.card { width: var(--card-w); height: var(--card-h); border-radius: 7px; background: #fff; color: var(--black); box-shadow: 0 2px 6px rgba(0,0,0,0.4); position: relative; user-select: none; font-weight: 700; flex-shrink: 0; }
.card.red { color: var(--red); }
.card .c { position: absolute; left: 5px; top: 3px; font-size: 0.85rem; line-height: 1; }
.card .c small { display: block; font-size: 0.85rem; }
.card .m { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; }
.card .c2 { position: absolute; right: 5px; bottom: 3px; font-size: 0.85rem; line-height: 1; transform: rotate(180deg); }
.card .c2 small { display: block; font-size: 0.85rem; }
.card.doubled::before { content: "×2"; position: absolute; top: -8px; right: -8px; background: var(--red); color: #fff; font-size: 0.65rem; border-radius: 10px; padding: 1px 5px; z-index: 2; }

.hand-wrap { padding: 6px 0 4px; position: relative; z-index: 6; }
.hand { display: flex; justify-content: center; align-items: flex-end; height: calc(var(--card-h) + 22px); }
.hand .card { margin-left: calc(var(--card-w) * -0.42); cursor: default; transition: transform .12s, filter .12s; filter: brightness(0.55); }
.hand .card:first-child { margin-left: 0; }
.hand .card.legal { filter: none; cursor: pointer; }
.hand .card.legal:hover { transform: translateY(-14px); }
.hand.idle .card { filter: none; }
@media (max-width: 480px) { :root { --card-w: 48px; --card-h: 70px; } .hand .card { margin-left: calc(var(--card-w) * -0.5); } .card .m { font-size: 1.5rem; } .seat-left, .seat-right { top: 40%; } }

.log { position: fixed; left: 12px; bottom: 200px; width: min(300px, 70vw); background: rgba(6, 14, 10, 0.78); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 6px 0 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 5; }
.log-head { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 2px 12px 5px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 4px; }
.log-item { position: relative; font-size: 0.78rem; line-height: 1.3; padding: 3px 12px 3px 24px; color: var(--muted); opacity: 0.6; }
.log-item::before { content: ""; position: absolute; left: 11px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.35); }
.log-item:nth-last-child(2) { opacity: 0.8; }
.log-item.new { color: var(--ink); opacity: 1; font-weight: 500; animation: logIn .25s ease-out; }
.log-item.new::before { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.log-item b { font-weight: 700; color: var(--ink); }
.log-item b.red { color: #ff9b94; }
@keyframes logIn { from { transform: translateX(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) {
  .log { position: static; width: auto; margin: 4px 0 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .log-head { display: none; }
  .log-item { display: none; padding: 5px 12px 5px 24px; background: rgba(0,0,0,0.35); border-radius: 10px; }
  .log-item.new { display: block; }
}

/* ---------- auto & player card ---------- */
.btn.on { background: var(--gold); color: #2b2203; border-color: transparent; font-weight: 600; }
.chip.auto { background: rgba(231,193,90,0.2); color: var(--gold); border-color: rgba(231,193,90,0.5); }
.player { cursor: pointer; }
.player:hover { border-color: rgba(255,255,255,0.4); }
.pcard { max-width: 440px; }
.pc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pc-head h3 { margin: 0 0 4px; }
.pc-head > div:nth-child(2) { flex: 1; min-width: 0; }
.pc-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.avatar.big { width: 56px; height: 56px; font-size: 1.5rem; border: 2px solid rgba(255,255,255,0.3); }
.pc-score { text-align: right; line-height: 1; }
.pc-score b { font-size: 1.7rem; display: block; }
.pc-score small { color: var(--muted); font-size: 0.72rem; }
.pc-score.neg b { color: #ff9b94; }
.pc-score.pos b { color: #8fe3a8; }
.pc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pc-grid > div { background: rgba(255,255,255,0.06); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.pc-grid small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.pc-grid b { font-size: 1.1rem; }
.pc-grid b.neg { color: #ff9b94; }
.pc-grid b.pos { color: #8fe3a8; }
.pc-section { margin-bottom: 12px; }
.pc-section > small { display: block; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.pc-pen { display: flex; gap: 4px; flex-wrap: wrap; }
.rbars { display: flex; gap: 3px; align-items: flex-end; height: 48px; padding: 0 2px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.rbar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.rbar span { display: block; width: 100%; border-radius: 2px 2px 0 0; }
.rbar span.pos { background: #8fe3a8; }
.rbar span.neg { background: #ff9b94; }
@media (max-width: 480px) { .pc-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- tarneeb ---------- */
.bid-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 0; }
.bid { aspect-ratio: 1; max-height: 76px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: var(--ink); font-size: 1.5rem; font-weight: 700; cursor: pointer; position: relative; font-family: inherit; }
.bid.pass { font-size: 1rem; color: var(--muted); background: transparent; border-style: dashed; }
.bid.pass:hover { color: var(--ink); }
.bid:hover:not(:disabled) { border-color: var(--gold); background: rgba(231,193,90,0.2); }
.bid.off { opacity: 0.3; cursor: default; }
.bid small { position: absolute; top: 3px; right: 5px; font-size: 0.6rem; color: var(--gold); }
.trump-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.trump { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2); background: #fff; color: var(--black); cursor: pointer; }
.trump.red { color: var(--red); }
.trump span { font-size: 2.2rem; line-height: 1; }
.trump small { color: #555; font-size: 0.72rem; }
.trump:hover { border-color: var(--gold); transform: translateY(-2px); }
/* sideways on a phone: the bids in one row of eight, the four suits in one row, less air around them */
@media (orientation: landscape) and (max-height: 500px) {
  .bid-list { grid-template-columns: repeat(8, 1fr); gap: 6px; }
  .bid { font-size: 1.25rem; }
  .trump-list { grid-template-columns: repeat(4, 1fr); }
  .trump { padding: 8px 4px; }
  .trump span { font-size: 1.8rem; }
  .modal .modal-card h3 { margin-bottom: 6px; }
}
.hud-teams .tm em { font-style: normal; font-size: 0.68rem; color: var(--muted); }

/* ---------- baloot ---------- */
.upcard-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upcard-wrap small { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.upcard-wrap .card { animation: drop .3s ease-out; box-shadow: 0 0 0 2px var(--gold), 0 6px 16px rgba(0,0,0,0.5); }
.baloot-up { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.baloot-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.bcall { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2); background: #fff; color: var(--black); cursor: pointer; }
.bcall.red { color: var(--red); }
.bcall.sun { background: linear-gradient(160deg, #ffe9a6, #e7b93a); color: #4a3200; }
.bcall.ashkal { background: linear-gradient(160deg, #e2f2ff, #9fd0ff); color: #0d2a4a; }
.bcall.gahwa { background: linear-gradient(160deg, #3b2412, #7a4a24); color: #fff; }
.bcall.gahwa small { color: #f1d7b0; }
.bcall span { font-size: 2rem; line-height: 1; }
.bcall b { font-size: 1rem; }
.bcall small { color: #555; font-size: 0.7rem; text-align: center; }
.bcall:hover { border-color: var(--gold); transform: translateY(-2px); }

@media (max-height: 700px) { .log { bottom: 150px; } .log-item:not(.new):not(:nth-last-child(2)) { display: none; } }

/* ---------- hand: table melds ---------- */
.hand-center { display: flex; flex-direction: column; align-items: center; gap: 12px; pointer-events: auto; max-width: 70vw; }
.table-melds { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; max-height: 34vh; overflow: auto; padding: 4px; --card-w: 34px; --card-h: 48px; }
.tmeld { position: relative; display: flex; align-items: center; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 6px 8px 6px 4px; gap: 0; transition: box-shadow .15s, transform .1s; }
.tmeld .card { margin-left: -13px; border-radius: 4px; }
.tmeld .card:first-of-type { margin-left: 0; }
.tmeld .card .m { font-size: 0.95rem; }
.tmeld .card .c, .tmeld .card .c2 { font-size: 0.55rem; }
.tmeld .card.joker .as { display: none; }
.tmeld .owner { margin-right: 6px; }
.tmeld .owner .avatar { width: 20px; height: 20px; font-size: 0.7rem; }
.tmeld small { margin-left: 6px; color: var(--muted); font-size: 0.68rem; white-space: nowrap; }
.tmeld.prov { border-style: dashed; border-color: var(--gold); }
.tmeld.mine { background: rgba(231,193,90,0.08); }
.tmeld.laytarget { cursor: pointer; box-shadow: 0 0 0 2px rgba(143,227,168,0.6); }
.tmeld.laytarget:hover, .tmeld.over { box-shadow: 0 0 0 3px #8fe3a8; transform: translateY(-2px); }
.tmeld.takeback { cursor: pointer; }
.tmeld.takeback::after { content: "↩ take back"; position: absolute; right: 6px; top: -9px; font-size: 0.6rem; background: var(--gold); color: #2b2203; border-radius: 6px; padding: 1px 5px; font-weight: 700; }
.first-meld .crown { font-weight: 900; color: var(--gold); font-size: 1rem; }
.first-meld.ok { border-color: #8fe3a8 !important; }
.first-meld.ok b { color: #8fe3a8; }
.drop-grp { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); background: #8fe3a8; color: #0b2a14; border: 0; border-radius: 8px; font-size: 0.66rem; font-weight: 800; padding: 2px 8px; cursor: pointer; z-index: 3; white-space: nowrap; }
.drop-grp:hover { background: #b6f0c9; }
.hand.rummy .grp.droppable { padding-top: 12px; }
@media (max-width: 560px) { .table-melds { --card-w: 26px; --card-h: 36px; max-height: 28vh; } .tmeld .card { margin-left: -10px; } .tmeld small { display: none; } .hand-center { max-width: 92vw; } }

/* ---------- hand (rummy) ---------- */
.piles { display: flex; gap: 28px; align-items: flex-end; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; cursor: default; }
.pile small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; }
.pile.active { cursor: pointer; }
.pile.active .card, .pile.drop .card { box-shadow: 0 0 0 3px var(--gold), 0 6px 16px rgba(0,0,0,0.5); }
.pile.active:hover .card { transform: translateY(-4px); }
.card.back { background: repeating-linear-gradient(135deg, #2b4f9e 0 4px, #4a6fc0 4px 8px); border: 3px solid #fff; display: flex; align-items: center; justify-content: center; }
.card.back span { background: rgba(0,0,0,0.55); color: #fff; font-size: 0.8rem; padding: 2px 7px; border-radius: 8px; }
.card.empty { background: transparent; border: 2px dashed rgba(255,255,255,0.3); box-shadow: none; }
.card.joker { color: #6b3fc9; background: linear-gradient(160deg, #fff 0%, #f3edff 100%); }
.card.joker .c, .card.joker .c2 { font-weight: 800; letter-spacing: 0.02em; }
.card.joker .m { font-size: 1.9rem; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; gap: 2px; }
.card.joker .m small { font-size: 0.5rem; letter-spacing: 0.14em; font-weight: 800; color: #6b3fc9; }
.card.joker .as { position: absolute; left: 4px; top: 30px; background: #6b3fc9; color: #fff; font-size: 0.7rem; font-weight: 800; padding: 2px 7px; border-radius: 8px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
.card.joker .as.red { background: var(--red); }
.hand.rummy { --card-w: 72px; --card-h: 104px; height: auto; flex-wrap: nowrap; padding-top: 12px; justify-content: center; align-items: flex-end; gap: 0; overflow: visible; }
.hand.rummy .card { margin-left: calc(var(--card-w) * -0.45); cursor: pointer; filter: none; transition: transform .12s; border-radius: 8px; }
.hand.rummy .card .m { font-size: 2.3rem; }
.hand.rummy .card .c, .hand.rummy .card .c2 { font-size: 1rem; }
.hand.rummy .card .c small, .hand.rummy .card .c2 small { font-size: 1rem; }
.hand.rummy .card:hover { transform: translateY(-8px); }
.hand.rummy .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,0.5); z-index: 2; }
.hand.rummy .card.goout::after { content: "✓"; position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: #8fe3a8; color: #0b2a14; font-size: 0.65rem; font-weight: 800; border-radius: 10px; padding: 1px 6px; }
.hand.rummy .card.taken { outline: 2px dashed var(--red); outline-offset: -2px; }
.hand.rummy .grp { display: flex; position: relative; margin: 0; padding: 0; }
.hand.rummy .grp + .grp .card:first-child { margin-left: calc(var(--card-w) * -0.45); }
/* a recognised meld: red corner tab on every card of the group + a hair of space around it */
.hand.rummy .grp.meld { margin: 0 5px; }
.hand.rummy .grp.meld .card:first-child, .hand.rummy .grp.meld + .grp .card:first-child { margin-left: 0; }
.hand.rummy .grp.meld .card { box-shadow: inset 0 4px 0 #8fe3a8, 0 2px 6px rgba(0,0,0,0.4); }
.hand.rummy .grp.meld .card.sel { box-shadow: inset 0 4px 0 #8fe3a8, 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,0.5); }
.hand.rummy .grp.meld::after { content: attr(data-label); position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); font-size: 0.62rem; font-weight: 800; color: #8fe3a8; letter-spacing: 0.06em; white-space: nowrap; }
@media (max-width: 900px) { .hand.rummy { --card-w: 56px; --card-h: 82px; } .hand.rummy .card .m { font-size: 1.7rem; } .hand.rummy .card .c, .hand.rummy .card .c2, .hand.rummy .card .c small, .hand.rummy .card .c2 small { font-size: 0.8rem; } }
@media (max-width: 560px) { .hand.rummy { --card-w: 44px; --card-h: 64px; } .hand.rummy .card { margin-left: calc(var(--card-w) * -0.5); } .hand.rummy .card .m { font-size: 1.2rem; } .hand.rummy .grp.meld .card { box-shadow: inset 0 4px 0 #8fe3a8, 0 2px 6px rgba(0,0,0,0.4); } }
.hand.rummy .grp.meld .card.sel { box-shadow: inset 0 4px 0 #8fe3a8, 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,0.5); }
.hand.rummy .card.new { box-shadow: 0 0 0 2px #8fd3ff, 0 2px 6px rgba(0,0,0,0.4); }
.hand-actions { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 22px; }
.hand-actions .btn.primary { font-size: 1rem; padding: 8px 18px; }
.melds { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 12px; --card-w: 36px; --card-h: 52px; }
.meld { display: flex; background: rgba(255,255,255,0.06); border-radius: 8px; padding: 4px; }
.meld .card { margin-left: -14px; }
.meld .card:first-child { margin-left: 0; }
.meld .card .m { font-size: 1rem; }
.meld .card .c, .meld .card .c2 { font-size: 0.6rem; }
.hand .card { touch-action: none; }
.table.drop-ready .felt { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35), inset 0 0 48px rgba(0,0,0,0.5); }
.table.drop-ready.over.playable .felt { box-shadow: inset 0 0 0 4px #8fe3a8, inset 0 0 60px rgba(143,227,168,0.25); }
.table.drop-ready.over.prepare .felt { box-shadow: inset 0 0 0 4px var(--gold), inset 0 0 60px rgba(231,193,90,0.2); }
.card.dragging { position: fixed !important; z-index: 100; pointer-events: none; transform: scale(1.08) rotate(-4deg); box-shadow: 0 14px 30px rgba(0,0,0,0.6); margin: 0 !important; }
.card.placeholder { opacity: 0.25; }
.pile.discard.over .card, .pile.discard.over .card.empty { box-shadow: 0 0 0 4px #8fe3a8, 0 6px 16px rgba(0,0,0,0.5); transform: scale(1.06); }
.hand .card.prepared { transform: translateY(-14px); box-shadow: 0 0 0 3px #8fd3ff, 0 8px 18px rgba(0,0,0,0.5); filter: none !important; }
.hand .card.prepared::after { content: "ready"; position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: #8fd3ff; color: #0b2a3a; font-size: 0.6rem; font-weight: 800; border-radius: 10px; padding: 1px 6px; }
.hand.idle .card { cursor: pointer; }
.hint { font-size: 0.72rem; color: var(--muted); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal-card { background: #10261d; border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.modal-card.wide { max-width: 560px; }
.modal-card h3 { margin: 0 0 12px; }
.choose-list { display: grid; gap: 8px; }
.choice { text-align: left; display: block; width: 100%; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: var(--ink); padding: 12px; border-radius: 10px; cursor: pointer; }
.choice:hover { background: rgba(231,193,90,0.2); border-color: var(--gold); }
.choice b { display: block; }
.choice b small { color: var(--gold); font-weight: 400; margin-left: 6px; }
.choice span { font-size: 0.85rem; color: var(--muted); }
.double-list { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.double-list .card { cursor: pointer; outline: 3px solid transparent; }
.double-list .card.sel { outline-color: var(--gold); transform: translateY(-6px); }
table.scores { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.scores th, table.scores td { padding: 6px 8px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.1); }
table.scores th:first-child, table.scores td:first-child { text-align: left; }
table.scores tr.total td { font-weight: 700; color: var(--gold); }
.delta-pos { color: #8fe3a8; }
.delta-neg { color: #ff9b94; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #3b1b1b; color: #ffd9d6; border: 1px solid #a33; padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: 0.9rem; }
.badge { font-size: 0.7rem; background: rgba(255,255,255,0.15); padding: 2px 6px; border-radius: 6px; }

/* ---------- Wahed (colour cards) ---------- */
:root { --w-R: #d9352f; --w-G: #1f9d55; --w-B: #2667d9; --w-Y: #f3b322; --w-X: #1b2033; }
.card.u { background: transparent; border: 0; box-shadow: 0 3px 8px rgba(0,0,0,0.5); overflow: hidden; }
.card.u > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 7px; }
.card.u.top { transform: scale(1.22) rotate(-4deg); box-shadow: 0 12px 28px rgba(0,0,0,0.6); margin: 8px 0 16px; }
.card.u.drawn { outline: 3px solid var(--gold); outline-offset: 2px; }
.card.back.u { background: transparent; border: 0; }
.card.back.u span { position: absolute; left: 50%; bottom: 4px; font-size: 0.7rem; padding: 1px 6px; line-height: 1.3; transform: translateX(-50%); background: rgba(0,0,0,0.6); color: #fff6e3; border: 1px solid rgba(217,181,90,0.6); }
.hand.wahed .card { margin-left: calc(var(--card-w) * -0.38); }
.hand.wahed .card.legal:hover { transform: translateY(-16px) scale(1.04); }
.hand.wahed .card.prepared { transform: translateY(-10px); outline: 3px solid var(--gold); outline-offset: 2px; }
.wahed-center .piles { gap: 40px; }
.wpile.drop .card.u.top { box-shadow: 0 0 0 4px rgba(255,255,255,0.65), 0 10px 24px rgba(0,0,0,0.55); }
.wpile.R .card.u.top { box-shadow: 0 0 0 4px var(--w-R), 0 0 28px var(--w-R), 0 10px 24px rgba(0,0,0,0.55); }
.wpile.G .card.u.top { box-shadow: 0 0 0 4px var(--w-G), 0 0 28px var(--w-G), 0 10px 24px rgba(0,0,0,0.55); }
.wpile.B .card.u.top { box-shadow: 0 0 0 4px var(--w-B), 0 0 28px var(--w-B), 0 10px 24px rgba(0,0,0,0.55); }
.wpile.Y .card.u.top { box-shadow: 0 0 0 4px var(--w-Y), 0 0 28px var(--w-Y), 0 10px 24px rgba(0,0,0,0.55); }
.hud-king .wcolor { width: 26px; height: 26px; flex-shrink: 0; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }
.color-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.wcolor-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); color: var(--ink); cursor: pointer; text-transform: capitalize; }
.wcolor-btn svg { width: 52px; height: 52px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.wcolor-btn:hover { border-color: var(--gold); transform: translateY(-2px); }
/* Draw / Keep / Wahed! / Catch! above your cards, over the right end of the row (--cards-r: set by placeWahedActions) */
#wahed-actions { position: absolute; right: var(--cards-r, 12px); bottom: calc(100% + 4px); margin: 0; justify-content: flex-end; flex-wrap: nowrap; z-index: 7; }
#wahed-actions .btn.call { background: var(--gold); color: #2b2203; border-color: transparent; font-weight: 800; letter-spacing: 0.02em; }
#wahed-actions .btn.call.on { background: #8fe3a8; color: #0b2a14; }
#wahed-actions .btn.catch { background: var(--red); color: #fff; border-color: transparent; font-weight: 700; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.mode-switch.seat-pick { flex-wrap: wrap; }
.mode-switch.seat-pick .mode { flex: 1 1 auto; min-width: 0; padding: 8px 8px; white-space: nowrap; }
[dir="rtl"] .mode-switch.seat-pick .mode { font-size: 0.84rem; padding: 8px 7px; }
.hand.wahed { --card-w: 74px; --card-h: 111px; height: auto; padding-top: 14px; }
.wahed-center { --card-w: 78px; --card-h: 117px; }
@media (max-width: 900px) { .hand.wahed { --card-w: 60px; --card-h: 90px; } .wahed-center { --card-w: 64px; --card-h: 96px; } }
@media (max-width: 560px) { .hand.wahed { --card-w: 48px; --card-h: 72px; } .hand.wahed .card { margin-left: calc(var(--card-w) * -0.45); } .wahed-center { --card-w: 54px; --card-h: 81px; } .wahed-center .piles { gap: 22px; } }
.lobby-head .brand, .lobby-head .online, .lobby-head .profile-btn, .admin-link, .coins-pill { white-space: nowrap; }
.admin-link { text-decoration: none; padding: 6px 12px; font-size: 0.85rem; border-radius: 30px; }
.lobby-head .profile-btn { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .lobby-head .brand { font-size: 1.3rem; } .lobby-head .online { display: none; } .lobby-main > .panel-head { margin-bottom: 8px; } }

/* ---------- Chess ---------- */
.chess-mode .hand-wrap { padding: 0; }
.chess-mode .hand { display: none; }
.chess-mode .table-surface { display: none; } /* chess: no oval table, just the board on the background */
.chess-wrap { pointer-events: auto; display: flex; align-items: center; justify-content: center; }
#screen-table.chess-mode { --sq: calc(min(100dvh - 200px, 100vw - 40px, 680px) / 8); }
#screen-table.game-chess { --sq: calc(min(100dvh - 200px, 100vw - 480px, 680px) / 8); } /* room beside the board for the clock panel */
.board8 { display: grid; grid-template-columns: repeat(8, var(--sq)); grid-template-rows: repeat(8, var(--sq)); border: 6px solid #2a2a33; border-radius: 6px; box-shadow: 0 16px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.12); }
.sq { position: relative; width: var(--sq); height: var(--sq); user-select: none; -webkit-user-select: none; touch-action: none; }
.sq.light { background: #ece1c6; }
.sq.dark { background: #6f8f66; }
.sq.last.light { background: #e6d28a; }
.sq.last.dark { background: #a8a85a; }
.sq.sel.light, .sq.sel.dark { background: #f0c860; }
.sq.check { background: radial-gradient(circle, #ff5a4a 0%, #e0463a 45%, transparent 75%) !important; }
.sq.over { outline: 3px solid rgba(255,255,255,0.8); outline-offset: -3px; }
.sq.sq-to::after { /* (not .dot: that is the friends' online dot, 8px wide) */  content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(20, 30, 20, 0.35); pointer-events: none; }
.sq.cap::after { content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 4px solid rgba(20, 30, 20, 0.4); pointer-events: none; }
.sq .piece { position: absolute; inset: 4%; width: 92%; height: 92%; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.35)); pointer-events: none; }
.sq .piece.mine { cursor: grab; }
.sq.lifting .piece { opacity: 0.25; }
.piece-ghost { position: fixed; z-index: 50; pointer-events: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,0.5)); transform: scale(1.12); }
.piece-ghost .piece { width: 100%; height: 100%; }
.sq .coord { position: absolute; font-size: calc(var(--sq) * 0.2); font-weight: 700; opacity: 0.7; pointer-events: none; line-height: 1; }
.sq .coord.rank { left: 3px; top: 2px; }
.sq .coord.file { right: 3px; bottom: 2px; }
.sq.light .coord { color: #6f8f66; }
.sq.dark .coord { color: #ece1c6; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem; background: rgba(0,0,0,0.45); border-radius: 8px; padding: 1px 8px; letter-spacing: 0.03em; }
.player.turn .clock { background: var(--gold); color: #2b2203; }
.clock.urgent { background: var(--red) !important; color: #fff !important; }
.captured { display: inline-flex; align-items: flex-end; margin-left: 6px; }
.captured .piece { width: 16px; height: 16px; margin-left: -4px; }
.captured .piece:first-child { margin-left: 0; }
#chess-actions { margin-top: 10px; }
.movelist { display: flex; flex-wrap: wrap; gap: 4px 6px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; max-height: 120px; overflow: auto; }
.movelist .no { color: var(--gold); margin-left: 4px; }
.movelist span:not(.no) { color: var(--ink); }
#chess-moves { max-width: 420px; }
.chess-result { font-size: 1.05rem; margin: 0 0 6px; }
.promo-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.promo { aspect-ratio: 1; background: #ece1c6; border: 2px solid rgba(255,255,255,0.2); border-radius: 12px; cursor: pointer; padding: 6px; }
.promo:hover { border-color: var(--gold); transform: translateY(-2px); }
.promo .piece { width: 100%; height: 100%; }
/* chess for two at one device: each seat's face is its king, on a plain disc */
.avatar:has(> .av-piece) { background: #3a4060; }
.avatar > .av-piece { width: 82%; height: 82%; display: block; }
/* wide screens: the two players sit in the right-hand corners so the board gets the full height */
@media (min-width: 761px) {
  .chess-mode .seat-top { left: auto; right: 10px; top: 10px; transform: none; align-items: flex-end; }
  .chess-mode .seat-bottom { left: auto; right: 10px; bottom: 10px; transform: none; align-items: flex-end; }
  .chess-mode .log { bottom: 90px; width: min(270px, 22vw); }
}
@media (max-width: 760px) { .chess-wrap { --sq: calc(min(100dvh - 300px, 100vw - 40px) / 8); } .chess-mode .seat-top, .chess-mode .seat-bottom { transform: translateX(-50%) scale(0.9); } }

.sq.hint.light, .sq.hint.dark { background: #8fd3f4; }
.sq.hint::before { content: ""; position: absolute; inset: 8%; border-radius: 10%; border: 3px dashed #1b6fa8; pointer-events: none; }
.chess-wrap { gap: 12px; }
.evalbar { position: relative; width: 16px; height: calc(var(--sq) * 8 + 12px); border-radius: 8px; background: #262633; border: 2px solid #2a2a33; overflow: hidden; display: flex; flex-direction: column-reverse; box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
.evalfill { width: 100%; background: #f6efdf; transition: height .4s ease; }
.evalfill.b { background: #262633; }
.evalbar:has(.evalfill.b) { background: #f6efdf; }
.evaltxt { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); font-size: 0.6rem; font-weight: 700; color: #888; writing-mode: vertical-rl; }

/* ---------- Tic Tac Toe ---------- */
.xo-wrap { pointer-events: auto; --cell: calc(min(100dvh - 260px, 100vw - 48px, 480px) / 3); }
.xo-board { display: grid; grid-template-columns: repeat(3, var(--cell)); grid-template-rows: repeat(3, var(--cell)); gap: 8px; padding: 10px; border-radius: 22px; background: #1b2033; box-shadow: 0 16px 40px rgba(0,0,0,0.55), 0 0 0 3px #d9b55a; }
.xo-cell { position: relative; background: #f3ead6; border: 0; border-radius: 14px; cursor: default; padding: 10%; transition: background .15s, transform .15s; }
.xo-cell svg { width: 100%; height: 100%; display: block; }
.xo-cell .ghost-mark { position: absolute; inset: 10%; opacity: 0; transition: opacity .15s; }
.xo-board.live .xo-cell:not(.filled) { cursor: pointer; }
.xo-board.live .xo-cell:not(.filled):hover { background: #fff8e7; }
.xo-board.live .xo-cell:not(.filled):hover .ghost-mark { opacity: 0.35; }
.xo-cell.filled svg { animation: pop .18s ease-out; }
.xo-cell.win { background: #e7c15a; animation: pulse .6s ease-in-out 3; }
.xo-cell.dim { opacity: 0.55; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chip.xo-x { background: #d9352f; color: #fff; border-color: transparent; font-weight: 700; }
.chip.xo-o { background: #2667d9; color: #fff; border-color: transparent; font-weight: 700; }

/* ---------- Dominoes ---------- */
.domino-wrap { pointer-events: auto; width: min(78vw, 820px); height: min(52vh, 420px); display: flex; align-items: center; justify-content: center; }
.domino-wrap .chain { width: 100%; height: 100%; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.45)); }
.domino-wrap .chain [data-end="L"], .domino-wrap .chain [data-end="R"] { cursor: pointer; }
.domino-wrap .endglow { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { from { opacity: 0.5; } to { opacity: 1; } }
.domino-empty { color: var(--muted); font-size: 1.05rem; background: rgba(0,0,0,0.3); padding: 14px 22px; border-radius: 14px; border: 1px dashed rgba(255,255,255,0.25); }
.hand.domino { height: auto; gap: 8px; padding: 10px 0 2px; flex-wrap: wrap; }
.dtile { line-height: 0; border-radius: 9px; transition: transform .12s, filter .12s; filter: brightness(0.6); }
.dtile .tile { display: block; }
.hand.idle .dtile { filter: none; }
.dtile.legal { filter: none; cursor: pointer; }
.dtile.legal:hover { transform: translateY(-10px); }
.dtile.sel { transform: translateY(-14px); outline: 3px solid var(--gold); outline-offset: 2px; }
#domino-actions { margin-top: 10px; }
@media (max-width: 560px) { .dtile .tile { width: 32px; height: 64px; } .domino-wrap { width: 94vw; height: 44vh; } }

/* ---------- Tawla ---------- */
.tawla-wrap { pointer-events: auto; width: min(92vw, calc((100dvh - 190px) * 1.56), 1000px); }
.tawla-wrap .tawla { width: 100%; height: auto; display: block; filter: drop-shadow(0 16px 40px rgba(0,0,0,0.55)); border-radius: 22px; }
.tawla .pt.from, .tawla .pt.to { cursor: pointer; }
.tawla .pick { filter: drop-shadow(0 0 6px #e7c15a); }
.tawla .picked { stroke: #e7c15a !important; stroke-width: 6 !important; }
.tawla .dest { animation: glow 0.9s ease-in-out infinite alternate; pointer-events: none; }
/* the checker just played glides to its point; the one drawn there shows once it has arrived */
.tawla .tw-fly { pointer-events: none; transform-box: fill-box; transform-origin: center; animation: tw-fly .32s cubic-bezier(.3,.7,.35,1) both; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); }
.tawla .tw-fly.off { animation: tw-fly .32s cubic-bezier(.3,.7,.35,1) both, tw-gone .2s .3s both; }
.tawla .landing { animation: tw-wait .32s step-end; }
@keyframes tw-fly { from { transform: translate(var(--dx), var(--dy)) scale(1.08); } to { transform: none; } }
@keyframes tw-gone { to { opacity: 0; } }
@keyframes tw-wait { from { opacity: 0; } to { opacity: 0; } }
#tawla-actions { margin-top: 8px; }

/* ---------- Basra ---------- */
.basra-table { pointer-events: auto; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; max-width: min(70vw, 620px); padding: 16px; border-radius: 18px; background: rgba(0,0,0,0.18); border: 1px dashed rgba(255,255,255,0.18); position: relative; }
.basra-table .card { transition: transform .15s, box-shadow .15s; }
.basra-table .card.take { transform: translateY(-8px) scale(1.06); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,0.5); }
/* on a phone the table stays between the side players' avatars (still three cards a row), the empty-table note too */
@media (max-width: 560px) { .basra-table { max-width: calc(100vw - 170px); padding: 10px; } .basra-table .domino-empty { font-size: 0.9rem; padding: 10px 12px; text-align: center; } }
.basra-badge { position: absolute; top: -16px; right: -10px; background: var(--gold); color: #2b2203; font-weight: 900; padding: 4px 12px; border-radius: 20px; font-size: 0.85rem; box-shadow: 0 4px 10px rgba(0,0,0,0.4); animation: pop .2s ease-out; }
.hand .card.would-take.legal { box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -4px 0 #8fe3a8; }
.hand .card.would-basra.legal { box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -4px 0 var(--gold); }

/* ---------- Caravan & Treasure Island ---------- */
.card.u.help { --card-w: 96px; --card-h: 132px; width: var(--card-w); height: var(--card-h); background: linear-gradient(#fff8e8, #f1e4c6); border: 3px solid var(--hc); color: #1b2033; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 6px 4px; gap: 1px; text-align: center; overflow: hidden; }
.card.u.help .hc-icon { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
.card.u.help .hc-icon .art { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25)); }
.art { display: block; object-fit: contain; pointer-events: none; }
.card.u.help .hc-name { font-weight: 800; font-size: 0.78rem; line-height: 1.1; margin-top: 2px; }
.card.u.help .hc-ar { font-size: 0.72rem; color: var(--hc); }
.card.u.help .hc-text { font-size: 0.6rem; line-height: 1.15; color: #4a4a58; font-weight: 500; }
.hand.help { height: auto; gap: 10px; padding: 10px 0 2px; }
.hand.help .card { margin-left: 0; }
.hand.help .card.legal:hover { transform: translateY(-10px); }
.hand.help .card.sel { transform: translateY(-12px); outline: 3px solid var(--gold); outline-offset: 2px; }
#race-actions { margin-top: 10px; }
#race-actions .btn.roll { font-size: 1.05rem; padding: 10px 24px; }
.race-targets { display: inline-flex; gap: 6px; align-items: center; }
.race-mode .hand { display: flex; }
.race-mode .hand-wrap { padding: 6px 0 4px; }
.ico { width: 100%; height: 100%; display: block; }
/* Caravan: a long map that fills the play area and scrolls; the die floats at the bottom */
.caravan-wrap { pointer-events: auto; position: relative; width: 100%; height: 100%; }
.cv-scroll { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; border-radius: 18px; overscroll-behavior: contain; scrollbar-width: thin; box-shadow: 0 12px 34px rgba(0,0,0,0.45); }
.cv-map { position: relative; width: 100%; }
.caravan-wrap .die-box { top: auto; bottom: 10px; margin: 0; padding: 6px 16px 6px 8px; border-radius: 18px; background: rgba(10, 22, 15, 0.78); box-shadow: 0 6px 18px rgba(0,0,0,0.45); z-index: 3; }
.caravan-wrap .track { width: 100%; height: 100%; display: block; }
.caravan-wrap .tile-g { cursor: help; }
.tokens { position: absolute; inset: 0; pointer-events: none; }
.token { position: absolute; transition: left .7s cubic-bezier(.4,.1,.3,1), top .7s cubic-bezier(.4,.1,.3,1); }
.token.pin { transition-duration: .42s; width: 36px; height: 36px; margin-left: -18px; margin-top: -18px; border-radius: 50%; border: 3px solid var(--c); background: #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.45); overflow: hidden; }
.token.pin .avatar { width: 100%; height: 100%; display: block; }
.token .avatar .av-img { width: 100%; height: 100%; object-fit: cover; }
.token.camel { width: 76px; height: 76px; margin-left: -38px; margin-top: -32px; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.45)); }
.token.camel > .art { width: 100%; height: 100%; }
.token.camel .avatar { position: absolute; left: -1px; top: 2px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--c); background: #fff; overflow: hidden; display: block; box-shadow: 0 0 0 2px #fff; }
.token.turn.camel { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 3px 3px rgba(0,0,0,0.45)); }
.token.pin.turn { box-shadow: 0 0 0 3px #fff, 0 0 14px var(--gold), 0 4px 10px rgba(0,0,0,0.45); }
.token.shield::after { content: "🛡"; position: absolute; right: -6px; top: -8px; font-size: 0.8rem; }
.token.carry::after { content: "💰"; position: absolute; right: -8px; bottom: -8px; font-size: 0.85rem; }
.die-box { position: absolute; left: 50%; top: 100%; margin-top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; color: #f6efdf; pointer-events: auto; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.die-box .die-face { width: 64px; height: 64px; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.45)); transition: transform .15s; }
.die-box .die-face svg { width: 100%; height: 100%; display: block; }
.die-box .die-face.tumble { animation: dice-throw 1.3s cubic-bezier(.2,.6,.35,1); }
@keyframes dice-throw { 0% { transform: translate(-34px, -46px) rotate(-250deg) scale(1.2); } 30% { transform: translate(-10px, 0) rotate(-70deg) scale(1); } 44% { transform: translate(-6px, -16px) rotate(-38deg) scale(1.04); } 58% { transform: translate(-3px, 0) rotate(-14deg); } 70% { transform: translate(-1px, -5px) rotate(-6deg); } 80% { transform: translate(0, 0) rotate(-2deg); } 90% { transform: rotate(1deg); } 100% { transform: none; } }
@keyframes tumble { 0% { transform: rotate(0) scale(1); } 25% { transform: rotate(90deg) scale(1.15); } 50% { transform: rotate(180deg) scale(0.95); } 75% { transform: rotate(270deg) scale(1.1); } 100% { transform: rotate(360deg) scale(1); } }
.die-box .die-label { font-size: 1rem; line-height: 1.2; }
.die-box .die-label b { color: var(--gold); }
.die-box.mine { cursor: pointer; }
.die-box.mine .die-face { animation: die-pulse 1.1s ease-in-out infinite; }
.die-box.mine:hover .die-face { transform: scale(1.12) rotate(-8deg); animation: none; }
.die-box.mine .die-label { color: var(--gold); font-weight: 700; }
.die-box.rolling { pointer-events: none; }
@keyframes die-pulse { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.08) rotate(6deg); } }
.island-wrap { pointer-events: auto; position: relative; width: min(100%, calc(100dvh - 400px), 640px); margin-bottom: 128px; }
.island-wrap .tokens { z-index: 2; }
@media (max-height: 820px) { .race-mode .card.u.help { --card-w: 78px; --card-h: 108px; } .race-mode .card.u.help .hc-icon { width: 44px; height: 44px; } .race-mode .card.u.help .hc-text { display: none; } }
.island { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); gap: 3px; padding: 10px; background: radial-gradient(circle at 30% 20%, #4c93ea, #2a6fd6 60%, #1e55a8); border-radius: 18px; box-shadow: 0 16px 40px rgba(0,0,0,0.5); aspect-ratio: 1; }
.isle { position: relative; border-radius: 7px; background: #ebdcb8; display: flex; align-items: center; justify-content: center; padding: 7%; user-select: none; min-width: 0; min-height: 0; aspect-ratio: 1; overflow: hidden; }
.isle .ico, .isle .art { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.isle .art.deco { opacity: 0.75; transform: scale(0.9); }
.isle.swamp { background: #6f9d78; }
.isle.croc { background: #a8cf8a; }
.isle.rock { background: #cfc6b0; }
.isle.cave { background: #c9a263; }
.isle.spot { background: #e9d9b5; }
.isle.chest { background: #f3d57a; }
.isle.empty { background: #dccba3; }
.isle .dug { width: 50%; height: 30%; border-radius: 50%; background: #b8a070; }
.isle.boat { background: #8fd3f4; }
.isle.step { cursor: pointer; background: #f8e9a8; box-shadow: inset 0 0 0 4px var(--gold), 0 0 10px rgba(217,181,90,0.8); animation: step-pulse 0.8s ease-in-out infinite alternate; z-index: 1; }
.isle.step:hover { background: #ffe066; }
@keyframes step-pulse { from { box-shadow: inset 0 0 0 3px var(--gold), 0 0 4px rgba(217,181,90,0.4); } to { box-shadow: inset 0 0 0 5px #ffd84a, 0 0 16px rgba(255,216,74,0.95); } }
.isle.trapok { cursor: crosshair; box-shadow: inset 0 0 0 3px #d9352f; }
.island-wrap .token.pin { width: 34px; height: 34px; margin-left: -17px; margin-top: -17px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.lg { display: flex; align-items: center; gap: 8px; }
.lg .lg-ic { width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; background: #e9d9b5; padding: 3px; }
.lg .lg-ic .art { width: 100%; height: 100%; }
.lg .lg-ic.hc { background: #f6efdf; box-shadow: inset 0 0 0 2px var(--hc); }
.lg b { display: block; font-size: 0.88rem; }
.lg small { color: var(--muted); font-size: 0.74rem; }
.howto h4 { margin: 12px 0 6px; color: var(--gold); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.howto p { margin: 0; color: var(--muted); font-size: 0.9rem; }
@media (min-width: 761px) {
  .race-mode .log { top: 64px; bottom: auto; left: 12px; width: 230px; max-height: 34vh; overflow: hidden; }
  .race-mode .center { left: 250px; right: 200px; }
  .race-mode .seat-right, .race-mode .seat-top, .race-mode .seat-left { left: auto; right: 10px; transform: none; align-items: flex-end; }
  .race-mode .seat-right { top: 4px; }
  .race-mode .seat-top { top: 94px; }
  .race-mode .seat-left { top: 184px; }
  .race-mode .seat-bottom { left: 12px; right: auto; bottom: 4px; transform: none; align-items: flex-start; }
}

/* Treasure Island direction pad (shown under the board while walking) */
.island-wrap .die-box { left: 50%; }
.island-wrap:has(.dpad) .die-box { left: auto; right: 50%; margin-right: 76px; margin-top: 30px; transform: none; }
.dpad { position: absolute; top: 100%; left: 50%; margin-top: 4px; margin-left: -60px; display: grid; grid-template-columns: 38px 38px 38px; grid-template-rows: 38px 38px 38px; grid-template-areas: ". up ." "left c right" ". down ."; gap: 3px; pointer-events: auto; }
.dpad .dp { font-size: 1.1rem; font-weight: 900; border-radius: 10px; border: 2px solid rgba(255,255,255,0.25); background: rgba(27,32,51,0.75); color: #f6efdf; cursor: pointer; transition: transform .1s, background .15s; }
.dpad .dp.up { grid-area: up; } .dpad .dp.down { grid-area: down; } .dpad .dp.left { grid-area: left; } .dpad .dp.right { grid-area: right; }
.dpad .dp:not(:disabled) { background: var(--gold); color: #2b2203; border-color: transparent; box-shadow: 0 3px 0 #9a7a2c, 0 6px 12px rgba(0,0,0,0.4); animation: die-pulse 1.1s ease-in-out infinite; }
.dpad .dp:not(:disabled):hover { transform: scale(1.1); animation: none; }
.dpad .dp:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #9a7a2c; }
.dpad .dp:disabled { opacity: 0.3; cursor: default; }
.dpad .dp-c { grid-area: c; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #f6efdf; line-height: 1; background: rgba(27,32,51,0.75); border-radius: 50%; }
.dpad .dp-c b { font-size: 1.15rem; color: var(--gold); } .dpad .dp-c small { font-size: 0.6rem; opacity: 0.8; }

/* ---------- languages: switch + right-to-left ---------- */
.lang-switch { display: inline-flex; gap: 2px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 2px; }
.lang-switch button { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 0.78rem; padding: 4px 10px; border-radius: 999px; cursor: pointer; font-family: inherit; }
.lang-switch button.sel { background: var(--gold); color: #2b2203; }
.login-card { position: relative; }
.login-lang { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2; }
html[lang="ar"] body { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", "Geeza Pro", sans-serif; }
html[lang="ar"] .brand, html[lang="ar"] .login-hero h1 { font-family: "Segoe UI", Tahoma, sans-serif; }
/* boards, cards and the move list stay left-to-right; the text inside them is bidi-safe */
[dir="rtl"] .table, [dir="rtl"] .hand, [dir="rtl"] .movelist, [dir="rtl"] .chess-wrap, [dir="rtl"] .tawla-wrap, [dir="rtl"] .caravan-wrap, [dir="rtl"] .island-wrap, [dir="rtl"] .dpad, [dir="rtl"] .die-box, [dir="rtl"] .domino-chain, [dir="rtl"] .basra-table { direction: ltr; }
[dir="rtl"] .seat .pinfo, [dir="rtl"] .penalties, [dir="rtl"] .hud, [dir="rtl"] .log, [dir="rtl"] .die-label { direction: rtl; }
[dir="rtl"] .pname, [dir="rtl"] .hud-contract, [dir="rtl"] .log-item { text-align: right; }
[dir="rtl"] .game-title h4 { text-align: right; }
[dir="rtl"] .txt-center { text-align: center; }
[dir="rtl"] .score, [dir="rtl"] .delta, [dir="rtl"] .code, [dir="rtl"] .clock, [dir="rtl"] .chip.proj, [dir="rtl"] .hud-teams b { direction: ltr; unicode-bidi: isolate; }

/* ---------- phones: no sideways scroll, stacked table layout for the board games ---------- */
html, body { overflow-x: hidden; }
.lobby-grid, .games { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .games { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 1000px) { .games { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); } }
.game-card, .lobby-main, .panel { min-width: 0; }
.mode-switch.seat-pick { flex-wrap: wrap; }
.mode-switch .mode { min-width: 0; }
@media (max-width: 760px) {
  .lobby-head { flex-wrap: wrap; gap: 8px; }
  .lobby-head .profile-btn { max-width: 50vw; }
  /* chess / xo / tawla / caravan / island: opponents in a row above the board, you below it — never on top of it */
  .chess-mode .table { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px 4px; align-items: center; justify-items: center; min-height: 0; }
  .chess-mode .seat { position: static; transform: none; align-items: center; min-width: 0; }
  .chess-mode .seat-left { grid-row: 1; grid-column: 1; }
  .chess-mode .seat-top { grid-row: 1; grid-column: 2; }
  .chess-mode .seat-right { grid-row: 1; grid-column: 3; }
  .chess-mode .seat:empty { display: none; }
  .chess-mode .center { position: static; inset: auto; grid-row: 2; grid-column: 1 / -1; width: 100%; min-height: 0; }
  .chess-mode .seat-bottom { grid-row: 3; grid-column: 1 / -1; }
  .chess-mode .seat .player { transform: none; }
  .chess-mode .player .pname { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chess-wrap { --sq: calc(min(100dvh - 360px, 100vw - 28px) / 8); }
  .island-wrap { width: min(100vw - 28px, 100dvh - 480px); margin-bottom: 112px; }
  .caravan-wrap { width: min(100vw - 24px, calc((100dvh - 400px) * 2.05)); margin-bottom: 76px; }
  /* race games on a phone: compact player strip and small help cards so the board keeps its size */
  .race-mode .seat .player { padding: 3px 8px; }
  .race-mode .seat .pname { font-size: 0.72rem; }
  .race-mode .penalties { display: none; }
  .race-mode .card.u.help { --card-w: 58px; --card-h: 74px; padding: 4px 3px 2px; }
  .race-mode .card.u.help .hc-icon { width: 36px; height: 36px; }
  .race-mode .card.u.help .hc-name { font-size: 0.62rem; }
  .race-mode .card.u.help .hc-text { display: none; }
  .dpad { grid-template-columns: 34px 34px 34px; grid-template-rows: 34px 34px 34px; margin-left: -53px; }
  .island-wrap:has(.dpad) .die-box { margin-right: 62px; margin-top: 24px; }
  .race-mode .seat, .race-mode .seat-bottom { position: static; transform: none; }
  .race-mode .log { display: none; }
  .race-mode .center { left: auto; right: auto; }
  .die-box .die-face { width: 52px; height: 52px; }
  .die-box .die-label { font-size: 0.9rem; }
  .xo-board, .tawla-wrap { max-width: calc(100vw - 24px); }
}

/* phones: the top bar is two rows — buttons first, then the status strip across the full width */
@media (max-width: 760px) {
  .table-top { flex-wrap: wrap; gap: 6px; align-items: center; }
  .table-top .hud { order: 2; flex-basis: 100%; flex-wrap: nowrap; overflow: hidden; }
  .table-top .btn { margin-top: 0; padding: 5px 9px; font-size: 0.8rem; }
  #btn-auto { margin-inline-end: auto; }
  .hud-contract { max-width: none; flex: 1; min-width: 0; }
  .hud-contract b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
  .hud-round { flex-shrink: 0; }
  .hud-teams { display: none; }
  .hud-king:not(:first-of-type) { display: none; }
}
@media (max-width: 760px) {
  /* opponents above the board: compact pills so three fit side by side */
  .chess-mode .seat-top .player, .chess-mode .seat-left .player, .chess-mode .seat-right .player { padding: 3px 8px 3px 3px; gap: 6px; border-radius: 30px 12px 12px 30px; max-width: 32vw; }
  .chess-mode .seat-top .ring, .chess-mode .seat-left .ring, .chess-mode .seat-right .ring { width: 34px; height: 34px; padding: 2px; }
  .chess-mode .seat-top .pname, .chess-mode .seat-left .pname, .chess-mode .seat-right .pname { font-size: 0.66rem; max-width: 70px; }
  .chess-mode .seat-top .pmeta, .chess-mode .seat-left .pmeta, .chess-mode .seat-right .pmeta { font-size: 0.7rem; }
  .chess-mode .seat-top .pname small, .chess-mode .seat-left .pname small, .chess-mode .seat-right .pname small { display: none; }
}

/* ---------- levels / XP ---------- */
.lvl { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--gold); color: #2b2203; font-size: 0.66rem; font-weight: 800; line-height: 1; vertical-align: middle; margin-inline-start: 5px; direction: ltr; }
.pname .lvl { height: 15px; min-width: 15px; font-size: 0.6rem; margin-inline-start: 4px; }
[dir="rtl"] .pname .lvl { margin-left: 0; margin-right: 4px; } /* .lvl is direction: ltr: its inline-start is the left, away from an Arabic name */
.level-card { display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, rgba(231,193,90,0.16), rgba(255,255,255,0.04)); border: 1px solid rgba(231,193,90,0.35); border-radius: 14px; padding: 12px 14px; margin: 12px 0 4px; }
.level-card.up { animation: level-glow 1.6s ease-out; }
@keyframes level-glow { 0% { box-shadow: 0 0 0 0 rgba(231,193,90,0.7); } 100% { box-shadow: 0 0 0 18px rgba(231,193,90,0); } }
.level-ring { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(0,0,0,0.25); line-height: 1; }
.level-ring small { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.level-ring b { font-size: 1.6rem; color: var(--gold); }
.level-info { flex: 1; min-width: 0; }
.level-title { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.level-bar { height: 8px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; }
.level-bar span { display: block; height: 100%; background: linear-gradient(90deg, #e7c15a, #f5d98a); border-radius: 999px; transition: width .8s ease-out; }
.level-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.76rem; color: var(--muted); margin-top: 5px; flex-wrap: wrap; }
.xp-gain { text-align: center; margin: 12px 0 0; }
.xp-total { font-size: 1.7rem; font-weight: 800; color: var(--gold); direction: ltr; }
.xp-total small { font-size: 0.9rem; font-weight: 600; }
.xp-parts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.xp-part { display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,0.08); border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; }
.xp-part b { color: var(--gold); direction: ltr; }
.xp-gain.up .xp-total { animation: xp-pop .6s ease-out; }
@keyframes xp-pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
#round-xp .level-card { margin: 10px 0 20px; }
#round-xp .xp-gain { margin-top: 14px; }

/* ---------- coins / challenges ---------- */
.coin { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.coins-pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(231,193,90,0.14); border: 1px solid rgba(231,193,90,0.5); color: var(--gold); font-weight: 700; border-radius: 30px; padding: 6px 12px; cursor: pointer; font-size: 0.9rem; }
.coins-pill:hover { background: rgba(231,193,90,0.24); }
.mode-switch.stake-row { flex-wrap: nowrap; }
.stake-row .mode.stake { font-size: 0.78rem; padding: 6px 4px; direction: ltr; }
.stake-label { font-size: 0.95rem; flex: 0 0 auto; opacity: 0.85; }
.stake-row .mode.stake.sel { background: rgba(231,193,90,0.2); border-color: var(--gold); color: var(--gold); }
.game-card.staked { border-color: rgba(231,193,90,0.45); box-shadow: inset 0 0 0 1px rgba(231,193,90,0.2); }
.tables-panel { margin-bottom: 16px; }
.tables-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tables-head h3 { margin: 0; }
.join-row { display: flex; gap: 8px; align-items: center; }
.join-row input { width: 120px; text-transform: uppercase; letter-spacing: 0.15em; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.18); color: var(--ink); border-radius: 10px; padding: 8px 10px; }
.rooms .empty { color: var(--muted); font-size: 0.9rem; padding: 4px 0; }
.room-stake { margin: 4px 0 10px; font-size: 0.9rem; }
.hud-pot b { color: var(--gold); }
.coin-result { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 12px 0 2px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); text-align: center; }
.coin-result b { font-size: 1.5rem; direction: ltr; unicode-bidi: isolate; }
.coin-result.win b { color: #8fe3a8; }
.coin-result.lost b { color: #ff9c94; }
.coin-result.refund b, .coin-result.reward b { color: var(--gold); }
.coin-result span { font-size: 0.9rem; }
.coin-result small { color: var(--muted); }
.coin-result.reward { background: rgba(231,193,90,0.1); border-color: rgba(231,193,90,0.35); }
.coins-card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 12px 14px; margin: 8px 0 4px; }
.coins-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.coins-head small { display: block; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.coins-head b { font-size: 1.4rem; color: var(--gold); direction: ltr; unicode-bidi: isolate; }
.coin-log { display: grid; gap: 4px; margin-top: 10px; }
.cl { display: grid; grid-template-columns: 70px 1fr auto; gap: 8px; font-size: 0.82rem; align-items: center; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 4px 8px; }
.cl > span:first-child { direction: ltr; unicode-bidi: isolate; font-weight: 700; }

/* open tables rows */
.room-row { gap: 14px; padding: 12px 14px; }
.room-row > div:first-child { min-width: 0; display: grid; gap: 4px; }
.room-row .rr-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; line-height: 1.3; }
.room-row .rr-stake { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--gold); color: #2b2203; letter-spacing: 0; white-space: nowrap; }
.room-row .meta { line-height: 1.5; }
.room-row .meta .code { margin-inline-start: 2px; }
.room-row .btn { flex-shrink: 0; }

/* ---------- brand / landing ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand .mark, .hero-mark .mark { width: 1.35em; height: 1.35em; color: var(--gold); border-radius: 22%; background: linear-gradient(135deg, #1b6e4f, #0c3324); box-shadow: inset 0 0 0 1.5px rgba(231,193,90,0.5); }
.hero-mark { display: flex; justify-content: center; }
.hero-mark .mark { width: 64px; height: 64px; box-shadow: inset 0 0 0 2px rgba(231,193,90,0.5), 0 10px 30px rgba(0,0,0,0.35); }
.login-hero h1 { display: flex; justify-content: center; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.login-hero h1 .brand-ar { color: var(--gold); font-size: 0.8em; font-weight: 700; }
.landing { max-width: 820px; margin: 0 auto; padding: 0 16px 40px; color: var(--ink); }
.landing-inner { padding-top: 8px; }
.landing h2 { font-size: 1.35rem; margin: 18px 0 8px; text-align: center; }
.landing-lead { color: var(--muted); text-align: center; max-width: 640px; margin: 0 auto 18px; line-height: 1.55; }
.landing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.land-card { background: var(--panel); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 14px 16px; }
.land-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--gold); }
.land-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.landing-faq { margin-top: 18px; background: var(--panel); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 10px 16px; }
.landing-faq h3 { margin: 6px 0 4px; font-size: 1rem; }
.landing-faq details { border-top: 1px solid rgba(255,255,255,0.08); padding: 8px 0; }
.landing-faq summary { cursor: pointer; font-weight: 600; }
.landing-faq p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.landing-foot { text-align: center; margin-top: 18px; }
.landing-foot a { color: var(--gold); }
#screen-login.login { flex-direction: column; gap: 14px; padding: 24px 16px; }
.site-foot { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--muted); }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--gold); text-decoration: underline; }
/* about / faq pages */
.page-top { max-width: 820px; margin: 0 auto; padding: 18px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-top .brand { font-weight: 700; font-size: 1.15rem; }
.page .landing h1 { font-size: 1.6rem; margin: 18px 0 8px; text-align: center; }
.page-play { display: flex; justify-content: center; margin: 22px 0 6px; }
.page-play .btn { text-decoration: none; }
.btn.thinking { opacity: .6; animation: pulse 1s infinite alternate; } @keyframes pulse { to { opacity: 1; } }

/* Android app (edge-to-edge) and notched phones: keep content clear of the status and navigation bars.
   env() works in recent Android WebViews; Capacitor's SystemBars plugin sets --safe-area-inset-* for older ones. */
:root { --sat: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px)); --sab: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px)); }
.screen { padding-top: calc(16px + var(--sat)); padding-bottom: calc(16px + var(--sab)); }
#screen-login.login { padding-top: calc(24px + var(--sat)); padding-bottom: calc(24px + var(--sab)); }
#screen-table { padding-top: calc(8px + var(--sat)); padding-bottom: calc(8px + var(--sab)); }
.modal { padding-top: calc(16px + var(--sat)); padding-bottom: calc(16px + var(--sab)); }
.toast { bottom: calc(24px + var(--sab)); }
.page-top { padding-top: calc(18px + var(--sat)); }

/* opponents: a fan of face-down cards behind the avatar instead of a card count */
.ring .fan { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; }
.ring .fan i { position: absolute; left: -8px; top: -41px; width: 16px; height: 23px; border-radius: 2px; background: repeating-linear-gradient(135deg, #2b4f9e 0 2px, #4a6fc0 2px 4px); border: 1px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.45); transform-origin: 50% 41px; transform: rotate(var(--a)); }
/* the round's points pop up on each seat (there is no result window between rounds) */
.pmeta .delta { font-size: 0.82rem; font-weight: 800; padding: 2px 6px; animation: deltaPop .35s ease-out; }
@keyframes deltaPop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@media (max-width: 760px) {
  /* card tables on a phone: the side players are compact (avatar over name) so the middle stays free */
  #screen-table:not(.chess-mode) .seat-left, #screen-table:not(.chess-mode) .seat-right { min-width: 0; top: 50%; }
  #screen-table:not(.chess-mode) .seat-left .player, #screen-table:not(.chess-mode) .seat-right .player { flex-direction: column; border-radius: 14px; padding: 6px 6px 5px; gap: 3px; width: 84px; }
  #screen-table:not(.chess-mode) .seat-left .pinfo, #screen-table:not(.chess-mode) .seat-right .pinfo { align-items: center; width: 100%; }
  #screen-table:not(.chess-mode) .seat-left .pname, #screen-table:not(.chess-mode) .seat-right .pname { max-width: 74px; font-size: 0.74rem; text-align: center; }
  #screen-table:not(.chess-mode) .seat-left .pmeta, #screen-table:not(.chess-mode) .seat-right .pmeta { justify-content: center; gap: 4px; }
  #screen-table:not(.chess-mode) .seat-left .penalties, #screen-table:not(.chess-mode) .seat-right .penalties { max-width: 90px; }
  /* no event line at the bottom on a phone — the table itself shows what happened */
  #screen-table .log { display: none; }
}

/* players sit on the table without a panel: avatar, name, and the score in its own small box */
.player, .player.me, .player.turn, .player:hover { background: transparent; border-color: transparent; box-shadow: none; }
.player { padding: 0; }
.player.turn .ring { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(231,193,90,0.7); border-radius: 50%; }
.pname { text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
.pname small { color: rgba(255,255,255,0.7); }
.pmeta .score { background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.18); border-radius: 8px; padding: 3px 9px; min-width: 36px; text-align: center; }
.player.turn .pmeta .score { border-color: var(--gold); }
@media (max-width: 760px) {
  #screen-table:not(.chess-mode) .seat-left .player, #screen-table:not(.chess-mode) .seat-right .player { padding: 0; }
}

/* ---------- Caravan sideways, Treasure Island upright on a phone ---------- */
:root { --sal: max(env(safe-area-inset-left, 0px), var(--safe-area-inset-left, 0px)); --sar: max(env(safe-area-inset-right, 0px), var(--safe-area-inset-right, 0px)); }

/* Treasure Island upright: the board fits the space between the players and your cards, anchored at the top — it never slides under the players */
@media (max-width: 760px) {
  .race-mode .center { container-type: size; align-self: stretch; align-items: flex-start; padding-top: 4px; }
  .island-wrap { width: min(100cqw - 8px, 100cqh - 118px, 640px); margin-bottom: 0; }
  .race-mode #race-actions { min-height: 46px; margin-top: 8px; }
}

/* Caravan sideways: you and your cards on the left, the road in the middle, the other players on the right */
@media (orientation: landscape) and (max-height: 500px) {
  #screen-table.race-mode { position: relative; padding-left: calc(8px + var(--sal)); padding-right: calc(8px + var(--sar)); }
  .race-mode .table-top .btn { padding: 4px 9px; font-size: 0.8rem; }
  .race-mode .hud > div { min-height: 30px; padding: 3px 9px; border-radius: 9px; }
  .race-mode .hud-contract .rule { display: none; }
  .race-mode .hud-contract b { font-size: 0.9rem; }
  .race-mode .log { display: none; }
  .race-mode .table { margin: 4px 0 0; min-height: 0; }
  .race-mode .center { left: 156px; right: 128px; top: 0; bottom: 0; container-type: size; align-items: flex-start; }
  .caravan-mode .center { left: 0; right: 0; } /* the map runs under your column and the other players */
  .island-wrap { width: min(100cqw, 100cqh - 66px); }
  .race-mode .seat .pname { max-width: 100px; }
  .race-mode .seat-right, .race-mode .seat-top, .race-mode .seat-left { right: 8px; }
  .race-mode .seat-bottom { left: 4px; }
  .race-mode #race-actions .btn.ghost, .race-mode #race-actions .chip { background: rgba(10, 22, 15, 0.82); }
  .race-mode .die-box { margin-top: 6px; }
  .race-mode .die-box .die-face { width: 50px; height: 50px; }
  .race-mode .seat-bottom { left: 0; right: auto; top: 0; bottom: auto; transform: none; align-items: flex-start; }
  .race-mode .seat-right, .race-mode .seat-top, .race-mode .seat-left { left: auto; right: 0; transform: none; align-items: flex-end; min-width: 0; }
  .race-mode .seat-right { top: 0; }
  .race-mode .seat-top { top: 33%; }
  .race-mode .seat-left { top: 66%; }
  .race-mode .seat .player { gap: 6px; }
  .race-mode .seat .ring { width: 36px; height: 36px; padding: 2px; }
  .race-mode .seat .pname { font-size: 0.74rem; max-width: 76px; }
  .race-mode .seat .pmeta .score { padding: 1px 7px; min-width: 28px; }
  .race-mode .penalties { display: flex; font-size: 0.7rem; }
  .race-mode .penalties .chip { padding: 1px 6px; }
  .race-mode .hand-wrap { position: absolute; left: calc(8px + var(--sal)); bottom: calc(6px + var(--sab)); width: 148px; padding: 0; }
  .race-mode .hand { height: auto; flex-wrap: wrap; justify-content: flex-start; gap: 4px; }
  .race-mode .hand .card { margin: 0 !important; }
  .race-mode .card.u.help { --card-w: 52px; --card-h: 66px; padding: 3px 2px 2px; }
  .race-mode .card.u.help .hc-icon { width: 32px; height: 32px; }
  .race-mode .card.u.help .hc-name { font-size: 0.58rem; }
  .race-mode .card.u.help .hc-text { display: none; }
  .race-mode #race-actions { justify-content: flex-start; margin-top: 6px; gap: 6px; }
  .race-mode #race-actions .btn { padding: 5px 10px; font-size: 0.8rem; }
  .race-mode #race-actions .chip { font-size: 0.7rem; }
}
#race-info:empty { display: none; }

/* ---------- race games (Caravan, Treasure Island): every player in one aligned row on top, the board fills all the space below ---------- */
#screen-table.race-mode .log { display: none; }
#screen-table.race-mode .table { display: flex; justify-content: space-evenly; align-items: flex-start; gap: 8px; margin: 4px 0 0; min-height: 0; }
#screen-table.race-mode .seat { position: static; inset: auto; transform: none; min-width: 0; flex: 0 1 auto; align-items: center; gap: 2px; }
#screen-table.race-mode .seat:empty { display: none; }
#screen-table.race-mode .seat-bottom { order: -1; }
#screen-table.race-mode .seat .player { flex-direction: row; width: auto; max-width: none; padding: 0; gap: 6px; border-radius: 0; }
#screen-table.race-mode .seat .ring { width: 38px; height: 38px; padding: 2px; }
#screen-table.race-mode .seat .pinfo { align-items: flex-start; width: auto; }
#screen-table.race-mode .seat .pname { font-size: 0.78rem; max-width: 92px; text-align: start; }
#screen-table.race-mode .seat .pname small { display: none; }
#screen-table.race-mode .seat .pmeta { justify-content: flex-start; font-size: 0.78rem; }
#screen-table.race-mode .penalties { display: flex; justify-content: center; max-width: none; margin: 0; font-size: 0.7rem; }
#screen-table.race-mode .penalties .chip { padding: 1px 7px; }
#screen-table.race-mode .center { position: absolute; top: 68px; right: 0; bottom: 0; left: 0; inset: 68px 0 0 0; container-type: size; padding: 0; align-items: flex-start; justify-content: center; }
#screen-table.race-mode .die-label:empty { display: none; }
.island-wrap { width: min(100cqw - 8px, 100cqh - 76px, 680px); margin: 0; }
@media (orientation: landscape) and (max-height: 500px) {
  #screen-table.race-mode .center { inset: 64px 0 0 0; }
  #screen-table.race-mode .seat .ring { width: 34px; height: 34px; }
}
/* the island is square: it sits in the middle of the space below the players (with room for the die under it) */
#screen-table.island-mode .center { align-items: center; }
#screen-table.island-mode .island-wrap { margin-bottom: 70px; }

/* ---------- our own confirm window ---------- */
#modal-confirm { z-index: 60; }
.confirm-card { max-width: 340px; text-align: center; padding: 22px 20px 18px; border-color: rgba(231,193,90,0.35); }
.confirm-icon { font-size: 2.4rem; line-height: 1; margin-bottom: 8px; }
.confirm-card h3 { margin: 0 0 6px; }
.confirm-card p { margin: 0; }
.confirm-btns { justify-content: center; gap: 10px; margin: 18px 0 0; }
.confirm-btns .btn { min-width: 110px; }

/* the table colour only changes the oval felt — not shown where there is none */
.chess-mode #btn-table { display: none; }
.help-btn { width: 34px; padding-left: 0 !important; padding-right: 0 !important; font-weight: 800; }
#screen-table.race-mode #btn-legend { display: none; }

/* race games: the rivals in a row on top, you at the bottom — more room for each */
#screen-table.race-mode .seat-bottom { order: 0; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
#screen-table.race-mode .center { inset: 68px 0 64px 0; }
/* the race games' buttons (end the move, whom to raid) sit beside your cards instead of on a row of their own */
#screen-table.race-mode .hand-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 10px; }
#screen-table.race-mode #hand { width: auto; }
#screen-table.race-mode .hud-contract .roll-n { color: #fff; }
#screen-table.race-mode #race-actions { min-height: 0; margin-top: 0; }
@media (orientation: landscape) and (max-height: 500px) {
  /* sideways there is room for everyone in the top row */
  #screen-table.race-mode .seat-bottom { position: static; transform: none; order: -1; }
  #screen-table.race-mode .center { inset: 64px 0 0 0; }
}

/* ---------- the end-of-game window ---------- */
.victory-card { position: relative; overflow: hidden; max-width: 460px; text-align: center; }
.victory-card #round-title { font-size: 1.5rem; color: var(--gold); margin: 4px 0 14px; }
.victory { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.v-winners, .v-others { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px 18px; }
.v-p { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 72px; position: relative; }
.v-p b { font-size: 0.85rem; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-p .v-av { width: 44px; height: 44px; font-size: 1.2rem; opacity: 0.85; }
.v-p.win .v-av { width: 78px; height: 78px; font-size: 2rem; opacity: 1; box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(231,193,90,0.65); animation: v-pop .5s cubic-bezier(.3,1.6,.5,1) both; }
.v-p.win b { font-size: 1rem; }
.v-crown { position: absolute; top: -16px; font-size: 1.4rem; z-index: 1; animation: v-pop .5s .15s cubic-bezier(.3,1.6,.5,1) both; }
.v-res { font-size: 0.78rem; font-weight: 700; padding: 1px 8px; border-radius: 8px; background: rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.15); font-variant-numeric: tabular-nums; }
.v-p.win .v-res { border-color: var(--gold); color: var(--gold); }
.v-p.me b::after { content: " ★"; color: var(--gold); }
.v-sep { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; width: 100%; }
.v-detail { margin: 0; font-size: 0.85rem; color: var(--muted); }
@keyframes v-pop { from { transform: scale(0.3); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.confetti i { position: absolute; top: -20px; border-radius: 2px; opacity: 0.95; animation: confetti-fall var(--d) var(--w) cubic-bezier(.25,.5,.5,1) forwards; }
@keyframes confetti-fall { 0% { transform: translate(0, 0) rotate(0); } 100% { transform: translate(var(--x), 560px) rotate(var(--r)); opacity: 0; } }
/* a bit more air in the end-of-game window */
.victory { gap: 16px; margin-bottom: 22px; }
.victory-card { padding: 26px 22px 22px; }
.victory-card #round-title { margin-bottom: 22px; }
.v-winners { margin-bottom: 4px; }
.v-p { gap: 6px; }
.v-sep { padding-top: 14px; margin-top: 2px; }
.v-detail { margin-top: 4px; line-height: 1.45; }
#round-xp:not(:empty) { margin-bottom: 18px; }
.v-p b { max-width: 120px; }
.v-p.win b { max-width: 170px; }

/* ---------- trix: choosing the contract — a small banner in the middle of the table, your cards stay visible ---------- */
.choose-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; width: max-content; max-width: calc(100% - 16px); padding: 10px 12px 12px; border-radius: 16px; background: rgba(8, 20, 14, 0.9); border: 1px solid rgba(231,193,90,0.45); box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; animation: rise .25s ease-out; }
.cb-title { font-size: 0.82rem; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.cb-cards { display: flex; gap: 8px; justify-content: center; }
.cb-opt { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; cursor: pointer; width: 58px; }
.cb-card { position: relative; width: 56px; height: 78px; border-radius: 7px; background: #fff; color: var(--black); box-shadow: 0 3px 8px rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; font-weight: 800; transition: transform .15s, box-shadow .15s; }
.cb-opt:not(:disabled):hover .cb-card, .cb-opt:not(:disabled):active .cb-card { transform: translateY(-4px); box-shadow: 0 0 0 2px var(--gold), 0 6px 14px rgba(0,0,0,0.5); }
.cb-name { font-size: 0.68rem; font-weight: 700; line-height: 1.15; max-width: 62px; }
.cb-opt:disabled { cursor: default; opacity: 0.32; }
.cb-card .red { color: var(--red); }
.cf-r { position: absolute; left: 5px; top: 4px; font-size: 1.15rem; line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.cf-r .sv { width: 0.85em; height: 0.85em; }
.cf-big { font-size: 2.5rem; line-height: 1; margin-top: 12px; }
.cf-big .sv { width: 1em; height: 1em; }
.cf-suits { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 4px; font-size: 1.15rem; line-height: 1.1; margin-top: 16px; font-style: normal; }
.cf-suits i { font-style: normal; }
.cf-stack { position: relative; width: 30px; height: 40px; }
.cf-stack i { position: absolute; inset: 0; border-radius: 4px; border: 1.5px solid #fff; background: repeating-linear-gradient(135deg, #2b4f9e 0 3px, #4a6fc0 3px 6px); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.cf-stack i:nth-child(1) { transform: rotate(-14deg) translate(-5px, 2px); }
.cf-stack i:nth-child(3) { transform: rotate(14deg) translate(5px, 2px); }
.cf-mix { display: flex; flex-direction: column; font-size: 0.8rem; line-height: 1.15; }
@media (max-width: 420px) { .cb-cards { gap: 5px; } .cb-opt { width: 54px; } .cb-card { width: 50px; height: 70px; } .cf-big { font-size: 2.1rem; } }
.choose-bar { left: 0; right: 0; top: 0; bottom: 0; transform: none; margin: auto; height: fit-content; }

/* no "table events" panel in any game — the table itself shows what happens */
#log-wrap { display: none !important; }

/* ---------- drawn suits: the same on every phone (no emoji) ---------- */
.sv { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; fill: currentColor; }
.card .c small .sv, .card .c2 small .sv { width: 0.95em; height: 0.95em; display: block; margin-top: 1px; }
.card .m .sv { width: 0.9em; height: 0.9em; }
.bslot .card .c small .sv { display: inline-block; margin: 0 0 0 1px; vertical-align: -0.08em; }
.cf-suits .sv { width: 0.85em; height: 0.85em; }
.cf-mix .sv { width: 0.85em; height: 0.85em; vertical-align: -0.1em; }
/* the big suits printed on the felt, in the table's own colour */
.felt::after { content: ""; background-color: var(--tbl-mark); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 460 100'%3E%3Cpath d='M50 5C40 20 10 38 10 60c0 15 13 24 26 20 4-1 7-4 9-7-1 9-5 17-11 22h32c-6-5-10-13-11-22 2 3 5 6 9 7 13 4 26-5 26-20C90 38 60 20 50 5z'/%3E%3Cpath transform='translate(120 0)' d='M50 90C30 74 6 56 6 33 6 18 18 8 31 8c9 0 16 5 19 13 3-8 10-13 19-13 13 0 25 10 25 25 0 23-24 41-44 57z'/%3E%3Cg transform='translate(240 0)'%3E%3Ccircle cx='50' cy='27' r='19'/%3E%3Ccircle cx='27' cy='58' r='19'/%3E%3Ccircle cx='73' cy='58' r='19'/%3E%3Cpath d='M50 40c-4 6-6 14-6 22 0 13-4 22-12 30h36c-8-8-12-17-12-30 0-8-2-16-6-22z'/%3E%3C/g%3E%3Cpath transform='translate(360 0)' d='M50 4l36 46-36 46-36-46z'/%3E%3C/svg%3E") center / min(62%, 430px) auto no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 460 100'%3E%3Cpath d='M50 5C40 20 10 38 10 60c0 15 13 24 26 20 4-1 7-4 9-7-1 9-5 17-11 22h32c-6-5-10-13-11-22 2 3 5 6 9 7 13 4 26-5 26-20C90 38 60 20 50 5z'/%3E%3Cpath transform='translate(120 0)' d='M50 90C30 74 6 56 6 33 6 18 18 8 31 8c9 0 16 5 19 13 3-8 10-13 19-13 13 0 25 10 25 25 0 23-24 41-44 57z'/%3E%3Cg transform='translate(240 0)'%3E%3Ccircle cx='50' cy='27' r='19'/%3E%3Ccircle cx='27' cy='58' r='19'/%3E%3Ccircle cx='73' cy='58' r='19'/%3E%3Cpath d='M50 40c-4 6-6 14-6 22 0 13-4 22-12 30h36c-8-8-12-17-12-30 0-8-2-16-6-22z'/%3E%3C/g%3E%3Cpath transform='translate(360 0)' d='M50 4l36 46-36 46-36-46z'/%3E%3C/svg%3E") center / min(62%, 430px) auto no-repeat; }

/* ---------- card backs: pick one like the table ---------- */
:root, [data-back="classic"] { --back: repeating-linear-gradient(135deg, #2b4f9e 0 4px, #4a6fc0 4px 8px); --back-edge: #ffffff; }
[data-back="shadda"] { --back: radial-gradient(circle at 50% 50%, transparent 0 22%, #e7c15a 23% 27%, transparent 28%), repeating-linear-gradient(45deg, rgba(231,193,90,0.38) 0 1px, transparent 1px 8px), repeating-linear-gradient(-45deg, rgba(231,193,90,0.38) 0 1px, transparent 1px 8px), linear-gradient(160deg, #1f7a57, #0f3d2e); --back-edge: #e7c15a; }
[data-back="arabesque"] { --back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg fill='none' stroke='%23e7c15a' stroke-width='1.1'%3E%3Crect x='5' y='5' width='10' height='10'/%3E%3Crect x='5' y='5' width='10' height='10' transform='rotate(45 10 10)'/%3E%3C/g%3E%3C/svg%3E") center / 13px 13px, linear-gradient(160deg, #1d3a6b, #0e1d3a); --back-edge: #e7c15a; }
[data-back="sadu"] { --back: radial-gradient(circle, #f1e2c0 0 1.3px, transparent 1.8px) 0 2px / 7px 14px, repeating-linear-gradient(0deg, #9c1c1c 0 8px, #1b1b1b 8px 10px, #f1e2c0 10px 12px, #1b1b1b 12px 14px); --back-edge: #f1e2c0; }
[data-back="dunes"] { --back: repeating-radial-gradient(ellipse at 50% 135%, rgba(255,240,210,0.28) 0 2px, transparent 2px 8px), linear-gradient(180deg, #f6c76a, #e08a3c 58%, #8a3b1e); --back-edge: #fff3d6; }
[data-back="night"] { --back: radial-gradient(circle at 66% 27%, #0f1838 0 10%, transparent 10.5%), radial-gradient(circle at 58% 31%, #f3d27a 0 13%, transparent 13.5%), radial-gradient(circle, #ffffff 0 0.8px, transparent 1.2px) 0 0 / 9px 11px, radial-gradient(circle, rgba(255,255,255,0.65) 0 0.6px, transparent 1px) 4px 5px / 13px 9px, linear-gradient(180deg, #0b1230, #263a7a); --back-edge: #d9c27a; }
[data-back="mosaic"] { --back: radial-gradient(circle, #d9a441 0 1.4px, transparent 1.9px) 0 0 / 9px 9px, conic-gradient(from 45deg, #0f7c86 25%, #e8f3ef 0 50%, #0f7c86 0 75%, #e8f3ef 0) 0 0 / 9px 9px; --back-edge: #ffffff; }
[data-back="ruby"] { --back: radial-gradient(circle, rgba(255,215,160,0.55) 0 1.4px, transparent 1.9px) 0 0 / 8px 8px, repeating-linear-gradient(45deg, rgba(0,0,0,0.18) 0 4px, transparent 4px 8px), linear-gradient(160deg, #a3203a, #5a0f1f); --back-edge: #f1d29a; }
.card.back, .cb, .ring .fan i, .cf-stack i { background: var(--back); border-color: var(--back-edge); }
.card.back.u { background: transparent; border: 0; }
.picker-h { margin: 4px 0 8px; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.back-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.bswatch { background: transparent; border: 2px solid transparent; border-radius: 10px; padding: 6px 2px; cursor: pointer; color: var(--muted); font-size: 0.66rem; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: border-color .15s, transform .1s; font-family: inherit; }
.bswatch:hover { transform: translateY(-2px); color: var(--ink); }
.bswatch.sel { border-color: var(--gold); color: var(--ink); background: rgba(231,193,90,0.1); }
.bs-card { display: block; width: 38px; height: 54px; border-radius: 5px; border: 2px solid; background: var(--back); border-color: var(--back-edge); box-shadow: 0 3px 8px rgba(0,0,0,0.45); }

/* ---------- court cards (J, Q, K): base rules (Classic's own layout is in the drawn-card block below) ---------- */
.card.court { overflow: hidden; }
.card .court-img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; object-position: center; border-radius: 3px; pointer-events: none; user-select: none; }
.card.court .c, .card.court .c2 { z-index: 1; background: #fff; border-radius: 3px; padding: 1px 2px 2px 1px; }
.card.court .c2 { padding: 2px 1px 1px 2px; }

/* ---------- card styles ---------- */
/* vintage, modern and playful pictures are whole cards: they fill ours edge to edge */
.card.court.full .court-img { inset: 0; width: 100%; height: 100%; border-radius: inherit; }
.card.joker.full { background: #fff; }
/* the modern deck prints spades and clubs in blue */
:root[data-deck="modern"] .card:not(.red):not(.back) { color: #1d4fa6; }
.deck-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 14px; }
.dswatch { background: transparent; border: 2px solid transparent; border-radius: 10px; padding: 6px 2px; cursor: pointer; color: var(--muted); font-size: 0.7rem; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: border-color .15s, transform .1s; font-family: inherit; }
.dswatch:hover { transform: translateY(-2px); color: var(--ink); }
.dswatch.sel { border-color: var(--gold); color: var(--ink); background: rgba(231,193,90,0.1); }
.ds-card { display: block; width: 44px; height: 62px; border-radius: 5px; overflow: hidden; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,0.45); }
.ds-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ds-card.classic { padding: 2px; }
.ds-card .ds-plain { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; font-weight: 800; font-size: 1.1rem; line-height: 1; color: var(--black); gap: 2px; }
.ds-card .ds-plain.red { color: var(--red); }
.ds-card .ds-plain .sv { width: 1em; height: 1em; }
/* plain cards: the court letter big in the middle, its suit under it */
.ds-card.classic img { border-radius: 3px; }
/* two backs from the modern deck */
[data-back="flame"] { --back: url("art/backs/flame.webp") center / cover, #e8584a; --back-edge: #fff3e6; }
[data-back="flameNight"] { --back: url("art/backs/flame-night.webp") center / cover, #1b2346; --back-edge: #f3d27a; }
.back-picker { grid-template-columns: repeat(5, 1fr); }
/* on whole-card pictures our corner index fully covers the deck's own */
.card.court.full .c { left: 1px; top: 1px; padding: 2px 4px 4px 3px; border-radius: 4px; }
.card.court.full .c2 { right: 1px; bottom: 1px; padding: 4px 3px 2px 4px; border-radius: 4px; }

/* ---------- full decks: the whole card is the deck's own picture ---------- */
.card.face { background: #fff; overflow: hidden; }
.card .face-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; pointer-events: none; user-select: none; }


/* contract cards drawn from the chosen card style */
.cb-card.art { background: transparent; box-shadow: none; overflow: visible; }
.cb-card.art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; box-shadow: 0 3px 8px rgba(0,0,0,0.45); background: #fff; }
.cb-card.art.classic img { padding: 2px; }
.cb-card.art.fan img { inset: auto; left: 15%; top: 6%; width: 70%; height: 88%; transform-origin: 50% 110%; transform: rotate(var(--a)); }
.cb-opt:not(:disabled):hover .cb-card.art, .cb-opt:not(:disabled):active .cb-card.art { box-shadow: none; }
.cb-opt:not(:disabled):hover .cb-card.art img { box-shadow: 0 0 0 2px var(--gold), 0 6px 14px rgba(0,0,0,0.5); }

/* classic ltoosh: a small trick of four cards */
.cf-trick { position: relative; width: 36px; height: 48px; }
.cf-trick i { position: absolute; left: 9px; top: 6px; width: 18px; height: 26px; border-radius: 3px; background: #fff; border: 1px solid #bbb; box-shadow: 0 1px 3px rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; font-style: normal; transform-origin: 50% 120%; color: var(--black); }
.cf-trick i.red { color: var(--red); }
.cf-trick i .sv { width: 10px; height: 10px; }
.cf-trick i:nth-child(1) { transform: rotate(-24deg); } .cf-trick i:nth-child(2) { transform: rotate(-8deg); } .cf-trick i:nth-child(3) { transform: rotate(8deg); } .cf-trick i:nth-child(4) { transform: rotate(24deg); }

/* ---------- card games on a phone: big cards in the hand, spread over the full width ---------- */
/* phones, and any screen held upright (tablets too): the hand grows with the screen instead of staying small under a huge table */
@media (max-width: 760px), (max-height: 500px), (orientation: portrait) {
  .hand:not(.rummy):not(.wahed):not(.domino):not(.help) { --card-w: min(92px, 23vw); --card-h: calc(var(--card-w) * 1.42); width: 100%; }
  .hand:not(.rummy):not(.wahed):not(.domino):not(.help) .card { margin-left: var(--ov, calc(var(--card-w) * -0.6)); }
  .hand:not(.rummy):not(.wahed):not(.domino):not(.help) .card:first-child { margin-left: 0; }
  /* cards on the table a bit bigger too */
  #screen-table:not(.chess-mode) .trick { --card-w: clamp(56px, 7vw, 72px); --card-h: calc(var(--card-w) * 1.43); }
}
/* touch screens: no sticky hover lift */
@media (hover: none) { .hand .card.legal:hover { transform: none; } }

/* ---------- card games sideways on a phone (like Jawaker's landscape) ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  #screen-table:not(.chess-mode) { padding-left: calc(8px + var(--sal)); padding-right: calc(8px + var(--sar)); }
  #screen-table:not(.chess-mode) .table-top { flex-wrap: nowrap; gap: 6px; align-items: center; }
  #screen-table:not(.chess-mode) .table-top .btn { padding: 4px 9px; font-size: 0.78rem; }
  #screen-table:not(.chess-mode) .hud { flex-wrap: nowrap; gap: 6px; overflow: hidden; order: 2; flex: 1; justify-content: flex-end; } /* round and status together at the far end of the row: the middle stays free for the partner */
  #screen-table:not(.chess-mode) .hud > div { min-height: 30px; padding: 3px 9px; border-radius: 9px; }
  #screen-table:not(.chess-mode) .hud-round { order: 3; } /* after the status, at the far end: nothing left under the partner */
  #screen-table:not(.chess-mode) .hud-contract { margin: 0; }
  #screen-table:not(.chess-mode) .hud-contract .rule, #screen-table:not(.chess-mode) .hud-king small { display: none; }
  #screen-table:not(.chess-mode) .hud-contract b { font-size: 0.85rem; white-space: nowrap; }
  #screen-table:not(.chess-mode) .table { margin: 2px 0 0; min-height: 0; }
  #screen-table:not(.chess-mode) .table-surface { left: 140px; right: 140px; top: 4px; bottom: 4px; padding: 6px; }
  /* players around the edges, compact */
  /* the player opposite you sits at the top in the middle, as everywhere else; the score box and the last trick keep the corners */
  #screen-table:not(.chess-mode) .seat-top { top: -38px; left: 53%; transform: translateX(-50%); align-items: center; z-index: 26; } /* a little towards the free end of the row, away from the buttons */
  [dir="rtl"] #screen-table:not(.chess-mode) .seat-top { left: 47%; }
  #screen-table:not(.chess-mode) .seat-top .ring .fan { display: none; } /* the partner's pill sits in the free middle of the top row, above the table's edge, clear of the cards in play */
  #screen-table:not(.chess-mode) .seat-left, #screen-table:not(.chess-mode) .seat-right { top: 56%; }
  #screen-table:not(.chess-mode) .seat-left { left: 4px; }
  #screen-table:not(.chess-mode) .seat-right { right: 4px; }
  #screen-table:not(.chess-mode) .seat .ring { width: 38px; height: 38px; padding: 2px; }
  #screen-table:not(.chess-mode) .seat .pname { font-size: 0.74rem; max-width: 90px; }
  /* your own seat at the left end of the hand row: the left side of the table then holds only the score box and the player on your left.
     Smaller than the others (after them, so it wins), and a long name ends before the first card */
  #screen-table:not(.chess-mode) .seat-bottom { left: 2px; bottom: auto; top: calc(100% - 6px); transform: none; min-width: 0; z-index: 7; gap: 0; }
  #screen-table:not(.chess-mode) .seat-bottom .chip { padding: 1px 6px; font-size: 0.62rem; }
  #screen-table:not(.chess-mode) .seat-bottom .player { padding: 1px 7px 1px 1px; gap: 5px; }
  #screen-table:not(.chess-mode) .seat-bottom .ring { width: 34px; height: 34px; padding: 2px; }
  #screen-table:not(.chess-mode) .seat-bottom .pname { max-width: 56px; font-size: 0.68rem; }
  #screen-table:not(.chess-mode) .penalties { max-width: 130px; }
  /* your hand: big cards along the bottom, only their top part shows (rank, suit and picture) */
  #screen-table:not(.chess-mode) .hand-wrap { height: 74px; overflow: hidden; padding: 4px 0 0; }
  #screen-table:not(.chess-mode) .hand:not(.rummy):not(.wahed) { --card-w: min(86px, 15vh + 20px); height: auto; align-items: flex-start; width: auto; max-width: calc(100% - 200px); margin: 0 92px 0 108px; }
  /* plain cards sideways: only the top of the card shows, so the centre (which would be cut in half) stays hidden and the corner is big */
  #screen-table:not(.chess-mode) #hand .card.drawn .m { display: none; }
  #screen-table:not(.chess-mode) #hand .card.drawn .c { font-size: 1.3rem; left: 7px; top: 6px; }
  #screen-table:not(.chess-mode) .hand.rummy, #screen-table:not(.chess-mode) .hand.wahed { margin-left: 104px; width: auto; } /* room for your seat at the left end of the row */
  #screen-table:not(.chess-mode) .hand .card.legal { transform: translateY(-2px); }
  #screen-table:not(.chess-mode) .hand .card:not(.legal) { transform: translateY(8px); }
  #screen-table:not(.chess-mode) .hand.idle .card { transform: none; }
  #screen-table:not(.chess-mode) .hand-actions { position: absolute; right: 0; top: 4px; margin: 0; }
  #screen-table:not(.chess-mode) #wahed-actions { position: fixed; top: auto; bottom: calc(80px + var(--sab)); right: calc(10px + var(--sar)); z-index: 8; } /* the hand strip clips its children: float on the felt above it */
  #screen-table:not(.chess-mode) #hand-actions { position: fixed; top: auto; bottom: calc(80px + var(--sab)); right: calc(10px + var(--sar)); z-index: 8; } /* Hand: the points and the buttons float on the felt just above the cards (the hand strip clips its own children) */
  /* trix board: four rows instead of columns — sideways there is plenty of width */
  .board { --bc-w: clamp(30px, min(calc((100vw - 330px) / 13 - 3px), calc((100dvh - 200px) / 4 / 1.4)), 52px); --step: calc(var(--bc-w) + 3px); flex-direction: column; height: auto; gap: 5px; }
  .board-col { width: calc(var(--step) * 12 + var(--bc-w)); height: var(--bc-h); }
  .bslot { top: 0; left: calc((12 - var(--i)) * var(--step)); }
}

/* ---------- your hand on a phone: big, Jawaker-style corners so every card reads at a glance ---------- */
.card.face .hi { display: none; }
@media (max-width: 760px), (max-height: 500px) {
  #hand .card.face .hi { position: absolute; left: 0; top: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
    width: max(var(--strip, 26px), 22px); padding: 3px 0 4px; background: var(--hi-bg, #fff); border-radius: 6px 0 6px 0;
    color: var(--hi-black, #161616); font-family: var(--hi-font, Georgia, "Times New Roman", serif); font-weight: 800; line-height: 0.95; }
  #hand .card.face.red .hi { color: var(--hi-red, #c4122f); }
  #hand .card.face .hi b { font-size: clamp(14px, calc(var(--strip, 26px) * 0.78), 24px); letter-spacing: -0.07em; }
  #hand .card.face .hi .sv { width: clamp(11px, calc(var(--strip, 26px) * 0.62), 19px); height: clamp(11px, calc(var(--strip, 26px) * 0.62), 19px); }
}
:root[data-deck="modern"] { --hi-bg: #fbf7f1; --hi-black: #1d4fa6; --hi-red: #d23a2f; --hi-font: "Segoe UI", system-ui, sans-serif; }
:root[data-deck="playful"] { --hi-red: #e3342f; --hi-black: #111; }

/* ---------- the 3D die ---------- */
.die-box .die-face { position: relative; perspective: 320px; filter: none; }
.die-box .die-face::after { content: none; }
.die-box::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 56px; height: 12px; margin-left: -28px; border-radius: 50%; background: rgba(0,0,0,0.38); filter: blur(4px); z-index: -1; pointer-events: none; }
.die-box.rolling::after { animation: die-shadow 1.35s linear; }
@keyframes die-shadow { 0% { transform: scale(0.55); opacity: 0.25; } 22% { transform: scale(0.45); opacity: 0.12; } 45% { transform: scale(1.05); opacity: 1; } 53% { transform: scale(0.85); opacity: 0.6; } 62% { transform: scale(1); opacity: 1; } 69% { transform: scale(0.94); opacity: 0.8; } 76%, 100% { transform: scale(1); opacity: 1; } }
.die3d { width: 100%; height: 100%; }
.die3d .cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .95s cubic-bezier(.14,.68,.24,1); } /* the spin ends as the die lands */
.die3d .cube.snap { transition: none; }
.die3d .cube i { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16%; }
.die3d .cube i svg { width: 100%; height: 100%; display: block; }
.die3d .f1 { transform: translateZ(calc(var(--ds, 56px) / 2)); }
.die3d .f2 { transform: rotateX(90deg) translateZ(calc(var(--ds, 56px) / 2)); }
.die3d .f3 { transform: rotateY(90deg) translateZ(calc(var(--ds, 56px) / 2)); }
.die3d .f4 { transform: rotateY(-90deg) translateZ(calc(var(--ds, 56px) / 2)); }
.die3d .f5 { transform: rotateX(-90deg) translateZ(calc(var(--ds, 56px) / 2)); }
.die3d .f6 { transform: rotateY(180deg) translateZ(calc(var(--ds, 56px) / 2)); }
.die-box .die-face { --ds: 66px; width: var(--ds) !important; height: var(--ds) !important; }
.die-box .die-face.tumble { animation: none; }
/* thrown in from above: lands, bounces twice and settles while the cube slows down */
.die-box .die-face.toss { animation: die-toss 1.35s linear; }
/* a throw from your side of the table: up out of the hand (bigger as it comes nearest), down onto the table at 45%, a bounce,
   a smaller one, a last tap, still — the spin (showDie) is timed to the same moments */
@keyframes die-toss {
  0% { transform: translate(-30px, 70px) scale(0.8); animation-timing-function: cubic-bezier(.2,.5,.5,1); }
  22% { transform: translate(8px, -54px) scale(1.22); animation-timing-function: cubic-bezier(.55,0,.85,.45); }
  45% { transform: translate(-6px, 0) scale(1); animation-timing-function: cubic-bezier(.2,.6,.5,1); }
  53% { transform: translate(-4px, -17px) scale(1.03); animation-timing-function: cubic-bezier(.55,0,.85,.45); }
  62% { transform: translate(-2px, 0) scale(1); animation-timing-function: cubic-bezier(.2,.6,.5,1); }
  69% { transform: translate(-1px, -6px); animation-timing-function: cubic-bezier(.55,0,.85,.45); }
  76% { transform: translate(0, 0); animation-timing-function: ease-out; }
  81% { transform: translate(0, -2px); }
  86%, 100% { transform: none; }
}
.die-box.mine .die-face { animation: die-ready 1.4s ease-in-out infinite; }
@keyframes die-ready { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.die-box .die-label.hidden { display: none; }

/* ---------- caravan: the die has its own strip under the map (it never covers the road) ---------- */
.caravan-wrap { display: flex; flex-direction: column; gap: 8px; }
.caravan-wrap .cv-scroll { position: relative; inset: auto; flex: 1; min-height: 0; }
.caravan-wrap .die-box { position: static; transform: none; margin: 0 auto; padding: 4px 14px 4px 8px; flex: none; }
/* camels walk tile by tile with a little hop */
.token.camel { transition: left var(--step, .27s) linear, top var(--step, .27s) linear; }
.token.camel.hop > .art { animation: camel-hop var(--step, .27s) ease-out; }
@keyframes camel-hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-9px) rotate(-3deg); } }

/* ---------- tricks: cards slide in from their player, then go to whoever took the trick ---------- */
.trick .card { animation: none; transform: var(--pos); }
.trick .card[data-rel="0"] { --pos: translateY(44px); --from: translate(0, 240px) rotate(6deg); }
.trick .card[data-rel="1"] { --pos: translateX(-54px); --from: translate(-260px, 0) rotate(-14deg); }
.trick .card[data-rel="2"] { --pos: translateY(-44px); --from: translate(0, -240px) rotate(-6deg); }
.trick .card[data-rel="3"] { --pos: translateX(54px); --from: translate(260px, 0) rotate(14deg); }
.trick .card.enter { animation: card-in .34s cubic-bezier(.2,.75,.3,1); }
/* a card you dragged onto the table settles where you dropped it (it does not fly in from your hand again) */
.trick .card.landed { animation: card-land .2s ease-out; }
@keyframes card-land { from { transform: var(--pos) scale(1.08) rotate(-4deg); } to { transform: var(--pos); } }
@keyframes card-in { from { transform: var(--from) scale(0.92); opacity: 0.4; } to { transform: var(--pos); opacity: 1; } }
.trick.collect .card { transition: transform .5s cubic-bezier(.5,0,.75,0), opacity .5s ease-in; opacity: 0; }
.trick.collect[data-to="0"] .card { transform: translate(0, 260px) scale(0.55); }
.trick.collect[data-to="1"] .card { transform: translate(-280px, 0) scale(0.55); }
.trick.collect[data-to="2"] .card { transform: translate(0, -260px) scale(0.55); }
.trick.collect[data-to="3"] .card { transform: translate(280px, 0) scale(0.55); }

/* ---------- wahed on a phone: big cards across the width; played cards slide onto the pile ---------- */
@media (max-width: 760px), (max-height: 500px) {
  .hand.wahed { --card-w: min(86px, 22vw); --card-h: calc(var(--card-w) * 1.5); width: 100%; }
  .hand.wahed .card { margin-left: var(--ov, calc(var(--card-w) * -0.5)); }
  .hand.wahed .card:first-child { margin-left: 0; }
  .wahed-center { --card-w: 70px; --card-h: 105px; }
}
.wpile .card.enter[data-rel="0"] { --from: translate(0, 220px) rotate(8deg); }
.wpile .card.enter[data-rel="1"] { --from: translate(-240px, 0) rotate(-16deg); }
.wpile .card.enter[data-rel="2"] { --from: translate(0, -220px) rotate(-8deg); }
.wpile .card.enter[data-rel="3"] { --from: translate(240px, 0) rotate(16deg); }
.wpile .card.enter { animation: pile-in .36s cubic-bezier(.2,.75,.3,1); }
.wpile .card.landed { animation: pile-land .2s ease-out; }
@keyframes pile-land { from { transform: scale(1.08) rotate(-4deg); } to { transform: none; } }
@keyframes pile-in { from { transform: var(--from) scale(0.9); opacity: 0.5; } to { transform: none; opacity: 1; } }

/* race games upright: you on the left and the die on the right share the bottom row — the board gets the rest */
@media not ((orientation: landscape) and (max-height: 500px)) {
  #screen-table.race-mode .seat-bottom { left: 6px; bottom: 4px; transform: none; }
  #screen-table.race-mode .center { inset: 68px 0 0 0; }
  .caravan-wrap .die-box { margin: 0 4px 0 auto; }
  .island-wrap .die-box, .island-wrap:has(.dpad) .die-box { left: auto; right: 4px; transform: none; margin: 8px 0 0; }
  #screen-table.island-mode .island-wrap { margin-bottom: 76px; }
}
.die-box .die-label { max-width: 170px; white-space: normal; line-height: 1.2; }

/* the die: a solid inner core fills the rounded corners; faces are shaded a touch so it reads as a cube */
.die3d .cube b.core { position: absolute; inset: 6px; background: #f3f3f3; }
.die3d .cube b.core.f1 { transform: translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube b.core.f2 { transform: rotateX(90deg) translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube b.core.f3 { transform: rotateY(90deg) translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube b.core.f4 { transform: rotateY(-90deg) translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube b.core.f5 { transform: rotateX(-90deg) translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube b.core.f6 { transform: rotateY(180deg) translateZ(calc(var(--ds, 56px) / 2 - 6px)); }
.die3d .cube i svg rect { stroke: #d2d2d2; stroke-width: 1; }
.die3d .cube i.f3 svg, .die3d .cube i.f4 svg { filter: brightness(0.93); }
.die3d .cube i.f2 svg, .die3d .cube i.f5 svg { filter: brightness(0.97); }
#race-info { background: none; border: 0; color: var(--gold); font-weight: 700; }

/* seats: just the player — dealer and partner as small badges, no chips that repeat the top bar */
.dealer-badge, .partner-badge { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto; }
.dealer-badge { right: -4px; bottom: -2px; width: 18px; height: 18px; background: #f6efdf; color: #1b2033; font-size: 0.66rem; font-weight: 900; border: 1.5px solid #1b2033; }
.partner-badge { left: -5px; bottom: -3px; width: 20px; height: 20px; background: var(--gold); font-size: 0.7rem; }
#screen-table.team-score .pmeta .score { display: none; }

/* top bar on a phone: what is happening always gets room; the team box stays compact */
@media (max-width: 760px) {
  .table-top .hud .hud-contract { flex: 1 1 120px; min-width: 110px; }
  .table-top .hud .hud-teams { flex: 0 0 auto; gap: 6px !important; padding: 3px 8px; }
  .table-top .hud .hud-teams .tm b { font-size: 0.95rem; }
  .table-top .hud .hud-teams .tm em { font-size: 0.6rem; }
}
@media (max-width: 760px) { .table-top .hud .hud-round small:last-child:not(:first-child) { display: none; } .table-top .hud .hud-round { padding-inline: 8px; } }

/* hand (rummy) on a phone: big cards, the whole hand fits the width */
@media (max-width: 760px), (max-height: 500px) {
  .hand.rummy { --card-w: min(66px, 17.5vw); --card-h: calc(var(--card-w) * 1.45); width: 100%; justify-content: center; }
  .hand.rummy .card, .hand.rummy .grp + .grp .card:first-child { margin-left: var(--ov, calc(var(--card-w) * -0.5)); }
  .hand.rummy .grp:first-child .card:first-child { margin-left: 0; }
  .hand.rummy .grp.meld { margin: 0 5px; }
  .hand.rummy .grp.meld .card:first-child, .hand.rummy .grp.meld + .grp .card:first-child { margin-left: var(--ov, 0); }
  .hand.rummy .grp.meld:first-child .card:first-child { margin-left: 0; }
}
@media (max-width: 760px) { .hand-center:not(.wahed-center) { --card-w: 62px; --card-h: 90px; } }
/* hand on a phone, upright or sideways: the sets on the table never go under a player — compact sets (small cards, a small
   owner avatar) in their own space, scrolling with a quiet scrollbar when there are more than fit */
@media (max-width: 760px), (max-height: 500px) {
  #screen-table.game-hand .table-melds { gap: 6px 8px; --card-w: 24px; --card-h: 35px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.3) transparent; }
  #screen-table.game-hand .tmeld { padding: 4px 6px 4px 3px; border-radius: 8px; }
  #screen-table.game-hand .tmeld .card { margin-left: -12px; }
  #screen-table.game-hand .tmeld .card:first-of-type { margin-left: 0; }
  #screen-table.game-hand .tmeld .owner { margin-right: 4px; }
  #screen-table.game-hand .tmeld .owner .avatar { width: 16px; height: 16px; }
  #screen-table.game-hand .hand-center { max-width: none; width: 100%; min-height: 0; }
  #screen-table.game-hand .piles { flex: none; }
  #screen-table.game-hand .pile small { max-width: 80px; text-align: center; line-height: 1.25; }
}
/* upright: the piles sit under the top player with the side players beside them; the sets get the whole width below, down to
   your seat (centred in that space) */
@media (max-width: 760px) and (orientation: portrait) {
  #screen-table.game-hand .center { align-items: stretch; padding: 100px 8px 86px; }
  #screen-table.game-hand .seat-left, #screen-table.game-hand .seat-right { top: 100px; transform: none; }
  /* "laid down" is a badge on the avatar's top corner, so no seat grows a line when its player lays down */
  #screen-table.game-hand .seat .penalties { position: absolute; top: -7px; left: calc(50% + 10px); z-index: 3; margin: 0; pointer-events: none; }
  #screen-table.game-hand .seat .penalties .chip { font-size: 0.62rem; padding: 2px 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
  #screen-table.game-hand .hand-center { gap: 8px; }
  #screen-table.game-hand .table-melds { max-height: none; flex: 0 1 auto; min-height: 0; margin-block: auto; }
}
@media (max-width: 760px) and (orientation: portrait) and (max-height: 700px) { #screen-table.game-hand .piles { --card-w: 46px; --card-h: 67px; gap: 24px; } #screen-table.game-hand .pile { gap: 4px; } }
/* sideways: the piles at one end and the sets beside them, between the side players, under the top player and above the line
   with your points */
@media (max-height: 500px) and (orientation: landscape) {
  #screen-table.game-hand .center { align-items: stretch; padding: 30px 104px 34px; }
  #screen-table.game-hand .hand-center { flex-direction: row; align-items: center; gap: 16px; }
  #screen-table.game-hand .table-melds { flex: 1 1 0; min-width: 0; max-height: 100%; align-content: flex-start; }
}

/* dominoes upright on a phone: the side players move up to the corners — the chain gets the whole middle */
@media (max-width: 760px) and (orientation: portrait) {
  #screen-table.domino-mode .seat-left, #screen-table.domino-mode .seat-right { top: 13%; }
  #screen-table.domino-mode .domino-wrap { width: 96vw; height: 46vh; margin-top: 8vh; }
  /* the top-left corner is the left player's now: the scores go to the bottom-left corner, beside your seat (your name stays clear of them) */
  #screen-table.domino-mode .scorebox { top: auto; bottom: 6px; }
  #screen-table.domino-mode .seat-bottom .pname { max-width: calc(100vw - 250px); }
}
@media (max-width: 560px) { .hand.domino .dtile .tile { width: 40px; height: 80px; } }
/* tawla upright on a phone: the board turns on its side and fills the screen (more than twice as big) */
@media (max-width: 760px) and (orientation: portrait) {
  .chess-mode .tawla-wrap { --tw: min(94vw, calc((100dvh - 290px) * 0.64)); width: var(--tw); max-width: none; aspect-ratio: 640 / 1000; position: relative; }
  .chess-mode .tawla-wrap .tawla { position: absolute; left: 50%; top: 50%; width: calc(var(--tw) * 1.5625); height: auto; transform: translate(-50%, -50%) rotate(90deg); }
}

.tawla .tdie.roll { transform-box: fill-box; transform-origin: center; animation: tdie-roll .8s cubic-bezier(.2,.7,.3,1); }
.tawla .tdie.roll:nth-of-type(1) { animation-delay: 0s; }
@keyframes tdie-roll { 0% { transform: translate(-60px, -40px) rotate(-260deg) scale(0.5); opacity: 0.2; } 55% { transform: translate(4px, 0) rotate(18deg) scale(1.08); opacity: 1; } 75% { transform: rotate(-6deg) scale(0.98); } 100% { transform: none; } }

/* ---------- card tables: names under the picture, scores in one box, the contract as a small pill ---------- */
#screen-table:not(.chess-mode) .seat .player { flex-direction: column; align-items: center; gap: 3px; }
#screen-table:not(.chess-mode) .seat .pinfo { align-items: center; }
#screen-table:not(.chess-mode) .seat .pname { text-align: center; }
#screen-table:not(.chess-mode) .seat .pmeta { justify-content: center; }
#screen-table.scorebox-on .seat .pmeta .score, #screen-table.scorebox-on .seat .pmeta .delta { display: none; }
/* the score box: top-left corner, each score where its player sits */
.scorebox { position: absolute; left: 6px; top: 6px; z-index: 3; width: 92px; height: 92px; border-radius: 14px; background: rgba(6, 14, 10, 0.55); border: 1px solid rgba(255,255,255,0.1); }
.scorebox .sb { position: absolute; min-width: 36px; height: 24px; padding: 0 6px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #0b1712; border: 1px solid rgba(255,255,255,0.14); font-variant-numeric: tabular-nums; }
.scorebox .sb b { font-size: 0.82rem; color: var(--ink); }
.scorebox .sb.neg b { color: #ff9b94; }
.scorebox .sb.pos b { color: #8fe3a8; }
.scorebox .sb.turn { border-color: var(--gold); box-shadow: 0 0 8px rgba(231,193,90,0.6); }
.scorebox .sb.r0 { left: 50%; bottom: 4px; transform: translateX(-50%); }
.scorebox .sb.r1 { left: 4px; top: 50%; transform: translateY(-50%); }
.scorebox .sb.r2 { left: 50%; top: 4px; transform: translateX(-50%); }
.scorebox .sb.r3 { right: 4px; top: 50%; transform: translateY(-50%); }
.scorebox .sb i { position: absolute; top: -13px; right: -6px; font-style: normal; font-size: 0.66rem; font-weight: 800; padding: 0 4px; border-radius: 6px; background: #0b1712; animation: deltaPop .35s ease-out; }
.scorebox .sb i.neg { color: #ff9b94; } .scorebox .sb i.pos { color: #8fe3a8; }
/* the contract: a small pill on the right of the top bar, not a long banner */
#screen-table:not(.chess-mode) .hud { justify-content: flex-end; }
#screen-table:not(.chess-mode) .hud .hud-contract { flex: 0 1 auto; min-width: 0; max-width: 62%; }
#screen-table:not(.chess-mode) .hud .hud-contract .rule { display: none; }
#screen-table:not(.chess-mode) .hud .hud-round { margin-inline-end: auto; }

/* ---------- doubled cards ---------- */
/* in your hand: a gold outline and a gold ×2 tab on the visible left edge */
.card.doubled::before { content: none; }
.card.doubled { box-shadow: 0 0 0 2px var(--gold), 0 2px 6px rgba(0,0,0,0.4); overflow: visible; }
.card.doubled::after { content: "×2"; position: absolute; left: 3px; top: -10px; z-index: 3; padding: 1px 5px; border-radius: 6px; background: var(--gold); color: #2b2203; font-size: 0.62rem; font-weight: 900; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
/* on the table, bottom-left: who doubled what */
.dbl-panel { position: absolute; left: 6px; bottom: 6px; z-index: 3; display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px 4px; border-radius: 12px; background: rgba(6, 14, 10, 0.6); border: 1px solid rgba(231,193,90,0.35); --card-w: 34px; --card-h: 48px; }
.dbl-panel > small { align-self: center; color: var(--gold); font-weight: 900; font-size: 0.8rem; }
.dbl-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dbl-item .card { width: var(--card-w); height: var(--card-h); box-shadow: 0 0 0 1.5px var(--gold); }
.dbl-item .card::after { content: none; }
.dbl-item span { font-size: 0.6rem; color: var(--muted); max-width: 48px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the score box, smaller */
.scorebox { width: 74px; height: 74px; border-radius: 11px; left: 4px; top: 4px; }
.scorebox .sb { min-width: 28px; height: 19px; padding: 0 4px; border-radius: 10px; }
.scorebox .sb b { font-size: 0.7rem; }
.scorebox .sb.r0 { bottom: 3px; } .scorebox .sb.r1 { left: 3px; } .scorebox .sb.r2 { top: 3px; } .scorebox .sb.r3 { right: 3px; }
.scorebox .sb i { top: -11px; font-size: 0.6rem; }

/* another player's doubled cards, open next to them */
.seat-dbl { position: absolute; top: 2px; z-index: 3; display: flex; align-items: center; gap: 3px; padding: 4px 5px; border-radius: 9px; background: rgba(6, 14, 10, 0.6); border: 1px solid rgba(231,193,90,0.35); --card-w: 28px; --card-h: 40px; pointer-events: none; }
.seat-dbl > small { color: var(--gold); font-weight: 900; font-size: 0.66rem; }
.seat-dbl .card { width: var(--card-w); height: var(--card-h); box-shadow: 0 0 0 1.5px var(--gold); flex: none; }
.seat-dbl .card::after { content: none; }
.seat-left .seat-dbl, .seat-top .seat-dbl { left: calc(100% + 2px); }
.seat-right .seat-dbl { right: calc(100% + 2px); }

/* score box: a bit wider than tall so four-character scores fit side by side */
.scorebox { width: 96px; height: 66px; }
.scorebox .sb { min-width: 30px; }
.scorebox .sb.delta { border-color: currentColor; animation: deltaPop .35s ease-out; }
.scorebox .sb.delta.neg { color: #ff9b94; } .scorebox .sb.delta.pos { color: #8fe3a8; }
.scorebox .sb.delta b { color: inherit; }

/* doubled cards as small chips (like the cards under a name), with a gold frame */
.mini.dbl { box-shadow: 0 0 0 1.5px var(--gold); }
.dbl-tag { font-size: 0.62rem; font-weight: 900; color: var(--gold); align-self: center; }
.dbl-panel { gap: 4px; padding: 5px 7px; align-items: center; }
/* the last trick: top-right corner, each card where its player sits */
.last-trick { position: absolute; right: 4px; top: 4px; z-index: 3; width: 96px; height: 66px; border-radius: 11px; background: rgba(6, 14, 10, 0.55); border: 1px solid rgba(255,255,255,0.1); }
.last-trick > small { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: 0.5rem; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.last-trick .lt { position: absolute; }
.last-trick .lt .mini { font-size: 0.66rem; padding: 1px 4px; }
.last-trick .lt .mini.won { box-shadow: 0 0 0 1.5px var(--gold); }
.last-trick .lt.r0 { left: 50%; bottom: 3px; transform: translateX(-50%); }
.last-trick .lt.r1 { left: 3px; top: 50%; transform: translateY(-50%); }
.last-trick .lt.r2 { left: 50%; top: 3px; transform: translateX(-50%); }
.last-trick .lt.r3 { right: 3px; top: 50%; transform: translateY(-50%); }

/* the score box in every card game: the Us / Them block in the top bar gives way to it */
#screen-table.scorebox-on .hud .hud-teams { display: none; }
#screen-table.scorebox-on .seat .pmeta .score { display: none; }
.scorebox .sb.us { border-color: rgba(143, 227, 168, 0.5); }
.hud-contract .bid-prog { margin-inline-start: 4px; padding: 0 6px; border-radius: 8px; background: rgba(231, 193, 90, 0.18); color: var(--gold); font-variant-numeric: tabular-nums; }

/* a table on this device (bots only): no code or invite to share */
#screen-room.local .invite { display: none; }
#online.offline { color: var(--gold); }

/* the die, solid: square faces meet along whole edges (no notches); the darker rim of each face reads as a rounded edge;
   the light is set per face from how it faces (lightDie in app.js) */
/* each face is a picture of the real die (its rounded silhouette is in the picture); the drawn face underneath only shows if the picture is missing */
.die3d .cube i { border-radius: 0; overflow: visible; box-shadow: none; background: none; }
.die3d .cube i img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 1; }
.die3d .cube i svg { border-radius: 22%; }
.die3d .cube b.core { inset: 2%; border-radius: 12%; background: #f4f4f4; }
.die3d .cube i svg, .die3d .cube i.f3 svg, .die3d .cube i.f4 svg, .die3d .cube i.f2 svg, .die3d .cube i.f5 svg { filter: none; }
.die-box .die-face { perspective: 420px; }

/* ---------- top bar: you (profile, coins, language, notifications) with the logo in the middle ---------- */
.app-top { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(8px + var(--sat)) max(12px, calc((100% - var(--lobby-w)) / 2)) 8px; background: #071f16; border-bottom: 1px solid rgba(231, 193, 90, 0.2); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }
.app-top .top-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.app-top .top-end { justify-content: flex-end; }
.top-profile { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; max-width: 78px; font-family: inherit; }
.top-profile .avatar { width: 38px; height: 38px; background: rgba(255, 255, 255, 0.12); box-shadow: 0 0 0 2px rgba(231, 193, 90, 0.75); font-size: 1.05rem; }
.top-profile:hover .avatar { box-shadow: 0 0 0 2px var(--gold); }
.top-name { display: block; max-width: 78px; font-size: 0.68rem; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-name .lvl { font-size: 0.6rem; }
.app-top .top-coins { padding: 4px 9px; font-size: 0.78rem; }
.top-logo { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.top-logo .mark { width: 34px; height: 34px; }
.top-logo-text { display: flex; flex-direction: column; line-height: 1.05; }
.top-logo-text .online { font-size: 0.6rem; font-weight: 600; color: var(--muted); }
.top-logo-text .online.offline { color: var(--gold); }
.top-icon { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); color: var(--ink); cursor: pointer; padding: 0; text-decoration: none; }
.top-icon svg { width: 20px; height: 20px; }
.top-icon:hover { border-color: var(--gold); }
.notif-count { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #d9463b; color: #fff; font-size: 0.62rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px #071f16; }
.top-lang { height: 36px; min-width: 44px; padding: 0 10px; border-radius: 18px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); color: var(--ink); font-weight: 800; font-size: 0.8rem; cursor: pointer; font-family: "Segoe UI", Tahoma, sans-serif; }
.top-lang:hover { border-color: var(--gold); }
html[lang="ar"] .top-lang .to-ar, html:not([lang="ar"]) .top-lang .to-en { display: none; }
@media (max-width: 400px) {
  .app-top { gap: 4px; padding-inline: 10px; }
  .top-logo { font-size: 1rem; gap: 5px; }
  .top-logo .mark { width: 30px; height: 30px; }
  .app-top .top-side { gap: 6px; }
  .top-lang { min-width: 40px; padding: 0 8px; }
}
/* notifications */
.notif-panel { position: fixed; z-index: 45; top: calc(64px + var(--sat)); inset-inline-end: max(10px, calc((100% - var(--lobby-w)) / 2)); width: min(360px, calc(100vw - 20px)); max-height: min(70vh, 520px); overflow: auto;
  background: #0b2a1f; border: 1px solid rgba(231, 193, 90, 0.3); border-radius: 16px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); padding: 10px; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); margin-bottom: 6px; }
.notif { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-radius: 10px; }
.notif + .notif { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.notif.new { background: rgba(231, 193, 90, 0.08); }
.notif-icon { font-size: 1.2rem; width: 28px; text-align: center; flex: none; }
.notif-body { flex: 1; min-width: 0; font-size: 0.86rem; line-height: 1.3; }
.notif-body small { font-size: 0.7rem; }
.notif-empty { padding: 18px 8px; text-align: center; font-size: 0.86rem; }
/* ---------- bottom bar: the app (games, store, challenges) — not while you play ---------- */
.app-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px max(8px, calc((100% - var(--lobby-w)) / 2)) calc(6px + var(--sab)); background: #071f16; border-top: 1px solid rgba(231, 193, 90, 0.2); box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4); }
.app-nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0 3px; background: none; border: 0; color: var(--muted); font-family: inherit; font-size: 0.74rem; font-weight: 700; cursor: pointer; border-radius: 12px; }
.app-nav button svg { width: 25px; height: 25px; }
.app-nav button.sel { color: var(--gold); }
.app-nav button.sel svg { filter: drop-shadow(0 0 6px rgba(231, 193, 90, 0.45)); }
body.with-bars .screen { padding-top: 14px; padding-bottom: calc(84px + var(--sab)); }
/* store and challenges: coming soon */
.soon-page { max-width: 420px; margin: 12vh auto 0; text-align: center; padding: 28px 22px; background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 20px; }
.soon-icon { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: var(--gold); background: rgba(231, 193, 90, 0.1); border: 1px solid rgba(231, 193, 90, 0.35); }
.soon-icon svg { width: 36px; height: 36px; }
.soon-page h2 { margin: 0 0 6px; }
/* phones: the logo stacks (mark above the name) so the profile + coins and the language + bell fit beside it;
   the online count gives way, "Offline" takes the name's place when there is no internet */
@media (max-width: 440px) {
  .top-logo { flex-direction: column; gap: 1px; font-size: 0.74rem; }
  .top-logo .mark { width: 30px; height: 30px; }
  .top-logo-text { align-items: center; }
  .top-logo-text .online { display: none; }
  .top-logo-text .online.offline { display: block; }
  .top-logo-text:has(.online.offline) > span:first-child { display: none; }
  .top-profile, .top-name { max-width: 66px; }
  .app-top .top-coins { padding: 3px 7px; font-size: 0.72rem; }
}
/* the top bar's middle: just the shadda mark (no name, no online count); "Offline" shows under it without internet */
.top-logo-text > span:first-child, .top-logo-text .online { display: none !important; }
.top-logo-text .online.offline { display: block !important; font-size: 0.62rem; }
.top-logo { flex-direction: column; gap: 1px; }
.top-logo .mark { width: 36px; height: 36px; }
/* the games stand on their own as cards (no box around them) */
.games .game-card { background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.28)), rgba(4, 22, 16, 0.35); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); }
/* the shadda mark in the top bar, a bit bigger */
.top-logo .mark { width: 46px; height: 46px; }
/* Trix: the king wears a bigger crown on his seat; the kingdom's contracts (dots) sit in the contract pill */
.crown-badge { top: -15px; right: -11px; font-size: 22px; transform: rotate(16deg); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); z-index: 3; }
.hud-contract.with-dots { flex-direction: row; align-items: center; gap: 8px; }
.hud-contract.with-dots .kdots { display: inline-flex; gap: 3px; }
#screen-table .hud .hud-contract.with-dots { flex-direction: row; align-items: center !important; gap: 8px !important; }
/* the profile group: picture with the level on its corner, the name under it; the coins as a button like the ones on the other side */
.app-top .top-start { align-items: flex-start; gap: 10px; }
.top-avatar { position: relative; display: block; line-height: 0; }
.top-lvl { position: absolute; bottom: -3px; inset-inline-end: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center;
  background: var(--gold); color: #2b2203; font-size: 0.62rem; font-weight: 900; line-height: 1; box-shadow: 0 0 0 2px #071f16; }
.top-name { margin-top: 2px; text-align: center; }
.app-top .top-coins { height: 36px; margin-top: 1px; padding: 0 12px 0 9px; border-radius: 18px; gap: 6px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(231, 193, 90, 0.45); color: var(--gold); font-size: 0.82rem; font-weight: 800; }
.app-top .top-coins:hover { background: rgba(231, 193, 90, 0.14); border-color: var(--gold); }
@media (max-width: 440px) { .app-top .top-coins { height: 32px; margin-top: 3px; padding: 0 9px 0 7px; font-size: 0.74rem; } .app-top .top-start { gap: 6px; } }

/* Facebook in the footer; the lobby gets the footer under the games */
.site-foot .foot-fb { display: inline-flex; align-items: center; gap: 5px; }
.site-foot .foot-fb svg { width: 15px; height: 15px; color: #4a90e2; }
.site-foot { flex-wrap: wrap; }
.lobby-foot { margin: 22px 0 6px; }

/* ---------- reels (?reel=…): only the game — no menus, buttons or toasts — with an intro card and a call to action ---------- */
/* (a tour, ?reel=tour, shows the app's own pages: its menus and toasts stay) */
body.reel:not(.tour) #app-top, body.reel:not(.tour) #app-nav, body.reel:not(.tour) #toast, body.reel:not(.tour) #notif-panel, body.reel:not(.tour) .table-top > button, body.reel .seat .auto-badge, body.reel #tawla-actions, body.reel #hand-actions, body.reel #chess-actions { display: none !important; }
body.reel .hand.rummy { margin-bottom: 18px; } /* the labels under your sets ("run · 9") had the hidden buttons' room below them */
#reel-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity 0.6s ease;
  background: radial-gradient(120% 80% at 50% 0%, #1c7653, #0f4a34 55%, #0a2c1f); }
#reel-overlay.show { opacity: 1; }
#reel-overlay.hide { opacity: 0; }
.reel-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: #fbf3df; animation: reel-in 0.7s cubic-bezier(.2, .8, .3, 1) both; }
.reel-mark .mark { display: block; width: 112px; height: 112px; color: var(--gold); border-radius: 22%; background: linear-gradient(135deg, #1b6e4f, #0c3324); box-shadow: inset 0 0 0 3px rgba(231, 193, 90, 0.55), 0 10px 30px rgba(0, 0, 0, 0.45); margin-bottom: 6px; }
.reel-card b { font-size: 3.1rem; font-weight: 900; line-height: 1.1; }
.reel-card > span:not(.reel-mark) { font-size: 1.45rem; font-weight: 800; color: var(--gold); }
.reel-card i { font-style: normal; margin-top: 16px; padding: 10px 22px; border-radius: 999px; background: #fbf3df; color: #0f4a34; font-weight: 800; font-size: 1.05rem; }
@keyframes reel-in { from { transform: scale(0.86); opacity: 0; } to { transform: none; opacity: 1; } }
/* a chess puzzle's reel (?reel=puzzle&puzzle=<id>): a banner says what to find, a ring counts down, then the solution is played */
body.reel-pz #screen-puzzle { padding-top: 96px; }
body.reel-pz .pz-top, body.reel-pz .pz-info, body.reel-pz .pz-acts { display: none; }
#reel-overlay.pz { place-items: start center; padding-top: 14px; background: none; }
.reel-pz-banner { display: grid; justify-items: center; gap: 3px; padding: 9px 22px 10px; border-radius: 18px; background: rgba(10, 44, 31, 0.95); border: 1.5px solid var(--gold); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); white-space: nowrap; animation: reel-in 0.6s cubic-bezier(.2, .8, .3, 1) both; }
.reel-pz-banner b { font-size: 1.45rem; font-weight: 900; color: #fbf3df; line-height: 1.2; }
.reel-pz-banner span { font-size: 1rem; font-weight: 800; color: var(--gold); }
.reel-pz-clock { --p: 1; position: fixed; left: 50%; bottom: 22px; z-index: 210; width: 86px; height: 86px; margin-left: -43px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--p) * 1turn), rgba(255, 255, 255, 0.14) 0); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5); transition: opacity 0.45s ease, transform 0.45s ease; }
.reel-pz-clock::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #0b2a1f; }
.reel-pz-clock span { position: relative; font-size: 2.3rem; font-weight: 900; color: #fbf3df; }
.reel-pz-clock.gone { opacity: 0; transform: scale(0.7); }
.reel-card .reel-link { direction: ltr; unicode-bidi: isolate; font-size: 1.35rem; padding: 6px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 1.5px solid rgba(231, 193, 90, 0.6); }

/* sideways on a phone the round chip gives up its pushing margin (see above): both chips sit at the far end of the row, the partner in the middle */
@media (orientation: landscape) and (max-height: 500px) {
  #screen-table:not(.chess-mode) .hud .hud-round { margin-inline-end: 0; }
}

/* Caravan upright: the map takes the whole height; the other players float over its top on a dark see-through strip,
   you at the bottom left, the die at the bottom in the middle, your help cards at the bottom right */
@media not ((orientation: landscape) and (max-height: 500px)) {
  #screen-table.caravan-mode { position: relative; }
  /* the map's rounded frame clips everything in it (the strips, the scrolling map), so the corners are one clean curve; no scrollbar */
  #screen-table.caravan-mode .table { margin: 0; border-radius: 18px; overflow: hidden; box-shadow: 0 12px 34px rgba(0,0,0,0.45); }
  #screen-table.caravan-mode .center { inset: 0; }
  #screen-table.caravan-mode .caravan-wrap .cv-scroll { position: absolute; inset: 0; border-radius: 0; box-shadow: none; scrollbar-width: none; background: #dcbd87; padding: 78px 0 90px; box-sizing: border-box; } /* sand under the map; the padding keeps the start and the gate out from under the two strips */
  #screen-table.caravan-mode .caravan-wrap .cv-scroll::-webkit-scrollbar { display: none; }
  /* two dark see-through strips: the other players across the top, you / the die / your cards across the bottom */
  #screen-table.caravan-mode .caravan-wrap::before, #screen-table.caravan-mode .caravan-wrap::after { content: ""; position: absolute; left: 0; right: 0; z-index: 2; background: rgba(4, 12, 8, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); pointer-events: none; }
  #screen-table.caravan-mode .caravan-wrap::before { top: 0; height: 78px; border-bottom: 1px solid rgba(255,255,255,0.08); }
  #screen-table.caravan-mode .caravan-wrap::after { bottom: 0; height: 90px; border-top: 1px solid rgba(255,255,255,0.08); }
  #screen-table.caravan-mode .seat { position: relative; z-index: 3; padding-top: 7px; }
  #screen-table.caravan-mode .seat-bottom { position: absolute; left: 10px; bottom: 0; top: auto; height: 90px; justify-content: center; padding: 0; z-index: 7; }
  #screen-table.caravan-mode .seat-bottom .pinfo { max-width: 104px; } /* your chips wrap under your name, clear of the die in the middle */
  #screen-table.caravan-mode .seat-bottom .pmeta { flex-wrap: wrap; row-gap: 2px; }
  #screen-table.caravan-mode .caravan-wrap { display: block; }
  #screen-table.caravan-mode .caravan-wrap .die-box { position: absolute; left: 50%; right: auto; bottom: 12px; top: auto; margin: 0; padding: 0; transform: translateX(-50%); background: none; box-shadow: none; }
  #screen-table.caravan-mode .caravan-wrap .die-box { flex-direction: column-reverse; gap: 4px; } /* "tap to roll" above the die, so the die itself stays in the middle */
  #screen-table.caravan-mode .caravan-wrap .die-label { font-size: 0.78rem; max-width: 150px; text-align: center; padding: 2px 9px; border-radius: 10px; background: rgba(4, 12, 8, 0.72); }
  #screen-table.caravan-mode .hand-wrap { position: absolute; right: 18px; bottom: calc(8px + 12px + var(--sab)); left: auto; width: auto; padding: 0; z-index: 7; justify-content: flex-end; }
  #screen-table.caravan-mode .hand .card + .card { margin-left: -10px !important; }
  #screen-table.caravan-mode #race-actions { position: absolute; right: 0; bottom: 100%; margin: 0 0 6px; }
  #screen-table.caravan-mode .card.u.help { --card-w: 60px; --card-h: 76px; padding: 4px 3px 2px; } /* the help cards fit the bottom strip */
  #screen-table.caravan-mode .card.u.help .hc-icon { width: 36px; height: 36px; }
  #screen-table.caravan-mode .card.u.help .hc-name { font-size: 0.62rem; }
  #screen-table.caravan-mode .card.u.help .hc-text { display: none; }
}

/* the race games and chess: the picture, the name under it, the chips under that — like the card tables */
#screen-table.race-mode .seat .player, .chess-mode .seat-top .player, .chess-mode .seat-left .player, .chess-mode .seat-right .player, .chess-mode .seat-bottom .player { flex-direction: column; align-items: center; gap: 3px; border-radius: 16px; padding: 4px 8px; }
#screen-table.race-mode .seat .pinfo, .chess-mode .seat .pinfo { align-items: center; width: auto; }
#screen-table.race-mode .seat .pname, .chess-mode .seat .pname { text-align: center; }
#screen-table.race-mode .seat .pmeta, .chess-mode .seat .pmeta { justify-content: center; }
.seat .pmeta:empty { display: none; }
/* auto-play: a small gold badge on the picture */
.auto-badge { position: absolute; left: -5px; top: -4px; z-index: 2; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--gold); color: #2b2203; font-size: 0.6rem; box-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: none; }
/* the race games: no score under the name (the tile / the chests chips say what matters; the score only exists at the end) */
#screen-table.race-mode .seat .pmeta .score { display: none; }
#screen-table.caravan-mode .caravan-wrap::before { height: 98px; }
#screen-table.caravan-mode .seat { padding-top: 5px; }
#screen-table.caravan-mode .caravan-wrap .cv-scroll { padding-top: 98px; }
@media (orientation: landscape) and (max-height: 500px) {
  /* sideways your own seat shares the low card row: picture and name side by side there */
  #screen-table:not(.chess-mode) .seat-bottom .player { flex-direction: row; padding: 1px 7px 1px 1px; gap: 5px; }
}

/* chess on a wide screen: a clock panel beside the board, like the chess sites — each player a row (picture, then name and
   clock), the opponent just above the board's middle, you just below it */
@media (min-width: 761px) {
  #screen-table.game-chess .seat-top, #screen-table.game-chess .seat-bottom { left: calc(50% + var(--sq) * 4 + 26px); right: auto; bottom: auto; width: 230px; min-width: 0; transform: none; align-items: flex-start; gap: 6px; }
  #screen-table.game-chess .seat-top { top: calc(50% - 10px); transform: translateY(-100%); }
  #screen-table.game-chess .seat-bottom { top: calc(50% + 10px); }
  #screen-table.game-chess .seat .player { flex-direction: row; align-items: center; gap: 12px; padding: 7px 14px 7px 7px; border-radius: 40px 16px 16px 40px; background: rgba(6, 14, 10, 0.72); width: 100%; box-sizing: border-box; }
  #screen-table.game-chess .seat .ring { width: 52px; height: 52px; }
  #screen-table.game-chess .seat .pinfo { align-items: flex-start; }
  #screen-table.game-chess .seat .pname { text-align: start; font-size: 0.95rem; }
  #screen-table.game-chess .seat .pmeta { justify-content: flex-start; flex-wrap: wrap; row-gap: 4px; }
  #screen-table.game-chess .seat .clock { font-size: 1.35rem; padding: 2px 10px; }
  #screen-table.game-chess .penalties { justify-content: flex-start; margin-inline-start: 8px; }
  [dir="rtl"] #screen-table.game-chess .seat .player { border-radius: 16px 40px 40px 16px; padding: 7px 7px 7px 14px; }
}

/* ---------- the store: tables, card backs and avatar frames for coins ---------- */
.store, .chal { max-width: var(--lobby-w); margin: 0 auto; }
.store-head, .chal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 2px 8px; }
.store-head h2, .chal-head h2 { margin: 0; font-size: 1.5rem; }
.store-balance { display: inline-flex; align-items: center; gap: 6px; background: rgba(231,193,90,0.14); border: 1px solid rgba(231,193,90,0.5); color: var(--gold); font-weight: 800; border-radius: 30px; padding: 6px 14px; direction: ltr; }
.store-lead { margin: 0 2px 14px; font-size: 0.9rem; line-height: 1.4; }
.store-note:empty { display: none; }
.store-note, .chal-note { background: rgba(231,193,90,0.1); border: 1px solid rgba(231,193,90,0.35); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: 0.9rem; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.store-section { margin-bottom: 22px; }
.store-section h3 { margin: 0 2px 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 1.1rem; }
.store-section h3 small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.store-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.st-item { position: relative; background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(0,0,0,0.28)), rgba(4,22,16,0.35); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 12px 10px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,0.28); }
.st-item.inuse { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(231,193,90,0.35), 0 6px 18px rgba(0,0,0,0.28); }
.st-prev { height: 66px; width: 100%; display: grid; place-items: center; }
.st-prev .st-table { display: block; width: 96px; }
.st-prev .bs-card { width: 46px; height: 64px; border-radius: 6px; }
.st-prev .avatar { width: 58px; height: 58px; background: rgba(255,255,255,0.12); }
.st-name { font-weight: 700; font-size: 0.92rem; line-height: 1.2; }
.st-price { font-size: 0.8rem; font-weight: 800; color: var(--gold); direction: ltr; unicode-bidi: isolate; }
.st-price.free, .st-price.owned { color: #8fe3a8; }
.st-item .btn { width: 100%; margin-top: auto; }
.st-item .btn.inuse { background: rgba(231,193,90,0.18); border-color: var(--gold); color: var(--gold); cursor: default; }
.st-tag { position: absolute; top: 8px; inset-inline-end: 8px; font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 800; color: #2b2203; background: var(--gold); padding: 2px 7px; border-radius: 6px; }
@media (max-width: 400px) { .store-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .st-item { padding: 10px 8px 8px; } }

/* avatar frames: a ring inside the picture's circle, the same on every size */
.avatar { position: relative; }
.avatar .frame { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; border: 3px solid transparent; background-origin: border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); mask-composite: exclude; }
.avatar.tiny .frame, .tmeld .owner .avatar .frame { border-width: 2px; }
.avatar.big .frame, .st-prev .avatar .frame, .v-av .frame { border-width: 4px; }
.frame.fr-bronze { background: linear-gradient(135deg, #8a5a2b, #e0a96a 45%, #6b3f1a 100%); }
.frame.fr-silver { background: linear-gradient(135deg, #8f98a8, #ffffff 48%, #7b8494 100%); }
.frame.fr-gold { background: conic-gradient(from 20deg, #e7c15a, #fff2b0, #c99a2e, #ffe08a, #e7c15a); }
.frame.fr-emerald { background: conic-gradient(from 0deg, #0e7a55, #7af0c0, #0b5a3f, #4fd6a0, #0e7a55); }
.frame.fr-ruby { background: conic-gradient(from 0deg, #a3203a, #ff8a9c, #6a0f22, #ff9cab, #a3203a); }
.frame.fr-royal { background: conic-gradient(from 0deg, #5b2a9a, #c9a6ff, #3a1766, #e7c15a, #5b2a9a); }
.avatar:has(.fr-gold) { box-shadow: 0 0 8px rgba(231,193,90,0.55); }
.avatar:has(.fr-royal) { box-shadow: 0 0 10px rgba(179,136,255,0.65); }
.avatar:has(.fr-ruby) { box-shadow: 0 0 8px rgba(255,122,142,0.5); }
.avatar:has(.fr-emerald) { box-shadow: 0 0 8px rgba(122,240,192,0.5); }
/* the frame picker on the profile: the plain picture first, then the frames (locked ones dimmed) */
.frame-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.fswatch { background: transparent; border: 2px solid transparent; border-radius: 12px; padding: 6px 6px 4px; cursor: pointer; color: var(--muted); font-size: 0.66rem; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: inherit; transition: border-color .15s, transform .1s; }
.fswatch:hover { transform: translateY(-2px); color: var(--ink); }
.fswatch.sel { border-color: var(--gold); color: var(--ink); background: rgba(231,193,90,0.1); }
.fswatch .avatar { width: 40px; height: 40px; background: rgba(255,255,255,0.12); }
/* locked items in the pickers: dimmed, with a small lock; a tap says what it costs */
.swatch.locked, .bswatch.locked, .fswatch.locked { opacity: 0.55; }
.swatch.locked:hover, .bswatch.locked:hover, .fswatch.locked:hover { opacity: 0.8; }
.swatch, .bswatch, .fswatch { position: relative; }
.lock { position: absolute; top: 2px; inset-inline-end: 4px; font-size: 0.72rem; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }

/* card backs from the store */
[data-back="zellige"] { --back: radial-gradient(circle, #c98a2b 0 1.6px, transparent 2.1px) 7px 7px / 14px 14px, repeating-conic-gradient(from 45deg, #0e5a7a 0 25%, #f3e9cf 0 50%) 0 0 / 14px 14px; --back-edge: #f3e9cf; }
[data-back="palm"] { --back: repeating-linear-gradient(60deg, rgba(255,255,255,0.14) 0 2px, transparent 2px 9px), repeating-linear-gradient(-60deg, rgba(255,255,255,0.14) 0 2px, transparent 2px 9px), linear-gradient(180deg, #11693f, #063a22); --back-edge: #d9f0c0; }
[data-back="chevron"] { --back: linear-gradient(45deg, #1b2a4a 25%, transparent 25%) 0 0 / 16px 16px, linear-gradient(-45deg, #1b2a4a 25%, transparent 25%) 0 0 / 16px 16px, linear-gradient(45deg, transparent 75%, #1b2a4a 75%) 0 0 / 16px 16px, linear-gradient(-45deg, transparent 75%, #1b2a4a 75%) 0 0 / 16px 16px, #e8d9a8; --back-edge: #e8d9a8; }
[data-back="henna"] { --back: radial-gradient(circle, #f5e6c8 0 2px, transparent 2.6px) 0 0 / 10px 10px, radial-gradient(circle, transparent 0 4px, #f5e6c8 4px 5px, transparent 5.5px) 5px 5px / 14px 14px, linear-gradient(160deg, #7a2a1e, #3e120c); --back-edge: #f5e6c8; }
[data-back="carbon"] { --back: linear-gradient(27deg, #151515 5px, transparent 5px) 0 5px / 20px 20px, linear-gradient(207deg, #151515 5px, transparent 5px) 10px 0 / 20px 20px, linear-gradient(27deg, #222 5px, transparent 5px) 0 10px / 20px 20px, linear-gradient(207deg, #222 5px, transparent 5px) 10px 5px / 20px 20px, linear-gradient(90deg, #1b1b1b 10px, transparent 10px) 0 0 / 20px 20px, linear-gradient(#1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424) 0 0 / 20px 20px, #131313; --back-edge: #8a8a8a; }
[data-back="pearl"] { --back: repeating-linear-gradient(115deg, rgba(255,255,255,0.55) 0 3px, transparent 3px 9px), radial-gradient(ellipse at 30% 20%, #ffffff, #e9e4f2 40%, #cfd8e8 72%, #e8e0ee); --back-edge: #b8a9d9; }

/* ---------- challenges: the chess puzzle, today's quests, the weekly race, challenge tables ----------
   Phone first: one column, every section a panel with the same rhythm (16 px apart, 18 px inside, 14 px between a
   section's parts). From 900 px: two columns — the puzzle beside today's challenges, the race beside the tables. */
.chal { display: grid; gap: 14px; }
.chal-head.chal-head { display: grid; gap: 4px; margin: 4px 2px 0; }
.chal-sub { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.chal-body { display: grid; gap: 16px; }
@media (min-width: 900px) { .chal-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; } .chal-body .chal-signin, .chal-body > .chal-note { grid-column: 1 / -1; } }
.chal-sec.panel { display: grid; gap: 14px; padding: 18px; border-radius: 16px; }
.chal-sec > * { margin: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.sec-head h3 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.12rem; font-weight: 700; line-height: 1.25; }
.sec-ic { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; background: rgba(231,193,90,0.12); border: 1px solid rgba(231,193,90,0.3); }
.sec-meta { font-size: 0.76rem; font-weight: 600; color: var(--muted); white-space: nowrap; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 4px 10px; }
.chal .lead { margin: -4px 0 0; color: var(--muted); font-size: 0.87rem; line-height: 1.5; }
.chal .empty { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(0,0,0,0.18); border: 1px dashed rgba(255,255,255,0.12); color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.chal .chal-note { margin: 0; }
/* the chess puzzle: today's, with a picture of the position, and the earlier ones in a row */
.pz-feature { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 16px; align-items: center; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(231,193,90,0.12), rgba(0,0,0,0.2) 70%); border: 1px solid rgba(231,193,90,0.35); }
.pz-feature.solved { border-color: rgba(143,227,168,0.45); background: linear-gradient(135deg, rgba(143,227,168,0.1), rgba(0,0,0,0.2) 70%); }
.pz-mini-btn { display: block; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 8px; }
.pz-mini { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; width: 100%; border: 3px solid #2a2a33; border-radius: 6px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,0.45); direction: ltr; }
.pz-mini i { position: relative; display: block; }
.pz-mini i.l { background: #ece1c6; }
.pz-mini i.d { background: #6f8f66; }
.pz-mini .piece { position: absolute; inset: 1%; width: 98%; height: 98%; }
.pz-feat-body { display: grid; gap: 7px; min-width: 0; }
.pz-kicker { font-size: 0.75rem; font-weight: 700; color: var(--gold); }
.pz-feat-title { font-size: 1.3rem; font-weight: 800; line-height: 1.2; }
.pz-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pz-tag { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14); white-space: nowrap; }
.pz-tag.lvl-1 { color: #8fe3a8; border-color: rgba(143,227,168,0.45); }
.pz-tag.lvl-2 { color: var(--gold); border-color: rgba(231,193,90,0.45); }
.pz-tag.lvl-3 { color: #ff9c94; border-color: rgba(255,156,148,0.45); }
.pz-tag.done { color: #8fe3a8; }
.pz-feat-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-top: 4px; }
.pz-coins { display: grid; color: var(--gold); font-weight: 800; white-space: nowrap; line-height: 1.15; }
.pz-coins small { color: var(--muted); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.04em; }
.pz-done { color: #8fe3a8; font-weight: 800; }
.pz-earlier { display: grid; gap: 8px; }
.pz-earlier-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 0.9rem; }
.pz-earlier-head small { color: var(--muted); font-weight: 600; }
.pz-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; margin: 0 -2px; scrollbar-width: none; }
.pz-chips::-webkit-scrollbar { display: none; }
.pz-chip { position: relative; flex: 0 0 112px; min-width: 0; display: grid; gap: 2px; justify-items: start; text-align: start; padding: 9px 12px; border-radius: 12px; color: var(--ink); background: rgba(0,0,0,0.22); border: 1px solid rgba(255,255,255,0.1); cursor: pointer; font: inherit; }
.pz-chip:hover { border-color: rgba(231,193,90,0.5); }
.pz-chip b { font-size: 0.95rem; direction: ltr; unicode-bidi: isolate; }
.pz-chip small { color: var(--muted); font-size: 0.7rem; line-height: 1.3; }
.pz-chip i { position: absolute; top: 7px; inset-inline-end: 9px; font-style: normal; font-weight: 800; color: #8fe3a8; }
.pz-chip.solved { border-color: rgba(143,227,168,0.4); }
/* today's quests */
.quests { display: grid; gap: 10px; }
.quest { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: rgba(0,0,0,0.22); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 12px 14px; }
.quest.done { border-color: rgba(143,227,168,0.55); background: rgba(143,227,168,0.08); }
.quest-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; background: rgba(0,0,0,0.3); }
.quest.done .quest-ic { background: #8fe3a8; color: #0b2a14; font-weight: 800; }
.quest-ic.logo { padding: 4px; background: radial-gradient(circle at 30% 25%, #1f7a57, #0b3326); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15); }
.quest-ic.logo svg { width: 100%; height: 100%; display: block; }
.quest-main { min-width: 0; }
.quest-title { font-weight: 700; font-size: 0.93rem; line-height: 1.3; }
.quest-bar { height: 6px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; margin-top: 8px; }
.quest-bar span { display: block; height: 100%; background: linear-gradient(90deg, #e7c15a, #f5d98a); border-radius: 999px; transition: width .6s ease-out; }
.quest.done .quest-bar span { background: #8fe3a8; }
.quest-meta { font-size: 0.74rem; color: var(--muted); margin-top: 5px; direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .quest-meta { direction: rtl; }
.quest-reward { display: grid; justify-items: center; gap: 1px; padding: 6px 10px; border-radius: 10px; background: rgba(231,193,90,0.1); border: 1px solid rgba(231,193,90,0.25); font-weight: 800; color: var(--gold); white-space: nowrap; font-size: 0.92rem; }
.quest-reward span { direction: ltr; unicode-bidi: isolate; }
.quest-reward small { color: var(--muted); font-size: 0.62rem; letter-spacing: 0.04em; font-weight: 600; }
.quest.done .quest-reward { color: #8fe3a8; background: rgba(143,227,168,0.08); border-color: rgba(143,227,168,0.3); }
/* the weekly race */
.race-prizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.prize { display: grid; justify-items: center; gap: 2px; padding: 8px 6px; border-radius: 12px; background: rgba(231,193,90,0.1); border: 1px solid rgba(231,193,90,0.3); }
.prize .pm { font-size: 1.3rem; line-height: 1.1; }
.prize b { color: var(--gold); font-size: 0.86rem; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.race-rows { display: grid; gap: 6px; }
.race-row { display: grid; grid-template-columns: 28px 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(0,0,0,0.2); font-size: 0.9rem; }
.race-row.me { border: 1px solid var(--gold); background: rgba(231,193,90,0.08); }
.race-row .rk { font-weight: 800; color: var(--gold); text-align: center; font-variant-numeric: tabular-nums; }
.race-row .rk.medal { font-size: 1.15rem; }
/* the name and its level side by side with a gap in both languages (.lvl is direction: ltr, so its own
   margin-inline-start is a left margin — in Arabic that is the side away from the name) */
.race-row .nm { min-width: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.race-row .nm-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; } /* a Latin name in Arabic is cut at its end */
.race-row .nm .lvl { flex: none; margin: 0; }
.race-row .ws { font-weight: 700; white-space: nowrap; }
.race-row .ws small { color: var(--muted); font-weight: 400; }
.race-me { font-size: 0.86rem; color: var(--muted); }
.race-last { padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.race-last b { color: var(--ink); }
/* challenge tables */
.chal .rooms { display: grid; gap: 8px; }
.chal-create { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.chal-create .field { margin: 0; }
.chal select { width: 100%; background: rgba(0,0,0,0.3); color: var(--ink); border: 1px solid rgba(255,255,255,0.2); border-radius: 10px; padding: 10px 12px; font: inherit; }
.chal select option { background: #10261d; }
.chal .stake-row .mode.stake { flex: 1; }
.chal .room-row .btn { white-space: nowrap; }
@media (max-width: 420px) {
  .chal-sec.panel { padding: 16px 14px; }
  .pz-feature { grid-template-columns: 108px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .pz-feat-title { font-size: 1.15rem; }
  .quest { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 12px; }
  .quest-ic { width: 40px; height: 40px; }
}

/* ---------- a chess puzzle (#screen-puzzle): the board, what to find, how it is going ----------
   Phone: what to find, the board, then the messages and buttons. From 900 px: the board beside a column. */
.pz { max-width: 980px; margin: 0 auto; display: grid; gap: 10px; }
.pz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pz-back { display: inline-flex; align-items: center; gap: 4px; }
.pz-arrow { font-size: 1.2em; line-height: 1; }
[dir="rtl"] .pz-arrow { display: inline-block; transform: scaleX(-1); }
.pz-no { color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.pz-main { display: grid; gap: 12px; grid-template-areas: "info" "board" "play"; }
.pz-info { grid-area: info; display: grid; gap: 8px; }
.pz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pz-head h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.pz-goal { margin: 0; color: var(--muted); font-size: 0.92rem; }
.pz-board-wrap { grid-area: board; position: relative; display: flex; justify-content: center; direction: ltr; }
.pz-board-box { --sq: calc(min(100vw - 44px, 528px) / 8); }
.pz-board .sq.wrong { box-shadow: inset 0 0 0 4px #ff6b5e; }
.pz-board.solved .sq.last.dark, .pz-board.solved .sq.last.light { background: #9fd9a3; }
.pz-promo { position: absolute; inset: 0; display: flex; gap: 10px; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); border-radius: 8px; }
.pz-promo button { width: 64px; height: 64px; padding: 6px; border-radius: 12px; border: 0; background: #f3efe4; cursor: pointer; }
.pz-promo .piece { width: 100%; height: 100%; }
.pz-play { grid-area: play; display: grid; gap: 10px; align-content: start; }
.pz-steps { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.pz-dots { display: inline-flex; gap: 6px; }
.pz-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.16); }
.pz-dots i.ok { background: #8fe3a8; }
.pz-dots i.now { background: var(--gold); box-shadow: 0 0 0 3px rgba(231,193,90,0.25); }
.pz-dots i.bad { background: #ff7b70; }
.pz-msg { display: grid; gap: 4px; padding: 11px 14px; border-radius: 12px; background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.1); font-size: 0.93rem; line-height: 1.45; }
.pz-msg small { color: var(--muted); font-size: 0.8rem; }
.pz-msg .san { direction: ltr; unicode-bidi: isolate; color: var(--gold); }
.pz-msg.good { border-color: rgba(143,227,168,0.45); background: rgba(143,227,168,0.08); }
.pz-msg.bad { border-color: rgba(255,123,112,0.5); background: rgba(255,123,112,0.09); }
.pz-msg.bad .san { color: #ff9c94; }
.pz-msg.win { justify-items: center; text-align: center; gap: 6px; padding: 14px; border-color: rgba(231,193,90,0.55); background: rgba(231,193,90,0.1); }
.pz-win-title { font-size: 1.25rem; font-weight: 800; }
.pz-earn { font-size: 1.5rem; color: var(--gold); }
.pz-solution { font-size: 0.86rem; }
.pz-solution > span:first-child { color: var(--muted); }
.pz-line { direction: ltr; unicode-bidi: isolate; font-weight: 700; }
.pz-solution .reply { color: var(--muted); }
.pz-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.pz-acts .btn { flex: 1 1 auto; }
.pz-acts .btn small { opacity: 0.75; font-size: 0.75rem; }
.pz-acts .btn:disabled { opacity: 0.5; cursor: default; }
.pz-from { margin: 0; color: var(--muted); font-size: 0.8rem; font-style: italic; line-height: 1.45; }
@media (min-width: 900px) {
  .pz-main { grid-template-columns: auto minmax(300px, 360px); grid-template-rows: auto 1fr; grid-template-areas: "board info" "board play"; gap: 14px 28px; justify-content: center; align-items: start; }
  .pz-board-box { --sq: calc(min(100dvh - 230px, 560px) / 8); }
  .pz-info, .pz-play { background: var(--panel); border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 16px 18px; }
}

/* ---------- emotes: a tray under the top bar, bubbles over the seats ---------- */
.emote-tray { position: absolute; top: calc(100% + 6px); inset-inline-end: 8px; z-index: 40; width: min(344px, calc(100vw - 16px)); background: #0b2a1f; border: 1px solid rgba(231,193,90,0.3); border-radius: 16px; box-shadow: 0 14px 40px rgba(0,0,0,0.55); padding: 10px; text-align: start; }
.emote-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.8rem; }
.emote-head .muted { flex: 1; font-size: 0.72rem; }
.emote-head .btn { padding: 3px 8px; }
.emote-grid { display: block; }
.emote-grid-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emote-pack-h { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 8px 2px 4px; font-weight: 700; }
.emote-locked { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.72rem; color: var(--muted); }
.em-lock { font: inherit; font-size: 0.78rem; background: rgba(255,255,255,0.04); border: 1px dashed rgba(255,255,255,0.22); color: var(--muted); border-radius: 10px; padding: 3px 8px; cursor: pointer; }
.em-lock:hover { border-color: var(--gold); color: var(--ink); }
.st-prev .st-emotes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 8px; font-size: 1.25rem; line-height: 1.25; text-align: center; }
.st-prev .st-emotes i { font-style: normal; }
.xp-note { text-align: center; margin: 12px 0 2px; }
.emote-grid .em { font-size: 1.45rem; line-height: 1; padding: 6px 0; background: rgba(255,255,255,0.05); border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-family: inherit; }
.emote-grid .em:hover { background: rgba(255,255,255,0.12); border-color: rgba(231,193,90,0.5); transform: scale(1.08); }
.emote-phrases { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 8px; }
.emote-phrases .em { font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--ink); text-align: start; padding: 7px 9px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.emote-phrases .em:hover { background: rgba(255,255,255,0.12); border-color: rgba(231,193,90,0.5); }
#btn-emote.cool { opacity: 0.5; }
.emote-bubble { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 12; background: #fff; color: #1c1c24; border-radius: 16px; padding: 6px 10px; font-size: 1.7rem; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,0.4); white-space: nowrap; pointer-events: none; animation: bubbleIn .28s cubic-bezier(.2,1.4,.4,1); }
.emote-bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 12px; height: 12px; background: #fff; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.emote-bubble.phrase { font-size: 0.86rem; font-weight: 700; padding: 8px 12px; display: flex; gap: 6px; align-items: center; max-width: 220px; white-space: normal; text-align: center; line-height: 1.2; }
.emote-bubble.phrase i { font-style: normal; font-size: 1.15rem; }
.emote-bubble.out { animation: bubbleOut .3s ease-in forwards; }
.seat-top .emote-bubble { bottom: auto; top: calc(100% + 8px); }
.seat-top .emote-bubble::after { bottom: auto; top: -5px; }
.chess-mode .seat-left .emote-bubble, .chess-mode .seat-right .emote-bubble, .race-mode .seat .emote-bubble { bottom: auto; top: calc(100% + 8px); } /* opponents in a row above the board: under their pill, over the board */
.chess-mode .seat-left .emote-bubble::after, .chess-mode .seat-right .emote-bubble::after, .race-mode .seat .emote-bubble::after { bottom: auto; top: -5px; }
.chess-mode .seat-bottom .emote-bubble, .race-mode .seat-bottom .emote-bubble { bottom: calc(100% + 8px); top: auto; }
.chess-mode .seat-bottom .emote-bubble::after, .race-mode .seat-bottom .emote-bubble::after { top: auto; bottom: -5px; }
@keyframes bubbleIn { from { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(8px); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes bubbleOut { to { opacity: 0; transform: translateX(-50%) scale(0.8); } }
@media (max-width: 760px) { .emote-grid .em { font-size: 1.3rem; padding: 5px 0; } }
/* sideways on a phone the buttons come first in the top row (the status strip is after them), so the tray hangs under the buttons' end */
@media (orientation: landscape) and (max-height: 500px) {
  .emote-tray { inset-inline-end: auto; inset-inline-start: 8px; max-height: calc(100dvh - 56px); overflow-y: auto; padding: 8px; }
  .emote-head { margin-bottom: 6px; }
  .emote-grid { gap: 3px; }
  .emote-grid .em { font-size: 1.15rem; padding: 3px 0; }
  .emote-phrases { gap: 3px; margin-top: 6px; }
  .emote-phrases .em { padding: 4px 8px; font-size: 0.76rem; }
}

/* ---------- friends and messages: the chat panel under the top bar (or over the table) ---------- */
.chat-panel { display: flex; flex-direction: column; padding: 0; max-height: min(78vh, 640px); width: min(380px, calc(100vw - 20px)); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.chat-head .tabs { flex: 1; margin: 0; }
.chat-head .tab { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.chat-title .avatar { width: 26px; height: 26px; }
.chat-back { font-size: 1.3rem; line-height: 1; padding: 2px 10px; }
[dir="rtl"] .chat-back { transform: scaleX(-1); }
.tab-count { min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #d9463b; color: #fff; font-size: 0.62rem; font-weight: 800; display: inline-grid; place-items: center; }
.chat-body { flex: 1; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; padding: 8px; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.chat-form input { flex: 1; min-width: 0; padding: 9px 12px; }
.chat-form .btn { white-space: nowrap; padding: 9px 14px; }
.chat-note { padding: 14px 8px; text-align: center; font-size: 0.88rem; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.soc-h { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 10px 4px 6px; font-weight: 700; }
.soc-h:first-child { margin-top: 2px; }
/* one person per row: picture, name and status, then the buttons */
.soc-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 10px; }
.soc-row + .soc-row { border-top: 1px solid rgba(255,255,255,0.05); }
.soc-row.clickable { cursor: pointer; }
.soc-row.clickable:hover { background: rgba(255,255,255,0.05); }
.soc-row .avatar { width: 36px; height: 36px; flex: none; }
.soc-row .soc-who { flex: 1; min-width: 0; }
.soc-row .soc-name { font-weight: 700; font-size: 0.9rem; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.soc-row .soc-sub { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.soc-row .soc-sub b { color: var(--ink); font-weight: 600; }
.soc-row .soc-acts { display: flex; gap: 4px; flex: none; }
.soc-row .soc-acts .btn { padding: 5px 9px; font-size: 0.76rem; }
.soc-row .soc-acts .btn.icon { padding: 5px 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.3); flex: none; }
.dot.on { background: #51cf66; box-shadow: 0 0 6px rgba(81,207,102,0.7); }
.soc-unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--gold); color: #2b2203; font-size: 0.7rem; font-weight: 800; display: inline-grid; place-items: center; }
.soc-search { display: flex; gap: 6px; margin: 2px 0 8px; }
.soc-search input { flex: 1; min-width: 0; padding: 8px 12px; }
/* the thread: their bubbles at the start side, mine at the end side */
.msgs { display: flex; flex-direction: column; gap: 4px; padding: 2px 2px 6px; }
.msg { max-width: 82%; padding: 7px 11px; border-radius: 14px; font-size: 0.9rem; line-height: 1.35; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; position: relative; }
.msg.theirs { align-self: flex-start; background: rgba(255,255,255,0.1); border-start-start-radius: 4px; }
.msg.mine { align-self: flex-end; background: rgba(231,193,90,0.9); color: #2b2203; border-start-end-radius: 4px; }
.msg time { display: block; font-size: 0.62rem; opacity: 0.7; margin-top: 2px; text-align: end; direction: ltr; unicode-bidi: isolate; }
.msg.mine time { text-align: start; }
.msg-day { text-align: center; font-size: 0.68rem; color: var(--muted); margin: 8px 0 4px; }
.msg-more { align-self: center; margin-bottom: 6px; }
/* the chat button at the table: compact, with the same counter as the top bar */
.chat-table { position: relative; }
.chat-table .notif-count { top: -6px; inset-inline-end: -6px; }
/* the waiting room: friends online, each with an Invite button */
.room-friends { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.room-friends .invite-head { margin-bottom: 4px; }
.room-friends .soc-row { padding: 5px 2px; }
.room-friends .soc-row .avatar { width: 30px; height: 30px; }
/* the player card at the table: add as friend / message */
.pc-friend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 0 12px; }
.pc-friend .muted { font-size: 0.8rem; }
@media (max-width: 440px) { .chat-panel { width: calc(100vw - 12px); inset-inline-end: 6px; max-height: calc(100dvh - 80px - var(--sat)); } }
@media (orientation: landscape) and (max-height: 500px) { .chat-panel { top: calc(50px + var(--sat)); max-height: calc(100dvh - 58px); } }
.toast.tappable { cursor: pointer; background: #0b2a1f; color: var(--ink); border-color: rgba(231,193,90,0.55); box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.notif-acts { display: inline-flex; gap: 4px; }

/* ---------- drawn cards — Classic (the default) and Plain: a clean classic face, like a printed card. In the top corner the
   number in a serif face with its suit right under it, one big pip in the middle, no second index (it crowded small cards).
   Classic keeps its court pictures, Plain its big court letters. Sizes follow the card (--card-w), so the same face reads on
   the table, in the trick, on the Trix board and in the hand. ---------- */
.card.drawn { background: #fff; color: #171717; border: 1px solid rgba(0,0,0,0.13); border-radius: calc(var(--card-w) * 0.085); box-shadow: 0 2px 6px rgba(0,0,0,0.35); font-family: Georgia, "Times New Roman", "Noto Serif", "DejaVu Serif", serif; font-weight: 700; }
.card.drawn.red { color: #c8102e; }
.card.drawn .c { left: 7%; top: 4%; right: auto; display: flex; flex-direction: column; align-items: center; font-size: calc(var(--card-w) * 0.3); line-height: 0.95; letter-spacing: -0.06em; padding: 0; background: none; }
.card.drawn .c small { display: block; font-size: 0.74em; margin: 0.12em 0 0; line-height: 1; letter-spacing: 0; }
.card.drawn .c small .sv { display: block; width: 1em; height: 1em; margin: 0; }
.card.drawn .c2 { display: none; }
.card.drawn .m { inset: 30% 0 7% 0; height: auto; padding: 0; display: flex; align-items: center; justify-content: center; font-size: calc(var(--card-w) * 0.5); }
.card.drawn .m .sv { width: 1em; height: 1em; }
.card.drawn .m.court-m { flex-direction: column; gap: 0; font-size: calc(var(--card-w) * 0.42); line-height: 1; letter-spacing: -0.02em; }
.card.drawn .m.court-m .sv { width: 0.6em; height: 0.6em; display: block; margin-top: 0.08em; }
/* Classic courts, like a printed card: the same index as the number cards, in the white corner, and the picture in a
   frame beside it — never under the index. In a fan or a Trix column only the white corner with the index shows.
   (--court-l: the white column the index needs; the picture keeps the art's own shape, 180 x 288) */
.card.drawn.court { --court-l: 32%; }
.card.drawn.court .court-img { inset: auto; right: 6%; top: 50%; transform: translateY(-50%); width: calc(94% - var(--court-l)); height: auto; aspect-ratio: 180 / 288; max-height: 90%; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.card.drawn.court .c { padding: 0; background: none; border-radius: 0; }
/* the Trix board: only a strip of each card shows, so the number and its suit stand side by side */
.bslot .card.drawn { --card-w: var(--bc-w); }
.bslot .card.drawn .c { flex-direction: row; align-items: baseline; gap: 0.06em; font-size: calc(var(--bc-w) * 0.31); left: 8%; top: 5%; }
.bslot .card.drawn .c small { display: inline-block; font-size: 0.78em; margin: 0; }
.bslot .card.drawn .c small .sv { display: inline-block; vertical-align: -0.04em; }
/* a Trix column shows the top of each card: the picture goes under the index row */
.bslot .card.drawn.court .court-img { top: auto; bottom: 5%; left: 50%; right: auto; transform: translateX(-50%); height: 64%; width: auto; max-height: none; }
/* your hand: only the top corner of each card shows, so the corner is a little bigger and the pip is drawn on the last card alone */
#hand .card.drawn .c { font-size: clamp(1.2rem, calc(var(--card-w) * 0.27), 1.8rem); left: 6px; top: 5px; }
#hand .card.drawn .c small { font-size: 0.92em; }
#hand .card.drawn.court { --court-l: calc(10px + clamp(1.2rem, calc(var(--card-w) * 0.27), 1.8rem) * 0.8); } /* the hand's bigger index */
#hand .card.drawn .m { display: none; }
#hand .card.drawn:last-child .m { display: flex; inset: 46% 0 5px 0; font-size: clamp(1.8rem, calc(var(--card-w) * 0.6), 3.6rem); }
#hand .card.drawn:last-child .m.court-m { font-size: clamp(1.5rem, calc(var(--card-w) * 0.44), 2.6rem); }
