/* ============================================
   Дуракъ — стиль карточного салона
   ============================================ */

:root {
  --felt-1: #1c4a30;
  --felt-2: #0f2e1d;
  --felt-edge: #061509;
  --mahogany: #3d1f12;
  --mahogany-light: #5a3220;
  --gold: #c9a961;
  --gold-bright: #e8c878;
  --ivory: #ebe0c2;
  --ivory-dim: #b9ad8c;
  --card-cream: #f4e8d0;
  --card-cream-edge: #d8c89d;
  --ink: #1a1410;
  --ink-red: #a82828;
  --danger: #b34040;

  --font-display: "Yeseva One", "Times New Roman", serif;
  --font-body: "Caudex", "Georgia", serif;

  --shadow-card: 0 2px 4px rgba(0,0,0,0.4), 0 8px 16px rgba(0,0,0,0.25);
  --shadow-lift: 0 4px 10px rgba(0,0,0,0.5), 0 16px 30px rgba(0,0,0,0.4);
  --shadow-panel: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ivory);
  background:
    radial-gradient(ellipse at top, #1f3d2a 0%, #0a1f12 60%, var(--felt-edge) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Зерно поверх всего — лёгкая фактура сукна */
.grain {
  pointer-events: none;
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.4'/></svg>");
  opacity: 0.18;
  mix-blend-mode: overlay;
  z-index: 9999;
}

/* ---------- Экраны ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  animation: fadeUp 0.4s ease both;
}
.screen.active { display: flex; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Логин ---------- */
#screen-login {
  align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, rgba(60,30,15,0.85), rgba(30,15,8,0.85));
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 48px 36px 36px;
  box-shadow: var(--shadow-panel);
  position: relative;
}
.login-card::before {
  content: ''; position: absolute; inset: 8px;
  border: 1px solid rgba(201,169,97,0.3);
  pointer-events: none;
  border-radius: 2px;
}
.brand {
  font-family: var(--font-display);
  font-size: 64px;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 rgba(0,0,0,0.5), 0 0 30px rgba(232,200,120,0.2);
  margin-bottom: 4px;
}
.brand-sub {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 11px;
  color: var(--ivory-dim);
  text-transform: uppercase;
  margin-bottom: 32px;
}

/* ---------- Поля и кнопки ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 11px; letter-spacing: 0.25em;
  text-transform: uppercase; color: var(--ivory-dim); margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,169,97,0.4);
  color: var(--ivory);
  padding: 10px 12px;
  font-family: var(--font-body); font-size: 16px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s;
}
.field input:focus, .field select:focus { border-color: var(--gold); }

.btn {
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 10px 22px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold-bright);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
  position: relative;
}
.btn:hover:not(:disabled) {
  background: rgba(201,169,97,0.1);
  color: var(--ivory);
  box-shadow: 0 0 20px rgba(201,169,97,0.2);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #5a3220, #3d1f12);
  border-color: var(--gold);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6d3d28, #4a2818);
}
.btn-warn { border-color: var(--danger); color: #e8a8a8; }
.btn-warn:hover:not(:disabled) { background: rgba(179,64,64,0.15); }
.btn-ghost { border-color: rgba(201,169,97,0.3); color: var(--ivory-dim); }

#btn-login { width: 100%; padding: 14px; }

/* ---------- Лобби ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(201,169,97,0.2);
  background: rgba(0,0,0,0.25);
}
.brand-small {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
}
.me { color: var(--ivory-dim); font-style: italic; }

.lobby-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  padding: 24px;
  overflow: hidden;
}
.panel {
  background: linear-gradient(180deg, rgba(40,25,15,0.7), rgba(20,12,8,0.7));
  border: 1px solid rgba(201,169,97,0.3);
  border-radius: 4px;
  padding: 24px;
  box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  color: var(--gold);
  margin-bottom: 16px;
  letter-spacing: 0.04em;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin-bottom: 0; }

.rooms-list { list-style: none; overflow-y: auto; flex: 1; }
.rooms-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid rgba(201,169,97,0.2);
  border-radius: 2px;
  background: rgba(0,0,0,0.2);
  cursor: pointer;
  transition: all 0.2s;
}
.rooms-list li:hover { border-color: var(--gold); background: rgba(201,169,97,0.05); }
.rooms-list .room-name { font-size: 16px; }
.rooms-list .room-meta { font-size: 11px; color: var(--ivory-dim); letter-spacing: 0.1em; text-transform: uppercase; }
.rooms-list .empty { color: var(--ivory-dim); font-style: italic; text-align: center; padding: 40px 0; cursor: default; }
.rooms-list .empty:hover { border-color: rgba(201,169,97,0.2); background: rgba(0,0,0,0.2); }

/* ---------- Комната (до старта) ---------- */
.room-inner {
  flex: 1; display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px; padding: 24px;
  min-height: 0;
}
.seats-list { list-style: none; margin-bottom: 16px; }
.seats-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-bottom: 1px dashed rgba(201,169,97,0.15);
}
.seat-name { flex: 1; font-size: 16px; }
.seat-badge {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 2px; border: 1px solid;
}
.seat-badge.ready { border-color: var(--gold); color: var(--gold-bright); }
.seat-badge.waiting { border-color: rgba(201,169,97,0.3); color: var(--ivory-dim); }
.seat-badge.offline { border-color: var(--danger); color: #e8a8a8; }

.hint { font-size: 12px; color: var(--ivory-dim); font-style: italic; margin-top: 12px; }

.chat-panel { display: flex; flex-direction: column; }
.chat-log {
  list-style: none; flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(201,169,97,0.15);
  border-radius: 2px;
  min-height: 0;
}
.chat-log li { padding: 4px 10px; font-size: 13px; }
.chat-log li .from { color: var(--gold); margin-right: 6px; }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input input {
  flex: 1; background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,169,97,0.3);
  color: var(--ivory); padding: 8px 10px; border-radius: 2px;
  font-family: var(--font-body); outline: none;
}
.chat-input input:focus { border-color: var(--gold); }

