/* Дурак VK Mini App — премиум-стол: зелёное сукно, золото, живые карты.
   Тема единая (тёмная) вне зависимости от схемы VK — дизайн-решение. */
:root {
    --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 16px;

    --bg-0: #0b3a24;
    --bg-1: #052013;
    --text: #eef7f0;
    --text-dim: #93b6a3;

    --gold-1: #f6df9c;
    --gold-2: #d4a941;
    --gold-3: #9c7420;

    --felt-0: #12613a;
    --felt-1: #0c4529;
    --felt-edge: #073019;

    --panel: rgba(9, 42, 27, .62);
    --panel-2: rgba(14, 58, 37, .8);
    --panel-border: rgba(120, 200, 150, .28);
    --panel-glow: 0 0 18px rgba(30, 140, 80, .18), inset 0 1px 0 rgba(255,255,255,.05);

    --card-w: 58px;
    --card-h: 82px;

    --red: #d10000;   /* тот же красный, что в портретах фигур — иначе масти спорят */
    --black: #1a2230;

    /* Рубашка карты — часть скина стола (см. [data-skin] ниже). */
    --back-a: #b23b3b;
    --back-b: #8f2a2a;

    --hl: rgba(120, 230, 170, .9);   /* подсветка «можно сыграть» */
    --hl-soft: rgba(120, 230, 170, .5);
    --danger: #e0553f;
    --coach-bg: #123f2a;
    --coach-border: #d4a941;
    --coach-radius: 14px;
    /* Высота панели действий зарезервирована всегда: иначе появление «Беру»/«Бито»
       сжимало стол на 39 px и карты прыгали на каждом ходе. */
    --action-h: 56px;
    --motion-fast: 180ms;
}

/* Глобально гасим выделение текста и системный контекст-меню/колбаут на долгом тапе —
   на игровом поле это выглядит как баг (п.1.6.2.7 десктоп / п.1.6.1.8 моб.), а полей
   ввода в игре нет, так что выделять тут нечего и намеренно. */
* {
    box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}
html, body {
    height: 100%;
    /* Жёстко фиксируем вьюпорт — без этого на моб. Safari/Chrome возможна браузерная
       прокрутка/оттяжка страницы поверх игры (п.1.10.2 требований платформы). */
    overflow: hidden; overscroll-behavior: none; touch-action: none; position: fixed; inset: 0; width: 100%;
}
body { -webkit-user-drag: none; }
body {
    font-family: var(--font);
    color: var(--text);
    font-size: 15px; line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(120% 70% at 50% -10%, rgba(40, 160, 95, .25), transparent 60%),
        radial-gradient(90% 60% at 50% 115%, rgba(20, 100, 60, .18), transparent 60%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1) 72%);
    background-attachment: fixed;
}
.hidden { display: none !important; }
#app { min-height: 100%; height: 100%; display: flex; flex-direction: column; }
.screen {
    flex: 1; display: flex; flex-direction: column;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    animation: screenIn .22s ease;
}
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Игровой экран: строки заданы явно, стол занимает ровно остаток. Ни один блок,
   который появляется по ходу партии, не может изменить его высоту. */
#screen-game {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) var(--action-h) auto auto;
    align-content: stretch;
}

