/* ═══════════════════════════════════════════════════
   ДУРАК ОНЛАЙН — Main Stylesheet
   Тема: уютный вечер за карточным столом
   ═══════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg:           #0d1b2a;
  --bg2:          #162032;
  --wood:         #5c3010;
  --wood-light:   #7a4218;
  --felt:         #1b6b2f;
  --felt-dark:    #154f22;
  --gold:         #d4a017;
  --gold-light:   #f0c040;
  --cream:        #f5e6c8;
  --text:         #f0e0c0;
  --text-dim:     #a09070;
  --red:          #cc2222;
  --red-light:    #e84040;
  --blue-dark:    #1a237e;
  --card-bg:      #fffdf8;
  --card-border:  #d0c8b8;
  --shadow:       rgba(0,0,0,0.6);
  --primary:      #c8860a;
  --primary-h:    #e09a10;
  --online:       #1565c0;
  --online-h:     #1976d2;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --transit:      0.2s ease;
  --ya-banner-h:  0px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; touch-action: manipulation; }
body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input { font: inherit; color: inherit; outline: none; }
img { display: block; }

/* ── Screens (SPA routing) ── */
.screen {
  display: none;
  position: absolute;
  inset: 0 0 var(--ya-banner-h) 0;
  overflow: hidden;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ── Scrollable containers ── */
.scroll-y { overflow-y: auto; overflow-x: hidden; }
.scroll-y::-webkit-scrollbar { width: 4px; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }
.scroll-y::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ══════════════════════════════════════
   LOADING SCREEN
══════════════════════════════════════ */
#screen-loading {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1e3560 0%, #0d1b2a 70%);
}
.loading-wrap { text-align: center; padding: 24px; }

