/* ============================================================
   Chutes & Chums — design tokens
   A board-game table at night: deep felt green, cream tiles,
   coral snakes, brass ladders. Display face: Bungee (signage),
   body face: Outfit.
   ============================================================ */
:root {
  --felt: #123a2c;
  --felt-deep: #0c2b20;
  --tile: #f6ebd9;
  --tile-alt: #eddcc2;
  --ink: #221b14;
  --snake: #e2574c;
  --ladder: #e8a93b;
  --mint: #8fd0b8;
  --p1: #e2574c;
  --p2: #3f7fbf;
  --card: #fffdf8;
  --shadow: 0 10px 30px rgba(6, 22, 16, .45);
  --radius: 18px;
  --display: 'Noto Kufi Arabic', sans-serif;
  --body: 'Vazirmatn', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1b5240 0%, transparent 60%),
    var(--felt);
  color: var(--tile);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.75;
}

h1, h2, .brand, .turn-label, .record-num {
  font-weight: 700;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 2px dashed rgba(246, 235, 217, .18);
}

.brand {
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--tile);
  text-decoration: none;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand em { color: var(--ladder); font-style: normal; }
.brand-die {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  background: var(--tile);
  color: var(--ink);
  border-radius: 9px;
  font-size: 1.3rem;
  transform: rotate(-8deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,.35);
}

.topnav { display: flex; align-items: center; gap: 20px; }
.topnav a { color: var(--tile); text-decoration: none; font-weight: 600; }
.topnav a:hover { color: var(--ladder); }
.inline-form { display: inline; }
.link-btn {
  background: none; border: none; padding: 0;
  color: var(--tile); font: inherit; font-weight: 600; cursor: pointer;
}
.link-btn:hover { color: var(--ladder); }

.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  background: var(--ladder);
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 #b9821f;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b9821f; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }

.btn-big { font-size: 1.1rem; padding: 15px 34px; }
.btn-small { font-size: .9rem; padding: 8px 18px; }
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--tile);
  box-shadow: inset 0 0 0 2px rgba(246,235,217,.4);
}
.btn-ghost:active { box-shadow: inset 0 0 0 2px rgba(246,235,217,.4); }

.hidden { display: none !important; }

/* ---------- Type ---------- */
h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  line-height: 1.08;
  margin: 8px 0 16px;
  letter-spacing: .5px;
}
h2 { font-family: var(--display); font-weight: 400; font-size: 1.1rem; letter-spacing: .5px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
  font-weight: 700;
  color: var(--mint);
  margin: 0;
}
.lede { font-size: 1.15rem; max-width: 46ch; color: rgba(246,235,217,.85); }
.squiggle {
  color: var(--snake);
  text-decoration: underline wavy var(--snake) 3px;
  text-underline-offset: 7px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: center;
  padding: 48px 0 32px;
}
.hero-actions { display: flex; gap: 14px; margin-top: 26px; flex-wrap: wrap; }