/* ============================================
   ИГРОВОЙ СТОЛ
   ============================================ */
#screen-game { overflow: hidden; }

.table-wrap {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  padding: 16px 24px 12px;
  position: relative;
  /* сине-серое сукно как в rstgames */
  background:
    radial-gradient(ellipse at center, #54667d 0%, #44566c 55%, #36465a 100%);
}

.game-status {
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-bright);
  font-style: italic;
}

/* противники */
.opponents {
  display: flex; justify-content: space-around; align-items: flex-start;
  gap: 20px; min-height: 110px;
}
.opponent {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
  transition: all 0.3s;
  min-width: 140px;
}
.opponent.is-defender {
  border-color: var(--danger);
  box-shadow: 0 0 24px rgba(179,64,64,0.3);
}
.opponent.is-attacker {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(201,169,97,0.3);
}
.opponent.is-done { opacity: 0.4; filter: grayscale(0.5); }
.opponent-name {
  font-size: 15px;
  margin-bottom: 6px;
  display: flex; gap: 6px; align-items: center;
}
.role-tag {
  font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 2px;
}
.role-tag.atk { color: var(--gold-bright); background: rgba(201,169,97,0.15); }
.role-tag.def { color: #e8a8a8; background: rgba(179,64,64,0.2); }

.opponent-hand {
  display: flex; height: 60px;
  position: relative;
}
.opponent-hand .card {
  width: 38px; height: 56px;
  position: absolute;
  transition: transform 0.3s;
}
.opponent-hand .card-count {
  font-size: 11px; color: var(--ivory-dim);
  letter-spacing: 0.1em; margin-top: 2px;
}

/* центр стола */
.table-center {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 24px;
  min-height: 0;
}

.deck-area, .discard-area {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  position: relative; height: 130px;
}

.deck-pile, .discard-pile {
  position: relative;
  width: 72px; height: 104px;
  z-index: 1;
}
/* стопка колоды — несколько карт-рубашек, слегка смещены */
.deck-pile::before, .deck-pile::after {
  content: ''; position: absolute; inset: 0;
  background: var(--card-back-bg, linear-gradient(135deg, #6d2218 0%, #3d1208 50%, #6d2218 100%));
  border: 1.5px solid var(--gold);
  border-radius: 6px;
  box-shadow: var(--shadow-card);
}
.deck-pile::before { transform: translate(-3px, 3px); opacity: 0.7; }
.deck-pile::after  { transform: translate(-1px, 1px); opacity: 0.85; }

/* козырь лежит боком ПОВЕРХ колоды, чтобы было видно */
.trump-card {
  position: absolute;
  top: 52px; left: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  width: 72px; height: 104px;
  z-index: 2;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.45));
}
.trump-card .card { width: 72px; height: 104px; }

.deck-count, .discard-count {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.discard-pile {
  background: rgba(0,0,0,0.3);
  border: 1px dashed rgba(201,169,97,0.2);
  border-radius: 6px;
}
.discard-pile.has-cards { border-color: rgba(201,169,97,0.5); }
.discard-pile.has-cards::before {
  content: ''; position: absolute; inset: 4px;
  background: linear-gradient(135deg, #6d2218, #3d1208);
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  transform: rotate(8deg);
  opacity: 0.6;
}

/* зона игры — отбитые/неотбитые пары */
.play-area {
  display: flex; flex-wrap: wrap;
  gap: 18px; justify-content: center; align-content: center;
  min-height: 120px;
  padding: 12px;
}
.attack-pair {
  position: relative;
  width: 72px; height: 104px;
}
.attack-pair .card { width: 72px; height: 104px; position: absolute; }
.attack-pair .defend-card {
  top: 20px; left: 18px;
  transform: rotate(15deg);
}

/* кнопки действий */
.actions {
  display: flex; gap: 12px; justify-content: center;
  min-height: 44px;
}
.actions .btn, .my-actions .btn { padding: 8px 22px; }

/* моя рука */
.my-hand {
  display: flex; justify-content: center; align-items: flex-end;
  height: 150px;
  position: relative;
}
.my-hand .card {
  width: 108px; height: 156px;
  margin: 0 -22px;
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s, margin 0.2s;
  box-shadow: var(--shadow-card);
}
.my-hand .card:hover {
  transform: translateY(-16px);
  box-shadow: var(--shadow-lift);
  z-index: 10;
}
.my-hand .card.playable { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold); }
.my-hand .card.dimmed { opacity: 1; cursor: default; }
.my-hand .card.selecting { transform: translateY(-24px); box-shadow: var(--shadow-lift), 0 0 0 2px var(--gold-bright); }

/* мини-чат в игре */
.game-chat {
  position: absolute;
  right: 16px; bottom: 104px;
  width: 260px; height: 180px;
  background: rgba(10,20,12,0.85);
  border: 1px solid rgba(201,169,97,0.3);
  border-radius: 10px;
  display: flex; flex-direction: column;
  padding: 10px;
  backdrop-filter: blur(4px);
  z-index: 4;
}
.game-chat .chat-log { background: transparent; border: none; padding: 0; }

/* модалка конца игры */
.endgame {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeUp 0.4s ease both;
}
.endgame.hidden { display: none; }
.endgame-card {
  background: linear-gradient(180deg, rgba(60,30,15,0.95), rgba(30,15,8,0.95));
  border: 1px solid var(--gold);
  padding: 40px 60px;
  border-radius: 4px;
  text-align: center;
  box-shadow: var(--shadow-panel);
}
.endgame-card h2 {
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--gold-bright);
  margin-bottom: 12px;
}
.endgame-card p { color: var(--ivory); margin-bottom: 24px; font-size: 18px; }

/* ============================================
   КАРТЫ
   ============================================ */
.card {
  width: 72px; height: 104px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f6f4 100%);
  border-radius: 8px;
  border: 1px solid #d8d8d4;
  box-shadow: var(--shadow-card);
  position: relative;
  font-family: "Arial Narrow", "Arial", sans-serif;
  user-select: none;
  overflow: hidden;
}
.card::after {
  /* очень лёгкий глянец */
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 12%, rgba(255,255,255,0.6), transparent 45%);
  border-radius: 8px;
  pointer-events: none;
}
.card .corner {
  position: absolute;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.card .corner .rank { display: block; font-family: "Arial", sans-serif; font-weight: 800; font-size: 17px; }
.card .corner .suit { display: block; font-size: 13px; line-height: 1; margin-top: 0px; }
.card .corner.tl { top: 4px; left: 6px; }
.card .corner.br { bottom: 4px; right: 6px; transform: rotate(180deg); }
.card .card-center { position: absolute; inset: 0; }
/* числовые карты — раскладка пунктов */
.pip-grid { position: absolute; inset: 0; }
.pip-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 20px;
  line-height: 1;
}
.pip-dot.flip { transform: translate(-50%, -50%) rotate(180deg); }
/* туз — крупная масть в центре */
.pip-ace {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; line-height: 1;
}
/* фигурные карты — оригинальный SVG */
.card .court { position: absolute; inset: 6px 0 0; width: 100%; height: 88%; }
.card.suit-H, .card.suit-D { color: #d11e1e; }
.card.suit-S, .card.suit-C { color: #1a1a1a; }

/* рубашка — зелёная с узором, как в rstgames */
.card-back {
  background:
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,0.08) 6px 7px),
    repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255,255,255,0.06) 6px 7px),
    radial-gradient(ellipse at center, #2f7d4f 0%, #1f5e3a 55%, #154128 100%);
  border-color: #ffffff;
}
.card-back::before {
  content: '';
  position: absolute; inset: 4px;
  border: 1.5px solid rgba(255,255,255,0.55);
  border-radius: 5px;
}
.card-back::after {
  content: '';
  position: absolute; inset: 0;
  background: none;
}