.loading-suits {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.ls {
  font-size: 52px;
  opacity: 0;
  display: inline-block;
  animation: suitPop 0.6s ease forwards;
}
.ls-s { color: #e0e0e0; animation-delay: 0.0s; }
.ls-h { color: #e84040; animation-delay: 0.2s; }
.ls-d { color: #e84040; animation-delay: 0.4s; }
.ls-c { color: #e0e0e0; animation-delay: 0.6s; }
@keyframes suitPop {
  from { opacity: 0; transform: scale(0.3) rotate(-20deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.game-logo {
  font-size: clamp(28px, 7vw, 52px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold-light);
  text-shadow: 0 0 30px rgba(240,192,64,0.5), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 32px;
}
.loading-bar-wrap {
  width: min(320px, 80vw);
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto 16px;
}
.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.loading-hint { color: var(--text-dim); font-size: 13px; }

/* ══════════════════════════════════════
   TOP BAR (shared header)
══════════════════════════════════════ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(212,160,23,0.2);
  flex-shrink: 0;
  gap: 8px;
  min-height: 52px;
  z-index: 10;
}
.top-bar h2 {
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 700;
  color: var(--gold-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-title {
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 15px rgba(240,192,64,0.4);
}
.suit-s, .suit-c { color: #ccc; font-size: 18px; }
.suit-h, .suit-d { color: var(--red-light); font-size: 18px; }

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  transition: background var(--transit);
  white-space: nowrap;
}
.back-btn:hover { background: rgba(255,255,255,0.14); }

.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  transition: background var(--transit);
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.16); }

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-h));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform var(--transit), box-shadow var(--transit), filter var(--transit);
}
.primary-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); filter: brightness(0.95); }

.online-btn {
  background: linear-gradient(135deg, var(--online), var(--online-h));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform var(--transit), filter var(--transit);
}
.online-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

.secondary-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: background var(--transit);
}
.secondary-btn:hover { background: rgba(255,255,255,0.18); }

.cancel-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  transition: color var(--transit);
}
.cancel-btn:hover { color: var(--text); }

.sm-btn { padding: 6px 14px; font-size: 13px; }

/* ══════════════════════════════════════
   MODALS
══════════════════════════════════════ */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: linear-gradient(160deg, #1e2d42, #162032);
  border: 1px solid rgba(212,160,23,0.35);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.modal-box h2 {
  text-align: center;
  color: var(--gold-light);
  font-size: 20px;
  font-weight: 800;
}
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.modal-actions > * { flex: 1; min-width: 100px; }

/* ══════════════════════════════════════
   MAIN MENU
══════════════════════════════════════ */
#screen-menu { background: var(--bg); }
.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 30%, rgba(92,48,16,0.3) 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(27,107,47,0.15) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='50%25' y='55%25' font-size='24' text-anchor='middle' fill='rgba(255,255,255,0.02)'%3E♠%3C/text%3E%3C/svg%3E");
  pointer-events: none;
}
.menu-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px;
}
.floating-cards {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.fc {
  position: absolute;
  font-size: clamp(30px, 8vw, 60px);
  opacity: 0.06;
  animation: floatCard 8s infinite ease-in-out;
}
.fc1 { top: 5%;  left: 5%;  color:#fff; animation-delay: 0s; }
.fc2 { top: 10%; right:8%;  color:var(--red-light); animation-delay: 1.5s; }
.fc3 { top: 40%; left: 3%;  color:var(--red-light); animation-delay: 3s; }
.fc4 { top: 60%; right:5%;  color:#fff; animation-delay: 4.5s; }
.fc5 { top: 80%; left: 15%; color:#fff; animation-delay: 2s; }
.fc6 { top: 75%; right:20%; color:var(--red-light); animation-delay: 6s; }
@keyframes floatCard {
  0%,100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-20px) rotate(5deg); }
}

.menu-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  position: relative;
  z-index: 1;
}
.menu-btn {
  width: 100%;
  padding: 16px 24px;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 700;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.btn-icon { font-size: 22px; flex-shrink: 0; }
.header-player { display: flex; align-items: center; gap: 8px; }
.mini-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold);
}

/* Difficulty modal */
.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: rgba(255,255,255,0.07);
  border: 2px solid transparent;
  border-radius: var(--radius);
  transition: all var(--transit);
}
.diff-btn:hover { border-color: var(--gold); background: rgba(212,160,23,0.1); }
.diff-btn strong { font-size: 14px; }
.diff-btn small { font-size: 11px; color: var(--text-dim); }
.diff-icon { font-size: 28px; }
.diff-btn[data-diff="easy"]:hover { border-color: #66bb6a; }
.diff-btn[data-diff="hard"]:hover { border-color: var(--red-light); }

/* ══════════════════════════════════════
   LOBBY
══════════════════════════════════════ */
#screen-lobby { background: var(--bg); flex-direction: column; }
.lobby-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 0;
  overflow: hidden;
}
@media (max-width: 760px) {
  .lobby-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 1fr;
  }
  /* Панель игроков — горизонтальная полоска */
  .players-panel { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06); }
  .players-online-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 8px;
    gap: 8px;
  }
  .online-player-item {
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    padding: 4px 6px;
    gap: 4px;
  }
  .op-name { font-size: 10px; white-space: nowrap; }
  .op-actions { gap: 2px; }
  .op-btn { width: 22px; height: 22px; font-size: 11px; }
  /* Emoji: прокрутка в одну строку */
  .emoji-strip { flex-wrap: nowrap; overflow-x: auto; padding: 4px 8px; }
  .em { flex-shrink: 0; width: 28px; height: 28px; font-size: 16px; }
}
@media (max-width: 480px) {
  /* На телефоне панель игроков скрываем — слишком мало места */
  .players-panel { display: none; }
  .lobby-layout { grid-template-rows: 1fr 1fr; }
  /* Кнопка "Создать Игру": компактнее */
  .panel-head-btns .primary-btn { font-size: 12px; padding: 6px 8px; }
}
.rooms-panel, .chat-panel, .players-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  gap: 6px;
}
.panel-head h3 { font-size: 14px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.panel-head-btns { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Online count badge */
.online-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--online);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

/* Players online list */
.players-online-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.online-player-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  transition: background var(--transit);
}
.online-player-item:hover { background: rgba(255,255,255,0.09); }
.op-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.op-avatar-placeholder {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.op-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.op-actions { display: flex; gap: 4px; flex-shrink: 0; }
.op-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transit);
  cursor: pointer;
}
.op-btn:hover { background: rgba(255,255,255,0.22); }

/* PM notification popup */
.pm-notify {
  position: fixed;
  bottom: calc(70px + var(--ya-banner-h));
  right: 14px;
  width: 280px;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  padding: 12px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
}
.pm-notify-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}
.pm-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
}
.pm-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
  word-break: break-word;
}
.pm-notify .primary-btn { width: 100%; }