.hero-board { display: grid; place-items: center; }
.mini-board {
  position: relative;
  width: min(340px, 100%);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  border: 10px solid var(--tile);
  border-radius: 14px;
  transform: rotate(3deg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mini-cell.a { background: var(--tile); }
.mini-cell.b { background: var(--tile-alt); }
.mini-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.mini-snake { fill: none; stroke: var(--snake); stroke-width: 4; stroke-linecap: round; }
.mini-ladder { stroke: var(--ladder); stroke-width: 3.5; stroke-linecap: round; }
.mini-token {
  position: absolute; width: 12%; aspect-ratio: 1; border-radius: 50%;
  border: 3px solid #fff;
}
.mini-token.p1 { background: var(--p1); left: 12%; bottom: 8%; animation: bob 3s ease-in-out infinite; }
.mini-token.p2 { background: var(--p2); left: 62%; top: 34%; animation: bob 3.6s ease-in-out infinite reverse; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 40px;
}
.feature {
  background: rgba(255,253,248,.06);
  border: 1px solid rgba(246,235,217,.15);
  border-radius: var(--radius);
  padding: 22px 24px;
}
.feature h3 { margin: 0 0 6px; color: var(--ladder); font-size: 1.05rem; }
.feature p { margin: 0; color: rgba(246,235,217,.8); }

/* ---------- Auth cards ---------- */
.auth-card {
  max-width: 440px;
  margin: 40px auto;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.7rem; color: var(--ink); }
.auth-sub { margin-top: -6px; color: #6b5f50; }
.auth-card label { display: block; font-weight: 600; margin: 16px 0 6px; }
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 11px 14px;
  border: 2px solid #d8cbb6;
  border-radius: 10px;
  background: #fff;
}
.auth-card input:focus-visible { outline: 3px solid var(--mint); border-color: var(--felt); }
.auth-card .btn { margin-top: 24px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 500 !important; }
.auth-switch { margin-top: 18px; color: #6b5f50; }
.auth-switch a { color: var(--felt); font-weight: 700; }
.form-errors, .field-error { color: var(--snake); font-size: .9rem; }
.form-errors ul { margin: 0 0 8px; padding-left: 18px; }

/* ---------- Lobby ---------- */
.lobby { display: grid; grid-template-columns: 1.5fr 1fr; gap: 36px; padding-top: 24px; }
.queue-panel { margin-top: 26px; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.die-icon { font-size: 1.3rem; }

.search-state { display: flex; align-items: center; gap: 14px; }
.pulse-die {
  font-size: 2rem;
  animation: spin-die 1.1s linear infinite;
  display: inline-block;
}
@keyframes spin-die { to { transform: rotate(360deg); } }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.match-found { color: var(--mint); font-size: 1.1rem; }
.queue-size { color: rgba(246,235,217,.6); font-size: .9rem; }

.stat-card {
  background: rgba(255,253,248,.06);
  border: 1px solid rgba(246,235,217,.15);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.stat-card h2 { margin-top: 0; color: var(--ladder); }
.record { display: flex; gap: 36px; }
.record-num { font-family: var(--display); font-size: 2rem; display: block; }
.record-label { color: rgba(246,235,217,.6); }
.match-list { list-style: none; margin: 0; padding: 0; }
.match-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px dashed rgba(246,235,217,.15);
  font-size: .92rem;
}
.match-list li.won .match-result { color: var(--mint); }
.match-list li.lost .match-result { color: var(--snake); }
.empty-hint { color: rgba(246,235,217,.55); }

/* ---------- Game layout ---------- */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr);
  gap: 28px;
  align-items: start;
}

.board-frame {
  position: relative;
  border: 14px solid var(--tile);
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--tile);
}
.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  aspect-ratio: 1;
}
.cell {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 4px 6px;
  font-size: clamp(.55rem, 1.1vw, .8rem);
  font-weight: 700;
  color: rgba(34,27,20,.55);
  user-select: none;
}
.cell.a { background: var(--tile); }
.cell.b { background: var(--tile-alt); }
.cell.snake-head { box-shadow: inset 0 0 0 3px var(--snake); }
.cell.ladder-foot { box-shadow: inset 0 0 0 3px var(--ladder); }
.cell.goal { background: var(--mint); color: var(--felt-deep); }

.board-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.svg-snake { fill: none; stroke: var(--snake); stroke-width: 14; stroke-linecap: round; opacity: .85; }
.svg-snake-head { fill: var(--snake); }
.svg-ladder { stroke: var(--ladder); stroke-width: 8; stroke-linecap: round; opacity: .9; }
.svg-rung { stroke: var(--ladder); stroke-width: 6; stroke-linecap: round; opacity: .9; }

.token {
  position: absolute;
  width: 5.5%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
  transition: left .5s cubic-bezier(.34,1.4,.64,1), top .5s cubic-bezier(.34,1.4,.64,1);
  z-index: 5;
}
.token-p1 { background: var(--p1); }
.token-p2 { background: var(--p2); }

/* ---------- Table edge: turn strip, dice, log ---------- */
.table-edge { margin-top: 18px; }
.turn-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.player-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,253,248,.08);
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 600;
}
.player-chip.active { box-shadow: 0 0 0 2px var(--mint); }
.chip-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; }
.chip-dot.p1 { background: var(--p1); }
.chip-dot.p2 { background: var(--p2); }
.chip-pos { color: rgba(246,235,217,.6); font-size: .85rem; }
.turn-label { font-family: var(--display); font-size: .95rem; color: var(--mint); text-align: center; }

