/* Свара: флэт-минимализм, тёмный графит, один золотой акцент (ТЗ ч.3 п.3). */
:root {
  --bg: #14181b;
  --table: #1d2b26;        /* тёмно-зелёный графит, без текстуры */
  --table-edge: #24352f;
  --panel: #1a2023;
  --line: #2c343a;
  --text: #e7ebee;
  --muted: #8b979e;
  --gold: #e8b64c;         /* монеты и банк */
  --gold-dim: #a8842f;
  --red: #e05252;          /* червы/бубны */
  --joker: #b46cf0;        /* акцент Джокера */
  --ok: #4caf7d;
  --danger: #c94f4f;
  --card-bg: #f4f1e8;
  --card-back: #35524a;
  --svara: #e8734c;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ─── Экран входа ─── */

#auth { align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 360px; }
.logo { text-align: center; margin-bottom: 28px; }
.logo-mark {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px;
  background: var(--table); color: var(--gold);
  font-size: 34px; line-height: 64px; text-align: center;
}
.logo h1 { font-size: 28px; letter-spacing: 8px; font-weight: 700; }
.logo-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 15px; cursor: pointer;
}
.tab.active { background: var(--panel); color: var(--text); border-color: var(--gold-dim); }

#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form input {
  padding: 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 16px; outline: none;
}
#auth-form input:focus { border-color: var(--gold-dim); }
.auth-error { color: var(--danger); font-size: 14px; text-align: center; min-height: 18px; }

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

.btn {
  border: none; border-radius: 12px; cursor: pointer; font-weight: 600;
  padding: 14px 18px; font-size: 16px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #201a08; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.big { flex: 1; padding: 16px; font-size: 17px; }
.btn.small-btn { padding: 8px 14px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted); font-size: 17px; cursor: pointer;
}

/* ─── Шапка ─── */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
}
.me { display: flex; flex-direction: column; gap: 2px; }
#me-name { font-size: 15px; font-weight: 600; }
.coins { color: var(--gold); font-weight: 700; font-size: 15px; }
.coins::after { content: ' ●'; font-size: 11px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.observers { color: var(--muted); font-size: 13px; }

/* ─── Стол ─── */

#table-wrap { position: relative; flex: 1; min-height: 0; }
#table { position: absolute; inset: 0 8px 8px; }
#oval {
  position: absolute; inset: 6% 2% 16%;
  background: radial-gradient(ellipse at 50% 42%, var(--table-edge), var(--table) 68%);
  border: 2px solid #2e463d;
  border-radius: 50% / 56%;
}

.status-banner {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  z-index: 5; padding: 8px 16px; border-radius: 20px;
  background: rgba(20, 24, 27, .88); border: 1px solid var(--line);
  font-size: 13px; color: var(--text); white-space: nowrap;
}

/* Банк в центре стола */
.bank {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 7px; z-index: 4;
  background: rgba(0,0,0,.30); padding: 7px 14px; border-radius: 18px;
}
.bank-chip { color: var(--gold); font-size: 14px; }
#bank-amount { color: var(--gold); font-weight: 700; font-size: 17px; }

/* ─── Места (фиксированный шаблон на 10 слотов, ТЗ ч.3 п.2) ─── */

.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 64px; text-align: center; z-index: 3;
  transition: opacity .3s;
}
.seat .avatar-wrap { position: relative; width: 46px; height: 46px; margin: 0 auto; }
.seat .avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--line);
  font-size: 18px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.seat.svara-member .avatar { border-color: var(--svara); box-shadow: 0 0 8px rgba(232,115,76,.55); }
.seat.folded { opacity: .38; }
.seat.empty .avatar { border-style: dashed; background: transparent; }
.seat .name {
  font-size: 11px; color: var(--text); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat.empty .name { color: var(--muted); font-size: 10px; }
.seat .stack { font-size: 11px; color: var(--gold); font-weight: 600; }
.seat .dealer-chip {
  position: absolute; right: -7px; bottom: -3px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--gold); color: #201a08;
  font-size: 10px; font-weight: 800; line-height: 18px;
}

/* Кольцевой таймер хода вокруг аватара (ТЗ ч.3 п.2) */
.seat .ring { position: absolute; inset: -5px; pointer-events: none; }
.seat .ring circle {
  fill: none; stroke: var(--gold); stroke-width: 3;
  stroke-linecap: round; transform: rotate(-90deg); transform-origin: center;
}

