/* Общие настройки в стиле старых консолей */
body {
    margin: 0;
    padding: 0;
    background-color: #0b0214;
    color: #00ff66;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    overflow: hidden;
    height: 100vh;
    box-sizing: border-box;
}

/* Эффект ЭЛТ-телевизора поверх всего экрана */
.crt-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), 
                linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    z-index: 5;
    pointer-events: none;
    opacity: 0.6;
}

/* Главный контейнер */
.arcade-container {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px; /* Сжали расстояние между блоками */
    height: 100vh;
    min-height: 0;
}

/* Аркадная панель управления (СДЕЛАЛИ УЗКОЙ: внутренние отступы 6px вместо 15px) */
.arcade-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #130324;
    border: 4px solid #ff00ff;
    padding: 6px 20px; /* Панель стала тонкой полосой */
    box-shadow: inset 0 0 15px rgba(255, 0, 255, 0.3);
    z-index: 10;
}

.control-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

label {
    color: #ff00ff;
    text-shadow: 0 0 5px #ff00ff;
    white-space: nowrap;
    font-size: 10px;
}

.retro-select {
    background: #000;
    color: #00ff66;
    border: 2px solid #00ff66;
    font-family: 'Press Start 2P', monospace;
    padding: 5px 10px; /* Компактные отступы внутри селекта */
    outline: none;
    cursor: pointer;
    font-size: 11px;
    width: 500px;
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.retro-select:focus {
    border-color: #fff;
    box-shadow: 0 0 10px #00ff66;
}

#playerCountSelect,
#playerNumberSelect {
    width: 170px;
}

#challengeSelect {
    width: 250px;
}

.retro-btn {
    background: #00ff66;
    color: #000;
    border: none;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px; /* Сделали шрифт кнопок капельку меньше */
    font-weight: bold;
    padding: 6px 15px; /* Уменьшили высоту кнопок */
    cursor: pointer;
    box-shadow: 0 0 10px #00ff66;
    transition: all 0.1s ease;
}

.retro-btn:hover {
    background: #fff;
    box-shadow: 0 0 20px #fff;
}

.retro-btn:active {
    transform: scale(0.95);
}

/* ==========================================
   СЕТКА ДЛЯ МУЛЬТИПЛЕЕРА (Твоя оригинальная)
========================================== */
.grid-layout {
    display: grid;
    gap: 20px;
    width: 100%;
    z-index: 6;
}

.grid-1-players { grid-template-columns: 1fr; }
.grid-2-players { grid-template-columns: 1fr 1fr; }
.grid-3-players { grid-template-columns: 1fr 1fr; }
.grid-4-players { grid-template-columns: 1fr 1fr; }

.player-slot {
    background: #000;
    border: 4px solid #ffcc00;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
    position: relative;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
    z-index: 7;
}

.player-slot.active-user-slot {
    border-color: #00ffcc;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.6);
}

.player-slot.stream-slot {
    border-color: #ff0055;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

.player-label {
    position: absolute;
    top: -12px; left: 15px;
    background: #ffcc00;
    color: #000;
    padding: 2px 8px;
    font-size: 10px;
    z-index: 12;
    text-transform: uppercase;
    font-weight: bold;
}

.player-slot.active-user-slot .player-label {
    background: #00ffcc;
}

.player-slot.stream-slot .player-label {
    background: #ff0055;
    color: #fff;
}

.slot-content {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    image-rendering: pixelated;
    background: #000;
    z-index: 4;
}

video.slot-content {
    object-fit: contain;
}

/* Экран обратного отсчета */
.countdown-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#countdown-number {
    font-size: 100px;
    color: #ffcc00;
    text-shadow: 0 0 30px #ffcc00;
    font-family: 'Press Start 2P', monospace;
    animation: pulseCount 0.5s infinite alternate;
}

@keyframes pulseCount {
    0% { transform: scale(0.9); }
    100% { transform: scale(1.1); }
}

/* Кнопка челленджа особого цвета */
.retro-btn.challenge-trigger {
    background: #ffcc00;
    color: #000;
    box-shadow: 0 0 10px #ffcc00;
}
.retro-btn.challenge-trigger:hover {
    background: #fff;
    box-shadow: 0 0 25px #ffcc00;
}

/* Таблица лидеров соревнования */
.leaderboard-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    border-color: #ffcc00 !important;
    box-shadow: inset 0 0 15px rgba(255, 204, 0, 0.2) !important;
    gap: 10px !important;
}

.leaderboard-title {
    color: #ffcc00;
    font-size: 11px;
    margin-bottom: 5px;
}

.player-score-row {
    font-size: 10px;
    margin: 4px 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
}