/* ---------- Кошелёк ---------- */
.wallet { width: 100%; max-width: 400px; display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
.wallet-lvl, .wallet-coins { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 12px; padding: 7px 14px; box-shadow: var(--panel-glow); }
.wallet-lvl b, .wallet-coins b { font-size: 15px; font-weight: 800; }
.wallet-coins b { color: var(--gold-1); }
.wallet-ico { font-size: 14px; }

/* ---------- Бонусы ---------- */
.bonus-row { width: 100%; max-width: 400px; display: flex; gap: 10px; margin-top: 12px; }
.bonus-card { flex: 1; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; cursor: pointer; font-family: var(--font); color: var(--text); background: linear-gradient(165deg, rgba(212,169,65,.2), rgba(20,96,58,.5)); border: 1.5px solid rgba(212,169,65,.5); box-shadow: var(--panel-glow); transition: transform .07s ease, opacity .2s; }
.bonus-card:active { transform: scale(.97); }
.bonus-card:disabled { opacity: .5; cursor: default; filter: grayscale(.5); }
.bonus-card.ready { animation: bonusPulse 1.8s ease-in-out infinite; }
@keyframes bonusPulse { 0%,100% { box-shadow: 0 0 0 rgba(212,169,65,0); } 50% { box-shadow: 0 0 16px rgba(212,169,65,.5); } }
.bonus-ico { font-size: 24px; flex: none; }
.bonus-text { display: flex; flex-direction: column; text-align: left; }
.bonus-text b { font-size: 14px; font-weight: 800; }
.bonus-text i { font-size: 11.5px; font-style: normal; color: var(--text-dim); }

/* ---------- Меню ---------- */
/* Меню выше вьюпорта на вебе (широкий/низкий экран) — иначе не долистать до «Как играть».
   Делаем экран прокручиваемым (min-height:0 нужно flex-элементу, чтобы включился overflow). */
/* touch-action:pan-y — точечное исключение из глобального touch-action:none на html/body:
   без него контент меню ниже экрана (кнопка «Как играть») снова станет недостижим на моб. */
#screen-menu {
    align-items: center; justify-content: safe center; gap: 6px; min-height: 0;
    overflow-y: auto; touch-action: pan-y;
    /* Нижняя docking-zone остаётся свободной для системных баблов VK на mobile/iframe. */
    padding-bottom: max(92px, calc(env(safe-area-inset-bottom) + 76px));
    scroll-padding-bottom: max(92px, calc(env(safe-area-inset-bottom) + 76px));
}
.brand { text-align: center; margin-bottom: 10px; }
.brand-cards { position: relative; height: 40px; margin-bottom: 4px; font-size: 30px; }
.brand-cards .bc { display: inline-block; margin: 0 -2px; transform-origin: bottom center; filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); }
.brand-cards .bc-1 { transform: rotate(-16deg) translateY(3px); color: #eef7f0; }
.brand-cards .bc-2 { transform: rotate(-6deg); color: #ff6b6b; }
.brand-cards .bc-3 { transform: rotate(6deg); color: #eef7f0; }
.brand-cards .bc-4 { transform: rotate(16deg) translateY(3px); color: #ff6b6b; }
.menu-title {
    font-size: 52px; font-weight: 800; letter-spacing: 1px;
    background: linear-gradient(180deg, var(--gold-1) 20%, var(--gold-2) 62%, var(--gold-3));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 3px 12px rgba(212, 169, 65, .35));
}
.menu-subtitle {
    font-size: 12px; font-weight: 700; letter-spacing: 2.2px; text-transform: uppercase;
    color: var(--text-dim); margin: -2px 0 20px; text-align: center;
}

.menu-actions { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 10px; }
.mode-card {
    display: flex; align-items: center; gap: 14px; text-align: left;
    font-family: var(--font); color: var(--text); cursor: pointer;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 16px;
    padding: 13px 15px; box-shadow: var(--panel-glow);
    transition: transform .07s ease, border-color .15s ease, box-shadow .15s ease;
}
.mode-card:active { transform: scale(.98); }
.mode-card-primary {
    border-color: rgba(120, 230, 160, .6);
    box-shadow: 0 0 26px rgba(30, 160, 90, .32), inset 0 1px 0 rgba(255,255,255,.08);
    background: linear-gradient(165deg, rgba(20, 96, 58, .7), rgba(9, 42, 27, .7));
}
.mode-card-online { position: relative; border-color: rgba(246,223,156,.7); background: linear-gradient(155deg, rgba(28,115,70,.92), rgba(12,69,41,.78)); }
.mode-text { flex: 1; min-width: 0; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #75f0a7; box-shadow: 0 0 0 5px rgba(117,240,167,.12), 0 0 14px rgba(117,240,167,.8); animation: livePulse 1.5s ease-in-out infinite; }
@keyframes livePulse { 50% { opacity: .55; transform: scale(.86); } }
.mode-icon {
    flex: none; width: 48px; height: 48px; border-radius: 13px; font-size: 24px;
    background: rgba(5, 28, 18, .6); border: 1px solid var(--panel-border);
    display: flex; align-items: center; justify-content: center;
}
.mode-name { display: block; font-size: 16.5px; font-weight: 800; }
.mode-sub { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }

.live-panel { width: 100%; max-width: 400px; margin-top: 12px; padding: 13px; border: 1.5px solid var(--panel-border); border-radius: 16px; background: var(--panel); box-shadow: var(--panel-glow); }
.live-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.live-head > div { display: flex; flex-direction: column; }
.live-head b { font-size: 16px; color: var(--gold-1); }
.mini-action { border: 1px solid var(--panel-border); border-radius: 9px; padding: 7px 10px; color: var(--text); background: rgba(255,255,255,.06); font: 700 11px var(--font); cursor: pointer; }
.live-list { display: flex; flex-direction: column; gap: 6px; }
.live-online { font-size: 12px; margin-bottom: 8px; min-height: 15px; }

/* ---------- Главная ----------
   Шапка вместо крупного логотипа, одно главное действие и настройки в шторке:
   раньше меню занимало 1.84 экрана и выбор режима лежал ниже кнопки «играть». */
.home-top { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 400px; margin: 0 auto 14px; }
.home-brand { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 800; color: var(--gold-1); }
.home-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--panel-2); border: 1.5px solid var(--panel-border); font-size: 15px; }
.home-level { display: flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--panel); border: 1.5px solid var(--panel-border); color: var(--text-dim); font: 700 12px var(--font); cursor: pointer; }
.home-level b { font-size: 15px; color: var(--gold-1); }
.home-right { display: flex; gap: 8px; }
.shop-balance { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: var(--panel-2); border: 1.5px solid var(--panel-border); font-size: 13px; color: var(--text-dim); }
.shop-balance b { font-size: 17px; color: var(--gold-1); }
.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: var(--panel); border: 1.5px solid var(--panel-border); }
.shop-item-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shop-item-copy b { font-size: 14px; }
.shop-item-copy span { font-size: 11.5px; color: var(--text-dim); }
.shop-buy { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--gold-3); background: rgba(212,169,65,.16); color: var(--gold-1); font: 800 13px var(--font); cursor: pointer; white-space: nowrap; }
.shop-buy[disabled] { opacity: .55; cursor: default; }
.shop-note { font-size: 11.5px; color: var(--text-dim); line-height: 1.45; margin: 0; }
.tourney-list { display: flex; flex-direction: column; gap: 8px; }
.tourney-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: var(--panel); border: 1.5px solid var(--panel-border); }
.tourney-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tourney-copy b { font-size: 14px; }
.tourney-copy span { font-size: 11.5px; color: var(--text-dim); }
.tourney-create { display: flex; gap: 8px; }
.tourney-create .btn { flex: 1; margin: 0; }

.play-btn {
    width: 100%; max-width: 400px; margin: 0 auto; min-height: 62px;
    border-radius: 18px; border: 1.5px solid rgba(246,223,156,.55); cursor: pointer;
    background: linear-gradient(165deg, #1f8a52, #12613a);
    color: var(--text); font: 800 20px var(--font); letter-spacing: .01em;
    box-shadow: 0 10px 26px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.12);
}
.play-btn:active { transform: scale(.985); }
.play-config {
    width: 100%; max-width: 400px; margin: 8px auto 0; min-height: 44px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: transparent; border: 0; cursor: pointer;
    color: var(--text-dim); font: 600 12.5px var(--font);
}
.play-config-edit { font-size: 12px; opacity: .8; }
.quick-btn { width: 100%; margin-bottom: 10px; }
.live-links { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 10px; }

