.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-panel {
    background: var(--card-bg);
    border: 1px solid #334155;
    border-bottom: none;
    color: var(--text-main);
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 474px;
    box-sizing: border-box;
}

.info-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.next-balls {
    display: flex;
    gap: 8px;
    align-items: center;
    background: rgba(15, 17, 26, 0.5);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #334155;
}

.next-preview {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #151722;
    box-shadow: inset -2px -2px 6px rgba(0,0,0,0.6);
    transition: background-color 0.3s ease;
}

#field {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    grid-template-rows: repeat(9, 50px);
    gap: 2px;
    background: #151722;
    padding: 6px;
    border: 1px solid #334155;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.cell {
    background: var(--card-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

/* Анимированный полноценный шарик */
.ball {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    position: absolute;
    z-index: 2;
    box-shadow: inset -5px -5px 12px rgba(0,0,0,0.5), 2px 4px 8px rgba(0,0,0,0.3);
    transform: scale(1);
    animation: ballSpawn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Маленький шарик-подсказка будущего спавна */
.ball-preview {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    z-index: 1;
    opacity: 0.45;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.4);
    animation: ballSpawn 0.3s ease-out forwards;
    pointer-events: none;
}

.cell.selected .ball {
    animation: bounce 0.6s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
}

/* Безопасное перемещение шарика без изменения inline-стилей top/left */
.ball.moving {
    z-index: 10;
    transition: transform 0.045s linear;
}

/* Безопасное и жесткое сопоставление цветов через CSS Классы/Атрибуты для CSP */
[data-ball-color="0"] { background-color: #e74c3c; }
[data-ball-color="1"] { background-color: #3498db; }
[data-ball-color="2"] { background-color: #2ecc71; }
[data-ball-color="3"] { background-color: #f1c40f; }
[data-ball-color="4"] { background-color: #9b59b6; }
[data-ball-color="5"] { background-color: #34495e; }
[data-ball-color="6"] { background-color: #e67e22; }

@keyframes ballSpawn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); }
}

@keyframes bounce {
    from { transform: scale(1.02) translateY(0); box-shadow: inset -5px -5px 12px rgba(0,0,0,0.5), 2px 4px 6px rgba(0,0,0,0.3); }
    to { transform: scale(0.98) translateY(-6px); box-shadow: inset -5px -5px 12px rgba(0,0,0,0.5), 2px 10px 12px rgba(0,0,0,0.15); }
}