/* PM dialog */
#pm-dialog {
  position: fixed;
  inset: 0 0 var(--ya-banner-h) 0;
  z-index: 200;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 16px 16px 16px;
}
@media (max-width: 480px) {
  #pm-dialog {
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 0 0;
  }
  .pm-modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    min-height: 260px;
    max-height: 70vh;
  }
}
#pm-dialog .modal-box {
  gap: 0;
  padding: 0;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.pm-modal-box {
  width: 340px;
  max-width: calc(100vw - 32px);
  height: auto;
  max-height: calc(100vh - 48px);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  gap: 0;
}
.pm-modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
}
.pm-modal-head .icon-btn { margin-left: auto; }
.pm-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-msg {
  max-width: 80%;
  padding: 7px 11px;
  border-radius: 14px;
  font-size: 13px;
  word-break: break-word;
  flex-shrink: 0;
}
.pm-msg-me {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pm-msg-them {
  align-self: flex-start;
  background: rgba(255,255,255,0.1);
  border-bottom-left-radius: 4px;
}
.pm-modal-box .chat-input-row {
  padding: 8px 10px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.15);
}

/* Rooms list */
.rooms-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.empty-state { color: var(--text-dim); text-align: center; padding: 24px; font-size: 14px; }
.room-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background var(--transit);
}
.room-card:hover { background: rgba(255,255,255,0.1); }
.room-card-info { flex: 1; min-width: 0; }
.room-card-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.room-join-btn {
  padding: 6px 14px;
  background: var(--online);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transition: filter var(--transit);
}
.room-join-btn:hover { filter: brightness(1.15); }
.room-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-wait { background: #66bb6a; }
.dot-full { background: var(--red-light); }

/* ── Chat shared styles ── */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-msg .sender {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}
.chat-msg .mtext {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  background: rgba(255,255,255,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 5px 9px;
  max-width: 90%;
  display: inline-block;
}
.chat-msg.own .mtext {
  background: rgba(212,160,23,0.15);
  border-radius: var(--radius-sm) 0 var(--radius-sm) var(--radius-sm);
  margin-left: auto;
}
.chat-msg.own .sender { text-align: right; color: var(--cream); }

.emoji-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.emoji-strip.mini { padding: 4px 8px; }
.em {
  font-size: 18px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  transition: background var(--transit), transform 0.1s;
  flex-shrink: 0;
}
.em:hover { background: rgba(255,255,255,0.12); transform: scale(1.2); }
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.chat-input-row input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
}
.chat-input-row input:focus { border-color: rgba(212,160,23,0.4); }
.send-btn {
  width: 38px; height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: filter var(--transit);
  flex-shrink: 0;
}
.send-btn:hover { filter: brightness(1.15); }

/* Create room form */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.form-row input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
}
.form-row input:focus { border-color: var(--gold); }
.count-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.cnt-btn {
  padding: 8px 16px;
  background: rgba(255,255,255,0.07);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  transition: all var(--transit);
}
.cnt-btn:hover { border-color: rgba(255,255,255,0.3); }
.cnt-btn.active { border-color: var(--gold); color: var(--gold-light); background: rgba(212,160,23,0.1); }

