/* ============================================================
   Карточный стол — общий для тысячи и дурака

   Устроен одинаково: соперники сверху рубашками, посередине то, что на
   столе, свои карты внизу веером. Справа — счёт, разговор и лента
   событий. Гамма общая с сайтом, синяя; зелёное сукно нарочно
   приглушённое, иначе на тёмной странице оно кричит.

   Приставка у классов осталась `th-` с тех пор, когда файл был только
   про тысячу: переименовывать её в разметке трёх десятков мест ради
   красоты — дороже, чем эта строчка объяснения. Специфика каждой игры
   лежит в своём файле: thousand.css здесь больше нет, durak.css — для
   стола с отбоем.
   ============================================================ */

.th-fs {
    border-radius: 18px;
}

.th-fs:fullscreen {
    padding: 20px;
    background: var(--body-color, #0b0b0f);
    overflow-y: auto;
}

.th-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 22px;
    margin-bottom: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: var(--card-color);
}

.th-head__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}

.th-head__title i { color: var(--accent); font-size: 26px; }

.th-head__sub {
    margin-top: 4px;
    font-size: 13px;
    color: #8a8a95;
}

.th-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Кнопки ---------- */

.th-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border: none;
    border-radius: 10px;
    background: var(--btn-wallet-color);
    color: #fff !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.th-btn:hover { background: var(--btn-wallet-color-hover); text-decoration: none; }

.th-btn--ghost {
    background: rgba(255, 255, 255, .06);
    color: #d6d6de !important;
}

.th-btn--ghost:hover { background: rgba(255, 255, 255, .12); }

.th-btn:disabled { cursor: default; }
.th-btn:disabled:not(.is-loading) { opacity: .4; }

/* Нажали — кнопка гаснет и крутит колечко, чтобы не жали дважды */
.th-btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.th-btn.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: th-spin .6s linear infinite;
}

@keyframes th-spin { to { transform: rotate(360deg); } }

/* ---------- Лобби ---------- */

.th-lobby {
    padding: 20px 22px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: var(--card-color);
}

.th-lobby__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.th-lobby__title { font-size: 18px; font-weight: 700; color: #fff; }
.th-lobby__title--sub { margin: 22px 0 12px; font-size: 15px; }
.th-lobby__sub { margin-top: 4px; font-size: 13px; color: #8a8a95; }

.th-lobby__list { display: grid; gap: 10px; }

.th-lobby__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .22);
}

.th-lobby__players { display: flex; }

.th-lobby__players img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
}

.th-lobby__players img + img { margin-left: -8px; }