.dice-tray { display: flex; align-items: center; gap: 26px; margin: 22px 0 10px; }

/* 3D die */
.die-scene { width: 64px; height: 64px; perspective: 320px; }
.die {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-18deg) rotateY(24deg);
  transition: transform .9s cubic-bezier(.3,1.2,.4,1);
}
.die.rolling { animation: tumble .7s linear infinite; }
@keyframes tumble {
  from { transform: rotateX(0) rotateY(0) rotateZ(0); }
  to { transform: rotateX(360deg) rotateY(720deg) rotateZ(180deg); }
}
.face {
  position: absolute; inset: 0;
  background: var(--tile);
  border-radius: 12px;
  border: 2px solid #d8cbb6;
  display: grid;
  padding: 9px;
  gap: 3px;
}
.pip { width: 11px; height: 11px; background: var(--ink); border-radius: 50%; align-self: center; justify-self: center; }
.f1 { transform: translateZ(32px); grid-template: 1fr / 1fr; }
.f2 { transform: rotateY(90deg) translateZ(32px); grid-template: 1fr 1fr / 1fr 1fr; }
.f2 .pip:nth-child(1) { grid-area: 1/1; } .f2 .pip:nth-child(2) { grid-area: 2/2; }
.f3 { transform: rotateY(180deg) translateZ(32px); grid-template: repeat(3,1fr) / repeat(3,1fr); }
.f3 .pip:nth-child(1) { grid-area: 1/1; } .f3 .pip:nth-child(2) { grid-area: 2/2; } .f3 .pip:nth-child(3) { grid-area: 3/3; }
.f4 { transform: rotateY(-90deg) translateZ(32px); grid-template: 1fr 1fr / 1fr 1fr; }
.f5 { transform: rotateX(90deg) translateZ(32px); grid-template: repeat(3,1fr) / repeat(3,1fr); }
.f5 .pip:nth-child(1) { grid-area: 1/1; } .f5 .pip:nth-child(2) { grid-area: 1/3; }
.f5 .pip:nth-child(3) { grid-area: 2/2; }
.f5 .pip:nth-child(4) { grid-area: 3/1; } .f5 .pip:nth-child(5) { grid-area: 3/3; }
.f6 { transform: rotateX(-90deg) translateZ(32px); grid-template: repeat(3,1fr) / 1fr 1fr; }

.game-log {
  list-style: none; margin: 12px 0 0; padding: 12px 16px;
  background: rgba(6,22,16,.4);
  border-radius: 12px;
  max-height: 140px;
  overflow-y: auto;
  font-size: .9rem;
  display: flex; flex-direction: column-reverse; gap: 4px;
}
.game-log .snake-msg { color: var(--snake); }
.game-log .ladder-msg { color: var(--ladder); }
.game-log .win-msg { color: var(--mint); font-weight: 700; }

/* ---------- Call rail ---------- */
.call-rail { display: flex; flex-direction: column; gap: 14px; }
.video-card {
  position: relative;
  background: var(--felt-deep);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 2px solid rgba(246,235,217,.15);
}
.video-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-card-self { aspect-ratio: 16 / 9; }
.video-tag {
  position: absolute; left: 10px; bottom: 8px;
  background: rgba(6,22,16,.7);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.video-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(246,235,217,.45);
  font-size: .9rem;
}
.call-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.call-controls .btn { font-size: .88rem; padding: 9px 16px; }

.chat {
  background: rgba(255,253,248,.06);
  border: 1px solid rgba(246,235,217,.15);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 200px;
}
.chat-list {
  list-style: none; margin: 0; padding: 12px 14px;
  flex: 1; overflow-y: auto; font-size: .9rem;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px;
}
.chat-list .me strong { color: var(--mint); }
.chat-list .them strong { color: var(--ladder); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px dashed rgba(246,235,217,.15); }
.chat-form input {
  flex: 1; font: inherit; padding: 9px 12px;
  border-radius: 999px; border: none;
  background: rgba(6,22,16,.5); color: var(--tile);
}
.chat-form input:focus-visible { outline: 2px solid var(--mint); }