/* ══════════════════════════════════════
   ROOM SCREEN
══════════════════════════════════════ */
#screen-room { flex-direction: column; background: var(--bg); }
.room-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  overflow: hidden;
}
@media (max-width: 500px) {
  .room-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}
.room-players-panel {
  padding: 14px;
  border-right: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
  overflow-y: auto;
}
.room-players-panel h3 { font-size: 13px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.room-players-list { display: flex; flex-direction: column; gap: 8px; }
.room-player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
}
.rp-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.rp-name { font-size: 14px; font-weight: 600; flex: 1; }
.rp-host { font-size: 11px; color: var(--gold); }
.rp-ready { font-size: 16px; }
.room-hint { font-size: 12px; color: var(--text-dim); margin-top: 14px; text-align: center; }

/* ══════════════════════════════════════
   LEADERBOARD
══════════════════════════════════════ */
#screen-leaderboard { flex-direction: column; background: var(--bg); }
.lb-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
}
.lb-rank { font-size: 20px; font-weight: 900; width: 36px; text-align: center; flex-shrink: 0; }
.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.lb-name { flex: 1; font-weight: 600; }
.lb-score { font-size: 18px; font-weight: 900; color: var(--gold-light); }
.lb-my { border-color: var(--gold); background: rgba(212,160,23,0.08); }

/* ══════════════════════════════════════
   SETTINGS
══════════════════════════════════════ */
#screen-settings { flex-direction: column; background: var(--bg); }
.settings-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.setting-row > span { font-size: 15px; font-weight: 600; }
.toggle-sw { position: relative; width: 52px; height: 28px; flex-shrink: 0; }
.toggle-sw input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.3s;
}
.slider::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle-sw input:checked + .slider { background: var(--primary); }
.toggle-sw input:checked + .slider::before { transform: translateX(24px); }
.lang-row { display: flex; gap: 8px; }
.lang-btn {
  padding: 6px 14px;
  background: rgba(255,255,255,0.07);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transit);
}
.lang-btn:hover { border-color: rgba(255,255,255,0.25); }
.lang-btn.active { border-color: var(--gold); color: var(--gold-light); }
.setting-row input[type="range"] { width: 140px; accent-color: var(--primary); }
.server-input {
  flex: 1;
  min-width: 180px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
}
.server-input:focus { border-color: var(--gold); }

