/* === ЦВЕТОВАЯ СХЕМА === */
:root {
    --accent-orange: #ff6b2b;
    --accent-green: #4CAF50;
    --accent-purple: #9C27B0;
    --accent-blue: #2196F3;
    --bg-main: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #222222;
    --text-secondary: #666666;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --online-dot: #00c853;
    --offline-dot: #9e9e9e;
    --border-radius: 12px;
    --transition: 0.2s ease;
}

/* === БАЗОВЫЕ СТИЛИ === */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* === ШАПКА === */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 24px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.2rem;
}
.logo-icon {
    width: 32px;
    height: 32px;
    display: block;
    flex: 0 0 32px;
    object-fit: contain;
}
.logo-text {
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1.1;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn-search {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-search:hover { filter: brightness(0.95); }

.header-nav { display: flex; gap: 20px; }
.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 4px;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.nav-link:hover { border-bottom-color: var(--accent-orange); }

.header-right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }

#soundToggleBtn.muted { opacity: 0.4; }
#soundToggleBtn.muted:hover { opacity: 0.7; }

.user-avatar-wrapper { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-orange);
}
.user-name { font-weight: 500; font-size: 0.95rem; }

/* === МАКЕТ === */
.app-main {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* === ЛЕВАЯ КОЛОНКА === */
.sidebar-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    min-height: 0;
}
.sidebar-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.sidebar-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* Задания */
.quests-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.quest-item { display: flex; flex-direction: column; gap: 4px; }
.quest-info { display: flex; justify-content: space-between; font-size: 0.9rem; }
.quest-name { font-weight: 500; }
.quest-progress { color: var(--text-secondary); }
.quest-bar {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}
.quest-bar-fill {
    height: 100%;
    background: var(--accent-orange);
    transition: width 0.3s ease;
}
.quest-reward {
    font-size: 0.8rem;
    color: var(--accent-green);
    font-weight: 600;
}

/* Топ и Друзья */
.top-list, .friends-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }
.top-item, .friend-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}
.top-item:hover, .friend-item:hover { background: rgba(0,0,0,0.03); }
.friend-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.friend-name { flex: 1; font-size: 0.9rem; }
.room-player-list-avatar-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.room-player-list-avatar-wrap .friend-avatar {
    width: 100%;
    height: 100%;
}
.room-bot-remove-btn {
    position: absolute;
    top: -7px;
    left: -7px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff5a5f, #d81b60);
    color: white;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(216, 27, 96, 0.28);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.friend-item:hover .room-bot-remove-btn,
.room-player-list-avatar-wrap.is-removable-bot:hover .room-bot-remove-btn,
.room-bot-remove-btn:focus-visible {
    opacity: 1;
    transform: scale(1);
}
.online-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--online-dot);
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

/* === ЦЕНТРАЛЬНАЯ ЗОНА === */
.main-content { display: flex; flex-direction: column; gap: 20px; }

/* Баннер-слайдер */
.banner-slider {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.banner-slide {
    padding: 30px;
    color: white;
    min-height: 180px;
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}
.banner-slide.active { display: flex; }
.banner-slide h2 { font-size: 1.5rem; font-weight: 700; }
.banner-slide p { opacity: 0.95; }
.banner-btn {
    align-self: flex-start;
    background: white;
    color: var(--accent-orange);
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.banner-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.slider-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
}
.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: var(--transition);
}
.dot.active { background: white; transform: scale(1.2); }

/* Чат: адаптивная высота через clamp().
   Минимум 400px (всегда видно несколько сообщений),
   максимум 700px (не выглядит "огромным" на 2K/4K),
   идеал = 100vh минус хедер(60)+паддинги(40)+комната(8 ботов ~360)+gap(20)+буфер(20) = 500px. */
.chat-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: clamp(400px, calc(100vh - 500px), 700px);
    overflow: hidden;
}
.chat-section .chat-messages { min-height: 0; }
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}
.chat-header h3 { font-size: 1rem; }
.online-count { font-size: 0.85rem; color: var(--text-secondary); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-message {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
    max-width: 80%;
    align-items: flex-end;
}
.chat-message .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-message .content {
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 14px 14px 14px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-message .author { font-weight: 600; color: var(--accent-orange); font-size: 0.8rem; }
.chat-message .text { word-break: break-word; line-height: 1.4; }

/* Telegram-style: own messages on the right, blue bubble */
.chat-message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-message.own .content {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    border-radius: 14px 14px 4px 14px;
}
.chat-message.own .author { color: rgba(255,255,255,0.9); }
.chat-message.own .avatar { display: none; }

.chat-input-form {
    position: relative;
    display: flex;
    padding: 10px 16px;
    border-top: 1px solid #eee;
    gap: 8px;
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.95rem;
}
.chat-send-btn, .chat-emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}
.chat-send-btn:hover { background: var(--accent-orange); color: white; }

.chat-profile-trigger {
    cursor: pointer;
}

.chat-profile-trigger:hover {
    text-decoration: underline;
}

.chat-own-mention {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 7px;
    background: rgba(255,193,7,0.24);
    color: #ff9800;
    font-weight: 800;
}

.chat-mention-panel {
    position: absolute;
    left: 16px;
    right: 58px;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 14px 32px rgba(0,0,0,0.18);
    z-index: 50;
}

.chat-mention-panel.hidden {
    display: none;
}

.chat-mention-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
}

.chat-mention-item:hover,
.chat-mention-item.is-selected {
    background: rgba(255,107,43,0.12);
}

.chat-mention-item img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-mention-item small {
    margin-left: auto;
    color: var(--text-secondary);
}