/* Шторка настроек */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(3,18,11,.66); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
    width: min(100%, 460px); max-height: 88vh; display: flex; flex-direction: column; gap: 12px;
    padding: 14px 14px max(16px, env(safe-area-inset-bottom));
    background: var(--bg-0); border: 1.5px solid var(--panel-border); border-bottom: 0;
    border-radius: 20px 20px 0 0; box-shadow: 0 -12px 34px rgba(0,0,0,.45);
    animation: sheetIn var(--motion-fast) ease;
}
@keyframes sheetIn { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head b { font-size: 16px; color: var(--gold-1); }
.sheet-body { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.sheet-body .opt-block { margin: 0; }
.sheet-done { margin: 0; }
.ad-notice {
    position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
    background: rgba(3, 18, 11, .82); color: var(--text-dim);
    font: 700 14px var(--font); letter-spacing: .04em; text-align: center; padding: 24px;
}
.mode-card-resume { border-color: var(--gold-3); }
.mode-card-resume .mode-name { color: var(--gold-1); }
.live-offline { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.live-offline .btn { margin: 0; }
.live-table { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 11px; background: rgba(0,0,0,.14); }
.live-avatar, .recent-player i { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: rgba(255,255,255,.08); font-style: normal; }
.live-avatar img, .recent-player img, .opp-ava img, .rp-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.live-copy b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.live-copy span { color: var(--text-dim); font-size: 10.5px; }
.create-table-btn { width: 100%; margin-top: 9px; padding: 10px 14px; font-size: 13px; }
.recent-opponents { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--panel-border); }
.recent-title { display: block; margin-bottom: 6px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; font-size: 9.5px; font-weight: 800; }
.recent-list { display: flex; gap: 7px; overflow: hidden; }
.recent-player { min-width: 0; flex: 1; display: flex; align-items: center; gap: 5px; }
.recent-player i { width: 25px; height: 25px; }
.recent-player b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }

/* Опции (сложность / число игроков) */
.opt-block { width: 100%; max-width: 400px; margin-top: 16px; }
.opt-label { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; text-align: center; }
.seg { display: flex; gap: 6px; background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 14px; padding: 6px; box-shadow: var(--panel-glow); }
.seg-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 9px 4px; border: none; border-radius: 10px; cursor: pointer;
    background: transparent; color: var(--text-dim); font-family: var(--font);
    transition: background .15s, color .15s;
}
.seg-btn .seg-ico { font-size: 17px; }
.seg-btn b { font-size: 13.5px; font-weight: 700; }
.seg-btn.active { background: linear-gradient(165deg, rgba(212,169,65,.28), rgba(156,116,32,.22)); color: var(--gold-1); box-shadow: inset 0 0 0 1px rgba(212,169,65,.4); }

/* Статистика */
.menu-stats {
    display: flex; align-items: stretch; gap: 4px; margin-top: 18px; width: 100%; max-width: 400px;
    background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 14px;
    padding: 12px 8px; box-shadow: var(--panel-glow);
}
.stat-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-item b { font-size: 22px; font-weight: 800; color: var(--gold-1); }
.stat-item span { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.stat-sep { width: 1px; background: var(--panel-border); }
.meta-panel {
    width: 100%; max-width: 400px; margin-top: 16px; padding: 15px;
    background: linear-gradient(165deg, rgba(20,96,58,.7), rgba(7,32,20,.82));
    border: 1.5px solid rgba(212,169,65,.4); border-radius: 16px;
    box-shadow: var(--panel-glow); display: flex; flex-direction: column; gap: 9px;
}
.meta-head, .meta-subhead, .leader-row, .mission-row { display: flex; align-items: center; }
.meta-head { justify-content: space-between; }
.meta-head > div { display: flex; flex-direction: column; }
.meta-kicker, .meta-subhead { color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.2px; font-size: 10px; font-weight: 800; }
.meta-head b { font-size: 18px; color: var(--gold-1); }
.level-badge { padding: 6px 9px; border-radius: 10px; background: rgba(212,169,65,.18); color: var(--gold-1); font-size: 12px; }
.mastery-progress, .mission-bar { overflow: hidden; background: rgba(0,0,0,.25); border-radius: 99px; }
.mastery-progress { height: 7px; }
.mastery-progress i, .mission-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-3), var(--gold-1)); border-radius: inherit; transition: width .25s ease; }
.mastery-caption { color: var(--text-dim); font-size: 10.5px; text-align: right; margin-top: -6px; }
.meta-subhead { justify-content: space-between; margin-top: 4px; }
.meta-subhead small { color: var(--gold-1); font-size: 10px; letter-spacing: 0; }
.mission-list, .leader-list { display: flex; flex-direction: column; gap: 6px; }
.mission-row { gap: 9px; min-height: 32px; }
.mission-check { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--panel-border); color: var(--text-dim); font-size: 11px; }
.mission-row.done .mission-check { color: #062617; background: var(--gold-1); border-color: var(--gold-1); }
.mission-copy { flex: 1; min-width: 0; }
.mission-name { font-size: 12px; font-weight: 700; line-height: 1.25; }
.mission-bar { height: 4px; margin-top: 4px; }
.mission-count { width: 34px; text-align: right; color: var(--text-dim); font-size: 10.5px; }
.leader-row { gap: 8px; padding: 5px 7px; border-radius: 9px; background: rgba(0,0,0,.12); font-size: 11.5px; }
.leader-row.you { background: rgba(212,169,65,.17); color: var(--gold-1); }
.leader-rank { width: 24px; color: var(--text-dim); font-weight: 800; }
.leader-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-weight: 800; }
.meta-muted { color: var(--text-dim); font-size: 11.5px; text-align: center; padding: 4px; }
.help-links { display: flex; gap: 20px; margin-top: 18px; }
.rules-link { min-height: 44px; background: none; border: none; cursor: pointer; color: var(--text-dim); font-family: var(--font); font-size: 14px; font-weight: 700; text-decoration: underline; }
.rules-link:focus-visible, .coach-skip:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* ---------- Шапка игры ---------- */
.game-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.icon-btn {
    flex: none; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
    background: var(--panel); border: 1.5px solid var(--panel-border); color: var(--text);
    font-size: 20px; display: flex; align-items: center; justify-content: center; font-family: var(--font);
}
.icon-btn:active { transform: scale(.94); }
.status { flex: 1; text-align: center; font-weight: 700; font-size: 15px; color: var(--text); }