/* состояние "выбрано для броска/перевода" */
.card.highlight { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold-bright); }

/* ---------- тосты ---------- */
.toasts {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  padding: 10px 18px;
  background: rgba(30,15,8,0.95);
  border: 1px solid var(--gold);
  color: var(--ivory);
  border-radius: 2px;
  font-size: 14px;
  animation: toastIn 0.3s, toastOut 0.3s 2.7s forwards;
  max-width: 400px;
}
.toast.error { border-color: var(--danger); color: #ffd0d0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .lobby-grid, .room-inner { grid-template-columns: 1fr; }
  .game-chat { display: none; }
  .my-hand .card { width: 88px; height: 126px; margin: 0 -22px; }
  .table-center { grid-template-columns: 80px 1fr; gap: 12px; }
  .deck-pile, .trump-card .card, .attack-pair, .attack-pair .card { width: 54px; height: 78px; }
  .brand { font-size: 48px; }
}

/* ============================================
   Дополнения: вход, профиль, лидерборд, таймеры, анимации
   ============================================ */

/* ---- Вход ---- */
.google-wrap {
  display: flex; justify-content: center;
  margin-bottom: 12px; min-height: 44px;
}
.divider {
  position: relative;
  text-align: center;
  margin: 16px 0;
  color: var(--ivory-dim);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.divider::before, .divider::after {
  content: '';
  position: absolute; top: 50%;
  width: 35%; height: 1px;
  background: rgba(201,169,97,0.3);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }
.hint-center { text-align: center; margin-top: 12px; }

/* ---- Топ-навигация (вкладки) ---- */
.top-nav {
  display: flex; gap: 4px;
  flex: 1; justify-content: center;
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--ivory-dim);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-btn:hover { color: var(--ivory); }
.nav-btn.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
}