/* ==========================================
   GRIDSTACK — РЕДАКТОР LAYOUT
   ========================================== */
/* Контейнер грида + бумажная grid-layout внутри */
#main-arena.gridstack-active {
    background: #0a020f;
    padding: 6px;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    /* GridStack сам управляет layout */
}

/* Переопределяем GridStack под ретро-стиль */
.grid-stack {
    background: #0a020f;
    width: 100%;
    height: 100%;
}

/* Единый холст-слой страницы (обычный режим): сетка лежит прямо на нём,
   без промежуточных обёрток/рамок. Масштабируется CSS zoom в fitPageCanvas. */
.page-canvas {
    flex: 0 0 auto;
    position: relative;
}

.grid-stack-item-content {
    background: transparent !important;
    border: none !important;
    overflow: hidden;
}

/* Кнопка удаления на виджете в режиме редактирования */
.widget-delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ff0055;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 50%;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 100;
    display: none;
    font-family: 'Press Start 2P', monospace;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.8);
}

.grid-stack-item.ui-draggable .widget-delete-btn,
.grid-stack-item.ui-resizable .widget-delete-btn {
    display: block;
}

/* Ручка перетаскивания */
.widget-handle {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 6px;
    background: rgba(255, 0, 255, 0.6);
    border-radius: 3px;
    cursor: grab;
    z-index: 50;
    display: none;
    box-shadow: 0 0 8px #ff00ff;
}

.grid-stack-item.ui-draggable .widget-handle {
    display: block;
}

/* Маркер изменения размера (уголок) */
.widget-resize-handle {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-right: 3px solid rgba(0, 255, 102, 0.6);
    border-bottom: 3px solid rgba(0, 255, 102, 0.6);
    cursor: nw-resize;
    z-index: 50;
    display: none;
}

.grid-stack-item.ui-resizable .widget-resize-handle {
    display: block;
}

/* Панель виджетов */
.widget-panel {
    border-color: #ff00ff !important;
    margin-top: 4px;
}

.widget-panel .control-row {
    flex-wrap: wrap;
    gap: 8px;
}

/* Анимация появления виджета */
@keyframes widgetAppear {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.grid-stack-item-content > div {
    animation: widgetAppear 0.2s ease-out;
}

/* Placeholder для пустых слотов при drag */
.grid-stack-placeholder {
    background: rgba(255, 0, 255, 0.15) !important;
    border: 2px dashed #ff00ff !important;
    border-radius: 8px !important;
}

/* ==========================================
   СТИЛИ РЕДАКТОРА (vanilla JS)
   ========================================== */
#main-arena.editing {
    background: #0a020f;
    padding: 6px;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.editor-widget {
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
    transition: box-shadow 0.15s;
}

.editor-widget .widget-inner {
    border-radius: 0;
}

.editor-widget:hover {
    box-shadow: 0 0 0 2px #ff00ff, 0 4px 20px rgba(255,0,255,0.3);
}

/* Placeholder при добавлении нового виджета */
@keyframes widgetPopIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.editor-widget {
    animation: widgetPopIn 0.2s ease-out;
}

/* Кнопки редактора */
.editor-toolbar {
    margin-top: 6px;
    border-top: 1px solid rgba(255,0,255,0.3);
    padding-top: 8px;
}

/* Критические исправления для окон (оригинал) */
#main-arena:not(.editing) {
    background: #0a020f;
    padding: 10px;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
}

.player-frame {
    background: #000;
    border: 4px solid #ffcc00;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
}

.player-frame .player-header {
    background: #130324;
    color: #ffcc00;
    padding: 8px 12px;
    font-size: 12px;
    border-bottom: 3px solid #ff00ff;
    flex-shrink: 0;
}

.player-frame iframe {
    width: 100%;
    height: calc(100% - 40px);
    border: none;
    flex-shrink: 1;
    min-height: 0;
}

.player-frame.ratio-16-9 {
    aspect-ratio: 16 / 9;
}

/* ==========================================
   РЕТРО-ЧЕКБОКСЫ ДЛЯ ФИЛЬТРА ПЛАТФОРМ
========================================== */
.retro-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #00ff66;
    font-size: 11px;
    user-select: none;
}

.retro-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #00ff66;
    background: #000;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.retro-checkbox input[type="checkbox"]:checked {
    background: #00ff66;
    box-shadow: 0 0 8px #00ff66;
}

.retro-checkbox input[type="checkbox"]:checked::after {
    content: "✔";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    font-size: 12px;
    font-weight: bold;
}

.retro-checkbox input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 8px #00ff66;
}