/* ---------- Соперники ---------- */
.opponents { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; min-height: 62px; margin-bottom: 4px; }
.opp {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 10px 7px; border-radius: 14px; min-width: 76px;
    background: var(--panel); border: 1.5px solid var(--panel-border); box-shadow: var(--panel-glow);
    transition: border-color .2s, box-shadow .2s, opacity .3s;
}
.opp.active { border-color: var(--hl); box-shadow: 0 0 16px rgba(120,230,170,.35), inset 0 1px 0 rgba(255,255,255,.06); }
.opp.defender { border-color: rgba(224,85,63,.7); box-shadow: 0 0 16px rgba(224,85,63,.3); }
.opp.out { opacity: .4; filter: grayscale(.6); }
.opp-ava { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 24px; line-height: 1; }
.opp-name { font-size: 12px; font-weight: 700; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-cards { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-dim); font-weight: 700; }
.opp-cards .mini-back {
    display: inline-block; width: 11px; height: 15px; border-radius: 2px;
    background: repeating-linear-gradient(45deg, #b23b3b 0 3px, #8f2a2a 3px 6px); border: .5px solid rgba(255,255,255,.35);
}
.opp-role { position: absolute; top: -8px; right: -6px; font-size: 13px; background: var(--bg-1); border-radius: 50%; padding: 1px 3px; border: 1px solid var(--panel-border); }
.opp-thinking .opp-ava { animation: bob 1s ease-in-out infinite; }

/* Компактные соперники для стола на 3–4: плашки в одну строку, чтобы стол не терял высоту. */
.opponents.compact { gap: 6px; flex-wrap: nowrap; }
.opponents.compact .opp { min-width: 0; flex: 1 1 0; padding: 5px 6px 6px; border-radius: 12px; }
.opponents.compact .opp-ava { width: 24px; height: 24px; font-size: 19px; }
.opponents.compact .opp-name { font-size: 10.5px; max-width: 100%; }
.opponents.compact .opp-cards { font-size: 10px; gap: 2px; }
.opponents.compact .opp-cards .mini-back { width: 7px; height: 11px; }
.opponents.compact .opp-role { font-size: 11px; top: -7px; right: -4px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------- Стол ---------- */
.table-felt {
    position: relative; flex: 1; margin: 4px 0; border-radius: 22px; overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 40%, var(--felt-0), var(--felt-1) 70%, var(--felt-edge));
    border: 2px solid rgba(0,0,0,.35);
    box-shadow: inset 0 0 60px rgba(0,0,0,.4), inset 0 0 0 6px rgba(212,169,65,.12), 0 8px 24px rgba(0,0,0,.35);
    display: flex; align-items: center; justify-content: center;
    min-height: 200px;
    /* Стол не шире двух своих высот (требование площадок и просто здравый смысл:
       иначе он превращается в пустую полосу сукна). Пропорцию держит aspect-ratio,
       а высоту задаёт строка грида: ширина подстраивается сама. Уже, чем 2:1, стол
       быть может — на вертикальном телефоне это нормально. */
    height: 100%;
    width: auto;
    aspect-ratio: 2 / 1;
    max-width: 100%;
    align-self: stretch;
    justify-self: center;
    margin-inline: auto;
}
.table-felt::before {
    content: ''; position: absolute; inset: 12px; border-radius: 16px;
    border: 1.5px dashed rgba(212,169,65,.22); pointer-events: none;
    z-index: 1;
}
/* Ткань сукна: мелкое зерно поверх градиента и мягкий свет сверху. Шум — inline-SVG
   (feTurbulence), внешних файлов нет; лежит под картами и не ловит нажатия. */
.table-felt::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background-image:
        radial-gradient(80% 55% at 50% -6%, rgba(255,255,255,.10), transparent 70%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    background-size: auto, 140px 140px;
    opacity: .5;
    mix-blend-mode: soft-light;
}
/* Зерно не должно съедать батарею на слабых устройствах и мешать «уменьшенной анимации». */
@media (prefers-reduced-motion: reduce) { .table-felt::after { opacity: .35; } }

/* Колода + козырь (левый край стола) */
.deck-zone { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: calc(var(--card-w) + 52px); height: var(--card-h); }
/* Козырь лежит под колодой поперёк и должен ЧИТАТЬСЯ: из-под рубашки выступает верхний
   угол с рангом и мастью. Раньше карта пряталась под колодой почти целиком, и какой
   козырь в партии, приходилось смотреть по бейджу масти. */
.trump-card {
    position: absolute; left: calc(var(--card-w) * 0.57); top: 0;
    width: var(--card-w); height: var(--card-h);
    transform: rotate(90deg); transform-origin: 50% 50%;
}
.deck-pile {
    position: absolute; left: 0; top: 0; z-index: 2; width: var(--card-w); height: var(--card-h);
    border-radius: 8px; background: repeating-linear-gradient(48deg, #b23b3b 0 7px, #8f2a2a 7px 14px);
    border: 1.5px solid rgba(255,255,255,.4);
    box-shadow: 2px 0 0 rgba(255,255,255,.12), 3px 2px 6px rgba(0,0,0,.4), inset 0 0 0 3px rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
}
.deck-count {
    position: relative; z-index: 2; min-width: 30px; padding: 2px 7px; border-radius: 9px;
    background: rgba(0,0,0,.45); font-size: 19px; font-weight: 800; color: #fff; text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
}
/* Бейдж масти козыря — всегда виден (в т.ч. когда колода кончилась) */
.trump-badge {
    position: absolute; left: -8px; bottom: -8px; z-index: 3;
    width: 26px; height: 26px; border-radius: 50%;
    background: #fbf6e6; border: 2px solid var(--gold-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; line-height: 1; color: #1a2230;
    box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.trump-badge.red { color: var(--red); }
.deck-pile.empty { background: rgba(0,0,0,.18); border-style: dashed; border-color: rgba(212,169,65,.3); box-shadow: none; }
.deck-pile.empty .deck-count { display: none; }

/* Отбой (правый край) */
.discard-zone {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%) rotate(-8deg);
    width: var(--card-w); height: var(--card-h); border-radius: 8px;
    background: rgba(0,0,0,.16); border: 1.5px dashed rgba(255,255,255,.14);
    display: flex; align-items: center; justify-content: center; color: var(--text-dim);
}
/* Отбой — та же рубашка, что и колода: раньше у него был свой полосатый узор,
   и на столе оказывались две разные «спины» карт. */
.discard-zone.has::after {
    content: ''; position: absolute; inset: 0; border-radius: 8px;
    background: repeating-linear-gradient(48deg, var(--back-a) 0 7px, var(--back-b) 7px 14px);
    filter: brightness(.82);
    border: 1.5px solid rgba(255,255,255,.3); box-shadow: -2px 0 0 rgba(0,0,0,.25);
}
.discard-zone.has .back-pattern { z-index: 1; opacity: .75; }
.discard-count { min-width: 26px; padding: 1px 6px; border-radius: 8px; background: rgba(0,0,0,.45); }
/* Подписи пустых зон: пустой прямоугольник на сукне читается как недорисованный. */
.deck-pile.empty::after, .discard-zone:not(.has)::after {
    content: attr(data-label); position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: rgba(255,255,255,.32); text-align: center; padding: 0 4px;
}
.discard-count { position: relative; z-index: 2; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.7); }

/* Куча боя — пары атака/защита */
.battle {
    display: flex; flex-wrap: wrap; gap: 5px 8px; align-items: center; justify-content: center;
    /* Зона боя живёт между колодой слева и отбоем справа: без этих отступов пары
       наезжали на колоду, а на столе из четверых карт бывает до шести. */
    max-width: min(78%, 320px); padding: 0 6px; z-index: 2;
    margin-left: calc(var(--card-w) * 0.9);
    margin-right: calc(var(--card-w) * 0.2);
}
.battle.crowded { max-width: min(58%, 240px); }
.pair { position: relative; width: var(--card-w); height: var(--card-h); }
.pair .card.def {
    position: absolute; left: 10px; top: 12px; transform: rotate(7deg);
    box-shadow: -2px 2px 6px rgba(0,0,0,.4);
}
.pair.new-attack { animation: drop .22s ease; }
@keyframes drop { from { transform: translateY(-18px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
/* Ход соперника/бота подсвечивается мягким золотым свечением на карте — видно, что стол
   изменился не по моей воле. Свой ход (my-move) остаётся без рамки — он и так под пальцем. */
.pair.opp-move .card { animation: oppMoveGlow .7s ease; }
@keyframes oppMoveGlow {
    0% { box-shadow: 0 0 0 3px rgba(212,169,65,.9), 0 2px 5px rgba(0,0,0,.28); }
    100% { box-shadow: 0 2px 5px rgba(0,0,0,.28), inset 0 0 0 1.5px rgba(255,255,255,.7); }
}
/* «Бито/беру»: карты держатся ~0.5с, затем уезжают (в отбой вправо / к игроку вниз). */
.battle.to-discard .pair { animation: settleDiscard .95s ease forwards; }
.battle.to-take .pair { animation: settleTake .95s ease forwards; }
@keyframes settleDiscard { 0%,52% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(120px, -8px) scale(.7) rotate(10deg); } }
@keyframes settleTake { 0%,52% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(70px) scale(.7); } }
.table-hint {
    position: absolute; bottom: 8px; left: 0; right: 0; text-align: center;
    font-size: 12px; font-weight: 700; color: rgba(255,255,255,.75); text-shadow: 0 1px 3px rgba(0,0,0,.6); z-index: 3;
    pointer-events: none;
}

/* ---------- Карта ---------- */
.card {
    width: var(--card-w); height: var(--card-h); border-radius: 8px; position: relative;
    user-select: none; flex: none;
}
.card.face {
    background: linear-gradient(160deg, #ffffff, #f2f0e8);
    border: 1px solid rgba(0,0,0,.28);
    box-shadow: 0 2px 5px rgba(0,0,0,.28), inset 0 0 0 1.5px rgba(255,255,255,.7);
    color: var(--black);
}
.card.face.red { color: var(--red); }
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: .92; font-weight: 800; }
.card .corner.tl { left: 4px; top: 3px; }
.card .corner.br { right: 4px; bottom: 3px; transform: rotate(180deg); }
.card .c-rank { font-size: 14px; }
.card .c-suit { font-size: 12px; }
.card .center { position: absolute; inset: 15px 6px; }
.card .pip { position: absolute; transform: translate(-50%, -50%); font-size: 15px; }
.card .pip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.card .ace { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 34px; }
.card .court {
    position: absolute; inset: 0; border: 1.5px solid currentColor; border-radius: 4px; opacity: .92;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.card .court b { font-size: 24px; font-weight: 800; line-height: 1; }
.card .court i { font-size: 18px; font-style: normal; }
.card.is-trump { box-shadow: 0 2px 5px rgba(0,0,0,.28), 0 0 0 2px var(--gold-2), inset 0 0 0 1.5px rgba(255,255,255,.7); }

/* Набор «крупный индекс»: ранг во всю карту. На столе из четверых карта втрое мельче,
   и мелкие пипсы там не читаются. */
.card.bold .center { display: grid; place-items: center; gap: 1px; inset: 14px 6px 8px; }
.card.bold .big-rank { font-size: calc(var(--card-h) * 0.42); font-weight: 900; line-height: .85; letter-spacing: -.02em; }
.card.bold .big-suit { font-size: calc(var(--card-h) * 0.24); line-height: 1; }
.card.bold .corner.br { display: none; }

/* Набор «фигуры»: свои силуэты вместо буквы у В/Д/К. */
.card .court-art { width: 100%; height: 100%; }
.card.art .center { inset: 13px 5px 12px; }
.card.art .court { border: 0; opacity: 1; display: block; }
/* Портрет тянем абсолютом, а не процентами в гриде: в auto-строке height:100% считается
   от контента, и картинка вылезала за нижнюю кромку карты. */
.card .court-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* Страховка, когда портрет не доехал: карта не должна остаться пустой. */
.card .court.court-fallback { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border: 1.5px solid currentColor; border-radius: 4px; }
.card .court.court-fallback b { font-size: 24px; font-weight: 800; line-height: 1; }
.card .court.court-fallback i { font-size: 18px; font-style: normal; }
.card.figured .center { inset: 12px 5px; }
.card.figured .court { border: 0; display: grid; place-items: center; opacity: 1; }

.card.back {
    background: repeating-linear-gradient(48deg, var(--back-a) 0 7px, var(--back-b) 7px 14px);
    border: 1.5px solid rgba(255,255,255,.42);
    box-shadow: 0 2px 5px rgba(0,0,0,.3), inset 0 0 0 3px rgba(255,255,255,.1);
}
.card.back .back-pattern, .deck-pile .back-pattern {
    position: absolute; inset: 6px; border-radius: 4px; border: 1px solid rgba(255,255,255,.28);
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.12), transparent 60%);
}
/* Рисунок рубашки. Узор отдельно от цвета: цвет задаёт скин стола, узор — выбор игрока. */
html[data-back="grid"] .card.back .back-pattern, html[data-back="grid"] .deck-pile .back-pattern {
    background-image:
        repeating-linear-gradient(0deg, rgba(255,255,255,.22) 0 1px, transparent 1px 8px),
        repeating-linear-gradient(90deg, rgba(255,255,255,.22) 0 1px, transparent 1px 8px);
}
html[data-back="rhomb"] .card.back .back-pattern, html[data-back="rhomb"] .deck-pile .back-pattern {
    background-image:
        repeating-linear-gradient(45deg, rgba(255,255,255,.2) 0 1px, transparent 1px 9px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,.2) 0 1px, transparent 1px 9px);
}
html[data-back="stars"] .card.back .back-pattern, html[data-back="stars"] .deck-pile .back-pattern {
    background-image:
        radial-gradient(circle at 25% 25%, rgba(255,255,255,.3) 1.4px, transparent 1.6px),
        radial-gradient(circle at 75% 75%, rgba(255,255,255,.3) 1.4px, transparent 1.6px);
    background-size: 14px 14px;
}
html[data-back="mono"] .card.back .back-pattern::after, html[data-back="mono"] .deck-pile .back-pattern::after {
    content: '♠'; position: absolute; inset: 0; display: grid; place-items: center;
    font-size: calc(var(--card-h) * 0.32); color: rgba(255,255,255,.7);
}

