/* ==========================================================
   حکم آنلاین — styles
   ========================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair';
  src: url('../fonts/playfair-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Playfair';
  src: url('../fonts/playfair-900.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}

:root {
  --bg-0: #060a14;
  --bg-1: #0c1326;
  --bg-2: #141d3a;
  --glass: rgba(16, 24, 48, .66);
  --glass-hi: rgba(28, 38, 70, .72);
  --line: rgba(255, 255, 255, .09);
  --line-hi: rgba(255, 255, 255, .16);
  --text: #f4f0e6;
  --muted: #a3abc4;
  --dim: #6d7594;

  --gold: #eab84a;
  --gold-hi: #ffd678;
  --gold-2: #c98f25;
  --gold-3: #7d5512;
  --teal: #34d6c0;
  --teal-2: #13a491;
  --teal-3: #0a6a5e;
  --ruby: #ff7489;
  --ruby-2: #dc3b58;
  --ruby-3: #8c1d36;

  --felt-1: #15805a;
  --felt-2: #0c573f;
  --felt-3: #05281d;
  --wood-1: #7a431f;
  --wood-2: #45220d;
  --wood-3: #1f0e05;

  --card-bg: #fffcf4;
  --card-bg-2: #f1e9d6;
  --card-red: #c62238;
  --card-black: #171923;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);

  --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --font-card: 'Playfair', Georgia, 'Times New Roman', serif;

  /* card + table geometry */
  --cw: clamp(52px, min(5.4vw + 22px, 17vh), 108px);
  --ch: calc(var(--cw) * 1.42);
  --tcw: calc(var(--cw) * .9);
  --tw: min(86vw, 1120px, 150vh);
  --th: calc(var(--tw) * .54);
  --tilt: 36deg;
  --table-y: 45%;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
html { height: 100dvh; }
body {
  position: fixed; inset: 0; height: auto;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
svg { display: block; }
.hidden { display: none !important; }

* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ---------- backdrop ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 50% 38%, rgba(21, 128, 90, .22), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(234, 184, 74, .10), transparent 60%),
    radial-gradient(800px 600px at 5% -10%, rgba(52, 214, 192, .08), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
.backdrop::after {
  content: ''; position: absolute; inset: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23eab84a' stroke-width='1'%3E%3Cpath d='M40 8l9 23 23 9-23 9-9 23-9-23-23-9 23-9z'/%3E%3Cpath d='M40 8l9 23 23 9-23 9-9 23-9-23-23-9 23-9z' transform='rotate(45 40 40)'/%3E%3Ccircle cx='40' cy='40' r='8'/%3E%3Cpath d='M0 0l8 8M80 0l-8 8M0 80l8-8M80 80l-8-8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}

main { position: relative; z-index: 1; height: 100%; }
.screen {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .45s var(--ease), visibility 0s linear .45s;
}
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .45s var(--ease); }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

/* ---------- buttons ---------- */
.btn {
  --c1: #3a4466; --c2: #262e4a; --edge: #151a2e; --fg: var(--text);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px; width: 100%;
  border-radius: 14px;
  font-weight: 800; font-size: 16px; color: var(--fg);
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 5px 0 var(--edge), 0 10px 22px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
  transform: translateY(0);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .2s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge), 0 4px 10px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn:disabled { cursor: not-allowed; filter: grayscale(.8) brightness(.7); }
.btn-gold { --c1: #ffd678; --c2: #e0a93a; --edge: #8d5f13; --fg: #2b1a02; }
.btn-teal { --c1: #4ee6d1; --c2: #17ab97; --edge: #0a6258; --fg: #03241f; }
.btn-ruby { --c1: #ff8a9c; --c2: #de4561; --edge: #861b33; --fg: #2d0510; }
.btn-ghost { --c1: rgba(255, 255, 255, .1); --c2: rgba(255, 255, 255, .06); --edge: rgba(0, 0, 0, .35); }
.btn-lg { height: 58px; font-size: 18px; }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  color: var(--text);
  transition: background .2s, transform .15s var(--ease);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: rgba(255, 255, 255, .13); }
.icon-btn:active { transform: scale(.93); }
.icon-btn.on { background: var(--gold-soft, rgba(234, 184, 74, .18)); border-color: rgba(234, 184, 74, .45); color: var(--gold-hi); }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700;
  transition: background .2s;
}
.chip-btn svg { width: 16px; height: 16px; }
.chip-btn:hover { background: rgba(255, 255, 255, .14); }

.link-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14px;
  transition: color .2s, background .2s;
}
.link-btn svg { width: 18px; height: 18px; }
.link-btn:hover { color: var(--gold-hi); background: rgba(255, 255, 255, .05); }