/* Комнаты */
.rooms-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.rooms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.rooms-header h3 { font-size: 1rem; }
.btn-create-room {
    background: var(--accent-orange);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.btn-create-room:hover { filter: brightness(0.95); }

.rooms-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Карточка комнаты в стиле референса (широкая, в одну колонку) */
.room-card {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "header actions"
        "players actions";
    column-gap: 16px;
    row-gap: 8px;
    align-items: start;
    transition: var(--transition);
    background: #fff;
}
.room-card.is-mine {
    grid-template-areas:
        "badge actions"
        "header actions"
        "players actions";
}
.room-badge {
    grid-area: badge;
    font-size: 0.72rem;
    color: var(--accent-orange);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}
.room-card:hover { border-color: var(--accent-orange); box-shadow: var(--shadow); }
.room-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    grid-area: header;
}
.room-mode-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b2b, #c2185b);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}
.room-name { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.room-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.room-tag {
    font-size: 0.78rem;
    padding: 2px 6px;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.room-players {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-start;
    grid-area: players;
}
.room-player-slot {
    width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: default;
}
.room-player-slot .room-player-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    background: #f5f5f5;
    position: relative;
}
.room-player-slot.filled .online-dot {
    position: absolute;
    bottom: 2px; right: 2px;
    width: 12px; height: 12px;
    background: #4CAF50;
    border: 2px solid white;
    border-radius: 50%;
}
.room-player-avatar-wrap { position: relative; }
.room-player-avatar-wrap.is-removable-bot:hover .room-bot-remove-btn-card,
.room-bot-remove-btn-card:focus-visible {
    opacity: 1;
    transform: scale(1);
}
.room-bot-remove-btn-card {
    top: -6px;
    left: auto;
    right: -6px;
    width: 18px;
    height: 18px;
    font-size: 14px;
    z-index: 2;
}
.room-player-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    max-width: 64px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-player-slot.empty {
    cursor: pointer;
    transition: var(--transition);
}
.room-player-slot.empty .room-player-avatar {
    background: #fafafa;
    border: 2px dashed #ddd;
    display: flex; align-items: center; justify-content: center;
    color: #bbb;
    font-size: 1.6rem;
    line-height: 1;
    font-weight: 400;
    padding-bottom: 4px;
    box-sizing: border-box;
}
.room-player-slot.empty:hover .room-player-avatar { border-color: var(--accent-green); color: var(--accent-green); }
.room-player-slot.empty .room-player-name { color: #bbb; }

/* Неактивный пустой слот — серый, без ховера, без курсора-пальца.
   Используется для своей комнаты, чтобы хост визуально видел
   сколько мест осталось свободно. */
.room-player-slot.empty.inactive {
    cursor: default;
    pointer-events: none;
}
.room-player-slot.empty.inactive .room-player-avatar {
    background: #ececec;
    border: 2px solid #d8d8d8;
    color: #b0b0b0;
}
.room-player-slot.empty.inactive .room-player-name { color: #b0b0b0; }
.room-player-slot.empty.inactive:hover .room-player-avatar {
    border-color: #d8d8d8;
    color: #b0b0b0;
}
.btn-join-room {
    grid-area: actions;
    align-self: start;
    margin-top: 4px;
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-join-room:hover { filter: brightness(0.95); transform: translateY(-1px); }
.btn-join-room.disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.3); }
.btn-join-room.disabled:hover { transform: none; }

/* В своей комнате — вместо зелёной кнопки показывать компактные действия */
.room-card-own-actions {
    grid-area: actions;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-self: start;
    margin-top: 4px;
}
.room-card-own-actions .btn-start {
    background: var(--accent-orange);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}
.room-card-own-actions .btn-start:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.3);
}
.room-card-own-actions .btn-start:not(:disabled):hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}
.room-card-own-actions .btn-leave {
    background: #fff;
    color: #c62828;
    border: 1px solid #f2c0c0;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.82rem;
    cursor: pointer;
}
.room-card-own-actions .btn-leave:hover { background: #fff1f1; }
.room-card-own-actions .hint {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Лобби-бейдж: «Вы в комнате …» */
.lobby-room-badge {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 80;
    font-size: 0.92rem;
}
.lobby-room-badge.hidden { display: none; }
.lobby-room-badge-text { color: var(--text-primary); }
.lobby-room-badge-btn {
    background: #f5f5f5;
    border: none;
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}
.lobby-room-badge-btn.primary {
    background: var(--accent-orange);
    color: white;
}
.lobby-room-badge-btn:hover { filter: brightness(0.95); }

/* === ПРАВАЯ ПАНЕЛЬ === */
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    min-height: 0;
}
.room-chat-panel, .room-players-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.chat-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* === ИГРОВОЙ ЭКРАН === */
.game-screen {
    position: fixed;
    inset: 0;
    background: #0b1020;
    z-index: 200;
    display: flex;
    flex-direction: column;
}
#gameCanvas { display: none; }
.btn-leave-room {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--bg-card);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.btn-leave-room:hover { transform: translateY(-2px); }

/* === MAFIA LAYER СТИЛИ === */
#mafiaStageShell {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
    overflow: hidden;
}

.mafia-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}
.mafia-title { font-size: 1.3rem; font-weight: 700; }
.mafia-phase-indicator {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}
.mafia-phase-indicator.phase-waiting { background: #e3f2fd; color: #1976d2; }
.mafia-phase-indicator.phase-night { background: #1a237e; color: white; }
.mafia-phase-indicator.phase-speech { background: #fff3e0; color: #ef6c00; }
.mafia-phase-indicator.phase-vote { background: #f3e5f5; color: #7b1fa2; }
.mafia-phase-indicator.phase-finished { background: #e8f5e9; color: #2e7d32; }
.mafia-timer {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-orange);
}

.mafia-players-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    flex: 1;
    align-content: start;
}
.mafia-player-slot, .mafia-player-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
}
.mafia-player-slot.empty {
    border: 2px dashed #ddd;
    border-radius: 12px;
    min-height: 80px;
    justify-content: center;
}
.mafia-add-slot {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--accent-green);
    cursor: pointer;
}

.mafia-player-avatar {
    position: relative;
    transition: var(--transition);
}
.mafia-player-avatar img {
    width: 60px; height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #444;
    transition: var(--transition);
}
.mafia-player-avatar.is-talking img {
    border-color: var(--online-dot);
    box-shadow: 0 0 0 3px var(--online-dot), 0 0 16px rgba(0, 200, 83, 0.6);
    animation: voice-pulse 0.8s ease-in-out infinite;
}
.mafia-player-avatar.is-speaker img {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px var(--accent-orange);
}
.mafia-shouter-ring {
    position: absolute;
    top: -8px; right: -8px;
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    color: white;
    font-size: 1.1rem;
    border-radius: 50%;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    z-index: 5;
    box-shadow: 0 0 16px rgba(255, 107, 43, 0.8);
    animation: shouterWiggle 0.3s ease-in-out infinite;
}
@keyframes shouterWiggle {
    0%, 100% { transform: scale(1) rotate(-4deg); }
    50% { transform: scale(1.1) rotate(4deg); }
}
.mafia-player-avatar.is-dead {
    opacity: 0.5;
    filter: grayscale(1);
}
.mafia-player-avatar.is-dead img {
    border-color: #999;
}
.mafia-player-name {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mafia-player-badge, .mafia-speaker-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--accent-orange);
    color: white;
}
.mafia-speaker-badge { background: var(--accent-green); }

@keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--online-dot), 0 0 12px rgba(0,200,83,0.5); }
    50% { box-shadow: 0 0 0 5px var(--online-dot), 0 0 24px rgba(0,200,83,0.8); }
}