.retro-checkbox span {
    color: #00ff66;
    text-shadow: 0 0 5px #00ff66;
}

/* ==========================================
   НОВЫЙ DASHBOARD (замена editor.js)
   ========================================== */

/* Контейнер контента виджета */
.dashboard-widget-content {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Кнопка удаления виджета (редактирование) */
.gs-del {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    width: 22px !important;
    height: 22px !important;
    background: #ff0055 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 12px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(255,0,85,0.8) !important;
}

/* Кнопка настроек виджета (редактирование) */
.gs-settings {
    position: absolute !important;
    top: -8px !important;
    left: -8px !important;
    width: 22px !important;
    height: 22px !important;
    background: #00ff66 !important;
    color: #000 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(0,255,102,0.8) !important;
}

/* Кнопка студийного действия виджета (напр. «🎮» — открыть окно «Управление») */
.gs-studio-act {
    position: absolute !important;
    top: 20px !important;
    left: -8px !important;
    width: 22px !important;
    height: 22px !important;
    background: #ffcc00 !important;
    color: #000 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(255,204,0,0.8) !important;
}

.editing .gs-del,
.editing .gs-settings,
.editing .gs-studio-act {
    display: block !important;
}

/* Оверлей для iframe в режиме редактирования (чтобы не перехватывали drag) */
.edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: rgba(0,0,0,0.1);
    cursor: move;
}

/* GridStack styles */
.grid-stack {
    background: var(--dashboard-bg, #0a020f) !important;
    position: relative;
    z-index: 1;
}

/* ---------- Фон холста / сцены (картинка-GIF-видео) под сеткой ---------- */
/* Слой вставляется первым ребёнком хоста (#main-arena в студии, .page-canvas на странице) */
#main-arena {
    position: relative;
}
.canvas-bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ---------- Медиа-слой внутри виджета (фон контента: картинка/GIF/видео) ---------- */
.widget-media-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.widget-media-layer img,
.widget-media-layer video {
    width: 100%;
    height: 100%;
    display: block;
}
/* Когда у .widget-content (или слоя-виджета «Медиа/Фон») есть медиа-фон,
   остальное содержимое поднимаем над слоем */
.widget-has-media > *:not(.widget-media-layer) {
    position: relative;
    z-index: 1;
}
.grid-stack-item {
    background: transparent;
    border-radius: 6px;
    overflow: visible;
}
.grid-stack-item-content {
    background: transparent !important;
    border: none;
}
.dashboard-widget-content > div {
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

/* Клик-картинка: ссылка покрывает весь виджет, лёгкий hover-эффект */
.clickable-image-link {
    position: relative;
}
.clickable-image-link:hover img {
    filter: brightness(1.15);
}

/* Поля форм внутри виджетов наследуют шрифт и размер текста виджета
   (иначе input/select/button используют дефолтный размер браузера ~13px
   и не реагируют на «Размер шрифта (px)» в настройках виджета).
   Инлайн-стили вида font-size:..px в JS по-прежнему имеют приоритет. */
.dashboard-widget-content input,
.dashboard-widget-content select,
.dashboard-widget-content button,
.dashboard-widget-content textarea {
    font-family: inherit;
    font-size: inherit;
}

.grid-stack-placeholder {
    background: rgba(255,0,255,0.15) !important;
    border: 2px dashed #ff00ff !important;
    border-radius: 8px !important;
}

/* Floating Action Buttons (правый верхний угол) */
.fab-btn {
    width: 34px;
    height: 34px;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(255,0,255,0.6);
    transition: all 0.15s;
    font-family: 'Press Start 2P', monospace;
    line-height: 1;
    padding: 0;
    z-index: 99991;
}
.fab-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(255,0,255,1);
    border-color: #ff00ff;
}

/* Theme customizer panel */
.theme-customizer-panel input[type="range"] {
    accent-color: #ff00ff;
}

/* Settings modal */
.widget-settings-modal input:focus,
.widget-settings-modal select:focus {
    outline: none;
    border-color: #fff !important;
    box-shadow: 0 0 10px #ff00ff !important;
}

/* ==========================================
   ЭКСТРЕМАЛЬНОЕ СЖАТИЕ ВИДЖЕТОВ (minW/minH=1)
   ========================================== */

/* Предотвращаем выпадение контента за границы при сильном сжатии */
.grid-stack-item-content > div,
.grid-stack-item-content > div > div,
.dashboard-widget-content > div,
.dashboard-widget-content {
    min-width: 0 !important;
    min-height: 0 !important;
    overflow-y: hidden !important;
}

/* Виджеты с select — обрезаем текст опций, если не влезает */
.dashboard-widget-content select {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    text-overflow: ellipsis;
}