.tab-content { flex: 1; min-height: 0; }
.panel-wide { max-width: 800px; margin: 24px auto; overflow-y: auto; }

/* ---- Аватары ---- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: var(--mahogany);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; border-width: 2px; }
.avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 14px;
  color: var(--gold-bright);
  background: linear-gradient(135deg, var(--mahogany-light), var(--mahogany));
}
.avatar-lg.avatar-fallback { font-size: 28px; }

/* ---- Профиль ---- */
.profile-head {
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(201,169,97,0.2);
}
.profile-info { flex: 1; }
.profile-info h2 {
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-size: 26px;
  margin-bottom: 8px;
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.profile-stats > div {
  display: flex; flex-direction: column; gap: 2px;
}
.profile-stats span {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ivory-dim);
}
.profile-stats b {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ivory);
}

/* ---- История партий ---- */
.history-list, .leaderboard-list {
  list-style: none;
}
.history-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px dashed rgba(201,169,97,0.15);
}
.hist-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 14px;
  border-radius: 2px;
}
.hist-icon.win { background: rgba(80,160,80,0.15); color: #b8e0b8; }
.hist-icon.lose { background: rgba(179,64,64,0.2); color: #e8a8a8; }
.hist-mode { flex: 1; color: var(--ivory-dim); font-size: 13px; letter-spacing: 0.05em; }
.hist-date { font-size: 11px; color: var(--ivory-dim); font-style: italic; }
.hist-delta {
  font-family: var(--font-display);
  font-size: 16px;
  min-width: 50px; text-align: right;
}
.hist-delta.pos { color: #b8e0b8; }
.hist-delta.neg { color: #e8a8a8; }

/* ---- Лидерборд ---- */
.leaderboard-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  border-bottom: 1px dashed rgba(201,169,97,0.15);
}
.lb-rank {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ivory-dim);
  width: 40px; text-align: center;
}
.lb-rank.gold { color: var(--gold-bright); }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-name { flex: 1; font-size: 15px; }
.lb-rating {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--gold);
  min-width: 70px; text-align: right;
}
.lb-wl { font-size: 11px; color: var(--ivory-dim); min-width: 80px; text-align: right; }

/* ---- Места в лобби — с аватарами и рейтингом ---- */
.seats-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-bottom: 1px dashed rgba(201,169,97,0.15);
}
.seat-rating {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--gold);
  margin-right: 8px;
}