/* ---------- Скины стола ----------
   Косметика Лиги: меняются только сукно и рубашка, читаемость карт не трогаем.
   Открываются по уровню мастерства, за деньги ничего не продаётся. */
html[data-skin="night"] {
    --felt-0: #1b3a63; --felt-1: #12274a; --felt-edge: #0a1730;
    --back-a: #35508c; --back-b: #22355f;
}
html[data-skin="royal"] {
    --felt-0: #5e2233; --felt-1: #3f1523; --felt-edge: #290d17;
    --back-a: #d4a941; --back-b: #9c7420;
}
html[data-skin="graphite"] {
    --felt-0: #33393f; --felt-1: #22272c; --felt-edge: #14181b;
    --back-a: #4a8f86; --back-b: #2f625c;
}

.skin-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.skin-tile {
    position: relative; width: 66px; padding: 7px 0 6px; border-radius: 12px;
    border: 1.5px solid var(--panel-border); background: var(--panel-2);
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    color: var(--text-dim); font-size: 10px; font-weight: 700; cursor: pointer;
}
.skin-tile.active { border-color: var(--gold-2); color: var(--gold-1); box-shadow: 0 0 0 1px var(--gold-3); }
.skin-tile.locked { opacity: .55; cursor: default; }
.skin-swatch { width: 34px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.35); position: relative; overflow: hidden; }
.skin-swatch i { position: absolute; right: 3px; top: 3px; width: 11px; height: 16px; border-radius: 2px; border: 1px solid rgba(255,255,255,.5); }
.skin-lock { font-size: 9px; }
.back-preview { width: 26px; height: 34px; border-radius: 5px; position: relative; overflow: hidden;
    background: repeating-linear-gradient(48deg, var(--back-a) 0 5px, var(--back-b) 5px 10px);
    border: 1px solid rgba(255,255,255,.45); }