/* Панель действий */
.mafia-action-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}
.mafia-action-title {
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 1rem;
}
.mafia-action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.mafia-action-btn {
    background: var(--bg-main);
    border: 2px solid var(--accent-orange);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.mafia-action-btn:hover {
    background: var(--accent-orange);
    color: white;
}

/* Ночной итог */
.mafia-night-summary {
    background: #1a237e;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Голосование */
.mafia-vote-panel {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.mafia-vote-title {
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}
.mafia-vote-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.mafia-vote-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-main);
    border-radius: 8px;
}
.mafia-vote-name { font-weight: 500; }
.mafia-vote-count { color: var(--text-secondary); margin: 0 10px; }
.mafia-vote-btn {
    background: none;
    border: 2px solid var(--accent-green);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.mafia-vote-btn:hover {
    background: var(--accent-green);
    color: white;
}
#mafiaAbstainBtn {
    width: 100%;
    background: #eee;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}

/* Модальные окна */
.mafia-result-modal, .mafia-win-screen {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.mafia-result-content, .mafia-win-content {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.mafia-result-content h3, .mafia-win-content h2 {
    margin-bottom: 12px;
    font-size: 1.3rem;
}
#mafiaResultText, #mafiaWinText {
    margin-bottom: 20px;
    color: var(--text-secondary);
}
#mafiaWinRoles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}
.mafia-role-item {
    background: var(--bg-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
}
.mafia-btn {
    background: var(--accent-orange);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

#mafiaFinaleClose {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: max-content;
    min-width: 180px;
    margin-top: 14px;
    padding: 18px 32px;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 12px;
}
.mafia-btn:hover { filter: brightness(0.95); }
.mafia-btn-secondary {
    background: #eee;
    color: var(--text-primary);
}

/* === УТИЛИТЫ === */
.hidden { display: none !important; }

/* === АДАПТИВ === */
@media (max-width: 1200px) {
    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }
    .sidebar-left, .sidebar-right {
        order: 3;
    }
    .sidebar-left { display: grid; grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .app-header {
        padding: 10px 16px;
        flex-wrap: wrap;
    }
    .header-nav { display: none; }
    .app-main { padding: 12px; gap: 12px; }
    .sidebar-left { grid-template-columns: 1fr; }
    .mafia-players-grid { grid-template-columns: repeat(3, 1fr); }
}

/* === ХЕДЕР: ДОПКНОПКИ === */
.header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-card);
    border: 1px solid #eee;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition);
    position: relative;
}
.icon-btn:hover {
    background: #fff6f0;
    border-color: var(--accent-orange);
    transform: translateY(-1px);
}
.crystals-btn {
    width: auto;
    padding: 0 10px;
    gap: 4px;
    font-weight: 600;
    color: #2196F3;
}
.crystals-btn span:first-child { font-size: 1.1rem; }
.user-avatar-wrapper {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 12px 4px 4px;
    background: var(--bg-card);
    border: 1px solid #eee;
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--transition);
}
.user-avatar-wrapper:hover { border-color: var(--accent-orange); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
}
.user-name { font-weight: 600; font-size: 0.9rem; }

/* === RECONNECT BUTTON === */
.reconnect-block {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 107, 43, 0.35);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.reconnect-block.hidden { display: none; }
.reconnect-block-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
.reconnect-btn {
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.reconnect-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 107, 43, 0.35);
}