/* ---------- HOME: main menu ---------- */
.menu {
  height: 100%;
  display: grid; grid-template-rows: auto 1fr auto; justify-items: center;
  padding: calc(12px + var(--safe-t)) 16px calc(18px + var(--safe-b));
  gap: clamp(8px, 2vh, 20px);
}
.menu-top { width: min(100%, 720px); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-icons { display: flex; gap: 8px; }
.menu-icons .icon-btn { background: rgba(8, 12, 24, .55); }

.profile {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(40, 52, 92, .8), rgba(18, 24, 46, .8));
  border: 1px solid var(--line-hi);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .1);
  transition: transform .15s var(--ease);
}
.profile:active { transform: translateY(2px); }
.profile .avatar { width: 40px; height: 40px; font-size: 17px; }
.profile-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.3; }
.profile-text small { font-size: 10.5px; color: var(--muted); font-weight: 700; }
.profile-text b { font-size: 14px; font-weight: 900; max-width: 34vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-edit { width: 16px; height: 16px; color: var(--gold-hi); flex: none; }

.hero { align-self: center; text-align: center; perspective: 900px; }
.hero-cards {
  --hw: clamp(52px, 11vh, 86px);
  position: relative; height: calc(var(--hw) * 1.9); width: calc(var(--hw) * 3.3); margin: 0 auto;
  transform-style: preserve-3d;
  animation: heroFloat 7s ease-in-out infinite;
}
.hero-cards .card { --w: var(--hw); left: 50%; top: calc(var(--hw) * .25); margin-left: calc(var(--hw) / -2); transform-origin: 50% 120%; }
.hero-cards .card:nth-child(1) { transform: rotate(-24deg) translateZ(0); }
.hero-cards .card:nth-child(2) { transform: rotate(-8deg) translateY(-8px) translateZ(8px); }
.hero-cards .card:nth-child(3) { transform: rotate(8deg) translateY(-8px) translateZ(16px); }
.hero-cards .card:nth-child(4) { transform: rotate(24deg) translateZ(24px); }
@keyframes heroFloat {
  0%, 100% { transform: rotateX(18deg) rotateY(-10deg) translateY(0); }
  50% { transform: rotateX(10deg) rotateY(10deg) translateY(-6px); }
}
.logo {
  margin: 0; font-size: clamp(50px, 11vh, 96px); font-weight: 900; line-height: 1.05;
  background: linear-gradient(180deg, #fff3cf 10%, var(--gold) 55%, var(--gold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(125, 85, 18, .7)) drop-shadow(0 12px 24px rgba(0, 0, 0, .5));
}
.tagline { margin: 4px 0 0; color: var(--muted); font-size: clamp(12.5px, 1.8vh, 15px); }

.menu-main { width: min(100%, 420px); display: flex; flex-direction: column; gap: clamp(10px, 1.8vh, 16px); }
.menu-btn {
  --c1: #3a4466; --c2: #262e4a; --edge: #151a2e; --fg: var(--text); --ic: rgba(0, 0, 0, .18);
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px; width: 100%;
  height: clamp(62px, 9.5vh, 78px); padding: 0 12px 0 18px;
  border-radius: 20px; color: var(--fg); text-align: right;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 6px 0 var(--edge), 0 14px 26px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -3px 0 rgba(0, 0, 0, .12);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .2s;
  animation: menuIn .5s var(--spring) both;
}
.menu-btn:nth-child(2) { animation-delay: .06s; }
.menu-btn:nth-child(3) { animation-delay: .12s; }
@keyframes menuIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
.menu-btn::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent);
  transform: skewX(-18deg); pointer-events: none;
}
.menu-btn.gold::after { animation: shine 3.6s 1.2s ease-in-out infinite; }
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.menu-btn:hover { filter: brightness(1.07); }
.menu-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge), 0 5px 12px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .35); }
.menu-btn.gold { --c1: #ffd678; --c2: #e0a93a; --edge: #8d5f13; --fg: #2b1a02; }
.menu-btn.teal { --c1: #4ee6d1; --c2: #17ab97; --edge: #0a6258; --fg: #03241f; }
.menu-btn.violet { --c1: #a98bff; --c2: #7254e0; --edge: #3d2891; --fg: #fff; }
.mb-icon {
  flex: none; width: clamp(44px, 6.5vh, 54px); height: clamp(44px, 6.5vh, 54px); border-radius: 16px;
  display: grid; place-items: center; background: var(--ic);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18), 0 1px 0 rgba(255, 255, 255, .3);
}
.mb-icon svg { width: 26px; height: 26px; }
.mb-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mb-text b { font-size: clamp(18px, 2.7vh, 22px); font-weight: 900; line-height: 1.2; }
.mb-text small { font-size: 12.5px; font-weight: 700; opacity: .72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- menu panels (name / create / join) ---------- */
.modal.panel { width: min(100%, 400px); padding-top: 38px; overflow: visible; }
.panel-ribbon {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%);
  padding: 9px 30px; border-radius: 14px; white-space: nowrap;
  font-size: 18px; font-weight: 900; color: #2b1a02;
  background: linear-gradient(180deg, #ffe39a, #e0a93a);
  box-shadow: 0 4px 0 #8d5f13, 0 10px 20px rgba(0, 0, 0, .4), inset 0 1px 0 #fff6d8;
}
.panel-ribbon.teal { color: #03241f; background: linear-gradient(180deg, #7cf0e0, #17ab97); box-shadow: 0 4px 0 #0a6258, 0 10px 20px rgba(0, 0, 0, .4), inset 0 1px 0 #d6fff9; }
.panel-ribbon.violet { color: #fff; background: linear-gradient(180deg, #b9a0ff, #7254e0); box-shadow: 0 4px 0 #3d2891, 0 10px 20px rgba(0, 0, 0, .4), inset 0 1px 0 #e4dbff; }
.panel > p { margin: 4px 0 16px; }
.panel .modal-close { top: 10px; left: 10px; width: 36px; height: 36px; }
.panel .opts { margin-top: 10px; text-align: right; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field input {
  height: 54px; border-radius: 14px; padding: 0 16px; text-align: center;
  background: rgba(0, 0, 0, .28); border: 1.5px solid var(--line-hi);
  font-size: 19px; font-weight: 800; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(234, 184, 74, .18); }
.field input.shake { animation: shake .4s; border-color: var(--ruby); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); font-weight: 700; }
.seg { display: inline-flex; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 3px; border: 1px solid var(--line); }
.seg button {
  min-width: 46px; height: 36px; padding: 0 10px; border-radius: 9px;
  font-size: 14px; font-weight: 800; color: var(--muted);
  transition: background .2s, color .2s;
}
.seg button.on { background: linear-gradient(180deg, #ffd678, #e0a93a); color: #2b1a02; box-shadow: 0 2px 0 #8d5f13; }

.code-input { display: flex; gap: 8px; justify-content: center; }
.code-input input {
  width: 100%; max-width: 58px; aspect-ratio: .82; border-radius: 14px;
  text-align: center; font-size: 26px; font-weight: 900; font-family: var(--font);
  background: rgba(0, 0, 0, .3); border: 1.5px solid var(--line-hi); outline: none;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
  transition: border-color .2s, box-shadow .2s, transform .2s var(--spring);
}
.code-input input:focus { border-color: #a98bff; box-shadow: 0 0 0 4px rgba(169, 139, 255, .22); transform: translateY(-2px); }
.code-input input.filled { border-color: rgba(169, 139, 255, .65); background: rgba(169, 139, 255, .1); }

/* ---------- ROOM: lobby table ---------- */
.topbar {
  width: 100%; display: flex; align-items: center; gap: 12px;
}
.topbar h2 { margin: 0; font-size: 18px; font-weight: 900; flex: 1; text-align: center; }
.topbar .icon-btn { background: rgba(8, 12, 24, .55); }
.topbar .fs-btn.hidden { display: grid !important; visibility: hidden; }
.room {
  height: 100%; margin: 0 auto; width: min(100%, 680px);
  display: flex; flex-direction: column; align-items: stretch; gap: clamp(8px, 1.6vh, 14px);
  padding: calc(10px + var(--safe-t)) 16px calc(14px + var(--safe-b));
}
.code-card {
  border-radius: 20px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.code-digits { display: flex; gap: 6px; }
.code-digits span {
  width: clamp(34px, min(6vh, 10.5vw), 50px); height: clamp(42px, min(7.2vh, 12.6vw), 60px); border-radius: 12px;
  display: grid; place-items: center;
  font-size: clamp(24px, 4vh, 32px); font-weight: 900; color: #2b1a02;
  background: linear-gradient(180deg, #fff1c7, #eab84a);
  box-shadow: 0 4px 0 #8d5f13, 0 10px 20px rgba(0, 0, 0, .35), inset 0 1px 0 #fff;
  animation: digitIn .5s var(--spring) both;
}
.code-digits span:nth-child(2) { animation-delay: .05s; }
.code-digits span:nth-child(3) { animation-delay: .1s; }
.code-digits span:nth-child(4) { animation-delay: .15s; }
.code-digits span:nth-child(5) { animation-delay: .2s; }
@keyframes digitIn { from { transform: translateY(12px) rotateX(60deg); opacity: 0; } }
.code-actions { display: flex; gap: 8px; }
.icon-btn.gold { background: linear-gradient(180deg, #ffd678, #e0a93a); color: #2b1a02; border-color: transparent; box-shadow: 0 3px 0 #8d5f13; }

/* seats sit around a small felt table: 0 bottom, 1 right, 2 top, 3 left (partners opposite) */
.lobby-table { position: relative; flex: 1; min-height: 0; }
.lobby-felt {
  position: absolute; left: 50%; top: 50%;
  width: min(62%, 360px); height: min(46%, 240px);
  transform: translate(-50%, -50%);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, .08), transparent 55%),
    radial-gradient(ellipse at 50% 50%, var(--felt-1), var(--felt-2) 62%, var(--felt-3));
  box-shadow: 0 0 0 clamp(8px, 1.4vh, 12px) var(--wood-2), 0 0 0 calc(clamp(8px, 1.4vh, 12px) + 1.5px) rgba(234, 184, 74, .55),
    inset 0 0 40px rgba(0, 0, 0, .55), 0 30px 60px rgba(0, 0, 0, .55);
}
.team-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 900; }
.team-label i { width: 9px; height: 9px; border-radius: 50%; }
.team-label.t0 { color: var(--teal); }
.team-label.t1 { color: var(--ruby); }
.team-label.t0 i { background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.team-label.t1 i { background: var(--ruby); box-shadow: 0 0 10px var(--ruby); }
@media (max-aspect-ratio: 1/1) {
  .lobby-felt { width: min(52%, 300px); height: min(56%, 320px); flex-direction: column; gap: 8px; }
}
.vs { font-family: var(--font-card); font-weight: 900; font-size: 18px; color: rgba(234, 184, 74, .7); }

.lseat {
  position: absolute; z-index: 1;
  width: clamp(96px, 27vw, 150px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 10px 6px; border-radius: 18px;
  background: rgba(8, 12, 24, .78); border: 1.5px solid var(--line-hi);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeUp .35s var(--ease) both;
}
.lseat.team0 { border-color: rgba(52, 214, 192, .4); }
.lseat.team1 { border-color: rgba(255, 116, 137, .4); }
.lseat.s0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.lseat.s2 { left: 50%; top: 0; transform: translateX(-50%); }
.lseat.s1 { right: 0; top: 50%; transform: translateY(-50%); }
.lseat.s3 { left: 0; top: 50%; transform: translateY(-50%); }
.lseat.me { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(234, 184, 74, .25), 0 10px 24px rgba(0, 0, 0, .45); }
.lseat.vacant { border-style: dashed; background: rgba(8, 12, 24, .5); }
.lseat .avatar { width: clamp(40px, 6.4vh, 52px); height: clamp(40px, 6.4vh, 52px); font-size: 19px; }
.lseat .lname { font-weight: 800; font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lseat.vacant .lname { color: var(--dim); }
.lseat .tags { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.lseat .tags:empty { display: none; }
.tag { font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: var(--muted); }
.tag.host { background: rgba(234, 184, 74, .2); color: var(--gold-hi); }
.tag.you { background: rgba(255, 255, 255, .9); color: #111; }
.tag.off { background: rgba(255, 116, 137, .2); color: var(--ruby); }
.lseat .empty {
  width: clamp(40px, 6.4vh, 52px); height: clamp(40px, 6.4vh, 52px); border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .22);
  display: grid; place-items: center; color: var(--dim);
}
.lseat .empty svg { width: 18px; height: 18px; }
.lseat .seat-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.lseat .seat-actions:empty { display: none; }
.mini-btn {
  height: 28px; padding: 0 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800;
  background: rgba(255, 255, 255, .1); border: 1px solid var(--line-hi);
  display: inline-flex; align-items: center; gap: 3px;
  transition: background .2s, transform .15s;
}
.mini-btn:active { transform: scale(.95); }
.mini-btn svg { width: 13px; height: 13px; }
.mini-btn:hover { background: rgba(255, 255, 255, .18); }
.mini-btn.gold { background: rgba(234, 184, 74, .2); border-color: rgba(234, 184, 74, .45); color: var(--gold-hi); }
.mini-btn.danger { color: var(--ruby); }

.room-foot { display: flex; flex-direction: column; gap: 10px; }
.room-settings { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.room-settings .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--muted);
}
button.pill { cursor: pointer; border-style: dashed; }
.room-settings .pill b { color: var(--text); }
.hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0; }

/* ---------- avatars ---------- */
.avatar {
  --a1: #3a4466; --a2: #1e2440;
  position: relative; flex: none;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 22px; color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--a1), var(--a2));
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .12), 0 8px 18px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .25);
  text-shadow: 0 2px 4px rgba(0, 0, 0, .35);
}
.team0 .avatar, .avatar.team0 { --a1: #4ee6d1; --a2: #0b6e61; box-shadow: 0 0 0 3px rgba(52, 214, 192, .55), 0 8px 18px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .3); }
.team1 .avatar, .avatar.team1 { --a1: #ff8a9c; --a2: #8c1d36; box-shadow: 0 0 0 3px rgba(255, 116, 137, .55), 0 8px 18px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .3); }
.avatar .cnt {
  position: absolute; bottom: -3px; left: -5px; min-width: 22px; height: 20px; padding: 0 5px;
  border-radius: 10px; display: grid; place-items: center;
  font-size: 11px; font-weight: 900; color: #2b1a02;
  background: linear-gradient(180deg, #fff1c7, var(--gold)); box-shadow: 0 2px 0 var(--gold-3), 0 3px 8px rgba(0, 0, 0, .4);
  text-shadow: none;
}
.nocards .avatar .cnt { display: none; }
.avatar .bot-mark {
  position: absolute; bottom: -4px; left: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--line-hi); display: grid; place-items: center; color: var(--muted);
}
.avatar .bot-mark svg { width: 13px; height: 13px; }

/* ==========================================================
   GAME
   ========================================================== */
#screen-game { overflow: hidden; }
.scene {
  position: absolute; inset: 0;
  perspective: 1500px;
  perspective-origin: 50% 25%;
}
.table {
  position: absolute; left: 50%; top: var(--table-y);
  width: var(--tw); height: var(--th);
  margin-left: calc(var(--tw) / -2); margin-top: calc(var(--th) / -2);
  transform: rotateX(var(--tilt));
  transform-style: preserve-3d;
}
.table-side {
  position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(180deg, #3b1d0a, #150802);
}
.table-side.s1 { transform: translateZ(-8px); }
.table-side.s2 { transform: translateZ(-16px); background: #1d0c03; }
.table-side.s3 { transform: translateZ(-26px); background: #0e0501; box-shadow: 0 50px 80px rgba(0, 0, 0, .65), 0 0 120px rgba(0, 0, 0, .5); }
.table-rim {
  position: absolute; inset: 0; border-radius: 999px;
  padding: calc(var(--tw) * .026);
  background:
    repeating-linear-gradient(97deg, rgba(0, 0, 0, .09) 0 2px, transparent 2px 7px, rgba(255, 255, 255, .03) 7px 8px, transparent 8px 13px),
    radial-gradient(ellipse at 50% 0%, rgba(255, 200, 140, .25), transparent 60%),
    linear-gradient(180deg, var(--wood-1), var(--wood-2) 60%, var(--wood-3));
  box-shadow: inset 0 2px 1px rgba(255, 220, 170, .35), inset 0 -4px 8px rgba(0, 0, 0, .6);
  transform-style: preserve-3d;
}
.table-rim::after {
  content: ''; position: absolute; border-radius: 999px; pointer-events: none;
  inset: calc(var(--tw) * .026 - 5px);
  border: 1.5px solid rgba(234, 184, 74, .65);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 0 12px rgba(234, 184, 74, .2);
}
.felt {
  position: relative; width: 100%; height: 100%; border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, .08), transparent 55%),
    radial-gradient(ellipse at 50% 50%, var(--felt-1), var(--felt-2) 62%, var(--felt-3));
  box-shadow: inset 0 0 70px rgba(0, 0, 0, .6), inset 0 0 0 2px rgba(0, 0, 0, .45);
  transform-style: preserve-3d;
}
.felt::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; opacity: .45; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.medallion {
  position: absolute; left: 50%; top: 50%;
  width: calc(var(--th) * .78); height: calc(var(--th) * .78);
  transform: translate(-50%, -50%);
  color: rgba(234, 184, 74, .16);
  pointer-events: none;
}
.felt-trump {
  position: absolute; left: 50%; top: 50%; width: calc(var(--th) * .2); height: calc(var(--th) * .2);
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity .6s;
  pointer-events: none;
}
.felt-trump.show { opacity: .18; }
.felt-trump svg { width: 100%; height: 100%; fill: #fff; }

.trick { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.trick .card {
  --w: var(--tcw);
  left: calc(var(--tcw) / -2); top: calc(var(--tcw) * -.71);
  transform: translate3d(calc(var(--px, 0) * var(--tcw)), calc(var(--py, 0) * var(--tcw)), var(--pz, 0px)) rotate(var(--pr, 0deg));
  transition: transform .35s var(--ease), filter .3s;
}
.trick .card.win { --pz: 18px; }
.trick .card.win .face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 26px rgba(255, 214, 120, .75), 0 10px 20px rgba(0, 0, 0, .4); }
.trick .card.lose { filter: brightness(.72) saturate(.8); }

/* ---------- cards ---------- */
.card {
  --w: var(--cw);
  position: absolute;
  width: var(--w); height: calc(var(--w) * 1.42);
  font-size: var(--w);
  transform-style: preserve-3d;
}
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .55s var(--ease);
}
.card.down .card-inner { transform: rotateY(180deg); }
.face, .back {
  position: absolute; inset: 0;
  border-radius: .085em;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face {
  background: linear-gradient(165deg, var(--card-bg) 40%, var(--card-bg-2));
  color: var(--card-black);
  box-shadow: inset 0 0 0 .008em rgba(0, 0, 0, .18), inset 0 .01em 0 #fff, 0 .03em .08em rgba(0, 0, 0, .35), 0 .06em .16em rgba(0, 0, 0, .2);
  overflow: hidden;
  transition: box-shadow .25s;
}
.face.red { color: var(--card-red); }
.corner {
  position: absolute; top: .055em; left: .06em;
  width: .2em; display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.corner b { font-family: var(--font-card); font-weight: 900; font-size: .235em; letter-spacing: -.06em; }
.corner svg { width: .15em; height: .15em; margin-top: .02em; fill: currentColor; }
.corner.br { top: auto; left: auto; bottom: .055em; right: .06em; transform: rotate(180deg); }
.pips { position: absolute; left: 30%; right: 30%; top: 15%; bottom: 15%; }
.pips svg { position: absolute; width: .19em; height: .19em; fill: currentColor; transform: translate(-50%, -50%); }
.pips svg.flip { transform: translate(-50%, -50%) rotate(180deg); }
.ace { position: absolute; inset: 0; display: grid; place-items: center; }
.ace svg { width: .5em; height: .5em; fill: currentColor; filter: drop-shadow(0 .01em 0 rgba(0, 0, 0, .15)); }
.ace::before {
  content: ''; position: absolute; width: .7em; height: .7em; border-radius: 50%;
  border: .006em solid currentColor; opacity: .25;
  box-shadow: 0 0 0 .03em rgba(234, 184, 74, .25);
}
.court {
  position: absolute; inset: .2em .19em; border-radius: .04em;
  border: .012em solid var(--gold-2);
  box-shadow: inset 0 0 0 .02em var(--card-bg), inset 0 0 0 .028em rgba(201, 143, 37, .6);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, .7), transparent 60%),
    repeating-linear-gradient(45deg, rgba(201, 143, 37, .12) 0 .01em, transparent .01em .05em),
    repeating-linear-gradient(-45deg, rgba(201, 143, 37, .12) 0 .01em, transparent .01em .05em),
    linear-gradient(180deg, #fbf1d9, #efdfb8);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.court .crest { width: .2em; height: .2em; color: var(--gold-2); margin-bottom: .01em; }
.court b { font-family: var(--font-card); font-weight: 900; font-size: .42em; line-height: .9; }
.court .suit { width: .19em; height: .19em; fill: currentColor; margin-top: .03em; }

.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, #9e1f3a 0 .12em, transparent .125em),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12 3l2.6 6.4L21 12l-6.4 2.6L12 21l-2.6-6.4L3 12l6.4-2.6z' fill='none' stroke='%23eab84a' stroke-opacity='.55' stroke-width='1'/%3E%3Cg fill='%23eab84a' fill-opacity='.45'%3E%3Ccircle r='2'/%3E%3Ccircle cx='24' r='2'/%3E%3Ccircle cy='24' r='2'/%3E%3Ccircle cx='24' cy='24' r='2'/%3E%3C/g%3E%3C/svg%3E") center / .2em .2em,
    linear-gradient(160deg, #7c1630, #4a0b1c);
  box-shadow: inset 0 0 0 .04em #f4ead2, inset 0 0 0 .052em var(--gold-2), inset 0 0 .1em rgba(0, 0, 0, .5), 0 .03em .08em rgba(0, 0, 0, .4);
}
.back::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: .2em; height: .2em;
  transform: translate(-50%, -50%) rotate(45deg);
  border: .012em solid var(--gold); background: #7c1630;
  box-shadow: 0 0 0 .02em #7c1630, 0 0 0 .03em rgba(234, 184, 74, .6);
}

/* ---------- hand ---------- */
.hand {
  position: absolute; left: 50%; bottom: calc(10px + var(--safe-b));
  width: 0; height: var(--ch);
  z-index: 20;
}
.hand .card {
  --x: 0px; --y: 0px; --r: 0deg; --lift: 0px;
  left: calc(var(--cw) / -2); top: 0;
  transform-origin: 50% 130%;
  transform: translate3d(var(--x), calc(var(--y) + var(--lift)), 0) rotate(var(--r));
  transition: transform .42s var(--ease), filter .25s;
  cursor: default;
}
.hand .card.dealing { transition: transform .6s var(--ease); }
.hand.my-turn .card.playable { cursor: pointer; }
.hand.my-turn .card.playable .face { box-shadow: inset 0 0 0 .008em rgba(0, 0, 0, .18), 0 0 0 .02em var(--gold), 0 0 .16em rgba(234, 184, 74, .5), 0 .06em .16em rgba(0, 0, 0, .3); }
.hand.my-turn .card:not(.playable) { filter: brightness(.5) saturate(.5); --lift: 12px; }
@media (hover: hover) {
  .hand.my-turn .card.playable:hover { --lift: -24px; }
}
.hand .card.selected { --lift: -30px !important; }
.hand .card.sending { --lift: -46px !important; opacity: .9; }
.hand .card.nope { animation: nope .35s; }
@keyframes nope { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }

/* ---------- seats in game ---------- */
.gseat {
  position: absolute; z-index: 15;
  display: flex; align-items: center; gap: 10px;
  transition: opacity .3s;
}
.gseat[data-pos="0"] { right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(var(--ch) + 22px + var(--safe-b)); flex-direction: row; }
.gseat[data-pos="1"] { right: calc(14px + env(safe-area-inset-right, 0px)); top: 40%; flex-direction: column; }
.gseat[data-pos="2"] { left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); flex-direction: column; }
.gseat[data-pos="3"] { left: calc(14px + env(safe-area-inset-left, 0px)); top: 40%; flex-direction: column; }
.gseat .avatar { width: 58px; height: 58px; }
.gseat .ring { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); transform: rotate(-90deg); pointer-events: none; opacity: 0; }
.gseat .ring circle { fill: none; stroke: var(--gold-hi); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; }
.gseat.turn .ring { opacity: 1; }
.gseat.turn .ring.run circle { animation: ring var(--dur, 30s) linear forwards; animation-delay: var(--delay, 0s); }
@keyframes ring { to { stroke-dashoffset: 100; stroke: var(--ruby); } }
.gseat.turn .avatar { animation: turnGlow 1.6s ease-in-out infinite; }
@keyframes turnGlow { 50% { filter: brightness(1.25); transform: scale(1.05); } }
.gseat .crown {
  position: absolute; top: -17px; left: 50%; width: 26px; height: 26px; margin-left: -13px;
  color: var(--gold-hi); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6));
  opacity: 0; transform: translateY(6px) scale(.5); transition: all .4s var(--spring);
}
.gseat.hakem .crown { opacity: 1; transform: none; }
.gseat.offline .avatar { filter: grayscale(1) brightness(.6); }
.pinfo {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: rgba(6, 10, 20, .7); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px 10px; min-width: 76px; max-width: 130px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pname { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.pmeta { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.gseat.team0 .pname { color: #b8fff4; }
.gseat.team1 .pname { color: #ffd0d8; }
.thinking { display: none; gap: 3px; height: 6px; align-items: center; }
.gseat.turn.botturn .thinking { display: inline-flex; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold-hi); animation: dot 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .2; transform: translateY(-2px); } }

.opp-hand { position: absolute; width: 0; height: 0; pointer-events: none; }
.gseat[data-pos="2"] .opp-hand { left: 50%; top: calc(100% + 14px); transform: rotate(180deg); }
.gseat[data-pos="1"] .opp-hand { left: -26px; top: 32px; transform: rotate(-90deg); }
.gseat[data-pos="3"] .opp-hand { right: -26px; top: 32px; transform: rotate(90deg); }
.opp-hand .card { --w: 30px; left: -15px; top: -42px; transform-origin: 50% 110%; transition: transform .4s var(--ease), opacity .3s; }

.bubble {
  position: absolute; z-index: 30;
  max-width: 200px; padding: 8px 12px; border-radius: 16px;
  background: #fff; color: #111; font-size: 13px; font-weight: 700; line-height: 1.5;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .4);
  opacity: 0; transform: scale(.6); transform-origin: bottom center;
  transition: opacity .25s, transform .35s var(--spring);
  pointer-events: none; white-space: normal; word-break: break-word;
}
.bubble.emoji { background: none; box-shadow: none; font-size: 44px; padding: 0; }
.bubble.show { opacity: 1; transform: scale(1); }
.gseat[data-pos="0"] .bubble { bottom: calc(100% + 8px); right: 0; }
.gseat[data-pos="1"] .bubble { right: calc(100% + 10px); top: 0; }
.gseat[data-pos="2"] .bubble { top: 100%; right: calc(50% + 40px); }
.gseat[data-pos="3"] .bubble { left: calc(100% + 10px); top: 0; }

/* ---------- HUD ---------- */
.hud { position: absolute; z-index: 25; }
.hud-score {
  top: calc(12px + var(--safe-t)); right: calc(12px + env(safe-area-inset-right, 0px));
  border-radius: 18px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; min-width: 188px;
}
.score-row { display: flex; align-items: center; gap: 10px; }
.score-row .tdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.score-row.t0 .tdot { background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.score-row.t1 .tdot { background: var(--ruby); box-shadow: 0 0 10px var(--ruby); }
.score-row .tname { font-size: 12.5px; font-weight: 800; flex: 1; white-space: nowrap; }
.score-row .tpts { font-size: 22px; font-weight: 900; min-width: 22px; text-align: center; line-height: 1; }
.score-row.t0 .tpts { color: var(--teal); }
.score-row.t1 .tpts { color: var(--ruby); }
.score-row .tpts.bump { animation: bump .6s var(--spring); }
@keyframes bump { 40% { transform: scale(1.6); } }
.tricks { display: flex; gap: 3px; direction: ltr; }
.tricks i { width: 8px; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, .1); transition: background .3s, transform .3s var(--spring); }
.score-row.t0 .tricks i.on { background: var(--teal); transform: scaleY(1.15); }
.score-row.t1 .tricks i.on { background: var(--ruby); transform: scaleY(1.15); }
.score-foot { font-size: 11px; color: var(--dim); font-weight: 700; text-align: center; border-top: 1px solid var(--line); padding-top: 6px; }

.hud-trump {
  top: calc(12px + var(--safe-t)); left: calc(12px + env(safe-area-inset-left, 0px));
  border-radius: 18px; padding: 10px 14px 10px 10px;
  display: flex; align-items: center; gap: 10px; min-width: 150px;
}
.trump-badge {
  width: 50px; height: 50px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(165deg, #fffdf6, #eadfc4);
  box-shadow: 0 4px 0 #8d7a52, 0 8px 16px rgba(0, 0, 0, .35), inset 0 1px 0 #fff;
  color: var(--card-black);
}
.trump-badge.red { color: var(--card-red); }
.trump-badge.empty { background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px dashed rgba(255, 255, 255, .2); color: var(--dim); font-weight: 900; font-size: 22px; }
.trump-badge svg { width: 32px; height: 32px; fill: currentColor; }
.trump-badge.pop { animation: badgePop .7s var(--spring); }
@keyframes badgePop { 0% { transform: rotateY(180deg) scale(.4); } 100% { transform: none; } }
.trump-text { display: flex; flex-direction: column; gap: 2px; }
.trump-text small { font-size: 11px; color: var(--muted); font-weight: 700; }
.trump-text b { font-size: 16px; font-weight: 900; }
.trump-text .hk { font-size: 12px; color: var(--gold-hi); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.trump-text .hk svg { width: 14px; height: 14px; }

.hud-actions {
  left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(var(--ch) + 22px + var(--safe-b));
  display: flex; flex-direction: column; gap: 8px;
}
.hud-actions .icon-btn { background: rgba(8, 12, 24, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--ruby-2); color: #fff; font-size: 11px; font-style: normal; font-weight: 800;
  display: none; place-items: center; box-shadow: 0 0 0 2px var(--bg-0);
}
.badge.show { display: grid; }

.react-bar {
  position: absolute; z-index: 40;
  left: calc(66px + env(safe-area-inset-left, 0px)); bottom: calc(var(--ch) + 22px + 104px + var(--safe-b));
  display: flex; gap: 2px; padding: 6px; border-radius: 18px;
  opacity: 0; transform: translateX(-8px) scale(.9); pointer-events: none;
  transition: opacity .2s, transform .3s var(--spring);
}
.react-bar.show { opacity: 1; transform: none; pointer-events: auto; }
.react-bar button { width: 42px; height: 42px; border-radius: 12px; font-size: 24px; transition: transform .2s var(--spring), background .2s; }
.react-bar button:hover { background: rgba(255, 255, 255, .1); transform: scale(1.2); }

.last-trick {
  position: absolute; z-index: 40;
  left: calc(66px + env(safe-area-inset-left, 0px)); bottom: calc(var(--ch) + 22px + 150px + var(--safe-b));
  border-radius: 18px; padding: 12px 14px;
  opacity: 0; transform: translateX(-8px) scale(.95); pointer-events: none;
  transition: opacity .2s, transform .3s var(--spring);
}
.last-trick.show { opacity: 1; transform: none; pointer-events: auto; }
.last-trick h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.last-trick .lt-cards { display: flex; gap: 6px; }
.last-trick .lt { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.last-trick .lt .card { position: relative; --w: 46px; }
.last-trick .lt.win .face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 12px rgba(255, 214, 120, .6); }
.last-trick .lt.win span { color: var(--gold-hi); }

/* ---------- center message ---------- */
.center-msg {
  position: absolute; z-index: 30; left: 50%; top: 40%;
  transform: translate(-50%, -50%) scale(.85);
  padding: 14px 24px; border-radius: 18px;
  background: rgba(6, 10, 20, .78); border: 1px solid rgba(234, 184, 74, .35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5), 0 0 40px rgba(234, 184, 74, .12);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 18px; font-weight: 800; text-align: center; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .4s var(--spring);
  display: flex; align-items: center; gap: 10px;
}
.center-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.center-msg svg { width: 28px; height: 28px; color: var(--gold-hi); fill: currentColor; }
.center-msg .big-suit { width: 54px; height: 54px; animation: spinIn .9s var(--spring); }
.center-msg .big-suit.red { fill: #ff5d73; color: #ff5d73; }
.center-msg .big-suit.black { fill: #fff; color: #fff; }
@keyframes spinIn { from { transform: rotateY(360deg) scale(.3); } }
.center-msg .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.dots::after { content: '…'; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- trump picker ---------- */
.trump-picker {
  position: absolute; z-index: 35; left: 50%; top: 42%;
  transform: translate(-50%, -50%) scale(.9);
  width: min(92vw, 460px);
  border-radius: 24px; padding: 20px;
  text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .45s var(--spring);
  border-color: rgba(234, 184, 74, .35);
}
.trump-picker.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.trump-picker h3 { margin: 0; font-size: 20px; font-weight: 900; color: var(--gold-hi); }
.trump-picker p { margin: 4px 0 16px; font-size: 13px; color: var(--muted); }
.suits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.suit-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px 10px; border-radius: 16px;
  background: linear-gradient(170deg, #fffdf6, #eadfc4);
  color: var(--card-black);
  box-shadow: 0 5px 0 #8d7a52, 0 12px 20px rgba(0, 0, 0, .35), inset 0 1px 0 #fff;
  transition: transform .15s var(--ease), box-shadow .15s;
}
.suit-btn.red { color: var(--card-red); }
.suit-btn svg { width: 40px; height: 40px; fill: currentColor; transition: transform .3s var(--spring); }
.suit-btn:hover svg { transform: scale(1.15) rotate(-6deg); }
.suit-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #8d7a52, 0 4px 10px rgba(0, 0, 0, .3); }
.suit-btn b { font-size: 14px; font-weight: 900; }
.suit-btn small { font-size: 11px; font-weight: 700; color: #6b6150; }
.timebar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); margin-top: 16px; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--ruby), var(--gold)); transform-origin: left; border-radius: inherit; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: rgba(3, 6, 14, .55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .3s, visibility 0s linear .3s;
}
.overlay.show { opacity: 1; visibility: visible; transition: opacity .3s; }
.modal {
  position: relative; width: min(100%, 440px);
  border-radius: 26px; padding: 26px 22px 22px;
  text-align: center;
  transform: translateY(20px) scale(.94);
  transition: transform .45s var(--spring);
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.overlay.show .modal { transform: none; }
.modal h2 { margin: 0; font-size: 26px; font-weight: 900; }
.modal h3 { margin: 0 0 6px; font-size: 20px; font-weight: 900; }
.modal p { color: var(--muted); margin: 8px 0 0; font-size: 14px; line-height: 1.7; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.modal-close { position: absolute; top: 14px; left: 14px; }
.modal.small { width: min(100%, 360px); }

.result-kicker { font-size: 13px; font-weight: 800; letter-spacing: .02em; color: var(--muted); }
.result-title { margin: 6px 0 0; font-size: 26px; font-weight: 900; }
.result-title.win { color: var(--teal); }
.result-title.lose { color: var(--ruby); }
.kot-badge {
  display: inline-block; margin-top: 12px; padding: 6px 18px; border-radius: 999px;
  font-size: 22px; font-weight: 900; color: #2b1a02;
  background: linear-gradient(180deg, #ffe39a, #e0a93a);
  box-shadow: 0 4px 0 #8d5f13, 0 0 30px rgba(234, 184, 74, .5);
  animation: kotIn .8s var(--spring);
}
@keyframes kotIn { from { transform: scale(2.4) rotate(-12deg); opacity: 0; } }
.result-score { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 18px 0 4px; }
.result-score .side { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.result-score .side b { font-size: 40px; font-weight: 900; line-height: 1; }
.result-score .side.t0 b { color: var(--teal); }
.result-score .side.t1 b { color: var(--ruby); }
.result-score .side span { font-size: 12px; color: var(--muted); font-weight: 700; }
.result-score .dash { font-size: 24px; color: var(--dim); }
.result-pts { font-size: 15px; font-weight: 800; color: var(--gold-hi); margin-top: 10px; }
.result-next { font-size: 13px; color: var(--muted); margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.result-next svg { width: 16px; height: 16px; color: var(--gold-hi); }
.progress { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); margin-top: 18px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); transform-origin: right; animation: drain var(--dur, 5s) linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }

.over .trophy { width: 110px; height: 110px; margin: -8px auto 6px; filter: drop-shadow(0 12px 24px rgba(234, 184, 74, .45)); animation: trophy 1s var(--spring); }
.over.lost .trophy { filter: grayscale(1) brightness(.7); }
@keyframes trophy { from { transform: translateY(30px) scale(.4) rotate(-20deg); opacity: 0; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.stat { border-radius: 16px; overflow: hidden; border: 2px solid var(--c); background: rgba(0, 0, 0, .2); }
.stat .sh { background: var(--c); color: #111; font-size: 11px; font-weight: 900; padding: 4px 0; }
.stat .sv { padding: 10px 0; font-size: 20px; font-weight: 900; display: flex; justify-content: center; gap: 6px; align-items: baseline; }
.stat .sv .t0 { color: var(--teal); }
.stat .sv .t1 { color: var(--ruby); }
.stat .sv i { color: var(--dim); font-style: normal; font-size: 14px; }

.rules { width: min(100%, 560px); text-align: right; }
.rules h2 { text-align: center; color: var(--gold-hi); }
.rules ol { margin: 18px 0 0; padding-right: 20px; display: flex; flex-direction: column; gap: 10px; }
.rules li { font-size: 14px; line-height: 1.85; color: #d7dbe8; }
.rules li b { color: var(--text); }
.rules li::marker { color: var(--gold); font-weight: 900; }

/* ---------- chat ---------- */
.chat {
  position: fixed; z-index: 90;
  left: calc(12px + env(safe-area-inset-left, 0px)); bottom: calc(12px + var(--safe-b));
  width: min(calc(100vw - 24px), 340px); height: min(60vh, 440px);
  border-radius: 22px; display: flex; flex-direction: column;
  transform: translateY(20px) scale(.96); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .35s var(--spring);
}
.chat.show { transform: none; opacity: 1; pointer-events: auto; }
.chat header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.chat header .icon-btn { width: 36px; height: 36px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-log .msg { font-size: 13.5px; line-height: 1.6; padding: 7px 11px; border-radius: 14px; background: rgba(255, 255, 255, .06); max-width: 88%; align-self: flex-start; word-break: break-word; user-select: text; }
.chat-log .msg b { display: block; font-size: 11.5px; }
.chat-log .msg.team0 b { color: var(--teal); }
.chat-log .msg.team1 b { color: var(--ruby); }
.chat-log .msg.mine { align-self: flex-end; background: rgba(234, 184, 74, .14); }
.chat-log .empty-chat { margin: auto; color: var(--dim); font-size: 13px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; height: 42px; border-radius: 12px; padding: 0 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line-hi); outline: none; }
.chat-form input:focus { border-color: var(--gold); }
.chat-form .send { background: var(--gold); color: #2b1a02; border: 0; }

/* ---------- toasts / banner ---------- */
.toasts { position: fixed; z-index: 200; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  padding: 10px 18px; border-radius: 14px; font-size: 14px; font-weight: 700;
  background: rgba(20, 28, 54, .95); border: 1px solid var(--line-hi);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  animation: toastIn .4s var(--spring);
}
.toast.error { border-color: rgba(255, 116, 137, .5); color: #ffd0d8; }
.toast.ok { border-color: rgba(52, 214, 192, .5); color: #c4fff6; }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { transform: translateY(-16px) scale(.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
.conn-banner {
  position: fixed; z-index: 150; top: 0; left: 0; right: 0;
  padding: calc(8px + var(--safe-t)) 16px 8px; text-align: center;
  font-size: 13px; font-weight: 700;
  background: linear-gradient(90deg, var(--ruby-3), var(--ruby-2), var(--ruby-3));
  transform: translateY(-100%); transition: transform .3s var(--ease);
}
.conn-banner.show { transform: none; }
#confetti { position: fixed; inset: 0; z-index: 150; pointer-events: none; width: 100%; height: 100%; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
@keyframes popIn { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

/* ==========================================================
   Responsive
   ========================================================== */
/* portrait phones & tablets */
@media (max-aspect-ratio: 4/5) {
  :root {
    --cw: clamp(48px, 15.5vw, 92px);
    --tw: min(94vw, 600px);
    --th: calc(var(--tw) * 1.12);
    --tilt: 24deg;
    --table-y: 46%;
  }
  .gseat .avatar { width: 48px; height: 48px; font-size: 19px; }
  .gseat[data-pos="1"], .gseat[data-pos="3"] { top: 30%; gap: 4px; }
  .gseat[data-pos="2"] { top: calc(112px + var(--safe-t)); flex-direction: row; }
  .gseat[data-pos="2"] .opp-hand { top: calc(100% + 10px); }
  .gseat[data-pos="1"] .opp-hand, .gseat[data-pos="3"] .opp-hand { display: none; }
  .gseat:not([data-pos="0"]) .pmeta { display: none; }
  .gseat[data-pos="1"] .pinfo, .gseat[data-pos="3"] .pinfo { min-width: 0; max-width: 84px; padding: 2px 8px; }
  .hand { bottom: calc(16px + var(--safe-b)); }
  .opp-hand .card { --w: 22px; left: -11px; top: -31px; }
  .gseat[data-pos="1"] .opp-hand { left: -16px; top: 26px; }
  .gseat[data-pos="3"] .opp-hand { right: -16px; top: 26px; }
  .pinfo { min-width: 64px; padding: 3px 8px; }
  .pname { font-size: 12px; max-width: 84px; }
  .pmeta { font-size: 10px; }
  .hud-score { min-width: 0; padding: 8px 10px; gap: 6px; }
  .score-row .tpts { font-size: 18px; }
  .tricks i { width: 6px; height: 10px; }
  .hud-trump { min-width: 0; padding: 8px 10px 8px 8px; }
  .trump-badge { width: 42px; height: 42px; }
  .trump-badge svg { width: 26px; height: 26px; }
  .trump-text b { font-size: 14px; }
  .hud-actions { flex-direction: row; left: 50%; transform: translateX(-50%); bottom: calc(var(--ch) + 18px + var(--safe-b)); gap: 6px; }
  .hud-actions .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
  .hud-actions .icon-btn svg { width: 19px; height: 19px; }
  .gseat[data-pos="0"] { bottom: calc(var(--ch) + 64px + var(--safe-b)); }
  .react-bar { left: 50%; transform: translateX(-50%) scale(.9); bottom: calc(var(--ch) + 64px + var(--safe-b)); flex-wrap: wrap; justify-content: center; width: min(92vw, 360px); }
  .react-bar.show { transform: translateX(-50%); }
  .last-trick { left: 50%; transform: translateX(-50%) scale(.95); bottom: calc(var(--ch) + 64px + var(--safe-b)); }
  .last-trick.show { transform: translateX(-50%); }
  .center-msg { font-size: 16px; white-space: normal; width: max-content; max-width: 86vw; }
}

/* short landscape phones */
@media (max-height: 520px) and (min-aspect-ratio: 4/5) {
  :root { --tilt: 42deg; --table-y: 44%; --tw: min(70vw, 120vh); }
  .gseat .avatar { width: 42px; height: 42px; font-size: 17px; }
  .gseat[data-pos="2"] { flex-direction: row; top: calc(8px + var(--safe-t)); }
  .gseat[data-pos="2"] .opp-hand { display: none; }
  .gseat[data-pos="0"] { bottom: calc(var(--ch) * .55 + 10px); }
  .hand { bottom: calc(-.3 * var(--ch)); }
  .hud-actions { bottom: 10px; flex-direction: row; }
  .hud-actions .icon-btn { width: 36px; height: 36px; }
  .react-bar, .last-trick { bottom: 56px; left: 12px; }
  .hud-score, .hud-trump { padding: 6px 8px; }
  .trump-badge { width: 36px; height: 36px; }
  .trump-badge svg { width: 22px; height: 22px; }
  .modal { padding: 18px; }
  .over .trophy { width: 70px; height: 70px; }
}

/* wide screens: corners are free beside the hand */
@media (min-width: 1180px) and (min-aspect-ratio: 4/5) {
  .hud-actions { bottom: calc(18px + var(--safe-b)); }
  .gseat[data-pos="0"] { bottom: calc(18px + var(--safe-b)); }
  .react-bar { bottom: calc(18px + var(--safe-b)); }
  .last-trick { bottom: calc(18px + var(--safe-b)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- short landscape: menu side by side, lobby compact ---------- */
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .menu { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; column-gap: 24px; align-items: center; }
  .menu-top { grid-column: 1 / -1; width: 100%; }
  .hero-cards { --hw: clamp(40px, 13vh, 70px); }
  .logo { font-size: clamp(44px, 14vh, 72px); }
  .menu-btn { height: clamp(52px, 14vh, 66px); }
  .mb-text small { display: none; }
  .room { width: 100%; display: grid; grid-template-columns: 1fr minmax(220px, 34%); grid-template-rows: auto auto 1fr; column-gap: 16px; }
  .topbar { grid-column: 1 / -1; }
  .lobby-table { grid-column: 1; grid-row: 2 / 4; }
  .code-card { grid-column: 2; grid-row: 2; flex-direction: column; }
  .room-foot { grid-column: 2; grid-row: 3; justify-content: flex-end; }
  .lobby-felt { width: min(58%, 320px); height: min(40%, 180px); }
  .lseat { flex-direction: row; width: auto; max-width: 42%; padding: 6px 10px; gap: 6px; }
  .lseat .tags, .lseat.vacant .lname { display: none; }
  .lseat .avatar, .lseat .empty { width: 36px; height: 36px; font-size: 15px; }
  .lseat .lname { max-width: 70px; }
  .code-digits span { width: 34px; height: 42px; font-size: 22px; }
}
