/* =====================================================================
   Tarneeb · طرنيب — styles
   Arabian Nights: a woven carpet table, night-sky glass and gold on the table,
   parchment and gold for dialogs, jewel tones throughout.
   ===================================================================== */

:root {
  /* Night & gold */
  --night-0: #0E0827;
  --night-1: #1E1147;
  --night-2: #2E1A66;
  --night-3: #4A2A8A;
  --glass: #241A4F;
  --glass-line: rgba(242, 193, 78, .55);
  --gold: #F2C14E;
  --gold-1: #FFE6A0;
  --gold-2: #D49A2A;
  --gold-3: #9A6A16;
  --gold-grad: #E8B547;
  --teal: #1FB5AC;
  --ruby: #C8213F;

  /* Parchment surfaces */
  --parch: #FFF6E3;
  --parch-2: #F6E6C2;
  --parch-3: #EBD5A4;
  --ink: #2A1638;
  --ink-2: #6B4F6E;
  --ink-3: #A08AA2;
  --on-dark: #FFF1D6;
  --on-dark-2: rgba(255, 241, 214, .7);
  --line: rgba(154, 106, 22, .22);
  --line-2: rgba(154, 106, 22, .42);

  /* Teams & status (validated on parchment) */
  --us: #1597B8;
  --them: #D63A5E;
  --good: #1E9E5A;
  --good-soft: #DDF3E5;
  --bad: #D6334A;
  --bad-soft: #FBE1E4;
  --red: #C8213F;

  /* Table carpet */
  --carpet: #7D1734;
  --carpet-2: #57102A;
  --band: #1C2563;
  --bw: 22px;

  /* Type */
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Reem Kufi', 'IBM Plex Sans Arabic', sans-serif;
  --font-cal: 'Aref Ruqaa', 'Reem Kufi', serif;

  /* Depth & motion */
  --shadow-1: 0 1px 0 rgba(20, 8, 40, .22);
  --shadow-2: 0 2px 0 rgba(20, 8, 40, .3), 0 4px 10px rgba(20, 8, 40, .16);
  --shadow-3: 0 3px 0 rgba(20, 8, 40, .3), 0 14px 34px rgba(20, 8, 40, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);

  /* Ornaments */
  --arch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 120' preserveAspectRatio='none'%3E%3Cpath d='M0 120V54C0 26 20 9 50 0C80 9 100 26 100 54V120Z'/%3E%3C/svg%3E");
  --corner-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 -10 20 20'%3E%3Cg fill='%23D49A2A'%3E%3Crect x='-6.5' y='-6.5' width='13' height='13'/%3E%3Crect x='-6.5' y='-6.5' width='13' height='13' transform='rotate(45)'/%3E%3C/g%3E%3Ccircle r='2.4' fill='%23FFF6E3'/%3E%3C/svg%3E");
  --flourish: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 140 12'%3E%3Cpath d='M0 6H56M84 6H140' stroke='%23D49A2A' stroke-width='1.5'/%3E%3Cpath d='M70 0L76 6L70 12L64 6Z' fill='%23C8213F'/%3E%3Ccircle cx='53' cy='6' r='2.2' fill='%23D49A2A'/%3E%3Ccircle cx='87' cy='6' r='2.2' fill='%23D49A2A'/%3E%3C/svg%3E");
  --star8: polygon(50% 0, 64.7% 14.6%, 85.4% 14.6%, 85.4% 35.3%, 100% 50%, 85.4% 64.7%, 85.4% 85.4%, 64.7% 85.4%, 50% 100%, 35.3% 85.4%, 14.6% 85.4%, 14.6% 64.7%, 0 50%, 14.6% 35.3%, 14.6% 14.6%, 35.3% 14.6%);

  /* Layout (set by view.js) */
  --cw: 100px;
  --ch: 140px;
  --hud-h: 78px;
  --hand-top: 70vh;
  --play-cy: 45vh;
  --av: 58px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

body.felt-sapphire { --carpet: #2B2A7E; --carpet-2: #1B1A56; --band: #6A1230; }
body.felt-bordeaux { --carpet: #0F5E5A; --carpet-2: #08403D; --band: #3A1D78; }
body.felt-slate    { --carpet: #B98544; --carpet-2: #8F6229; --band: #2A1859; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--night-1);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  font-variant-emoji: text;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, .menu-btn:focus-visible {
  outline: 2.5px solid var(--gold);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.safe-probe {
  position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- icons */

.ico { width: 22px; height: 22px; flex: none; }
.suit-ico { width: 1em; height: 1em; fill: #231536; vertical-align: -.12em; flex: none; }
.suit-ico.suit-1, .suit-ico.suit-3 { fill: var(--red); }
body.four-color .suit-ico.suit-2 { fill: #0F7F6E; }
body.four-color .suit-ico.suit-3 { fill: #2747B8; }
.mini {
  display: inline-block; width: 9px; height: 12px; border-radius: 2.5px; flex: none;
  border: 1.6px solid currentColor; opacity: .75;
}

/* ================================================================ TABLE: the magic carpet */

.table { position: fixed; inset: 0; overflow: hidden; }
.felt {
  position: absolute; inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 0L40 20L20 40L0 20Z' fill='none' stroke='%23000' stroke-opacity='.14' stroke-width='1.2'/%3E%3Cg fill='%23F2C14E' fill-opacity='.24' transform='translate(20 20)'%3E%3Crect x='-3.5' y='-3.5' width='7' height='7'/%3E%3Crect x='-3.5' y='-3.5' width='7' height='7' transform='rotate(45)'/%3E%3C/g%3E%3Cg fill='%231FB5AC' fill-opacity='.35'%3E%3Ccircle r='1.6'/%3E%3Ccircle cx='40' r='1.6'/%3E%3Ccircle cy='40' r='1.6'/%3E%3Ccircle cx='40' cy='40' r='1.6'/%3E%3C/g%3E%3C/svg%3E"),
    var(--carpet);
  transition: background-color .5s;
}
/* The woven border: a band of gold stars between gold rules (masked to the frame only) */
.cloth {
  position: absolute; inset: 0; padding: var(--bw);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect width='24' height='24' fill='%23000' fill-opacity='0'/%3E%3Cg fill='%23F2C14E'%3E%3Crect x='8' y='8' width='8' height='8'/%3E%3Crect x='8' y='8' width='8' height='8' transform='rotate(45 12 12)'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='1.7' fill='%231C2563'/%3E%3Cg fill='%231FB5AC'%3E%3Ccircle r='1.8'/%3E%3Ccircle cx='24' r='1.8'/%3E%3Ccircle cy='24' r='1.8'/%3E%3Ccircle cx='24' cy='24' r='1.8'/%3E%3C/g%3E%3C/svg%3E") center / 24px repeat, var(--band);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.cloth::before, .cloth::after { content: ''; position: absolute; border: 2px solid var(--gold); }
.cloth::before { inset: calc(var(--bw) - 4px); border-radius: 6px; }
.cloth::after { inset: 3px; border-radius: 4px; }
.table.compact .felt, .table.short .felt { --bw: 12px; }
.table.compact .cloth::before, .table.short .cloth::before { inset: calc(var(--bw) - 3px); border-width: 1.5px; }
.table.compact .cloth::after, .table.short .cloth::after { inset: 2px; border-width: 1.5px; }

/* Inner guard stripe just inside the border */
.guard {
  position: absolute; inset: calc(var(--bw) + 7px); border-radius: 4px; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px rgba(242, 193, 78, .6), inset 0 0 0 5px rgba(31, 181, 172, .26), inset 0 0 0 6.5px rgba(242, 193, 78, .35);
}
/* Quarter medallions in the corners of the field, as on a Persian rug */
.spandrel { position: absolute; width: min(24vmin, 210px); height: min(24vmin, 210px); pointer-events: none; opacity: .82; }
.table.compact .spandrel, .table.short .spandrel { width: min(20vmin, 120px); height: min(20vmin, 120px); }
.spandrel svg { display: block; width: 100%; height: 100%; }
.sp-tl { top: calc(var(--bw) + 7px); left: calc(var(--bw) + 7px); }
.sp-tr { top: calc(var(--bw) + 7px); right: calc(var(--bw) + 7px); transform: scaleX(-1); }
.sp-br { bottom: calc(var(--bw) + 7px); right: calc(var(--bw) + 7px); transform: scale(-1, -1); }
.sp-bl { bottom: calc(var(--bw) + 7px); left: calc(var(--bw) + 7px); transform: scaleY(-1); }
.spandrel .sp-field { fill: var(--band); opacity: .78; }
.spandrel .sp-rim { fill: none; stroke: var(--gold); stroke-width: 3; }
.spandrel .sp-line { fill: none; stroke: rgba(242, 193, 78, .55); stroke-width: 1.4; }
.spandrel .sp-petal { fill: rgba(242, 193, 78, .75); }
.spandrel .sp-dot { fill: var(--teal); }
.spandrel .sp-star { fill: rgba(242, 193, 78, .1); stroke: rgba(242, 193, 78, .45); stroke-width: 1.2; }
.spandrel .sp-core { fill: rgba(242, 193, 78, .55); }

/* Gold motes drifting up like lamp magic */
.motes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.motes i {
  position: absolute; left: var(--x); bottom: -12px; width: var(--s); height: var(--s); border-radius: 50%;
  background: radial-gradient(circle, #FFF3C8 0 35%, rgba(242, 193, 78, .6) 60%, transparent 72%);
  opacity: 0; animation: mote var(--d) linear infinite; animation-delay: var(--delay);
}

/* Warm lamplight in front of whoever is acting */
.spot {
  position: absolute; left: 50%; top: 50%; width: min(52vmin, 420px); height: min(52vmin, 420px);
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 205, 120, .2), transparent);
  opacity: 0; transition: left .55s var(--ease), top .55s var(--ease), opacity .45s;
}
.spot, .spot.on { display: none; }

/* The medallion woven into the middle of the carpet */
.mat {
  position: absolute; left: 50%; top: var(--play-cy); width: var(--mat-d, 300px); height: var(--mat-d, 300px);
  transform: translate(-50%, -50%); pointer-events: none;
}
.mat svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mat .md-ring { fill: rgba(0, 0, 0, .14); stroke: rgba(242, 193, 78, .55); stroke-width: 1.6; }
.mat .md-line { fill: none; stroke: rgba(242, 193, 78, .4); stroke-width: 1; }
.mat .md-petal { fill: rgba(242, 193, 78, .2); }
.mat .md-star { fill: rgba(28, 37, 99, .34); stroke: rgba(242, 193, 78, .5); stroke-width: 1.2; }
.mat .md-core { fill: rgba(0, 0, 0, .18); stroke: rgba(242, 193, 78, .5); stroke-width: 1; }
.felt-trump {
  position: absolute; left: 50%; top: var(--play-cy);
  width: calc(var(--mat-d, 300px) * .3); height: calc(var(--mat-d, 300px) * .3);
  transform: translate(-50%, -50%) scale(.6); opacity: 0;
  transition: opacity .8s, transform .9s var(--spring);
}
.has-trump .felt-trump { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.felt-trump .suit-ico { width: 100%; height: 100%; fill: rgba(242, 193, 78, .36) !important; }

/* ---------------------------------------------------------------- cards */

.cards-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; direction: ltr; }
.card {
  position: absolute; left: 0; top: 0;
  width: var(--cw); height: var(--ch);
  margin: calc(var(--ch) / -2) 0 0 calc(var(--cw) / -2);
  pointer-events: none;
  will-change: transform;
}
.card.hidden, .card.held { visibility: hidden; }
.card .lift { position: relative; width: 100%; height: 100%; perspective: 1100px; transition: transform .2s var(--ease); }
.card .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .42s var(--ease); }
.card.down .inner { transform: rotateY(180deg); }
.instant .card .inner, .instant .card .lift { transition: none !important; }
.card .face, .card .back {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: calc(var(--cw) * .088);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 1px 0 rgba(20, 0, 20, .35), 0 3px 8px rgba(20, 0, 20, .25);
  transition: box-shadow .25s;
}
.card .face { background: #FFFBF1; }
.card .back { transform: rotateY(180deg); }
.card svg { display: block; width: 100%; height: 100%; }
.card .face::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: rgba(40, 10, 40, .3); opacity: 0; transition: opacity .25s;
}
.card.dim .face::after { opacity: 1; }
.card.dim .lift { transform: translateY(6%); }
.card.mine { pointer-events: auto; cursor: pointer; touch-action: none; }
@media (hover: hover) {
  .card.mine.playable:hover .lift { transform: translateY(-13%); }
  .card.mine.playable:hover .face { box-shadow: 0 0 0 2px var(--gold), 0 10px 18px rgba(20, 0, 20, .35); }
}
.cards-layer.hl .card.playable .face { box-shadow: 0 0 0 2px rgba(242, 193, 78, .9), 0 6px 16px rgba(20, 0, 20, .32); }
.card.selected .lift { transform: translateY(-20%) !important; }
.card.selected .face { box-shadow: 0 0 0 3px var(--gold), 0 10px 18px rgba(20, 0, 20, .35) !important; }
.card.hint .lift { animation: hintBob 1.1s ease-in-out infinite; }
.card.hint .face { box-shadow: 0 0 0 3px var(--teal), 0 0 0 6px #FBF3E1, 0 10px 18px rgba(20, 0, 20, .35) !important; }
.card.winner .face { box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px var(--ruby) !important; }
.card.winner .lift { transform: scale(1.06); }
.card.dragging .lift { transform: none; transition: none; }
.card.dragging .face { box-shadow: 0 0 0 3px var(--gold), 0 26px 48px rgba(20, 0, 20, .45) !important; }
.card.shake .lift { animation: shake .42s; }
.card.stacked .back, .card.stacked .face { box-shadow: 0 0 0 .5px rgba(0, 0, 0, .4), 0 1px 1px rgba(0, 0, 0, .15); }
.card.nudge .lift { animation: nudge .32s; }

/* Hint heatmap: a tag above each playable card's visible strip (the next card in the fan covers the rest) */
.card .ctag {
  position: absolute; top: -6px; left: calc(var(--strip, var(--cw)) / 2);
  transform: translate(-50%, -100%) scale(.5); opacity: 0; pointer-events: none;
  display: none; align-items: center; gap: 3px; height: 21px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  font: 700 11px/21px var(--font); color: #fff;
  box-shadow: 0 0 0 1.5px #FBF3E1;
  transition: opacity .25s, transform .35s var(--spring);
}
.card.tagged .ctag { display: flex; opacity: 1; transform: translate(-50%, -100%) scale(1); }
.card .ctag::before { font-size: 11px; }
.card.tag-best .ctag { background: var(--teal); }
.card.tag-best .ctag::before { content: '★'; }
.card.tag-good .ctag { background: #3E9C6E; }
.card.tag-good .ctag::before { content: '✓'; }
.card.tag-ok .ctag { background: var(--gold); color: #3A2205; }
.card.tag-ok .ctag::before { content: '~'; }
.card.tag-weak .ctag { background: var(--bad); }
.card.tag-weak .ctag::before { content: '✕'; }
.cards-layer.narrow .card .ctag { font-size: 0; gap: 0; padding: 0; width: 21px; justify-content: center; }

/* ---------------------------------------------------------------- seats: portraits in palace arches */

.seats { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
/* The seat box is exactly the portrait, so its centre is the anchor view.js lays out. */
.seat {
  --team-c: var(--us);
  position: absolute; width: var(--av); height: calc(var(--av) * 1.2); transform: translate(-50%, -50%);
  transition: opacity .5s;
}
.seat.them { --team-c: var(--them); }
.seat.vacant { opacity: 0; }
.avatar {
  position: relative; width: 100%; height: 100%;
  filter: drop-shadow(0 2px 0 rgba(10, 0, 20, .5));
  transition: transform .35s var(--spring), filter .3s;
}
.avatar::before {
  content: ''; position: absolute; inset: 0; background: var(--gold-grad);
  -webkit-mask: var(--arch) center / 100% 100% no-repeat; mask: var(--arch) center / 100% 100% no-repeat;
}
.av {
  position: absolute; inset: 3px; overflow: hidden; background: var(--night-2);
  -webkit-mask: var(--arch) center / 100% 100% no-repeat; mask: var(--arch) center / 100% 100% no-repeat;
}
.av svg { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.22) translateY(6%); }
.avatar .ring { display: none; }
.seat.turn .avatar { transform: scale(1.08); }
.seat.turn .avatar::before { background: var(--teal); }
.seat.turn .avatar::before { animation: none; }
.avatar.glow { animation: avatarGlow .9s ease-out; }
.dealer-chip {
  position: absolute; bottom: -2px; left: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold-grad); color: #3A2205; font: 700 11px/22px var(--font); text-align: center;
  box-shadow: 0 0 0 2px var(--night-1); opacity: 0; transform: scale(.3); transition: .4s var(--spring);
}
.seat.is-dealer .dealer-chip { opacity: 1; transform: none; }
.nameplate {
  position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; max-width: 132px; padding: 3px 11px 3px 9px; border-radius: 999px;
  background: var(--glass); color: var(--on-dark); box-shadow: inset 0 0 0 1px var(--glass-line), var(--shadow-1);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
[dir=rtl] .nameplate { padding: 3px 9px 3px 11px; }
.nameplate::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--team-c); }
.nameplate .name { overflow: hidden; text-overflow: ellipsis; }
.chips {
  position: absolute; top: -6px; left: calc(100% - 8px);
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
}
.seat[data-pos=e] .chips { left: auto; right: calc(100% - 8px); align-items: flex-end; }
.chip {
  display: none; align-items: center; justify-content: center; gap: 4px;
  min-width: 26px; height: 24px; padding: 0 8px; border-radius: 12px;
  font: 700 13px/24px var(--font); white-space: nowrap; direction: ltr;
  background: var(--glass); color: var(--gold-1); box-shadow: inset 0 0 0 1px var(--glass-line), var(--shadow-1);
}
.chip.on { display: inline-flex; animation: pop .38s var(--spring); }
.chip.passed { background: rgba(26, 14, 62, .65); color: var(--on-dark-2); box-shadow: none; }
.chip.contract { background: var(--gold-grad); color: #3A2205; box-shadow: var(--shadow-1); }
.chip.made { background: var(--good); color: #fff; box-shadow: var(--shadow-1); }
.chip .suit-ico { width: 14px; height: 14px; }
.chip.contract .suit-ico { fill: #3A2205 !important; }
.tricks-chip { gap: 5px; }
.chip.bump { animation: bump .55s var(--spring); }
.thinking {
  position: absolute; left: 50%; top: -14px; transform: translateX(-50%);
  display: flex; gap: 3px; padding: 5px 8px; border-radius: 10px;
  background: var(--glass); box-shadow: inset 0 0 0 1px var(--glass-line); opacity: 0; transition: opacity .25s;
}
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: dots 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
.seat.is-thinking .thinking { opacity: 1; }

.bubble {
  position: absolute; left: 50%; bottom: calc(100% + 14px); z-index: 2;
  transform: translateX(-50%) scale(.5); transform-origin: 50% 100%; opacity: 0;
  background: var(--parch); color: var(--ink);
  padding: 7px 14px; border-radius: 16px;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  box-shadow: inset 0 0 0 1.5px var(--gold-2), var(--shadow-3);
  transition: transform .28s var(--spring), opacity .2s;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--gold-2);
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }
.seat[data-pos=n] .bubble { bottom: auto; top: calc(100% + 38px); transform-origin: 50% 0; }
.seat[data-pos=n] .bubble::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--gold-2); }
.seat[data-pos=w] .bubble, .seat[data-pos=e] .bubble { bottom: auto; top: 50%; }
.seat[data-pos=w] .bubble { left: calc(100% + 16px); transform: translateY(-50%) scale(.5); transform-origin: 0 50%; }
.seat[data-pos=e] .bubble { left: auto; right: calc(100% + 16px); transform: translateY(-50%) scale(.5); transform-origin: 100% 50%; }
.seat[data-pos=w] .bubble.show, .seat[data-pos=e] .bubble.show { transform: translateY(-50%) scale(1); }
.seat[data-pos=w] .bubble::after { left: auto; right: 100%; top: 50%; transform: translateY(-50%); border-top-color: transparent; border-right-color: var(--gold-2); }
.seat[data-pos=e] .bubble::after { left: 100%; top: 50%; transform: translateY(-50%); border-top-color: transparent; border-left-color: var(--gold-2); }
.bub-bid { font-size: 22px; font-weight: 700; line-height: 1; color: var(--ruby); }
.bub-pass { color: var(--ink-2); }

/* Coach verdict on the card just played */
.coach-badge {
  --cb: #3E9C6E;
  position: absolute; z-index: 60; pointer-events: none;
  display: flex; align-items: center; gap: 7px; padding: 4px 13px 4px 4px; border-radius: 999px; white-space: nowrap;
  background: var(--parch); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--gold-2), var(--shadow-3);
  font-weight: 600; font-size: 13.5px;
  opacity: 0; transform: translate(-50%, -100%) scale(.4);
  transition: transform .5s var(--spring), opacity .25s;
}
[dir=rtl] .coach-badge { padding: 4px 4px 4px 13px; }
.coach-badge.in { opacity: 1; transform: translate(-50%, -100%) scale(1); }
.coach-badge.out { opacity: 0; transform: translate(-50%, -140%) scale(.92); transition: transform .45s var(--ease), opacity .45s; }
.cb-sym {
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center;
  background: var(--cb); color: #fff; font: 700 12px/1 var(--font);
}
.c-brilliant { --cb: #13A39A; }
.c-best { --cb: #1E9E5A; }
.c-good { --cb: #5FA77E; }
.c-inaccuracy { --cb: #D99A1A; }
.c-mistake { --cb: #E2702A; }
.c-blunder { --cb: #D6334A; }
.coach-badge.c-brilliant { animation: brilliantGlow 1.2s ease-in-out 2; }

/* ---------------------------------------------------------------- HUD */

/* Fixed row heights: the HUD always ends exactly at --hud-h, which layout() relies on. */
.hud {
  --pad: 8px; --sb-h: 62px; --btn: 46px;
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--hud-h) + var(--sat));
  padding: calc(var(--pad) + var(--sat)) 16px 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px;
  pointer-events: none;
}
.table.portrait .hud { --sb-h: 58px; --btn: 44px; }
.table.compact .hud { --pad: 7px; --sb-h: 52px; --btn: 40px; padding-left: 10px; padding-right: 10px; gap: 6px; grid-template-columns: auto 1fr auto; }
.table.short .hud { --pad: 5px; --sb-h: 44px; --btn: 40px; }
.hud > * { pointer-events: auto; }
.in-menu .hud { opacity: 0; }
.hud-side { display: flex; align-items: center; gap: 8px; height: var(--sb-h); }
.hud-side.end { justify-content: flex-end; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; padding: 0; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: var(--glass); border: 0; color: var(--gold); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
  transition: transform .2s, box-shadow .2s, opacity .2s, background .2s;
}
.hud .icon-btn { width: var(--btn); height: var(--btn); }
.icon-btn .ico { width: 21px; height: 21px; }
.icon-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--gold), var(--shadow-2); }
.icon-btn:disabled { opacity: .45; cursor: default; }

.scores {
  height: var(--sb-h); padding: 5px 16px 6px; border-radius: 18px;
  background: var(--glass); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
  display: grid; grid-template-columns: auto auto auto; align-items: center; justify-content: center;
  grid-template-areas: "us target them" "meter meter meter";
  column-gap: 14px; row-gap: 3px;
}
.team {
  display: flex; align-items: center; gap: 10px; min-width: 104px; padding: 0; border: 0; background: none;
  color: var(--on-dark); cursor: pointer; text-align: start;
}
.team.us { grid-area: us; justify-content: space-between; }
.team.them { grid-area: them; flex-direction: row-reverse; justify-content: space-between; }
.team-name { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--on-dark-2); }
.team-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--us); }
.team.them .team-name::before { background: var(--them); }
[lang=ar] .team-name { letter-spacing: 0; font-size: 12.5px; }
.team-score { font-weight: 700; font-size: 25px; line-height: 1; color: var(--gold-1); }
.team-score.counting { color: #fff; }
.team-bar { display: none; }
.target {
  grid-area: target;
  width: 36px; height: 36px; display: grid; place-items: center;
  clip-path: var(--star8); background: var(--gold-grad); color: #3A2205; font-weight: 700; font-size: 12.5px;
}
.target-star { font-size: 15px; line-height: 1; color: #3A2205; }

/* Trick meter: ours fill from one end, theirs from the other; the mark is the contract line. */
.meter { grid-area: meter; display: flex; align-items: center; gap: 8px; height: 14px; opacity: .55; transition: opacity .5s; }
.meter.live { opacity: 1; }
.meter-n { width: 16px; flex: none; font-weight: 700; font-size: 12px; line-height: 1; text-align: center; color: var(--on-dark-2); }
.meter-cells { position: relative; flex: 1; display: grid; grid-template-columns: repeat(13, 1fr); gap: 2.5px; height: 6px; }
.meter-cells i { border-radius: 3px; background: rgba(255, 241, 214, .14); transition: background .3s; }
.meter-cells i.zone { background: rgba(242, 193, 78, .35); }
.meter-cells i.us { background: var(--us); }
.meter-cells i.them { background: var(--them); }
.meter-cells i.new { animation: cellIn .7s var(--spring); }
.meter-mark {
  position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px;
  inset-inline-start: calc(var(--at) * (100% - 30px) / 13 + (var(--at) - .5) * 2.5px - 1.5px);
  background: var(--gold-1); box-shadow: 0 0 0 1.5px var(--night-1);
  transition: background .4s;
}
.meter.made .meter-mark { background: #7EF0B2; }
.meter.broken .meter-mark { background: #FF8EA0; }

/* 41: two players per side */
.scores.f41 { grid-template-areas: "us target them"; }
.team.duo { min-width: 0; height: 100%; }
.duo-row { display: flex; gap: 14px; }
.duo-p { display: grid; min-width: 0; }
.duo-n { font-size: 11px; font-weight: 600; color: var(--on-dark-2); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-s { font-weight: 700; font-size: 20px; line-height: 1.1; color: var(--gold-1); }
.duo-n .short { display: none; }
.table.compact .duo-n .full { display: none; }
.table.compact .duo-n .short { display: inline; font-weight: 700; }
.team.duo .duo-p:first-child .duo-n::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 4px; background: var(--us); vertical-align: 1px; }
.team.duo.them .duo-p:first-child .duo-n::before { background: var(--them); }

.contract { display: none; }
.contract.on { display: block; animation: pop .45s var(--spring); }
.contract-chip {
  display: flex; align-items: center; gap: 9px; height: var(--btn); padding: 0 16px 0 5px; border-radius: 999px;
  background: var(--glass); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
}
[dir=rtl] .contract-chip { padding: 0 5px 0 16px; }
.contract-suit { width: calc(var(--btn) - 10px); height: calc(var(--btn) - 10px); border-radius: 50%; display: grid; place-items: center; background: var(--parch); box-shadow: inset 0 0 0 2px var(--gold-2); }
.contract-suit .suit-ico { width: 58%; height: 58%; }
.contract-suit .q { color: var(--ink-3); font-weight: 700; font-size: 16px; }
.contract-txt { display: grid; line-height: 1.1; color: var(--on-dark); }
.contract-txt b { font-size: 17px; font-weight: 700; color: var(--gold-1); }
.contract-chip.muted .contract-txt b, .contract-chip:not(.us):not(.them) .contract-txt b { font-size: 13.5px; }
.contract-txt small { font-size: 11px; color: var(--on-dark-2); max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- prompt & panels */

.prompt {
  position: absolute; left: 50%; top: calc(var(--hand-top) - 62px); z-index: 25;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 16px; border-radius: 999px;
  background: var(--glass); color: var(--on-dark); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-3);
  font-weight: 600; font-size: 14.5px; white-space: nowrap;
  transition: opacity .3s, transform .35s var(--ease);
}
[dir=rtl] .prompt { padding: 5px 16px 5px 5px; }
.prompt.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.prompt-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite; }
.prompt-hint, .hint-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 0; background: var(--gold-grad); color: #3A2205;
  font-weight: 600; font-size: 13.5px; cursor: pointer; transition: filter .2s;
}
.prompt-hint:hover, .hint-btn:hover { filter: brightness(1.06); }
.prompt-hint .ico, .hint-btn .ico { width: 17px; height: 17px; }
.prompt-hint.busy .ico { animation: pulse .6s infinite; }

.actions {
  position: absolute; left: 50%; top: calc(var(--hand-top) - 14px); z-index: 40;
  width: min(580px, calc(100vw - 20px));
  transform: translate(-50%, calc(-100% + 24px)); opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .4s var(--ease);
}
.actions.on { opacity: 1; transform: translate(-50%, -100%); pointer-events: auto; }

/* Parchment with a double gold frame: panels, banners and dialogs share it */
.panel, .banner, .modal {
  background: #FBF3E1;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--gold-2), inset 0 0 0 5px #FFF7E6, inset 0 0 0 6.5px rgba(212, 154, 42, .55), var(--shadow-3);
}
.panel { position: relative; border-radius: 24px; padding: 18px 20px 20px; }
.panel::after, .modal::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: var(--corner-star) top 9px left 9px / 14px no-repeat, var(--corner-star) top 9px right 9px / 14px no-repeat,
              var(--corner-star) bottom 9px left 9px / 14px no-repeat, var(--corner-star) bottom 9px right 9px / 14px no-repeat;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-title { font-family: var(--font-display); font-size: 26px; line-height: 1; color: var(--ruby); letter-spacing: .02em; }
[lang=ar] .panel-title { font-size: 24px; }
.panel-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.bid-grid { display: grid; gap: 8px; }
.bid-grid.classic { grid-template-columns: 1.5fr repeat(7, 1fr); }
.bid-grid.f41 { grid-template-columns: repeat(6, 1fr); }
.bid-btn {
  position: relative; height: 54px; border-radius: 14px; cursor: pointer;
  border: 0; background: #FFFDF6; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2), 0 2px 0 var(--parch-3);
  font-weight: 700; font-size: 21px;
  transition: transform .12s, background .15s, opacity .2s, box-shadow .15s;
}
.bid-btn:hover:not(:disabled) { background: #FFF2CF; transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--gold-2), 0 3px 0 var(--parch-3); }
.bid-btn:active:not(:disabled) { transform: translateY(1px); }
.bid-btn:disabled { opacity: .3; cursor: not-allowed; }
.bid-btn.pass { font-size: 15.5px; font-weight: 600; background: var(--night-2); color: var(--gold-1); box-shadow: inset 0 0 0 1.5px var(--glass-line); }
.bid-btn.pass:hover { background: var(--night-3); }
.bid-btn.max { background: var(--gold-grad); color: #3A2205; box-shadow: inset 0 0 0 1px var(--gold-3); }
.bid-btn.dbl { background: #F1F8FB; }
.bid-btn small { position: absolute; top: 3px; right: 6px; font: 700 10px var(--font); color: var(--us); }
.bid-btn.suggest, .suit-btn.suggest { box-shadow: 0 0 0 3px var(--teal), 0 0 18px rgba(31, 181, 172, .55); animation: suggest 1.1s ease-in-out infinite; }
.suit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.suit-btn {
  display: grid; justify-items: center; gap: 2px; padding: 14px 4px 12px; border-radius: 18px; cursor: pointer;
  background: #FFFDF6; color: var(--ink); border: 0; box-shadow: inset 0 0 0 1.5px var(--line-2), 0 2px 0 var(--parch-3);
  transition: transform .14s, background .15s, box-shadow .15s;
}
.suit-btn:hover { transform: translateY(-2px); background: #FFF2CF; }
.suit-btn:active { transform: translateY(1px); }
.suit-big .suit-ico { width: 44px; height: 44px; }
.suit-name { font-weight: 600; font-size: 14px; margin-top: 5px; }
.suit-count { font-size: 12px; color: var(--ink-2); }
.suit-est { display: none; margin-top: 4px; padding: 1px 9px; border-radius: 999px; background: rgba(31, 181, 172, .15); color: #0E726C; font-size: 11.5px; font-weight: 600; }
.suit-est.on { display: block; }
.panel-why {
  display: none; align-items: center; gap: 9px; margin-top: 12px; padding: 9px 12px; border-radius: 12px;
  background: rgba(31, 181, 172, .12); box-shadow: inset 0 0 0 1px rgba(31, 181, 172, .35); font-size: 13px; line-height: 1.45; color: var(--ink);
}
.panel-why.on { display: flex; animation: rise .35s var(--ease); }
.panel-why > .ico { width: 18px; height: 18px; color: #0E8C84; }
.panel-why .suit-ico { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------------------------------------------------------------- announcements */

.announce {
  position: absolute; left: 50%; top: var(--play-cy); z-index: 50;
  transform: translate(-50%, -50%); pointer-events: none;
  display: grid; place-items: center;
}
.banner {
  grid-area: 1 / 1; display: grid; justify-items: center; gap: 6px; text-align: center;
  min-width: 240px; max-width: calc(100vw - 40px); padding: 20px 34px 22px; border-radius: 26px;
  opacity: 0; transform: scale(.75);
  transition: transform .5s var(--spring), opacity .3s;
}
.banner.in { opacity: 1; transform: scale(1); }
.banner.out { opacity: 0; transform: scale(1.05); transition: transform .3s var(--ease), opacity .3s; }
.banner-row { display: flex; align-items: center; gap: 10px; }
.banner-title { font-weight: 600; font-size: 17px; }
.banner-kicker { font-family: var(--font-display); font-size: 20px; color: var(--ruby); }
[lang=ar] .banner-kicker { letter-spacing: 0; }
.banner-big {
  font-family: var(--font-display); font-size: 72px; line-height: .95;
  color: var(--ruby);
}
.banner.trump { padding-top: 16px; }
.banner.trump .banner-title { font-size: 21px; font-weight: 700; }
.banner.redeal .banner-title { font-weight: 600; }
.banner.milestone { padding: 12px 26px; min-width: 0; border-radius: 999px; }
.banner.milestone::after { display: none; }
.banner.milestone .banner-title { font-family: var(--font-display); font-size: 24px; letter-spacing: .03em; }
.banner.milestone.good .banner-title { color: var(--good); }
.banner.milestone.bad .banner-title { color: var(--bad); }
.banner-targets { display: flex; gap: 14px; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.dstars { color: var(--gold-2); letter-spacing: 1px; }
.dstars i { font-style: normal; color: var(--parch-3); }
.trump-medal {
  position: relative; width: 104px; height: 104px; display: grid; place-items: center; margin-bottom: 4px;
  animation: medal 1s var(--spring) both;
}
/* A gold eight-point star with a puff of turquoise magic behind it */
.trump-medal::before {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  background: var(--teal); opacity: .9;
}
.trump-medal::after { content: ''; position: absolute; inset: 0; clip-path: var(--star8); background: var(--gold-grad); }
.trump-medal .suit-ico { position: relative; z-index: 1; width: 48px; height: 48px; padding: 6px; border-radius: 50%; background: var(--parch); box-sizing: content-box; }

.mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; overflow: hidden; display: inline-block;
  box-shadow: 0 0 0 2px var(--us); vertical-align: middle; background: var(--night-2);
}
.mini-avatar.them { box-shadow: 0 0 0 2px var(--them); }
.mini-avatar svg { display: block; width: 100%; height: 100%; }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed; left: 50%; top: var(--toast-top, calc(var(--hud-h) + var(--sat) + 10px)); z-index: 120;
  transform: translateX(-50%); display: grid; gap: 8px; justify-items: center;
  width: max-content; max-width: calc(100vw - 24px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px; padding: 11px 18px; border-radius: 14px;
  background: var(--glass); color: var(--on-dark); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-3);
  font-weight: 500; font-size: 14px; text-align: center; line-height: 1.4;
  animation: toastIn .4s var(--spring);
  transition: opacity .3s, transform .3s;
}
.toast .suit-ico { width: 22px; height: 22px; padding: 3px; border-radius: 6px; background: var(--parch); }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ================================================================ MODALS */

#modals { position: relative; z-index: 100; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(14, 8, 39, .62);
  opacity: 0; transition: opacity .22s;
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop.closing { opacity: 0; pointer-events: none; }
.modal {
  position: relative; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 28px 26px 22px; border-radius: 28px;
  transform: translateY(18px) scale(.97); transition: transform .35s var(--spring);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.modal-backdrop.open .modal { transform: none; }
.modal-title {
  margin: 0 0 16px; text-align: center;
  font-family: var(--font-display); font-weight: 400; font-size: 34px; line-height: 1.05; color: var(--ruby); letter-spacing: .02em;
}
.modal-title::after { content: ''; display: block; width: 140px; height: 12px; margin: 8px auto 0; background: var(--flourish) center / contain no-repeat; }
.modal-x { position: absolute; top: 16px; right: 16px; z-index: 3; width: 36px; height: 36px; box-shadow: inset 0 0 0 1.5px var(--line-2); background: #FFFDF6; color: var(--ink-2); backdrop-filter: none; }
[dir=rtl] .modal-x { right: auto; left: 16px; }
.modal-x .ico { width: 18px; height: 18px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 18px;
  position: sticky; bottom: -22px; z-index: 2; margin-bottom: -22px; padding: 16px 0 22px;
  /* The last few pixels stay clear so the dialog's gold frame shows through. */
  background: linear-gradient(rgba(251, 243, 225, 0), #FBF3E1 14px, #FBF3E1 calc(100% - 12px), rgba(251, 243, 225, 0) calc(100% - 12px));
}
.modal-small { width: min(390px, 100%); text-align: center; }
.confirm-text { font-size: 16px; line-height: 1.5; margin: 6px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 24px; border-radius: 15px; cursor: pointer;
  border: 0; font-weight: 600; font-size: 15.5px;
  transition: transform .14s, filter .2s, box-shadow .14s, background .2s;
}
.btn .ico { width: 18px; height: 18px; }
.btn-gold { background: var(--gold-grad); color: #3A2205; box-shadow: inset 0 0 0 1px var(--gold-3), 0 3px 0 var(--gold-3); }
.btn-gold:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-gold:active { transform: translateY(1px); }
.btn-ghost { background: #FFFDF6; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn-ghost:hover { background: #FFF2CF; }
.btn-danger { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1.5px rgba(214, 51, 74, .35); }
.btn-danger:hover { background: #F8CDD3; }
.btn-small { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 12px; }

/* setup */
.modal-setup { width: min(540px, 100%); }
.field { margin-bottom: 18px; }
.field-label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--gold-3); }
[lang=ar] .field-label { letter-spacing: 0; font-size: 13.5px; }
.field-desc { margin-top: 7px; text-align: center; font-size: 12.5px; color: var(--ink-3); }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  display: grid; gap: 6px; justify-items: start; align-content: start; text-align: start;
  padding: 14px; border-radius: 18px; cursor: pointer;
  background: #FFFDF6; border: 0; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background .2s, box-shadow .2s, transform .2s;
}
.mode-card:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.mode-card.on { background: #FFF1CC; box-shadow: inset 0 0 0 2px var(--gold-2), 0 6px 16px rgba(154, 106, 22, .2); }
.mode-card b { font-size: 16px; font-weight: 700; }
.mode-card > span:last-child { font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.mode-suits { display: flex; align-items: center; gap: 4px; padding: 6px 9px; border-radius: 10px; background: var(--parch-2); }
.mode-suits .suit-ico { width: 18px; height: 18px; }
.mode-suits.big .suit-ico { width: 20px; height: 20px; }
.mode-suits em { font-size: 15px; font-weight: 700; font-style: normal; }
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
  border-radius: 14px; background: var(--parch-2); box-shadow: inset 0 0 0 1px var(--line);
}
.seg-btn {
  height: 40px; padding: 0 8px; border: 0; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg-btn:hover:not(.on) { color: var(--ink); }
.seg-btn.on { background: var(--night-2); color: var(--gold-1); box-shadow: inset 0 0 0 1px var(--glass-line), var(--shadow-1); }
.seg-btn small { font-size: 11px; opacity: .75; }
.pips { display: inline-flex; align-items: flex-end; gap: 2px; }
.pips i { width: 3.5px; height: 10px; border-radius: 2px; background: currentColor; opacity: .75; }
.pips i:nth-child(1) { height: 5px; }
.pips i:nth-child(2) { height: 7px; }
.pips i:nth-child(3) { height: 9px; }
.pips i:nth-child(4) { height: 11px; }
.text-input {
  width: 100%; height: 50px; padding: 0 15px; border-radius: 14px; outline: none;
  border: 1.5px solid var(--line-2); background: #FFFDF6; color: var(--ink);
  font: 500 16px var(--font); user-select: text; -webkit-user-select: text;
  transition: border-color .2s, box-shadow .2s;
}
.text-input:focus { border-color: var(--gold-2); box-shadow: 0 0 0 4px rgba(242, 193, 78, .3); }
.text-input::placeholder { color: var(--ink-3); }

/* settings */
.modal-settings { width: min(540px, 100%); }
.settings section { margin-bottom: 18px; }
.settings h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; color: var(--gold-3); }
[lang=ar] .settings h3 { letter-spacing: 0; font-size: 13.5px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.row.col { flex-direction: column; align-items: stretch; gap: 0; }
.row .seg { min-width: 220px; }
.row-text { display: grid; gap: 1px; }
.row-label { font-weight: 600; font-size: 14.5px; }
.row-desc { font-size: 12.5px; color: var(--ink-3); }
.toggle-row { cursor: pointer; }
.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; margin: 0; cursor: pointer;
  width: 50px; height: 30px; border-radius: 15px; background: var(--parch-3);
  transition: background .25s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .3s var(--spring);
}
.switch:checked { background: var(--teal); }
.switch:checked::after { transform: translateX(20px); }
[dir=rtl] .switch::after { left: auto; right: 3px; }
[dir=rtl] .switch:checked::after { transform: translateX(-20px); }
.range { width: 52%; accent-color: var(--gold-2); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.swatch { display: grid; gap: 6px; justify-items: center; padding: 0; border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.swatch span { width: 100%; border-radius: 12px; transition: box-shadow .2s, transform .2s; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.swatch:hover span { transform: translateY(-2px); }
.swatch.on span { box-shadow: 0 0 0 3px var(--parch), 0 0 0 5px var(--gold-2); }
.swatch.on em { color: var(--ink); }
.swatch em { font-style: normal; }
.swatch[class*='back-'] span {
  aspect-ratio: 5 / 7; max-width: 64px;
  background: radial-gradient(circle, var(--g) 0 14%, transparent 15%), repeating-linear-gradient(45deg, var(--b) 0 6px, var(--d) 6px 12px);
  box-shadow: inset 0 0 0 4px var(--d), inset 0 0 0 5.5px var(--g);
}
.swatch.on[class*='back-'] span { box-shadow: inset 0 0 0 4px var(--d), inset 0 0 0 5.5px var(--g), 0 0 0 3px var(--parch), 0 0 0 5px var(--gold-2); }
.swatch.back-royal { --b: #3A1D78; --d: #2A1259; --g: #F2C14E; }
.swatch.back-emerald { --b: #0F6E6A; --d: #0A4F4C; --g: #F2C14E; }
.swatch.back-midnight { --b: #8E1839; --d: #6A0F29; --g: #F2C14E; }
.swatch.back-onyx { --b: #151A3D; --d: #0C1029; --g: #E9B949; }
.swatch[class*='felt-'] span { aspect-ratio: 4 / 3; max-width: 96px; box-shadow: inset 0 0 0 5px var(--band-c), inset 0 0 0 6.5px #F2C14E; }
.swatch.on[class*='felt-'] span { box-shadow: inset 0 0 0 5px var(--band-c), inset 0 0 0 6.5px #F2C14E, 0 0 0 3px var(--parch), 0 0 0 5px var(--gold-2); }
.swatch.felt-emerald { --band-c: #1C2563; }
.swatch.felt-emerald span { background: #7D1734; }
.swatch.felt-sapphire { --band-c: #6A1230; }
.swatch.felt-sapphire span { background: #2B2A7E; }
.swatch.felt-bordeaux { --band-c: #3A1D78; }
.swatch.felt-bordeaux span { background: #0F5E5A; }
.swatch.felt-slate { --band-c: #2A1859; }
.swatch.felt-slate span { background: #B98544; }

/* stats */
.stats-hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-bottom: 10px; }
.win-ring {
  --p: 0; width: 120px; height: 120px; border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 2px;
  background: radial-gradient(closest-side, var(--parch) 80%, transparent 81% 100%), conic-gradient(var(--gold-2) calc(var(--p) * 100%), var(--parch-3) 0);
}
.win-ring span { font-weight: 700; font-size: 28px; line-height: 1; }
.win-ring small { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-grid.wide { grid-template-columns: repeat(4, 1fr); margin-top: 8px; }
.stat { padding: 12px 8px; border-radius: 16px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); text-align: center; }
.stat-v { font-weight: 700; font-size: 22px; line-height: 1.15; }
.stat-v small { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.stat-l { margin-top: 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.stat-s { font-size: 11px; font-weight: 700; color: var(--gold-3); }
.sub-h { margin: 18px 0 8px; font-size: 13.5px; font-weight: 600; color: var(--gold-3); }
[lang=ar] .sub-h { letter-spacing: 0; font-size: 13.5px; }
.lvl { display: grid; grid-template-columns: 72px 1fr 52px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; font-weight: 600; }
.lvl-bar { height: 8px; border-radius: 4px; background: var(--parch-3); overflow: hidden; }
.lvl-bar i { display: block; height: 100%; width: calc(var(--p) * 100%); background: var(--gold-grad); border-radius: inherit; }
.lvl-v { text-align: end; color: var(--ink-2); }
.empty { display: grid; justify-items: center; gap: 8px; padding: 28px 10px; color: var(--ink-2); text-align: center; }
.empty .suit-ico { width: 46px; height: 46px; fill: var(--parch-3) !important; }
.empty p { margin: 0; }

/* rules */
.modal-rules { width: min(600px, 100%); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--parch-2); box-shadow: inset 0 0 0 1px var(--line); margin-bottom: 14px; }
.tab { flex: 1; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.tab:hover:not(.on) { color: var(--ink); }
.tab.on { background: var(--night-2); color: var(--gold-1); box-shadow: inset 0 0 0 1px var(--glass-line), var(--shadow-1); }
.rules-body { max-height: min(58vh, 560px); overflow: auto; padding-inline-end: 6px; font-size: 14.5px; line-height: 1.65; color: var(--ink-2); user-select: text; -webkit-user-select: text; }
.rules-body h3 { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; font-size: 16px; font-weight: 700; color: var(--ink); }
.rules-body h3:first-child { margin-top: 4px; }
.rules-body p { margin: 0 0 6px; }
.rules-body ul { margin: 4px 0 8px; padding-inline-start: 20px; }
.rules-body li { margin: 3px 0; }
.rules-body b { color: var(--ink); font-weight: 600; }
.rules-body ul.keys { list-style: none; padding: 0; }
.rule-ico { width: 30px; height: 30px; display: grid; place-items: center; clip-path: var(--star8); background: var(--gold-grad); color: #3A2205; font-size: 13px; flex: none; }
kbd {
  display: inline-block; min-width: 24px; padding: 1px 7px; border-radius: 7px; text-align: center;
  background: #FFFDF6; border: 1px solid var(--line-2); border-bottom-width: 2.5px;
  font: 600 12px var(--font); color: var(--ink);
}

/* scoreboard */
.modal-board { width: min(560px, 100%); }
.table-wrap { max-height: min(56vh, 520px); overflow: auto; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line-2); background: #FFFDF6; }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th, .board td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board thead th { position: sticky; top: 0; z-index: 1; background: var(--parch-2); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.board thead th .mini-avatar { width: 22px; height: 22px; margin-inline-end: 5px; }
.board .num { color: var(--ink-3); font-weight: 600; }
.board .us { color: var(--us); }
.board .them { color: var(--them); }
.board .ctr { display: flex; align-items: center; gap: 7px; justify-content: flex-start; }
.board .ctr .mini-avatar { width: 24px; height: 24px; }
.board .ctr b { font-size: 16px; font-weight: 700; }
.board .ctr .suit-ico { width: 18px; height: 18px; }
.board .pos { color: var(--good); font-weight: 700; }
.board .neg { color: var(--bad); font-weight: 700; }
.board .zero { color: var(--ink-3); font-weight: 700; }
.board .bt { display: block; font-size: 11px; color: var(--ink-3); }
.board tfoot td { font-size: 18px; font-weight: 700; border-bottom: 0; background: var(--parch-2); }
.board tfoot td:first-child, .board tfoot td:nth-child(2) { font-size: 13px; color: var(--ink-2); }
.board tr.clickable { cursor: pointer; transition: background .15s; }
.board tr.clickable:hover { background: #FFF2CF; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag.ok { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.gold { background: #FFEBB8; color: #7A4E00; }
.card-txt { display: inline-flex; align-items: center; gap: 1px; padding: 0 5px; border-radius: 6px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font-weight: 700; direction: ltr; }
.card-txt .suit-ico { width: 12px; height: 12px; }

/* score chart (team colours validated on parchment) */
.sc { margin: -4px 0 14px; }
.sc-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.sc-key { display: inline-flex; align-items: center; gap: 6px; }
.sc-plot { position: relative; direction: ltr; touch-action: pan-y; }
.sc-svg { display: block; width: 100%; height: auto; overflow: visible; }
.sc-grid { stroke: var(--line); stroke-width: 1; }
.sc-grid.zero { stroke: var(--line-2); }
.sc-target { stroke: var(--gold-2); stroke-width: 1; }
.sc-tick { fill: var(--ink-3); font: 500 10.5px var(--font); }
.sc-tick.gold { fill: var(--gold-3); }
.sc-end { fill: var(--ink); font: 600 11.5px var(--font); }
.sc-cross { stroke: var(--ink-3); stroke-width: 1; opacity: 0; }
.sc-plot.hover .sc-cross { opacity: 1; }
.sc-tip {
  position: absolute; top: 4px; transform: translateX(12px); pointer-events: none; z-index: 2;
  display: grid; gap: 3px; min-width: 120px; padding: 8px 10px; border-radius: 12px;
  background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-2); font-size: 12px; opacity: 0; transition: opacity .15s;
}
.sc-tip.flip { transform: translateX(calc(-100% - 12px)); }
.sc-plot.hover .sc-tip { opacity: 1; }
.sc-tip b { font-size: 11.5px; color: var(--ink-2); }
.sc-tip span { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink-2); }
.sc-tip span i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sc-tip em { margin-inline-start: auto; padding-inline-start: 10px; font-style: normal; color: var(--ink); font-weight: 700; }

/* last trick */
.modal-last { width: min(380px, 100%); }
.lt { position: relative; width: 300px; height: 310px; margin: 0 auto; direction: ltr; }
.lt-slot { position: absolute; display: grid; justify-items: center; gap: 5px; width: 92px; }
.lt-card { width: 74px; height: 104px; border-radius: 7px; overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 6px 14px rgba(40, 10, 40, .2); animation: ltIn .45s var(--spring) both; animation-delay: calc(var(--i) * .09s); }
.lt-card svg { display: block; width: 100%; height: 100%; }
.lt-slot.win .lt-card { box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgba(242, 193, 78, .45); }
.lt-s { left: 50%; bottom: 0; transform: translateX(-50%); }
.lt-n { left: 50%; top: 0; transform: translateX(-50%); }
.lt-w { left: 0; top: 50%; transform: translateY(-50%); }
.lt-e { right: 0; top: 50%; transform: translateY(-50%); }
.lt-name { display: flex; align-items: center; gap: 4px; max-width: 100%; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-name .ico { width: 15px; height: 15px; color: var(--gold-2); }
.lt-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; display: grid; place-items: center; clip-path: var(--star8); background: var(--gold-grad); }
.lt-center .suit-ico { width: 22px; height: 22px; }

/* pause */
.modal-pause { width: min(370px, 100%); }
.pause-list { display: grid; gap: 8px; }
.pause-btn {
  display: flex; align-items: center; gap: 13px; height: 54px; padding: 0 18px; border-radius: 15px; cursor: pointer; text-align: start;
  background: #FFFDF6; border: 0; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 600; font-size: 15px;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.pause-btn:hover { background: #FFF2CF; box-shadow: inset 0 0 0 1.5px var(--gold-2); transform: translateY(-1px); }
.pause-btn .ico { color: var(--gold-3); }
.pause-btn.primary { background: var(--gold-grad); color: #3A2205; box-shadow: inset 0 0 0 1px var(--gold-3); }
.pause-btn.primary .ico { color: #3A2205; }

/* hand summary */
.modal-summary { width: min(470px, 100%); text-align: center; }
.sum-emblem {
  position: relative; width: 88px; height: 88px; margin: 0 auto 12px;
  display: grid; place-items: center;
  animation: medal .9s var(--spring) both;
}
.sum-emblem::before { content: ''; position: absolute; inset: 0; clip-path: var(--star8); background: var(--gold-grad); }
.sum.bad .sum-emblem::before { background: #D88C9B; }
.sum-emblem .suit-ico { position: relative; width: 38px; height: 38px; padding: 6px; border-radius: 50%; background: var(--parch); box-sizing: content-box; }
.sum-emblem span {
  position: absolute; right: -6px; bottom: -2px; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 16px;
  background: var(--night-2); color: var(--gold-1); font-size: 16px; font-weight: 700; line-height: 32px;
  box-shadow: 0 0 0 2px var(--gold-2);
}
.sum-title { font-family: var(--font-display); font-size: 38px; line-height: 1.05; letter-spacing: .02em; }
.sum.good .sum-title { color: var(--good); }
.sum.bad .sum-title { color: var(--bad); }
.sum.kaboot .sum-title {
  font-size: 50px; color: var(--ruby);
  animation: kaboot 1.2s ease-in-out infinite;
}
.sum-sub { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; font-size: 14px; color: var(--ink-2); }
.sum-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sum-team { display: grid; justify-items: center; gap: 6px; padding: 14px 12px 16px; border-radius: 20px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); }
.sum-team.decl { box-shadow: inset 0 0 0 2px var(--gold-2); }
.sum-team-name { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.sum-team-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--us); }
.sum-team.them .sum-team-name::before { background: var(--them); }
[lang=ar] .sum-team-name { letter-spacing: 0; font-size: 13.5px; }
.sum-tricks { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.sum-tricks b { font-size: 20px; font-weight: 700; color: var(--ink); }
.sum-tricks small { font-size: 12px; }
.sum-delta { font-size: 34px; font-weight: 700; line-height: 1; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.zero { color: var(--ink-3); }
.sum-total { font-size: 14px; color: var(--ink-3); }
.sum-total .count { font-size: 21px; font-weight: 700; color: var(--ink); margin-inline-end: 4px; }
.sum-bar { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--parch-3); overflow: hidden; }
.sum-bar i { display: block; height: 100%; width: calc(var(--p0) * 100%); background: var(--us); border-radius: inherit; transition: width 1.1s var(--ease); }
.sum-team.them .sum-bar i { background: var(--them); }
.sum-bar i.go { width: calc(var(--p) * 100%); }
.board.sum41 td.who { display: flex; align-items: center; gap: 8px; text-align: start; }
.board.sum41 td.tot .count { font-size: 17px; font-weight: 700; }
.board.sum41 tr.miss td:nth-child(3) { color: var(--bad); }

/* coach panel in the hand summary */
.sum-coach {
  display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 12px 14px; border-radius: 20px; text-align: start;
  background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line);
}
.sum-coach .btn-ghost { background: var(--parch); }
.sum-coach-txt { flex: 1; display: grid; gap: 6px; min-width: 0; }
.sum-coach-txt > b { font-size: 14px; font-weight: 700; }
.acc-ring {
  --p: 0; flex: none; width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: baseline; justify-content: center; padding-top: 18px;
  background: radial-gradient(closest-side, #FFFDF6 79%, transparent 81% 100%), conic-gradient(var(--teal) calc(var(--p) * 100%), var(--parch-3) 0);
}
.acc-ring b { font-size: 18px; font-weight: 700; line-height: 1; }
.acc-ring small { font-size: 10px; color: var(--ink-3); font-weight: 700; }
.gchips { display: flex; flex-wrap: wrap; gap: 5px; }
.gchip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px 0 3px; border-radius: 12px; background: var(--parch-2); font-size: 12px; font-weight: 700; }
.gchip b { min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px; display: grid; place-items: center; background: var(--cb); color: #fff; font-size: 9.5px; }
.gchip i { font-style: normal; }
.sum-xp { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 12px; color: var(--gold-3); font-size: 13px; font-weight: 700; }
.sum-xp .ico { width: 16px; height: 16px; }
.sum-xp b { font-size: 17px; }

/* hand review */
.modal-review { width: min(560px, 100%); }
.rv-head { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; font-size: 14px; color: var(--ink-2); }
.rv-head > .suit-ico { width: 20px; height: 20px; }
.rv-list { display: grid; gap: 6px; max-height: min(60vh, 560px); overflow: auto; padding-inline-end: 4px; }
.rv-row {
  display: grid; grid-template-columns: 22px auto 1fr; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px;
  background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); border-inline-start: 4px solid var(--us);
  animation: rise .4s var(--ease) both; animation-delay: calc(var(--i) * 30ms);
}
.rv-row.w-them { border-inline-start-color: var(--them); }
.rv-n { font-size: 13px; font-weight: 700; color: var(--ink-3); text-align: center; }
.rv-cards { display: flex; gap: 6px; direction: ltr; }
.rv-c { display: grid; justify-items: center; gap: 3px; }
.rv-face { width: 40px; height: 56px; border-radius: 4px; overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 3px 8px rgba(40, 10, 40, .14); opacity: .6; }
.rv-face svg { display: block; width: 100%; height: 100%; }
.rv-c.win .rv-face, .rv-c.me .rv-face { opacity: 1; }
.rv-c.win .rv-face { box-shadow: 0 0 0 2.5px var(--gold); }
.rv-who { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; line-height: 1; }
.rv-who.us { color: var(--us); }
.rv-who.them { color: var(--them); }
.rv-who .ico { width: 11px; height: 11px; color: var(--gold-2); }
.rv-grade { display: flex; align-items: center; gap: 8px; justify-self: end; text-align: end; min-width: 0; }
.rv-grade .cb-sym { flex: none; }
.rv-gt { display: grid; gap: 2px; font-size: 12.5px; }
.rv-gt b { color: var(--cb); font-weight: 700; }
.rv-gt em { display: inline-flex; align-items: center; gap: 3px; font-style: normal; font-size: 11px; color: var(--ink-3); }
.rv-gt em .ico { width: 12px; height: 12px; }
.rv-gt small { font-size: 11.5px; color: var(--ink-2); display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.rv-note { margin: 12px 0 0; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* game over */
.modal-over { width: min(450px, 100%); text-align: center; overflow: hidden; }
.go-crest { position: relative; width: 140px; height: 140px; margin: 0 auto 4px; display: grid; place-items: center; }
.go-rays {
  position: absolute; inset: -30px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(212, 154, 42, .28) 0 7.5deg, transparent 7.5deg 15deg);
  -webkit-mask: radial-gradient(circle, #000 58%, transparent 59%); mask: radial-gradient(circle, #000 58%, transparent 59%);
}
.go.lose .go-rays { display: none; }
.go-icon {
  position: relative; width: 112px; height: 112px; display: grid; place-items: center; color: #3A2205;
  animation: medal 1.1s var(--spring) both;
}
.go-icon::before { content: ''; position: absolute; inset: 0; clip-path: var(--star8); background: var(--gold-grad); }
.go-icon .ico, .go-icon .suit-ico { position: relative; }
.go-icon .ico { width: 54px; height: 54px; stroke-width: 1.7; }
.go.lose .go-icon::before { background: #B8A7BD; }
.go.lose .go-icon .suit-ico { width: 48px; height: 48px; fill: var(--parch); }
.go-title { margin: 8px 0 4px; font-family: var(--font-display); font-weight: 400; font-size: 54px; line-height: 1; letter-spacing: .02em; }
.go.win .go-title { color: var(--ruby); }
.go.lose .go-title { color: var(--ink-2); }
.go-sub { margin: 0 0 16px; font-size: 15px; color: var(--ink-2); }
.go-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.go-meta span { padding: 5px 12px; border-radius: 999px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

/* ================================================================ PROGRESSION */

/* Level badge: a gold eight-point star */
.lvl-medal {
  position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  color: #3A2205; font-weight: 700; font-size: 16px;
}
.lvl-medal::before { content: ''; position: absolute; inset: 0; clip-path: var(--star8); background: var(--gold-grad); }
.lvl-medal span { position: relative; }
.lvl-medal.big { width: 66px; height: 66px; font-size: 24px; }
.xp-bar { display: block; height: 6px; border-radius: 3px; background: rgba(154, 106, 22, .2); overflow: hidden; }
.xp-bar i { display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: inherit; background: var(--gold-grad); }

.menu-top-end { display: flex; align-items: center; gap: 8px; }
.player-card {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: min(250px, 56vw); height: 56px; padding: 0 16px 0 6px;
  border-radius: 999px; cursor: pointer; text-align: start; color: var(--on-dark); border: 0;
  background: var(--glass); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
  transition: transform .2s, box-shadow .2s; animation: rise .6s var(--ease) both .2s;
}
[dir=rtl] .player-card { padding: 0 6px 0 16px; }
.player-card:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--gold); }
.pc-id { display: grid; gap: 2px; min-width: 0; flex: 1; }
.pc-name { font-weight: 700; font-size: 14px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-rank { font-size: 11.5px; font-weight: 500; color: var(--gold); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-card .xp-bar { height: 4px; width: 100%; min-width: 90px; margin-top: 3px; background: rgba(255, 241, 214, .16); }

/* profile */
.modal-profile { width: min(580px, 100%); }
.pf-head { display: flex; align-items: center; gap: 14px; margin: -2px 0 16px; padding: 14px 16px; border-radius: 20px; background: var(--night-2); color: var(--on-dark); box-shadow: inset 0 0 0 1.5px var(--glass-line); }
.pf-head .pc-name { font-size: 18px; }
.pf-head .pc-rank { font-size: 13px; }
.pf-head .xp-bar { height: 8px; margin-top: 7px; background: rgba(255, 241, 214, .16); }
.pc-xp { font-size: 11.5px; color: var(--on-dark-2); font-weight: 600; margin-top: 3px; }
.pf-body { min-height: 220px; }
.ov-rank { margin: 0 0 12px; text-align: center; font-size: 13px; color: var(--ink-2); }
.ov-grid { grid-template-columns: repeat(3, 1fr); }
.stat.ov { display: grid; justify-items: center; gap: 2px; padding: 14px 6px; }
.ov-ico { color: var(--gold-3); }
.ov-ico .ico { width: 21px; height: 21px; }
.ach-count { display: grid; gap: 7px; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; }
.ach-count .xp-bar { height: 6px; }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: min(52vh, 460px); overflow: auto; padding-inline-end: 4px; }
.ach {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 16px; text-align: start;
  background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line);
  animation: rise .4s var(--ease) both; animation-delay: calc(var(--i) * 18ms);
}
.ach.on { background: #FFF1CC; box-shadow: inset 0 0 0 1.5px var(--gold-2); }
.ach.on.rare { background: #E2F6F4; box-shadow: inset 0 0 0 1.5px var(--teal); }
.ach-ico { position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center; color: #3A2205; }
.ach-ico::before { content: ''; position: absolute; inset: 0; clip-path: var(--star8); background: var(--gold-grad); }
.ach-ico .ico, .ach-ico .suit-ico { position: relative; }
.ach-ico .ico { width: 20px; height: 20px; }
.ach-ico .suit-ico { width: 18px; height: 18px; fill: #3A2205 !important; }
.ach.rare.on .ach-ico { color: #fff; }
.ach.rare.on .ach-ico::before { background: var(--teal); }
.ach.rare.on .ach-ico .suit-ico { fill: #fff !important; }
.ach.off .ach-ico { color: var(--ink-3); }
.ach.off .ach-ico::before { background: var(--parch-3); }
.ach-t { display: grid; gap: 2px; min-width: 0; }
.ach-t b { font-size: 13.5px; font-weight: 700; }
.ach.off .ach-t b { color: var(--ink-2); }
.ach-t small { display: block; font-size: 11.5px; color: var(--ink-2); line-height: 1.35; }
.ach-t em { font-style: normal; font-size: 10.5px; color: var(--gold-3); font-weight: 700; }
.toast.ach-toast { gap: 12px; padding: 9px 18px 9px 9px; text-align: start; }
[dir=rtl] .toast.ach-toast { padding: 9px 9px 9px 18px; }
.toast.ach-toast .ach-ico { animation: medal .8s var(--spring) both; }
.toast.ach-toast .suit-ico { padding: 0; background: none; }
.toast.ach-toast small { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
[lang=ar] .toast.ach-toast small { letter-spacing: 0; font-size: 12px; }
.toast.ach-toast b { font-size: 15px; font-weight: 700; color: var(--on-dark); }

/* XP on game over */
.go-xp { margin-top: 18px; padding: 14px; border-radius: 20px; background: var(--night-2); color: var(--on-dark); box-shadow: inset 0 0 0 1.5px var(--glass-line); text-align: start; }
.go-xp-row { display: flex; align-items: center; gap: 12px; }
.go-xp-mid { flex: 1; display: grid; gap: 7px; }
.go-xp-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; font-weight: 600; }
.go-xp-top > span { color: var(--gold); font-weight: 700; }
.go-xp .xp-bar { height: 8px; background: rgba(255, 241, 214, .16); }
.go-xp .xp-bar i { width: calc(var(--p0) * 100%); transition: width 1.4s var(--ease); }
.go-xp .xp-bar i.go { width: calc(var(--p) * 100%); }
.go-levelup {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; padding: 10px; border-radius: 14px;
  background: var(--gold-grad); color: #3A2205; font-weight: 700;
  opacity: 0; transform: scale(.7); transition: opacity .4s, transform .6s var(--spring);
}
.go-levelup.on { opacity: 1; transform: none; }
.go-ach { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.go-ach-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px 3px 3px; border-radius: 999px; background: rgba(255, 241, 214, .1); box-shadow: inset 0 0 0 1px var(--glass-line); font-size: 12px; font-weight: 600; }
[dir=rtl] .go-ach-chip { padding: 3px 3px 3px 11px; }
.go-ach-chip .ico, .go-ach-chip .suit-ico { width: 24px; height: 24px; padding: 5px; border-radius: 50%; color: #3A2205; fill: #3A2205 !important; background: var(--gold-grad); }

/* ================================================================ DAILY CHALLENGE */

.modal-daily { width: min(460px, 100%); text-align: center; }
.dr-kicker { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.dr-kicker .ico { width: 18px; height: 18px; color: var(--gold-3); }
.dr-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: 12px 0 2px; }
.dr-star { font-size: 54px; line-height: 1; color: var(--parch-3); animation: starIn .7s var(--spring) both; animation-delay: calc(var(--i) * .26s + .2s); }
.dr-star:nth-child(2) { font-size: 68px; }
.dr-star.on { color: var(--gold); text-shadow: 0 3px 0 var(--gold-3); }
.dr-title { margin: 6px 0 4px; font-family: var(--font-display); font-weight: 400; font-size: 40px; letter-spacing: .02em; color: var(--ruby); }
.dr.lose .dr-title { color: var(--ink-2); }
.dr-sub { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.dr-sub .suit-ico { width: 18px; height: 18px; }
.dr-targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dr-t { display: grid; gap: 2px; padding: 10px 4px; border-radius: 14px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; color: var(--ink-3); }
.dr-t b { color: var(--parch-3); font-size: 14px; letter-spacing: 1px; }
.dr-t.hit { background: #FFF1CC; box-shadow: inset 0 0 0 1.5px var(--gold-2); color: var(--ink); }
.dr-t.hit b { color: var(--gold-2); }
.dr-best { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.dr-xp { color: var(--gold-3); }
.dr-next { margin: 12px 0 0; font-size: 12px; color: var(--ink-3); }

/* ================================================================ CARD TRACKER */

.modal-tracker { width: min(560px, 100%); }
.tk-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin: -4px 0 12px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tk-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tk-rows { display: grid; gap: 6px; direction: ltr; }
.tk-row { display: grid; grid-template-columns: 30px 1fr 28px; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 14px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); }
.tk-row.trump { background: #FFF1CC; box-shadow: inset 0 0 0 2px var(--gold-2); }
.tk-suit { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--parch-2); }
.tk-suit .suit-ico { width: 17px; height: 17px; }
.tk-cards { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; }
.tk-c {
  display: grid; place-items: center; height: 30px; border-radius: 7px; font-size: 12px; font-weight: 700; font-style: normal; line-height: 1;
  background: #FFFDF6; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2);
}
.tk-legend .tk-c { width: 20px; height: 22px; font-size: 10px; }
.tk-c.mine { background: var(--night-2); color: var(--gold-1); box-shadow: none; }
.tk-c.played { background: transparent; color: var(--ink-3); box-shadow: none; text-decoration: line-through; opacity: .6; }
.tk-out { text-align: center; font-size: 15px; font-weight: 700; color: var(--ink); }
.tk-voids { display: grid; gap: 6px; }
.tk-void { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 14px; background: #FFFDF6; box-shadow: inset 0 0 0 1px var(--line); }
.tk-vn { font-weight: 600; font-size: 13.5px; }
.tk-vs { margin-inline-start: auto; display: flex; gap: 5px; }
.tk-vs em { font-style: normal; font-size: 12px; color: var(--ink-3); }
.tk-x { position: relative; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--parch-2); }
.tk-x .suit-ico { width: 15px; height: 15px; opacity: .5; }
.tk-x::after { content: ''; position: absolute; left: 4px; right: 4px; top: 50%; height: 2px; background: var(--bad); transform: rotate(-35deg); border-radius: 1px; }

/* ================================================================ MENU: a night over the palace */

.menu {
  position: fixed; inset: 0; z-index: 90; overflow-x: hidden; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; visibility: hidden; transition: opacity .45s, visibility .45s;
}
.menu.on { opacity: 1; visibility: visible; }
.menu-bg {
  position: fixed; inset: 0; overflow: hidden;
  background: #1B1242;
}
.menu-bg .stars { position: absolute; inset: 0; width: 100%; height: 100%; }
.menu-bg .stars .tw { animation: twinkle 3.2s ease-in-out infinite; }
.shooting-star {
  position: absolute; top: 12%; left: 8%; width: 150px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 244, 214, 0), #FFF4D6); opacity: 0;
  transform: rotate(18deg); animation: shoot 9s ease-in infinite 2s;
}
.shooting-star::after { content: ''; position: absolute; right: -2px; top: -2px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px 3px rgba(255, 240, 200, .8); }
.shooting-star.late { top: 5%; left: 44%; width: 110px; animation-duration: 13s; animation-delay: 6.5s; }
.moon-wrap { position: absolute; top: calc(70px + var(--sat)); right: 9%; width: clamp(90px, 13vw, 150px); }
.moon { display: block; width: 100%; height: auto; }
.moon circle[fill^="url"] { display: none; }
.lanterns { position: absolute; inset: 0 0 auto 0; height: 0; }
.lantern-hang { position: absolute; top: 0; width: 44px; transform-origin: 50% 0; animation: swing 5s ease-in-out infinite; }
.lantern-hang svg { display: block; width: 100%; height: auto; }
.lantern circle[fill^='url'] { display: none; }
.lantern-hang.l0 { left: 19%; animation-delay: -1s; }
.lantern-hang.l1 { left: 29%; width: 36px; animation-delay: -2.4s; }
.lantern-hang.l2 { right: 4%; animation-delay: -.4s; }
.lantern-hang.l3 { right: 23%; width: 34px; animation-delay: -3.1s; }
.skyline { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: min(34vh, 300px); }
.skyline .windows path { filter: none; }
.menu-glow, .menu-pattern { display: none; }
.menu-top {
  position: fixed; top: calc(14px + var(--sat)); left: 14px; right: 14px; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  background: var(--glass); border: 0; color: var(--on-dark); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
  transition: transform .2s, box-shadow .2s;
}
.pill:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--gold); }
.pill .ico { width: 18px; height: 18px; color: var(--gold); }
.menu-inner {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: clamp(16px, 3vh, 30px); width: 100%; max-width: 540px; padding: 84px 18px 40px; margin: auto;
}
.hero { position: relative; display: flex; flex-direction: column; align-items: center; }
/* The cards ride a flying carpet that drifts up and down */
.hero-fan { position: relative; width: 300px; height: 190px; margin-bottom: 0; animation: drift 5s ease-in-out infinite; }
.flying-carpet { position: absolute; left: 50%; bottom: -34px; width: 330px; transform: translateX(-50%); animation: ripple 2.6s ease-in-out infinite; }
.hero-card {
  position: absolute; left: 50%; bottom: 14px; width: 94px; height: 132px; margin-left: -47px;
  transform-origin: 50% 130%;
  animation: heroIn 1.1s var(--spring) both; animation-delay: calc(var(--i) * .11s + .15s);
}
.hero-card:nth-child(2) { --r: -24deg; --y: 14px; }
.hero-card:nth-child(3) { --r: -8deg; --y: 0px; }
.hero-card:nth-child(4) { --r: 8deg; --y: 0px; }
.hero-card:nth-child(5) { --r: 24deg; --y: 14px; }
.hero-card { transform: rotate(var(--r)) translateY(var(--y)); }
.hero-card-in {
  position: relative; width: 100%; height: 100%; border-radius: 9px; overflow: hidden; background: #FFFBF1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 14px 28px rgba(10, 0, 30, .45);
}
.hero-card-in svg { display: block; width: 100%; height: 100%; }
.hero-card-in::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 240, 200, .55) 48%, transparent 60%);
  transform: translateX(-120%); animation: shine 6s ease-in-out infinite; animation-delay: calc(var(--i) * .25s + 1.4s);
}
.logo { position: relative; z-index: 1; margin: 36px 0 0; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.logo-ar {
  font-family: var(--font-cal); font-weight: 700; font-size: clamp(76px, 20vw, 128px); line-height: 1.2; padding: 0 .12em;
  color: #E8B547; text-shadow: 0 4px 0 #6B1E2E;
}
.logo-en {
  margin-top: 14px; font-family: var(--font-display); font-weight: 700; font-size: clamp(20px, 5vw, 26px);
  letter-spacing: .32em; text-indent: .32em; text-transform: uppercase; color: var(--gold-1);
}
.tagline { margin: 8px 0 0; font-size: 15px; color: var(--on-dark-2); text-align: center; }
.menu-nav { position: relative; z-index: 1; display: grid; gap: 10px; width: min(400px, 100%); }
.menu-btn {
  display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 22px; border-radius: 20px; cursor: pointer; text-align: start;
  background: var(--glass); border: 0; color: var(--on-dark); box-shadow: inset 0 0 0 1.5px var(--glass-line), var(--shadow-2);
  font-weight: 600; font-size: 17px;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s, filter .2s;
  animation: rise .7s var(--ease) both;
}
.menu-btn:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1.5px var(--gold), var(--shadow-2); }
.menu-btn.primary {
  position: relative; overflow: hidden;
  background: var(--gold-grad); color: #3A2205; font-size: 19px;
  box-shadow: inset 0 0 0 1px var(--gold-3), 0 4px 0 var(--gold-3);
}
.menu-btn.primary::after {
  display: none; content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .55) 46%, transparent 60%);
  transform: translateX(-120%); animation: shine 4.5s ease-in-out infinite 1.5s;
}
.menu-btn.primary:hover { filter: brightness(1.06); }
.menu-btn.primary:active { transform: translateY(1px); }
.menu-btn .ico { width: 24px; height: 24px; }
.menu-btn-text { display: grid; gap: 2px; }
.menu-btn-sub { font-size: 12.5px; font-weight: 500; opacity: .75; }
.menu-btn-sub:empty { display: none; }
.menu-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-btn.small { height: 82px; flex-direction: column; justify-content: center; gap: 7px; padding: 0 6px; font-size: 13px; text-align: center; }
.menu-btn.small .ico { color: var(--gold); }
.menu-btn.daily { position: relative; height: 64px; }
.menu-btn.daily .ico { color: var(--gold); }
.menu-btn.daily .menu-btn-sub { display: inline-flex; align-items: center; gap: 4px; }
.menu-btn.daily .menu-btn-sub .suit-ico { width: 15px; height: 15px; padding: 1.5px; border-radius: 4px; background: var(--parch); }
.daily-stars { margin-inline-start: auto; display: flex; gap: 2px; font-size: 18px; }
.daily-stars i { font-style: normal; color: rgba(255, 241, 214, .2); }
.daily-stars i.on { color: var(--gold); }
.menu-btn.daily:not(.done)::after {
  content: ''; position: absolute; top: 12px; inset-inline-start: 38px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal); animation: pulse 1.6s infinite;
}
.menu-nav > :nth-child(1) { animation-delay: .35s; }
.menu-nav > :nth-child(2) { animation-delay: .43s; }
.menu-nav > :nth-child(3) { animation-delay: .51s; }
.menu-nav > :nth-child(4) { animation-delay: .59s; }
.menu-foot { position: relative; z-index: 1; padding: 0 0 calc(16px + var(--sab)); color: rgba(255, 230, 160, .45); letter-spacing: .6em; font-size: 13px; }

/* ================================================================ FX */

.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 150; }

/* ================================================================ responsive */

.table.compact .nameplate, .table.short .nameplate { font-size: 11.5px; max-width: 96px; padding: 2px 9px 2px 7px; top: calc(100% + 4px); }
.table.compact .scores { column-gap: 8px; padding: 4px 10px 5px; border-radius: 16px; }
.table.compact .team { min-width: 0; gap: 6px; }
.table.compact .team-score { font-size: 20px; }
.table.compact .team-name { font-size: 10px; letter-spacing: .06em; }
.table.compact .target { width: 30px; height: 30px; font-size: 11px; }
.table.portrait .hide-portrait { display: none; }
.table.portrait .contract-chip.muted { display: none; }
.table.compact .contract { display: none; }
.table.compact .meter { gap: 5px; }
.table.compact .meter-n { width: 13px; font-size: 11px; }
.table.compact .duo-row { gap: 8px; }
.table.compact .duo-n { max-width: 44px; font-size: 10px; }
.table.compact .duo-s { font-size: 17px; }
.table.short .scores { padding: 3px 14px 4px; }
.table.short .team-score { font-size: 19px; }
.table.short .target { width: 28px; height: 28px; font-size: 11px; }
.table.short .meter { height: 10px; }
.table.short .meter-cells { height: 5px; }
.table.short .contract-txt small { display: none; }
.table.short .bid-btn { height: 44px; }
.table.short .suit-btn { padding: 6px 4px; }
.table.short .suit-big .suit-ico { width: 30px; height: 30px; }
.table.short .bubble { font-size: 13px; padding: 5px 11px; }
/* Phones in landscape: the trick fills the middle, so the prompt waits in the free corner beside the hand. */
.table.short .prompt { left: auto; right: calc(18px + env(safe-area-inset-right, 0px)); top: auto; bottom: calc(18px + var(--sab)); transform: translateY(12px); }
.table.short .prompt.on { transform: none; }
.table.short .prompt > span:not(.prompt-dot) { display: none; }
.table.short .prompt { gap: 8px; padding-inline-start: 12px; }

@media (max-width: 560px) {
  .modal-actions { bottom: -18px; margin-bottom: -18px; padding-bottom: 18px; }
  .modal-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 12px; white-space: nowrap; font-size: 14.5px; }
  .modal-title { font-size: 30px; }
  .seg-4 .pips { display: none; }
  .bid-grid.classic { grid-template-columns: repeat(4, 1fr); }
  .bid-grid.f41 { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .bid-btn { height: 50px; font-size: 20px; }
  .panel { padding: 16px 14px 16px; border-radius: 22px; }
  .panel-title { font-size: 23px; }
  .suit-grid { gap: 7px; }
  .suit-big .suit-ico { width: 36px; height: 36px; }
  .suit-name { font-size: 12.5px; }
  .modal { padding: 24px 16px 18px; border-radius: 24px; }
  .mode-cards { grid-template-columns: 1fr; }
  .stats-grid.wide { grid-template-columns: 1fr 1fr; }
  .stats-hero { grid-template-columns: 1fr; justify-items: center; }
  .row .seg { min-width: 0; }
  .seg-btn { font-size: 12.5px; padding: 0 4px; }
  .sum-delta { font-size: 30px; }
  .board th, .board td { padding: 8px 5px; }
  .lt { transform: scale(.92); margin: -10px auto; }
  .ach-grid { grid-template-columns: 1fr; }
  .ov-grid { grid-template-columns: 1fr 1fr; }
  .rv-row { grid-template-columns: 18px 1fr; }
  .rv-grade { grid-column: 2; justify-self: start; text-align: start; }
  .rv-gt small { justify-content: flex-start; }
  .rv-face { width: 36px; height: 50px; }
  .sum-coach { flex-wrap: wrap; }
  .sum-coach .btn { flex: 1 1 100%; }
  .tk-c { height: 26px; font-size: 10.5px; border-radius: 6px; }
  .tk-cards { gap: 2px; }
  .tk-row { grid-template-columns: 24px 1fr 22px; gap: 5px; padding: 5px 6px; }
  .tk-suit { width: 24px; height: 24px; }
  .lantern-hang.l1, .lantern-hang.l3 { display: none; }
  .moon-wrap { top: calc(76px + var(--sat)); right: 6%; }
}
@media (max-width: 420px) {
  .menu-top-end .pill span { display: none; }
  .menu-top-end .pill { width: 44px; padding: 0; justify-content: center; }
}
@media (max-width: 380px) {
  .table.compact .team-name { font-size: 9px; letter-spacing: .04em; }
  [lang=ar] .table.compact .team-name { font-size: 11px; }
  .menu-btn { height: 58px; font-size: 16px; }
  .menu-btn.small { height: 74px; font-size: 12px; }
}
@media (max-width: 340px) {
  .table.compact .team-name { display: none; }
}
@media (max-height: 700px) {
  .hero-fan { zoom: .8; }
  .menu-inner { padding-top: 70px; }
  .logo { margin-top: 18px; }
}

/* ================================================================ motion */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.8); } }
@keyframes dots { 0%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-3px); opacity: 1; } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }
@keyframes avatarGlow { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.12); } }
@keyframes archGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
@keyframes hintBob { 0%, 100% { transform: translateY(-20%); } 50% { transform: translateY(-26%); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px) rotate(-2deg); } 40% { transform: translateX(6px) rotate(2deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes medal { 0% { transform: scale(.2) rotate(-30deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes suggest { 0%, 100% { box-shadow: 0 0 0 3px var(--teal), 0 0 18px rgba(31, 181, 172, .55); } 50% { box-shadow: 0 0 0 3px var(--teal), 0 0 6px rgba(31, 181, 172, .2); } }
@keyframes kaboot { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes ltIn { from { transform: scale(.5) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes heroIn { from { transform: rotate(0) translateY(60px) scale(.6); opacity: 0; } to { transform: rotate(var(--r)) translateY(var(--y)); opacity: 1; } }
@keyframes drift { 0%, 100% { transform: translateY(0) rotate(-.6deg); } 50% { transform: translateY(-12px) rotate(.6deg); } }
@keyframes ripple { 0%, 100% { transform: translateX(-50%) skewX(0deg) scaleY(1); } 50% { transform: translateX(-50%) skewX(-3deg) scaleY(.94); } }
@keyframes shine { 0%, 70% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes twinkle { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes moonGlow { 0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 230, 160, .5)); } 50% { filter: drop-shadow(0 0 24px rgba(255, 230, 160, .85)); } }
@keyframes swing { 0%, 100% { transform: rotate(3deg); } 50% { transform: rotate(-3deg); } }
@keyframes magic { 0%, 100% { transform: scale(.9); opacity: .7; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes brilliantGlow { 0%, 100% { box-shadow: inset 0 0 0 1.5px var(--gold-2), var(--shadow-3); } 50% { box-shadow: inset 0 0 0 1.5px var(--gold-2), var(--shadow-3), 0 0 0 6px rgba(19, 163, 154, .3); } }
@keyframes cellIn { 0% { transform: scaleY(.2) scaleX(.6); filter: brightness(1.8); } 100% { transform: none; filter: none; } }
@keyframes starIn { 0% { transform: scale(0) rotate(-60deg); } 100% { transform: none; } }
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .85; } 70% { opacity: .55; } 100% { transform: translate(var(--drift), -85vh); opacity: 0; } }
@keyframes shoot { 0%, 86% { opacity: 0; transform: rotate(18deg) translateX(0); } 88% { opacity: 1; } 96%, 100% { opacity: 0; transform: rotate(18deg) translateX(440px); } }

body.reduced .hero-fan, body.reduced .flying-carpet, body.reduced .lantern-hang, body.reduced .hero-card-in::after,
body.reduced .go-rays, body.reduced .menu-bg .stars .tw, body.reduced .menu-btn.primary::after { animation: none; }
body.reduced .card.hint .lift { animation: none; transform: translateY(-20%); }
body.reduced .motes, body.reduced .shooting-star { display: none; }
@media (prefers-reduced-motion: reduce) {
  .hero-fan, .flying-carpet, .lantern-hang, .hero-card-in::after, .go-rays, .menu-bg .stars .tw, .menu-btn.primary::after { animation: none; }
  .motes, .shooting-star { display: none; }
}

/* Numbers: lining, and tabular where columns of them must line up. Signs stay left in Arabic. */
* { font-variant-numeric: lining-nums; }
.team-score, .duo-s, .lvl-v, .meter-n, .board td, .tk-out { font-variant-numeric: lining-nums tabular-nums; }
.sum-delta, .sum-total, .team-score, .duo-s, .board td, .board tfoot td, .stat-v, .lvl-v,
.bid-btn, .bub-bid, .banner-big, .sum-emblem span, .contract-txt b, .target, .chip {
  direction: ltr; unicode-bidi: isolate;
}

/* ================================================================ ONLINE */

.online-only { display: none !important; }
body.online .online-only { display: grid !important; }
.prompt-clock { min-width: 0; font-weight: 700; color: var(--gold); }
.prompt-clock:empty { display: none; }
.prompt-clock.urgent { color: #FF8EA0; animation: pulse .5s infinite; }
.seat.bot .nameplate::after {
  content: attr(data-tag); padding: 0 5px; border-radius: 6px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  background: rgba(255, 241, 214, .14); color: var(--on-dark-2);
}
.seat.away .avatar { opacity: .45; }
.seat.away .nameplate { opacity: .7; }
.bub-chat { font-weight: 600; }

/* Quick chat sheet */
.chat-pop {
  position: absolute; z-index: 70; right: 14px; top: calc(var(--hud-h) + var(--sat) + 6px);
  width: min(360px, calc(100vw - 28px)); padding: 12px; border-radius: 20px;
  background: var(--parch); color: var(--ink); box-shadow: inset 0 0 0 2px var(--gold-2), var(--shadow-3);
  opacity: 0; transform: translateY(-8px) scale(.97); pointer-events: none; transform-origin: 90% 0;
  transition: opacity .2s, transform .25s var(--spring);
}
[dir=rtl] .chat-pop { right: auto; left: 14px; transform-origin: 10% 0; }
.chat-pop.on { opacity: 1; transform: none; pointer-events: auto; }
.chat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: min(52vh, 360px); overflow: auto; }
.chat-btn {
  min-height: 40px; padding: 6px 10px; border: 0; border-radius: 12px; cursor: pointer; text-align: start;
  background: #FFFDF6; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 13.5px; font-weight: 600; line-height: 1.25;
}
.chat-btn:hover { background: #FFF2CF; }
.chat-mute {
  display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 6px 4px; border: 0; background: none;
  color: var(--ink-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chat-mute .ico { width: 16px; height: 16px; }

/* Matchmaking */
.online-intro { display: flex; gap: 10px; align-items: flex-start; margin: -4px 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.online-intro .ico { flex: none; color: var(--gold-3); }
.modal-mm { text-align: center; }
.mm-mode { font-weight: 600; color: var(--ink-2); font-size: 14px; }
.mm-seats { display: flex; justify-content: center; gap: 10px; margin: 16px 0 10px; }
.mm-seat {
  width: 48px; height: 58px; display: grid; place-items: center; color: var(--parch-3);
  border: 2px dashed var(--line-2); border-radius: 24px 24px 8px 8px;
}
.mm-seat.on { border: 0; background: var(--night-2); color: var(--gold); animation: pop .35s var(--spring); }
.mm-status { margin: 0 0 4px; font-weight: 700; font-size: 15px; }
.mm-time { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); }
.mm-fail p { margin: 6px 0 14px; color: var(--ink-2); }

/* Printed look: no shimmer, sparkles or light streaks. */
.hero-card-in::after, .motes, .shooting-star { display: none !important; }