/* ---- Противники с аватарами ---- */
.opponent-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.opponent-name { font-size: 14px; }
.opponent-rating {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--gold);
}

/* ---- Таймер хода ---- */
.timer-ring {
  position: relative;
  width: 32px; height: 32px;
}
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring circle {
  fill: none;
  stroke-width: 3;
}
.timer-ring .bg { stroke: rgba(201,169,97,0.15); }
.timer-ring .fg {
  stroke: var(--gold);
  stroke-dasharray: 88; /* 2π × 14 ≈ 87.96 */
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s;
  stroke-linecap: round;
}
.timer-ring.urgent .fg { stroke: var(--danger); }
.timer-ring .text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--ivory);
}
.timer-ring.urgent .text { color: #e8a8a8; }

/* ---- Анимация раздачи ---- */
@keyframes dealCard {
  from {
    transform: rotate(var(--fan-angle, 0deg)) translateY(calc(var(--fan-y, 0px) - 220px)) scale(0.6);
    opacity: 0;
  }
  to {
    transform: rotate(var(--fan-angle, 0deg)) translateY(var(--fan-y, 0px)) scale(1);
    opacity: 1;
  }
}
.my-hand .card.dealing {
  transform-origin: 50% 130%;
  animation: dealCard 0.5s cubic-bezier(0.4, 0.7, 0.3, 1) both;
}

/* ---- Анимация: карта летит на стол ---- */
@keyframes flyToTable {
  from {
    transform: translate(var(--from-x, 0), var(--from-y, 0)) rotate(var(--from-rot, 0deg));
    opacity: 0.6;
  }
  to {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }
}
.attack-pair .card.flying {
  animation: flyToTable 0.35s ease-out both;
}

/* ---- Анимация уноса в отбой ---- */
@keyframes flyToDiscard {
  from { transform: translate(0,0) rotate(0); opacity: 1; }
  to { transform: translate(var(--to-x, 200px), var(--to-y, 0)) rotate(20deg); opacity: 0; }
}
.attack-pair.discarding .card {
  animation: flyToDiscard 0.4s ease-in both;
}

/* ---- Анимация: карты улетают в руку при «беру» ---- */
@keyframes flyToHand {
  from { transform: translate(0,0); opacity: 1; }
  to { transform: translate(var(--to-x, 0), var(--to-y, 200px)) scale(0.8); opacity: 0; }
}
.attack-pair.taking .card {
  animation: flyToHand 0.4s ease-in both;
}

/* ---- Итог партии: рейтинги ---- */
.endgame-ratings {
  list-style: none;
  margin: 20px 0;
  text-align: left;
}
.endgame-ratings li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(201,169,97,0.15);
  font-size: 16px;
  gap: 12px;
}
.endgame-ratings .delta {
  font-family: var(--font-display);
  font-size: 18px;
}
.endgame-ratings .delta.pos { color: #b8e0b8; }
.endgame-ratings .delta.neg { color: #e8a8a8; }

/* ---- адаптив для новых элементов ---- */
@media (max-width: 900px) {
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
  .top-nav { gap: 0; }
  .nav-btn { padding: 8px 10px; font-size: 11px; letter-spacing: 0.1em; }
}

/* ============================================================
   DRAG & DROP
   ============================================================ */

/* Карта, которая сейчас перетаскивается — прячем оригинал (без просвечивания) */
.my-hand .card.being-dragged {
  visibility: hidden;
  transform: translateY(0) !important;
}

/* Ghost — копия карты, которая летит за курсором */
.dragging-ghost {
  pointer-events: none;
  box-shadow:
    0 18px 36px rgba(0,0,0,0.55),
    0 6px 14px rgba(0,0,0,0.4),
    0 0 0 1px rgba(201,169,97,0.4);
  transform-origin: center center;
  will-change: transform;
  z-index: 9999;
  border-radius: 8px;
  /* небольшая подсветка краёв — выделяет карту над столом */
  outline: 1px solid rgba(255, 230, 170, 0.25);
}

/* зоны сброса больше не подсвечиваются — никакой рамки/области */
.drop-active { }
.drop-hover { }

/* Лёгкая тряска при попытке потянуть невалидную карту */
@keyframes shake-card {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  50%      { transform: translateX(4px); }
  75%      { transform: translateX(-2px); }
}
.card.shake {
  animation: shake-card 0.22s ease-in-out;
}

/* "Думает" — пульс для соперника при бесконечном таймере */
@keyframes thinking-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 230, 170, 0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 230, 170, 0); }
}
.opponent.is-thinking .opponent-avatar,
.opponent.is-thinking .avatar {
  border-radius: 12px;
  animation: thinking-pulse 1.6s ease-in-out infinite;
}