.back-preview[data-pattern="grid"] {
    background-image:
        repeating-linear-gradient(0deg, rgba(255,255,255,.3) 0 1px, transparent 1px 6px),
        repeating-linear-gradient(90deg, rgba(255,255,255,.3) 0 1px, transparent 1px 6px),
        repeating-linear-gradient(48deg, var(--back-a) 0 5px, var(--back-b) 5px 10px);
}
.back-preview[data-pattern="rhomb"] {
    background-image:
        repeating-linear-gradient(45deg, rgba(255,255,255,.28) 0 1px, transparent 1px 7px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,.28) 0 1px, transparent 1px 7px),
        repeating-linear-gradient(48deg, var(--back-a) 0 5px, var(--back-b) 5px 10px);
}
.back-preview[data-pattern="stars"] {
    background-image:
        radial-gradient(circle at 25% 25%, rgba(255,255,255,.4) 1px, transparent 1.2px),
        radial-gradient(circle at 75% 75%, rgba(255,255,255,.4) 1px, transparent 1.2px),
        repeating-linear-gradient(48deg, var(--back-a) 0 5px, var(--back-b) 5px 10px);
    background-size: 10px 10px, 10px 10px, auto;
}
.back-preview[data-pattern="mono"]::after {
    content: '♠'; position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 14px; color: rgba(255,255,255,.8);
}

/* ---------- Панель действий ---------- */
.action-bar { display: flex; gap: 8px; align-items: center; justify-content: center; min-height: var(--action-h); }
/* Высоту панели держит min-height, поэтому скрытые кнопки можно убирать из потока:
   иначе они занимали ширину и сдвигали видимую кнопку от центра. */