/* === МОДАЛКИ === */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.18s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.modal-close {
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px; border-radius: 50%;
    border: none; background: #f0f0f0; cursor: pointer;
    font-size: 1.4rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #ffe0d0; }
.modal-title { font-size: 1.4rem; margin-bottom: 8px; }
.modal-subtitle { color: var(--text-secondary); margin-bottom: 18px; font-size: 0.95rem; }

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.modal-actions .btn-primary,
.modal-actions .btn-secondary {
    flex: 1 1 160px;
    width: auto;
}

.already-in-game-card {
    max-width: 440px;
    text-align: center;
}
.already-in-game-card .modal-title { margin-top: 6px; }
.already-in-game-hint {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: -4px 0 18px;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent-orange);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all var(--transition);
}
.btn-primary:hover { background: #e55a1e; transform: translateY(-1px); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; transform: none; }
.btn-secondary {
    background: white;
    color: var(--accent-orange);
    border: 1px solid var(--accent-orange);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary:hover { background: #fff6f0; }

/* === ПРОФИЛЬ === */
.profile-avatar-preview {
    display: flex; flex-direction: column;
    align-items: center; gap: 12px; margin-bottom: 20px;
}
.profile-avatar-large {
    width: 96px; height: 96px;
    border-radius: 50%;
    object-fit: cover;
    background: linear-gradient(135deg, #ff6b2b, #9C27B0);
    border: 3px solid white;
    box-shadow: var(--shadow);
}
.form-row { margin-bottom: 16px; }
.form-row label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-row input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
}
.form-row input:focus { border-color: var(--accent-orange); }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 18px 0;
}
.profile-stat {
    background: #f8f8f8;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
}
.profile-stat span { display: block; font-size: 0.8rem; color: var(--text-secondary); }
.profile-stat strong { font-size: 1.2rem; color: var(--accent-orange); }

/* === PROFILE MODAL EXTENDED === */
.profile-modal-card {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.chat-player-profile-card {
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
}

.profile-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.chat-player-profile-card .modal-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.profile-top3-slot {
    display: inline-flex;
    align-items: center;
    pointer-events: none;
}
.profile-top3-slot.hidden { display: none; }

.profile-top3-slot .top3-badge {
    width: 30px;
    height: 30px;
    font-size: 1rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.profile-top3-slot .top3-rank-num {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 5px;
    line-height: 1;
    min-width: 14px;
    text-align: center;
}

.chat-profile-period-filter {
    margin-top: 20px;
    margin-bottom: 16px;
}

.profile-cumulative-footer {
    margin-top: 18px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.profile-cumulative-footer .cumulative-title {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.profile-cumulative-footer .cumulative-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.profile-cumulative-footer .cumulative-stats strong {
    color: var(--accent-orange);
}

.profile-general-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.profile-stat-item {
    background: linear-gradient(180deg, #ffffff, #fafafa);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    padding: 16px 14px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.profile-stat-item .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-stat-item .stat-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2430;
}

.profile-period-filter {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    justify-content: center;
}

.period-btn {
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.period-btn:hover {
    border-color: var(--accent-orange);
}

.period-btn.active {
    background: var(--accent-orange);
    color: white;
    border-color: var(--accent-orange);
}

.profile-roles-stats {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 20px 0;
}

.profile-role-stat {
    background: linear-gradient(180deg, #ffffff, #fafafa);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 10px 22px rgba(0,0,0,0.05);
}

.role-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.role-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-icon {
    font-size: 1.5rem;
}

.role-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.role-progress-bar {
    width: 100%;
    height: 14px;
    background: linear-gradient(90deg, var(--role-track-start, #eceff3), var(--role-track-end, #f4f6f8));
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
    box-shadow: inset 0 0 0 1px var(--role-track-border, rgba(255,255,255,0.35));
}

.role-progress-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--role-fill-start, #ff6b2b), var(--role-fill-end, #ff8a50));
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15), 0 0 12px var(--role-fill-glow, rgba(255,107,43,0.35));
}

.role-win-rate {
    font-size: 1rem;
    font-weight: 800;
}

.role-stats-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* === DAILY REWARD === */
.daily-reward-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 18px 0;
}

.daily-reward-day {
    aspect-ratio: 1/1;
    background: #f8f8f8;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    position: relative;
    border: 2px solid transparent;
    transition: all var(--transition);
}

.daily-reward-day .day-num { font-size: 0.7rem; color: var(--text-secondary); }

.daily-reward-day .day-reward { font-weight: 700; color: var(--accent-blue); font-size: 0.85rem; }

.daily-reward-day.claimed { background: #e8f5e9; border-color: var(--accent-green); }

.daily-reward-day.claimed::after { content: '✓'; position: absolute; top: 2px; right: 4px; color: var(--accent-green); font-weight: 700; }

.daily-reward-day.today { background: linear-gradient(135deg, #fff3e0, #ffe0b2); border-color: var(--accent-orange); transform: scale(1.05); }

.daily-reward-day.locked { opacity: 0.5; }

.daily-reward-hint { text-align: center; font-size: 0.85rem; color: var(--text-secondary); margin-top: 12px; }

/* === РЕЙТИНГ === */
.rating-tabs { display: flex; gap: 6px; margin-bottom: 16px; }

.rating-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #eee;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.rating-tab.active { background: var(--accent-orange); color: white; border-color: var(--accent-orange); }

.rating-list { list-style: none; }

.rating-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.rating-item:last-child { border-bottom: none; }

.rating-rank {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    background: #f0f0f0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rating-rank.gold { background: linear-gradient(135deg, #FFD700, #FFA000); color: white; }
.rating-rank.silver { background: linear-gradient(135deg, #C0C0C0, #9E9E9E); color: white; }
.rating-rank.bronze { background: linear-gradient(135deg, #CD7F32, #8D6E63); color: white; }

.rating-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #ddd; }
.rating-avatar:hover { outline: 2px solid var(--accent-orange); }

.top3-badge {
    width: 22px; height: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    transition: transform 0.2s;
    position: relative;
}
.top3-badge.top3-gold {
    background: linear-gradient(135deg, #FFE17A, #FFC107);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.55);
    animation: top3-glow 2.2s ease-in-out infinite;
}
.top3-badge.top3-silver {
    background: linear-gradient(135deg, #E8E8E8, #B0B0B0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.top3-badge.top3-bronze {
    background: linear-gradient(135deg, #E0A57A, #B8732E);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.rating-item:hover .top3-badge, .top-item:hover .top3-badge { transform: scale(1.12); }
@keyframes top3-glow {
    0%, 100% { box-shadow: 0 2px 8px rgba(255, 193, 7, 0.55); }
    50% { box-shadow: 0 2px 14px rgba(255, 193, 7, 0.95); }
}

.rating-item-clickable, .top-item-clickable { cursor: pointer; transition: background 0.15s; }
.rating-item-clickable:hover, .top-item-clickable:hover { background: rgba(255, 107, 43, 0.08); }

.rating-name { flex: 1; font-weight: 500; cursor: pointer; }
.rating-name:hover { color: var(--accent-orange); }

.rating-score { font-weight: 700; color: var(--accent-orange); }

/* === ПОДАРКИ === */
.gifts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.gift-card {
    background: #f8f8f8;
    border-radius: 10px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.gift-card:hover { border-color: var(--accent-orange); transform: translateY(-2px); }

.gift-emoji { font-size: 2rem; }

.gift-name { font-size: 0.8rem; font-weight: 500; margin: 4px 0; }

.gift-price { font-size: 0.85rem; color: var(--accent-blue); font-weight: 600; }

/* === ЧАТ: УЛУЧШЕНИЯ === */
.chat-message {
    display: flex;
    gap: 10px;
    padding: 0;
    border-radius: 0;
    margin-bottom: 6px;
    animation: chatAppear 0.2s ease;
}

.chat-message:hover { background: transparent; }

@keyframes chatAppear { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: translateY(0) } }

.chat-message .avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

.chat-message .content { min-width: 0; }

.chat-message .author {
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 6px;
    color: var(--accent-orange);
}

.chat-message.bot .author { color: var(--accent-purple); }

.chat-message.bot .author::before { content: '🤖 '; font-size: 0.75rem; }

.chat-message .text { font-size: 0.9rem; word-wrap: break-word; overflow-wrap: anywhere; }

.chat-message.own { background: transparent; }

.chat-message.own .author {
    color: rgba(255,255,255,0.92);
    text-shadow: 0 1px 1px rgba(0,0,0,0.25);
}

/* === ЭМОДЗИ-ПИКЕР === */
.emoji-picker {
    width: 260px;
    max-width: 90vw;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    z-index: 1500;
    border: 1px solid #eee;
    box-sizing: border-box;
}

.emoji-pick {
    width: 100%;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition);
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

.emoji-pick:hover { background: #f0f0f0; }

/* === TOP NEDELI (SIDEBAR) === */
.top-list { list-style: none; padding: 0; margin: 0; }

.top-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.top-item:last-child { border-bottom: none; }

.top-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    object-fit: cover; background: #ddd; cursor: pointer;
}
.top-avatar:hover { outline: 2px solid var(--accent-orange); }

.top-item .top3-badge { width: 18px; height: 18px; font-size: 0.65rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }

.top-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; cursor: pointer; }
.top-name:hover { color: var(--accent-orange); }

.top-score { font-weight: 700; color: var(--accent-orange); font-size: 0.85rem; }

.top-empty { color: var(--text-secondary); font-size: 0.85rem; padding: 8px 4px; }

/* === БАННЕР-АРРОУ === */
.banner-slider { position: relative; }

.banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.95);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #333;
    padding: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    z-index: 5;
    transition: all var(--transition);
}

.banner-arrow svg { display: block; }

.banner-arrow:hover { background: white; transform: translateY(-50%) scale(1.08); }

.banner-arrow.left { left: 10px; }

.banner-arrow.right { right: 10px; }

/* Отступ текста баннера, чтобы стрелки не наезжали */
.banner-slide { padding-left: 80px !important; padding-right: 80px !important; }

/* Emoji-friendly шрифт для всех кнопок с иконками */
.icon-btn, .crystals-btn, .chat-send-btn, .chat-emoji-btn, .banner-arrow {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", system-ui, sans-serif;
}

.crystal-icon { color: #2196F3; }

/* === АНИМАЦИЯ МОДАЛОК (закрытие) === */
.modal-overlay.closing { animation: fadeOut 0.35s ease forwards; }

.modal-overlay.closing .modal { animation: modalScaleOut 0.35s ease forwards; }

@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

@keyframes modalScaleOut {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0.85); opacity: 0; }
}

/* Успех дейли — подсветка панели */
.daily-reward-grid.claimed-flash {
    animation: flashReward 0.8s ease;
}

@keyframes flashReward {
    0%, 100% { background: transparent; }
    50% { background: rgba(255, 215, 0, 0.2); box-shadow: 0 0 40px rgba(255,215,0,0.5); }
}

/* === MAFIA дополнения === */
.mafia-slot-wait {
    color: #bbb;
    font-size: 0.8rem;
    text-transform: lowercase;
}

.mafia-player-slot .mafia-player-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent-orange);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

.mafia-player-slot { position: relative; }

.mafia-start-btn {
    display: block;
    margin: 20px auto;
    padding: 14px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-orange), #e91e63);
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(255, 107, 43, 0.4);
}

.mafia-start-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 28px rgba(255, 107, 43, 0.5);
}

/* === BOTTOM SHEET (Создать игру) === */
.bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: white;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
    padding: 16px 24px 28px;
    z-index: 1200;
    max-width: 520px;
    margin: 0 auto;
    animation: slideUp 0.3s ease;
}

.bottom-sheet.hidden { display: none; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.bottom-sheet.closing { animation: slideDown 0.3s ease forwards; }

@keyframes slideDown { to { transform: translateY(100%); } }

.bottom-sheet-handle {
    width: 40px; height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 0 auto 12px;
}

.bottom-sheet-title {
    font-size: 1.2rem; font-weight: 700;
    margin-bottom: 16px; text-align: center;
}

.bottom-sheet-body { display: flex; flex-direction: column; gap: 12px; }

.field-row {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 0.9rem; color: var(--text-secondary);
}

.field-row.inline {
    flex-direction: row; align-items: center; gap: 10px;
    color: var(--text-primary); font-weight: 500;
    padding: 8px 12px;
    background: #f9f9f9;
    border-radius: 10px;
    cursor: pointer;
}

.field-row input[type="text"], .field-row select {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 0.95rem;
    background: white;
}

.field-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent-orange); }

.bottom-sheet-footer {
    display: flex; gap: 10px;
    margin-top: 18px;
}

.bottom-sheet-footer button { flex: 1; padding: 12px; border-radius: 12px; font-weight: 600; }

.btn-secondary {
    background: #f0f0f0; color: var(--text-primary); border: none; cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover { background: #e4e4e4; }

/* Подложка под bottom-sheet */
.sheet-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1100;
    animation: fadeIn 0.3s ease;
}

.sheet-backdrop.closing { animation: fadeOut 0.3s ease forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* === MAFIA STAGE (новый UI) === */
.mafia-stage-shell {
    background: #0b1020;
    color: #eef2ff;
    flex: 1 1 auto;
    min-height: 0;
    height: 100dvh;
    border-radius: 0;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.mafia-stage-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.mafia-stage-shell.has-game-chat .mafia-stage-body {
    grid-template-columns: minmax(0, 1fr) 320px;
}

.mafia-main-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
}

.mafia-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    flex: 0 0 auto;
}

.mafia-phase-pill {
    padding: 7px 16px;
    border-radius: 999px;
    background: #1c2548;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
}

.mafia-phase-pill.phase-night { background: linear-gradient(135deg,#1a237e,#4527a0); }

.mafia-phase-pill.phase-speech { background: linear-gradient(135deg,#ff8f00,#f57c00); }

.mafia-phase-pill.phase-vote { background: linear-gradient(135deg,#6a1b9a,#ad1457); }

.mafia-phase-pill.phase-reveal { background: linear-gradient(135deg,#00838f,#00695c); }

.mafia-phase-pill.phase-finished { background: linear-gradient(135deg,#388e3c,#1b5e20); }

.mafia-round { opacity: 0.8; font-size: 0.95rem; }

.mafia-my-role {
    padding: 6px 16px;
    border-radius: 999px;
    background: rgba(255,107,43,0.2);
    border: 2px solid #ff6b2b;
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffb74d;
}

.mafia-my-role.hidden {
    display: none;
}

.mafia-timer {
    font-family: monospace;
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffb74d;
    min-width: 80px;
    text-align: right;
}

.mafia-mobile-tabs {
    display: none;
    flex: 0 0 auto;
    gap: 8px;
    padding: 3px;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
}

.mafia-mobile-tab {
    flex: 1;
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: rgba(255,255,255,0.78);
    font-weight: 800;
    cursor: pointer;
}

.mafia-mobile-tab.active {
    background: #fff;
    color: #111827;
}

.mafia-phase-progress {
    height: 4px; background: rgba(255,255,255,0.1);
    border-radius: 4px; overflow: hidden;
}

.mafia-phase-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b2b, #ffb74d);
    width: 0%;
    transition: width 0.3s linear;
}

.mafia-vote-kick-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    color: #f5f7ff;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.mafia-vote-kick-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mafia-vote-kick-title {
    font-weight: 800;
    font-size: 0.98rem;
}

.mafia-vote-kick-target,
.mafia-vote-kick-stats,
.mafia-vote-kick-meta {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.82);
}

.mafia-vote-kick-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.mafia-vote-kick-btn {
    border: none;
    border-radius: 999px;
    padding: 9px 16px;
    font-weight: 700;
    cursor: pointer;
    color: white;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.mafia-vote-kick-btn:hover {
    transform: translateY(-1px);
}

.mafia-vote-kick-btn.is-yes {
    background: linear-gradient(135deg, #43a047, #66bb6a);
    box-shadow: 0 8px 18px rgba(67,160,71,0.25);
}

.mafia-vote-kick-btn.is-no {
    background: linear-gradient(135deg, #d32f2f, #ef5350);
    box-shadow: 0 8px 18px rgba(211,47,47,0.25);
}

.mafia-center-text {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffe082;
    padding: 4px 8px;
    min-height: 20px;
    flex: 0 0 auto;
}

/* Сетка игроков - по образцу рефа */
.mafia-players-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 4px 4px 0;
    flex: 1;
    align-content: start;
    min-height: 0;
    overflow: visible;
}

@media (max-width: 900px) {
    .mafia-players-grid { grid-template-columns: repeat(3, 1fr); }
}

.mafia-player-card {
    background: #1a2342;
    border-radius: 12px;
    padding: 10px 8px 8px;
    position: relative;
    text-align: center;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    overflow: visible;
    min-height: 116px;
}

.mafia-player-card.is-clickable { cursor: pointer; }

.mafia-player-card.is-clickable:hover {
    transform: translateY(-2px);
    border-color: #ff6b2b;
    box-shadow: 0 6px 20px rgba(255,107,43,0.3);
}

/* Пульсирующая оранжевая рамка — визуальный сигнал "кликни сюда".
   Помогает понять что нужно голосовать/действовать кликом по карточке. */
.mafia-player-card.is-clickable {
    animation: voteCardPulse 1.6s ease-in-out infinite;
}
@keyframes voteCardPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 43, 0.5), 0 0 0 1px rgba(255, 107, 43, 0.65);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(255, 107, 43, 0), 0 0 0 1px rgba(255, 107, 43, 0.65);
    }
}

.mafia-player-card.is-speaker {
    border-color: #ffd54f;
    box-shadow: 0 0 24px rgba(255,213,79,0.6);
    animation: speakerPulse 1.5s ease-in-out infinite;
}

@keyframes speakerPulse {
    0%, 100% { box-shadow: 0 0 18px rgba(255,213,79,0.4); }
    50% { box-shadow: 0 0 28px rgba(255,213,79,0.8); }
}

/* === ВЫКРИК (3-секундная реплика во время чужой речи) === */
.mafia-player-card.is-shouting {
    border-color: #ff3d00;
    box-shadow: 0 0 24px rgba(255, 61, 0, 0.85);
    animation: shoutingPulse 0.4s ease-in-out infinite;
}
@keyframes shoutingPulse {
    0%, 100% { box-shadow: 0 0 18px rgba(255, 61, 0, 0.5); }
    50% { box-shadow: 0 0 36px rgba(255, 61, 0, 0.95); }
}

/* Оверлей "ВЫКРИК" — отдельный элемент поверх активной карточки.
   Создаётся один раз и не пересоздаётся при смене спикера, поэтому
   не "мигает". Позиционируется JS-ом (top/left/width/height) на основе
   getBoundingClientRect() карточки активного крикуна. */
.mafia-shout-overlay {
    position: absolute;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 61, 0, 0.92), rgba(213, 0, 0, 0.92));
    color: white;
    border-radius: 12px;
    pointer-events: none;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.18s ease-out, transform 0.18s ease-out;
}
.mafia-shout-overlay.is-hidden {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}
.mafia-shout-overlay.is-active {
    animation: shoutBannerIn 0.18s ease-out;
}
@keyframes shoutBannerIn {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}
.mafia-shout-banner-text {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
    animation: shoutTextPulse 0.4s ease-in-out infinite;
}
@keyframes shoutTextPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}
.mafia-shout-banner-bar {
    position: absolute;
    left: 6px; right: 6px; bottom: 6px;
    height: 6px;
    background: rgba(0,0,0,0.35);
    border-radius: 999px;
    overflow: hidden;
}
.mafia-shout-banner-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffeb3b, #ffffff);
    border-radius: 999px;
    transform-origin: left center;
    transform: scaleX(1);
}

.mafia-btn-accent {
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    color: white;
}
.mafia-btn-accent:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.mafia-btn-accent:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
    transform: none;
}
.mafia-btn-shouting {
    background: linear-gradient(135deg, #ff3d00, #d50000) !important;
    color: white !important;
    animation: btnShout 0.3s ease-in-out infinite;
}
.mafia-btn-shouting::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 5px;
    background: rgba(0,0,0,0.35);
}
.mafia-btn-shouting::before {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    height: 5px;
    width: 100%;
    background: linear-gradient(90deg, #ffeb3b, #ffffff);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    transform-origin: left center;
    animation: shoutBarDrain 3s linear forwards;
}
@keyframes btnShout {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.mafia-player-card.is-talking { border-color: #4caf50; }

.mafia-player-card.is-dead { opacity: 0.45; filter: grayscale(0.8); }

.mafia-player-card.is-local { box-shadow: inset 0 0 0 2px #ff6b2b; padding-top: 24px; }

.mafia-player-card.is-mafia-ally { border-color: #e53935; background: linear-gradient(135deg,#3d1010,#1a2342); }

.mafia-player-card.is-check-red { border-color: #e53935; box-shadow: 0 0 18px rgba(229,57,53,0.5); }

.mafia-player-card.is-check-green { border-color: #4caf50; box-shadow: 0 0 18px rgba(76,175,80,0.5); }

.mafia-player-card.is-selected-vote-target {
    border-color: #ff6b2b;
    box-shadow: 0 0 0 2px rgba(255,107,43,0.35), 0 0 22px rgba(255,107,43,0.45);
}

.mafia-player-card.is-selected-night-target {
    border-color: #e53935;
    box-shadow: 0 0 0 2px rgba(229,57,53,0.3), 0 0 24px rgba(229,57,53,0.55);
}

.mafia-vote-choice-overlay {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 56px;
    pointer-events: none;
    z-index: 9;
}

.mafia-vote-choice-shade {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(6,10,20,0.12), rgba(6,10,20,0.88));
    backdrop-filter: blur(2px);
}

.mafia-vote-choice-number {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff7e8;
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.65);
}

.mafia-player-index {
    position: absolute; top: 6px; left: 6px;
    background: #ff6b2b; color: white;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem;
}

.mafia-player-photo {
    position: relative;
    width: clamp(52px, 8vh, 72px);
    height: clamp(52px, 8vh, 72px);
    margin: 0 auto 6px;
    border-radius: 50%;
    overflow: hidden;
    background: #0b1020;
}

.mafia-player-photo img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}

.mafia-player-avatar-img {
    cursor: pointer;
}

.mafia-dead-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
}

.mafia-role-overlay {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    border: 3px solid #0b1020;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 10;
}

.mafia-speaker-ring {
    position: absolute; inset: -4px;
    border: 3px solid #ffd54f;
    border-radius: 50%;
    animation: speakerRing 1.2s ease-in-out infinite;
    pointer-events: none;
}

.mafia-muted-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(11,16,32,0.95);
    border: 2px solid rgba(255,255,255,0.86);
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    font-size: 0.9rem;
    z-index: 11;
    pointer-events: none;
}

@keyframes speakerRing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

.mafia-player-name {
    font-size: 0.85rem;
    color: white;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

.mafia-vote-badge {
    position: absolute; top: 6px; right: 6px;
    background: #d32f2f; color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.mafia-player-card.is-local .mafia-vote-badge { top: 34px; }

.mafia-player-card.has-local-role-tag .mafia-muted-badge,
.mafia-player-card.has-vote-badge .mafia-muted-badge {
    top: 34px;
}

.mafia-player-card.has-local-role-tag.has-vote-badge .mafia-muted-badge {
    top: 62px;
}

.mafia-player-hover-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 12;
}

.mafia-player-card:hover .mafia-player-hover-actions,
.mafia-player-card:focus-within .mafia-player-hover-actions,
.mafia-player-card.is-volume-open .mafia-player-hover-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mafia-player-action {
    position: relative;
}

.mafia-player-action-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    background: rgba(11,16,32,0.9);
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0,0,0,0.28);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.mafia-player-action-btn:hover {
    transform: translateY(-1px);
    background: rgba(32,42,76,0.96);
    border-color: rgba(255,255,255,0.34);
}

.mafia-kick-btn {
    background: linear-gradient(135deg, rgba(211,47,47,0.95), rgba(239,83,80,0.95));
}

.mafia-volume-action {
    position: relative;
}

.mafia-volume-popover {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    transform: translateY(6px) scale(0.96);
    min-width: 132px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(11,16,32,0.96);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 14px 28px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.mafia-volume-popover::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -14px;
    height: 14px;
}

.mafia-volume-action:hover .mafia-volume-popover,
.mafia-volume-action.is-open .mafia-volume-popover,
.mafia-volume-action:focus-within .mafia-volume-popover {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.mafia-player-card.is-volume-open {
    z-index: 20;
}

.mafia-volume-popover-title {
    font-size: 0.74rem;
    font-weight: 700;
    color: rgba(255,255,255,0.76);
    margin-bottom: 8px;
}

.mafia-volume-slider {
    width: 100%;
    accent-color: #4a90e2;
}

.mafia-volume-value {
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    text-align: center;
}

.mafia-kick-badge {
    position: absolute;
    left: 50%;
    bottom: -10px;
    transform: translateX(-50%);
    padding: 3px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #d32f2f, #ef5350);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(211,47,47,0.28);
    z-index: 8;
}

.mafia-local-role-tag {
    position: absolute;
    top: 6px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: calc(100% - 42px);
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(255,107,43,0.92);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 12px rgba(0,0,0,0.28);
}

.mafia-local-role-tag span {
    font-size: 0.9rem;
    line-height: 1;
}

.mafia-ready-tag {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: #4caf50;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.mafia-you-tag {
    position: absolute; bottom: 6px; right: 6px;
    background: #ff6b2b; color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
}

.mafia-footer {
    display: flex; justify-content: center; gap: 10px;
    padding-top: 4px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.mafia-footer .mafia-btn {
    padding: 10px 22px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mafia-kick-decision {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin-top: 12px;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 14px;
    color: #fff;
}

.mafia-kick-decision-label {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
}

.mafia-kick-decision-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.mafia-kick-decision-buttons .mafia-btn {
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mafia-kick-decision-buttons .mafia-btn:disabled {
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.mafia-kick-decision-tally {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.78);
    text-align: center;
}

.mafia-btn-primary { background: linear-gradient(135deg,#ff6b2b,#e91e63); color: white; }

.mafia-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255,107,43,0.4); }

.mafia-btn-secondary { background: rgba(255,255,255,0.1); color: white; }

.mafia-btn-secondary:hover { background: rgba(255,255,255,0.18); }

/* Бейдж роли (при показе) */
.mafia-role-badge {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #111;
    padding: 24px 32px;
    border-radius: 20px;
    min-width: 320px;
    text-align: center;
    box-shadow: 0 16px 60px rgba(0,0,0,0.5);
    z-index: 100;
    animation: roleBadgePop 0.4s ease;
}

@keyframes roleBadgePop {
    from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.mafia-role-badge .role-icon { font-size: 3.5rem; margin-bottom: 8px; }

.mafia-role-badge .role-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }

.mafia-role-badge .role-descr { color: #666; font-size: 0.95rem; margin-bottom: 10px; }

.mafia-role-badge .role-allies { margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee; color: #333; }

/* Финал игры */
.mafia-finale {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 500;
    border-radius: 0;
    padding: 24px;
    box-sizing: border-box;
    overflow: hidden;
}

.mafia-finale-content {
    background: white;
    color: #111;
    padding: 24px 34px;
    border-radius: 18px;
    width: 100%;
    max-width: min(640px, calc(100vw - 64px));
    max-height: min(880px, calc(100dvh - 48px));
    min-height: 0;
    overflow: hidden;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.mafia-finale-content h2 { font-size: 1.8rem; margin-bottom: 16px; flex: 0 0 auto; }

.mafia-finale-leave-btn {
    margin-top: 20px;
    padding: 12px 28px;
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.mafia-finale-leave-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(233, 30, 99, 0.4);
    filter: brightness(1.08);
}
.mafia-finale-leave-btn:active { transform: translateY(0); }

.mafia-role-item {
    padding: 10px 12px;
    background: linear-gradient(180deg, var(--role-bg-start, #f8f8f8), var(--role-bg-end, #f1f1f1));
    border: 1px solid var(--role-border, rgba(0,0,0,0.06));
    box-shadow: 0 10px 22px rgba(0,0,0,0.05);
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 0.98rem;
    text-align: left;
    color: #1f2430;
    position: relative;
    overflow: hidden;
}

.mafia-role-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--role-accent, #d0d0d0);
}

/* === ФИНАЛ: список выживших/убитых === */
.mafia-finale-legend {
    background: #f0f4ff;
    border: 1px solid #c5d3f0;
    border-radius: 10px;
    padding: 6px 12px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #1a2340;
    text-align: left;
    flex: 0 0 auto;
}

#mafiaFinaleRoles {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 2px 4px;
}

.mafia-finale-section {
    margin-top: 8px;
    text-align: left;
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.mafia-finale-section-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #2a3050;
    padding: 4px 4px 6px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    margin-bottom: 6px;
    flex: 0 0 auto;
}

.mafia-finale-section-rows {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
}

.mafia-finale-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1.4fr) max-content 32px;
    align-items: center;
    row-gap: 1px;
    column-gap: 8px;
    padding: 4px 10px;
    border-radius: 10px;
    margin-bottom: 4px;
    text-align: left;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}

.mafia-finale-row.alive {
    background: linear-gradient(180deg, #f0fbf2, #e6f7eb);
    border-color: rgba(76, 175, 80, 0.3);
}

.mafia-finale-row.dead {
    background: linear-gradient(180deg, #faf0f0, #f5e6e6);
    border-color: rgba(229, 57, 53, 0.25);
    opacity: 0.85;
}

.mafia-finale-row.is-local {
    box-shadow: inset 0 0 0 2px rgba(255, 107, 43, 0.5);
}

.mafia-finale-row::before {
    content: none;
}

.mafia-finale-row {
    cursor: pointer;
    transition: background-color 0.15s;
}
.mafia-finale-row:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mafia-finale-avatar-wrap {
    width: 36px;
    height: 36px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mafia-finale-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #d8dee9;
    box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px transparent;
    position: relative;
    flex: 0 0 28px;
    overflow: hidden;
}

.mafia-finale-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.mafia-finale-row.dead .mafia-finale-avatar-img {
    filter: grayscale(0.8) brightness(0.7);
}

.mafia-finale-avatar.alive {
    box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px #4caf50;
}

.mafia-finale-avatar.dead {
    box-shadow: inset 0 0 0 2px #ffffff, 0 0 0 2px #e53935;
    background: #e6bcbc;
}

.mafia-finale-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: #1f2430;
    padding-left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mafia-finale-role {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.04);
    border: 1px solid var(--rc, rgba(0,0,0,0.1));
    color: var(--rc, #555);
    font-size: 0.78rem;
    font-weight: 600;
    width: max-content;
    white-space: nowrap;
}

.mafia-finale-role-icon {
    font-size: 0.85rem;
}

.mafia-finale-delta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffd54f, #ffb300);
    color: #1a1a1a;
    font-size: 0.78rem;
    font-weight: 800;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    flex: 0 0 32px;
}

.mafia-finale-when {
    grid-column: 2 / -1;
    font-size: 0.75rem;
    font-weight: 600;
    color: #5a5a5a;
    padding-left: 4px;
    margin-top: 1px;
    display: block;
    line-height: 1.15;
}

/* === ИГРОВОЙ ЧАТ === */
.mafia-game-chat {
    position: relative;
    width: 320px;
    min-height: 0;
    height: 100%;
    align-self: stretch;
    background: rgba(26, 35, 62, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    overflow: hidden;
}

.mafia-chat-header {
    padding: 16px;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.mafia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mafia-chat-messages .chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.mafia-chat-messages .chat-message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.mafia-chat-messages .chat-message .content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 88%;
    background: rgba(255,255,255,0.06);
    padding: 8px 12px;
    border-radius: 14px 14px 14px 6px;
}

.mafia-chat-messages .chat-message .author {
    font-weight: 700;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.96);
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.mafia-chat-messages .chat-message .text {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.88);
    word-wrap: break-word;
}

.mafia-chat-messages .chat-message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.mafia-chat-messages .chat-message.own .avatar {
    display: none;
}

.mafia-chat-messages .chat-message.own .content {
    background: linear-gradient(135deg, #4a90e2, #357abd);
    border-radius: 14px 14px 6px 14px;
}

.mafia-chat-messages .chat-message.own .author {
    color: rgba(255,255,255,0.96);
}

.mafia-chat-form {
    position: relative;
    padding: 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.mafia-chat-input {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 12px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}

.mafia-chat-input::placeholder {
    color: rgba(255,255,255,0.4);
}

.mafia-chat-input:focus {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
}

.mafia-chat-send {
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.mafia-chat-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,107,43,0.4);
}

.mafia-btn-danger {
    background: linear-gradient(135deg, #e53935, #c62828) !important;
}

.mafia-btn-danger:hover {
    box-shadow: 0 6px 20px rgba(229,57,53,0.4) !important;
}

@media (max-width: 1400px) {
    .mafia-stage-shell.has-game-chat .mafia-stage-body {
        grid-template-columns: minmax(0, 1fr) 280px;
    }
    .mafia-game-chat {
        width: 280px;
    }
}

@media (max-width: 1200px) {
    .mafia-stage-shell.has-game-chat .mafia-stage-body {
        grid-template-columns: minmax(0, 1fr);
    }
    .mafia-game-chat {
        min-height: 260px;
    }
}

@media (max-width: 760px), (max-height: 720px) {
    #mafiaStageShell,
    .mafia-stage-shell {
        padding: 8px;
        gap: 7px;
    }

    .mafia-top {
        flex-wrap: wrap;
        gap: 6px;
    }

    .mafia-phase-pill,
    .mafia-my-role {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .mafia-round {
        font-size: 0.78rem;
    }

    .mafia-timer {
        min-width: 58px;
        font-size: 1.25rem;
    }

    .mafia-center-text {
        font-size: 0.86rem;
        padding: 2px 4px;
        min-height: 18px;
    }

    .mafia-vote-kick-panel {
        padding: 8px;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .mafia-vote-kick-actions {
        justify-content: center;
    }

    .mafia-mobile-tabs:not(.hidden) {
        display: flex;
    }

    .mafia-stage-shell.has-game-chat .mafia-stage-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .mafia-stage-shell.has-game-chat .mafia-game-chat {
        display: none;
    }

    .mafia-stage-shell.has-game-chat.mobile-show-chat .mafia-main-panel {
        display: none;
    }

    .mafia-stage-shell.has-game-chat.mobile-show-chat .mafia-game-chat {
        display: flex;
        width: 100%;
        min-height: 0;
        height: 100%;
    }

    .mafia-players-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        padding: 3px 3px 0;
        align-content: stretch;
    }

    .mafia-player-card {
        min-height: 94px;
        padding: 8px 6px 6px;
        border-radius: 10px;
    }

    .mafia-player-card.is-local {
        padding-top: 22px;
    }

    .mafia-player-photo {
        width: clamp(42px, 9vh, 56px);
        height: clamp(42px, 9vh, 56px);
        margin-bottom: 5px;
    }

    .mafia-player-index {
        width: 20px;
        height: 20px;
        font-size: 0.68rem;
    }

    .mafia-player-name {
        font-size: 0.76rem;
    }

    .mafia-local-role-tag {
        font-size: 0.62rem;
        padding: 2px 6px;
    }

    .mafia-muted-badge {
        width: 24px;
        height: 24px;
        font-size: 0.78rem;
    }

    .mafia-footer {
        gap: 7px;
        padding-top: 2px;
    }

    .mafia-footer .mafia-btn {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 0.78rem;
        border-radius: 18px;
    }

    .mafia-kick-decision {
        gap: 8px;
        padding: 10px;
        margin-top: 6px;
    }

    .mafia-kick-decision-label {
        font-size: 0.88rem;
    }

    .mafia-kick-decision-buttons .mafia-btn {
        padding: 9px 12px;
        font-size: 0.78rem;
    }

    .mafia-chat-header {
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .mafia-chat-messages {
        padding: 10px;
    }
}

@media (max-width: 420px), (max-height: 620px) {
    .mafia-players-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mafia-player-card {
        min-height: 82px;
    }

    .mafia-player-photo {
        width: 42px;
        height: 42px;
    }
}

/* === GAME FINISHED STATS MODAL === */
.game-stats-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-stats-modal.show {
    opacity: 1;
}

.game-stats-card {
    width: 100%;
    max-width: min(620px, calc(100vw - 64px));
    min-height: auto;
    max-height: min(880px, calc(100dvh - 48px));
    border-radius: 22px;
    overflow-y: auto;
    padding: 28px clamp(18px, 4vw, 48px);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}

.game-stats-title {
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.game-stats-role {
    background: #f8f8f8;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.game-stats-role span {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.game-stats-role strong {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.game-stats-rewards {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.reward-item {
    background: linear-gradient(135deg, #ff6b2b, #e91e63);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reward-icon {
    font-size: 2rem;
}

.reward-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.game-stats-quests {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.game-stats-quests h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.quest-progress-item {
    margin-bottom: 12px;
}

.quest-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.quest-progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 4px;
}

.quest-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.5s ease;
}

.quest-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}

.game-stats-close {
    width: 100%;
    max-width: 420px;
    align-self: center;
    padding: 14px;
    font-size: 1rem;
}

@media (max-width: 760px) {
    .mafia-finale {
        align-items: stretch;
        padding: 12px;
    }

    .mafia-finale-content {
        max-width: 100%;
        max-height: 100%;
        border-radius: 18px;
        padding: 18px 18px 20px;
    }

    .game-stats-modal {
        align-items: stretch;
        padding: 0;
    }

    .game-stats-card {
        max-width: 100%;
        min-height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
}

.mafia-mention-panel {
    position: absolute;
    left: 10px;
    right: 52px;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(11,16,32,0.98);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 14px 32px rgba(0,0,0,0.38);
    z-index: 30;
}

.mafia-mention-panel.hidden {
    display: none;
}

.mafia-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: white;
    cursor: pointer;
    text-align: left;
}

.mafia-mention-item:hover,
.mafia-mention-item.is-selected {
    background: rgba(74,144,226,0.28);
}

.mafia-mention-item img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.mafia-own-mention {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 7px;
    background: rgba(255,213,79,0.28);
    color: #ffd54f;
    font-weight: 800;
}

.mafia-player-profile-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.58);
    z-index: 1000;
}

.mafia-player-profile-modal.hidden {
    display: none;
}

.mafia-player-profile-card {
    position: relative;
    width: min(340px, 100%);
    padding: 26px 22px 22px;
    border-radius: 20px;
    background: linear-gradient(180deg, #1a233e, #10182e);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 24px 70px rgba(0,0,0,0.45);
    color: white;
    text-align: center;
}

.mafia-player-profile-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: white;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
}

.mafia-player-profile-avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255,255,255,0.18);
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

.mafia-player-profile-name {
    margin-top: 14px;
    font-size: 1.35rem;
    font-weight: 800;
}

.mafia-player-profile-meta {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.mafia-player-profile-meta span {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.86);
    font-size: 0.85rem;
    font-weight: 700;
}