/* ============================================================
   ПОЛИРОВКА СТОЛА ПОД rstgames-вид
   ============================================================ */

/* играбельные карты слегка приподнимаются */
.my-hand .card.playable {
  cursor: default;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.my-hand .card.playable:hover {
  transform: translateY(-14px);
  box-shadow:
    0 14px 28px rgba(0,0,0,0.5),
    0 4px 10px rgba(0,0,0,0.35),
    0 0 0 1px rgba(201,169,97,0.45);
  z-index: 5;
}
.my-hand .card.playable:active {
  cursor: default;
}
.my-hand .card.dimmed { opacity: 1; cursor: default; }

/* play-area — заметнее как зона */
.play-area {
  min-height: 180px;
  border-radius: 18px;
  transition: background-color 0.2s ease;
}

/* атакующая пара — лёгкое смещение defend-карты, как на rstgames */
.attack-pair {
  position: relative;
}
.attack-pair .defend-card {
  position: absolute;
  left: 18px;
  top: 14px;
  transform: rotate(8deg);
}


/* ============================================================
   ВЕЕР РУКИ (fan layout)
   ============================================================ */
.my-hand {
  height: 200px;
  padding-bottom: 8px;
  perspective: 1200px;
}
/* карта в веере: поворот вокруг нижней точки + подъём по дуге */
.my-hand .card.fanned {
  transform-origin: 50% 130%;
  transform: rotate(var(--fan-angle, 0deg)) translateY(var(--fan-y, 0px));
  margin: 0 -26px;            /* плотное перекрытие как на rstgames */
  transition: transform 0.2s cubic-bezier(.2,.7,.3,1.1), box-shadow 0.2s;
}
/* при наведении — карта выезжает вверх и выпрямляется */
.my-hand .card.fanned.playable:hover {
  transform: rotate(var(--fan-angle, 0deg)) translateY(calc(var(--fan-y, 0px) - 30px)) scale(1.06);
  z-index: 100 !important;
  box-shadow:
    0 16px 30px rgba(0,0,0,0.55),
    0 0 0 2px var(--gold-bright);
}
/* выбранная (для отбоя кликом) */
.my-hand .card.fanned.selecting {
  transform: rotate(var(--fan-angle, 0deg)) translateY(calc(var(--fan-y, 0px) - 34px)) scale(1.08);
  z-index: 101 !important;
  box-shadow: 0 18px 32px rgba(0,0,0,0.6), 0 0 0 2px var(--gold-bright);
}
/* перетаскиваемая — прячем оригинал */
.my-hand .card.fanned.being-dragged {
  visibility: hidden;
}

/* ============================================================
   СМАЙЛИКИ — всплывают и тают
   ============================================================ */
.emoji-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: 6px auto 0;
  max-width: 460px;
}
.emoji-btn {
  background: rgba(10,20,12,0.6);
  border: 1px solid rgba(201,169,97,0.25);
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  padding: 0;
}
.emoji-btn:hover {
  transform: translateY(-3px) scale(1.12);
  background: rgba(201,169,97,0.18);
  border-color: var(--gold-bright);
}
.emoji-btn:active { transform: scale(0.94); }

/* всплывающий смайлик — крупнее рамки аватара */
.emoji-float {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 76px;
  line-height: 1;
  pointer-events: none;
  z-index: 10000;
  will-change: transform, opacity;
  animation: emoji-rise 2.2s ease-out forwards;
  filter: drop-shadow(0 5px 10px rgba(0,0,0,0.55));
}
@keyframes emoji-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  15% {
    opacity: 1;
    transform: translate(calc(-50% + var(--drift,0px) * 0.3), -90px) scale(1.25);
  }
  70% {
    opacity: 1;
    transform: translate(calc(-50% + var(--drift,0px)), -190px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--drift,0px) * 1.2), -260px) scale(0.85);
  }
}

/* ============================================================
   АВАТАРЫ ИГРОКОВ — круглые, как на rstgames
   ============================================================ */
.opponent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.opponent-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
}
.opponent .avatar {
  width: 58px; height: 58px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.5);
  object-fit: cover;
  background: #2a3a4a;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}
