/* Oýun Klub — карточный стол на туркменском ковре.
   Палитра: тёмная марена (фон), марена (действие), слоновая кость (текст),
   индиго (соперник), шафран (фишки), орех (доска нардов). */

@font-face {
  font-family: 'Manrope';
  src: url('../vendor/fonts/manrope/manrope-cyrillic-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  src: url('../vendor/fonts/manrope/manrope-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Manrope';
  src: url('../vendor/fonts/manrope/manrope-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Unbounded';
  src: url('../vendor/fonts/unbounded/unbounded-cyrillic-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Unbounded';
  src: url('../vendor/fonts/unbounded/unbounded-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 900; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Unbounded';
  src: url('../vendor/fonts/unbounded/unbounded-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ground: #2b1215;
  --ground-2: #3a1a1e;
  --ground-3: #4a2327;
  --madder: #b23a36;
  --madder-deep: #7a1f26;
  --ivory: #f2e6d0;
  --ivory-dim: #c9b9a0;
  --paper: #fbf5e8;
  --ink: #1e1c2a;
  --indigo: #26324f;
  --indigo-2: #34426a;
  --saffron: #e0a43a;
  --leaf: #6f9a5a;
  --wood: #5c3a21;
  --wood-2: #7a5232;

  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --r-s: 8px;
  --r-m: 14px;
  --r-l: 22px;
  --gut: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --cw: 52px;

  /* узор гёль — ромб внутри восьмиугольника */
  --gol: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpolygon points='15,2 33,2 46,15 46,33 33,46 15,46 2,33 2,15' fill='none' stroke='%23f2e6d0' stroke-opacity='.10' stroke-width='2'/%3E%3Cpolygon points='24,10 38,24 24,38 10,24' fill='%23f2e6d0' fill-opacity='.07'/%3E%3Crect x='21' y='21' width='6' height='6' fill='%23e0a43a' fill-opacity='.18'/%3E%3C/svg%3E");
  --band: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 56'%3E%3Crect width='56' height='56' fill='%237a1f26'/%3E%3Cpolygon points='17,3 39,3 53,17 53,39 39,53 17,53 3,39 3,17' fill='%23b23a36'/%3E%3Cpolygon points='20,9 36,9 47,20 47,36 36,47 20,47 9,36 9,20' fill='%2326324f'/%3E%3Cpolygon points='28,12 44,28 28,44 12,28' fill='%23f2e6d0'/%3E%3Cpolygon points='28,19 37,28 28,37 19,28' fill='%23b23a36'/%3E%3Crect x='25' y='25' width='6' height='6' fill='%23e0a43a'/%3E%3Cpath d='M0 0h4v4H0zM52 0h4v4h-4zM0 52h4v4H0zM52 52h4v4h-4z' fill='%23e0a43a'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ivory);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
input { font: inherit; }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

#app { min-height: 100%; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--ivory-dim); }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---------- кнопки ---------- */
.btn {
  border: 0; border-radius: var(--r-m);
  padding: 14px 18px; min-height: 50px;
  font-weight: 700; font-size: 16px;
  background: var(--ground-3); color: var(--ivory);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--madder); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.btn.gold { background: var(--saffron); color: #2b1a05; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.btn.indigo { background: var(--indigo-2); }
.btn.ghost { background: transparent; border: 1.5px solid rgba(242,230,208,.25); }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: rgba(242,230,208,.08); display: grid; place-items: center; font-size: 18px; cursor: pointer;
}

/* ---------- шапка лобби ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px var(--gut) 12px;
}
.top .who { flex: 1; min-width: 0; }
.top .who b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(224,164,58,.12); border: 1.5px solid rgba(224,164,58,.35);
  border-radius: 999px; padding: 6px 12px 6px 6px;
  color: var(--saffron); font-family: var(--display); font-weight: 600; font-size: 15px;
}
.coin {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f7cf7a, var(--saffron) 55%, #a8731f);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
  flex: none;
}
.ava {
  border-radius: 50%; background: var(--indigo-2); color: var(--ivory);
  display: grid; place-items: center; overflow: hidden; flex: none;
  font-weight: 800; font-size: 14px;
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava-m { width: 40px; height: 40px; }
.ava-s { width: 30px; height: 30px; font-size: 11px; }
.ava-l { width: 64px; height: 64px; font-size: 22px; }

/* ---------- ковровая полоса: главный акцент ---------- */
.band {
  margin: 4px 0 18px;
  height: 64px;
  background: var(--band) repeat-x center / 64px 64px;
  border-top: 3px solid var(--saffron);
  border-bottom: 3px solid var(--saffron);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.band::before, .band::after {
  content: ''; position: absolute; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--ivory) 0 6px, transparent 6px 12px);
  opacity: .5;
}
.band::before { top: 3px; }
.band::after { bottom: 3px; }
.band .btn { position: relative; z-index: 1; box-shadow: 0 6px 18px rgba(0,0,0,.45); }

/* ---------- плитки игр ---------- */
.games { padding: 0 var(--gut); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; overflow: hidden;
  border-radius: var(--r-l); border: 0; text-align: left;
  padding: 16px; min-height: 128px;
  background: var(--ground-2);
  cursor: pointer; display: flex; flex-direction: column; justify-content: flex-end;
}
.tile:active { transform: scale(.98); }
.tile h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: -.01em; }
.tile p { margin: 2px 0 0; font-size: 13px; color: var(--ivory-dim); }
.tile .glyph {
  position: absolute; right: -6px; top: -14px;
  font-size: 92px; line-height: 1; opacity: .9;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', sans-serif;
}
.tile.feature {
  grid-column: 1 / -1; min-height: 168px;
  background: var(--madder-deep) var(--gol) repeat center / 48px;
}
.tile.feature h3 { font-size: 28px; }
.tile.feature .fan { position: absolute; right: 18px; top: 18px; height: 96px; width: 150px; }
.fan .card { position: absolute; bottom: 0; --cw: 56px; transform-origin: 50% 120%; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.tile.t-nardy { background: var(--wood); }
.tile.t-nardy .glyph { color: var(--paper); font-size: 80px; top: -6px; }
.tile.t-checkers { background: var(--indigo); }
.tile.t-chess { background: var(--ground-3); }
.tile.t-chess .glyph, .tile.t-checkers .glyph { color: var(--ivory); }
.tile.t-poker { background: #1d3a30; }
.tile.t-poker .glyph { color: var(--ivory); opacity: .85; }
.tile.t-seka { grid-column: 1 / -1; min-height: 110px; background: var(--indigo); }
.tile.t-seka .fan { position: absolute; right: 18px; top: 12px; height: 80px; width: 120px; }
.checker-glyph {
  position: absolute; right: 14px; top: 14px; width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #f7efe0 0 38%, #d9cbb0 39% 44%, #f7efe0 45%);
  box-shadow: 18px 22px 0 -2px var(--madder), 18px 22px 0 0 #6d1a1c;
}

.join-code {
  margin: 18px var(--gut) 0; display: flex; gap: 8px;
}
.join-code input {
  flex: 1; min-width: 0; height: 50px; border-radius: var(--r-m);
  border: 1.5px solid rgba(242,230,208,.18); background: transparent; color: var(--ivory);
  padding: 0 14px; font-family: var(--display); font-size: 16px; text-transform: uppercase; letter-spacing: .12em;
}
.join-code input::placeholder { text-transform: none; letter-spacing: 0; font-family: var(--body); color: var(--ivory-dim); }

/* ---------- нижняя навигация ---------- */
.screen { flex: 1; padding-bottom: calc(84px + var(--safe-b)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(43,18,21,.94); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(242,230,208,.08);
}
.nav button {
  flex: 1; background: none; border: 0; padding: 8px 0; border-radius: 12px;
  font-size: 12px; font-weight: 700; color: var(--ivory-dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav button span { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--ivory); background: rgba(242,230,208,.07); }

/* ---------- листы, тосты ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,6,8,.6);
  display: flex; align-items: flex-end; animation: fade .18s ease;
}
.sheet-wrap.out { opacity: 0; transition: opacity .18s; }
.sheet {
  width: 100%; max-height: 88vh; overflow: auto;
  background: var(--ground-2); border-radius: 24px 24px 0 0;
  padding: 10px var(--gut) calc(20px + var(--safe-b));
  animation: rise .22s cubic-bezier(.2,.8,.2,1);
}
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: rgba(242,230,208,.25); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 24px; }
.sheet .lead { margin: 0 0 18px; color: var(--ivory-dim); }
.sheet-text { font-size: 16px; margin: 6px 0 18px; }
.sheet .stack { display: flex; flex-direction: column; gap: 10px; }
.sheet .rules { font-size: 14px; color: var(--ivory-dim); margin: 16px 0 0; }
.seg { display: flex; gap: 8px; margin: 8px 0 16px; }
.seg button {
  flex: 1; min-height: 46px; border-radius: 12px; border: 1.5px solid rgba(242,230,208,.18);
  background: transparent; font-weight: 700; cursor: pointer; padding: 6px 4px; line-height: 1.2;
}
.seg button small { display: block; font-weight: 500; font-size: 11px; color: var(--ivory-dim); }
.seg button.on { background: var(--ivory); color: var(--ground); border-color: var(--ivory); }
.seg button.on small { color: var(--ground-3); }
.label { font-size: 13px; font-weight: 700; color: var(--ivory-dim); margin-top: 4px; }

#toast-root { position: fixed; left: 0; right: 0; top: 12px; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  background: var(--ivory); color: var(--ground); font-weight: 700;
  padding: 10px 16px; border-radius: 14px; max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: drop .2s ease;
}
.toast.err { background: var(--madder); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .3s; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40%); } }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* ---------- поиск соперника ---------- */
.search {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px var(--gut); text-align: center; gap: 10px;
}
.spin-gol { width: 132px; height: 132px; margin-bottom: 18px; animation: turn 5s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.search h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 24px; }
.search .btn { margin-top: 18px; min-width: 220px; }

/* ---------- ожидание игроков ---------- */
.wait { padding: 8px var(--gut) 24px; display: flex; flex-direction: column; gap: 16px; }
.code-box {
  background: var(--ground-2); border-radius: var(--r-l); padding: 18px; text-align: center;
  border: 2px dashed rgba(224,164,58,.4);
}
.code-box .code { font-family: var(--display); font-weight: 700; font-size: 38px; letter-spacing: .14em; color: var(--saffron); }
.seats-list { display: flex; flex-direction: column; gap: 8px; }
.seat-row { display: flex; align-items: center; gap: 12px; background: var(--ground-2); padding: 10px 12px; border-radius: var(--r-m); }
.seat-row.free { background: transparent; border: 1.5px dashed rgba(242,230,208,.18); color: var(--ivory-dim); }

/* ---------- экран игры ---------- */
.game { flex: 1; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.g-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  flex: none;
}
.g-head .title { flex: 1; font-family: var(--display); font-weight: 600; font-size: 15px; opacity: .8; }
.g-body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

.player {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; position: relative;
  border-radius: var(--r-m); min-width: 0;
}
.player .pn { min-width: 0; }
.player .pn b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.player .pn small { color: var(--ivory-dim); font-size: 12px; }
.player.turn { background: rgba(242,230,208,.08); box-shadow: inset 0 0 0 1.5px rgba(224,164,58,.55); }
.player.off .ava { opacity: .45; }
.tbar { height: 4px; border-radius: 4px; background: rgba(242,230,208,.12); overflow: hidden; position: absolute; left: 12px; right: 12px; bottom: 2px; }
.tbar i { display: block; height: 100%; background: var(--saffron); transform-origin: left; transition: transform .2s linear; }
.tbar.hurry i { background: var(--madder); }

.status-line {
  text-align: center; font-weight: 700; font-size: 14px; padding: 6px 12px; min-height: 32px;
  color: var(--ivory-dim);
}
.status-line.mine { color: var(--saffron); }

.emote-bubble {
  position: absolute; z-index: 30; font-size: 40px; pointer-events: none;
  animation: pop 2.2s ease forwards;
}
@keyframes pop {
  0% { transform: scale(.3); opacity: 0; } 12% { transform: scale(1.15); opacity: 1; }
  20% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; }
}
.emote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.emote-grid button { font-size: 32px; height: 64px; border-radius: 16px; border: 0; background: rgba(242,230,208,.07); cursor: pointer; }

/* ---------- карты ---------- */
.card {
  --ch: calc(var(--cw) * 1.4);
  width: var(--cw); height: var(--ch); flex: none;
  border-radius: calc(var(--cw) * .12);
  background: var(--paper);
  position: relative; color: var(--ink);
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 3px 8px rgba(0,0,0,.25);
}
.card.red { color: var(--madder); }
.card .c-rank {
  position: absolute; left: 8%; top: 4%;
  font-family: var(--display); font-weight: 700; font-size: calc(var(--cw) * .32); line-height: 1;
}
.card .c-suit { position: absolute; left: 9%; top: calc(var(--cw) * .38); font-size: calc(var(--cw) * .26); line-height: 1; }
.card .c-big { position: absolute; right: 8%; bottom: 4%; font-size: calc(var(--cw) * .56); line-height: 1; }
.card.back {
  background: var(--madder-deep) var(--gol) center / calc(var(--cw) * .8);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--saffron), 0 3px 8px rgba(0,0,0,.3);
}
.card.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--saffron), 0 8px 16px rgba(0,0,0,.4); }
.card.can { cursor: pointer; }
.card.dim { filter: brightness(.6) saturate(.6); }
.card.target { box-shadow: 0 0 0 3px var(--saffron), 0 0 18px rgba(224,164,58,.6); cursor: pointer; animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 3px var(--saffron), 0 0 4px rgba(224,164,58,.2); } }
.card.in { animation: deal .25s cubic-bezier(.2,.8,.2,1); }
@keyframes deal { from { transform: translateY(30px) scale(.8); opacity: 0; } }

/* ковёр под картами */
.carpet {
  flex: 1; margin: 0 8px; border-radius: 26px; position: relative; min-height: 0;
  background: var(--madder-deep) var(--gol) repeat center / 56px;
  box-shadow: inset 0 0 0 6px #6a1a20, inset 0 0 0 8px var(--saffron), inset 0 0 0 10px #6a1a20, inset 0 0 60px rgba(0,0,0,.35);
}

/* ---------- дурак ---------- */
.durak .opps { display: flex; justify-content: center; gap: 6px; padding: 0 8px; flex-wrap: wrap; flex: none; }
.durak .opp { flex-direction: column; gap: 4px; padding: 8px 10px 10px; text-align: center; }
.durak .opp .backs { display: flex; height: 40px; justify-content: center; }
.durak .opp .backs .card { --cw: 28px; margin-left: -18px; }
.durak .opp .backs .card:first-child { margin-left: 0; }
.durak .opp .tag { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 99px; background: var(--madder); color: #fff; }
.durak .opp .tag.def { background: var(--indigo-2); }
.durak .carpet { display: flex; flex-direction: column; justify-content: center; padding: 16px 10px; }
.durak .deck {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 90px; height: 92px;
}
.durak .deck .trump { position: absolute; left: 30px; top: 12px; transform: rotate(90deg); --cw: 48px; }
.durak .deck .pile { position: absolute; left: 0; top: 12px; --cw: 48px; }
.durak .deck .cnt {
  position: absolute; left: 0; width: 48px; text-align: center; bottom: -20px;
  font-family: var(--display); font-size: 13px; font-weight: 600;
}
.durak .deck .trump-only {
  position: absolute; left: 6px; top: 22px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--paper); display: grid; place-items: center; font-size: 30px; color: var(--ink);
}
.durak .deck .trump-only.red { color: var(--madder); }
.durak .pairs { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 14px 16px; margin-left: 84px; }
.durak .pair { position: relative; width: calc(var(--cw) + 14px); height: calc(var(--cw) * 1.4 + 18px); --cw: 54px; }
.durak .pair > .card { position: absolute; left: 0; top: 0; }
.durak .pair > .card + .card { left: 14px; top: 18px; transform: rotate(8deg); }
.durak .bita { position: absolute; right: 12px; top: 12px; font-size: 12px; color: var(--ivory-dim); }

.hand { flex: none; padding: 10px 8px 4px; display: flex; justify-content: center; min-height: 116px; align-items: flex-end; }
.hand .card { --cw: 62px; margin-left: calc(var(--overlap, -22px)); transition: transform .12s ease; }
.hand .card:first-child { margin-left: 0; }
.actions { flex: none; display: flex; gap: 10px; padding: 8px 12px calc(10px + var(--safe-b)); }
.actions .btn { flex: 1; }

/* ---------- доски: шашки и шахматы ---------- */
.board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px 8px; min-height: 0; }
.board {
  --sq: min(calc((100vw - 24px) / 8), calc((100dvh - 290px) / 8));
  display: grid; grid-template-columns: repeat(8, var(--sq)); grid-template-rows: repeat(8, var(--sq));
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 0 0 4px var(--wood), 0 0 0 6px var(--saffron), 0 12px 32px rgba(0,0,0,.45);
}
.sq { position: relative; display: grid; place-items: center; }
.sq.l { background: #ead9b7; }
.sq.d { background: #9b4136; }
.sq.last::before { content: ''; position: absolute; inset: 0; background: rgba(224,164,58,.38); }
.sq.from::before { content: ''; position: absolute; inset: 0; background: rgba(242,230,208,.35); }
.sq.dest::after {
  content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%;
  background: rgba(30,28,42,.45); z-index: 2;
}
.sq.dest.occ::after { width: 86%; height: 86%; background: none; border: 4px solid rgba(30,28,42,.45); }
.sq.capt::after { content: '✕'; position: absolute; color: rgba(255,255,255,.7); font-weight: 800; z-index: 3; font-size: calc(var(--sq) * .4); }
.sq .coord { position: absolute; left: 3px; top: 1px; font-size: 9px; font-weight: 800; opacity: .55; color: var(--ink); }
.sq .coord.fl { left: auto; top: auto; right: 3px; bottom: 1px; }
.piece { width: 82%; height: 82%; border-radius: 50%; position: relative; z-index: 1; }
.piece.w { background: radial-gradient(circle at 50% 42%, #fffaf0 0 46%, #e2d4b8 47% 54%, #fffaf0 55% 66%, #d7c6a5 67%); box-shadow: 0 3px 0 #a99472, 0 5px 8px rgba(0,0,0,.35); }
.piece.b { background: radial-gradient(circle at 50% 42%, #3a3550 0 46%, #24203a 47% 54%, #3a3550 55% 66%, #1b1830 67%); box-shadow: 0 3px 0 #0f0d1c, 0 5px 8px rgba(0,0,0,.4); }
.piece.k::after {
  content: '♛'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--sq) * .42); color: var(--saffron);
}
.chess .sq .cp {
  font-size: calc(var(--sq) * .82); line-height: 1; position: relative; z-index: 1;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', sans-serif;
}
.cp.w { color: #fffaf0; -webkit-text-stroke: 1.2px #2a2433; text-shadow: 0 2px 2px rgba(0,0,0,.35); }
.cp.b { color: #24203a; -webkit-text-stroke: .6px #000; text-shadow: 0 2px 2px rgba(0,0,0,.25); }
.sq.check { background: radial-gradient(circle, #ff6a55 0 30%, transparent 70%), #9b4136; }
.clock {
  font-family: var(--display); font-size: 18px; font-weight: 600; padding: 4px 10px; border-radius: 10px;
  background: rgba(242,230,208,.08); margin-left: auto; font-variant-numeric: tabular-nums;
}
.player.turn .clock { background: var(--ivory); color: var(--ground); }
.clock.low { background: var(--madder) !important; color: #fff !important; }
.side-row { display: flex; align-items: center; gap: 10px; padding: 4px 12px; flex: none; }
.side-row .player { flex: 1; }
.captured { font-size: 16px; letter-spacing: -2px; opacity: .8; }
.draw-offer {
  margin: 0 12px; padding: 10px 12px; border-radius: var(--r-m); background: var(--indigo);
  display: flex; align-items: center; gap: 8px; flex: none; font-weight: 700; font-size: 14px;
}
.draw-offer span { flex: 1; }
.promo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.promo button { font-size: 44px; height: 76px; border-radius: 16px; border: 0; background: var(--ivory); cursor: pointer; color: var(--ink); }

/* ---------- нарды ---------- */
.nardy-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 6px; min-height: 0; }
.nboard {
  --pw: min(calc((100vw - 40px) / 13), 34px);
  --ph: min(calc(var(--pw) * 7.2), calc((100dvh - 330px) / 2));
  display: grid; grid-template-columns: repeat(6, var(--pw)) 14px repeat(6, var(--pw));
  grid-template-rows: var(--ph) 34px var(--ph);
  background: var(--wood-2); border-radius: 12px; padding: 8px;
  box-shadow: 0 0 0 5px var(--wood), 0 0 0 7px var(--saffron), 0 12px 32px rgba(0,0,0,.45);
  position: relative;
}
.nboard .bar { grid-row: 1 / 4; grid-column: 7; background: var(--wood); margin: -8px 0; }
.nboard .mid { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: center; gap: 12px; }
.pt { position: relative; display: flex; flex-direction: column; align-items: center; cursor: default; }
.pt::before {
  content: ''; position: absolute; left: 6%; right: 6%; top: 0; bottom: 12%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: var(--tri, #e8d6b4);
}
.pt.bottom { flex-direction: column-reverse; }
.pt.bottom::before { top: 12%; bottom: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.pt.odd { --tri: #9b4136; }
.pt .chk {
  width: calc(var(--pw) - 4px); height: calc(var(--pw) - 4px); border-radius: 50%; position: relative; z-index: 1;
  margin-bottom: -2px; flex: none;
}
.pt.bottom .chk { margin-bottom: 0; margin-top: -2px; }
.chk.c0 { background: radial-gradient(circle at 50% 40%, #fffaf0 0 50%, #dccbaa 51% 60%, #fffaf0 61%); box-shadow: 0 2px 0 #a99472; }
.chk.c1 { background: radial-gradient(circle at 50% 40%, #3a3550 0 50%, #24203a 51% 60%, #3a3550 61%); box-shadow: 0 2px 0 #0f0d1c; }
.chk .n {
  position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.chk.c0 .n { color: var(--ink); }
.chk.c1 .n { color: var(--ivory); }
.pt.src .chk:last-child { box-shadow: 0 0 0 3px var(--saffron); }
.pt.bottom.src .chk:last-child { box-shadow: 0 0 0 3px var(--saffron); }
.pt.can { cursor: pointer; }
.pt.dst::after {
  content: ''; position: absolute; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--saffron); z-index: 2; box-shadow: 0 0 0 3px rgba(43,18,21,.6); bottom: 14%;
}
.pt.bottom.dst::after { bottom: auto; top: 14%; }
.pt.lastto .chk:last-child { outline: 2px dashed rgba(224,164,58,.8); outline-offset: 1px; }
.dice { display: flex; gap: 8px; }
.die {
  width: 30px; height: 30px; border-radius: 7px; background: var(--paper); color: var(--ink);
  display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 16px;
  box-shadow: 0 2px 0 #b9a888;
}
.die.used { opacity: .35; }
.offzone {
  min-width: 64px; height: 34px; border-radius: 10px; border: 2px dashed rgba(242,230,208,.35);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; padding: 0 8px; cursor: pointer;
}
.offzone.dst { border-color: var(--saffron); background: rgba(224,164,58,.2); color: var(--saffron); }

/* ---------- покер и свара ---------- */
.table-area { flex: 1; position: relative; margin: 4px 8px 0; min-height: 0; }
.oval {
  position: absolute; inset: 10% 6% 12%;
  border-radius: 999px;
  background: var(--madder-deep) var(--gol) repeat center / 52px;
  box-shadow: inset 0 0 0 6px #6a1a20, inset 0 0 0 8px var(--saffron), inset 0 0 0 10px #6a1a20, inset 0 0 50px rgba(0,0,0,.4), 0 14px 40px rgba(0,0,0,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.oval .board-cards { display: flex; gap: 4px; }
.oval .board-cards .card { --cw: min(44px, 10vw); }
.pot { font-family: var(--display); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; color: var(--saffron); }
.pot .coin { width: 16px; height: 16px; }
.tseat {
  position: absolute; width: 92px; margin-left: -46px; margin-top: -40px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
}
.tseat .nm { font-size: 12px; font-weight: 700; max-width: 92px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tseat .stk { font-family: var(--display); font-size: 12px; font-weight: 600; color: var(--saffron); }
.tseat.turn .ava { box-shadow: 0 0 0 3px var(--saffron); }
.tseat.folded { opacity: .45; }
.tseat .hole { display: flex; position: absolute; top: -2px; left: 56px; z-index: 2; transform: rotate(8deg); }
.tseat .hole .card { --cw: 24px; margin-left: -12px; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.tseat .hole.show { position: static; transform: none; z-index: 1; margin-top: 2px; }
.tseat .hole.show .card { --cw: 32px; margin-left: -8px; }
.tseat .hole .card:first-child { margin-left: 0; }
.tseat .tbar { position: static; width: 70px; margin-top: 2px; }
.tseat.free { opacity: .5; }
.tseat.free .ava { background: transparent; border: 1.5px dashed rgba(242,230,208,.35); }
.chipbet {
  position: absolute; display: flex; align-items: center; gap: 4px; font-family: var(--display); font-size: 12px; font-weight: 600;
  background: rgba(30,12,14,.75); padding: 2px 8px 2px 3px; border-radius: 99px; color: var(--ivory); white-space: nowrap;
  transform: translate(-50%, -50%); z-index: 2;
}
.chipbet .coin { width: 14px; height: 14px; }
.dealer { position: absolute; width: 20px; height: 20px; border-radius: 50%; background: var(--ivory); color: var(--ground); font-size: 11px; font-weight: 800; display: grid; place-items: center; transform: translate(-50%, -50%); z-index: 2; }
.won-tag { position: absolute; top: -18px; font-family: var(--display); font-size: 13px; font-weight: 700; color: var(--saffron); background: var(--ground); padding: 0 6px; border-radius: 6px; }
.hand-name { font-size: 11px; font-weight: 800; color: var(--ivory); background: var(--indigo-2); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.my-cards { flex: none; display: flex; justify-content: center; gap: 6px; padding: 8px 8px 0; min-height: 92px; align-items: flex-end; }
.my-cards .card { --cw: 58px; }
.my-cards .card.best { box-shadow: 0 0 0 3px var(--saffron); }
.my-info { flex: none; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 4px 12px; font-size: 13px; }
.bet-panel { flex: none; padding: 6px 12px calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.bet-panel .row { gap: 8px; }
.bet-panel .btn { flex: 1; min-height: 48px; padding: 8px 6px; font-size: 15px; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input[type=range] { flex: 1; accent-color: var(--saffron); height: 30px; }
.slider .amt { font-family: var(--display); font-weight: 600; min-width: 80px; text-align: right; color: var(--saffron); }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; min-height: 34px; border-radius: 10px; border: 0; background: rgba(242,230,208,.08); font-weight: 700; font-size: 13px; cursor: pointer; }
.svara-banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20;
  background: var(--saffron); color: #2b1a05; border-radius: 18px; padding: 14px 20px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: pop2 .3s ease; width: max-content; max-width: 86%;
}
.svara-banner b { display: block; font-family: var(--display); font-size: 26px; }
@keyframes pop2 { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

/* ---------- итог партии ---------- */
.result { text-align: center; padding-top: 6px; }
.result .medal { width: 92px; height: 92px; margin: 0 auto 10px; display: block; }
.result h2 { font-size: 30px; }
.result.loss .medal { filter: grayscale(.8) brightness(.8); }
.result .why { color: var(--ivory-dim); margin: 0 0 18px; }

/* ---------- рейтинг и профиль ---------- */
.page { padding: 8px var(--gut); }
.page h1 { font-family: var(--display); font-weight: 600; font-size: 26px; margin: 8px 0 14px; }
.chips-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips-tabs button { flex: none; border: 0; border-radius: 99px; padding: 8px 14px; background: rgba(242,230,208,.08); font-weight: 700; cursor: pointer; }
.chips-tabs button.on { background: var(--ivory); color: var(--ground); }
.lb { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r-m); background: var(--ground-2); }
.lb-row.me { box-shadow: inset 0 0 0 1.5px var(--saffron); }
.lb-row .pos { width: 26px; font-family: var(--display); font-weight: 600; color: var(--ivory-dim); }
.lb-row:nth-child(1) .pos { color: var(--saffron); }
.lb-row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.lb-row .sc { font-family: var(--display); font-weight: 600; }
.empty { color: var(--ivory-dim); padding: 30px 0; text-align: center; }
.me-card { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.me-card b { font-size: 20px; display: block; }
.stat-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--ground-2); border-radius: var(--r-m); }
.stat-row span:first-child { font-weight: 700; }
.note { font-size: 13px; color: var(--ivory-dim); margin-top: 22px; }

.center-msg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 14px; }
.center-msg img { width: 80px; }

/* ---------- реклама за фишки ---------- */
.ad-card {
  margin: -6px var(--gut) 16px; width: calc(100% - 2 * var(--gut));
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border-radius: var(--r-l); border: 1.5px solid rgba(224,164,58,.45);
  background: rgba(224,164,58,.1); color: var(--ivory); cursor: pointer;
}
.ad-card:active { transform: scale(.99); }
.ad-card b { display: block; font-size: 15px; }
.ad-card small { color: var(--ivory-dim); font-size: 12px; }
.ad-card .ad-ic { font-size: 26px; }
.ad-card .ad-plus { font-family: var(--display); font-weight: 600; color: var(--saffron); }
.ad-card.done { border-style: dashed; background: transparent; opacity: .75; cursor: default; }

.adv {
  position: fixed; inset: 0; z-index: 90; background: #120708;
  display: flex; flex-direction: column; animation: fade .2s ease;
}
.adv-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.adv-label { flex: 1; font-size: 12px; font-weight: 800; color: var(--ivory-dim); }
.adv-count {
  min-width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--saffron); color: var(--saffron); font-size: 15px;
}
.adv-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.adv-media { max-width: 100%; max-height: 100%; border-radius: 14px; object-fit: contain; background: #000; }
.adv-bottom { padding: 12px var(--gut) calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.adv-title { font-size: 17px; text-align: center; }

/* ---------- чат ---------- */
.chat-btn { position: relative; }
.chat-btn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--madder); color: #fff; font-size: 11px; font-style: normal; font-weight: 800; display: grid; place-items: center;
}
.chat-list {
  max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  padding: 4px 0 10px; user-select: text; -webkit-user-select: text;
}
.chat-msg {
  align-self: flex-start; max-width: 82%; padding: 7px 11px; border-radius: 14px 14px 14px 4px;
  background: var(--ground-3); font-size: 14px; overflow-wrap: anywhere;
}
.chat-msg b { display: block; font-size: 11px; color: var(--saffron); }
.chat-msg.mine { align-self: flex-end; background: var(--indigo-2); border-radius: 14px 14px 4px 14px; }
.chat-empty { text-align: center; padding: 18px 0; font-size: 13px; }
.chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chat-quick button {
  flex: none; border: 1.5px solid rgba(242,230,208,.2); background: transparent; border-radius: 99px;
  padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chat-row { display: flex; gap: 8px; }
.chat-row .btn { min-width: 54px; }
.chat-input, .field {
  flex: 1; min-width: 0; width: 100%; height: 46px; border-radius: 12px; border: 1.5px solid rgba(242,230,208,.18);
  background: rgba(0,0,0,.18); color: var(--ivory); padding: 0 12px; font-size: 15px;
  user-select: text; -webkit-user-select: text;
}
.field { margin-bottom: 8px; }
.chat-bubble {
  position: fixed; z-index: 40; max-width: 220px; padding: 6px 10px; border-radius: 12px;
  background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); pointer-events: none; animation: drop .2s ease;
  transition: opacity .4s;
}
.chat-bubble.out { opacity: 0; }

/* ---------- зритель ---------- */
.watch-note { text-align: center; font-size: 11px; color: var(--ivory-dim); padding: 0 12px 2px; flex: none; }
.watch-result {
  flex: none; margin: 6px 12px calc(10px + var(--safe-b)); padding: 12px 14px; border-radius: var(--r-m);
  background: var(--saffron); color: #2b1a05; display: flex; flex-direction: column; gap: 2px;
}

/* ---------- админ ---------- */
.adm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.adm-stat { background: var(--ground-2); border-radius: var(--r-m); padding: 10px 12px; display: flex; flex-direction: column; }
.adm-stat b { font-size: 20px; }
.adm-stat span { font-size: 12px; font-weight: 700; }
.adm-stat small { font-size: 11px; color: var(--ivory-dim); }
.chips-tabs.small button { padding: 6px 12px; font-size: 13px; }
.adm-list { display: flex; flex-direction: column; gap: 8px; }
.adm-card { background: var(--ground-2); border-radius: var(--r-m); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.adm-card.off { opacity: .6; }
.adm-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-card-head .muted { font-size: 12px; flex: 1; }
.adm-card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.adm-card-foot .muted { flex: 1; font-size: 12px; }
.adm-players { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-players .pl { background: rgba(242,230,208,.07); border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.adm-players .pl small { color: var(--saffron); font-weight: 700; }
.adm-players .pl.off { opacity: .5; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--ground-3); }
.tag.playing { background: #2f5a3e; }
.tag.waiting { background: var(--indigo-2); }
.hist-row { background: var(--ground-2); border-radius: var(--r-m); padding: 10px 12px; }
.hist-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.hist-head b { font-size: 14px; }
.hist-players { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hp { border: 0; background: rgba(242,230,208,.07); border-radius: 99px; padding: 4px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.hp small { font-weight: 800; }
.hp.pos small, .pos { color: #8fd18a; }
.hp.neg small, .neg { color: #f08a7e; }
.hist-cards { margin-top: 6px; font-size: 12px; color: var(--ivory-dim); }
.mini-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.mini-row > span { min-width: 70px; }
.mini-cards { display: flex; gap: 3px; margin-top: 4px; }
.mini-cards .card { --cw: 26px; }
.filter-chip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 6px 6px 6px 12px;
  background: var(--indigo); border-radius: 99px; font-size: 13px; font-weight: 700;
}
.filter-chip button { border: 0; background: rgba(242,230,208,.1); border-radius: 99px; padding: 4px 10px; cursor: pointer; font-weight: 700; }
.filter-chip .link { margin-left: auto; }
.user-row { border: 0; width: 100%; text-align: left; cursor: pointer; }
.dot.on::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6fd17a; margin-right: 5px; }
.chat-log { background: var(--ground-3); border-radius: 10px; padding: 8px 10px; font-size: 14px; overflow-wrap: anywhere; }
.ad-row { display: flex; gap: 12px; align-items: flex-start; }
.ad-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #000; flex: none; }
.ad-preview {
  min-height: 140px; border-radius: var(--r-m); border: 1.5px dashed rgba(242,230,208,.25); margin-bottom: 8px;
  display: grid; place-items: center; overflow: hidden;
}
.ad-preview img, .ad-preview video { max-width: 100%; max-height: 240px; display: block; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.daily { display: flex; flex-direction: column; }
.daily-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; padding: 7px 4px; border-bottom: 1px solid rgba(242,230,208,.07); font-size: 14px; }
.daily-row span:not(:first-child) { text-align: right; }
.daily-row.head { font-size: 12px; color: var(--ivory-dim); font-weight: 700; }
.nav button { min-width: 0; }