/* Контекстный наставник: часть игрового стола, а не блокирующая модалка. */
.coach {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 3;
    width: min(94%, 520px); min-height: 52px;
    display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px;
    padding: 7px 8px; border: 1.5px solid var(--coach-border); border-radius: var(--coach-radius);
    background: var(--coach-bg); box-shadow: 0 8px 22px rgba(0,0,0,.28);
    animation: coachIn var(--motion-fast) ease;
}
@keyframes coachIn {
    from { opacity: 0; transform: translate(-50%, 5px); }
    to { opacity: 1; transform: translateX(-50%); }
}
.coach-step {
    width: 34px; height: 42px; display: grid; place-items: center; border-radius: 6px;
    border: 1.5px solid rgba(246,223,156,.8); background: #f4f1e7; color: #17432d;
    font-size: 11px; font-weight: 900; box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.coach-copy { min-width: 0; font-size: 12px; font-weight: 700; line-height: 1.3; text-align: left; }
.coach-skip { min-width: 76px; min-height: 44px; padding: 0 9px; border: 0; background: transparent; color: var(--text-dim); font: 700 11px var(--font); cursor: pointer; text-decoration: underline; }

/* ---------- Рука ---------- */
.hand-wrap { min-height: calc(var(--card-h) + 20px); display: flex; align-items: flex-end; justify-content: center; padding-top: 6px; }
.hand { display: flex; justify-content: center; align-items: flex-end; padding: 0 8px; min-height: var(--card-h); }
.hand .card {
    margin-left: -18px; transition: transform .14s ease, margin .14s ease;
    cursor: default; box-shadow: 0 3px 7px rgba(0,0,0,.35), inset 0 0 0 1.5px rgba(255,255,255,.7);
}
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
    box-shadow: 0 0 0 7px rgba(120,230,170,.45), 0 3px 7px rgba(0,0,0,.35);
}
.hand .card.playable::after {
    content: ''; position: absolute; inset: -2px; border-radius: 9px; border: 2px solid var(--hl); box-shadow: 0 0 12px var(--hl-soft); pointer-events: none;
}
.hand .card.playable:active, .hand .card.sel { transform: translateY(-16px); }
.hand .card.dimmed { opacity: .5; filter: saturate(.7); }
.hand.tight .card { margin-left: -26px; }
.hand.dense .card { margin-left: -34px; }
/* Совсем большая рука: сжимать нахлёстом уже некуда — уменьшаем сами карты. */
.hand.packed { --card-w: 46px; --card-h: 65px; }
.hand.packed .card { margin-left: -28px; }
.hand.packed .card .c-rank { font-size: 11px; }
.hand.packed .card .c-suit { font-size: 9px; }
.hand.tight .card:first-child,
.hand.dense .card:first-child,
.hand.packed .card:first-child { margin-left: 0; }
/* Раздача: карты въезжают снизу со сдвигом по времени */
.hand.dealing .card { animation: dealIn .32s cubic-bezier(.34,.9,.3,1) backwards; }
@keyframes dealIn { from { transform: translateY(40px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Реакции ---------- */
.react-row { display: flex; gap: 8px; justify-content: center; margin: 8px 0 2px; flex-wrap: wrap; }
.react-btn { width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--panel-border); background: var(--panel); color: var(--text); font-family: var(--font); font-size: 21px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.react-btn.react-phrase { width: auto; height: 36px; padding: 0 10px; font-size: 11px; font-weight: 800; }
.react-btn:active { transform: scale(.9); }
.react-float { position: fixed; left: 50%; top: 44%; transform: translate(-50%, -50%); font-size: 74px; z-index: 40; pointer-events: none; filter: drop-shadow(0 6px 16px rgba(0,0,0,.5)); }
.react-float.pop { animation: reactPop 1.6s ease forwards; }
.react-float.opp { top: 26%; }
.react-float.phrase { max-width: min(320px, 80vw); padding: 12px 18px; border-radius: 18px; background: rgba(5,28,18,.96); border: 1.5px solid var(--gold-2); color: var(--text); font-size: 18px; font-weight: 800; text-align: center; }
@keyframes reactPop { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); } 18% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); } 70% { opacity: 1; transform: translate(-50%,-60%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-90%) scale(.9); } }

#resign-btn { border-color: rgba(224,85,63,.5); background: rgba(224,85,63,.12); font-size: 17px; }