.opponent.is-attacker .avatar { border-color: #f0d080; box-shadow: 0 0 14px rgba(240,208,128,0.7); }
.opponent.is-defender .avatar { border-color: #e85a4a; box-shadow: 0 0 14px rgba(232,90,74,0.65); }
.opponent .avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 24px; color: #fff;
  border-radius: 12px;
}

/* мой ряд получает якорь для смайликов */
#my-hand { position: relative; }

/* ============================================================
   КНОПКИ ДЕЙСТВИЙ — округлые, как в rstgames
   ============================================================ */
.actions .btn, .my-actions .btn {
  padding: 10px 28px;
  border-radius: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.actions #btn-pass, .my-actions #btn-pass {
  background: linear-gradient(180deg, #f4d678 0%, #e3b94a 100%);
  color: #3a2a0a;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.actions #btn-pass:hover:not(:disabled), .my-actions #btn-pass:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe48a 0%, #efc658 100%);
}
.actions #btn-take, .my-actions #btn-take {
  background: linear-gradient(180deg, #f4d678 0%, #e3b94a 100%);
  color: #3a2a0a;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.actions #btn-take:hover:not(:disabled), .my-actions #btn-take:hover:not(:disabled) {
  background: linear-gradient(180deg, #ffe48a 0%, #efc658 100%);
}

/* зона стола чуть прозрачнее на синем сукне */
.attack-pair .card { box-shadow: 0 4px 10px rgba(0,0,0,0.4); }

/* счётчик карт у соперника — белый кружок с цифрой как на скрине */
.opponent .card-count {
  font-size: 12px;
  color: #fff;
  opacity: 0.85;
}

/* стол не подсвечивается рамкой при выборе карты */
.play-area.tap-target { cursor: pointer; }

/* ============================================================
   НИЖНЯЯ ПАНЕЛЬ ИГРОКА (как на rstgames)
   ============================================================ */
.my-panel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(20,28,38,0.35), rgba(14,20,28,0.72));
  border-top: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
}

.my-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-self: center;
}
.my-avatar {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(160deg, #3a4a5c, #243240);
  border: 2px solid rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 24px; color: #fff;
  box-shadow: 0 3px 12px rgba(0,0,0,0.45);
  flex: 0 0 auto;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}
.my-avatar.my-turn {
  border-color: #f0d080;
  box-shadow: 0 0 18px rgba(240,208,128,0.7);
  transform: scale(1.05);
}
.my-name {
  font-size: 13px;
  color: var(--ivory, #f3ead2);
  font-weight: 600;
  max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.my-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-self: start;
}

/* кнопка открытия смайлов */
.my-emoji-wrap { position: relative; justify-self: end; display: flex; justify-content: flex-end; z-index: 20; }
.emoji-toggle {
  width: 48px; height: 48px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  background: rgba(10,20,12,0.6);
  border: 1px solid rgba(201,169,97,0.3);
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.emoji-toggle:hover {
  transform: translateY(-2px) scale(1.06);
  background: rgba(201,169,97,0.2);
  border-color: var(--gold-bright, #e8c87a);
}

/* всплывающий пикер смайлов над кнопкой */
.emoji-picker {
  position: absolute;
  bottom: 58px;
  right: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 12px;
  background: rgba(16, 24, 32, 0.96);
  border: 1px solid rgba(201,169,97,0.3);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  z-index: 200;
  width: min(380px, 86vw);
}
.emoji-picker.hidden { display: none; }
.emoji-picker .emoji-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  padding: 0;
}
.emoji-picker .emoji-btn:hover {
  transform: scale(1.18);
  background: rgba(201,169,97,0.18);
}

/* мобильно — пикер шире, кнопки крупнее под палец */
@media (max-width: 720px) {
  .my-panel { padding: 8px 12px; gap: 8px; }
  .my-side { min-width: 64px; }
  .my-name { display: none; }
  .emoji-picker { grid-template-columns: repeat(6, 1fr); width: 90vw; }
}

/* ============================================================
   КОМНАТА-СТОЛ ДО СТАРТА
   ============================================================ */
.room-status {
  font-size: 16px;
  color: var(--ivory, #f3ead2);
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}
.room-status.countdown {
  font-family: var(--font-display, serif);
  font-size: 22px;
  color: var(--gold-bright, #e8c87a);
}

/* свободный слот */
.seat-empty { opacity: 0.65; }
.seat-avatar-empty {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 2px dashed rgba(201,169,97,0.4);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; color: rgba(201,169,97,0.6);
  flex: 0 0 auto;
}
.seat-badge.waiting { opacity: 0.7; }

/* ============================================================
   СОВРЕМЕННЫЕ ШТРИХИ / АНИМАЦИИ
   ============================================================ */
.my-actions .btn, .my-emoji-wrap .emoji-toggle {
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, filter 0.14s ease;
}
.my-actions .btn:hover:not(:disabled) { transform: translateY(-2px); }
.my-actions .btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }

/* мягкий пульс аватара, когда мой ход */
@keyframes avatar-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(240,208,128,0.45); }
  50%      { box-shadow: 0 0 24px rgba(240,208,128,0.85); }
}
.my-avatar.my-turn { animation: avatar-pulse 1.8s ease-in-out infinite; }

/* плавное появление нижней панели */
@keyframes panel-rise {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.my-panel { animation: panel-rise 0.4s ease-out; }


/* пункты/фигуры крупнее на больших картах руки */
.my-hand .card .pip-dot { font-size: 26px; }
.my-hand .card .pip-ace { font-size: 70px; }
.my-hand .card .corner .rank { font-size: 22px; }
.my-hand .card .corner .suit { font-size: 17px; }

/* ============================================================
   MODERN PASS — обновлённые логин/лобби (ровно, плавно, стильно)
   ============================================================ */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --glass: rgba(22, 28, 38, 0.72);
  --glass-line: rgba(255,255,255,0.08);
  --accent: #e8c878;
}

/* фон логина/лобби — мягкий сине-зелёный градиент с виньеткой */
html, body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #2a4a5e 0%, #1a2d3c 45%, #0f1a24 100%);
}

/* карточка логина */
#screen-login { padding: 24px; }
.login-card {
  max-width: 400px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 44px 36px 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(14px);
}
.login-card::before { display: none; }
.brand { text-shadow: 0 2px 20px rgba(232,200,120,0.25); }

/* поля и кнопки — скруглённые, с плавными переходами */
.field input, .field select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-line);
  background: rgba(0,0,0,0.28);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,200,120,0.15);
  outline: none;
}
.btn {
  border-radius: var(--radius-sm);
  transition: transform 0.14s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #f4d678, #e3b94a);
  color: #2a1e08; border: none;
  box-shadow: 0 6px 16px rgba(227,185,74,0.3);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffe48a, #efc658); }

/* топбар и панели */
.topbar {
  background: rgba(10,16,22,0.5);
  border-bottom: 1px solid var(--glass-line);
  backdrop-filter: blur(10px);
}
.nav-btn {
  border-radius: 999px;
  transition: background 0.16s ease, color 0.16s ease;
}
.nav-btn.active { background: rgba(232,200,120,0.16); color: var(--accent); }

.panel {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
}

/* список столов — карточки с ховером */
.rooms-list li {
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-line);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.rooms-list li:hover {
  transform: translateY(-2px);
  border-color: rgba(232,200,120,0.45);
  background: rgba(232,200,120,0.06);
}

/* список мест в комнате */
.seats-list li {
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-line);
  transition: background 0.16s ease;
}

