/* --- ГЛОБАЛЬНЫЕ СТИЛИ --- */
:root { 
    --bg: #121212; --panel: #1e1e1e; --accent: #f1c40f; --text: #e0e0e0; --input-bg: #111; --border: #444;
    --btn-start-1: #2ecc71; --btn-del-1: #e74c3c;
}
body { background-color: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Убираем стрелки у input */
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.inline-input { width: 50px !important; height: 20px !important; padding: 0 5px !important; border: none !important; background: transparent !important; color: #fff !important; font-weight: bold; text-align: center; border-bottom: 1px solid #555 !important; border-radius: 0 !important; }

/* МОДАЛЬНОЕ ОКНО */
#setupModal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 9999; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal-content { background: #222; width: 750px; max-width: 95%; max-height: 95vh; padding: 15px 25px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,0.9); display: flex; flex-direction: column; gap: 8px; overflow-y: auto; scrollbar-width: none; }
.modal-content::-webkit-scrollbar { display: none; }
.modal-title { font-size: 20px; font-weight: bold; color: var(--accent); text-transform: uppercase; text-align: center; border-bottom: 1px solid #333; padding-bottom: 10px; margin: 0; }
.section-title { font-size: 13px; font-weight: bold; color: #fff; background: #333; padding: 4px 10px; border-radius: 4px; margin: 5px 0; text-align: center; }
.status-badge { font-size:12px; text-align:center; padding:5px; border:1px solid #333; background:#111; border-radius:4px; color: #aaa; }
.app-description { background: #2a2a2a; border-left: 4px solid var(--accent); padding: 10px 15px; border-radius: 4px; font-size: 13px; line-height: 1.4; color: #ccc; margin-bottom: 5px; }
.app-description b { color: #fff; }

.form-row { display: flex; gap: 20px; }
.form-col { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; font-weight: bold; color: #888; text-transform: uppercase; }

input[type="text"], input[type="number"], textarea { background: var(--input-bg); border: 1px solid var(--border); color: #fff; padding: 8px; border-radius: 6px; font-family: monospace; font-size: 13px; width: 100%; box-sizing: border-box; }
input[type="color"] { height: 32px; width: 100%; padding: 2px; cursor: pointer; border: 1px solid #555; border-radius: 4px; }
textarea { min-height: 50px; max-height: 200px; resize: none; overflow-y: hidden; transition: height 0.1s; }
textarea:disabled { opacity: 0.3; cursor: not-allowed; background: #000; }

.mode-switch { display: flex; gap: 5px; background: #111; padding: 4px; border-radius: 8px; border: 1px solid #333; }
.mode-btn { flex: 1; padding: 8px; border: none; background: transparent; color: #666; cursor: pointer; font-weight: bold; border-radius: 5px; transition: 0.2s; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
.mode-btn.active { background: #333; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.speed-settings { background: #1a1a1a; padding: 10px; border-radius: 8px; border: 1px solid #333; display: flex; flex-direction: column; gap: 6px; }
.speed-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #ccc; }
.speed-input { width: 50px; text-align: center; }
.design-settings { background: #1a1a1a; padding: 10px; border-radius: 8px; border: 1px solid #333; display: flex; flex-direction: column; gap: 8px; }
.color-row { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #ccc; }

.checkbox-container { display: flex; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.checkbox-group { display: flex; align-items: center; gap: 10px; cursor: pointer; background: #2a2a2a; padding: 8px 12px; border-radius: 6px; flex: 1; border: 1px solid #333; min-width: 140px; }
.checkbox-group:hover { border-color: #555; }
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.checkbox-title { font-weight:bold; color:#fff; font-size: 12px; }
.checkbox-desc { font-size:10px; color:#888; }
.start-btn { background: linear-gradient(to right, #e67e22, #d35400); border: none; padding: 12px; width: 100%; color: white; font-weight: bold; font-size: 16px; text-transform: uppercase; border-radius: 8px; cursor: pointer; margin-top: 10px; transition: 0.2s; }
.start-btn:hover { filter: brightness(1.1); transform: scale(1.01); }
.start-btn:disabled { filter: grayscale(100%); opacity: 0.7; cursor: not-allowed; }

/* HEADER */
header { height: 80px; background: #0f0f0f; border-bottom: 2px solid #333; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.6); flex-shrink: 0; z-index: 20; }
.logo { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #888; display: flex; align-items: center; gap: 10px; }
.logo-img { max-height: 50px; max-width: 150px; object-fit: contain; }
.logo-emoji { font-size: 24px; }
.header-center { text-align: center; background: #1a1a1a; padding: 5px 20px; border-radius: 8px; border: 1px solid #333; min-width: 200px; }
.live-time { font-family: 'Consolas', monospace; font-size: 32px; font-weight: 900; color: var(--accent); text-shadow: 0 0 15px rgba(241, 196, 15, 0.4); display: flex; justify-content: center; gap: 10px; }
.live-dot { width: 10px; height: 10px; background: #ff0000; border-radius: 50%; box-shadow: 0 0 10px #ff0000; animation: blink 1s infinite; margin-top: 10px; }
@keyframes blink { 50% { opacity: 0.3; } }
.live-date { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: #7f8c8d; font-weight: 600; margin-top: 2px; }
.header-right { justify-self: end; display: flex; gap: 10px; align-items: center; }

.action-btn { border: none; padding: 10px 20px; font-size: 13px; font-weight: bold; text-transform: uppercase; border-radius: 6px; cursor: pointer; transition: all 0.2s; color: white; box-shadow: 0 4px 6px rgba(0,0,0,0.3); background: #37474f; }
.action-btn:disabled { filter: grayscale(100%); opacity: 0.6; cursor: not-allowed; }
.btn-settings { background: #333; font-size: 12px; padding: 8px 15px; }
.action-btn.state-green { background: var(--btn-start-1); box-shadow: 0 0 15px var(--btn-start-1); }
.action-btn.state-red { background: var(--btn-del-1); animation: pulse-alert 1.5s infinite; }
@keyframes pulse-alert { 0% { box-shadow: 0 0 0 0 rgba(255,255,255, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(255,255,255, 0); } 100% { box-shadow: 0 0 0 0 rgba(255,255,255, 0); } }

#linkProfile { display: none; color: #4fc3f7; text-decoration: none; font-weight: bold; border: 1px solid #4fc3f7; padding: 8px 16px; border-radius: 6px; font-size: 13px; }
#linkProfile:hover { background: rgba(79, 195, 247, 0.1); }
#linksContainer { display: none; margin-top: 5px; }
.link-profile { color: #4fc3f7; text-decoration: none; font-weight: bold; border: 1px solid #4fc3f7; padding: 5px 12px; border-radius: 6px; font-size: 12px; white-space: nowrap; margin-left: 5px; }
.link-profile:hover { background: rgba(79, 195, 247, 0.1); }

/* WORKSPACE */
.workspace { display: flex; flex: 1; height: calc(100vh - 80px); overflow: hidden; }

/* ОБНОВЛЕННАЯ СЕТКА (FLEXBOX) - КАРТОЧКИ ЗАПОЛНЯЮТ ВСЁ */
#gridContainer { 
    flex: 3; background: #121212; overflow: hidden; 
    /* Меньше отступы, больше места */
    padding: 20px !important; 
    border-right: 2px solid #333; 
    position: relative; 
    display: flex; align-items: center; justify-content: center; 
    box-sizing: border-box; 
}
#grid { 
    display: flex; 
    flex-wrap: wrap; 
    /* Центрируем содержимое */
    justify-content: center; 
    align-content: center;   
    gap: 10px; 
    width: 100%; height: 100%; 
    transition: all 0.5s ease;
}
#grid.single-item { justify-content: center; align-items: center; }

#logContainer { flex: 1; background: #0a0a0a; display: flex; flex-direction: column; min-width: 300px; }
.log-header { padding: 12px; background: #1e1e1e; font-weight: bold; font-size: 13px; border-bottom: 1px solid #333; color: #888; display: flex; justify-content: space-between; }
#consoleLog { flex: 1; padding: 12px; overflow-y: auto; font-family: 'Consolas', monospace; font-size: 12px; line-height: 1.6; background: #0e0e0e; }
.log-line { margin-bottom: 5px; border-bottom: 1px solid #1a1a1a; padding-bottom: 2px; }
.msg-sys { color: #7f8c8d; } .msg-info { color: #3498db; } .msg-elim { color: #ff5252; } .msg-warn { color: #e67e22; }
.msg-success { color: #00e676; font-weight: bold; border: 1px dashed #00e676; padding: 5px; text-align: center; margin-top: 5px; display: block;}

/* CARD */
.card { 
    background: #1e1e1e; border-radius: 8px; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); border: 1px solid #333; 
    overflow: hidden; 
    /* РАЗМЕРЫ ЗАДАЮТСЯ JS, ЗДЕСЬ ТОЛЬКО БАЗА */
    box-sizing: border-box; position: relative; 
}
.card img { width: 80px; height: 80px; max-width: 90%; max-height: 80%; border-radius: 50%; object-fit: cover; border: 2px solid #444; margin-bottom: 5px; background: #222; transition: all 0.3s; }
.card .name { font-size: 12px; text-align: center; font-weight: 600; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 95%; }
.card.mini .name { display: none; }
.card.mini img { margin-bottom: 0; width: 100%; height: 100%; border-radius: 50%; border: none; }
.card.mini { border-radius: 50%; background: transparent; border: none; box-shadow: none; }
.card.micro img { border-width: 1px; }

/* WINNERS */
.card.winner-solo { width: 50vh !important; height: 50vh !important; max-width: 400px !important; max-height: 400px !important; z-index: 200; background: #2e7d32; border: 4px solid #ffd700; border-radius: 16px !important; box-shadow: 0 0 100px rgba(46, 204, 113, 0.6); opacity: 1 !important; filter: none !important; margin: auto; }
.card.winner-solo .name { display: block !important; font-size: 32px !important; margin-top: 25px; white-space: normal; }
.card.winner-solo img { width: 200px !important; height: 200px !important; border-radius: 50% !important; margin-bottom: 10px !important; border: 5px solid #fff; }
.card.winner-solo::before { content: "🏆 ПОБЕДИТЕЛЬ"; position: absolute; top: 6px; background: #ffd700; color: #000; padding: 6px 20px; border-radius: 30px; font-weight: 900; font-size: 16px; animation: bounce 1s infinite; z-index: 300; white-space: nowrap; box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.card.winner-group { background: #2e7d32; border: 3px solid #ffd700; z-index: 50; transform: scale(1.15); box-shadow: 0 0 30px rgba(46, 204, 113, 0.6); opacity: 1 !important; filter: none !important; }
.card.winner-group::before { content: "🏆 ПОБЕДИТЕЛЬ"; position: absolute; top: -12px; background: #ffd700; color: #000; padding: 4px 10px; border-radius: 10px; font-weight: bold; font-size: 11px; z-index: 300; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }

.card.eliminated-dynamic { animation: implode 0.4s forwards; }
@keyframes implode { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(0); opacity: 0; } }
.card.eliminated-static { background: #0f0f0f; opacity: 0.1; filter: grayscale(100%); border-color: #222; }
/* Статус: Нарушитель (Не подписан) */
.card.eliminated-bad::after {
    content: "НЕ ПОДПИСАН";
    
    /* --- ВАЖНЫЕ ИЗМЕНЕНИЯ ДЛЯ ЦЕНТРОВКИ --- */
    position: absolute;
    top: 50%;
    left: 50%;
    /* translate(-50%, -50%) сдвигает центр плашки в центр координат top/left */
    transform: translate(-50%, -50%) rotate(-15deg); 
    /* --------------------------------------- */

    font-family: Impact, sans-serif;
    font-size: 16px; /* Чуть увеличил для читаемости */
    letter-spacing: 1px;
    background: #c0392b;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    white-space: nowrap; /* Запрещает перенос текста, чтобы не ломалось */
    box-shadow: 0 4px 15px rgba(0,0,0,0.9);
    border: 2px solid white;
    opacity: 1;
    z-index: 50; /* Поверх аватарки */
}
.card.eliminated-bad { animation: shake-hard 0.5s; }
@keyframes shake-hard { 0% { transform: translate(0,0) rotate(0deg); } 25% { transform: translate(2px, 2px) rotate(2deg); } 75% { transform: translate(-2px, -2px) rotate(-2deg); } }

#manualTokenField { display: none; }