.th-lobby__info { flex: 1; min-width: 0; }
.th-lobby__host { font-size: 14px; color: #fff; }
.th-lobby__count { font-size: 12px; color: #8a8a95; }
.th-lobby__lock { color: #e3c04a; font-size: 14px; vertical-align: -1px; }

.th-lobby__empty {
    padding: 22px;
    text-align: center;
    font-size: 13px;
    color: #8a8a95;
}

.th-matches { display: grid; gap: 8px; }

.th-match {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .22);
    font-size: 13px;
    color: #8a8a95;
}

.th-match i { color: #e3c04a; font-size: 16px; }
.th-match__winner { font-weight: 700; color: #fff; }
.th-match__players { flex: 1; min-width: 0; }
.th-match__deals { white-space: nowrap; font-size: 12px; }

/* ---------- Стол ---------- */

.th-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.th-board {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 480px;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .07);
    background:
        radial-gradient(620px 320px at 50% 42%, rgba(46, 125, 80, .22), transparent 72%),
        var(--card-color);
}

/* ---------- Соперники ---------- */

.th-rivals {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.th-rival {
    flex: 0 1 260px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(0, 0, 0, .25);
}

/* Чей ход — тот и подсвечен: без этого за столом теряешься */
.th-rival.is-turn {
    box-shadow: 0 0 0 2px rgba(95, 101, 220, .45);
    background: rgba(95, 101, 220, .1);
}

.th-rival__head { display: flex; align-items: center; gap: 10px; }

.th-rival__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.th-rival__login { font-size: 14px; font-weight: 700; }
.th-rival__sub { font-size: 11px; color: #8a8a95; }

.th-rival__cards { display: flex; margin-top: 8px; }

/* Рубашки чужих карт: их считают глазами, поэтому кладём внахлёст */
.th-rival__back {
    width: 20px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: repeating-linear-gradient(45deg, #2a2a3a, #2a2a3a 3px, #343449 3px, #343449 6px);
}

.th-rival__back + .th-rival__back { margin-left: -8px; }

/* ---------- Середина ---------- */

.th-middle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 150px;
}

.th-trump {
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, .3);
    font-size: 13px;
    color: #8a8a95;
}

.th-trump b { font-size: 16px; color: #fff; }
.th-red { color: #e66; }

.th-trick { display: flex; gap: 10px; min-height: 96px; align-items: center; }

.th-trick__slot {
    padding: 3px;
    border-radius: 10px;
    border: 2px solid transparent;
}

.th-talon { text-align: center; }
.th-talon__label { margin-bottom: 6px; font-size: 12px; color: #8a8a95; }
.th-talon__cards { display: flex; gap: 8px; }

/* ---------- Карты ---------- */

.th-card {
    position: relative;
    width: 62px;
    height: 88px;
    flex: 0 0 auto;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, .4);
    background: linear-gradient(180deg, #f6f6f8, #e4e4ec);
    color: #1a1a22;
    user-select: none;
}

.th-card__rank {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

/* Масть держим слева, под достоинством: в веере видна именно левая
   полоска карты, правую перекрывает соседняя */
.th-card__suit {
    position: absolute;
    left: 7px;
    bottom: 6px;
    font-size: 26px;
    line-height: 1;
}

/* Цена карты подписана мелко: в тысяче её считают весь вечер */
.th-card__points {
    position: absolute;
    top: 7px;
    right: 8px;
    font-size: 11px;
    color: #8a8a95;
}

.th-card--red { color: #c62828; }
.th-card--back { background: repeating-linear-gradient(45deg, #2a2a3a, #2a2a3a 5px, #343449 5px, #343449 10px); }

/* ---------- Своя рука ---------- */

.th-hand {
    display: flex;
    justify-content: center;
    padding-top: 6px;
    min-height: 100px;
}

/* Веер держим редким: карты должны читаться, не наводя мышь */
.th-hand .th-card { margin-left: -6px; transition: transform .12s, box-shadow .12s; }
.th-hand .th-card:first-child { margin-left: 0; }

/* Чем можно ходить, тем и подсвечено — список приходит с сервера */
.th-hand .th-card.is-live { cursor: pointer; box-shadow: 0 0 0 2px rgba(95, 101, 220, .55); }
.th-hand .th-card.is-live:hover { transform: translateY(-14px); }
.th-hand .th-card.is-dead { opacity: .45; }

/* ---------- Кнопки хода ---------- */

.th-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 40px;
}

.th-actions__hint {
    width: 100%;
    text-align: center;
    font-size: 13px;
    color: #8a8a95;
}

.th-actions__note {
    width: 100%;
    text-align: center;
    font-size: 13px;
    color: #e3a54a;
}

/* ---------- Правая колонка ---------- */

.th-side { display: flex; flex-direction: column; gap: 12px; }

.th-turn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(95, 101, 220, .35);
    background: rgba(95, 101, 220, .1);
}

.th-turn__label { font-size: 13px; color: #fff; }
.th-turn__clock { font-size: 15px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }

.th-score {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .22);
}

.th-score__title { margin-bottom: 8px; font-size: 12px; color: #8a8a95; }

.th-score__row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    color: #d6d6de;
}

.th-score__row.is-me .th-score__login { color: #fff; font-weight: 600; }

.th-score__dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.th-score__login { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-score__value { color: #fff; font-variant-numeric: tabular-nums; }

.th-score__mark {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(95, 101, 220, .22);
    font-size: 10px;
    color: #c3c6f5;
    white-space: nowrap;
}

.th-score__mark--barrel { background: rgba(227, 192, 74, .2); color: #e3c04a; }
.th-score__mark--dim { background: rgba(255, 255, 255, .06); color: #8a8a95; }

/* ---------- Лента событий ---------- */

.th-log {
    max-height: 190px;
    overflow-y: auto;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, .32);
    font-size: 12px;
    line-height: 1.5;
    color: #8a8a95;
}

.th-log__row {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 3px 6px 3px 8px;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
    background: rgba(255, 255, 255, .02);
}

.th-log__row i { flex: 0 0 auto; margin-top: 1px; font-size: 14px; }
.th-log__row span { min-width: 0; word-break: break-word; }

.th-log__row--dim  i { color: #6c6c78; }
.th-log__row--good i { color: #5cb85c; }
.th-log__row--bad  i { color: #e05252; }
.th-log__row--warn i { color: #e3a54a; }
.th-log__row--gold i { color: #e3c04a; }
.th-log__row--own  i { color: #7a80ea; }

.th-log__row--gold { background: rgba(227, 192, 74, .08); color: #d8cfae; }
.th-log__row--bad  { color: #d6a7a7; }

/* ---------- Чат ---------- */

.th-chat {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .07);
    background: rgba(0, 0, 0, .22);
    overflow: hidden;
}

.th-chat__head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    font-size: 12px;
    color: #8a8a95;
}

.th-chat__rows {
    height: 130px;
    overflow-y: auto;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
}

.th-chat__row { margin-bottom: 5px; color: #d6d6de; word-break: break-word; }
.th-chat__empty { padding-top: 34px; text-align: center; font-size: 12px; color: #6c6c78; }

.th-chat__form {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.th-chat__input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 13px;
}

.th-chat__input:focus { outline: none; border-color: rgba(95, 101, 220, .6); }

.th-chat__send {
    flex: 0 0 auto;
    width: 36px;
    border: none;
    border-radius: 8px;
    background: var(--btn-wallet-color);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.th-chat__send:hover { background: var(--btn-wallet-color-hover); }

/* ---------- Приглашение ---------- */

.th-invite {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(95, 101, 220, .35);
    background: rgba(95, 101, 220, .08);
}

.th-invite__label { margin-bottom: 6px; font-size: 12px; color: #8a8a95; }

.th-invite__input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(0, 0, 0, .3);
    color: #fff;
    font-size: 12px;
}

.th-invite__chat { width: 100%; margin-top: 8px; }

/* ---------- Окна ---------- */

.th-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, .65);
}

.th-modal.is-open { display: flex; }

.th-modal__box {
    width: 100%;
    max-width: 420px;
    padding: 20px 22px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: var(--card-color);
}

.th-modal__box--wide { max-width: 640px; }

.th-modal__title { margin-bottom: 14px; font-size: 17px; font-weight: 700; color: #fff; }

.th-modal__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}

.th-pass__label { margin-bottom: 10px; font-size: 13px; line-height: 1.45; color: #8a8a95; }

.th-pass__input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(0, 0, 0, .35);
    color: #fff;
    font-size: 14px;
}

.th-pass__input:focus { outline: none; border-color: rgba(95, 101, 220, .6); }
.th-pass__note { margin-top: 8px; font-size: 12px; color: #e07a7a; }

.th-rules { font-size: 13px; line-height: 1.6; color: #a9a9b5; max-height: 60vh; overflow-y: auto; }
.th-rules p { margin: 0 0 10px; }
.th-rules b { color: #fff; }

/* ---------- Итоги раздачи ---------- */

.th-deal { display: grid; gap: 6px; }

.th-deal__row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1fr .7fr .7fr;
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .25);
    font-size: 12px;
    color: #8a8a95;
}

/* Заказчик — главный герой раздачи, его строку и выделяем */
.th-deal__row.is-taker {
    border: 1px solid rgba(95, 101, 220, .4);
    background: rgba(95, 101, 220, .1);
}

.th-deal__login { font-size: 13px; font-weight: 600; color: #fff; }
.th-deal__gain { font-weight: 700; }
.th-deal__gain.is-good { color: #5cb85c; }
.th-deal__gain.is-bad  { color: #e05252; }
.th-deal__score { text-align: right; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- Итоги партии ---------- */

.th-final {
    margin-top: 16px;
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(227, 192, 74, .35);
    background: rgba(227, 192, 74, .07);
    text-align: center;
}

.th-final__title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 16px; }
.th-final__rows { display: grid; gap: 8px; max-width: 420px; margin: 0 auto; }

.th-final__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .28);
    font-size: 14px;
    color: #d6d6de;
}

.th-final__row.is-win { border: 1px solid rgba(227, 192, 74, .5); color: #fff; }
.th-final__row img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.th-final__row span { flex: 1; text-align: left; }
.th-final__actions { margin-top: 18px; }

/* ---------- Узкие экраны ---------- */

@media (max-width: 1100px) {
    .th-layout { grid-template-columns: minmax(0, 1fr); }
}