/* divider тоньше и аккуратнее */
.divider { color: var(--ivory-dim); }

/* плавная смена экранов */
.screen { animation: screenIn 0.35s cubic-bezier(.2,.7,.3,1) both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(12px) scale(0.995); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   ОППОНЕНТЫ — круглые аватары с кольцом таймера (как на скрине)
   ============================================================ */
.opp-avatar-holder {
  position: relative;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.opp-avatar-holder .avatar {
  width: 56px; height: 56px;
  border-radius: 14px;            /* мягкий квадрат как в rstgames */
}
/* кольцо таймера обтягивает аватар */
.opp-ring.timer-ring {
  position: absolute; inset: -5px;
  width: calc(100% + 10px); height: calc(100% + 10px);
}
.opp-ring.timer-ring svg {
  width: 100%; height: 100%;
}
.opp-ring .text {
  font-size: 12px;
  top: auto; bottom: -20px;
  color: var(--ivory);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
/* активный оппонент — зелёная подсветка как на скрине */
.opponent.is-attacker .opp-avatar-holder .avatar,
.opponent.is-defender .opp-avatar-holder .avatar {
  box-shadow: 0 0 0 3px #6cc24a, 0 0 16px rgba(108,194,74,0.6);
}
.opponent.is-thinking .opp-avatar-holder .avatar {
  animation: thinking-pulse 1.6s ease-in-out infinite;
  border-radius: 14px;
}

/* SVG-фигуры на картах не мешают курсору/тачу */
.card .court, .card .pip-grid, .card .pip-ace, .card .card-center { pointer-events: none; }