/* Лобби: кнопки и текст не ломают сетку при сильном сжатии.
   Классы (а не id) — виджет может встречаться несколько раз. */
.lobby-widget-body button {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-room-list > div {
    overflow: hidden;
}

.lobby-room-list > div > div {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-status {
    overflow: hidden;
}

/* Виджеты-кнопки (steal_save, customizer, lobby_page) — текст не вылезает */
.grid-stack-item-content button {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ranking: строки не разрывают layout */
.dashboard-widget-content > div > div {
    word-break: break-word;
    overflow: hidden;
}

/* Виджет чата — сообщения не ломают layout */
.chat-messages div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Game loader — drop zone адаптируется под размер */
#game-loader-input + div + div {
    min-height: 30px !important;
    padding: 4px !important;
    font-size: 6px !important;
}
/* ==========================================
   КОНТЕЙНЕР (вложенная сетка + прокрутка)
   ========================================== */

/* Скролл-поверхность внутри контейнера — может расти за пределы виджета */
.cw-scroll-surface {
    width: 100% !important;
    min-width: 100% !important;
    height: max-content !important;
    min-height: 100% !important;
}

/* Вложенная сетка контейнера */
.cw-nested-grid {
    background: transparent !important;
    height: 100%;
}
.cw-nested-grid .grid-stack-item-content {
    background: rgba(0,0,0,0.35) !important;
    border: 1px dashed rgba(255,0,255,0.25) !important;
    border-radius: 4px;
}

/* Крестик удаления вложенного виджета (edit mode) */
.gs-del-nested {
    position: absolute !important;
    top: -8px !important;
    right: -8px !important;
    width: 22px !important;
    height: 22px !important;
    background: #ff0055 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 12px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(255,0,85,0.8) !important;
}

/* Кнопка настроек вложенного виджета (edit mode) */
.gs-settings-nested {
    position: absolute !important;
    top: -8px !important;
    left: -8px !important;
    width: 22px !important;
    height: 22px !important;
    background: #00ff66 !important;
    color: #000 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(0,255,102,0.8) !important;
}

/* Кнопка дублирования вложенного виджета (edit mode) */
.gs-dup-nested {
    position: absolute !important;
    top: -8px !important;
    right: 18px !important;
    width: 22px !important;
    height: 22px !important;
    background: #ffcc00 !important;
    color: #000 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 11px !important;
    line-height: 18px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 999 !important;
    display: none !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 10px rgba(255,204,0,0.8) !important;
}
.gs-dup-nested:hover {
    transform: scale(1.1);
}

/* Подсветка выбранного вложенного виджета (OBS Studio) */
.cw-nested-grid .grid-stack-item.cw-child-selected {
    outline: 2px solid #00ff66 !important;
    outline-offset: -2px;
    box-shadow: 0 0 14px rgba(0,255,102,0.7) !important;
    z-index: 5 !important;
}

/* Кнопка «Добавить внутрь» в шапке контейнера */
.gs-add-nested {
    margin-left: auto !important;
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    align-items: center;
    justify-content: center;
    background: #00ff66 !important;
    color: #000 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    font-size: 10px !important;
    line-height: 1 !important;
    text-align: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    font-family: sans-serif !important;
    box-shadow: 0 0 8px rgba(0,255,102,0.8) !important;
}
.gs-add-nested:hover {
    transform: scale(1.1);
}

/* Меню добавления виджета внутрь контейнера */
.cw-nested-menu {
    font-family: 'Press Start 2P', monospace;
}
.cw-nested-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #eee;
    font-family: inherit;
    font-size: 9px;
    padding: 6px 8px;
    cursor: pointer;
    margin: 0 0 2px;
}
.cw-nested-menu button:hover {
    background: rgba(255,0,255,0.2) !important;
    border-color: #ff00ff !important;
    box-shadow: 0 0 8px rgba(255,0,255,0.4) !important;
}

/* ==========================================
   ПРАВАЯ ПАНЕЛЬ «ДОБАВИТЬ ВНУТРЬ» (контейнер)
   ========================================== */
#cw-add-panel {
    position: fixed;
    top: 34px;
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 99997;
    background: #0d0118;
    border-left: 2px solid #ff00ff;
    box-shadow: -8px 0 24px rgba(255,0,255,0.35);
    display: flex;
    flex-direction: column;
    font-family: 'Press Start 2P', monospace;
    box-sizing: border-box;
}
#cw-add-panel .cw-add-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #130324;
    border-bottom: 1px solid #ff00ff;
    flex-shrink: 0;
}
#cw-add-panel .cw-add-title { color: #ff00ff; font-size: 10px; flex: 1; text-shadow: 0 0 6px rgba(255,0,255,0.6); }
#cw-add-panel .cw-add-count { color: #00ff66; font-size: 8px; }
#cw-add-panel .cw-add-close {
    background: #ff0055; color: #fff; border: none; cursor: pointer;
    font-size: 10px; padding: 4px 8px; font-family: inherit;
}
#cw-add-panel .cw-add-close:hover { background: #ff3366; }
#cw-add-panel .cw-add-search {
    margin: 8px; padding: 8px; box-sizing: border-box;
    background: #000; color: #fff; border: 2px solid #444;
    font-family: inherit; font-size: 9px; flex-shrink: 0;
    outline: none;
}
#cw-add-panel .cw-add-search:focus { border-color: #ff00ff; }
#cw-add-panel .cw-add-qty {
    display: flex; align-items: center; gap: 6px;
    padding: 0 8px 8px; color: #ccc; font-size: 9px; flex-shrink: 0;
}
#cw-add-panel .cw-add-qty input {
    width: 72px; background: #000; color: #fff; border: 2px solid #444;
    padding: 6px; font-family: inherit; font-size: 9px;
}
#cw-add-panel .cw-add-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
#cw-add-panel .cw-add-type-btn {
    display: block; width: 100%; box-sizing: border-box; text-align: left;
    background: #0a0a0a; color: #ddd; border: 1px solid #333;
    padding: 8px 10px; margin-bottom: 4px; cursor: pointer;
    font-family: inherit; font-size: 9px;
}
#cw-add-panel .cw-add-type-btn:hover {
    background: rgba(255,0,255,0.15); border-color: #ff00ff; color: #fff;
}
#cw-add-panel .cw-add-empty { color: #888; font-size: 9px; padding: 10px; text-align: center; }
#cw-add-panel .cw-add-hint {
    color: #777; font-size: 8px; padding: 8px 10px;
    border-top: 1px solid #333; flex-shrink: 0;
}