/* ══════════════════════════════════════
   GAME OVER
══════════════════════════════════════ */
#screen-gameover {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a2a1a, #0d1b2a);
}
.gameover-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  max-width: 500px;
  width: 100%;
}
.gameover-anim { font-size: clamp(50px, 15vw, 100px); animation: popIn 0.6s cubic-bezier(.17,.67,.35,1.4); }
@keyframes popIn {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}
.gameover-title {
  font-size: clamp(24px, 7vw, 40px);
  font-weight: 900;
  text-shadow: 0 0 20px currentColor;
}
.gameover-title.win  { color: var(--gold-light); }
.gameover-title.lose { color: var(--red-light); }
.gameover-results { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
}
.result-pos { font-size: 20px; font-weight: 900; width: 32px; }
.result-name { flex: 1; text-align: left; font-weight: 600; font-size: 15px; }
.result-badge { font-size: 13px; padding: 4px 10px; border-radius: 20px; font-weight: 700; }
.badge-win  { background: #2e7d32; color: #fff; border: 1px solid #4caf50; font-size: 16px; }
.badge-lose { background: rgba(204,34,34,0.2);  color: var(--red-light); border: 1px solid var(--red-light); }
.badge-durak { background: rgba(204,34,34,0.3); color: #ff6666; border: 1px solid #ff6666; }
.gameover-btns { display: flex; gap: 12px; flex-wrap: wrap; width: 100%; }
.gameover-btns > * { flex: 1; min-width: 130px; }
.lb-section { width: 100%; }
.lb-section h3 { font-size: 14px; color: var(--gold); text-transform: uppercase; margin-bottom: 10px; }

/* ══════════════════════════════════════
   TOASTS
══════════════════════════════════════ */
#toasts {
  position: fixed;
  bottom: calc(80px + var(--ya-banner-h));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
  width: min(320px, 90vw);
}
.toast {
  background: rgba(20,30,50,0.95);
  border: 1px solid rgba(212,160,23,0.4);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  text-align: center;
}
.toast.error { border-color: var(--red-light); color: #ff9999; }
.toast.success { border-color: #66bb6a; color: #a5d6a7; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════
   ✨ POLISH — АНИМАЦИИ И УКРАШЕНИЯ
══════════════════════════════════════ */

/* slideUp — для pm-notify */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Переход между экранами */
.screen.active { animation: screenFadeIn 0.3s ease both; }
@keyframes screenFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Всплывающее модальное окно — пружинный pop */
.modal-overlay:not(.hidden) .modal-box {
  animation: modalSpring 0.26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes modalSpring {
  from { opacity: 0; transform: scale(0.85) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Лобби — насыщенный фон */
#screen-lobby {
  background:
    radial-gradient(ellipse 55% 40% at 12% 18%, rgba(212,160,23,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 88% 75%, rgba(21,101,192,0.08) 0%, transparent 60%),
    var(--bg);
}

/* Блик на menu-btn при наведении */
.menu-btn { position: relative; overflow: hidden; }
.menu-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -80%;
  width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  transition: left 0.55s ease;
  pointer-events: none;
}
.menu-btn:hover::before { left: 140%; }

/* Нажатие кнопок */
.primary-btn:active { transform: scale(0.96) translateY(1px) !important; }
.online-btn:active  { transform: scale(0.96) translateY(1px) !important; }
.menu-btn:active    { transform: scale(0.97) !important; }

/* Карточки комнат — stagger fade-in */
.room-card { animation: roomCardIn 0.2s ease both; }
.room-card:nth-child(2) { animation-delay: 0.05s; }
.room-card:nth-child(3) { animation-delay: 0.10s; }
.room-card:nth-child(4) { animation-delay: 0.15s; }
.room-card:nth-child(5) { animation-delay: 0.20s; }
.room-card:nth-child(6) { animation-delay: 0.25s; }
@keyframes roomCardIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Игроки онлайн — stagger */
.online-player-item { animation: playerFadeUp 0.16s ease both; }
@keyframes playerFadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Сообщения чата */
.chat-msg { animation: chatMsgIn 0.2s ease both; }
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* PM сообщения */
.pm-msg { animation: pmMsgIn 0.16s ease both; }
@keyframes pmMsgIn {
  from { opacity: 0; transform: scale(0.94) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Кнопка обновить — спин при наведении */
#btn-refresh-rooms { transition: background var(--transit), transform 0.4s ease; }
#btn-refresh-rooms:hover { transform: rotate(180deg); }

/* Кнопка Войти в комнату — блик */
.room-join-btn { position: relative; overflow: hidden; }
.room-join-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.18) 50%, transparent 65%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.room-join-btn:hover::after { opacity: 1; }

/* Top bar — глубина */
.top-bar {
  box-shadow: 0 2px 20px rgba(0,0,0,0.5), inset 0 -1px 0 rgba(212,160,23,0.18);
}

/* Таблица результатов — stagger */
.result-row { animation: resultRowIn 0.25s ease both; }
.result-row:nth-child(2) { animation-delay: 0.08s; }
.result-row:nth-child(3) { animation-delay: 0.16s; }
.result-row:nth-child(4) { animation-delay: 0.24s; }
@keyframes resultRowIn {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════
   UTILITY
══════════════════════════════════════ */
.hidden { display: none !important; }