/* ---------- Win overlay ---------- */
.win-overlay {
  position: fixed; inset: 0;
  background: rgba(6,22,16,.8);
  display: grid; place-items: center;
  z-index: 50;
}
.win-card {
  background: var(--card); color: var(--ink);
  border-radius: var(--radius);
  padding: 42px 48px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: pop-in .35s cubic-bezier(.3,1.6,.5,1);
}
.win-card h2 { font-size: 1.8rem; margin: 0 0 6px; color: var(--ink); }
.win-card .btn { margin-top: 18px; }
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } }

/* ---------- Responsive & a11y ---------- */
@media (max-width: 960px) {
  .hero, .lobby, .game-layout { grid-template-columns: 1fr; }
  .feature-row { grid-template-columns: 1fr; }
  .hero-board { order: -1; }
}

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

/* ============================================================
   زیادکراوەکان: RTL، هەڵبژاردنی یاری، کارتەکان، دۆمینۆ، مۆبایل
   ============================================================ */

/* ---------- RTL: things that must stay physically LTR ---------- */
.board-frame, .board, .die-scene, .chain-strip, .mini-board { direction: ltr; }
.squiggle { text-underline-offset: 9px; }

/* ---------- Game picker (lobby) ---------- */
.game-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin: 26px 0 8px;
}
.game-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: start;
  font-family: var(--body);
  color: var(--tile);
  background: rgba(255,253,248,.06);
  border: 2px solid rgba(246,235,217,.18);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.game-option:hover { transform: translateY(-2px); }
.game-option:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.game-option.selected {
  border-color: var(--ladder);
  background: rgba(232,169,59,.12);
  box-shadow: 0 0 0 1px var(--ladder);
}
.game-emoji { font-size: 1.9rem; }
.game-name { font-family: var(--display); font-weight: 700; font-size: 1.02rem; }
.game-desc { font-size: .86rem; color: rgba(246,235,217,.75); line-height: 1.6; }
.game-waiting { font-size: .8rem; color: var(--mint); margin-top: 4px; }

/* ---------- Cards table (هەشتە شێتەکان) ---------- */
.cards-table, .domino-table { min-width: 0; }