/* ---------- Кнопки ---------- */
.btn { font-family: var(--font); font-weight: 800; font-size: 16px; border: none; border-radius: 14px; padding: 14px 22px; cursor: pointer; color: #fff; transition: transform .07s ease, filter .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(165deg, #1f9d5c, #12613a); box-shadow: 0 6px 18px rgba(20,120,70,.4), inset 0 1px 0 rgba(255,255,255,.2); }
.btn-gold { background: linear-gradient(165deg, var(--gold-1), var(--gold-2) 70%, var(--gold-3)); color: #3a2c07; box-shadow: 0 6px 18px rgba(212,169,65,.35), inset 0 1px 0 rgba(255,255,255,.4); }
.btn-danger { background: linear-gradient(165deg, #e56a54, #b3341f); box-shadow: 0 6px 18px rgba(200,60,40,.35), inset 0 1px 0 rgba(255,255,255,.2); }
.btn-secondary { background: var(--panel-2); border: 1.5px solid var(--panel-border); font-size: 14px; padding: 11px 16px; }
.btn-ghost { background: none; color: var(--text-dim); font-weight: 700; font-size: 14px; padding: 8px; }
.action-bar .btn { padding: 12px 26px; }

/* ---------- Комната ---------- */
.room-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 10px; max-width: 400px; margin: 0 auto; width: 100%; }
.room-code-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.room-illus { font-size: 60px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.room-code-label { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); }
.room-code { font-size: 40px; font-weight: 800; letter-spacing: 8px; color: var(--gold-1); background: none; border: none; font-family: var(--font); cursor: pointer; text-shadow: 0 2px 10px rgba(212,169,65,.35); }
.room-hint { font-size: 12px; color: var(--text-dim); margin-top: -6px; }
.room-players { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.room-player { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1.5px solid var(--panel-border); min-width: 68px; }
.room-player.empty { opacity: .45; border-style: dashed; }
.room-player .rp-ava { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 22px; }
.room-player .rp-name { max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; }
.room-status { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 13px; }
.room-spinner { width: 15px; height: 15px; border: 2px solid var(--panel-border); border-top-color: var(--gold-1); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.room-body .btn { width: 100%; max-width: 320px; }

/* ---------- Оверлеи ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(3, 18, 11, .72); backdrop-filter: blur(4px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay-card { width: 100%; max-width: 360px; max-height: calc(100dvh - 24px); overflow-y: auto; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1.5px solid var(--panel-border); border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5), var(--panel-glow); display: flex; flex-direction: column; gap: 12px; }
.overlay-emoji { font-size: 60px; }
.overlay-title { font-size: 26px; font-weight: 800; color: var(--gold-1); }
.overlay-sub { font-size: 14px; color: var(--text-dim); margin-top: -6px; }
.overlay-score { font-size: 14px; color: var(--text-dim); font-weight: 700; }
.result-highlights { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-highlights > div { min-width: 0; padding: 9px 7px; border: 1px solid rgba(212,169,65,.34); border-radius: 12px; background: rgba(212,169,65,.08); }
.result-highlights span { display: block; color: var(--text-dim); font-size: 10px; line-height: 1.2; }
.result-highlights b { display: block; margin-top: 3px; color: var(--gold-1); font-size: 14px; line-height: 1.2; overflow-wrap: anywhere; }
.result-details { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.15); text-align: left; }
.result-details > div { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; }
.result-details span { color: var(--text-dim); }
.result-details b { max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.rematch-status { color: var(--text-dim); font-size: 11.5px; }
.share-row { display: flex; gap: 8px; }
.share-row .btn { flex: 1; }
.rules-card { text-align: left; }
.rules-card .overlay-title { text-align: center; }
.rules-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.achv-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.achv-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border: 1.5px solid var(--panel-border); }
.achv-item.done { border-color: var(--gold-3); }
.achv-ico { font-size: 18px; width: 22px; text-align: center; }
.achv-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.achv-copy b { font-size: 13px; font-weight: 700; }
.achv-item:not(.done) .achv-copy b { color: var(--text-dim); }
.achv-copy span { font-size: 11px; color: var(--text-dim); }
.achv-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,.12); margin-top: 5px; overflow: hidden; }
.achv-bar i { display: block; height: 100%; background: var(--gold-2); }
.rules-list li { position: relative; padding-left: 26px; font-size: 14px; color: var(--text); }
.rules-list li::before { content: '🃏'; position: absolute; left: 0; top: 0; }

/* ---------- Тост ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(5, 28, 18, .95); border: 1.5px solid var(--panel-border); color: var(--text); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90%; text-align: center; }

/* ---------- Адаптив ---------- */
@media (min-width: 430px) { :root { --card-w: 64px; --card-h: 90px; } }
@media (max-height: 680px) { :root { --card-w: 52px; --card-h: 74px; } .menu-title { font-size: 44px; } }
@media (max-height: 600px) {
    :root { --action-h: 48px; }
    .opponents { min-height: 54px; }
    .brand-cards { display: none; }
    .coach { min-height: 46px; padding-block: 3px; bottom: 6px; }
    .coach-copy { font-size: 11px; }
}
@media (max-height: 440px) { .overlay { align-items: flex-start; overflow-y: auto; padding-block: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-bottom)); } .overlay-card { margin: auto; padding: 16px; gap: 8px; } .overlay-emoji { font-size: 38px; } .overlay-title { font-size: 22px; } }

/* Альбомная ориентация телефона: высоты мало, всё ужимаем — иначе рука уезжает
   за нижнюю кромку, а стол превращается в полосу. */
@media (max-height: 460px) {
    :root { --card-w: 40px; --card-h: 57px; --action-h: 40px; }
    .screen { padding-block: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-bottom)); }
    .game-header { margin-bottom: 4px; }
    .icon-btn { width: 34px; height: 34px; font-size: 17px; }
    .status { font-size: 13px; }
    /* Селекторы с .opponents.compact — иначе правила компактного стола на 3–4
       перебивают эти по специфичности, и плашки остаются высокими. */
    .opponents, .opponents.compact { min-height: 0; margin-bottom: 2px; gap: 5px; }
    .opponents .opp, .opponents.compact .opp { padding: 2px 6px 3px; gap: 0; min-width: 0; }
    .opponents .opp-ava, .opponents.compact .opp-ava { width: 18px; height: 18px; font-size: 14px; }
    .opponents .opp-name, .opponents.compact .opp-name { font-size: 9px; }
    .opponents .opp-cards, .opponents.compact .opp-cards { font-size: 9px; }
    /* Мини-рубашки в плашке соперника съедали высоту, которой не хватало столу:
       в альбомной ориентации оставляем только счётчик карт. */
    .opponents .opp-cards .mini-back, .opponents.compact .opp-cards .mini-back { display: none; }
    .opponents .opp-cards::before { content: '🂠'; font-size: 10px; opacity: .75; }
    /* 300×150 — ровно два к одному при карте 42 px: колода с козырем, бой на две пары
       и отбой умещаются, а стол не превращается в растянутую полосу. */
    .table-felt { min-height: 130px; margin: 2px 0; border-radius: 14px; }
    .battle { margin-left: calc(var(--card-w) * 1.9); margin-right: 0; max-width: 42%; }
    /* Подсказку уводим на пустое поле справа от стола: в альбомной ориентации она
       перекрывала карты боя. */
    .coach {
        position: fixed; left: auto; right: 10px; top: 50%; bottom: auto;
        transform: translateY(-50%); width: min(220px, 32vw);
        grid-template-columns: 26px minmax(0, 1fr);
        grid-template-areas: 'step copy' 'skip skip';
        row-gap: 4px; padding: 6px 8px;
    }
    .coach-step { grid-area: step; }
    .coach-copy { grid-area: copy; }
    .coach-skip { grid-area: skip; justify-self: end; min-height: 30px; }
    @keyframes coachIn { from { opacity: 0; transform: translateY(-46%); } to { opacity: 1; transform: translateY(-50%); } }
    .deck-zone { left: 8px; width: calc(var(--card-w) + 38px); }
    .discard-zone { right: 8px; }
    .hand-wrap { padding-top: 0; }
    .table-felt::before { inset: 7px; border-radius: 10px; }
    .hand-wrap { min-height: calc(var(--card-h) + 4px); }
    .coach { min-height: 38px; bottom: 4px; padding-block: 2px; }
    .coach-step { width: 26px; height: 30px; font-size: 9px; }
    .coach-copy { font-size: 10px; }
    .coach-skip { min-width: 58px; min-height: 36px; font-size: 10px; }
    .action-bar .btn { padding: 8px 16px; font-size: 13px; min-height: 38px; }
    .deck-count { font-size: 15px; }
}

/* Оверлеи на низких экранах: содержимое скроллится, кнопка всегда на виду —
   именно на этом ловила модерация («Понятно» уходила за нижнюю кромку). */
@media (max-height: 520px) {
    .overlay-card { max-height: calc(100dvh - 16px); padding: 14px; }
    .rules-list, .achv-list { max-height: 42vh; overflow-y: auto; }
    .overlay-card > .btn:last-child {
        position: sticky; bottom: 0; margin-top: 4px;
        box-shadow: 0 -10px 14px -8px rgba(0,0,0,.55);
    }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