/* Мини-карты соперников (рубашки) */
.seat .mini-cards { display: flex; justify-content: center; gap: 2px; margin-top: 3px; height: 22px; }
.mini-card {
  width: 15px; height: 22px; border-radius: 3px;
  background: var(--card-back); border: 1px solid #47695f;
}
.mini-card.open {
  background: var(--card-bg); color: #222; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border-color: #ccc;
  width: 17px;
}
.mini-card.open.red { color: var(--red); }
.mini-card.open.joker { color: var(--joker); }

/* Всплывающая подпись действия у места («Повысил +20», ТЗ ч.3 п.4) */
.seat .bubble {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  background: rgba(20,24,27,.92); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 11px; font-size: 11px; white-space: nowrap;
  opacity: 0; animation: bubble 1.8s ease forwards; pointer-events: none; z-index: 6;
}
@keyframes bubble {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ─── Свои карты: крупно снизу по центру ─── */

.my-cards {
  position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%);
  display: flex; gap: 9px; z-index: 5;
}
.card {
  width: 62px; height: 88px; border-radius: 9px;
  background: var(--card-bg); color: #23272b;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 3px 10px rgba(0,0,0,.4);
  transition: transform .25s, opacity .25s;
}
.card .rank { font-size: 26px; line-height: 1; }
.card .suit { font-size: 22px; line-height: 1.2; }
.card.red { color: var(--red); }
.card.joker { color: var(--joker); }
.card.joker .rank { font-size: 15px; letter-spacing: 1px; }
.card.joker .suit { font-size: 30px; }
.card.dealt { animation: deal .3s ease-out; }
@keyframes deal {
  from { transform: translateY(-46vh) scale(.4); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.card.win-glow, .mini-card.win-glow {
  box-shadow: 0 0 14px 3px rgba(232,182,76,.85);
  border: 1px solid var(--gold);
}

/* ─── Момент «Свара»: баннер-вспышка (ТЗ ч.3 п.4) ─── */

.svara-banner {
  position: fixed; top: 42%; left: 50%; transform: translate(-50%, -50%);
  z-index: 40; padding: 18px 44px; border-radius: 16px;
  background: var(--svara); color: #fff; font-size: 34px; font-weight: 800;
  letter-spacing: 6px; animation: svara-flash 1.8s ease forwards;
  box-shadow: 0 0 40px rgba(232,115,76,.6);
}
@keyframes svara-flash {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.06); }
  25% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Летящая сумма выигрыша */
.win-amount {
  position: absolute; z-index: 30; color: var(--gold); font-size: 26px; font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.6); pointer-events: none;
  animation: win-float 1.6s ease forwards;
}
@keyframes win-float {
  0% { opacity: 0; transform: translate(-50%,-50%) translateY(8px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) translateY(-34px); }
}

/* Летящая фишка (ставка → банк, банк → победитель) */
.chip-fly {
  position: absolute; z-index: 25; width: 16px; height: 16px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 6px rgba(232,182,76,.7);
  transition: transform .38s cubic-bezier(.3,.7,.4,1), opacity .38s;
  pointer-events: none;
}
#fly-layer { position: absolute; inset: 0; pointer-events: none; z-index: 25; }

/* ─── Нижняя панель ─── */

.panel {
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  display: flex; flex-direction: column; gap: 8px;
}
.panel-row { display: flex; gap: 10px; justify-content: center; }
#panel-actions { flex-wrap: wrap; }
#panel-actions .btn { flex: 1 1 30%; min-width: 100px; padding: 14px 8px; font-size: 15px; }
#panel-leave { justify-content: flex-end; }

/* ─── История ─── */

.log-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(78vw, 300px); z-index: 50;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.log-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px; border-bottom: 1px solid var(--line); font-weight: 600;
}
#log-list { list-style: none; overflow-y: auto; padding: 10px 14px; flex: 1; }
#log-list li { font-size: 13px; color: var(--muted); padding: 5px 0; border-bottom: 1px dashed #232b30; }
#log-list li b { color: var(--text); font-weight: 600; }

/* ─── Тост ─── */

.toast {
  position: fixed; bottom: 116px; left: 50%; transform: translateX(-50%);
  background: rgba(20,24,27,.94); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px; font-size: 14px; z-index: 60;
  max-width: 86vw; text-align: center;
}

/* Широкие экраны: стол по центру колонкой */
@media (min-width: 700px) {
  #game { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