.opp-hand {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 12px 0;
  min-height: 48px;
}
.card-back {
  width: 46px; height: 66px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, #a33d34 0 6px, #8e332b 6px 12px);
  border: 2px solid var(--tile);
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.card-back.mini { width: 32px; height: 46px; margin-inline-start: -14px; }
.card-back.mini:first-child { margin-inline-start: 0; }

.center-table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: 22px;
  background: rgba(6,22,16,.35);
  border-radius: var(--radius);
  border: 2px dashed rgba(246,235,217,.15);
  flex-wrap: wrap;
}
.pile-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pile-label { font-size: .8rem; color: rgba(246,235,217,.6); }
.stock-pile {
  position: relative;
  background: none; border: none; padding: 0; cursor: pointer;
}
.stock-pile:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; border-radius: 10px; }
.pile-count {
  position: absolute; inset-inline-end: -8px; top: -8px;
  background: var(--ladder); color: var(--ink);
  border-radius: 999px;
  min-width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700;
}
.suit-indicator { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.suit-badge {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  background: var(--tile);
  color: var(--ink);
  border-radius: 50%;
  font-size: 1.7rem;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.suit-badge.red { color: var(--snake); }

.play-card {
  position: relative;
  width: 72px; height: 104px;
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  border: 1px solid #cfc4b0;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
  flex-shrink: 0;
  direction: ltr;
  user-select: none;
}
.play-card.red { color: var(--snake); }
.pc-corner {
  position: absolute; top: 5px; left: 7px;
  font-size: .78rem; font-weight: 700; line-height: 1.05;
  text-align: center;
}
.pc-corner.flip { top: auto; left: auto; bottom: 5px; right: 7px; transform: rotate(180deg); }
.pc-center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 2.1rem;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.hand {
  display: flex;
  gap: 8px;
  padding: 14px;
  background: rgba(6,22,16,.35);
  border-radius: var(--radius);
  overflow-x: auto;
  min-height: 132px;
  -webkit-overflow-scrolling: touch;
}
.hand .play-card { cursor: default; opacity: .75; }
.hand .play-card.playable {
  cursor: pointer;
  opacity: 1;
  box-shadow: 0 0 0 3px var(--mint), 0 5px 12px rgba(0,0,0,.35);
  transition: transform .12s ease;
}
.hand .play-card.playable:hover,
.hand .play-card.playable:focus-visible { transform: translateY(-10px); outline: none; }

.suit-choices, .side-choices {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.suit-choice {
  width: 64px; height: 64px;
  font-size: 2rem;
  background: #fff;
  border: 2px solid #cfc4b0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .1s ease;
}
.suit-choice:hover { transform: scale(1.12); }
.suit-choice:focus-visible { outline: 3px solid var(--mint); }
.suit-choice.red { color: var(--snake); }
.suit-choice.black { color: var(--ink); }

.error-msg { color: var(--snake); }
.wild-msg { color: var(--ladder); }

/* ---------- Domino table ---------- */
.chain-wrap {
  position: relative;
  background: rgba(6,22,16,.35);
  border: 2px dashed rgba(246,235,217,.15);
  border-radius: var(--radius);
  margin: 14px 0;
  min-height: 110px;
  display: flex;
  align-items: center;
}
.chain-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 18px;
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
.chain-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: rgba(246,235,217,.5);
  margin: 0;
  pointer-events: none;
}

.dm-tile {
  display: flex;
  background: var(--card);
  border-radius: 8px;
  border: 2px solid #cfc4b0;
  box-shadow: 0 3px 6px rgba(0,0,0,.3);
  flex-shrink: 0;
  direction: ltr;
  user-select: none;
}
.dm-tile.vertical { flex-direction: column; }
.dm-half {
  width: 44px; height: 44px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 6px;
  gap: 1px;
}
.dm-tile:not(.vertical) .dm-half:first-child { border-inline-end: 2px solid #cfc4b0; }
.dm-tile.vertical .dm-half:first-child { border-bottom: 2px solid #cfc4b0; }
.dm-half i { border-radius: 50%; }
.dm-half i.on { background: var(--ink); width: 9px; height: 9px; align-self: center; justify-self: center; }

.domino-hand { min-height: 90px; }
.domino-hand .dm-tile { cursor: default; opacity: .7; }
.domino-hand .dm-tile.playable {
  cursor: pointer;
  opacity: 1;
  box-shadow: 0 0 0 3px var(--mint), 0 5px 12px rgba(0,0,0,.35);
  transition: transform .12s ease;
}
.domino-hand .dm-tile.playable:hover,
.domino-hand .dm-tile.playable:focus-visible { transform: translateY(-8px); outline: none; }

/* ============================================================
   مۆبایل: هەموو یارییەکان لەسەر مۆبایلیش دەکرێن
   ============================================================ */
@media (max-width: 960px) {
  .page { padding: 20px 14px 60px; }
  .topbar { padding: 12px 16px; }
  .topnav { gap: 12px; font-size: .92rem; }

  .game-picker { grid-template-columns: 1fr; }
  .queue-panel { align-items: stretch; }
  .queue-panel .btn-big { width: 100%; }

  /* یاری: تەختە لە سەرەوە، ڤیدیۆ وەک ستوونێکی بچووکی ئاسۆیی */
  .game-layout { gap: 18px; }
  .call-rail {
    flex-direction: row;
    flex-wrap: wrap;
    order: -1;              /* ڤیدیۆکان لە سەرەوە وەک مێزی ڕاستەقینە */
  }
  .call-rail .video-card { flex: 1 1 46%; aspect-ratio: 16/10; }
  .call-rail .video-card-self { aspect-ratio: 16/10; }
  .call-controls { flex-basis: 100%; justify-content: center; }
  .chat { flex-basis: 100%; min-height: 150px; }
  .chat-list { max-height: 120px; }

  .turn-strip { justify-content: center; }
  .dice-tray { justify-content: center; }
  .die-scene { width: 54px; height: 54px; }
  .f1,.f2,.f3,.f4,.f5,.f6 { transform-origin: center; }

  .center-table { gap: 20px; padding: 16px; }
  .play-card { width: 62px; height: 90px; }
  .pc-center { font-size: 1.7rem; }
  .dm-half { width: 38px; height: 38px; }
  .hand { min-height: 116px; }

  .win-card { margin: 0 16px; padding: 30px 24px; }
}

@media (max-width: 480px) {
  html, body { font-size: 15px; }
  .brand { font-size: 1.05rem; }
  .hero { padding-top: 24px; }
  .btn-big { padding: 13px 24px; font-size: 1rem; }
  .call-rail .video-card { flex-basis: 100%; }
  .call-rail .video-card-self {
    position: fixed;
    inset-inline-end: 12px;
    bottom: 12px;
    width: 110px;
    aspect-ratio: 3/4;
    z-index: 40;
    flex: none;
    box-shadow: 0 6px 18px rgba(0,0,0,.5);
  }
  .play-card { width: 56px; height: 82px; }
  .dm-half { width: 34px; height: 34px; }
  .suit-choice { width: 56px; height: 56px; }
  .auth-card { padding: 26px 20px; margin: 20px auto; }
}

/* Touch targets */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .hand .play-card.playable:hover { transform: none; }
  .hand .play-card.playable:active { transform: translateY(-8px); }
}

/* ============================================================
   یارییە نوێکان: دامە، شەترەنج، خاڵ و چوارگۆشە، تەختەنەرد
   ============================================================ */

/* ---------- Shared grid boards (dama + chess) ---------- */
.grid-board-frame {
  border: 12px solid var(--tile);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: var(--tile);
  direction: ltr;
}
.grid-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
}
.gb-cell {
  position: relative;
  border: none;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 5.5vw, 2.6rem);
  line-height: 1;
  transition: box-shadow .1s ease;
}
.gb-cell.light { background: var(--tile); }
.gb-cell.dark { background: #b99a6b; }
.gb-cell:focus-visible { outline: 3px solid var(--mint); outline-offset: -3px; z-index: 2; }
.gb-cell.sel { box-shadow: inset 0 0 0 4px var(--mint); }
.gb-cell.target::after {
  content: '';
  width: 26%; aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(143,208,184,.75);
}
.gb-cell.cap-target { box-shadow: inset 0 0 0 4px var(--snake); }
.gb-cell.must { box-shadow: inset 0 0 0 3px rgba(232,169,59,.8); }
.gb-cell.last-move { box-shadow: inset 0 0 0 4px rgba(232,169,59,.55); }
.gb-cell.check { box-shadow: inset 0 0 0 5px var(--snake); }

/* ---------- Dama pieces ---------- */
.dama-piece {
  width: 68%; aspect-ratio: 1;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .9em;
  box-shadow: 0 3px 6px rgba(0,0,0,.4), inset 0 -4px 0 rgba(0,0,0,.2);
}
.dama-piece.w { background: #f3ede1; border: 3px solid #c9bda4; }
.dama-piece.b { background: #3a3f8f; border: 3px solid #23265c; }
.dama-piece.king { font-size: .55em; }

/* ---------- Chess pieces ---------- */
.chess-board .gb-cell { user-select: none; }
.gb-cell.white-piece { color: #fdfaf2; text-shadow: 0 2px 3px rgba(0,0,0,.55), 0 0 2px rgba(0,0,0,.6); }
.gb-cell.black-piece { color: #17141f; text-shadow: 0 1px 2px rgba(255,255,255,.25); }
.chip-dot.white-dot { background: #fdfaf2; }
.chip-dot.black-dot { background: #17141f; }

/* ---------- Dots & Boxes ---------- */
.dots-frame { padding: 16px; }
.dots-board {
  --n: 5;
  display: grid;
  direction: ltr;
  grid-template-columns: repeat(var(--n), 14px 1fr) 14px;
  grid-template-rows: repeat(var(--n), 14px 1fr) 14px;
  aspect-ratio: 1;
  gap: 0;
}
.dt-dot {
  width: 14px; height: 14px;
  background: var(--ink);
  border-radius: 50%;
  align-self: center; justify-self: center;
  z-index: 2;
}
.dt-edge {
  border: none;
  padding: 0;
  background: rgba(34,27,20,.12);
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s ease;
  margin: 3px;
}
.dt-edge:hover:not(:disabled):not(.taken) { background: rgba(143,208,184,.8); }
.dt-edge:focus-visible { outline: 3px solid var(--mint); }
.dt-edge.taken { background: var(--ink); cursor: default; }
.dt-edge:disabled:not(.taken) { cursor: default; }
.dt-box {
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 1.2rem;
  margin: 4px;
  transition: background .2s ease;
}
.dt-box.own1 { background: rgba(226,87,76,.85); color: #fff; }
.dt-box.own2 { background: rgba(63,127,191,.85); color: #fff; }

/* ---------- Backgammon ---------- */
.bg-board {
  display: flex;
  gap: 10px;
  direction: ltr;
  background: var(--tile);
  border-radius: 14px;
  border: 12px solid var(--tile);
  box-shadow: var(--shadow);
  padding: 4px;
}
.bg-quadrants { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bg-row { display: flex; gap: 2px; min-height: 150px; }
.bg-gap { width: 14px; background: #b99a6b; border-radius: 4px; margin: 0 3px; }
.bg-point {
  flex: 1;
  position: relative;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.bg-point.bottom { flex-direction: column-reverse; }
.bg-point::before {
  content: '';
  position: absolute; inset: 0;
}
.bg-point.top::before { clip-path: polygon(0 0, 100% 0, 50% 88%); }
.bg-point.bottom::before { clip-path: polygon(0 100%, 100% 100%, 50% 12%); }
.bg-point.odd::before { background: #b06a4f; }
.bg-point.even::before { background: #6f4f35; }
.bg-point.can-move::before { filter: brightness(1.25); }
.bg-point.sel::before { outline: 3px solid var(--mint); outline-offset: -3px; }
.bg-point.target::before { outline: 3px dashed var(--mint); outline-offset: -3px; }
.bg-point.hit-target::before { outline: 3px dashed var(--snake); outline-offset: -3px; }
.bg-point:focus-visible { outline: 3px solid var(--mint); }
.bg-num {
  position: relative; z-index: 1;
  font-size: .62rem; font-weight: 700;
  color: rgba(246,235,217,.9);
  padding: 1px 0;
}
.bg-stack {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 0;
}
.bg-point.bottom .bg-stack { flex-direction: column-reverse; }
.bg-checker {
  width: clamp(16px, 3.4vw, 30px);
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,.4), inset 0 -3px 0 rgba(0,0,0,.2);
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 700;
}
.bg-checker.p1 { background: #f3ede1; border: 2px solid #c9bda4; color: var(--ink); }
.bg-checker.p2 { background: #3a3f8f; border: 2px solid #23265c; color: #fff; }
.bg-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  margin: 4px 0;
  background: #b99a6b;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-wrap: wrap;
  padding: 4px;
}
.bg-bar .bg-checker { width: 22px; }
.bg-bar.can-move { box-shadow: 0 0 0 3px var(--ladder); }
.bg-bar.sel { box-shadow: 0 0 0 3px var(--mint); }
.bg-off {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  background: rgba(34,27,20,.12);
  border-radius: 10px;
  cursor: pointer;
  min-width: 52px;
}
.bg-off.target { box-shadow: 0 0 0 3px var(--mint); }
.bg-off-stack { display: flex; flex-direction: column; gap: 2px; }
.bg-off-stack .bg-checker { width: 26px; height: 10px; border-radius: 4px; aspect-ratio: auto; }
.bg-dice { display: flex; gap: 8px; font-size: 2.6rem; color: var(--tile); direction: ltr; }
.bg-die { line-height: 1; }

/* ---------- New games on mobile ---------- */
@media (max-width: 960px) {
  .bg-row { min-height: 110px; }
  .bg-off { min-width: 42px; }
  .gb-cell { font-size: clamp(1.2rem, 8vw, 2rem); }
  .dots-board {
    grid-template-columns: repeat(var(--n), 10px 1fr) 10px;
    grid-template-rows: repeat(var(--n), 10px 1fr) 10px;
  }
  .dt-dot { width: 10px; height: 10px; }
  .dt-edge { margin: 2px; }
}
@media (max-width: 480px) {
  .bg-row { min-height: 88px; }
  .bg-num { font-size: .5rem; }
  .bg-dice { font-size: 2rem; }
}
