/* ============================================
   GLOBAL RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #111820;
    --bg-card: #161f2b;
    --bg-input: #0d141c;
    --bg-hover: #1c2a3a;
    --border-color: #2a3a4a;
    --text-primary: #e8edf5;
    --text-secondary: #8b9bb0;
    --text-muted: #5a6a7a;
    --accent-blue: #4a9eff;
    --accent-green: #2ecc71;
    --accent-red: #ff4757;
    --accent-gold: #f1c40f;
    --accent-purple: #a855f7;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    padding: 20px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 32px 40px;
}
@media (max-width: 768px) {
    .container { padding: 16px; }
    body { padding: 10px; }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 0 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 20, 0.85);
}
header h1 {
    font-size: 26px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
nav a { color: var(--text-secondary); text-decoration: none; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; transition: var(--transition); }
nav a:hover { color: var(--text-primary); background: var(--bg-hover); }
.theme-switcher select { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-color); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; transition: var(--transition); }
.theme-switcher select:hover { border-color: var(--accent-blue); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
@media (max-width: 992px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card { background: var(--bg-card); padding: 24px 20px; border-radius: var(--radius); border: 1px solid var(--border-color); text-align: center; transition: var(--transition); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple)); opacity: 0; transition: var(--transition); }
.stat-card:hover { transform: translateY(-4px); border-color: rgba(74, 158, 255, 0.3); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }
.stat-card h3 { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; margin-bottom: 6px; }
.stat-card p { font-size: 34px; font-weight: 800; background: linear-gradient(135deg, var(--accent-blue), #60b0ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.main-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-bottom: 32px; }
.main-grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 32px; }
@media (max-width: 992px) { .main-grid-3 { grid-template-columns: 1fr 1fr; } .main-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .main-grid-3 { grid-template-columns: 1fr; } }

.top-players, .site-chat, .games-history, .player-profile-card, .comments-section, .profile-card, .auth-box, .players-list {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.top-players:hover, .site-chat:hover, .games-history:hover { border-color: rgba(74, 158, 255, 0.15); }
.top-players h2, .site-chat h2, .games-history h2, .comments-section h2 { font-size: 18px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.top-players h2::after, .site-chat h2::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-color), transparent); }

table { width: 100%; border-collapse: collapse; }
th { color: var(--text-secondary); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; padding: 10px 12px; text-align: left; border-bottom: 2px solid var(--border-color); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
table a { color: var(--accent-blue); text-decoration: none; font-weight: 500; }
table a:hover { color: #60b0ff; text-decoration: underline; }

/* ===== ЧАТ ===== */
.site-chat { display: flex; flex-direction: column; }
.chat-header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.chat-header-bar h2 { margin: 0; font-size: 18px; font-weight: 700; }
.chat-count { font-size: 12px; color: var(--text-secondary, #8b949e); }
.chat-box { height: 400px !important; min-height: 400px !important; max-height: 400px !important; overflow-y: auto; background: var(--bg-input, #0d1117); border: 1px solid var(--border-color, #30363d); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; scroll-behavior: smooth; }
.chat-empty { text-align: center; padding: 30px 0; color: var(--text-secondary, #8b949e); }
.chat-message { padding: 6px 0; border-bottom: 1px solid rgba(42, 58, 74, 0.3); word-wrap: break-word; }
.chat-message:last-child { border-bottom: none; }
.chat-message strong { font-weight: 600; font-size: 13px; display: inline-block; }
.chat-message .time { color: var(--text-muted, #5a6a7a); font-size: 10px; margin-left: 8px; font-weight: 400; }
.chat-message p { margin: 3px 0 0 0; color: var(--text-primary, #e8edf5); font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-input-area { display: flex; flex-direction: column; gap: 8px; position: relative; }
#chatForm { display: flex; gap: 8px; align-items: stretch; }
#chatForm input { flex: 1; padding: 12px 16px; background: var(--bg-input, #0d1117); border: 1px solid var(--border-color, #30363d); border-radius: 8px; color: var(--text-primary, #e8edf5); font-size: 14px; outline: none; transition: all 0.2s; }
#chatForm input:focus { border-color: var(--accent-blue, #58a6ff); box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15); }
#chatForm button[type="submit"] { padding: 12px 24px; background: linear-gradient(135deg, var(--accent-blue, #58a6ff), #4a8bdb); border: none; border-radius: 8px; color: white; font-size: 18px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
#chatForm button[type="submit"]:hover { transform: scale(1.05); box-shadow: 0 4px 20px rgba(88, 166, 255, 0.4); }
.smile-btn { padding: 12px 16px; background: var(--bg-input, #0d1117); border: 1px solid var(--border-color, #30363d); color: var(--text-primary, #e8edf5); font-size: 20px; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.smile-btn:hover { background: rgba(88, 166, 255, 0.15); border-color: var(--accent-blue, #58a6ff); }
.smile-panel { position: absolute; bottom: 70px; left: 0; background: var(--bg-card, #161b22); border: 1px solid var(--border-color, #30363d); border-radius: 10px; padding: 10px; max-width: 340px; max-height: 200px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); z-index: 100; }
.smile-panel .emoji { cursor: pointer; font-size: 22px; padding: 4px 6px; border-radius: 6px; transition: 0.15s; user-select: none; }
.smile-panel .emoji:hover { background: rgba(88, 166, 255, 0.2); transform: scale(1.2); }
.chat-login-block { padding: 20px; text-align: center; background: var(--bg-input, #0d1117); border: 1px dashed var(--border-color, #30363d); border-radius: 8px; min-height: 100px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.chat-btn-login { padding: 8px 20px; background: linear-gradient(135deg, var(--accent-blue, #58a6ff), #4a8bdb); color: white; text-decoration: none; border-radius: 6px; font-size: 13px; font-weight: 600; }
.chat-btn-register { padding: 8px 20px; background: rgba(139, 148, 158, 0.15); color: var(--text-primary, #e8edf5); text-decoration: none; border-radius: 6px; font-size: 13px; font-weight: 600; }
.online-list { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-color, #30363d); }
.online-list h3 { font-size: 12px; color: var(--text-secondary, #8b949e); font-weight: 600; margin-bottom: 6px; }
.online-user-item { display: inline-block; padding: 1px 10px; border-radius: 12px; font-size: 12px; border: 1px solid var(--border-color, #30363d); background: var(--bg-input, #0d1117); margin: 2px 4px 2px 0; transition: 0.15s; }
.online-user-item:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.online-user-item.admin { color: #ff4444; border-color: rgba(255,68,68,0.3); }
.online-user-item.moderator { color: #58a6ff; border-color: rgba(88,166,255,0.3); }
.online-user-item.guest { color: #8b949e; }
.online-user-item.user { color: var(--text, #e6edf3); }

footer { margin-top: 30px; padding-top: 15px; border-top: 1px solid var(--border-color); text-align: center; color: var(--text-muted); font-size: 12px; }
/* ===== Активные лобби ===== */
.lobby-item { padding: 10px 12px; margin-bottom: 6px; border-radius: 8px; border: 1px solid transparent; transition: 0.15s; }
.lobby-item:hover { background: var(--bg-hover, #1c2a3a); border-color: var(--border-color, #30363d); }
.lobby-item.active { border-left: 3px solid #2ecc71; }
.lobby-item.completed { border-left: 3px solid #8b949e; opacity: 0.75; }

.lobby-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.lobby-name { font-weight: 600; font-size: 14px; }
.lobby-name .map-short { font-size: 11px; font-weight: 500; color: var(--accent, #58a6ff); background: rgba(88,166,255,0.1); padding: 1px 8px; border-radius: 10px; margin-left: 6px; }
.lobby-status { font-size: 11px; font-weight: 500; padding: 2px 10px; border-radius: 12px; white-space: nowrap; }
.lobby-status.active { background: rgba(46,204,113,0.15); color: #2ecc71; }
.lobby-status.completed { background: rgba(139,148,158,0.12); color: #8b949e; }

.lobby-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary, #8b949e); margin: 3px 0 4px 0; }
.lobby-meta span { display: inline-flex; align-items: center; gap: 3px; }

.lobby-players { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.lobby-players a { display: inline-block; padding: 1px 10px; background: var(--bg-input, #0d1117); border-radius: 12px; font-size: 12px; color: var(--text-secondary, #8b949e); text-decoration: none; border: 1px solid transparent; transition: 0.15s; }
.lobby-players a:hover { color: var(--accent, #58a6ff); border-color: var(--accent, #58a6ff); }