/* Игровой стол (одиночная и сетевая партия).
   Один акцент — латунь: главные кнопки — золото, остальное — одно тёмное стекло; цвет только на картах (+ / − / ±). */

/* размер карт: с запасом под низкие экраны; если всё равно не влезло — ui.js fitTable() уменьшит ровно на сколько нужно */
#s-game { --cw: min(calc((100vw - 86px) / 5), calc((100vh - 336px) / 7.4), 72px); --hw: calc(var(--cw) * 1.14);
  padding: max(env(safe-area-inset-top), 8px) 10px max(env(safe-area-inset-bottom), 10px); gap: 8px; }
#s-game.has-chat { --cw: min(calc((100vw - 86px) / 5), calc((100vh - 390px) / 7.4), 72px); }

/* ---------- шапка соперника ---------- */
.opp-bar { position: relative; z-index: 4; display: flex; align-items: center; gap: 10px; min-height: 64px; }
.opp-bar .portrait { width: 62px; height: 62px; border-radius: 14px; overflow: hidden; flex: none; transition: box-shadow .3s ease;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 0 18px var(--glow, rgba(207, 174, 106, .3)); }
/* в ход соперника — золотое кольцо у портрета */
.opp-bar .portrait.turn { box-shadow: 0 0 0 2px rgba(241, 215, 154, .9), 0 0 18px rgba(207, 174, 106, .55); animation: turn-ring 1.6s ease-in-out infinite; }
@keyframes turn-ring { 50% { box-shadow: 0 0 0 2px rgba(241, 215, 154, .55), 0 0 8px rgba(207, 174, 106, .3); } }
.portrait svg, .portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.opp-meta { flex: 1; min-width: 0; }
.opp-name { font-weight: 600; font-size: 18px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ромбы целиком (это повёрнутые квадраты — выступают на 2 px); время хода — всегда своей строкой под ромбами */
.opp-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.opp-sub > span { white-space: nowrap; }
.opp-sub .pips { padding-left: 3px; }
#g-pot { flex-basis: 100%; font-size: 12px; }
#g-pot:empty { display: none; }
.pips { display: inline-flex; gap: 6px; }
.pips i { width: 10px; height: 10px; transform: rotate(45deg); box-shadow: inset 0 0 0 1.5px var(--brass-dim); }
.pips i.on { background: var(--brass-hi); box-shadow: 0 0 8px rgba(241, 215, 154, .7); }
.opp-hand { display: flex; gap: 4px; --cw: 19px; }
.opp-hand .card::before, .opp-hand .card::after { display: none; }
.opp-hand .card.gone { opacity: .14; }

/* ---------- пузыри: соперник — у портрета, свой — над рукой ---------- */
.bubble { position: absolute; z-index: 6; left: 54px; top: 64px; max-width: calc(100% - 64px); padding: 10px 13px; border-radius: 4px 14px 14px 14px;
  background: rgba(10, 18, 34, .94); box-shadow: inset 0 0 0 1px rgba(var(--glow-rgb, 142, 232, 255), 0.6), 0 0 20px rgba(var(--glow-rgb, 142, 232, 255), 0.2), 0 8px 20px rgba(0, 0, 0, .5);
  font-size: 14.5px; line-height: 1.4; opacity: 0; transform: translateY(-6px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.bubble.show { opacity: 1; transform: none; }
.bubble.emo-bubble { display: flex; align-items: center; gap: 10px; font-weight: 600; }
#s-game .bubble.emo-bubble { box-shadow: inset 0 0 0 1px rgba(207, 174, 106, .55), 0 8px 20px rgba(0, 0, 0, .5); }
.me-bubble { position: absolute; z-index: 6; right: 14px; top: 0; max-width: calc(100% - 28px); padding: 8px 13px; border-radius: 14px 14px 4px 14px; font-size: 14.5px; font-weight: 600;
  background: rgba(10, 18, 34, .94); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(207, 174, 106, .55), 0 8px 20px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.me-bubble.show { opacity: 1; transform: none; }
.me-bubble small { display: block; font-size: 11px; font-weight: 400; color: var(--brass-hi); margin-bottom: 1px; }

/* ---------- стол ---------- */
.table { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 10px 8px; border-radius: 28px; isolation: isolate;
  background: radial-gradient(120% 90% at 50% 40%, #121a2a 0%, #070a12 62%, #030408 100%);
  box-shadow: inset 0 0 0 1px rgba(207, 174, 106, .28), inset 0 0 0 5px rgba(0, 0, 0, .5), inset 0 0 0 6px rgba(207, 174, 106, .12), inset 0 0 60px rgba(0, 0, 0, .8), 0 18px 40px rgba(0, 0, 0, .6); }
.table .veins { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; border-radius: inherit; opacity: .9; }
.board { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border-radius: 16px; transition: background .3s ease, box-shadow .3s ease; }
/* чей ход: свечение ВНУТРИ стола (рамка не выходит наружу и не задевает карты), тот, кто ждёт, — приглушён */
.board.active { background: radial-gradient(110% 70% at 50% 0%, rgba(207, 174, 106, .16), rgba(207, 174, 106, .03) 75%);
  box-shadow: inset 0 0 0 1px rgba(207, 174, 106, .42); }
.board .slots, .board .board-head { transition: opacity .3s ease; }
#s-game .board:not(.active) .slots, #s-game .board:not(.active) .board-head { opacity: .62; }
.board-head { display: flex; align-items: center; gap: 8px; min-height: 24px; padding: 0 4px; }
.board-head .who { font-size: 14px; color: var(--muted); }
.board.active .board-head .who { color: var(--brass-hi); }
.board .turn-tag { display: none; font-size: 14px; color: var(--brass-hi); margin-left: -4px; }
.board.active .turn-tag { display: inline; }
.stood-tag { display: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #1b1305; background: var(--brass); }
.board.stood .stood-tag { display: inline-block; }
.total { margin-left: auto; min-width: 54px; padding: 1px 10px; border-radius: 10px; text-align: center; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--holo); background: rgba(142, 232, 255, .06); box-shadow: inset 0 0 0 1px rgba(142, 232, 255, .25); text-shadow: 0 0 10px rgba(142, 232, 255, .7); }
.total.over { color: var(--bad); box-shadow: inset 0 0 0 1px rgba(255, 81, 104, .55); text-shadow: 0 0 10px rgba(255, 81, 104, .8); }
.total.twenty { color: var(--brass-hi); box-shadow: inset 0 0 0 1px rgba(241, 215, 154, .6); text-shadow: 0 0 12px rgba(241, 215, 154, .9); }
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: calc(var(--cw) * 5 + 24px); margin: 0 auto; }
#board-opp .slots { flex-wrap: wrap-reverse; }
.midline { display: flex; align-items: center; gap: 10px; min-height: 26px; padding: 0 8px; }
.midline::before, .midline::after { content: ""; height: 1px; flex: 0 0 18px; background: linear-gradient(90deg, transparent, rgba(207, 174, 106, .5)); }
.midline::after { background: linear-gradient(90deg, rgba(207, 174, 106, .5), transparent); }
.set-no { font-weight: 600; color: var(--brass-hi); font-size: 14px; white-space: nowrap; }
.status { flex: 1; font-size: 14px; color: var(--muted); text-align: center; }
.status.warn { color: var(--bad); font-weight: 600; }
.status.mine { color: var(--ink); }

/* песочные часы хода (сетевая партия): золотые — ваш ход, бирюзовые — соперника, красные — мало времени */
.turn-timer { position: relative; display: inline-flex; align-items: center; gap: 5px; margin-left: auto; min-width: 0; padding: 2px 8px 2px 4px; border-radius: 12px;
  background: rgba(5, 8, 16, .65); box-shadow: inset 0 0 0 1px var(--line); --hg: #7fe9ff; --hg-rgb: 127, 233, 255; }
.turn-timer.mine { --hg: #f1d79a; --hg-rgb: 241, 215, 154; }
.turn-timer.low { --hg: #ff7a7a; --hg-rgb: 255, 122, 122; }
.turn-timer .hg { width: 18px; height: 26px; display: block; overflow: visible; filter: drop-shadow(0 0 4px rgba(var(--hg-rgb), .55)); }
.turn-timer.low .hg { animation: hgPulse .8s ease-in-out infinite; }
@keyframes hgPulse { 50% { filter: drop-shadow(0 0 8px rgba(var(--hg-rgb), .95)); } }
.hg-glass { fill: rgba(var(--hg-rgb), .07); stroke: rgba(var(--hg-rgb), .55); stroke-width: .9; }
.hg-sand { fill: var(--hg); opacity: .9; }
.hg-stream { stroke: var(--hg); stroke-width: .9; stroke-dasharray: 1.2 1.4; animation: hgFlow .35s linear infinite; transition: opacity .2s; }
@keyframes hgFlow { to { stroke-dashoffset: -2.6; } }
.hg-frame { stroke: rgba(207, 174, 106, .75); stroke-width: 1.3; stroke-linecap: round; fill: none; }
.hg-led { fill: var(--hg); }
.turn-timer b { position: relative; margin-left: auto; font-size: 14px; font-weight: 600; color: var(--hg); min-width: 2ch; text-align: left; font-variant-numeric: tabular-nums; }

/* ---------- рука и кнопки хода ---------- */
.hand { display: flex; justify-content: center; gap: 10px; padding: 2px 0; min-height: calc(var(--hw) * 1.38 + 6px); --cw: var(--hw); }
.hand button { padding: 0; transition: transform .12s ease; }
.hand button:active { transform: translateY(-5px); }
.hand button:disabled { opacity: .42; filter: saturate(.5); }
.hand .empty { color: var(--muted); font-size: 14px; align-self: center; }
/* «Передать ход» и «Остановиться на N» — обе золотые, одна высота и шрифт, подпись второй строкой */
.actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
#s-game.chat-mini .actions { grid-template-columns: 50px minmax(0, 1fr) minmax(0, 1fr); }
.actions .btn { min-width: 0; min-height: 50px; padding: 6px 10px; font-size: 16px; letter-spacing: 0; line-height: 1.15; }
.actions .btn small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 12px; line-height: 1.15; white-space: nowrap; letter-spacing: -.01em; }
#btn-end small { opacity: .78; }
/* где кнопки узкие — подпись короче: «планшет — в ваш ход» */
#s-game.chat-mini #btn-end .sub-long { display: none; }
.actions .gc-mini { width: 50px; height: 50px; color: var(--brass-hi); }
.actions .gc-mini svg { width: 22px; height: 22px; }

/* итог сета */
.result { position: absolute; z-index: 5; left: 10px; right: 10px; bottom: max(env(safe-area-inset-bottom), 10px); padding: 16px 16px 14px; border-radius: 18px; text-align: center;
  background: rgba(8, 13, 24, .95); box-shadow: inset 0 0 0 1px rgba(207, 174, 106, .4), 0 -10px 40px rgba(0, 0, 0, .6); }
.result h2 { font-size: 24px; }
.result .reason { color: var(--muted); font-size: 14.5px; margin: 4px 0 6px; }
.result .score { font-size: 30px; font-weight: 600; letter-spacing: .1em; margin-bottom: 10px; }
.result .score small { display: block; font-size: 12.5px; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.win { color: var(--ok); }
.lose { color: var(--bad); }

/* ---------- реакции (сетевая партия) ---------- */
.emote-btn { position: relative; font-size: 20px; }
.emo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 4px; }
.emo { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 8px; border-radius: 12px; background: rgba(14, 22, 40, .9); box-shadow: inset 0 0 0 1px var(--line); font-size: 14.5px; }
.emo:active { transform: scale(.97); }
.emo-ic { display: inline-flex; width: 28px; height: 28px; color: var(--brass-hi); flex: none; }
.emo-ic svg { width: 100%; height: 100%; }
/* частицы: сердечко и планшет «20» разлетаются от аватара */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.fx { position: absolute; will-change: transform, opacity; }
.fx svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 6px rgba(255, 80, 120, .65)); }
.fx.tab20 { display: grid; place-items: center; border-radius: 5px; background: linear-gradient(180deg, rgba(255, 226, 150, .95), rgba(207, 160, 80, .95));
  box-shadow: 0 0 0 1px rgba(255, 240, 200, .8), 0 0 14px rgba(255, 200, 100, .75); }
.fx.tab20 span { font: 700 13px/1 var(--font); color: #2b1a04; letter-spacing: .02em; }
.fx-glow { position: absolute; width: 120px; height: 120px; border-radius: 50%; }
.fx-glow.heart { background: radial-gradient(circle, rgba(255, 110, 150, .55), rgba(255, 60, 110, 0) 70%); }
.fx-glow.tab20 { background: radial-gradient(circle, rgba(255, 215, 130, .6), rgba(255, 180, 80, 0) 70%); }

/* ---------- реплики за столом ---------- */
.game-chat { display: flex; align-items: center; gap: 8px; }
.game-chat .icon-btn { width: 44px; height: 44px; font-size: 20px; color: var(--ink); }
.game-chat .gc-field { position: relative; flex: 1; min-width: 0; }
.game-chat input { width: 100%; height: 44px; padding: 0 52px 0 14px; border: 0; border-radius: 12px; font: inherit; font-size: 15px; color: var(--ink);
  background: rgba(14, 22, 40, .7); box-shadow: inset 0 0 0 1px var(--line); outline: none; -webkit-appearance: none; appearance: none; }
.game-chat input:focus { box-shadow: inset 0 0 0 1.5px rgba(207, 174, 106, .8); }
.game-chat .gc-count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.game-chat .gc-send { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #1b1305;
  background: linear-gradient(180deg, #f3dca2 0%, #cfae6a 52%, #a8853f 100%); box-shadow: inset 0 0 0 1px rgba(255, 240, 200, .6); }
.game-chat .gc-send svg { width: 22px; height: 22px; }
.game-chat .gc-send:active { filter: brightness(1.1); transform: scale(.96); }
#s-game.has-chat .emote-btn { display: none !important; }       /* ☺ переезжает в строку */
/* пишем — рука и кнопки хода прячутся; видны все ячейки обоих столов, стол компактнее, карты мельче (fitTable) */
#s-game.typing .hand, #s-game.typing .actions { display: none; }
#s-game.typing .board { gap: 3px; padding-top: 4px; padding-bottom: 6px; }
#s-game.typing .board-head { min-height: 0; margin-bottom: 4px; font-size: 12.5px; }
#s-game.typing .board-head .total { min-width: 0; padding: 1px 8px; font-size: 15px; }
#s-game.typing .board .slots { gap: 4px; }
#s-game.typing .table { row-gap: 4px; }

/* ---------- небольшие экраны ---------- */
@media (max-height: 640px) {
  .opp-bar { min-height: 54px; }
  .opp-bar .portrait { width: 52px; height: 52px; }
  .bubble { top: 56px; }
}
@media (max-width: 380px) {
  #btn-end .sub-long { display: none; }
  .opp-hand { --cw: 15px; gap: 3px; }
  .actions .btn { font-size: 15.5px; padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) { .opp-bar .portrait.turn { animation: none; } }