/* Тонкие скроллбары внутри контейнера */
.cw-nested-grid,
.cw-scroll-surface {
    scrollbar-width: thin;
    scrollbar-color: #7a1fa2 #1a0430;
}
.cw-nested-grid::-webkit-scrollbar,
.cw-scroll-surface::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.cw-nested-grid::-webkit-scrollbar-track,
.cw-scroll-surface::-webkit-scrollbar-track {
    background: #1a0430;
}
.cw-nested-grid::-webkit-scrollbar-thumb,
.cw-scroll-surface::-webkit-scrollbar-thumb {
    background: #7a1fa2;
    border-radius: 6px;
}

/* ==========================================
   ВИДЫ ПРОКРУТКИ КОНТЕЙНЕРА
   ========================================== */

/* Скрыть нативные полосы в режимах со стрелками/затемнением */
.cw-scroll-mode-arrows,
.cw-scroll-mode-fade,
.cw-scroll-mode-arrows_fade {
    scrollbar-width: none;
}
.cw-scroll-mode-arrows::-webkit-scrollbar,
.cw-scroll-mode-fade::-webkit-scrollbar,
.cw-scroll-mode-arrows_fade::-webkit-scrollbar {
    display: none;
}

/* Оверлей управления прокруткой (стрелки/градиенты) */
.cw-scroll-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

/* Кнопки-стрелки по краям */
.cw-arrow-btn {
    position: absolute;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(10,2,20,0.55);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    user-select: none;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
}
.cw-arrow-btn.show {
    opacity: 0.85;
    pointer-events: auto;
}
.cw-arrow-btn:hover {
    opacity: 1;
    background: rgba(30,10,60,0.85);
    box-shadow: 0 0 12px rgba(255,0,255,0.55);
    border-color: #ff00ff;
}
.cw-arrow-left  { left: 4px;  top: 50%; transform: translateY(-50%); }
.cw-arrow-right { right: 4px; top: 50%; transform: translateY(-50%); }
.cw-arrow-up    { top: 4px;   left: 50%; transform: translateX(-50%); }
.cw-arrow-down  { bottom: 4px; left: 50%; transform: translateX(-50%); }

/* Градиенты-маски по краям */
.cw-fade-edge {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
}
.cw-fade-edge.show { opacity: 1; }
.cw-fade-left   { left: 0; top: 0; bottom: 0; width: 18px; }
.cw-fade-right  { right: 0; top: 0; bottom: 0; width: 18px; }
.cw-fade-top    { top: 0; left: 0; right: 0; height: 14px; }
.cw-fade-bottom { bottom: 0; left: 0; right: 0; height: 14px; }

